@orchestrator-claude/sdk 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +170 -0
  2. package/dist/OrchestratorSDK.d.ts +69 -0
  3. package/dist/OrchestratorSDK.d.ts.map +1 -0
  4. package/dist/OrchestratorSDK.js +74 -0
  5. package/dist/OrchestratorSDK.js.map +1 -0
  6. package/dist/agents/AgentAPI.d.ts +119 -0
  7. package/dist/agents/AgentAPI.d.ts.map +1 -0
  8. package/dist/agents/AgentAPI.js +227 -0
  9. package/dist/agents/AgentAPI.js.map +1 -0
  10. package/dist/agents/index.d.ts +2 -0
  11. package/dist/agents/index.d.ts.map +1 -0
  12. package/dist/agents/index.js +2 -0
  13. package/dist/agents/index.js.map +1 -0
  14. package/dist/index.d.ts +27 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +26 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/skills/SkillAPI.d.ts +103 -0
  19. package/dist/skills/SkillAPI.d.ts.map +1 -0
  20. package/dist/skills/SkillAPI.js +194 -0
  21. package/dist/skills/SkillAPI.js.map +1 -0
  22. package/dist/skills/index.d.ts +2 -0
  23. package/dist/skills/index.d.ts.map +1 -0
  24. package/dist/skills/index.js +2 -0
  25. package/dist/skills/index.js.map +1 -0
  26. package/dist/types/Agent.d.ts +124 -0
  27. package/dist/types/Agent.d.ts.map +1 -0
  28. package/dist/types/Agent.js +5 -0
  29. package/dist/types/Agent.js.map +1 -0
  30. package/dist/types/Skill.d.ts +100 -0
  31. package/dist/types/Skill.d.ts.map +1 -0
  32. package/dist/types/Skill.js +5 -0
  33. package/dist/types/Skill.js.map +1 -0
  34. package/dist/types/Workflow.d.ts +225 -0
  35. package/dist/types/Workflow.d.ts.map +1 -0
  36. package/dist/types/Workflow.js +5 -0
  37. package/dist/types/Workflow.js.map +1 -0
  38. package/dist/types/index.d.ts +7 -0
  39. package/dist/types/index.d.ts.map +1 -0
  40. package/dist/types/index.js +5 -0
  41. package/dist/types/index.js.map +1 -0
  42. package/dist/workflows/WorkflowAPI.d.ts +134 -0
  43. package/dist/workflows/WorkflowAPI.d.ts.map +1 -0
  44. package/dist/workflows/WorkflowAPI.js +266 -0
  45. package/dist/workflows/WorkflowAPI.js.map +1 -0
  46. package/dist/workflows/index.d.ts +2 -0
  47. package/dist/workflows/index.d.ts.map +1 -0
  48. package/dist/workflows/index.js +2 -0
  49. package/dist/workflows/index.js.map +1 -0
  50. package/package.json +25 -0
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # @orchestrator/sdk
2
+
3
+ Programmatic SDK for Orchestrator - Create and manage agents, workflows, and skills via code.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @orchestrator/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { OrchestratorSDK } from '@orchestrator/sdk';
15
+
16
+ // Initialize SDK
17
+ const sdk = new OrchestratorSDK({ projectPath: '.' });
18
+
19
+ // Create an agent
20
+ const agent = sdk.agents.create({
21
+ name: 'my-agent',
22
+ displayName: 'My Custom Agent',
23
+ prompt: 'You are a helpful assistant...',
24
+ capabilities: ['code-generation', 'documentation']
25
+ });
26
+
27
+ await sdk.agents.save(agent);
28
+ ```
29
+
30
+ ## Features
31
+
32
+ - **Type-safe API**: Full TypeScript support with strict types
33
+ - **Fluent interface**: Chainable methods for easy usage
34
+ - **Event-driven**: Emits domain events for observability
35
+ - **Local & Remote**: Supports both local file and remote API modes
36
+
37
+ ## API Overview
38
+
39
+ ### Agents API
40
+
41
+ ```typescript
42
+ // Create agent
43
+ const agent = sdk.agents.create({
44
+ name: 'code-reviewer',
45
+ prompt: 'You are an expert code reviewer...',
46
+ capabilities: ['code-review', 'security-analysis'],
47
+ tools: ['git', 'grep']
48
+ });
49
+
50
+ await sdk.agents.save(agent);
51
+
52
+ // List agents
53
+ const agents = await sdk.agents.list({ tier: 'user' });
54
+
55
+ // Get agent
56
+ const agent = await sdk.agents.get('code-reviewer');
57
+
58
+ // Clone agent
59
+ const cloned = await sdk.agents.clone('specifier', 'my-specifier', {
60
+ prompt: 'Custom prompt...'
61
+ });
62
+
63
+ // Delete agent
64
+ await sdk.agents.delete('my-agent');
65
+ ```
66
+
67
+ ### Workflows API
68
+
69
+ ```typescript
70
+ // Create workflow definition
71
+ const definition = sdk.workflows.createDefinition({
72
+ name: 'Custom Workflow',
73
+ description: 'A custom development workflow',
74
+ phases: [
75
+ { id: 'research', name: 'Research', agent: 'researcher' },
76
+ { id: 'plan', name: 'Plan', agent: 'planner' },
77
+ { id: 'implement', name: 'Implement', agent: 'implementer' }
78
+ ],
79
+ approvalPoints: [
80
+ { beforePhase: 'implement', message: 'Approve implementation?' }
81
+ ]
82
+ });
83
+
84
+ await sdk.workflows.saveDefinition(definition);
85
+
86
+ // Start workflow instance
87
+ const workflow = await sdk.workflows.start('custom-workflow', 'project-123');
88
+
89
+ // Get workflow instance
90
+ const instance = await sdk.workflows.getInstance(workflow.id);
91
+
92
+ // List definitions
93
+ const definitions = await sdk.workflows.listDefinitions({ tier: 'user' });
94
+
95
+ // List instances
96
+ const instances = await sdk.workflows.listInstances({ status: 'active' });
97
+ ```
98
+
99
+ ### Skills API
100
+
101
+ ```typescript
102
+ // Create skill
103
+ const skill = sdk.skills.create({
104
+ name: 'code-analyzer',
105
+ description: 'Analyzes code quality',
106
+ trigger: {
107
+ type: 'command',
108
+ value: 'analyze-code'
109
+ },
110
+ promptTemplate: 'Analyze this code for quality and security: {{input}}'
111
+ });
112
+
113
+ await sdk.skills.save(skill);
114
+
115
+ // List skills
116
+ const skills = await sdk.skills.list({ triggerType: 'command' });
117
+
118
+ // Get skill
119
+ const skill = await sdk.skills.get('code-analyzer');
120
+
121
+ // Delete skill
122
+ await sdk.skills.delete('my-skill');
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ ```typescript
128
+ const sdk = new OrchestratorSDK({
129
+ // Project root path (default: process.cwd())
130
+ projectPath: '/path/to/project',
131
+
132
+ // API URL for remote mode (optional)
133
+ apiUrl: 'https://api.orchestrator.dev',
134
+
135
+ // Operation mode (default: 'local')
136
+ mode: 'local' // or 'remote'
137
+ });
138
+ ```
139
+
140
+ ## Type Definitions
141
+
142
+ All SDK types are fully typed with TypeScript:
143
+
144
+ ```typescript
145
+ import type {
146
+ AgentDefinition,
147
+ CreateAgentConfig,
148
+ WorkflowDefinition,
149
+ CreateWorkflowDefinitionConfig,
150
+ SkillDefinition,
151
+ CreateSkillConfig
152
+ } from '@orchestrator/sdk';
153
+ ```
154
+
155
+ ## Examples
156
+
157
+ See the [examples](./examples) directory for complete usage examples:
158
+
159
+ - `create-agent.ts` - Create custom agents
160
+ - `create-workflow.ts` - Create workflow definitions
161
+ - `start-workflow.ts` - Start and manage workflows
162
+ - `create-skill.ts` - Create custom skills
163
+
164
+ ## Documentation
165
+
166
+ See [API Documentation](./docs/API.md) for detailed API reference.
167
+
168
+ ## License
169
+
170
+ MIT
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Main entry point for Orchestrator SDK
3
+ */
4
+ import { AgentAPI } from './agents/AgentAPI.js';
5
+ import { WorkflowAPI } from './workflows/WorkflowAPI.js';
6
+ import { SkillAPI } from './skills/SkillAPI.js';
7
+ /**
8
+ * SDK configuration options
9
+ */
10
+ export interface SDKConfig {
11
+ /**
12
+ * Project root path. Defaults to current working directory.
13
+ */
14
+ projectPath?: string;
15
+ /**
16
+ * API URL for remote mode
17
+ */
18
+ apiUrl?: string;
19
+ /**
20
+ * Operation mode: local file system or remote API
21
+ * @default 'local'
22
+ */
23
+ mode?: 'local' | 'remote';
24
+ }
25
+ /**
26
+ * Main SDK class providing access to all Orchestrator APIs
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const sdk = new OrchestratorSDK({ projectPath: '.' });
31
+ * const agent = sdk.agents.create({ name: 'my-agent', prompt: '...' });
32
+ * await sdk.agents.save(agent);
33
+ * ```
34
+ */
35
+ export declare class OrchestratorSDK {
36
+ private readonly config;
37
+ private _agents?;
38
+ private _workflows?;
39
+ private _skills?;
40
+ /**
41
+ * Create a new SDK instance
42
+ *
43
+ * @param config - SDK configuration options
44
+ */
45
+ constructor(config?: SDKConfig);
46
+ /**
47
+ * Get the Agent API for managing agent definitions
48
+ *
49
+ * Lazily initialized on first access.
50
+ */
51
+ get agents(): AgentAPI;
52
+ /**
53
+ * Get the Workflow API for managing workflow definitions and instances
54
+ *
55
+ * Lazily initialized on first access.
56
+ */
57
+ get workflows(): WorkflowAPI;
58
+ /**
59
+ * Get the Skill API for managing skill definitions
60
+ *
61
+ * Lazily initialized on first access.
62
+ */
63
+ get skills(): SkillAPI;
64
+ /**
65
+ * Get the current SDK configuration
66
+ */
67
+ getConfig(): Readonly<Required<SDKConfig>>;
68
+ }
69
+ //# sourceMappingURL=OrchestratorSDK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrchestratorSDK.d.ts","sourceRoot":"","sources":["../src/OrchestratorSDK.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAW;IAC3B,OAAO,CAAC,UAAU,CAAC,CAAc;IACjC,OAAO,CAAC,OAAO,CAAC,CAAW;IAE3B;;;;OAIG;gBACS,MAAM,CAAC,EAAE,SAAS;IAQ9B;;;;OAIG;IACH,IAAI,MAAM,IAAI,QAAQ,CAKrB;IAED;;;;OAIG;IACH,IAAI,SAAS,IAAI,WAAW,CAK3B;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,QAAQ,CAKrB;IAED;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;CAG3C"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Main entry point for Orchestrator SDK
3
+ */
4
+ import { AgentAPI } from './agents/AgentAPI.js';
5
+ import { WorkflowAPI } from './workflows/WorkflowAPI.js';
6
+ import { SkillAPI } from './skills/SkillAPI.js';
7
+ /**
8
+ * Main SDK class providing access to all Orchestrator APIs
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const sdk = new OrchestratorSDK({ projectPath: '.' });
13
+ * const agent = sdk.agents.create({ name: 'my-agent', prompt: '...' });
14
+ * await sdk.agents.save(agent);
15
+ * ```
16
+ */
17
+ export class OrchestratorSDK {
18
+ config;
19
+ _agents;
20
+ _workflows;
21
+ _skills;
22
+ /**
23
+ * Create a new SDK instance
24
+ *
25
+ * @param config - SDK configuration options
26
+ */
27
+ constructor(config) {
28
+ this.config = {
29
+ projectPath: config?.projectPath ?? process.cwd(),
30
+ apiUrl: config?.apiUrl ?? '',
31
+ mode: config?.mode ?? 'local',
32
+ };
33
+ }
34
+ /**
35
+ * Get the Agent API for managing agent definitions
36
+ *
37
+ * Lazily initialized on first access.
38
+ */
39
+ get agents() {
40
+ if (!this._agents) {
41
+ this._agents = new AgentAPI(this.config.projectPath);
42
+ }
43
+ return this._agents;
44
+ }
45
+ /**
46
+ * Get the Workflow API for managing workflow definitions and instances
47
+ *
48
+ * Lazily initialized on first access.
49
+ */
50
+ get workflows() {
51
+ if (!this._workflows) {
52
+ this._workflows = new WorkflowAPI(this.config.projectPath);
53
+ }
54
+ return this._workflows;
55
+ }
56
+ /**
57
+ * Get the Skill API for managing skill definitions
58
+ *
59
+ * Lazily initialized on first access.
60
+ */
61
+ get skills() {
62
+ if (!this._skills) {
63
+ this._skills = new SkillAPI(this.config.projectPath);
64
+ }
65
+ return this._skills;
66
+ }
67
+ /**
68
+ * Get the current SDK configuration
69
+ */
70
+ getConfig() {
71
+ return { ...this.config };
72
+ }
73
+ }
74
+ //# sourceMappingURL=OrchestratorSDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrchestratorSDK.js","sourceRoot":"","sources":["../src/OrchestratorSDK.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAuBhD;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAsB;IACrC,OAAO,CAAY;IACnB,UAAU,CAAe;IACzB,OAAO,CAAY;IAE3B;;;;OAIG;IACH,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG;YACZ,WAAW,EAAE,MAAM,EAAE,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE;YACjD,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;YAC5B,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,OAAO;SAC9B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Agent API for managing agent definitions
3
+ */
4
+ import type { AgentDefinition, CreateAgentConfig, AgentFilter } from '../types/Agent.js';
5
+ /**
6
+ * API for creating and managing agent definitions
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const agent = sdk.agents.create({
11
+ * name: 'code-reviewer',
12
+ * prompt: 'You are an expert code reviewer...',
13
+ * capabilities: ['code-review', 'security-analysis']
14
+ * });
15
+ * await sdk.agents.save(agent);
16
+ * ```
17
+ */
18
+ export declare class AgentAPI {
19
+ private readonly _projectPath;
20
+ constructor(_projectPath: string);
21
+ /**
22
+ * Get project path (used by repository implementations)
23
+ * @internal
24
+ */
25
+ protected getProjectPath(): string;
26
+ /**
27
+ * Create a new agent definition
28
+ *
29
+ * @param config - Agent configuration
30
+ * @returns Agent definition (not yet persisted)
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const agent = sdk.agents.create({
35
+ * name: 'My Agent',
36
+ * prompt: 'You are a helpful assistant...'
37
+ * });
38
+ * ```
39
+ */
40
+ create(config: CreateAgentConfig): AgentDefinition;
41
+ /**
42
+ * Save an agent definition to the repository
43
+ *
44
+ * @param agent - Agent definition to save
45
+ * @throws {Error} If agent is invalid or cannot be saved
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * await sdk.agents.save(agent);
50
+ * ```
51
+ */
52
+ save(agent: AgentDefinition): Promise<void>;
53
+ /**
54
+ * List all agent definitions
55
+ *
56
+ * @param filter - Optional filter criteria
57
+ * @returns Array of agent definitions
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const agents = await sdk.agents.list({ tier: 'user' });
62
+ * ```
63
+ */
64
+ list(filter?: AgentFilter): Promise<AgentDefinition[]>;
65
+ /**
66
+ * Get a specific agent by slug
67
+ *
68
+ * @param slug - Agent slug
69
+ * @returns Agent definition or null if not found
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const agent = await sdk.agents.get('my-agent');
74
+ * ```
75
+ */
76
+ get(slug: string): Promise<AgentDefinition | null>;
77
+ /**
78
+ * Clone an existing agent with optional overrides
79
+ *
80
+ * @param sourceSlug - Source agent slug
81
+ * @param newSlug - New agent slug
82
+ * @param overrides - Optional configuration overrides
83
+ * @returns New agent definition
84
+ * @throws {Error} If source agent not found
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const cloned = await sdk.agents.clone('specifier', 'my-specifier', {
89
+ * prompt: 'Custom prompt...'
90
+ * });
91
+ * ```
92
+ */
93
+ clone(sourceSlug: string, newSlug: string, overrides?: Partial<CreateAgentConfig>): Promise<AgentDefinition>;
94
+ /**
95
+ * Delete an agent definition
96
+ *
97
+ * @param slug - Agent slug to delete
98
+ * @throws {Error} If agent is builtin or cannot be deleted
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * await sdk.agents.delete('my-agent');
103
+ * ```
104
+ */
105
+ delete(slug: string): Promise<void>;
106
+ /**
107
+ * Validate agent configuration
108
+ */
109
+ private validateConfig;
110
+ /**
111
+ * Validate agent definition
112
+ */
113
+ private validateAgent;
114
+ /**
115
+ * Convert name to slug format
116
+ */
117
+ private slugify;
118
+ }
119
+ //# sourceMappingURL=AgentAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentAPI.d.ts","sourceRoot":"","sources":["../../src/agents/AgentAPI.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAQ;IAEP,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,MAAM;IAEjD;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,MAAM;IAIlC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe;IAqBlD;;;;;;;;;;OAUG;IACG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjD;;;;;;;;;;OAUG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAM5D;;;;;;;;;;OAUG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAUxD;;;;;;;;;;;;;;;OAeG;IACG,KAAK,CACT,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,OAAO,CAAC,eAAe,CAAC;IAkC3B;;;;;;;;;;OAUG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAczC;;OAEG;IACH,OAAO,CAAC,cAAc;IAsBtB;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB;;OAEG;IACH,OAAO,CAAC,OAAO;CAQhB"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Agent API for managing agent definitions
3
+ */
4
+ /**
5
+ * API for creating and managing agent definitions
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const agent = sdk.agents.create({
10
+ * name: 'code-reviewer',
11
+ * prompt: 'You are an expert code reviewer...',
12
+ * capabilities: ['code-review', 'security-analysis']
13
+ * });
14
+ * await sdk.agents.save(agent);
15
+ * ```
16
+ */
17
+ export class AgentAPI {
18
+ _projectPath;
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ constructor(_projectPath) {
21
+ this._projectPath = _projectPath;
22
+ }
23
+ /**
24
+ * Get project path (used by repository implementations)
25
+ * @internal
26
+ */
27
+ getProjectPath() {
28
+ return this._projectPath;
29
+ }
30
+ /**
31
+ * Create a new agent definition
32
+ *
33
+ * @param config - Agent configuration
34
+ * @returns Agent definition (not yet persisted)
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const agent = sdk.agents.create({
39
+ * name: 'My Agent',
40
+ * prompt: 'You are a helpful assistant...'
41
+ * });
42
+ * ```
43
+ */
44
+ create(config) {
45
+ this.validateConfig(config);
46
+ const slug = this.slugify(config.name);
47
+ const now = new Date().toISOString();
48
+ return {
49
+ slug,
50
+ name: config.name,
51
+ ...(config.displayName && { displayName: config.displayName }),
52
+ ...(config.description && { description: config.description }),
53
+ prompt: config.prompt,
54
+ ...(config.capabilities && { capabilities: config.capabilities }),
55
+ ...(config.tools && { tools: config.tools }),
56
+ ...(config.modelPreference && { modelPreference: config.modelPreference }),
57
+ tier: config.tier ?? 'user',
58
+ createdAt: now,
59
+ updatedAt: now,
60
+ };
61
+ }
62
+ /**
63
+ * Save an agent definition to the repository
64
+ *
65
+ * @param agent - Agent definition to save
66
+ * @throws {Error} If agent is invalid or cannot be saved
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * await sdk.agents.save(agent);
71
+ * ```
72
+ */
73
+ async save(agent) {
74
+ this.validateAgent(agent);
75
+ // TODO: Implement persistence via repository
76
+ // For now, just validate
77
+ console.log(`[SDK] Would save agent: ${agent.slug}`);
78
+ }
79
+ /**
80
+ * List all agent definitions
81
+ *
82
+ * @param filter - Optional filter criteria
83
+ * @returns Array of agent definitions
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const agents = await sdk.agents.list({ tier: 'user' });
88
+ * ```
89
+ */
90
+ async list(filter) {
91
+ // TODO: Implement via repository
92
+ console.log(`[SDK] Would list agents with filter:`, filter);
93
+ return [];
94
+ }
95
+ /**
96
+ * Get a specific agent by slug
97
+ *
98
+ * @param slug - Agent slug
99
+ * @returns Agent definition or null if not found
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const agent = await sdk.agents.get('my-agent');
104
+ * ```
105
+ */
106
+ async get(slug) {
107
+ if (!slug || typeof slug !== 'string') {
108
+ throw new Error('Agent slug is required and must be a string');
109
+ }
110
+ // TODO: Implement via repository
111
+ console.log(`[SDK] Would get agent: ${slug}`);
112
+ return null;
113
+ }
114
+ /**
115
+ * Clone an existing agent with optional overrides
116
+ *
117
+ * @param sourceSlug - Source agent slug
118
+ * @param newSlug - New agent slug
119
+ * @param overrides - Optional configuration overrides
120
+ * @returns New agent definition
121
+ * @throws {Error} If source agent not found
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const cloned = await sdk.agents.clone('specifier', 'my-specifier', {
126
+ * prompt: 'Custom prompt...'
127
+ * });
128
+ * ```
129
+ */
130
+ async clone(sourceSlug, newSlug, overrides) {
131
+ const source = await this.get(sourceSlug);
132
+ if (!source) {
133
+ throw new Error(`Source agent not found: ${sourceSlug}`);
134
+ }
135
+ if (await this.get(newSlug)) {
136
+ throw new Error(`Agent with slug '${newSlug}' already exists`);
137
+ }
138
+ const now = new Date().toISOString();
139
+ // Build cloned agent with only defined optional properties
140
+ const displayName = overrides?.displayName ?? source.displayName;
141
+ const description = overrides?.description ?? source.description;
142
+ const capabilities = overrides?.capabilities ?? source.capabilities;
143
+ const tools = overrides?.tools ?? source.tools;
144
+ const modelPreference = overrides?.modelPreference ?? source.modelPreference;
145
+ return {
146
+ slug: newSlug,
147
+ name: overrides?.name ?? source.name,
148
+ ...(displayName !== undefined && { displayName }),
149
+ ...(description !== undefined && { description }),
150
+ prompt: overrides?.prompt ?? source.prompt,
151
+ ...(capabilities !== undefined && { capabilities }),
152
+ ...(tools !== undefined && { tools }),
153
+ ...(modelPreference !== undefined && { modelPreference }),
154
+ tier: 'user', // Clones are always user-tier
155
+ createdAt: now,
156
+ updatedAt: now,
157
+ };
158
+ }
159
+ /**
160
+ * Delete an agent definition
161
+ *
162
+ * @param slug - Agent slug to delete
163
+ * @throws {Error} If agent is builtin or cannot be deleted
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * await sdk.agents.delete('my-agent');
168
+ * ```
169
+ */
170
+ async delete(slug) {
171
+ const agent = await this.get(slug);
172
+ if (!agent) {
173
+ throw new Error(`Agent not found: ${slug}`);
174
+ }
175
+ if (agent.tier === 'builtin') {
176
+ throw new Error('Cannot delete builtin agents');
177
+ }
178
+ // TODO: Implement via repository
179
+ console.log(`[SDK] Would delete agent: ${slug}`);
180
+ }
181
+ /**
182
+ * Validate agent configuration
183
+ */
184
+ validateConfig(config) {
185
+ if (!config.name || typeof config.name !== 'string') {
186
+ throw new Error('Agent name is required and must be a string');
187
+ }
188
+ if (!config.prompt || typeof config.prompt !== 'string') {
189
+ throw new Error('Agent prompt is required and must be a string');
190
+ }
191
+ if (config.name.length < 3) {
192
+ throw new Error('Agent name must be at least 3 characters');
193
+ }
194
+ if (config.prompt.length < 10) {
195
+ throw new Error('Agent prompt must be at least 10 characters');
196
+ }
197
+ if (config.tier && !['user', 'community'].includes(config.tier)) {
198
+ throw new Error('Agent tier must be "user" or "community"');
199
+ }
200
+ }
201
+ /**
202
+ * Validate agent definition
203
+ */
204
+ validateAgent(agent) {
205
+ if (!agent.slug || typeof agent.slug !== 'string') {
206
+ throw new Error('Agent slug is required');
207
+ }
208
+ if (!agent.name || typeof agent.name !== 'string') {
209
+ throw new Error('Agent name is required');
210
+ }
211
+ if (!agent.prompt || typeof agent.prompt !== 'string') {
212
+ throw new Error('Agent prompt is required');
213
+ }
214
+ }
215
+ /**
216
+ * Convert name to slug format
217
+ */
218
+ slugify(name) {
219
+ return name
220
+ .toLowerCase()
221
+ .trim()
222
+ .replace(/[^a-z0-9\s-]/g, '')
223
+ .replace(/\s+/g, '-')
224
+ .replace(/-+/g, '-');
225
+ }
226
+ }
227
+ //# sourceMappingURL=AgentAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentAPI.js","sourceRoot":"","sources":["../../src/agents/AgentAPI.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAQ;IAEU;IAD7B,6DAA6D;IAC7D,YAA6B,YAAoB;QAApB,iBAAY,GAAZ,YAAY,CAAQ;IAAG,CAAC;IAErD;;;OAGG;IACO,cAAc;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAErC,OAAO;YACL,IAAI;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;YAC9D,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;YAC9D,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;YACjE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC;YAC1E,IAAI,EAAE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AED,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;OAEG;IACK,OAAO,CAAC,IAAY;QAC1B,OAAO,IAAI;aACR,WAAW,EAAE;aACb,IAAI,EAAE;aACN,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;aAC5B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export { AgentAPI } from './AgentAPI.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { AgentAPI } from './AgentAPI.js';
2
+ //# sourceMappingURL=index.js.map