71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
/**
|
|
* Tauri adapter for {@link SkillGateway} (L12).
|
|
*
|
|
* Commands use snake_case (Tauri convention); payload keys are camelCase
|
|
* (matching the backend DTO `#[serde(rename_all = "camelCase")]`), consistent
|
|
* with the other adapters in this directory. The `scope` value (`"global"` /
|
|
* `"project"`) maps directly onto the backend `SkillScope` serde enum.
|
|
*/
|
|
|
|
import { invoke } from "@tauri-apps/api/core";
|
|
|
|
import type { Skill, SkillScope } from "@/domain";
|
|
import type { CreateSkillInput, SkillGateway } from "@/ports";
|
|
|
|
export class TauriSkillGateway implements SkillGateway {
|
|
listSkills(projectId: string, scope: SkillScope): Promise<Skill[]> {
|
|
return invoke<Skill[]>("list_skills", { projectId, scope });
|
|
}
|
|
|
|
createSkill(input: CreateSkillInput): Promise<Skill> {
|
|
return invoke<Skill>("create_skill", {
|
|
request: {
|
|
projectId: input.projectId,
|
|
name: input.name,
|
|
content: input.content,
|
|
scope: input.scope,
|
|
},
|
|
});
|
|
}
|
|
|
|
updateSkill(
|
|
projectId: string,
|
|
scope: SkillScope,
|
|
skillId: string,
|
|
content: string,
|
|
): Promise<Skill> {
|
|
return invoke<Skill>("update_skill", {
|
|
request: { projectId, scope, skillId, content },
|
|
});
|
|
}
|
|
|
|
async deleteSkill(
|
|
projectId: string,
|
|
scope: SkillScope,
|
|
skillId: string,
|
|
): Promise<void> {
|
|
await invoke("delete_skill", { projectId, scope, skillId });
|
|
}
|
|
|
|
async assignSkill(
|
|
projectId: string,
|
|
agentId: string,
|
|
skillId: string,
|
|
scope: SkillScope,
|
|
): Promise<void> {
|
|
await invoke("assign_skill_to_agent", {
|
|
request: { projectId, agentId, skillId, scope },
|
|
});
|
|
}
|
|
|
|
async unassignSkill(
|
|
projectId: string,
|
|
agentId: string,
|
|
skillId: string,
|
|
): Promise<void> {
|
|
await invoke("unassign_skill_from_agent", {
|
|
request: { projectId, agentId, skillId },
|
|
});
|
|
}
|
|
}
|