pilotswarm-sdk 0.1.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 (183) hide show
  1. package/dist/agent-loader.d.ts +61 -0
  2. package/dist/agent-loader.d.ts.map +1 -0
  3. package/dist/agent-loader.js +212 -0
  4. package/dist/agent-loader.js.map +1 -0
  5. package/dist/artifact-tools.d.ts +31 -0
  6. package/dist/artifact-tools.d.ts.map +1 -0
  7. package/dist/artifact-tools.js +190 -0
  8. package/dist/artifact-tools.js.map +1 -0
  9. package/dist/blob-store.d.ts +73 -0
  10. package/dist/blob-store.d.ts.map +1 -0
  11. package/dist/blob-store.js +220 -0
  12. package/dist/blob-store.js.map +1 -0
  13. package/dist/client.d.ts +159 -0
  14. package/dist/client.d.ts.map +1 -0
  15. package/dist/client.js +676 -0
  16. package/dist/client.js.map +1 -0
  17. package/dist/cms.d.ts +129 -0
  18. package/dist/cms.d.ts.map +1 -0
  19. package/dist/cms.js +313 -0
  20. package/dist/cms.js.map +1 -0
  21. package/dist/index.d.ts +44 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +42 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/managed-session.d.ts +70 -0
  26. package/dist/managed-session.d.ts.map +1 -0
  27. package/dist/managed-session.js +717 -0
  28. package/dist/managed-session.js.map +1 -0
  29. package/dist/management-client.d.ts +171 -0
  30. package/dist/management-client.d.ts.map +1 -0
  31. package/dist/management-client.js +401 -0
  32. package/dist/management-client.js.map +1 -0
  33. package/dist/mcp-loader.d.ts +50 -0
  34. package/dist/mcp-loader.d.ts.map +1 -0
  35. package/dist/mcp-loader.js +83 -0
  36. package/dist/mcp-loader.js.map +1 -0
  37. package/dist/model-providers.d.ts +143 -0
  38. package/dist/model-providers.d.ts.map +1 -0
  39. package/dist/model-providers.js +228 -0
  40. package/dist/model-providers.js.map +1 -0
  41. package/dist/orchestration-registry.d.ts +7 -0
  42. package/dist/orchestration-registry.d.ts.map +1 -0
  43. package/dist/orchestration-registry.js +49 -0
  44. package/dist/orchestration-registry.js.map +1 -0
  45. package/dist/orchestration.d.ts +36 -0
  46. package/dist/orchestration.d.ts.map +1 -0
  47. package/dist/orchestration.js +1357 -0
  48. package/dist/orchestration.js.map +1 -0
  49. package/dist/orchestration_1_0_0.d.ts +20 -0
  50. package/dist/orchestration_1_0_0.d.ts.map +1 -0
  51. package/dist/orchestration_1_0_0.js +497 -0
  52. package/dist/orchestration_1_0_0.js.map +1 -0
  53. package/dist/orchestration_1_0_1.d.ts +19 -0
  54. package/dist/orchestration_1_0_1.d.ts.map +1 -0
  55. package/dist/orchestration_1_0_1.js +546 -0
  56. package/dist/orchestration_1_0_1.js.map +1 -0
  57. package/dist/orchestration_1_0_10.d.ts +36 -0
  58. package/dist/orchestration_1_0_10.d.ts.map +1 -0
  59. package/dist/orchestration_1_0_10.js +1253 -0
  60. package/dist/orchestration_1_0_10.js.map +1 -0
  61. package/dist/orchestration_1_0_11.d.ts +36 -0
  62. package/dist/orchestration_1_0_11.d.ts.map +1 -0
  63. package/dist/orchestration_1_0_11.js +1255 -0
  64. package/dist/orchestration_1_0_11.js.map +1 -0
  65. package/dist/orchestration_1_0_12.d.ts +36 -0
  66. package/dist/orchestration_1_0_12.d.ts.map +1 -0
  67. package/dist/orchestration_1_0_12.js +1250 -0
  68. package/dist/orchestration_1_0_12.js.map +1 -0
  69. package/dist/orchestration_1_0_13.d.ts +36 -0
  70. package/dist/orchestration_1_0_13.d.ts.map +1 -0
  71. package/dist/orchestration_1_0_13.js +1260 -0
  72. package/dist/orchestration_1_0_13.js.map +1 -0
  73. package/dist/orchestration_1_0_14.d.ts +36 -0
  74. package/dist/orchestration_1_0_14.d.ts.map +1 -0
  75. package/dist/orchestration_1_0_14.js +1258 -0
  76. package/dist/orchestration_1_0_14.js.map +1 -0
  77. package/dist/orchestration_1_0_15.d.ts +36 -0
  78. package/dist/orchestration_1_0_15.d.ts.map +1 -0
  79. package/dist/orchestration_1_0_15.js +1266 -0
  80. package/dist/orchestration_1_0_15.js.map +1 -0
  81. package/dist/orchestration_1_0_16.d.ts +36 -0
  82. package/dist/orchestration_1_0_16.d.ts.map +1 -0
  83. package/dist/orchestration_1_0_16.js +1275 -0
  84. package/dist/orchestration_1_0_16.js.map +1 -0
  85. package/dist/orchestration_1_0_17.d.ts +36 -0
  86. package/dist/orchestration_1_0_17.d.ts.map +1 -0
  87. package/dist/orchestration_1_0_17.js +1314 -0
  88. package/dist/orchestration_1_0_17.js.map +1 -0
  89. package/dist/orchestration_1_0_18.d.ts +36 -0
  90. package/dist/orchestration_1_0_18.d.ts.map +1 -0
  91. package/dist/orchestration_1_0_18.js +1328 -0
  92. package/dist/orchestration_1_0_18.js.map +1 -0
  93. package/dist/orchestration_1_0_19.d.ts +36 -0
  94. package/dist/orchestration_1_0_19.d.ts.map +1 -0
  95. package/dist/orchestration_1_0_19.js +1324 -0
  96. package/dist/orchestration_1_0_19.js.map +1 -0
  97. package/dist/orchestration_1_0_2.d.ts +19 -0
  98. package/dist/orchestration_1_0_2.d.ts.map +1 -0
  99. package/dist/orchestration_1_0_2.js +749 -0
  100. package/dist/orchestration_1_0_2.js.map +1 -0
  101. package/dist/orchestration_1_0_20.d.ts +36 -0
  102. package/dist/orchestration_1_0_20.d.ts.map +1 -0
  103. package/dist/orchestration_1_0_20.js +1347 -0
  104. package/dist/orchestration_1_0_20.js.map +1 -0
  105. package/dist/orchestration_1_0_3.d.ts +19 -0
  106. package/dist/orchestration_1_0_3.d.ts.map +1 -0
  107. package/dist/orchestration_1_0_3.js +826 -0
  108. package/dist/orchestration_1_0_3.js.map +1 -0
  109. package/dist/orchestration_1_0_4.d.ts +19 -0
  110. package/dist/orchestration_1_0_4.d.ts.map +1 -0
  111. package/dist/orchestration_1_0_4.js +1020 -0
  112. package/dist/orchestration_1_0_4.js.map +1 -0
  113. package/dist/orchestration_1_0_5.d.ts +19 -0
  114. package/dist/orchestration_1_0_5.d.ts.map +1 -0
  115. package/dist/orchestration_1_0_5.js +1027 -0
  116. package/dist/orchestration_1_0_5.js.map +1 -0
  117. package/dist/orchestration_1_0_6.d.ts +19 -0
  118. package/dist/orchestration_1_0_6.d.ts.map +1 -0
  119. package/dist/orchestration_1_0_6.js +1034 -0
  120. package/dist/orchestration_1_0_6.js.map +1 -0
  121. package/dist/orchestration_1_0_7.d.ts +19 -0
  122. package/dist/orchestration_1_0_7.d.ts.map +1 -0
  123. package/dist/orchestration_1_0_7.js +1085 -0
  124. package/dist/orchestration_1_0_7.js.map +1 -0
  125. package/dist/orchestration_1_0_8.d.ts +36 -0
  126. package/dist/orchestration_1_0_8.d.ts.map +1 -0
  127. package/dist/orchestration_1_0_8.js +1106 -0
  128. package/dist/orchestration_1_0_8.js.map +1 -0
  129. package/dist/orchestration_1_0_9.d.ts +36 -0
  130. package/dist/orchestration_1_0_9.d.ts.map +1 -0
  131. package/dist/orchestration_1_0_9.js +1207 -0
  132. package/dist/orchestration_1_0_9.js.map +1 -0
  133. package/dist/prompt-layering.d.ts +16 -0
  134. package/dist/prompt-layering.d.ts.map +1 -0
  135. package/dist/prompt-layering.js +60 -0
  136. package/dist/prompt-layering.js.map +1 -0
  137. package/dist/resourcemgr-tools.d.ts +27 -0
  138. package/dist/resourcemgr-tools.d.ts.map +1 -0
  139. package/dist/resourcemgr-tools.js +638 -0
  140. package/dist/resourcemgr-tools.js.map +1 -0
  141. package/dist/session-dumper.d.ts +26 -0
  142. package/dist/session-dumper.d.ts.map +1 -0
  143. package/dist/session-dumper.js +272 -0
  144. package/dist/session-dumper.js.map +1 -0
  145. package/dist/session-manager.d.ts +152 -0
  146. package/dist/session-manager.d.ts.map +1 -0
  147. package/dist/session-manager.js +493 -0
  148. package/dist/session-manager.js.map +1 -0
  149. package/dist/session-proxy.d.ts +68 -0
  150. package/dist/session-proxy.d.ts.map +1 -0
  151. package/dist/session-proxy.js +665 -0
  152. package/dist/session-proxy.js.map +1 -0
  153. package/dist/session-store.d.ts +35 -0
  154. package/dist/session-store.d.ts.map +1 -0
  155. package/dist/session-store.js +88 -0
  156. package/dist/session-store.js.map +1 -0
  157. package/dist/skills.d.ts +31 -0
  158. package/dist/skills.d.ts.map +1 -0
  159. package/dist/skills.js +93 -0
  160. package/dist/skills.js.map +1 -0
  161. package/dist/sweeper-tools.d.ts +28 -0
  162. package/dist/sweeper-tools.d.ts.map +1 -0
  163. package/dist/sweeper-tools.js +332 -0
  164. package/dist/sweeper-tools.js.map +1 -0
  165. package/dist/types.d.ts +498 -0
  166. package/dist/types.d.ts.map +1 -0
  167. package/dist/types.js +9 -0
  168. package/dist/types.js.map +1 -0
  169. package/dist/worker.d.ts +128 -0
  170. package/dist/worker.d.ts.map +1 -0
  171. package/dist/worker.js +562 -0
  172. package/dist/worker.js.map +1 -0
  173. package/package.json +74 -0
  174. package/plugins/mgmt/agents/pilotswarm.agent.md +59 -0
  175. package/plugins/mgmt/agents/resourcemgr.agent.md +111 -0
  176. package/plugins/mgmt/agents/sweeper.agent.md +67 -0
  177. package/plugins/mgmt/skills/resourcemgr/SKILL.md +41 -0
  178. package/plugins/mgmt/skills/resourcemgr/tools.json +1 -0
  179. package/plugins/mgmt/skills/sweeper/SKILL.md +44 -0
  180. package/plugins/mgmt/skills/sweeper/tools.json +1 -0
  181. package/plugins/system/agents/default.agent.md +58 -0
  182. package/plugins/system/skills/durable-timers/SKILL.md +39 -0
  183. package/plugins/system/skills/sub-agents/SKILL.md +75 -0
@@ -0,0 +1,498 @@
1
+ import type { Tool, SessionConfig } from "@github/copilot-sdk";
2
+ import type { SessionStateStore } from "./session-store.js";
3
+ export declare const SESSION_STATE_MISSING_PREFIX = "SESSION_STATE_MISSING:";
4
+ export type TurnAction = {
5
+ type: "wait";
6
+ seconds: number;
7
+ reason: string;
8
+ content?: string;
9
+ events?: CapturedEvent[];
10
+ } | {
11
+ type: "input_required";
12
+ question: string;
13
+ choices?: string[];
14
+ allowFreeform?: boolean;
15
+ events?: CapturedEvent[];
16
+ } | {
17
+ type: "spawn_agent";
18
+ task: string;
19
+ model?: string;
20
+ systemMessage?: string | {
21
+ mode: "append" | "replace";
22
+ content: string;
23
+ };
24
+ toolNames?: string[];
25
+ agentName?: string;
26
+ content?: string;
27
+ events?: CapturedEvent[];
28
+ } | {
29
+ type: "message_agent";
30
+ agentId: string;
31
+ message: string;
32
+ events?: CapturedEvent[];
33
+ } | {
34
+ type: "check_agents";
35
+ events?: CapturedEvent[];
36
+ } | {
37
+ type: "wait_for_agents";
38
+ agentIds: string[];
39
+ events?: CapturedEvent[];
40
+ } | {
41
+ type: "list_sessions";
42
+ events?: CapturedEvent[];
43
+ } | {
44
+ type: "complete_agent";
45
+ agentId: string;
46
+ events?: CapturedEvent[];
47
+ } | {
48
+ type: "cancel_agent";
49
+ agentId: string;
50
+ reason?: string;
51
+ events?: CapturedEvent[];
52
+ } | {
53
+ type: "delete_agent";
54
+ agentId: string;
55
+ reason?: string;
56
+ events?: CapturedEvent[];
57
+ };
58
+ type QueuedTurnActionCarrier = {
59
+ queuedActions?: TurnAction[];
60
+ };
61
+ export type TurnResult = {
62
+ type: "completed";
63
+ content: string;
64
+ events?: CapturedEvent[];
65
+ } | ({
66
+ type: "wait";
67
+ seconds: number;
68
+ reason: string;
69
+ content?: string;
70
+ events?: CapturedEvent[];
71
+ } & QueuedTurnActionCarrier) | ({
72
+ type: "input_required";
73
+ question: string;
74
+ choices?: string[];
75
+ allowFreeform?: boolean;
76
+ events?: CapturedEvent[];
77
+ } & QueuedTurnActionCarrier) | ({
78
+ type: "spawn_agent";
79
+ task: string;
80
+ model?: string;
81
+ systemMessage?: string | {
82
+ mode: "append" | "replace";
83
+ content: string;
84
+ };
85
+ toolNames?: string[];
86
+ agentName?: string;
87
+ content?: string;
88
+ events?: CapturedEvent[];
89
+ } & QueuedTurnActionCarrier) | ({
90
+ type: "message_agent";
91
+ agentId: string;
92
+ message: string;
93
+ events?: CapturedEvent[];
94
+ } & QueuedTurnActionCarrier) | ({
95
+ type: "check_agents";
96
+ events?: CapturedEvent[];
97
+ } & QueuedTurnActionCarrier) | ({
98
+ type: "wait_for_agents";
99
+ agentIds: string[];
100
+ events?: CapturedEvent[];
101
+ } & QueuedTurnActionCarrier) | ({
102
+ type: "list_sessions";
103
+ events?: CapturedEvent[];
104
+ } & QueuedTurnActionCarrier) | ({
105
+ type: "complete_agent";
106
+ agentId: string;
107
+ events?: CapturedEvent[];
108
+ } & QueuedTurnActionCarrier) | ({
109
+ type: "cancel_agent";
110
+ agentId: string;
111
+ reason?: string;
112
+ events?: CapturedEvent[];
113
+ } & QueuedTurnActionCarrier) | ({
114
+ type: "delete_agent";
115
+ agentId: string;
116
+ reason?: string;
117
+ events?: CapturedEvent[];
118
+ } & QueuedTurnActionCarrier) | {
119
+ type: "cancelled";
120
+ } | {
121
+ type: "error";
122
+ message: string;
123
+ events?: CapturedEvent[];
124
+ };
125
+ /** A raw event captured from CopilotSession.on() during a turn. */
126
+ export interface CapturedEvent {
127
+ eventType: string;
128
+ data: unknown;
129
+ }
130
+ export interface TurnOptions {
131
+ onDelta?: (delta: string) => void;
132
+ onToolStart?: (name: string, args: any) => void;
133
+ /** Called for every event as it fires during the turn. */
134
+ onEvent?: (event: CapturedEvent) => void;
135
+ /** Model summary text for the list_available_models tool. */
136
+ modelSummary?: string;
137
+ /** Internal: startup/bootstrap turn that should not be recorded as a user message. */
138
+ bootstrap?: boolean;
139
+ }
140
+ /** Serializable config — travels through duroxide (no functions). */
141
+ export interface SerializableSessionConfig {
142
+ model?: string;
143
+ systemMessage?: string | {
144
+ mode: "append" | "replace";
145
+ content: string;
146
+ };
147
+ workingDirectory?: string;
148
+ /** Wait threshold in seconds. Waits shorter than this sleep in-process. */
149
+ waitThreshold?: number;
150
+ /** Internal: name of the bound agent definition whose prompt should be layered into this session. */
151
+ boundAgentName?: string;
152
+ /** Internal: selects how framework, app, and agent prompts compose for this session. */
153
+ promptLayering?: {
154
+ kind: "app-agent" | "app-system-agent" | "pilotswarm-system-agent";
155
+ };
156
+ /**
157
+ * Names of tools registered on the worker via `worker.registerTools()`.
158
+ * Serializable — travels through duroxide. The worker resolves these
159
+ * names to actual Tool objects from its registry at activity execution time.
160
+ */
161
+ toolNames?: string[];
162
+ }
163
+ /** Full config — includes non-serializable fields (tools, hooks). Stays in memory. */
164
+ export interface ManagedSessionConfig extends SerializableSessionConfig {
165
+ tools?: Tool<any>[];
166
+ hooks?: SessionConfig["hooks"];
167
+ /** Turn timeout in milliseconds. 0 or undefined = no timeout. */
168
+ turnTimeoutMs?: number;
169
+ }
170
+ export type PilotSwarmSessionStatus = "pending" | "running" | "idle" | "waiting" | "input_required" | "completed" | "failed" | "error";
171
+ export interface PilotSwarmSessionInfo {
172
+ sessionId: string;
173
+ status: PilotSwarmSessionStatus;
174
+ /** LLM model used for this session. */
175
+ model?: string;
176
+ /** LLM-generated 3-5 word summary of the session. */
177
+ title?: string;
178
+ createdAt: Date;
179
+ updatedAt: Date;
180
+ pendingQuestion?: {
181
+ question: string;
182
+ choices?: string[];
183
+ allowFreeform?: boolean;
184
+ };
185
+ waitingUntil?: Date;
186
+ waitReason?: string;
187
+ result?: string;
188
+ error?: string;
189
+ iterations: number;
190
+ /** If this is a sub-agent session, the parent session's ID. */
191
+ parentSessionId?: string;
192
+ /** Whether this is a system session (e.g. Sweeper Agent). Cannot be deleted. */
193
+ isSystem?: boolean;
194
+ /** Agent definition ID (e.g. "sweeper"). Links session to its agent config. */
195
+ agentId?: string;
196
+ /** Splash banner (blessed markup) from the agent definition. */
197
+ splash?: string;
198
+ }
199
+ export interface OrchestrationInput {
200
+ sessionId: string;
201
+ config: SerializableSessionConfig;
202
+ iteration?: number;
203
+ responseVersion?: number;
204
+ commandVersion?: number;
205
+ affinityKey?: string;
206
+ needsHydration?: boolean;
207
+ blobEnabled?: boolean;
208
+ prompt?: string;
209
+ /** Internal: pending prompt is a bootstrap message, not a user-authored prompt. */
210
+ bootstrapPrompt?: boolean;
211
+ dehydrateThreshold?: number;
212
+ idleTimeout?: number;
213
+ inputGracePeriod?: number;
214
+ /** Timestamp (ms) when the next title summarization should fire. 0 = not yet scheduled. */
215
+ nextSummarizeAt?: number;
216
+ /** How many consecutive retries have been attempted for the current prompt. */
217
+ retryCount?: number;
218
+ /** The user's original task-defining prompt, preserved to survive LLM truncation. */
219
+ taskContext?: string;
220
+ /** Original system message before task context injection (avoids double-appending). */
221
+ baseSystemMessage?: string | {
222
+ mode: "append" | "replace";
223
+ content: string;
224
+ };
225
+ /** Seconds between periodic checkpoints (blob upload without losing session pin). -1 = disabled. */
226
+ checkpointInterval?: number;
227
+ /** Custom message prepended to the user prompt on rehydration (after worker death). */
228
+ rehydrationMessage?: string;
229
+ /** Tracked sub-agents spawned by this orchestration. Carried across continueAsNew. */
230
+ subAgents?: SubAgentEntry[];
231
+ /** Durable queue of additional tool actions emitted in the same LLM turn. */
232
+ pendingToolActions?: TurnAction[];
233
+ /** One already-dequeued inbound message to replay first after continueAsNew. */
234
+ pendingMessage?: unknown;
235
+ /** If this is a sub-agent, the parent session ID (for sending updates back via SDK). */
236
+ parentSessionId?: string;
237
+ /** @deprecated Use parentSessionId. Kept for backward compat with frozen orchestration versions. */
238
+ parentOrchId?: string;
239
+ /** Current nesting level (0 = root, 1 = child, 2 = grandchild). Used to enforce max depth. */
240
+ nestingLevel?: number;
241
+ /** Whether this is a system session (e.g. Sweeper Agent). System sessions skip title summarization. */
242
+ isSystem?: boolean;
243
+ /** Agent definition ID bound to this session (e.g. "supervisor"). Used for policy validation. */
244
+ agentId?: string;
245
+ /** Session creation policy (loaded from session-policy.json). */
246
+ sessionPolicy?: SessionPolicy;
247
+ /** Names of all loaded non-system agents. Used by orchestration to validate policy. */
248
+ allowedAgentNames?: string[];
249
+ }
250
+ /** A sub-agent entry tracked in the parent orchestration's state. */
251
+ export interface SubAgentEntry {
252
+ /** The child orchestration ID (e.g. "session-<guid>"). */
253
+ orchId: string;
254
+ /** The session ID portion. */
255
+ sessionId: string;
256
+ /** Short description of the task assigned to this sub-agent. */
257
+ task: string;
258
+ /** Last known status of the sub-agent. */
259
+ status: "running" | "completed" | "failed" | "cancelled";
260
+ /** Final result content (set when status becomes completed). */
261
+ result?: string;
262
+ }
263
+ /**
264
+ * App-level session creation policy. Loaded from `session-policy.json`
265
+ * in a plugin directory. Controls which sessions can be created and deleted.
266
+ */
267
+ export interface SessionPolicy {
268
+ version: 1;
269
+ creation?: {
270
+ /** "allowlist" = only loaded non-system agents; "open" = current behavior. Default: "open". */
271
+ mode?: "allowlist" | "open";
272
+ /** Whether generic (blank, no agent) sessions are allowed. Default: true. */
273
+ allowGeneric?: boolean;
274
+ /** Default agent name for TUI single-step creation. */
275
+ defaultAgent?: string;
276
+ };
277
+ deletion?: {
278
+ /** Whether system sessions are protected from deletion. Default: true. */
279
+ protectSystem?: boolean;
280
+ };
281
+ }
282
+ export interface PilotSwarmWorkerOptions {
283
+ store: string;
284
+ /** GitHub token. Required unless a custom `provider` is specified. */
285
+ githubToken?: string;
286
+ logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all";
287
+ waitThreshold?: number;
288
+ maxSessionsPerRuntime?: number;
289
+ sessionIdleTimeoutMs?: number;
290
+ workerNodeId?: string;
291
+ /** Azure Blob Storage connection string for the built-in blob-backed session store. */
292
+ blobConnectionString?: string;
293
+ /** Blob container name for the built-in blob-backed session store. */
294
+ blobContainer?: string;
295
+ /** Optional session state store. When set, enables durable session dehydration without Azure Blob Storage. */
296
+ sessionStore?: SessionStateStore;
297
+ /**
298
+ * Turn timeout in milliseconds. If a single LLM turn takes longer than this,
299
+ * it is aborted. 0 or undefined = no timeout (default).
300
+ */
301
+ turnTimeoutMs?: number;
302
+ /**
303
+ * Base directory for local session state files.
304
+ * Default: `~/.copilot/session-state`.
305
+ */
306
+ sessionStateDir?: string;
307
+ /**
308
+ * Optional trace callback for startup diagnostics.
309
+ * If not provided, trace messages are discarded.
310
+ */
311
+ traceWriter?: (msg: string) => void;
312
+ /**
313
+ * Custom LLM provider (BYOK — Bring Your Own Key).
314
+ * When specified, uses this API endpoint instead of the GitHub Copilot API.
315
+ * Eliminates the need for a GitHub token.
316
+ *
317
+ * Supports OpenAI-compatible, Azure OpenAI, and Anthropic endpoints.
318
+ */
319
+ provider?: {
320
+ /** Provider type. Defaults to "openai" for generic OpenAI-compatible APIs. */
321
+ type?: "openai" | "azure" | "anthropic";
322
+ /** API endpoint URL (e.g. https://my-resource.openai.azure.com/openai/deployments/gpt-4.1-mini) */
323
+ baseUrl: string;
324
+ /** API key. Optional for local providers like Ollama. */
325
+ apiKey?: string;
326
+ /** Azure-specific options. */
327
+ azure?: {
328
+ apiVersion?: string;
329
+ };
330
+ };
331
+ /**
332
+ * PostgreSQL schema name for duroxide orchestration tables.
333
+ * Default: `"duroxide"`. Change this to run multiple independent
334
+ * deployments on the same database.
335
+ */
336
+ duroxideSchema?: string;
337
+ /**
338
+ * PostgreSQL schema name for the session catalog (CMS) tables.
339
+ * Default: `"copilot_sessions"`. Change this to isolate session
340
+ * data across deployments sharing the same database.
341
+ */
342
+ cmsSchema?: string;
343
+ /**
344
+ * Inline app-level default instructions layered beneath the embedded
345
+ * PilotSwarm framework base prompt.
346
+ */
347
+ systemMessage?: string;
348
+ /**
349
+ * Plugin directories to load at startup.
350
+ * Each directory can contain:
351
+ * - `skills/` subdirectories with `SKILL.md` files
352
+ * - `agents/` directory with `.agent.md` files
353
+ * - `.mcp.json` file with MCP server configs
354
+ * - `plugin.json` manifest (optional metadata)
355
+ *
356
+ * The worker reads these at startup and passes their contents
357
+ * through the SDK's `skillDirectories`, `customAgents`, and
358
+ * `mcpServers` session config fields.
359
+ */
360
+ pluginDirs?: string[];
361
+ /**
362
+ * Additional skill directories (beyond plugins).
363
+ * Each directory should contain subdirectories with `SKILL.md` files.
364
+ * These are passed directly to the SDK's `skillDirectories` config.
365
+ */
366
+ skillDirectories?: string[];
367
+ /**
368
+ * Additional custom agents (beyond plugins).
369
+ * Passed directly to the SDK's `customAgents` config.
370
+ */
371
+ customAgents?: Array<{
372
+ name: string;
373
+ description?: string;
374
+ prompt: string;
375
+ tools?: string[] | null;
376
+ }>;
377
+ /**
378
+ * Additional MCP server configs (beyond plugins).
379
+ * Passed directly to the SDK's `mcpServers` config.
380
+ */
381
+ mcpServers?: Record<string, any>;
382
+ /**
383
+ * Path to a `model_providers.json` file.
384
+ * Defines multiple LLM providers (GitHub Copilot, Azure OpenAI, OpenAI, Anthropic)
385
+ * each with their own endpoints, API keys, and available models.
386
+ *
387
+ * If not specified, auto-discovers `.model_providers.json` in cwd or /app/.
388
+ * Falls back to legacy env vars (LLM_ENDPOINT, GITHUB_TOKEN) if no file found.
389
+ */
390
+ modelProvidersPath?: string;
391
+ /**
392
+ * Disable SDK-bundled management agents (pilotswarm, resourcemgr, sweeper).
393
+ * Default: false. Set to true for headless/minimal deployments.
394
+ */
395
+ disableManagementAgents?: boolean;
396
+ }
397
+ export interface PilotSwarmClientOptions {
398
+ /** Store URL (postgres:// or sqlite://). */
399
+ store: string;
400
+ /** Enables durable session-store paths in the orchestration. Works with Azure blob or any custom session store configured on workers. */
401
+ blobEnabled?: boolean;
402
+ waitThreshold?: number;
403
+ dehydrateThreshold?: number;
404
+ dehydrateOnInputRequired?: number;
405
+ dehydrateOnIdle?: number;
406
+ /**
407
+ * Optional trace callback for startup diagnostics.
408
+ * If not provided, trace messages are discarded.
409
+ */
410
+ traceWriter?: (msg: string) => void;
411
+ /** Seconds between periodic checkpoints (blob upload without losing session pin). -1 = disabled. */
412
+ checkpointInterval?: number;
413
+ /** Custom message prepended to the user prompt on rehydration (after worker death). */
414
+ rehydrationMessage?: string;
415
+ /**
416
+ * PostgreSQL schema name for duroxide orchestration tables.
417
+ * Default: `"duroxide"`. Must match the worker's `duroxideSchema`.
418
+ */
419
+ duroxideSchema?: string;
420
+ /**
421
+ * PostgreSQL schema name for the session catalog (CMS) tables.
422
+ * Default: `"copilot_sessions"`. Must match the worker's `cmsSchema`.
423
+ */
424
+ cmsSchema?: string;
425
+ /**
426
+ * Session creation policy. Typically set by the worker and forwarded
427
+ * to co-located clients. Controls which sessions can be created.
428
+ */
429
+ sessionPolicy?: SessionPolicy;
430
+ /**
431
+ * Names of loaded non-system agents. Set by the worker and forwarded
432
+ * to co-located clients for client-side policy validation.
433
+ */
434
+ allowedAgentNames?: string[];
435
+ }
436
+ export interface UserInputRequest {
437
+ question: string;
438
+ choices?: string[];
439
+ allowFreeform?: boolean;
440
+ }
441
+ export interface UserInputResponse {
442
+ answer: string;
443
+ wasFreeform: boolean;
444
+ }
445
+ export type UserInputHandler = (request: UserInputRequest, invocation: {
446
+ sessionId: string;
447
+ }) => Promise<UserInputResponse> | UserInputResponse;
448
+ export interface CommandMessage {
449
+ type: "cmd";
450
+ cmd: string;
451
+ args?: Record<string, unknown>;
452
+ id: string;
453
+ }
454
+ export interface CommandResponse {
455
+ id: string;
456
+ cmd: string;
457
+ result?: unknown;
458
+ error?: string;
459
+ }
460
+ export declare const RESPONSE_VERSION_KEY = "meta.responseVersion";
461
+ export declare const COMMAND_VERSION_KEY = "meta.commandVersion";
462
+ export declare const RESPONSE_LATEST_KEY = "response.latest";
463
+ export declare function commandResponseKey(cmdId: string): string;
464
+ export interface SessionResponsePayload {
465
+ schemaVersion: 1;
466
+ version: number;
467
+ iteration: number;
468
+ type: "completed" | "wait" | "input_required";
469
+ content?: string;
470
+ question?: string;
471
+ choices?: string[];
472
+ allowFreeform?: boolean;
473
+ waitReason?: string;
474
+ waitSeconds?: number;
475
+ waitStartedAt?: number;
476
+ emittedAt: number;
477
+ model?: string;
478
+ }
479
+ export interface SessionCommandResponse extends CommandResponse {
480
+ schemaVersion: 1;
481
+ version: number;
482
+ emittedAt: number;
483
+ }
484
+ export interface SessionStatusSignal {
485
+ status: PilotSwarmSessionStatus;
486
+ iteration: number;
487
+ responseVersion?: number;
488
+ commandVersion?: number;
489
+ commandId?: string;
490
+ cmdProcessing?: string;
491
+ waitReason?: string;
492
+ waitSeconds?: number;
493
+ waitStartedAt?: number;
494
+ error?: string;
495
+ retriesExhausted?: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;IAC3D,aAAa,EAAE,CAAC,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,uBAAuB,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ export const SESSION_STATE_MISSING_PREFIX = "SESSION_STATE_MISSING:";
2
+ // ─── KV-Backed Response Channel ────────────────────────────────
3
+ export const RESPONSE_VERSION_KEY = "meta.responseVersion";
4
+ export const COMMAND_VERSION_KEY = "meta.commandVersion";
5
+ export const RESPONSE_LATEST_KEY = "response.latest";
6
+ export function commandResponseKey(cmdId) {
7
+ return `command.response.${cmdId}`;
8
+ }
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAibrE,kEAAkE;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC5C,OAAO,oBAAoB,KAAK,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,128 @@
1
+ import type { SessionCatalogProvider } from "./cms.js";
2
+ import { type ModelProviderRegistry } from "./model-providers.js";
3
+ import type { Tool } from "@github/copilot-sdk";
4
+ import type { PilotSwarmWorkerOptions, ManagedSessionConfig } from "./types.js";
5
+ import type { AgentConfig } from "./agent-loader.js";
6
+ /**
7
+ * PilotSwarmWorker — runs activities and orchestrations.
8
+ *
9
+ * Owns:
10
+ * - SessionManager (creates/resumes CopilotSessions, holds tools/hooks)
11
+ * - duroxide Runtime (dispatches activities + orchestrations)
12
+ * - Session state store (optional, for session dehydration/hydration)
13
+ *
14
+ * In single-process mode, pass this worker to PilotSwarmClient's
15
+ * constructor so they share the database provider and the client can
16
+ * forward tool/hook registrations.
17
+ */
18
+ export declare class PilotSwarmWorker {
19
+ private config;
20
+ private sessionManager;
21
+ private sessionStore;
22
+ private blobStore;
23
+ private runtime;
24
+ private _provider;
25
+ private _catalog;
26
+ private _started;
27
+ /** Worker-level tool registry — name → Tool. */
28
+ private toolRegistry;
29
+ /** Loaded skill directories from plugins + direct config. */
30
+ private _loadedSkillDirs;
31
+ /** Raw loaded user-creatable agent configs from plugins + direct config. */
32
+ private _rawLoadedAgents;
33
+ /** Loaded agent configs from plugins + direct config, composed for SDK customAgents. */
34
+ private _loadedAgents;
35
+ /** Loaded MCP server configs from plugins + direct config. */
36
+ private _loadedMcpServers;
37
+ /** Model provider registry — multi-provider LLM config. */
38
+ private _modelProviders;
39
+ /** Embedded PilotSwarm framework prompt. */
40
+ private _frameworkBasePrompt;
41
+ /** App-level default prompt overlay from app pluginDirs and inline worker config. */
42
+ private _appDefaultPrompt;
43
+ /** System agents loaded from plugins — started automatically on worker start. */
44
+ private _loadedSystemAgents;
45
+ /** Prompt lookup used for direct named/system sessions. */
46
+ private _agentPromptLookup;
47
+ /** Session creation policy loaded from session-policy.json. */
48
+ private _sessionPolicy;
49
+ constructor(options: PilotSwarmWorkerOptions);
50
+ /**
51
+ * Register tools at the worker level.
52
+ *
53
+ * These tools are available to ALL sessions on this worker.
54
+ * Clients can reference them by name in createSession() via
55
+ * `toolNames: ["tool_name_1", "tool_name_2"]` — the names travel
56
+ * through duroxide as serializable strings, and the worker
57
+ * resolves them to the actual Tool objects at execution time.
58
+ *
59
+ * This is the primary mechanism for custom tools in remote/
60
+ * separate-process mode where client and worker run on
61
+ * different machines.
62
+ */
63
+ registerTools(tools: Tool<any>[]): void;
64
+ /** Store full config (with tools/hooks) for a session. */
65
+ setSessionConfig(sessionId: string, config: ManagedSessionConfig): void;
66
+ /** Whether a durable session store is configured. */
67
+ get blobEnabled(): boolean;
68
+ /** Whether the worker runtime is running. */
69
+ get isStarted(): boolean;
70
+ /** @internal — shared with co-located PilotSwarmClient. */
71
+ get provider(): any;
72
+ /** Session catalog (CMS) — available when store is PostgreSQL. */
73
+ get catalog(): SessionCatalogProvider | null;
74
+ /** Loaded skill directories. */
75
+ get loadedSkillDirs(): string[];
76
+ /** Loaded agent configs. */
77
+ get loadedAgents(): Array<{
78
+ name: string;
79
+ description?: string;
80
+ prompt: string;
81
+ tools?: string[] | null;
82
+ namespace?: string;
83
+ }>;
84
+ /** Loaded MCP server configs. */
85
+ get loadedMcpServers(): Record<string, any>;
86
+ /** Model provider registry (null if no providers configured). */
87
+ get modelProviders(): ModelProviderRegistry | null;
88
+ /** System agents loaded from plugins. */
89
+ get systemAgents(): AgentConfig[];
90
+ /** Session creation policy (null if no session-policy.json found). */
91
+ get sessionPolicy(): import("./types.js").SessionPolicy | null;
92
+ /** Names of loaded non-system agents that can be created as top-level sessions. */
93
+ get allowedAgentNames(): string[];
94
+ start(): Promise<void>;
95
+ stop(): Promise<void>;
96
+ /** Dehydrate all active sessions, then stop. */
97
+ gracefulShutdown(): Promise<void>;
98
+ /** Destroy a session on this worker. */
99
+ destroySession(sessionId: string): Promise<void>;
100
+ /**
101
+ * Load plugin contents from SDK bundled plugins + app plugin directories.
102
+ *
103
+ * Three-tier loading order:
104
+ * 1. system/ — SDK core (always loaded: base system prompt, durable-timers, sub-agents)
105
+ * 2. mgmt/ — SDK management agents (loaded unless disableManagementAgents is true)
106
+ * 3. app — Consumer-provided plugin dirs (from pluginDirs option)
107
+ * 4. direct — Inline config (skillDirectories, customAgents, mcpServers options)
108
+ *
109
+ * Agents merge by name (later tiers override earlier).
110
+ * Skills merge additively (all dirs combined).
111
+ * MCP servers merge by name (later tiers override earlier).
112
+ */
113
+ private _loadPlugins;
114
+ /**
115
+ * Load agents, skills, MCP config, and session policy from a single plugin directory.
116
+ */
117
+ private _loadPluginDir;
118
+ /**
119
+ * Auto-start system agents defined in plugins.
120
+ *
121
+ * Each system agent has a deterministic session UUID derived from its `id` slug.
122
+ * Multiple workers calling this concurrently is safe — CMS upsert and
123
+ * duroxide startOrchestrationVersioned are both idempotent.
124
+ */
125
+ private _startSystemAgents;
126
+ private _createProvider;
127
+ }
128
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAMtF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAsB,MAAM,YAAY,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAcrD;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,C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