@demicodes/agent 0.19.2 → 0.19.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.
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +168 -37
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -339,6 +339,7 @@ declare class AgentServer {
|
|
|
339
339
|
//#endregion
|
|
340
340
|
//#region src/subagent.d.ts
|
|
341
341
|
declare const MAX_LIVE_SUBAGENTS = 8;
|
|
342
|
+
declare const MAX_ARCHIVED_SUBAGENTS = 16;
|
|
342
343
|
declare const SUBAGENT_RESULT_MAX_BYTES: number;
|
|
343
344
|
type SubagentExecution = 'idle' | 'provider_streaming' | 'tool_executing' | 'compacting' | 'finalizing' | 'pending_yield';
|
|
344
345
|
interface ChildSupervisorOptions<State> {
|
|
@@ -364,7 +365,8 @@ interface ChildSupervisorOptions<State> {
|
|
|
364
365
|
* on the parent connection. Children persist exactly like the parent: each
|
|
365
366
|
* live child keeps a checkpoint and job record under the parent's session
|
|
366
367
|
* directory, and reopening the parent restores and resumes them (`restore`).
|
|
367
|
-
* A closed child
|
|
368
|
+
* A closed child moves to the archive: its transcript checkpoint stays on
|
|
369
|
+
* store and `demi agent resume` revives it with a new user message.
|
|
368
370
|
*/
|
|
369
371
|
declare class ChildSupervisor<State = unknown> {
|
|
370
372
|
private readonly options;
|
|
@@ -399,6 +401,18 @@ declare class ChildSupervisor<State = unknown> {
|
|
|
399
401
|
*/
|
|
400
402
|
restore(): Promise<void>;
|
|
401
403
|
private restoreJob;
|
|
404
|
+
/** Shared by restore and resume: rebuild a persisted child's job and session from its checkpoint. */
|
|
405
|
+
private reassembleJob;
|
|
406
|
+
/**
|
|
407
|
+
* Revives an archived child: its job record turns live again (this round's
|
|
408
|
+
* metadata, a fresh spawnedAt), the session rebuilds from the preserved
|
|
409
|
+
* checkpoint, and the message opens its next turn on top of the old
|
|
410
|
+
* transcript.
|
|
411
|
+
*/
|
|
412
|
+
private resumeArchived;
|
|
413
|
+
/** Every archived (finished, revivable) child of this parent, newest first. */
|
|
414
|
+
private listArchivedJobs;
|
|
415
|
+
private pruneArchive;
|
|
402
416
|
abortSubtree(id: string): Promise<void>;
|
|
403
417
|
private spawn;
|
|
404
418
|
/** Everything spawn and restore share: the command tree, the harness runtime, and the job record (session attached separately). */
|
|
@@ -407,6 +421,8 @@ declare class ChildSupervisor<State = unknown> {
|
|
|
407
421
|
private childStoreKey;
|
|
408
422
|
private childSessionStore;
|
|
409
423
|
private deletePersistedJob;
|
|
424
|
+
/** Shared spawn/resume foreground behaviour: announce the id, wire abort and stdin steers, wait for close, report the outcome. */
|
|
425
|
+
private attendChild;
|
|
410
426
|
/** Delivers one steer to a child: mid-turn as a steer, idle as a new user turn. */
|
|
411
427
|
private steerChild;
|
|
412
428
|
private pumpStdinSteers;
|
|
@@ -516,4 +532,4 @@ interface ShellToolView {
|
|
|
516
532
|
declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandStatus, ctx: AgentToolInvokeContext<State>): Promise<AgentToolInvokeResult>;
|
|
517
533
|
declare function shellCommandHandleRequired(result: ShellCommandStatus, budgetTokens: number): boolean;
|
|
518
534
|
//#endregion
|
|
519
|
-
export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentHostContext, AgentLifecycleEvent, AgentMetadata, AgentPromptContext, AgentReferenceResolveContext, AgentServer, AgentServerOptions, AgentServerSessionOptions, AgentServerTransport, AgentSession, AgentSessionCheckpoint, AgentSessionCloneParams, AgentSessionOptions, AgentSessionParams, AgentSessionRestoreParams, AgentSessionStore, AgentSystemPromptContext, AgentTool, AgentToolContext, AgentToolInvokeContext, AgentToolInvokeResult, AgentTransport, AgentTransportBinding, ChildSupervisor, ChildSupervisorOptions, ClientFrame, ClientSessionEvent, CompactionWindow, ConversationSummary, DEFAULT_MAX_MEDIA_BYTES, DEFAULT_TURN_RETRY_POLICY, DrainedTranscriptPatches, ExternalMutationReservation, InProcessTransportPair, JsonWebSocket, MAX_LIVE_SUBAGENTS, ModelSwitchApply, PrepareShell, PrepareShellContext, ProviderStreamError, ResumePoint, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, SUBAGENT_RESULT_MAX_BYTES, ServerFrame, SessionEvent, SessionEventListener, ShellCommandStatusLike, ShellToolResultOptions, ShellToolView, StandardAgentToolOptions, SubagentExecution, SubagentJob, SubagentProfile, TranscriptLog, TranscriptOptions, TranscriptPatch, TurnRetryPolicy, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createReadonlyHost, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, findResumePoint, finishShellToolResult, injectSubagentCommand, isContextLengthExceeded, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
|
|
535
|
+
export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentHostContext, AgentLifecycleEvent, AgentMetadata, AgentPromptContext, AgentReferenceResolveContext, AgentServer, AgentServerOptions, AgentServerSessionOptions, AgentServerTransport, AgentSession, AgentSessionCheckpoint, AgentSessionCloneParams, AgentSessionOptions, AgentSessionParams, AgentSessionRestoreParams, AgentSessionStore, AgentSystemPromptContext, AgentTool, AgentToolContext, AgentToolInvokeContext, AgentToolInvokeResult, AgentTransport, AgentTransportBinding, ChildSupervisor, ChildSupervisorOptions, ClientFrame, ClientSessionEvent, CompactionWindow, ConversationSummary, DEFAULT_MAX_MEDIA_BYTES, DEFAULT_TURN_RETRY_POLICY, DrainedTranscriptPatches, ExternalMutationReservation, InProcessTransportPair, JsonWebSocket, MAX_ARCHIVED_SUBAGENTS, MAX_LIVE_SUBAGENTS, ModelSwitchApply, PrepareShell, PrepareShellContext, ProviderStreamError, ResumePoint, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, SUBAGENT_RESULT_MAX_BYTES, ServerFrame, SessionEvent, SessionEventListener, ShellCommandStatusLike, ShellToolResultOptions, ShellToolView, StandardAgentToolOptions, SubagentExecution, SubagentJob, SubagentProfile, TranscriptLog, TranscriptOptions, TranscriptPatch, TurnRetryPolicy, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createReadonlyHost, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, findResumePoint, finishShellToolResult, injectSubagentCommand, isContextLengthExceeded, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
|
package/dist/index.mjs
CHANGED
|
@@ -2653,6 +2653,7 @@ function shellCommandHandleRequired(result, budgetTokens) {
|
|
|
2653
2653
|
//#endregion
|
|
2654
2654
|
//#region src/subagent.ts
|
|
2655
2655
|
const MAX_LIVE_SUBAGENTS = 8;
|
|
2656
|
+
const MAX_ARCHIVED_SUBAGENTS = 16;
|
|
2656
2657
|
const SUBAGENT_RESULT_MAX_BYTES = 32768;
|
|
2657
2658
|
const SHOW_RECENT_TOOLS = 8;
|
|
2658
2659
|
const SPAWN_PROMPT_DESCRIPTION = "The child's first user message and only task brief. The child starts with an empty transcript and cannot see this conversation: do not refer to prior turns, and do not paste this conversation or the product user's message unchanged. Include the goal for this child, applicable decisions and constraints, whether to edit or only report, how to verify, and every concrete identifier it needs (paths, ids, error text, commands already tried and their key results). State the exact shape of the last assistant text it should return.";
|
|
@@ -2663,7 +2664,8 @@ const SPAWN_PROMPT_DESCRIPTION = "The child's first user message and only task b
|
|
|
2663
2664
|
* on the parent connection. Children persist exactly like the parent: each
|
|
2664
2665
|
* live child keeps a checkpoint and job record under the parent's session
|
|
2665
2666
|
* directory, and reopening the parent restores and resumes them (`restore`).
|
|
2666
|
-
* A closed child
|
|
2667
|
+
* A closed child moves to the archive: its transcript checkpoint stays on
|
|
2668
|
+
* store and `demi agent resume` revives it with a new user message.
|
|
2667
2669
|
*/
|
|
2668
2670
|
var ChildSupervisor = class {
|
|
2669
2671
|
options;
|
|
@@ -2712,30 +2714,12 @@ var ChildSupervisor = class {
|
|
|
2712
2714
|
await io.stderr(`demi agent: ${errorMessage(error)}\n`);
|
|
2713
2715
|
return { exitCode: 1 };
|
|
2714
2716
|
}
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
this.pumpStdinSteers(job.id, stdinStream);
|
|
2722
|
-
const close = await job.closed;
|
|
2723
|
-
signal.removeEventListener("abort", onAbort);
|
|
2724
|
-
if (close.phase === "completed") {
|
|
2725
|
-
const text = close.result ?? "";
|
|
2726
|
-
if (parsed.json) await io.stdout(`${JSON.stringify({
|
|
2727
|
-
subagentId: job.id,
|
|
2728
|
-
text
|
|
2729
|
-
})}\n`);
|
|
2730
|
-
else if (text.length > 0) await io.stdout(text.endsWith("\n") ? text : `${text}\n`);
|
|
2731
|
-
return { exitCode: 0 };
|
|
2732
|
-
}
|
|
2733
|
-
if (close.phase === "aborted") {
|
|
2734
|
-
await io.stderr(`demi agent: subagent ${job.id} aborted\n`);
|
|
2735
|
-
return { exitCode: 130 };
|
|
2736
|
-
}
|
|
2737
|
-
await io.stderr(`demi agent: subagent ${job.id} failed: ${close.failure ?? "unknown error"}\n`);
|
|
2738
|
-
return { exitCode: 1 };
|
|
2717
|
+
return this.attendChild(job, {
|
|
2718
|
+
io,
|
|
2719
|
+
isJson: parsed.json === true,
|
|
2720
|
+
signal,
|
|
2721
|
+
stdinStream
|
|
2722
|
+
});
|
|
2739
2723
|
},
|
|
2740
2724
|
subcommands: [
|
|
2741
2725
|
{
|
|
@@ -2794,21 +2778,73 @@ var ChildSupervisor = class {
|
|
|
2794
2778
|
return { exitCode: 0 };
|
|
2795
2779
|
}
|
|
2796
2780
|
},
|
|
2781
|
+
{
|
|
2782
|
+
name: "resume",
|
|
2783
|
+
summary: "Revive an archived (finished) child with a new user message on top of its preserved transcript. Behaves like the spawn command afterwards: stays running until the child ends again, stdout is its new last assistant text, shell_write steers, shell_abort aborts. Archived ids are in `demi agent list`.",
|
|
2784
|
+
input: {
|
|
2785
|
+
id: z.string().describe("subagentId of an archived child"),
|
|
2786
|
+
message: z.string().optional().describe("The reviving user message; positional, or stdin/heredoc when omitted.")
|
|
2787
|
+
},
|
|
2788
|
+
positionals: ["id", "message"],
|
|
2789
|
+
stdinField: "message",
|
|
2790
|
+
output: { json: z.object({
|
|
2791
|
+
subagentId: z.string(),
|
|
2792
|
+
text: z.string()
|
|
2793
|
+
}) },
|
|
2794
|
+
run: async ({ parsed, io, signal, stdinStream }) => {
|
|
2795
|
+
const id = String(parsed.values.id);
|
|
2796
|
+
const message = String(parsed.values.message ?? "").trim();
|
|
2797
|
+
if (!message) {
|
|
2798
|
+
await io.stderr("demi agent resume: message must not be empty\n");
|
|
2799
|
+
return { exitCode: 1 };
|
|
2800
|
+
}
|
|
2801
|
+
let job;
|
|
2802
|
+
try {
|
|
2803
|
+
job = await this.resumeArchived(id, message);
|
|
2804
|
+
} catch (error) {
|
|
2805
|
+
await io.stderr(`demi agent resume: ${errorMessage(error)}\n`);
|
|
2806
|
+
return { exitCode: 1 };
|
|
2807
|
+
}
|
|
2808
|
+
return this.attendChild(job, {
|
|
2809
|
+
io,
|
|
2810
|
+
isJson: parsed.json === true,
|
|
2811
|
+
signal,
|
|
2812
|
+
stdinStream
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
},
|
|
2797
2816
|
{
|
|
2798
2817
|
name: "list",
|
|
2799
|
-
summary: "Snapshot roster of this session's running children (finished
|
|
2800
|
-
output: { json: z.object({
|
|
2818
|
+
summary: "Snapshot roster of this session's running children, then its archived (finished, revivable via resume) children. One line per child with ages relative to now. A read, not a wait — not for polling loops.",
|
|
2819
|
+
output: { json: z.object({
|
|
2820
|
+
agents: z.array(z.unknown()),
|
|
2821
|
+
archived: z.array(z.unknown())
|
|
2822
|
+
}) },
|
|
2801
2823
|
run: async ({ parsed, io }) => {
|
|
2802
2824
|
const jobs = [...this.jobs.values()];
|
|
2825
|
+
const archived = await this.listArchivedJobs();
|
|
2803
2826
|
if (parsed.json) {
|
|
2804
|
-
await io.stdout(`${JSON.stringify({
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2827
|
+
await io.stdout(`${JSON.stringify({
|
|
2828
|
+
agents: jobs.map((job) => this.snapshot(job, false)),
|
|
2829
|
+
archived: archived.map(({ id, meta }) => ({
|
|
2830
|
+
subagentId: id,
|
|
2831
|
+
description: meta.description,
|
|
2832
|
+
profile: meta.profileName,
|
|
2833
|
+
phase: meta.closedPhase,
|
|
2834
|
+
closedAgoMs: meta.closedAt === void 0 ? null : Date.now() - meta.closedAt
|
|
2835
|
+
}))
|
|
2836
|
+
})}\n`);
|
|
2809
2837
|
return { exitCode: 0 };
|
|
2810
2838
|
}
|
|
2839
|
+
if (jobs.length === 0) await io.stdout("no running subagents\n");
|
|
2811
2840
|
for (const job of jobs) await io.stdout(`${this.renderListLine(job)}\n`);
|
|
2841
|
+
if (archived.length > 0) {
|
|
2842
|
+
await io.stdout("archived (revivable with `demi agent resume <id>`):\n");
|
|
2843
|
+
for (const { id, meta } of archived) {
|
|
2844
|
+
const closedAgo = meta.closedAt === void 0 ? "" : ` closed ${formatDuration(Date.now() - meta.closedAt)} ago`;
|
|
2845
|
+
await io.stdout(` ${id} ${meta.closedPhase}${closedAgo} ${meta.description ? `"${meta.description}"` : "(no description)"}\n`);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2812
2848
|
return { exitCode: 0 };
|
|
2813
2849
|
}
|
|
2814
2850
|
},
|
|
@@ -2901,11 +2937,18 @@ var ChildSupervisor = class {
|
|
|
2901
2937
|
}
|
|
2902
2938
|
}
|
|
2903
2939
|
async restoreJob(id) {
|
|
2904
|
-
|
|
2905
|
-
if (!parent) return;
|
|
2940
|
+
if (!this.parentSession) return;
|
|
2906
2941
|
const meta = await this.options.store.readJson(this.childStoreKey(id, "job.json"));
|
|
2942
|
+
if (meta?.closedPhase) return;
|
|
2907
2943
|
const checkpoint = await this.childSessionStore(id).loadCheckpoint();
|
|
2908
2944
|
if (!meta || !checkpoint) throw new Error("incomplete persisted subagent");
|
|
2945
|
+
const job = this.reassembleJob(id, meta, checkpoint);
|
|
2946
|
+
this.watchTurn(job, job.session.resume(meta.metadata ? { metadata: meta.metadata } : {}));
|
|
2947
|
+
}
|
|
2948
|
+
/** Shared by restore and resume: rebuild a persisted child's job and session from its checkpoint. */
|
|
2949
|
+
reassembleJob(id, meta, checkpoint) {
|
|
2950
|
+
const parent = this.parentSession;
|
|
2951
|
+
if (!parent) throw new Error("subagent supervisor has no parent session");
|
|
2909
2952
|
const profile = this.resolveProfile(meta.profileName ?? void 0);
|
|
2910
2953
|
const { job, runtime } = this.assembleJob({
|
|
2911
2954
|
id,
|
|
@@ -2925,7 +2968,59 @@ var ChildSupervisor = class {
|
|
|
2925
2968
|
...this.options.sessionOptions
|
|
2926
2969
|
});
|
|
2927
2970
|
this.attachSession(job, session);
|
|
2928
|
-
|
|
2971
|
+
return job;
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* Revives an archived child: its job record turns live again (this round's
|
|
2975
|
+
* metadata, a fresh spawnedAt), the session rebuilds from the preserved
|
|
2976
|
+
* checkpoint, and the message opens its next turn on top of the old
|
|
2977
|
+
* transcript.
|
|
2978
|
+
*/
|
|
2979
|
+
async resumeArchived(id, message) {
|
|
2980
|
+
const parent = this.parentSession;
|
|
2981
|
+
if (!parent) throw new Error("subagent supervisor has no parent session");
|
|
2982
|
+
if (this.isDisposed) throw new Error("parent session is closing");
|
|
2983
|
+
if (this.jobs.has(id)) throw new Error(`subagent "${id}" is still running; steer it instead`);
|
|
2984
|
+
if (this.jobs.size >= 8) throw new Error(`at most 8 running subagents per session; abort one or wait for a result`);
|
|
2985
|
+
const meta = await this.options.store.readJson(this.childStoreKey(id, "job.json"));
|
|
2986
|
+
if (!meta?.closedPhase) throw new Error(`no archived subagent "${id}" (see \`demi agent list\`)`);
|
|
2987
|
+
const checkpoint = await this.childSessionStore(id).loadCheckpoint();
|
|
2988
|
+
if (!checkpoint) throw new Error(`archived subagent "${id}" has no checkpoint left`);
|
|
2989
|
+
const liveMeta = {
|
|
2990
|
+
description: meta.description,
|
|
2991
|
+
profileName: meta.profileName,
|
|
2992
|
+
metadata: parent.actionMetadata(),
|
|
2993
|
+
spawnedAt: Date.now()
|
|
2994
|
+
};
|
|
2995
|
+
await this.options.store.writeJson(this.childStoreKey(id, "job.json"), liveMeta);
|
|
2996
|
+
const job = this.reassembleJob(id, liveMeta, checkpoint);
|
|
2997
|
+
this.watchTurn(job, job.session.send([{
|
|
2998
|
+
type: "text",
|
|
2999
|
+
text: message
|
|
3000
|
+
}], liveMeta.metadata ? { metadata: liveMeta.metadata } : {}));
|
|
3001
|
+
return job;
|
|
3002
|
+
}
|
|
3003
|
+
/** Every archived (finished, revivable) child of this parent, newest first. */
|
|
3004
|
+
async listArchivedJobs() {
|
|
3005
|
+
const parent = this.parentSession;
|
|
3006
|
+
if (!parent) return [];
|
|
3007
|
+
const prefix = `agent-sessions/${parent.id()}/subagents/`;
|
|
3008
|
+
const keys = await this.options.store.list(prefix).catch(() => []);
|
|
3009
|
+
const ids = [...new Set(keys.map((key) => key.slice(prefix.length).split("/")[0] ?? "").filter(Boolean))];
|
|
3010
|
+
const archived = [];
|
|
3011
|
+
for (const id of ids) {
|
|
3012
|
+
if (this.jobs.has(id)) continue;
|
|
3013
|
+
const meta = await this.options.store.readJson(this.childStoreKey(id, "job.json"));
|
|
3014
|
+
if (meta?.closedPhase) archived.push({
|
|
3015
|
+
id,
|
|
3016
|
+
meta
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
return archived.sort((a, b) => (b.meta.closedAt ?? 0) - (a.meta.closedAt ?? 0));
|
|
3020
|
+
}
|
|
3021
|
+
async pruneArchive() {
|
|
3022
|
+
const archived = await this.listArchivedJobs();
|
|
3023
|
+
for (const stale of archived.slice(16)) await this.deletePersistedJob(stale.id);
|
|
2929
3024
|
}
|
|
2930
3025
|
async abortSubtree(id) {
|
|
2931
3026
|
const job = this.jobs.get(id);
|
|
@@ -3068,6 +3163,34 @@ var ChildSupervisor = class {
|
|
|
3068
3163
|
await this.options.store.delete(this.childStoreKey(id, "checkpoint.json")).catch(noop);
|
|
3069
3164
|
await this.options.store.delete(this.childStoreKey(id, "job.json")).catch(noop);
|
|
3070
3165
|
}
|
|
3166
|
+
/** Shared spawn/resume foreground behaviour: announce the id, wire abort and stdin steers, wait for close, report the outcome. */
|
|
3167
|
+
async attendChild(job, ctx) {
|
|
3168
|
+
const { io, isJson, signal, stdinStream } = ctx;
|
|
3169
|
+
await io.stderr(`subagentId: ${job.id}\n`);
|
|
3170
|
+
const onAbort = () => {
|
|
3171
|
+
this.abortSubtree(job.id).catch(noop);
|
|
3172
|
+
};
|
|
3173
|
+
if (signal.aborted) onAbort();
|
|
3174
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
3175
|
+
this.pumpStdinSteers(job.id, stdinStream);
|
|
3176
|
+
const close = await job.closed;
|
|
3177
|
+
signal.removeEventListener("abort", onAbort);
|
|
3178
|
+
if (close.phase === "completed") {
|
|
3179
|
+
const text = close.result ?? "";
|
|
3180
|
+
if (isJson) await io.stdout(`${JSON.stringify({
|
|
3181
|
+
subagentId: job.id,
|
|
3182
|
+
text
|
|
3183
|
+
})}\n`);
|
|
3184
|
+
else if (text.length > 0) await io.stdout(text.endsWith("\n") ? text : `${text}\n`);
|
|
3185
|
+
return { exitCode: 0 };
|
|
3186
|
+
}
|
|
3187
|
+
if (close.phase === "aborted") {
|
|
3188
|
+
await io.stderr(`demi agent: subagent ${job.id} aborted\n`);
|
|
3189
|
+
return { exitCode: 130 };
|
|
3190
|
+
}
|
|
3191
|
+
await io.stderr(`demi agent: subagent ${job.id} failed: ${close.failure ?? "unknown error"}\n`);
|
|
3192
|
+
return { exitCode: 1 };
|
|
3193
|
+
}
|
|
3071
3194
|
/** Delivers one steer to a child: mid-turn as a steer, idle as a new user turn. */
|
|
3072
3195
|
async steerChild(job, message) {
|
|
3073
3196
|
const content = [{
|
|
@@ -3134,7 +3257,15 @@ var ChildSupervisor = class {
|
|
|
3134
3257
|
const result = phase === "completed" ? boundedResultText(lastAssistantText(job.session.transcript().blocks)) : void 0;
|
|
3135
3258
|
await job.session.dispose().catch(noop);
|
|
3136
3259
|
await this.disposeJobShells(job);
|
|
3137
|
-
await this.
|
|
3260
|
+
await this.options.store.writeJson(this.childStoreKey(job.id, "job.json"), {
|
|
3261
|
+
description: job.description,
|
|
3262
|
+
profileName: job.profileName,
|
|
3263
|
+
metadata: job.metadata,
|
|
3264
|
+
spawnedAt: job.spawnedAt,
|
|
3265
|
+
closedPhase: phase,
|
|
3266
|
+
closedAt: Date.now()
|
|
3267
|
+
}).catch(noop);
|
|
3268
|
+
await this.pruneArchive().catch(noop);
|
|
3138
3269
|
const close = {
|
|
3139
3270
|
phase,
|
|
3140
3271
|
...result !== void 0 ? { result } : {},
|
|
@@ -4360,4 +4491,4 @@ function createProviderMap(providers) {
|
|
|
4360
4491
|
return map;
|
|
4361
4492
|
}
|
|
4362
4493
|
//#endregion
|
|
4363
|
-
export { AgentClient, AgentServer, AgentSession, ChildSupervisor, DEFAULT_MAX_MEDIA_BYTES, DEFAULT_TURN_RETRY_POLICY, MAX_LIVE_SUBAGENTS, ProviderStreamError, RunCommandLineCommandNotRegisteredError, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, SUBAGENT_RESULT_MAX_BYTES, TranscriptLog, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createReadonlyHost, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, findResumePoint, finishShellToolResult, injectSubagentCommand, isContextLengthExceeded, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
|
|
4494
|
+
export { AgentClient, AgentServer, AgentSession, ChildSupervisor, DEFAULT_MAX_MEDIA_BYTES, DEFAULT_TURN_RETRY_POLICY, MAX_ARCHIVED_SUBAGENTS, MAX_LIVE_SUBAGENTS, ProviderStreamError, RunCommandLineCommandNotRegisteredError, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, SUBAGENT_RESULT_MAX_BYTES, TranscriptLog, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createReadonlyHost, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, findResumePoint, finishShellToolResult, injectSubagentCommand, isContextLengthExceeded, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@demicodes/agent",
|
|
3
3
|
"description": "Session runtime and transport-neutral client and server protocol for Demi.",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@demicodes/core": "^0.19.
|
|
23
|
-
"@demicodes/provider": "^0.19.
|
|
24
|
-
"@demicodes/shell": "^0.19.
|
|
25
|
-
"@demicodes/utils": "^0.19.
|
|
22
|
+
"@demicodes/core": "^0.19.3",
|
|
23
|
+
"@demicodes/provider": "^0.19.3",
|
|
24
|
+
"@demicodes/shell": "^0.19.3",
|
|
25
|
+
"@demicodes/utils": "^0.19.3",
|
|
26
26
|
"zod": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"license": "Apache-2.0",
|