@robota-sdk/agent-subagent-runner 3.0.0-beta.82 → 3.0.0-beta.83

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.
@@ -1,6 +1,6 @@
1
1
  import { IConnectionEnvironmentCheck, ISubagentJobHandle, ISubagentJobStart, ISubagentRunner, ISubagentWorktreeAdapter } from "@robota-sdk/agent-executor";
2
2
  import { IHookTypeExecutor, IProviderDefinition, IProviderDefinitionConfig, ISessionUsageTotals, IToolWithEventService, TPermissionMode, TToolArgs } from "@robota-sdk/agent-core";
3
- import { IAgentDefinition, IInProcessSubagentRunnerDeps, IResolvedConfig, ISubagentParentContext, TSubagentRunnerFactory, restoreSessionRecordIntoSession } from "@robota-sdk/agent-framework";
3
+ import { IAgentDefinition, IInProcessSubagentRunnerDeps, IResolvedConfig, ISubagentOptions, ISubagentParentContext, TSubagentRunnerFactory, restoreSessionRecordIntoSession } from "@robota-sdk/agent-framework";
4
4
  import { ISerializableProviderProfile, ISubagentSpawnRequest } from "@robota-sdk/agent-interface-execution";
5
5
  //#region src/worker-entry.d.ts
6
6
  /**
@@ -42,104 +42,6 @@ interface ISubagentWorkerEntry {
42
42
  /** True when this process was started as a subagent worker. */
43
43
  declare function isSubagentWorkerModeArgv(argv: readonly string[]): boolean;
44
44
  //#endregion
45
- //#region src/child-process-subagent-runner.d.ts
46
- interface IChildProcessSubagentRunnerOptions {
47
- /**
48
- * DIST-006: how to start a copy of the running artifact in subagent-worker mode, stated by the
49
- * composition root. It replaced `workerPath`, which asked this package to locate a file whose
50
- * location is a property of the packaging step — a question no library can answer, and one that
51
- * was answered wrongly twice.
52
- */
53
- workerEntry: ISubagentWorkerEntry;
54
- providerConfig?: IProviderDefinitionConfig;
55
- /**
56
- * The parent's provider registry. Its defaults complete the connection the child is given, and
57
- * each definition names the environment its client reads. Required: a job whose provider has no
58
- * definition here is refused, because its connection cannot be checked.
59
- */
60
- providerDefinitions: readonly IProviderDefinition[];
61
- killGraceMs?: number;
62
- /**
63
- * How long a spawned worker may take to signal `ready` before the runner gives up. Injectable so
64
- * the branch is reachable in a test; without that it is a fix that ships untested.
65
- */
66
- handshakeBudgetMs?: number;
67
- env?: NodeJS.ProcessEnv;
68
- worktreeIsolation?: boolean;
69
- worktreeAdapter: ISubagentWorktreeAdapter;
70
- logsDir?: string;
71
- }
72
- declare function createChildProcessSubagentRunnerFactory(options: IChildProcessSubagentRunnerOptions): TSubagentRunnerFactory;
73
- declare class ChildProcessSubagentRunner implements ISubagentRunner {
74
- private readonly deps;
75
- private readonly workerEntry;
76
- private readonly killGraceMs;
77
- private readonly handshakeBudgetMs?;
78
- private readonly providerConfig?;
79
- private readonly providerDefinitions;
80
- private readonly env?;
81
- private readonly logsDir?;
82
- constructor(deps: IInProcessSubagentRunnerDeps, options: IChildProcessSubagentRunnerOptions);
83
- start(job: ISubagentJobStart): ISubagentJobHandle;
84
- /**
85
- * The payload the child is started with. The builder lives in
86
- * `child-process-subagent-projection.ts` (CLI-1994 moved it there so the ARCH-044 key-set test
87
- * pins the code that produces it); review of ARCH-033/ARCH-034 is the reason it is a named
88
- * producer at all — both fields were declared on the wire type, read by the worker, and set by
89
- * nothing, because this was the only production site that constructs a payload and no test
90
- * reached it.
91
- */
92
- private createStartPayload;
93
- private resolveTranscriptPath;
94
- }
95
- //#endregion
96
- //#region src/subagent-worker-start-dto.d.ts
97
- /**
98
- * The parent's loaded-context RUNTIME model (`ILoadedContext`, which the framework barrel does not
99
- * export). Named here for the encoder/restore signatures only — the wire DTO below never references it.
100
- */
101
- type TParentContextModel = IInProcessSubagentRunnerDeps['context'];
102
- interface ISubagentWorkerAgentDefinitionDto {
103
- readonly name: string;
104
- readonly description: string;
105
- readonly systemPrompt: string;
106
- readonly model?: string;
107
- readonly effort?: IAgentDefinition['effort'];
108
- readonly role?: string;
109
- readonly maxTurns?: number;
110
- readonly tools?: readonly string[];
111
- readonly disallowedTools?: readonly string[];
112
- }
113
- interface ISubagentWorkerContextFileEntryDto {
114
- readonly filePath: string;
115
- readonly content: string;
116
- readonly contentHash: string;
117
- }
118
- interface ISubagentWorkerParentContextDto {
119
- readonly agentsMd: string;
120
- readonly projectNotesMd: string;
121
- readonly memoryMd?: string;
122
- readonly taskContext?: string;
123
- readonly compactInstructions?: string;
124
- readonly agentsFileEntries?: readonly ISubagentWorkerContextFileEntryDto[];
125
- readonly projectNotesFileEntries?: readonly ISubagentWorkerContextFileEntryDto[];
126
- }
127
- type TDtoDecodeResult<TDto> = {
128
- readonly ok: true;
129
- readonly value: TDto;
130
- } | {
131
- readonly ok: false;
132
- readonly reason: string;
133
- };
134
- declare function encodeAgentDefinition(definition: IAgentDefinition): ISubagentWorkerAgentDefinitionDto;
135
- declare function decodeAgentDefinitionDto(value: unknown): TDtoDecodeResult<ISubagentWorkerAgentDefinitionDto>;
136
- /** Explicit restore in the worker: the DTO's fields are the runtime model's, copied, not aliased. */
137
- declare function restoreAgentDefinition(dto: ISubagentWorkerAgentDefinitionDto): IAgentDefinition;
138
- /** Accepts the issue #2317 projection (or anything wider, structurally); only declared fields cross. */
139
- declare function encodeParentContext(context: ISubagentParentContext): ISubagentWorkerParentContextDto;
140
- declare function decodeParentContextDto(value: unknown): TDtoDecodeResult<ISubagentWorkerParentContextDto>;
141
- declare function restoreParentContext(dto: ISubagentWorkerParentContextDto): TParentContextModel;
142
- //#endregion
143
45
  //#region src/worker-composition.d.ts
144
46
  /**
145
47
  * The session record store a fork job's `resumeSessionId` names a record in, typed FROM the one
@@ -252,6 +154,34 @@ interface ISubagentWorkerComposition {
252
154
  readonly openSessionStore?: (context: {
253
155
  readonly cwd: string;
254
156
  }) => TResumeSessionStore;
157
+ /**
158
+ * A sandbox the child composes itself at its execution root, rather than restoring one from a
159
+ * snapshot: the OS sandbox is a function of the root and its settings, and the settings cross as
160
+ * data (`parentSettings`, the parent's as they stood at spawn) where a live handle cannot.
161
+ *
162
+ * The worker builds it once and hands the SAME instance to `createTools` (as `sandboxClient`) and to
163
+ * the session (as `commandSandbox`), so the approval a confined command gets comes from the instance
164
+ * the command runs under. Absent ⇒ the child's session approves no command on a sandbox's say-so.
165
+ */
166
+ readonly createSandbox?: (context: {
167
+ readonly cwd: string;
168
+ /** The parent's sandbox settings at spawn, when its composition root sent them. */
169
+ readonly parentSettings?: TParentSandboxSettings;
170
+ }) => ISubagentComposedSandbox | undefined;
171
+ }
172
+ /** A composition root's sandbox settings, as plain data that crosses the process boundary. */
173
+ type TParentSandboxSettings = Readonly<Record<string, unknown>>;
174
+ /** A sandbox the child composed itself: the client its tools run under and the approval it gives. */
175
+ interface ISubagentComposedSandbox {
176
+ readonly client: TProjectedSandboxClient;
177
+ readonly commandSandbox?: ISubagentOptions['commandSandbox'];
178
+ /**
179
+ * Take the parent's settings after a change it made while this child runs (`/sandbox`), so the
180
+ * next command is confined and approved as the parent's would be. Throws on settings it cannot
181
+ * read: the worker then aborts the run and ends it with that error, rather than run on settings the
182
+ * user has replaced.
183
+ */
184
+ readonly applyParentSettings?: (settings: TParentSandboxSettings) => void;
255
185
  }
256
186
  /**
257
187
  * Rebuilds a sandbox client of ONE type from a snapshot reference the parent produced.
@@ -284,6 +214,119 @@ interface ISandboxProjection {
284
214
  readonly snapshotId: string;
285
215
  }
286
216
  //#endregion
217
+ //#region src/child-process-subagent-runner.d.ts
218
+ interface IChildProcessSubagentRunnerOptions {
219
+ /**
220
+ * DIST-006: how to start a copy of the running artifact in subagent-worker mode, stated by the
221
+ * composition root. It replaced `workerPath`, which asked this package to locate a file whose
222
+ * location is a property of the packaging step — a question no library can answer, and one that
223
+ * was answered wrongly twice.
224
+ */
225
+ workerEntry: ISubagentWorkerEntry;
226
+ providerConfig?: IProviderDefinitionConfig;
227
+ /**
228
+ * The parent's provider registry. Its defaults complete the connection the child is given, and
229
+ * each definition names the environment its client reads. Required: a job whose provider has no
230
+ * definition here is refused, because its connection cannot be checked.
231
+ */
232
+ providerDefinitions: readonly IProviderDefinition[];
233
+ killGraceMs?: number;
234
+ /**
235
+ * How long a spawned worker may take to signal `ready` before the runner gives up. Injectable so
236
+ * the branch is reachable in a test; without that it is a fix that ships untested.
237
+ */
238
+ handshakeBudgetMs?: number;
239
+ env?: NodeJS.ProcessEnv;
240
+ worktreeIsolation?: boolean;
241
+ worktreeAdapter: ISubagentWorktreeAdapter;
242
+ logsDir?: string;
243
+ /**
244
+ * The parent's sandbox settings as they stand now, read at EACH spawn: a setting the user changed
245
+ * this session (`/sandbox`) lives on the parent's live client, not in the files a child would read.
246
+ * The child's `createSandbox` receives the value. Absent ⇒ the child reads its root's settings.
247
+ */
248
+ parentSandboxSettings?: () => TParentSandboxSettings | undefined;
249
+ /**
250
+ * Be told the parent's sandbox settings after each change (`/sandbox`); returns the way to stop.
251
+ * The runner forwards each change to every running child, so a child started before the change
252
+ * follows it too.
253
+ */
254
+ watchParentSandboxSettings?: (listener: (settings: TParentSandboxSettings) => void) => () => void;
255
+ }
256
+ declare function createChildProcessSubagentRunnerFactory(options: IChildProcessSubagentRunnerOptions): TSubagentRunnerFactory;
257
+ declare class ChildProcessSubagentRunner implements ISubagentRunner {
258
+ private readonly deps;
259
+ private readonly workerEntry;
260
+ private readonly killGraceMs;
261
+ private readonly handshakeBudgetMs?;
262
+ private readonly providerConfig?;
263
+ private readonly providerDefinitions;
264
+ private readonly env?;
265
+ private readonly logsDir?;
266
+ private readonly parentSandboxSettings?;
267
+ private readonly watchParentSandboxSettings?;
268
+ constructor(deps: IInProcessSubagentRunnerDeps, options: IChildProcessSubagentRunnerOptions);
269
+ start(job: ISubagentJobStart): ISubagentJobHandle;
270
+ /**
271
+ * The payload the child is started with. The builder lives in
272
+ * `child-process-subagent-projection.ts` (CLI-1994 moved it there so the ARCH-044 key-set test
273
+ * pins the code that produces it); review of ARCH-033/ARCH-034 is the reason it is a named
274
+ * producer at all — both fields were declared on the wire type, read by the worker, and set by
275
+ * nothing, because this was the only production site that constructs a payload and no test
276
+ * reached it.
277
+ */
278
+ private createStartPayload;
279
+ private forwardSandboxSettingChanges;
280
+ private resolveTranscriptPath;
281
+ }
282
+ //#endregion
283
+ //#region src/subagent-worker-start-dto.d.ts
284
+ /**
285
+ * The parent's loaded-context RUNTIME model (`ILoadedContext`, which the framework barrel does not
286
+ * export). Named here for the encoder/restore signatures only — the wire DTO below never references it.
287
+ */
288
+ type TParentContextModel = IInProcessSubagentRunnerDeps['context'];
289
+ interface ISubagentWorkerAgentDefinitionDto {
290
+ readonly name: string;
291
+ readonly description: string;
292
+ readonly systemPrompt: string;
293
+ readonly model?: string;
294
+ readonly effort?: IAgentDefinition['effort'];
295
+ readonly role?: string;
296
+ readonly maxTurns?: number;
297
+ readonly tools?: readonly string[];
298
+ readonly disallowedTools?: readonly string[];
299
+ }
300
+ interface ISubagentWorkerContextFileEntryDto {
301
+ readonly filePath: string;
302
+ readonly content: string;
303
+ readonly contentHash: string;
304
+ }
305
+ interface ISubagentWorkerParentContextDto {
306
+ readonly agentsMd: string;
307
+ readonly projectNotesMd: string;
308
+ readonly memoryMd?: string;
309
+ readonly taskContext?: string;
310
+ readonly compactInstructions?: string;
311
+ readonly agentsFileEntries?: readonly ISubagentWorkerContextFileEntryDto[];
312
+ readonly projectNotesFileEntries?: readonly ISubagentWorkerContextFileEntryDto[];
313
+ }
314
+ type TDtoDecodeResult<TDto> = {
315
+ readonly ok: true;
316
+ readonly value: TDto;
317
+ } | {
318
+ readonly ok: false;
319
+ readonly reason: string;
320
+ };
321
+ declare function encodeAgentDefinition(definition: IAgentDefinition): ISubagentWorkerAgentDefinitionDto;
322
+ declare function decodeAgentDefinitionDto(value: unknown): TDtoDecodeResult<ISubagentWorkerAgentDefinitionDto>;
323
+ /** Explicit restore in the worker: the DTO's fields are the runtime model's, copied, not aliased. */
324
+ declare function restoreAgentDefinition(dto: ISubagentWorkerAgentDefinitionDto): IAgentDefinition;
325
+ /** Accepts the issue #2317 projection (or anything wider, structurally); only declared fields cross. */
326
+ declare function encodeParentContext(context: ISubagentParentContext): ISubagentWorkerParentContextDto;
327
+ declare function decodeParentContextDto(value: unknown): TDtoDecodeResult<ISubagentWorkerParentContextDto>;
328
+ declare function restoreParentContext(dto: ISubagentWorkerParentContextDto): TParentContextModel;
329
+ //#endregion
287
330
  //#region src/child-process-subagent-ipc.d.ts
288
331
  type TSubagentWorkerWireValue = string | number | boolean | null | undefined | object;
289
332
  /** ARCH-044: the four config members the child reads. See `projectParentConfig`. */
@@ -358,6 +401,12 @@ interface ISubagentWorkerStartPayload {
358
401
  sessionTiers?: {
359
402
  readonly includeGoalTool?: boolean;
360
403
  };
404
+ /**
405
+ * The parent's sandbox settings as they stand at spawn, including a change made this session.
406
+ * Opaque here: the composition root produced it and its `createSandbox` reads it, so the child
407
+ * confines and approves as the parent does now, not as its root's settings files say.
408
+ */
409
+ parentSandboxSettings?: TParentSandboxSettings;
361
410
  permissionMode?: TPermissionMode;
362
411
  logsDir?: string;
363
412
  }
@@ -373,7 +422,12 @@ interface ISubagentWorkerCancelMessage {
373
422
  type: 'cancel';
374
423
  reason?: string;
375
424
  }
376
- type TSubagentWorkerParentMessage = ISubagentWorkerStartMessage | ISubagentWorkerSendMessage | ISubagentWorkerCancelMessage;
425
+ /** The parent's sandbox settings changed while the child runs (`/sandbox`); the child follows. */
426
+ interface ISubagentWorkerSandboxSettingsMessage {
427
+ type: 'sandbox_settings';
428
+ settings: TParentSandboxSettings;
429
+ }
430
+ type TSubagentWorkerParentMessage = ISubagentWorkerStartMessage | ISubagentWorkerSendMessage | ISubagentWorkerCancelMessage | ISubagentWorkerSandboxSettingsMessage;
377
431
  interface ISubagentWorkerReadyMessage {
378
432
  type: 'ready';
379
433
  /**
@@ -432,5 +486,5 @@ declare function isSubagentWorkerChildMessage(value: TSubagentWorkerWireValue):
432
486
  */
433
487
  declare function runSubagentWorkerMain(composition: ISubagentWorkerComposition): void;
434
488
  //#endregion
435
- export { ChildProcessSubagentRunner, type IChildProcessSubagentRunnerOptions, type ISubagentWorkerAgentDefinitionDto, type ISubagentWorkerComposition, type ISubagentWorkerContextFileEntryDto, type ISubagentWorkerEntry, type ISubagentWorkerParentContextDto, type ISubagentWorkerStartPayload, SUBAGENT_WORKER_MODE_FLAG, type TResumeSessionStore, type TSubagentWorkerChildMessage, type TSubagentWorkerParentMessage, type TSubagentWorkerWireValue, createChildProcessSubagentRunnerFactory, decodeAgentDefinitionDto, decodeParentContextDto, encodeAgentDefinition, encodeParentContext, isSubagentWorkerChildMessage, isSubagentWorkerModeArgv, isSubagentWorkerParentMessage, restoreAgentDefinition, restoreParentContext, runSubagentWorkerMain };
489
+ export { ChildProcessSubagentRunner, type IChildProcessSubagentRunnerOptions, type ISubagentComposedSandbox, type ISubagentWorkerAgentDefinitionDto, type ISubagentWorkerComposition, type ISubagentWorkerContextFileEntryDto, type ISubagentWorkerEntry, type ISubagentWorkerParentContextDto, type ISubagentWorkerStartPayload, SUBAGENT_WORKER_MODE_FLAG, type TParentSandboxSettings, type TResumeSessionStore, type TSubagentWorkerChildMessage, type TSubagentWorkerParentMessage, type TSubagentWorkerWireValue, createChildProcessSubagentRunnerFactory, decodeAgentDefinitionDto, decodeParentContextDto, encodeAgentDefinition, encodeParentContext, isSubagentWorkerChildMessage, isSubagentWorkerModeArgv, isSubagentWorkerParentMessage, restoreAgentDefinition, restoreParentContext, runSubagentWorkerMain };
436
490
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/worker-entry.ts","../../src/child-process-subagent-runner.ts","../../src/subagent-worker-start-dto.ts","../../src/worker-composition.ts","../../src/child-process-subagent-ipc.ts","../../src/child-process-subagent-worker.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;cAmBa;;;;;;;;;;UAWI;;WAEN;;WAEA;;WAEA;;;iBAIK,yBAAyB;;;UCMxB;;;;;;;EAOf,aAAa;EACb,iBAAiB;;;;;;EAMjB,8BAA8B;EAC9B;;;;;EAKA;EACA,MAAM,OAAO;EACb;EACA,iBAAiB;EACjB;;iBAGc,wCACd,SAAS,qCACR;cAaU,sCAAsC;mBAU9B;mBATF;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAGE,YAAA,MAAM,8BACvB,SAAS;EAWX,MAAM,KAAK,oBAAoB;;;;;;;;;UAsFvB;UAWA;;;;;;;;KClLL,sBAAsB;UAEV;WACN;WACA;WACA;WACA;WACA,SAAS;WACT;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA,6BAA6B;WAC7B,mCAAmC;;KAmClC,iBAAiB;WAChB;WAAmB,OAAO;;WAAoB;WAAoB;;iBAmE/D,sBACd,YAAY,mBACX;iBAOa,yBACd,iBACC,iBAAiB;;iBASJ,uBAAuB,KAAK,oCAAoC;;iBAgBhE,oBACd,SAAS,yBACR;iBAOa,uBACd,iBACC,iBAAiB;iBAIJ,qBAAqB,KAAK,kCAAkC;;;;;;;;;KCrMhE,sBAAsB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;UAuBnC;;EAEf,gCAAgC;;;;;;;;;EAShC,YAAY;aACD;;;;;;;;;;;;;;aAcA;;eAEE;;;;;;;;;;aAUF,gBAAgB;MACvB;;;;;;WAOK,8BAA8B;;;;;;;;;;;;;;;;;;;;;WAsB9B,mBAAmB,SAAS,eAAe;;;;;;;;;;;;;;WAe3C,oBAAoB;aAAoB;QAAkB;;;;;;;;KASzD,yBAAyB,uBAAuB,QAAQ;;;;;;;;;;;;;KAcxD;;;;;;;UAQK;WACN;WACA;;;;KCxIC;;UAKK;WACN;aAAqB;;WACrB,aAAa;WACb,mBAAmB;WACnB,QAAQ;;UAGF;EACf;EACA,SAAS;;;;;;;;;;EAUT;aAAsB;aAAuB;;;EAE7C,iBAAiB;;;;;;;;;;;EAWjB,cAAc;;;;;;;EAOd,eAAe;EACf,iBAAiB;;;;;EAKjB,iBAAiB;;;;;;;;;;;;EAYjB,oBAAoB;;;;;;;EAOpB;aAA0B;;EAC1B,iBAAiB;EACjB;;UAGe;EACf;EACA,SAAS;;UAGM;EACf;EACA;;UAGe;EACf;EACA;;KAGU,+BACV,8BAA8B,6BAA6B;UAE5C;EACf;;;;;;;;;EASA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA;;UAGe;EACf;EACA;;EAEA,QAAQ;;UAGO;EACf;EACA;;UAGe;EACf;EACA;;KAGU,8BACR,8BACA,kCACA,kCACA,gCACA,+BACA,8BACA;iBA+GY,8BACd,OAAO,2BACN,SAAS;iBAcI,6BACd,OAAO,2BACN,SAAS;;;;;;;;;;;;;;iBCpCI,sBAAsB,aAAa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/worker-entry.ts","../../src/worker-composition.ts","../../src/child-process-subagent-runner.ts","../../src/subagent-worker-start-dto.ts","../../src/child-process-subagent-ipc.ts","../../src/child-process-subagent-worker.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;cAmBa;;;;;;;;;;UAWI;;WAEN;;WAEA;;WAEA;;;iBAIK,yBAAyB;;;;;;;;;KC3B7B,sBAAsB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;UAuBnC;;EAEf,gCAAgC;;;;;;;;;EAShC,YAAY;aACD;;;;;;;;;;;;;;aAcA;;eAEE;;;;;;;;;;aAUF,gBAAgB;MACvB;;;;;;WAOK,8BAA8B;;;;;;;;;;;;;;;;;;;;;WAsB9B,mBAAmB,SAAS,eAAe;;;;;;;;;;;;;;WAe3C,oBAAoB;aAAoB;QAAkB;;;;;;;;;;WAW1D,iBAAiB;aACf;;aAEA,iBAAiB;QACtB;;;KAII,yBAAyB,SAAS;;UAG7B;WACN,QAAQ;WACR,iBAAiB;;;;;;;WAOjB,uBAAuB,UAAU;;;;;;;;KAShC,yBAAyB,uBAAuB,QAAQ;;;;;;;;;;;;;KAcxD;;;;;;;UAQK;WACN;WACA;;;;UCvIM;;;;;;;EAOf,aAAa;EACb,iBAAiB;;;;;;EAMjB,8BAA8B;EAC9B;;;;;EAKA;EACA,MAAM,OAAO;EACb;EACA,iBAAiB;EACjB;;;;;;EAMA,8BAA8B;;;;;;EAM9B,8BAA8B,WAAW,UAAU;;iBAGrC,wCACd,SAAS,qCACR;cAaU,sCAAsC;mBAY9B;mBAXF;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAGE,YAAA,MAAM,8BACvB,SAAS;EAaX,MAAM,KAAK,oBAAoB;;;;;;;;;UAyFvB;UAaA;UAYA;;;;;;;;KCrNL,sBAAsB;UAEV;WACN;WACA;WACA;WACA;WACA,SAAS;WACT;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA,6BAA6B;WAC7B,mCAAmC;;KAmClC,iBAAiB;WAChB;WAAmB,OAAO;;WAAoB;WAAoB;;iBAmE/D,sBACd,YAAY,mBACX;iBAOa,yBACd,iBACC,iBAAiB;;iBASJ,uBAAuB,KAAK,oCAAoC;;iBAgBhE,oBACd,SAAS,yBACR;iBAOa,uBACd,iBACC,iBAAiB;iBAIJ,qBAAqB,KAAK,kCAAkC;;;KClMhE;;UAKK;WACN;aAAqB;;WACrB,aAAa;WACb,mBAAmB;WACnB,QAAQ;;UAGF;EACf;EACA,SAAS;;;;;;;;;;EAUT;aAAsB;aAAuB;;;EAE7C,iBAAiB;;;;;;;;;;;EAWjB,cAAc;;;;;;;EAOd,eAAe;EACf,iBAAiB;;;;;EAKjB,iBAAiB;;;;;;;;;;;;EAYjB,oBAAoB;;;;;;;EAOpB;aAA0B;;;;;;;EAM1B,wBAAwB;EACxB,iBAAiB;EACjB;;UAGe;EACf;EACA,SAAS;;UAGM;EACf;EACA;;UAGe;EACf;EACA;;;UAIe;EACf;EACA,UAAU;;KAGA,+BACR,8BACA,6BACA,+BACA;UAEa;EACf;;;;;;;;;EASA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA;;UAGe;EACf;EACA;;EAEA,QAAQ;;UAGO;EACf;EACA;;UAGe;EACf;EACA;;KAGU,8BACR,8BACA,kCACA,kCACA,gCACA,+BACA,8BACA;iBAkHY,8BACd,OAAO,2BACN,SAAS;iBAgBI,6BACd,OAAO,2BACN,SAAS;;;;;;;;;;;;;;iBCPI,sBAAsB,aAAa"}
@@ -1,3 +1,3 @@
1
- import{spawn as e}from"node:child_process";import{existsSync as t,readFileSync as n}from"node:fs";import{join as r}from"node:path";import{BackgroundTaskError as i,connectionEnvironmentNames as a,createBackgroundTaskLogPage as o,createProviderFromExactProfile as s,createWorktreeSubagentRunner as c,findConnectionEnvironmentDivergence as l,sealConnectionEnvironment as u,subagentExecutionRoot as d,verifyConnectionEnvironment as f}from"@robota-sdk/agent-executor";import{DEFAULT_KILL_GRACE_MS as p,killProcessTree as ee}from"@robota-sdk/agent-process";import{createBoundedOutput as te,findProviderDefinition as m,isModelEffort as ne,sumHistoryUsage as re}from"@robota-sdk/agent-core";import{createSubagentLogger as ie,createSubagentSession as ae,restoreSessionRecordIntoSession as oe}from"@robota-sdk/agent-framework";function se(e){return{provider:{model:e.provider.model},permissions:e.permissions,defaultTrustLevel:e.defaultTrustLevel,...e.hooks===void 0?{}:{hooks:e.hooks}}}function ce(e){return{agentsMd:e.agentsMd,projectNotesMd:e.projectNotesMd}}const h={name:{kind:`string`,required:!0},description:{kind:`string`,required:!0},systemPrompt:{kind:`string`,required:!0},model:{kind:`string`,required:!1},effort:{kind:`effort`,required:!1},role:{kind:`string`,required:!1},maxTurns:{kind:`number`,required:!1},tools:{kind:`string[]`,required:!1},disallowedTools:{kind:`string[]`,required:!1}},g={agentsMd:{kind:`string`,required:!0},projectNotesMd:{kind:`string`,required:!0},memoryMd:{kind:`string`,required:!1},taskContext:{kind:`string`,required:!1},compactInstructions:{kind:`string`,required:!1},agentsFileEntries:{kind:`file-entry[]`,required:!1},projectNotesFileEntries:{kind:`file-entry[]`,required:!1}};function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function y(e){return _(e)&&typeof e.filePath==`string`&&typeof e.content==`string`&&typeof e.contentHash==`string`}function b(e,t){switch(e){case`string`:return typeof t==`string`;case`number`:return typeof t==`number`&&Number.isFinite(t);case`effort`:return typeof t==`string`&&ne(t);case`string[]`:return v(t);case`file-entry[]`:return Array.isArray(t)&&t.every(y)}}function x(e,t){let n={};for(let r of Object.keys(t)){let t=e[r];t!==void 0&&(n[r]=t)}return n}function S(e,t,n){if(!_(t))return{ok:!1,reason:`${e}: expected an object`};for(let[r,i]of Object.entries(n)){let n=t[r];if(n===void 0){if(i.required)return{ok:!1,reason:`${e}.${r}: required`};continue}if(!b(i.kind,n))return{ok:!1,reason:`${e}.${r}: expected ${i.kind}`}}return{ok:!0,value:x(t,n)}}function C(e){return x(e,h)}function w(e){return S(`agentDefinition`,e,h)}function T(e){let t={name:e.name,description:e.description,systemPrompt:e.systemPrompt};return e.model!==void 0&&(t.model=e.model),e.effort!==void 0&&(t.effort=e.effort),e.role!==void 0&&(t.role=e.role),e.maxTurns!==void 0&&(t.maxTurns=e.maxTurns),e.tools!==void 0&&(t.tools=[...e.tools]),e.disallowedTools!==void 0&&(t.disallowedTools=[...e.disallowedTools]),t}function E(e){return x(e,g)}function D(e){return S(`parentContext`,e,g)}function O(e){let t={agentsMd:e.agentsMd,projectNotesMd:e.projectNotesMd};return e.memoryMd!==void 0&&(t.memoryMd=e.memoryMd),e.taskContext!==void 0&&(t.taskContext=e.taskContext),e.compactInstructions!==void 0&&(t.compactInstructions=e.compactInstructions),e.agentsFileEntries!==void 0&&(t.agentsFileEntries=e.agentsFileEntries.map(e=>({...e}))),e.projectNotesFileEntries!==void 0&&(t.projectNotesFileEntries=e.projectNotesFileEntries.map(e=>({...e}))),t}function le(e){return e.sessionTiers===void 0?{}:{sessionTiers:e.sessionTiers}}async function ue(e){let{sandboxClient:t,sandboxType:n}=e;return t?.snapshot===void 0||n===void 0?{}:{sandboxProjection:{type:n,snapshotId:await t.snapshot()}}}function k(e,t,n,r,o){let s=n.providerDefinitions,c=(n.providerConfig??t.config.provider).name;if(m(s,c)===void 0)throw new i(`validation`,`No provider definition for "${c}" was given to the subagent runner, so the connection a child would make cannot be checked; the subagent was not started.`);let d=j(n.providerConfig,t,e,s),f=a(d,s),p=l(f,r,o);if(p!==void 0)throw new i(`validation`,`The subagent's environment sets ${p} differently from this session, which would change where its provider connects or which credential it sends; the subagent was not started.`);return{providerProfile:d,connectionCheck:u(f,o)}}function de(e,t,n){let r=fe(e.request.agentType,t.customAgentRegistry,t.builtInAgents,t.agentDefinitions),i={taskId:e.taskId,request:e.request,...e.worktree?{worktree:e.worktree}:{},agentDefinition:C(pe(r,e)),parentConfig:se(t.getParentPermissionRules===void 0?t.config:{...t.config,permissions:t.getParentPermissionRules()}),parentContext:E(ce(t.context)),...n.connection??k(e,t,n,process.env,process.env),permissionMode:t.permissionMode,...le(t),...n.logsDir?{logsDir:n.logsDir}:{}};return ue(t).then(e=>({...i,...e}))}function fe(e,t,n,r){let a=t?.(e)??n?.find(t=>t.name===e)??r?.find(t=>t.name===e);if(!a)throw new i(`validation`,`Unknown agent type: ${e}`);return a}function pe(e,t){return{...e,...t.request.model?{model:t.request.model}:{},...t.request.effort===void 0?{}:{effort:t.request.effort},...t.request.allowedTools?{tools:t.request.allowedTools}:{},...t.request.disallowedTools?{disallowedTools:t.request.disallowedTools}:{}}}function A(e,t){return e.apiKeyEnv===void 0?e.apiKey===void 0?t===void 0?{}:t.startsWith(`$ENV:`)?{apiKeyEnv:t.slice(5)}:{apiKey:t}:{apiKey:e.apiKey}:{apiKeyEnv:e.apiKeyEnv}}function j(e,t,n,r){let i=e??t.config.provider,a=m(r,i.name)?.defaults??{},o=i.baseURL??a.baseURL,s=i.options??a.options,c=A(i,a.apiKey);return{...e===void 0&&t.config.currentProvider!==void 0?{profileName:t.config.currentProvider}:{},type:i.name,model:n.request.model??i.model,...c,...o===void 0?{}:{baseURL:o},...i.timeout===void 0?{}:{timeout:i.timeout},...s===void 0?{}:{options:s}}}function M(e){return typeof e==`object`&&!!e}function N(e){if(!M(e)||!P(e,`nonce`)||!P(e,`digest`))return!1;let t=e.names;return Array.isArray(t)&&t.every(e=>typeof e==`string`)}function P(e,t){return typeof e[t]==`string`}function F(e,t){return P(e,t)}function I(e,t){return P(e,t)}function L(e,t){return e[t]===void 0||typeof e[t]==`string`}function R(e){if(e.usage===void 0)return!0;let t=e.usage;return M(t)?typeof t.promptTokens==`number`&&typeof t.completionTokens==`number`&&typeof t.totalTokens==`number`:!1}function z(e){if(e.composedToolNames===void 0)return!0;let t=e.composedToolNames;return Array.isArray(t)?t.every(e=>typeof e==`string`):!1}function B(e){return!M(e)||!I(e,`taskId`)||!M(e.request)||!F(e.request,`agentType`)||!F(e.request,`prompt`)||!F(e.request,`permissionPolicy`)||!F(e.request,`cwd`)||!L(e.request,`resumeSessionId`)||e.worktree!==void 0&&(!M(e.worktree)||!P(e.worktree,`path`))||!w(e.agentDefinition).ok||!M(e.parentConfig)||!D(e.parentContext).ok||!M(e.providerProfile)||!P(e.providerProfile,`type`)||!P(e.providerProfile,`model`)?!1:N(e.connectionCheck)}function V(e){if(!M(e)||!P(e,`type`))return!1;switch(e.type){case`start`:return B(e.payload);case`send`:return P(e,`prompt`);case`cancel`:return e.reason===void 0||typeof e.reason==`string`;default:return!1}}function H(e){if(!M(e)||!P(e,`type`))return!1;switch(e.type){case`ready`:return z(e);case`text_delta`:return P(e,`delta`);case`tool_start`:return P(e,`toolName`);case`tool_end`:return P(e,`toolName`)&&typeof e.success==`boolean`;case`result`:return P(e,`output`)&&R(e);case`error`:return P(e,`message`);case`cancelled`:return e.reason===void 0||typeof e.reason==`string`;default:return!1}}const me=process.platform!==`win32`;function he(e,t){return new Promise(n=>{if(e.exitCode!==null||e.signalCode!==null){n();return}let r=setTimeout(()=>{e.removeListener(`exit`,i),n()},t);r.unref?.();let i=()=>{clearTimeout(r),n()};e.once(`exit`,i)})}const U=new WeakMap;function ge(e){let t=e.stderr;if(!t)return;let n=te({maxBytes:4096,retain:`tail`,truncationMarker:()=>``});U.set(e,n),t.on(`error`,()=>{}),t.on(`data`,e=>n.append(e))}function _e(e){return(U.get(e)?.toString()??``).trim()}function ve(e,t,n,r,a){switch(e.type){case`ready`:t();break;case`result`:n(e);break;case`error`:r(new i(`runner`,e.message));break;case`cancelled`:r(new i(`runner`,e.reason??`Subagent worker cancelled`));break;case`text_delta`:a?.({type:`background_task_text_delta`,delta:e.delta});break;case`tool_start`:a?.({type:`background_task_tool_start`,toolName:e.toolName,firstArg:ye(e.toolArgs)});break;case`tool_end`:a?.({type:`background_task_tool_end`,toolName:e.toolName,success:e.success});break;default:r(new i(`runner`,`Unhandled subagent worker message`))}}function ye(e){if(!e)return;let t=Object.values(e)[0];if(t!==void 0)return typeof t==`object`?JSON.stringify(t):String(t)}function W(e,t){return new Promise((n,r)=>{if(!e.connected){r(new i(`crash`,`Subagent worker IPC channel is closed`));return}e.send(t,e=>{if(e){r(e);return}n()})})}async function G(e,t){await ee(e.child,{graceMs:e.killGraceMs,processGroup:me,preKill:async()=>{e.child.connected&&(await W(e.child,{type:`cancel`,reason:t}).catch(()=>void 0),await he(e.child,e.killGraceMs))}})}function be(e){return new Promise((t,n)=>{new xe(e,t,n).start()})}var xe=class{options;resolve;reject;settled=!1;started=!1;ready=!1;timeoutTimer;handshakeTimer;handshakeBudgetMs;payload;constructor(e,t,n){this.options=e,this.resolve=t,this.reject=n;let r=e.handshakeBudgetMs;this.handshakeBudgetMs=r!==void 0&&r>0?r:3e4,this.payload=e.payload.catch(e=>{this.rejectOnce(e instanceof Error?e:Error(String(e)))}),this.timeoutTimer=Ce(this.options.runtime,e=>this.rejectOnce(e)),this.handshakeTimer=setTimeout(()=>{this.ready||this.settled||(G(this.options.runtime,`Subagent worker never signalled ready`),this.rejectOnce(new i(`runner`,`Subagent worker never signalled ready within ${this.handshakeBudgetMs}ms. Its entry must dispatch worker mode before starting the host application.`)))},this.handshakeBudgetMs),this.handshakeTimer.unref?.()}start(){let{child:e}=this.options.runtime;e.on(`message`,this.onMessage),e.on(`error`,this.onError),e.on(`exit`,this.onExit),e.once(`spawn`,()=>{setImmediate(this.startWorker)})}startWorker=()=>{if(this.started)return;this.started=!0;let{child:e}=this.options.runtime;this.payload.then(t=>t===void 0?void 0:W(e,{type:`start`,payload:t})).catch(e=>{this.rejectOnce(e instanceof Error?e:Error(String(e)))})};onMessage=e=>{if(!H(e)){this.rejectOnce(new i(`runner`,`Received malformed subagent worker message`));return}this.ready=!0,clearTimeout(this.handshakeTimer);let{job:t}=this.options.runtime;ve(e,this.startWorker,this.resolveOnce,this.rejectOnce,t.emit)};onError=e=>{this.rejectOnce(new i(`crash`,e.message))};onExit=(e,t)=>{this.settled||this.rejectOnce(new i(`crash`,Te(e,t,_e(this.options.runtime.child))))};resolveOnce=e=>{if(this.settled)return;this.settled=!0,this.clearTimers(),this.cleanup();let{runtime:t,resolveTranscriptPath:n}=this.options;this.resolve(we(t.job,e,n))};rejectOnce=e=>{this.settled||(this.settled=!0,this.clearTimers(),this.cleanup(),this.reject(e))};clearTimers(){this.timeoutTimer&&clearTimeout(this.timeoutTimer),clearTimeout(this.handshakeTimer)}cleanup(){let{child:e}=this.options.runtime;e.off(`message`,this.onMessage),e.off(`error`,this.onError),e.off(`exit`,this.onExit)}};function Se(e){let t=!1,n=()=>{};return{promise:new Promise((e,t)=>{n=t}),reject(r){t||(t=!0,n(new i(`runner`,r??`Subagent job cancelled: ${e}`)))}}}function Ce(e,t){if(e.job.request.timeoutMs)return setTimeout(()=>{G(e,`Subagent worker timed out`),t(new i(`timeout`,`Subagent worker timed out`))},e.job.request.timeoutMs)}function we(e,t,n){let r=n(e);return{taskId:e.taskId,output:t.output,...r?{metadata:{transcriptPath:r,logPath:r}}:{},...t.usage?{usage:t.usage}:{}}}function Te(e,t,n){return`Subagent worker exited before result: ${t===null?`exit code ${e===null?`unknown`:e}`:`signal ${t}`}${n.length>0?`: ${n}`:``}`}const K=`--__robota-subagent-worker`;function Ee(e){return e.includes(K)}const De=process.platform!==`win32`;function Oe(e){return t=>{let n=new q(t,e);return e.worktreeIsolation===!1?n:c({runner:n,worktreeAdapter:e.worktreeAdapter,hooks:t.config.hooks,hookTypeExecutors:t.hookTypeExecutors})}}var q=class{deps;workerEntry;killGraceMs;handshakeBudgetMs;providerConfig;providerDefinitions;env;logsDir;constructor(e,t){this.deps=e,this.workerEntry=t.workerEntry,this.killGraceMs=t.killGraceMs??p,this.handshakeBudgetMs=t.handshakeBudgetMs,this.providerConfig=t.providerConfig,this.providerDefinitions=t.providerDefinitions,this.env=t.env,this.logsDir=t.logsDir}start(t){let n=this.workerEntry,r={...process.env,...this.env??{}},i=k(t,this.deps,{...this.providerConfig===void 0?{}:{providerConfig:this.providerConfig},providerDefinitions:this.providerDefinitions},process.env,r),a=e(n.execPath,[...n.execArgv??[],...n.args,K],{cwd:d(t),env:r,stdio:[`ignore`,`ignore`,`pipe`,`ipc`],detached:De});ge(a);let o={job:t,child:a,killGraceMs:this.killGraceMs},s=be({runtime:o,payload:this.createStartPayload(t,i),...this.handshakeBudgetMs===void 0?{}:{handshakeBudgetMs:this.handshakeBudgetMs},resolveTranscriptPath:e=>this.resolveTranscriptPath(e)}),c=Se(t.taskId);s.catch(()=>void 0);let l=Promise.race([s,c.promise]);l.catch(()=>void 0);let u=this.resolveTranscriptPath(t);return{taskId:t.taskId,...a.pid!==void 0&&{pid:a.pid},...u!==void 0&&{transcriptPath:u,logPath:u},result:l,cancel:async e=>{c.reject(e),await G(o,e)},send:async e=>{await W(a,{type:`send`,prompt:e})},...u!==void 0&&{readLog:async e=>ke(t.taskId,u,e)}}}createStartPayload(e,t){return de(e,this.deps,{connection:t,providerDefinitions:this.providerDefinitions,...this.logsDir===void 0?{}:{logsDir:this.logsDir}})}resolveTranscriptPath(e){if(this.logsDir)return r(this.logsDir,e.request.parentSessionId,`subagents`,`${e.taskId}.jsonl`)}};function ke(e,r,i){return t(r)?o(e,n(r,`utf8`).split(/\r?\n/).filter(Boolean),i):{taskId:e,cursor:i,lines:[]}}function Ae(e,t,n){let r=e.request.resumeSessionId;if(r!==void 0){if(n===void 0)throw Error(`subagent worker: job ${e.taskId} asks to resume session ${r}, but this composition opens no session store. Register ISubagentWorkerComposition.openSessionStore at the composition root — the same place providerDefinitions is registered.`);oe(n,r,t)}}function je(e,t){let n=e.request.resumeSessionId;if(n!==void 0){if(t.openSessionStore===void 0)throw Error(`subagent worker: job ${e.taskId} asks to resume session ${n}, but this composition opens no session store. Register ISubagentWorkerComposition.openSessionStore at the composition root — the same place providerDefinitions is registered.`);return t.openSessionStore({cwd:e.request.cwd})}}async function Me(e,t){if(e===void 0)return;let n=t?.[e.type];if(n===void 0)throw Error(`subagent worker: sandbox type "${e.type}" is not registered in the worker composition. The parent is sandboxed and passed a snapshot reference, but this child cannot construct that client type. Register it in ISubagentWorkerComposition.sandboxFactories at the composition root — the same place providerDefinitions is registered, and for the same reason.`);return n(e.snapshotId)}const J={write:()=>{},writeLine:()=>{},writeMarkdown:()=>{},writeError:()=>{},prompt:()=>Promise.resolve(``),select:()=>Promise.resolve(0),spinner:()=>({stop:()=>{},update:()=>{}})};let Y=null,X=!1,Z=Promise.resolve();function Q(e){process.send&&process.send(e)}function $(e,t){let n=!1,r=()=>{n||(n=!0,process.exit(t))};if(process.send){let t=setTimeout(r,2e3);t.unref?.(),process.send(e,void 0,void 0,()=>{clearTimeout(t),r()})}else r()}function Ne(e){try{return re(e.getFullHistory())}catch{return}}async function Pe(e,t){try{if(!f(e.connectionCheck,process.env))throw Error(`The provider connection environment changed after the parent checked it; the subagent was not started.`);let n=await Me(e.sandboxProjection,t.sandboxFactories),r=s(e.providerProfile,e.request.model,t.providerDefinitions),i=e.logsDir?ie(e.request.parentSessionId,e.taskId,e.logsDir):void 0,a=je(e,t);Y=ae({agentDefinition:T(e.agentDefinition),parentConfig:e.parentConfig,parentContext:O(e.parentContext),parentTools:t.createTools({cwd:d(e),...n===void 0?{}:{sandboxClient:n},...e.sessionTiers===void 0?{}:{sessionTiers:e.sessionTiers}}),cwd:d(e),provider:r,terminal:J,sessionId:e.request.resumeSessionId??e.taskId,...a===void 0?{}:{sessionStore:a},...i?{sessionLogger:i}:{},permissionMode:e.permissionMode,...e.request.permissionPolicy===void 0?{}:{permissionPolicy:e.request.permissionPolicy},...e.request.allowedTools===void 0?{}:{taskAllowedTools:e.request.allowedTools},...e.request.disallowedTools===void 0?{}:{taskDisallowedTools:e.request.disallowedTools},hooks:e.parentConfig.hooks,...t.createHookTypeExecutors===void 0?{}:{hookTypeExecutors:t.createHookTypeExecutors()},onTextDelta:e=>Q({type:`text_delta`,delta:e}),onToolExecution:Fe}),Ae(e,Y,a);let o=await Y.run(e.request.prompt);if(X){$({type:`cancelled`,reason:`Subagent worker cancelled`},130);return}let c=Ne(Y);$({type:`result`,output:o,...c?{usage:c}:{}},0)}catch(e){if(X){$({type:`cancelled`,reason:`Subagent worker cancelled`},130);return}$({type:`error`,message:e instanceof Error?e.message:String(e)},0)}}function Fe(e){if(e.type===`start`){Q({type:`tool_start`,toolName:e.toolName,toolArgs:e.toolArgs});return}Q({type:`tool_end`,toolName:e.toolName,success:e.success??!0})}function Ie(e){if(Y===null){Q({type:`error`,message:`Subagent worker has not started`});return}Z=Z.then(async()=>{try{await Y?.run(e)}catch(e){Q({type:`error`,message:e instanceof Error?e.message:String(e)})}})}async function Le(e){X=!0,Y?.abort(),Q({type:`cancelled`,reason:e}),await Y?.shutdown({reason:`other`}).catch(()=>void 0),setTimeout(()=>process.exit(130),0)}function Re(e){try{return e.createTools({cwd:process.cwd()}).map(e=>e.getName())}catch(e){process.stderr.write(`robota: could not enumerate the composed tool surface: ${e instanceof Error?e.message:String(e)}\n`);return}}function ze(e){process.send===void 0&&(process.stderr.write(`robota: subagent worker mode requires an IPC channel; it is started by the agent runtime, not by hand.
2
- `),process.exit(2)),process.on(`message`,t=>{if(!V(t)){Q({type:`error`,message:`Malformed subagent worker parent message`});return}switch(t.type){case`start`:Z=Z.then(()=>Pe(t.payload,e));break;case`send`:Ie(t.prompt);break;case`cancel`:Le(t.reason);break;default:Q({type:`error`,message:`Unhandled subagent worker parent message`})}}),process.on(`disconnect`,()=>{X=!0,Y?.abort(),Y?.shutdown({reason:`other`}).catch(()=>void 0)});let t=Re(e);Q({type:`ready`,...t?{composedToolNames:t}:{}})}export{q as ChildProcessSubagentRunner,K as SUBAGENT_WORKER_MODE_FLAG,Oe as createChildProcessSubagentRunnerFactory,w as decodeAgentDefinitionDto,D as decodeParentContextDto,C as encodeAgentDefinition,E as encodeParentContext,H as isSubagentWorkerChildMessage,Ee as isSubagentWorkerModeArgv,V as isSubagentWorkerParentMessage,T as restoreAgentDefinition,O as restoreParentContext,ze as runSubagentWorkerMain};
1
+ import{spawn as e}from"node:child_process";import{existsSync as t,readFileSync as n}from"node:fs";import{join as r}from"node:path";import{BackgroundTaskError as i,connectionEnvironmentNames as a,createBackgroundTaskLogPage as o,createProviderFromExactProfile as s,createWorktreeSubagentRunner as c,findConnectionEnvironmentDivergence as l,sealConnectionEnvironment as u,subagentExecutionRoot as d,verifyConnectionEnvironment as f}from"@robota-sdk/agent-executor";import{DEFAULT_KILL_GRACE_MS as p,killProcessTree as ee}from"@robota-sdk/agent-process";import{createBoundedOutput as te,findProviderDefinition as m,isModelEffort as h,sumHistoryUsage as ne}from"@robota-sdk/agent-core";import{createSubagentLogger as re,createSubagentSession as ie,restoreSessionRecordIntoSession as ae}from"@robota-sdk/agent-framework";function oe(e){return{provider:{model:e.provider.model},permissions:e.permissions,defaultTrustLevel:e.defaultTrustLevel,...e.hooks===void 0?{}:{hooks:e.hooks}}}function se(e){return{agentsMd:e.agentsMd,projectNotesMd:e.projectNotesMd}}const g={name:{kind:`string`,required:!0},description:{kind:`string`,required:!0},systemPrompt:{kind:`string`,required:!0},model:{kind:`string`,required:!1},effort:{kind:`effort`,required:!1},role:{kind:`string`,required:!1},maxTurns:{kind:`number`,required:!1},tools:{kind:`string[]`,required:!1},disallowedTools:{kind:`string[]`,required:!1}},_={agentsMd:{kind:`string`,required:!0},projectNotesMd:{kind:`string`,required:!0},memoryMd:{kind:`string`,required:!1},taskContext:{kind:`string`,required:!1},compactInstructions:{kind:`string`,required:!1},agentsFileEntries:{kind:`file-entry[]`,required:!1},projectNotesFileEntries:{kind:`file-entry[]`,required:!1}};function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ce(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function le(e){return v(e)&&typeof e.filePath==`string`&&typeof e.content==`string`&&typeof e.contentHash==`string`}function ue(e,t){switch(e){case`string`:return typeof t==`string`;case`number`:return typeof t==`number`&&Number.isFinite(t);case`effort`:return typeof t==`string`&&h(t);case`string[]`:return ce(t);case`file-entry[]`:return Array.isArray(t)&&t.every(le)}}function y(e,t){let n={};for(let r of Object.keys(t)){let t=e[r];t!==void 0&&(n[r]=t)}return n}function b(e,t,n){if(!v(t))return{ok:!1,reason:`${e}: expected an object`};for(let[r,i]of Object.entries(n)){let n=t[r];if(n===void 0){if(i.required)return{ok:!1,reason:`${e}.${r}: required`};continue}if(!ue(i.kind,n))return{ok:!1,reason:`${e}.${r}: expected ${i.kind}`}}return{ok:!0,value:y(t,n)}}function x(e){return y(e,g)}function S(e){return b(`agentDefinition`,e,g)}function C(e){let t={name:e.name,description:e.description,systemPrompt:e.systemPrompt};return e.model!==void 0&&(t.model=e.model),e.effort!==void 0&&(t.effort=e.effort),e.role!==void 0&&(t.role=e.role),e.maxTurns!==void 0&&(t.maxTurns=e.maxTurns),e.tools!==void 0&&(t.tools=[...e.tools]),e.disallowedTools!==void 0&&(t.disallowedTools=[...e.disallowedTools]),t}function w(e){return y(e,_)}function T(e){return b(`parentContext`,e,_)}function E(e){let t={agentsMd:e.agentsMd,projectNotesMd:e.projectNotesMd};return e.memoryMd!==void 0&&(t.memoryMd=e.memoryMd),e.taskContext!==void 0&&(t.taskContext=e.taskContext),e.compactInstructions!==void 0&&(t.compactInstructions=e.compactInstructions),e.agentsFileEntries!==void 0&&(t.agentsFileEntries=e.agentsFileEntries.map(e=>({...e}))),e.projectNotesFileEntries!==void 0&&(t.projectNotesFileEntries=e.projectNotesFileEntries.map(e=>({...e}))),t}function de(e){return e.sessionTiers===void 0?{}:{sessionTiers:e.sessionTiers}}async function D(e){let{sandboxClient:t,sandboxType:n}=e;return t?.snapshot===void 0||n===void 0?{}:{sandboxProjection:{type:n,snapshotId:await t.snapshot()}}}function O(e,t,n,r,o){let s=n.providerDefinitions,c=(n.providerConfig??t.config.provider).name;if(m(s,c)===void 0)throw new i(`validation`,`No provider definition for "${c}" was given to the subagent runner, so the connection a child would make cannot be checked; the subagent was not started.`);let d=ge(n.providerConfig,t,e,s),f=a(d,s),p=l(f,r,o);if(p!==void 0)throw new i(`validation`,`The subagent's environment sets ${p} differently from this session, which would change where its provider connects or which credential it sends; the subagent was not started.`);return{providerProfile:d,connectionCheck:u(f,o)}}function fe(e,t,n){let r=pe(e.request.agentType,t.customAgentRegistry,t.builtInAgents,t.agentDefinitions),i={taskId:e.taskId,request:e.request,...e.worktree?{worktree:e.worktree}:{},agentDefinition:x(me(r,e)),parentConfig:oe(t.getParentPermissionRules===void 0?t.config:{...t.config,permissions:t.getParentPermissionRules()}),parentContext:w(se(t.context)),...n.connection??O(e,t,n,process.env,process.env),permissionMode:t.permissionMode,...de(t),...n.parentSandboxSettings===void 0?{}:{parentSandboxSettings:n.parentSandboxSettings},...n.logsDir?{logsDir:n.logsDir}:{}};return D(t).then(e=>({...i,...e}))}function pe(e,t,n,r){let a=t?.(e)??n?.find(t=>t.name===e)??r?.find(t=>t.name===e);if(!a)throw new i(`validation`,`Unknown agent type: ${e}`);return a}function me(e,t){return{...e,...t.request.model?{model:t.request.model}:{},...t.request.effort===void 0?{}:{effort:t.request.effort},...t.request.allowedTools?{tools:t.request.allowedTools}:{},...t.request.disallowedTools?{disallowedTools:t.request.disallowedTools}:{}}}function he(e,t){return e.apiKeyEnv===void 0?e.apiKey===void 0?t===void 0?{}:t.startsWith(`$ENV:`)?{apiKeyEnv:t.slice(5)}:{apiKey:t}:{apiKey:e.apiKey}:{apiKeyEnv:e.apiKeyEnv}}function ge(e,t,n,r){let i=e??t.config.provider,a=m(r,i.name)?.defaults??{},o=i.baseURL??a.baseURL,s=i.options??a.options,c=he(i,a.apiKey);return{...e===void 0&&t.config.currentProvider!==void 0?{profileName:t.config.currentProvider}:{},type:i.name,model:n.request.model??i.model,...c,...o===void 0?{}:{baseURL:o},...i.timeout===void 0?{}:{timeout:i.timeout},...s===void 0?{}:{options:s}}}function k(e){return typeof e==`object`&&!!e}function A(e){if(!k(e)||!j(e,`nonce`)||!j(e,`digest`))return!1;let t=e.names;return Array.isArray(t)&&t.every(e=>typeof e==`string`)}function j(e,t){return typeof e[t]==`string`}function M(e,t){return j(e,t)}function N(e,t){return j(e,t)}function P(e,t){return e[t]===void 0||typeof e[t]==`string`}function F(e){if(e.usage===void 0)return!0;let t=e.usage;return k(t)?typeof t.promptTokens==`number`&&typeof t.completionTokens==`number`&&typeof t.totalTokens==`number`:!1}function I(e){if(e.composedToolNames===void 0)return!0;let t=e.composedToolNames;return Array.isArray(t)?t.every(e=>typeof e==`string`):!1}function L(e){return!k(e)||!N(e,`taskId`)||!k(e.request)||!M(e.request,`agentType`)||!M(e.request,`prompt`)||!M(e.request,`permissionPolicy`)||!M(e.request,`cwd`)||!P(e.request,`resumeSessionId`)||e.worktree!==void 0&&(!k(e.worktree)||!j(e.worktree,`path`))||!S(e.agentDefinition).ok||!k(e.parentConfig)||!T(e.parentContext).ok||!k(e.providerProfile)||!j(e.providerProfile,`type`)||!j(e.providerProfile,`model`)||e.parentSandboxSettings!==void 0&&!k(e.parentSandboxSettings)?!1:A(e.connectionCheck)}function R(e){if(!k(e)||!j(e,`type`))return!1;switch(e.type){case`start`:return L(e.payload);case`send`:return j(e,`prompt`);case`cancel`:return e.reason===void 0||typeof e.reason==`string`;case`sandbox_settings`:return k(e.settings);default:return!1}}function z(e){if(!k(e)||!j(e,`type`))return!1;switch(e.type){case`ready`:return I(e);case`text_delta`:return j(e,`delta`);case`tool_start`:return j(e,`toolName`);case`tool_end`:return j(e,`toolName`)&&typeof e.success==`boolean`;case`result`:return j(e,`output`)&&F(e);case`error`:return j(e,`message`);case`cancelled`:return e.reason===void 0||typeof e.reason==`string`;default:return!1}}const _e=process.platform!==`win32`;function ve(e,t){return new Promise(n=>{if(e.exitCode!==null||e.signalCode!==null){n();return}let r=setTimeout(()=>{e.removeListener(`exit`,i),n()},t);r.unref?.();let i=()=>{clearTimeout(r),n()};e.once(`exit`,i)})}const B=new WeakMap;function ye(e){let t=e.stderr;if(!t)return;let n=te({maxBytes:4096,retain:`tail`,truncationMarker:()=>``});B.set(e,n),t.on(`error`,()=>{}),t.on(`data`,e=>n.append(e))}function be(e){return(B.get(e)?.toString()??``).trim()}function xe(e,t,n,r,a){switch(e.type){case`ready`:t();break;case`result`:n(e);break;case`error`:r(new i(`runner`,e.message));break;case`cancelled`:r(new i(`runner`,e.reason??`Subagent worker cancelled`));break;case`text_delta`:a?.({type:`background_task_text_delta`,delta:e.delta});break;case`tool_start`:a?.({type:`background_task_tool_start`,toolName:e.toolName,firstArg:Se(e.toolArgs)});break;case`tool_end`:a?.({type:`background_task_tool_end`,toolName:e.toolName,success:e.success});break;default:r(new i(`runner`,`Unhandled subagent worker message`))}}function Se(e){if(!e)return;let t=Object.values(e)[0];if(t!==void 0)return typeof t==`object`?JSON.stringify(t):String(t)}function V(e,t){return new Promise((n,r)=>{if(!e.connected){r(new i(`crash`,`Subagent worker IPC channel is closed`));return}e.send(t,e=>{if(e){r(e);return}n()})})}async function H(e,t){await ee(e.child,{graceMs:e.killGraceMs,processGroup:_e,preKill:async()=>{e.child.connected&&(await V(e.child,{type:`cancel`,reason:t}).catch(()=>void 0),await ve(e.child,e.killGraceMs))}})}function Ce(e){return new Promise((t,n)=>{new we(e,t,n).start()})}var we=class{options;resolve;reject;settled=!1;started=!1;ready=!1;timeoutTimer;handshakeTimer;handshakeBudgetMs;payload;constructor(e,t,n){this.options=e,this.resolve=t,this.reject=n;let r=e.handshakeBudgetMs;this.handshakeBudgetMs=r!==void 0&&r>0?r:3e4,this.payload=e.payload.catch(e=>{this.rejectOnce(e instanceof Error?e:Error(String(e)))}),this.timeoutTimer=Ee(this.options.runtime,e=>this.rejectOnce(e)),this.handshakeTimer=setTimeout(()=>{this.ready||this.settled||(H(this.options.runtime,`Subagent worker never signalled ready`),this.rejectOnce(new i(`runner`,`Subagent worker never signalled ready within ${this.handshakeBudgetMs}ms. Its entry must dispatch worker mode before starting the host application.`)))},this.handshakeBudgetMs),this.handshakeTimer.unref?.()}start(){let{child:e}=this.options.runtime;e.on(`message`,this.onMessage),e.on(`error`,this.onError),e.on(`exit`,this.onExit),e.once(`spawn`,()=>{setImmediate(this.startWorker)})}startWorker=()=>{if(this.started)return;this.started=!0;let{child:e}=this.options.runtime;this.payload.then(t=>t===void 0?void 0:V(e,{type:`start`,payload:t})).catch(e=>{this.rejectOnce(e instanceof Error?e:Error(String(e)))})};onMessage=e=>{if(!z(e)){this.rejectOnce(new i(`runner`,`Received malformed subagent worker message`));return}this.ready=!0,clearTimeout(this.handshakeTimer);let{job:t}=this.options.runtime;xe(e,this.startWorker,this.resolveOnce,this.rejectOnce,t.emit)};onError=e=>{this.rejectOnce(new i(`crash`,e.message))};onExit=(e,t)=>{this.settled||this.rejectOnce(new i(`crash`,Oe(e,t,be(this.options.runtime.child))))};resolveOnce=e=>{if(this.settled)return;this.settled=!0,this.clearTimers(),this.cleanup();let{runtime:t,resolveTranscriptPath:n}=this.options;this.resolve(De(t.job,e,n))};rejectOnce=e=>{this.settled||(this.settled=!0,this.clearTimers(),this.cleanup(),this.reject(e))};clearTimers(){this.timeoutTimer&&clearTimeout(this.timeoutTimer),clearTimeout(this.handshakeTimer)}cleanup(){let{child:e}=this.options.runtime;e.off(`message`,this.onMessage),e.off(`error`,this.onError),e.off(`exit`,this.onExit)}};function Te(e){let t=!1,n=()=>{};return{promise:new Promise((e,t)=>{n=t}),reject(r){t||(t=!0,n(new i(`runner`,r??`Subagent job cancelled: ${e}`)))}}}function Ee(e,t){if(e.job.request.timeoutMs)return setTimeout(()=>{H(e,`Subagent worker timed out`),t(new i(`timeout`,`Subagent worker timed out`))},e.job.request.timeoutMs)}function De(e,t,n){let r=n(e);return{taskId:e.taskId,output:t.output,...r?{metadata:{transcriptPath:r,logPath:r}}:{},...t.usage?{usage:t.usage}:{}}}function Oe(e,t,n){return`Subagent worker exited before result: ${t===null?`exit code ${e===null?`unknown`:e}`:`signal ${t}`}${n.length>0?`: ${n}`:``}`}const U=`--__robota-subagent-worker`;function ke(e){return e.includes(U)}const Ae=process.platform!==`win32`;function je(e){return t=>{let n=new W(t,e);return e.worktreeIsolation===!1?n:c({runner:n,worktreeAdapter:e.worktreeAdapter,hooks:t.config.hooks,hookTypeExecutors:t.hookTypeExecutors})}}var W=class{deps;workerEntry;killGraceMs;handshakeBudgetMs;providerConfig;providerDefinitions;env;logsDir;parentSandboxSettings;watchParentSandboxSettings;constructor(e,t){this.deps=e,this.workerEntry=t.workerEntry,this.killGraceMs=t.killGraceMs??p,this.handshakeBudgetMs=t.handshakeBudgetMs,this.providerConfig=t.providerConfig,this.providerDefinitions=t.providerDefinitions,this.env=t.env,this.logsDir=t.logsDir,this.parentSandboxSettings=t.parentSandboxSettings,this.watchParentSandboxSettings=t.watchParentSandboxSettings}start(t){let n=this.workerEntry,r={...process.env,...this.env??{}},i=O(t,this.deps,{...this.providerConfig===void 0?{}:{providerConfig:this.providerConfig},providerDefinitions:this.providerDefinitions},process.env,r),a=e(n.execPath,[...n.execArgv??[],...n.args,U],{cwd:d(t),env:r,stdio:[`ignore`,`ignore`,`pipe`,`ipc`],detached:Ae});ye(a),this.forwardSandboxSettingChanges(a);let o={job:t,child:a,killGraceMs:this.killGraceMs},s=Ce({runtime:o,payload:this.createStartPayload(t,i),...this.handshakeBudgetMs===void 0?{}:{handshakeBudgetMs:this.handshakeBudgetMs},resolveTranscriptPath:e=>this.resolveTranscriptPath(e)}),c=Te(t.taskId);s.catch(()=>void 0);let l=Promise.race([s,c.promise]);l.catch(()=>void 0);let u=this.resolveTranscriptPath(t);return{taskId:t.taskId,...a.pid!==void 0&&{pid:a.pid},...u!==void 0&&{transcriptPath:u,logPath:u},result:l,cancel:async e=>{c.reject(e),await H(o,e)},send:async e=>{await V(a,{type:`send`,prompt:e})},...u!==void 0&&{readLog:async e=>Me(t.taskId,u,e)}}}createStartPayload(e,t){let n=this.parentSandboxSettings?.();return fe(e,this.deps,{connection:t,providerDefinitions:this.providerDefinitions,...this.logsDir===void 0?{}:{logsDir:this.logsDir},...n===void 0?{}:{parentSandboxSettings:n}})}forwardSandboxSettingChanges(e){let t=this.watchParentSandboxSettings?.(t=>{e.connected&&V(e,{type:`sandbox_settings`,settings:t}).catch(()=>void 0)});t!==void 0&&(e.once(`exit`,t),e.once(`error`,t))}resolveTranscriptPath(e){if(this.logsDir)return r(this.logsDir,e.request.parentSessionId,`subagents`,`${e.taskId}.jsonl`)}};function Me(e,r,i){return t(r)?o(e,n(r,`utf8`).split(/\r?\n/).filter(Boolean),i):{taskId:e,cursor:i,lines:[]}}function Ne(e,t,n){let r=e.request.resumeSessionId;if(r!==void 0){if(n===void 0)throw Error(`subagent worker: job ${e.taskId} asks to resume session ${r}, but this composition opens no session store. Register ISubagentWorkerComposition.openSessionStore at the composition root — the same place providerDefinitions is registered.`);ae(n,r,t)}}function Pe(e,t){let n=e.request.resumeSessionId;if(n!==void 0){if(t.openSessionStore===void 0)throw Error(`subagent worker: job ${e.taskId} asks to resume session ${n}, but this composition opens no session store. Register ISubagentWorkerComposition.openSessionStore at the composition root — the same place providerDefinitions is registered.`);return t.openSessionStore({cwd:e.request.cwd})}}async function Fe(e,t){if(e===void 0)return;let n=t?.[e.type];if(n===void 0)throw Error(`subagent worker: sandbox type "${e.type}" is not registered in the worker composition. The parent is sandboxed and passed a snapshot reference, but this child cannot construct that client type. Register it in ISubagentWorkerComposition.sandboxFactories at the composition root — the same place providerDefinitions is registered, and for the same reason.`);return n(e.snapshotId)}const Ie={write:()=>{},writeLine:()=>{},writeMarkdown:()=>{},writeError:()=>{},prompt:()=>Promise.resolve(``),select:()=>Promise.resolve(0),spinner:()=>({stop:()=>{},update:()=>{}})};let G=null,K=!1,q,J,Y,X=Promise.resolve();function Z(e){process.send&&process.send(e)}function Q(e,t){let n=!1,r=()=>{n||(n=!0,process.exit(t))};if(process.send){let t=setTimeout(r,2e3);t.unref?.(),process.send(e,void 0,void 0,()=>{clearTimeout(t),r()})}else r()}function Le(e){try{return ne(e.getFullHistory())}catch{return}}async function Re(e,t){try{if(!f(e.connectionCheck,process.env))throw Error(`The provider connection environment changed after the parent checked it; the subagent was not started.`);let n=await Fe(e.sandboxProjection,t.sandboxFactories),r=s(e.providerProfile,e.request.model,t.providerDefinitions),i=e.logsDir?re(e.request.parentSessionId,e.taskId,e.logsDir):void 0,a=Pe(e,t),o=q??e.parentSandboxSettings;J=n===void 0?t.createSandbox?.({cwd:d(e),...o===void 0?{}:{parentSettings:o}}):void 0;let c=n??J?.client;G=ie({agentDefinition:C(e.agentDefinition),parentConfig:e.parentConfig,parentContext:E(e.parentContext),parentTools:t.createTools({cwd:d(e),...c===void 0?{}:{sandboxClient:c},...e.sessionTiers===void 0?{}:{sessionTiers:e.sessionTiers}}),cwd:d(e),provider:r,terminal:Ie,sessionId:e.request.resumeSessionId??e.taskId,...a===void 0?{}:{sessionStore:a},...i?{sessionLogger:i}:{},permissionMode:e.permissionMode,...J?.commandSandbox===void 0?{}:{commandSandbox:J.commandSandbox},...e.request.permissionPolicy===void 0?{}:{permissionPolicy:e.request.permissionPolicy},...e.request.allowedTools===void 0?{}:{taskAllowedTools:e.request.allowedTools},...e.request.disallowedTools===void 0?{}:{taskDisallowedTools:e.request.disallowedTools},hooks:e.parentConfig.hooks,...t.createHookTypeExecutors===void 0?{}:{hookTypeExecutors:t.createHookTypeExecutors()},onTextDelta:e=>Z({type:`text_delta`,delta:e}),onToolExecution:$}),Ne(e,G,a);let l=await G.run(e.request.prompt);if(Y!==void 0){Q({type:`error`,message:Y},0);return}if(K){Q({type:`cancelled`,reason:`Subagent worker cancelled`},130);return}let u=Le(G);Q({type:`result`,output:l,...u?{usage:u}:{}},0)}catch(e){if(Y!==void 0){Q({type:`error`,message:Y},0);return}if(K){Q({type:`cancelled`,reason:`Subagent worker cancelled`},130);return}Q({type:`error`,message:e instanceof Error?e.message:String(e)},0)}}function $(e){if(e.type===`start`){Z({type:`tool_start`,toolName:e.toolName,toolArgs:e.toolArgs});return}Z({type:`tool_end`,toolName:e.toolName,success:e.success??!0})}function ze(e){if(G===null){Z({type:`error`,message:`Subagent worker has not started`});return}X=X.then(async()=>{try{await G?.run(e)}catch(e){Z({type:`error`,message:e instanceof Error?e.message:String(e)})}})}async function Be(e){K=!0,G?.abort(),Z({type:`cancelled`,reason:e}),await G?.shutdown({reason:`other`}).catch(()=>void 0),setTimeout(()=>process.exit(130),0)}function Ve(e){try{return e.createTools({cwd:process.cwd()}).map(e=>e.getName())}catch(e){process.stderr.write(`robota: could not enumerate the composed tool surface: ${e instanceof Error?e.message:String(e)}\n`);return}}function He(e){q=e;try{J?.applyParentSettings?.(e)}catch(e){Y??=e instanceof Error?e.message:String(e),G?.abort()}}function Ue(e){process.send===void 0&&(process.stderr.write(`robota: subagent worker mode requires an IPC channel; it is started by the agent runtime, not by hand.
2
+ `),process.exit(2)),process.on(`message`,t=>{if(!R(t)){Z({type:`error`,message:`Malformed subagent worker parent message`});return}switch(t.type){case`start`:X=X.then(()=>Re(t.payload,e));break;case`send`:ze(t.prompt);break;case`cancel`:Be(t.reason);break;case`sandbox_settings`:He(t.settings);break;default:Z({type:`error`,message:`Unhandled subagent worker parent message`})}}),process.on(`disconnect`,()=>{K=!0,G?.abort(),G?.shutdown({reason:`other`}).catch(()=>void 0)});let t=Ve(e);Z({type:`ready`,...t?{composedToolNames:t}:{}})}export{W as ChildProcessSubagentRunner,U as SUBAGENT_WORKER_MODE_FLAG,je as createChildProcessSubagentRunnerFactory,S as decodeAgentDefinitionDto,T as decodeParentContextDto,x as encodeAgentDefinition,w as encodeParentContext,z as isSubagentWorkerChildMessage,ke as isSubagentWorkerModeArgv,R as isSubagentWorkerParentMessage,C as restoreAgentDefinition,E as restoreParentContext,Ue as runSubagentWorkerMain};
3
3
  //# sourceMappingURL=index.js.map