@demicodes/agent 0.19.3 → 0.21.0
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/client-entry.d.mts +2 -2
- package/dist/client-entry.mjs +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +13 -3
- package/dist/stdio-transport.d.mts +1 -1
- package/dist/{transport-CHrPzcrU.d.mts → transport-_eV2zg9M.d.mts} +2 -0
- package/dist/{websocket-transport-NZ5Btmb4.d.mts → websocket-transport-BC7OstFf.d.mts} +7 -1
- package/dist/{websocket-transport-CIOotpd-.mjs → websocket-transport-BsKvbXIp.mjs} +8 -0
- package/package.json +5 -5
package/dist/client-entry.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as TranscriptPatch, l as ServerFrame, n as AgentServerTransport, o as ClientFrame, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike, x as AgentMetadata } from "./transport-
|
|
2
|
-
import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-
|
|
1
|
+
import { f as TranscriptPatch, l as ServerFrame, n as AgentServerTransport, o as ClientFrame, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike, x as AgentMetadata } from "./transport-_eV2zg9M.mjs";
|
|
2
|
+
import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-BC7OstFf.mjs";
|
|
3
3
|
import { ProviderSelection } from "@demicodes/provider";
|
|
4
4
|
export { type AgentActionOptions, AgentClient, type AgentClientListener, type AgentClientTransport, type AgentMetadata, type AgentServerTransport, type AgentTransport, type ClientFrame, type ClientSessionEvent, type JsonWebSocket, type ProviderSelection, type ServerFrame, type ShellCommandStatusLike, type TranscriptPatch, createWebSocketClientTransport, createWebSocketServerTransport };
|
package/dist/client-entry.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-
|
|
1
|
+
import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-BsKvbXIp.mjs";
|
|
2
2
|
export { AgentClient, createWebSocketClientTransport, createWebSocketServerTransport };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AgentSystemPromptContext, B as CompactionWindow, C as AgentReferenceResolveContext, D as AgentSessionParams, E as AgentSessionOptions, F as ExternalMutationReservation, G as DEFAULT_TURN_RETRY_POLICY, H as TranscriptLog, I as ModelSwitchApply, J as resolveRetryPolicy, K as TurnRetryPolicy, L as SessionEvent, M as AgentToolContext, N as AgentToolInvokeContext, O as AgentSessionRestoreParams, P as AgentToolInvokeResult, R as SessionEventListener, S as AgentPromptContext, T as AgentSessionCloneParams, U as TranscriptOptions, V as DrainedTranscriptPatches, W as estimateTranscriptBlockTokens, Y as retryDelayMs, _ as AgentHarnessContext, a as createInProcessTransportPair, b as AgentLifecycleEvent, c as ConversationSummary, d as SubagentJob, f as TranscriptPatch, g as AgentHarness, h as AgentDisposeContext, i as InProcessTransportPair, j as AgentTool, k as AgentSessionStore, l as ServerFrame, m as AbortTarget, n as AgentServerTransport, o as ClientFrame, p as AbortResult, q as isRetryableCode, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike, v as AgentHarnessRuntime, w as AgentSessionCheckpoint, x as AgentMetadata, y as AgentHostContext, z as SubagentProfile } from "./transport-
|
|
2
|
-
import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-
|
|
1
|
+
import { A as AgentSystemPromptContext, B as CompactionWindow, C as AgentReferenceResolveContext, D as AgentSessionParams, E as AgentSessionOptions, F as ExternalMutationReservation, G as DEFAULT_TURN_RETRY_POLICY, H as TranscriptLog, I as ModelSwitchApply, J as resolveRetryPolicy, K as TurnRetryPolicy, L as SessionEvent, M as AgentToolContext, N as AgentToolInvokeContext, O as AgentSessionRestoreParams, P as AgentToolInvokeResult, R as SessionEventListener, S as AgentPromptContext, T as AgentSessionCloneParams, U as TranscriptOptions, V as DrainedTranscriptPatches, W as estimateTranscriptBlockTokens, Y as retryDelayMs, _ as AgentHarnessContext, a as createInProcessTransportPair, b as AgentLifecycleEvent, c as ConversationSummary, d as SubagentJob, f as TranscriptPatch, g as AgentHarness, h as AgentDisposeContext, i as InProcessTransportPair, j as AgentTool, k as AgentSessionStore, l as ServerFrame, m as AbortTarget, n as AgentServerTransport, o as ClientFrame, p as AbortResult, q as isRetryableCode, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike, v as AgentHarnessRuntime, w as AgentSessionCheckpoint, x as AgentMetadata, y as AgentHostContext, z as SubagentProfile } from "./transport-_eV2zg9M.mjs";
|
|
2
|
+
import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-BC7OstFf.mjs";
|
|
3
3
|
import { BashAuditEvent, BashEnvironment, BashEnvironmentOptions, Command, CommandMetadataRecord, Host, HostStore, ShellCommandStatus, ShellOutputChunk } from "@demicodes/shell";
|
|
4
4
|
import { AgentProvider, Provider } from "@demicodes/provider";
|
|
5
5
|
import { Block, Model, ModelMediaKind, ModelSelection, ProviderErrorDiagnostics, QueuedMessage, SessionPhase, UserContentBlock } from "@demicodes/core";
|
|
@@ -414,6 +414,8 @@ declare class ChildSupervisor<State = unknown> {
|
|
|
414
414
|
private listArchivedJobs;
|
|
415
415
|
private pruneArchive;
|
|
416
416
|
abortSubtree(id: string): Promise<void>;
|
|
417
|
+
/** Aborts every live child; the archive is untouched. */
|
|
418
|
+
abortAll(): Promise<void>;
|
|
417
419
|
private spawn;
|
|
418
420
|
/** Everything spawn and restore share: the command tree, the harness runtime, and the job record (session attached separately). */
|
|
419
421
|
private assembleJob;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as cloneBlocks, i as applyTranscriptPatches, n as createWebSocketServerTransport, o as ProviderStreamError, r as AgentClient, s as isContextLengthExceeded, t as createWebSocketClientTransport } from "./websocket-transport-
|
|
1
|
+
import { a as cloneBlocks, i as applyTranscriptPatches, n as createWebSocketServerTransport, o as ProviderStreamError, r as AgentClient, s as isContextLengthExceeded, t as createWebSocketClientTransport } from "./websocket-transport-BsKvbXIp.mjs";
|
|
2
2
|
import { AbortError, abortable, asError, asRecord, asString, bytesToBase64, createId, decodeUtf8, delay, errorMessage, isAbortError, isRecord, noop, parseJsonOrString, safeJsonStringify, sliceHead, sliceTail, throwIfAborted, toWellFormedText, truncate, utf8Slice } from "@demicodes/utils";
|
|
3
3
|
import { BashEnvironment, CommandRegistry, MAX_TIMEOUT_MS, heredocDelimiter, shellQuote } from "@demicodes/shell";
|
|
4
4
|
import { providerRuntime } from "@demicodes/provider";
|
|
@@ -2597,7 +2597,7 @@ function formatShellToolResult(result, options) {
|
|
|
2597
2597
|
lines.push(`metaPath: ${result.artifactDir}/meta.json`);
|
|
2598
2598
|
}
|
|
2599
2599
|
if (options.includePreview) appendPreview(lines, result, options.previewBudgetTokens ?? SMALL_CONTEXT_PREVIEW_TOKENS);
|
|
2600
|
-
if (result.status === "running") lines.push("next: command is still running; check again with shell_status, or call yield to end this turn and be woken later, or shell_abort to stop it.");
|
|
2600
|
+
if (result.status === "running") lines.push(result.runningHint ?? "next: command is still running; check again with shell_status, or call yield to end this turn and be woken later, or shell_abort to stop it.");
|
|
2601
2601
|
else if (result.status === "aborted") lines.push("next: command was intentionally stopped.");
|
|
2602
2602
|
else if (exposeCommandHandle) lines.push("next: command is complete; read the artifact only if the preview is insufficient.");
|
|
2603
2603
|
return lines.join("\n");
|
|
@@ -2656,6 +2656,7 @@ const MAX_LIVE_SUBAGENTS = 8;
|
|
|
2656
2656
|
const MAX_ARCHIVED_SUBAGENTS = 16;
|
|
2657
2657
|
const SUBAGENT_RESULT_MAX_BYTES = 32768;
|
|
2658
2658
|
const SHOW_RECENT_TOOLS = 8;
|
|
2659
|
+
const SPAWN_RUNNING_HINT = "next: the child agent is still working; a long-running spawn is normal. shell_write steers it, shell_abort aborts it. Otherwise stop attending and end the turn — the child's completion returns as this command's result and wakes the session when it is idle. Do not poll with shell_status or timed yields; use `demi agent show` only to decide a steer or abort.";
|
|
2659
2660
|
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.";
|
|
2660
2661
|
/**
|
|
2661
2662
|
* Per-parent subagent supervisor. Owns every child `AgentSession` this parent
|
|
@@ -2683,7 +2684,7 @@ var ChildSupervisor = class {
|
|
|
2683
2684
|
const profileNames = this.configuredProfileNames();
|
|
2684
2685
|
return {
|
|
2685
2686
|
name: "agent",
|
|
2686
|
-
summary: "Start an isolated child agent session and wait for its result. The command stays running until the child session ends; stdout is the child's last assistant text. While it is the foreground job, shell_write steers the child and shell_abort aborts it. Run several in separate shell_exec calls with short timeoutMs to fan out.",
|
|
2687
|
+
summary: "Start an isolated child agent session and wait for its result. The command stays running until the child session ends; stdout is the child's last assistant text. While it is the foreground job, shell_write steers the child and shell_abort aborts it. Run several in separate shell_exec calls with short timeoutMs to fan out, then end the turn — completion wakes an idle session; do not poll.",
|
|
2687
2688
|
successOutput: "first stderr line is \"subagentId: <id>\" at start; stdout is the child's last assistant text (empty is valid), written only at exit",
|
|
2688
2689
|
failureOutput: "non-zero exit with the abort or failure reason on stderr",
|
|
2689
2690
|
input: {
|
|
@@ -2697,6 +2698,7 @@ var ChildSupervisor = class {
|
|
|
2697
2698
|
subagentId: z.string(),
|
|
2698
2699
|
text: z.string()
|
|
2699
2700
|
}) },
|
|
2701
|
+
runningHint: SPAWN_RUNNING_HINT,
|
|
2700
2702
|
run: async ({ parsed, io, signal, stdinStream }) => {
|
|
2701
2703
|
const prompt = String(parsed.values.prompt ?? "").trim();
|
|
2702
2704
|
if (!prompt) {
|
|
@@ -2791,6 +2793,7 @@ var ChildSupervisor = class {
|
|
|
2791
2793
|
subagentId: z.string(),
|
|
2792
2794
|
text: z.string()
|
|
2793
2795
|
}) },
|
|
2796
|
+
runningHint: SPAWN_RUNNING_HINT,
|
|
2794
2797
|
run: async ({ parsed, io, signal, stdinStream }) => {
|
|
2795
2798
|
const id = String(parsed.values.id);
|
|
2796
2799
|
const message = String(parsed.values.message ?? "").trim();
|
|
@@ -3027,6 +3030,10 @@ var ChildSupervisor = class {
|
|
|
3027
3030
|
if (!job) return;
|
|
3028
3031
|
await this.closeJob(job, "aborted");
|
|
3029
3032
|
}
|
|
3033
|
+
/** Aborts every live child; the archive is untouched. */
|
|
3034
|
+
async abortAll() {
|
|
3035
|
+
for (const id of [...this.jobs.keys()]) await this.abortSubtree(id);
|
|
3036
|
+
}
|
|
3030
3037
|
async spawn(input) {
|
|
3031
3038
|
const parent = this.parentSession;
|
|
3032
3039
|
if (!parent) throw new Error("subagent supervisor has no parent session");
|
|
@@ -3942,6 +3949,9 @@ var AgentTransportBindingImpl = class {
|
|
|
3942
3949
|
});
|
|
3943
3950
|
return;
|
|
3944
3951
|
}
|
|
3952
|
+
case "abort_subagents":
|
|
3953
|
+
await this.supervisor?.abortAll();
|
|
3954
|
+
return;
|
|
3945
3955
|
case "shell_write":
|
|
3946
3956
|
await this.handleShellWrite(frame);
|
|
3947
3957
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-
|
|
1
|
+
import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-_eV2zg9M.mjs";
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
//#region src/stdio-transport.d.ts
|
|
4
4
|
declare function createStdioClientTransport(readable: Readable, writable: Writable): AgentClientTransport;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ModelSwitchApply, c as ConversationSummary, n as AgentServerTransport, p as AbortResult, s as ClientSessionEvent, t as AgentClientTransport, x as AgentMetadata } from "./transport-
|
|
1
|
+
import { I as ModelSwitchApply, c as ConversationSummary, n as AgentServerTransport, p as AbortResult, s as ClientSessionEvent, t as AgentClientTransport, x as AgentMetadata } from "./transport-_eV2zg9M.mjs";
|
|
2
2
|
import { ProviderSelection } from "@demicodes/provider";
|
|
3
3
|
import { Block, UserContentBlock } from "@demicodes/core";
|
|
4
4
|
//#region src/client.d.ts
|
|
@@ -59,6 +59,12 @@ declare class AgentClient {
|
|
|
59
59
|
resume(options?: AgentActionOptions): Promise<void>;
|
|
60
60
|
compact(options?: AgentActionOptions): Promise<void>;
|
|
61
61
|
abort(): Promise<AbortResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Aborts every live child agent of this session (the archive is untouched).
|
|
64
|
+
* Fire-and-forget: each child settles through its own `subagent closed`
|
|
65
|
+
* frame with phase 'aborted'.
|
|
66
|
+
*/
|
|
67
|
+
abortSubagents(): void;
|
|
62
68
|
shellWrite(commandId: string, stdin: string, options?: AgentActionOptions): Promise<void>;
|
|
63
69
|
close(): Promise<void>;
|
|
64
70
|
subscribe(listener: AgentClientListener): () => void;
|
|
@@ -209,6 +209,14 @@ var AgentClient = class {
|
|
|
209
209
|
this.sendFrame({ type: "abort" });
|
|
210
210
|
return wait;
|
|
211
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Aborts every live child agent of this session (the archive is untouched).
|
|
214
|
+
* Fire-and-forget: each child settles through its own `subagent closed`
|
|
215
|
+
* frame with phase 'aborted'.
|
|
216
|
+
*/
|
|
217
|
+
abortSubagents() {
|
|
218
|
+
this.sendFrame({ type: "abort_subagents" });
|
|
219
|
+
}
|
|
212
220
|
shellWrite(commandId, stdin, options = {}) {
|
|
213
221
|
const wait = this.waitForShellWrite(commandId);
|
|
214
222
|
this.sendFrame({
|
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.
|
|
4
|
+
"version": "0.21.0",
|
|
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.
|
|
23
|
-
"@demicodes/provider": "^0.
|
|
24
|
-
"@demicodes/shell": "^0.
|
|
25
|
-
"@demicodes/utils": "^0.
|
|
22
|
+
"@demicodes/core": "^0.21.0",
|
|
23
|
+
"@demicodes/provider": "^0.21.0",
|
|
24
|
+
"@demicodes/shell": "^0.21.0",
|
|
25
|
+
"@demicodes/utils": "^0.21.0",
|
|
26
26
|
"zod": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"license": "Apache-2.0",
|