@demicodes/agent 0.22.0 → 0.23.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/index.d.mts +89 -70
- package/dist/index.mjs +19 -10
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -244,6 +244,78 @@ declare class AgentSession<State> {
|
|
|
244
244
|
declare function applyTranscriptPatches(blocks: Block[], patches: TranscriptPatch[]): Block[];
|
|
245
245
|
declare function cloneBlocks(blocks: Block[]): Block[];
|
|
246
246
|
//#endregion
|
|
247
|
+
//#region src/tools.d.ts
|
|
248
|
+
interface StandardAgentToolOptions<State = unknown> {
|
|
249
|
+
environment: BashEnvironment | ((ctx: AgentToolInvokeContext<State>, handle: {
|
|
250
|
+
shellId?: string;
|
|
251
|
+
commandId?: string;
|
|
252
|
+
}) => BashEnvironment | Promise<BashEnvironment>);
|
|
253
|
+
scheduleYield(ctx: AgentToolInvokeContext<State>, durationMs: number): AgentToolInvokeResult;
|
|
254
|
+
/**
|
|
255
|
+
* Tool-result preview budget in tokens for a given model context window.
|
|
256
|
+
* Defaults to {@link shellPreviewBudgetTokens}.
|
|
257
|
+
*/
|
|
258
|
+
previewBudgetTokens?: ShellPreviewBudget;
|
|
259
|
+
}
|
|
260
|
+
type ShellPreviewBudget = (contextWindow: number) => number;
|
|
261
|
+
declare function createStandardAgentTools<State = unknown>(options: StandardAgentToolOptions<State>): AgentTool<State>[];
|
|
262
|
+
interface ShellToolResultOptions {
|
|
263
|
+
includePreview?: boolean;
|
|
264
|
+
previewBudgetTokens?: number;
|
|
265
|
+
exposeCommandHandle?: boolean;
|
|
266
|
+
/** Model receiving this result; gates binary-stream media attachment. */
|
|
267
|
+
model?: Model;
|
|
268
|
+
/** Per-modality byte caps on attached media; unset modalities keep the defaults. */
|
|
269
|
+
maxMediaBytes?: Partial<Record<ModelMediaKind, number>>;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* How many bytes of each modality a tool may hand to the model.
|
|
273
|
+
*
|
|
274
|
+
* One number cannot serve both, because bytes buy wildly different amounts of
|
|
275
|
+
* context per modality — measured against a frontier model, a KiB of video
|
|
276
|
+
* costs ~2 tokens where a KiB of image costs ~50. A cap generous enough to show
|
|
277
|
+
* a five-minute clip would let a single still eat a six-figure token budget.
|
|
278
|
+
*
|
|
279
|
+
* image (4 MiB): well past any sane still — a 4000x3000 PNG lands under it — so
|
|
280
|
+
* crossing this line is a mistake, not a use case.
|
|
281
|
+
* video (16 MiB): roughly ten minutes at a viewing-grade encoding, and
|
|
282
|
+
* deliberately under the ~20 MB inline-payload ceiling the major APIs enforce.
|
|
283
|
+
* A larger cap buys no reach, only a rejection further downstream where the
|
|
284
|
+
* reason is harder to read.
|
|
285
|
+
*
|
|
286
|
+
* Bytes are a proxy, not a budget: for video they track cost reasonably at a
|
|
287
|
+
* fixed encoding, but an image's real driver is its pixel dimensions.
|
|
288
|
+
*/
|
|
289
|
+
declare const DEFAULT_MAX_MEDIA_BYTES: Record<ModelMediaKind, number>;
|
|
290
|
+
declare function shellPreviewBudgetTokens(contextWindow: number): number;
|
|
291
|
+
declare function toShellToolResult(result: ShellCommandStatus, options?: ShellToolResultOptions): AgentToolInvokeResult;
|
|
292
|
+
/** Character budget for a shell view's render window (tail-biased). */
|
|
293
|
+
declare const SHELL_VIEW_MAX_CHARS = 32768;
|
|
294
|
+
/**
|
|
295
|
+
* Bounded UI view of a shell command stored on the tool_call block. Full
|
|
296
|
+
* output lives in the command artifact directory (real files on the host
|
|
297
|
+
* filesystem, see `artifactDir`), keyed by
|
|
298
|
+
* `commandId`; the view carries only the tail render window and never embeds
|
|
299
|
+
* raw or base64 bytes.
|
|
300
|
+
*/
|
|
301
|
+
interface ShellToolView {
|
|
302
|
+
kind: 'shell';
|
|
303
|
+
status: 'running' | 'exited' | 'aborted';
|
|
304
|
+
shellId: string;
|
|
305
|
+
commandId: string;
|
|
306
|
+
exitCode?: number;
|
|
307
|
+
runningMs: number;
|
|
308
|
+
idleMs: number;
|
|
309
|
+
/** Tail of the merged output, capped at SHELL_VIEW_MAX_CHARS. */
|
|
310
|
+
chunks: ShellOutputChunk[];
|
|
311
|
+
/** True when chunks were capped; the artifact has the full output. */
|
|
312
|
+
viewTruncated: boolean;
|
|
313
|
+
audit?: BashAuditEvent[];
|
|
314
|
+
commandMeta?: CommandMetadataRecord[];
|
|
315
|
+
}
|
|
316
|
+
declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandStatus, ctx: AgentToolInvokeContext<State>, previewBudget?: ShellPreviewBudget): Promise<AgentToolInvokeResult>;
|
|
317
|
+
declare function shellCommandHandleRequired(result: ShellCommandStatus, budgetTokens: number): boolean;
|
|
318
|
+
//#endregion
|
|
247
319
|
//#region src/server.d.ts
|
|
248
320
|
/** Session tuning forwarded to every AgentSession this server creates. */
|
|
249
321
|
interface AgentServerSessionOptions {
|
|
@@ -275,9 +347,11 @@ interface AgentServerOptions {
|
|
|
275
347
|
session?: AgentServerSessionOptions;
|
|
276
348
|
subagents?: {
|
|
277
349
|
/**
|
|
278
|
-
* When false, a child closing never wakes
|
|
279
|
-
* user send; the host app observes the `subagent
|
|
280
|
-
* the
|
|
350
|
+
* When false, a child of the ROOT session closing never wakes the idle
|
|
351
|
+
* root with an automatic user send; the host app observes the `subagent
|
|
352
|
+
* closed` frame and drives the root itself. Applies to the root level
|
|
353
|
+
* only: a subagent parent has no host-side message channel, so deeper
|
|
354
|
+
* levels always self-notify. Defaults to true.
|
|
281
355
|
*/
|
|
282
356
|
notifyParentOnIdle?: boolean;
|
|
283
357
|
/**
|
|
@@ -286,6 +360,14 @@ interface AgentServerOptions {
|
|
|
286
360
|
*/
|
|
287
361
|
maxLiveSubagents?: number;
|
|
288
362
|
};
|
|
363
|
+
tools?: {
|
|
364
|
+
/**
|
|
365
|
+
* Shell tool-result preview budget in tokens as a function of the current
|
|
366
|
+
* model's context window, applied to every session in the tree. Defaults
|
|
367
|
+
* to the built-in 10k / 100k split at an 800k context window.
|
|
368
|
+
*/
|
|
369
|
+
shellPreviewBudgetTokens?: ShellPreviewBudget;
|
|
370
|
+
};
|
|
289
371
|
/**
|
|
290
372
|
* Optional host-side shell prep (env, PATH, etc.). Implementation-agnostic —
|
|
291
373
|
* command bridge wiring lives in `@demicodes/host-local`, not here.
|
|
@@ -331,6 +413,7 @@ declare class AgentServer {
|
|
|
331
413
|
private readonly prepareShell;
|
|
332
414
|
private readonly notifyParentOnIdle;
|
|
333
415
|
private readonly maxLiveSubagents;
|
|
416
|
+
private readonly shellPreviewBudgetTokens;
|
|
334
417
|
private readonly bindings;
|
|
335
418
|
private readonly sessionOwnership;
|
|
336
419
|
constructor(options: AgentServerOptions);
|
|
@@ -448,6 +531,8 @@ interface ChildSupervisorOptions<State> {
|
|
|
448
531
|
directory: AgentDirectory<State>;
|
|
449
532
|
/** Live-children ceiling for this supervisor (from `AgentServerOptions.subagents.maxLiveSubagents`). */
|
|
450
533
|
maxLiveSubagents: number;
|
|
534
|
+
/** Shell preview budget for every child (from `AgentServerOptions.tools.shellPreviewBudgetTokens`); null uses the built-in split. */
|
|
535
|
+
shellPreviewBudgetTokens: ShellPreviewBudget | null;
|
|
451
536
|
/** When false, this supervisor's owner may not spawn: its `demi agent` tree carries communication and reads only. */
|
|
452
537
|
canSpawn: boolean;
|
|
453
538
|
/** Invoked whenever the live-children set changes; wired to the owning job's settle loop. */
|
|
@@ -614,70 +699,4 @@ declare function injectSubagentCommand(commands: Command[], agentNode: Command):
|
|
|
614
699
|
*/
|
|
615
700
|
declare function createReadonlyHost(host: Host): Host;
|
|
616
701
|
//#endregion
|
|
617
|
-
|
|
618
|
-
interface StandardAgentToolOptions<State = unknown> {
|
|
619
|
-
environment: BashEnvironment | ((ctx: AgentToolInvokeContext<State>, handle: {
|
|
620
|
-
shellId?: string;
|
|
621
|
-
commandId?: string;
|
|
622
|
-
}) => BashEnvironment | Promise<BashEnvironment>);
|
|
623
|
-
scheduleYield(ctx: AgentToolInvokeContext<State>, durationMs: number): AgentToolInvokeResult;
|
|
624
|
-
}
|
|
625
|
-
declare function createStandardAgentTools<State = unknown>(options: StandardAgentToolOptions<State>): AgentTool<State>[];
|
|
626
|
-
interface ShellToolResultOptions {
|
|
627
|
-
includePreview?: boolean;
|
|
628
|
-
previewBudgetTokens?: number;
|
|
629
|
-
exposeCommandHandle?: boolean;
|
|
630
|
-
/** Model receiving this result; gates binary-stream media attachment. */
|
|
631
|
-
model?: Model;
|
|
632
|
-
/** Per-modality byte caps on attached media; unset modalities keep the defaults. */
|
|
633
|
-
maxMediaBytes?: Partial<Record<ModelMediaKind, number>>;
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* How many bytes of each modality a tool may hand to the model.
|
|
637
|
-
*
|
|
638
|
-
* One number cannot serve both, because bytes buy wildly different amounts of
|
|
639
|
-
* context per modality — measured against a frontier model, a KiB of video
|
|
640
|
-
* costs ~2 tokens where a KiB of image costs ~50. A cap generous enough to show
|
|
641
|
-
* a five-minute clip would let a single still eat a six-figure token budget.
|
|
642
|
-
*
|
|
643
|
-
* image (4 MiB): well past any sane still — a 4000x3000 PNG lands under it — so
|
|
644
|
-
* crossing this line is a mistake, not a use case.
|
|
645
|
-
* video (16 MiB): roughly ten minutes at a viewing-grade encoding, and
|
|
646
|
-
* deliberately under the ~20 MB inline-payload ceiling the major APIs enforce.
|
|
647
|
-
* A larger cap buys no reach, only a rejection further downstream where the
|
|
648
|
-
* reason is harder to read.
|
|
649
|
-
*
|
|
650
|
-
* Bytes are a proxy, not a budget: for video they track cost reasonably at a
|
|
651
|
-
* fixed encoding, but an image's real driver is its pixel dimensions.
|
|
652
|
-
*/
|
|
653
|
-
declare const DEFAULT_MAX_MEDIA_BYTES: Record<ModelMediaKind, number>;
|
|
654
|
-
declare function shellPreviewBudgetTokens(contextWindow: number): number;
|
|
655
|
-
declare function toShellToolResult(result: ShellCommandStatus, options?: ShellToolResultOptions): AgentToolInvokeResult;
|
|
656
|
-
/** Character budget for a shell view's render window (tail-biased). */
|
|
657
|
-
declare const SHELL_VIEW_MAX_CHARS = 32768;
|
|
658
|
-
/**
|
|
659
|
-
* Bounded UI view of a shell command stored on the tool_call block. Full
|
|
660
|
-
* output lives in the command artifact directory (real files on the host
|
|
661
|
-
* filesystem, see `artifactDir`), keyed by
|
|
662
|
-
* `commandId`; the view carries only the tail render window and never embeds
|
|
663
|
-
* raw or base64 bytes.
|
|
664
|
-
*/
|
|
665
|
-
interface ShellToolView {
|
|
666
|
-
kind: 'shell';
|
|
667
|
-
status: 'running' | 'exited' | 'aborted';
|
|
668
|
-
shellId: string;
|
|
669
|
-
commandId: string;
|
|
670
|
-
exitCode?: number;
|
|
671
|
-
runningMs: number;
|
|
672
|
-
idleMs: number;
|
|
673
|
-
/** Tail of the merged output, capped at SHELL_VIEW_MAX_CHARS. */
|
|
674
|
-
chunks: ShellOutputChunk[];
|
|
675
|
-
/** True when chunks were capped; the artifact has the full output. */
|
|
676
|
-
viewTruncated: boolean;
|
|
677
|
-
audit?: BashAuditEvent[];
|
|
678
|
-
commandMeta?: CommandMetadataRecord[];
|
|
679
|
-
}
|
|
680
|
-
declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandStatus, ctx: AgentToolInvokeContext<State>): Promise<AgentToolInvokeResult>;
|
|
681
|
-
declare function shellCommandHandleRequired(result: ShellCommandStatus, budgetTokens: number): boolean;
|
|
682
|
-
//#endregion
|
|
683
|
-
export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDirectory, 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, AgentTreeNode, 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 };
|
|
702
|
+
export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDirectory, 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, AgentTreeNode, 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, ShellPreviewBudget, 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
|
@@ -2248,8 +2248,8 @@ var InProcessEndpoint = class {
|
|
|
2248
2248
|
const MAX_CONSECUTIVE_IDENTICAL_EXEC = 6;
|
|
2249
2249
|
const REPEAT_WINDOW_MS = 6e4;
|
|
2250
2250
|
const MAX_DELAY_MS = 6e5;
|
|
2251
|
-
const SMALL_CONTEXT_PREVIEW_TOKENS =
|
|
2252
|
-
const LARGE_CONTEXT_PREVIEW_TOKENS =
|
|
2251
|
+
const SMALL_CONTEXT_PREVIEW_TOKENS = 1e4;
|
|
2252
|
+
const LARGE_CONTEXT_PREVIEW_TOKENS = 1e5;
|
|
2253
2253
|
const LARGE_CONTEXT_THRESHOLD_TOKENS = 8e5;
|
|
2254
2254
|
const APPROX_CHARS_PER_TOKEN = 4;
|
|
2255
2255
|
const TOOL_DESCRIPTION_FIELD = "Concise title for the concrete user-visible state or result to make visible or confirm. Do not describe waiting, pausing, tool mechanics, generic actions, object labels, steps, tool names, ids, internals, or reasons.";
|
|
@@ -2288,7 +2288,7 @@ function createStandardAgentTools(options) {
|
|
|
2288
2288
|
signal: ctx.signal
|
|
2289
2289
|
});
|
|
2290
2290
|
ctx.emitProgress(result);
|
|
2291
|
-
return finishShellToolResult(environment, result, ctx);
|
|
2291
|
+
return finishShellToolResult(environment, result, ctx, options.previewBudgetTokens);
|
|
2292
2292
|
}
|
|
2293
2293
|
},
|
|
2294
2294
|
{
|
|
@@ -2311,7 +2311,7 @@ function createStandardAgentTools(options) {
|
|
|
2311
2311
|
const environment = await resolveEnvironment(options.environment, ctx, { commandId: parsed.commandId });
|
|
2312
2312
|
const result = await environment.status(parsed);
|
|
2313
2313
|
ctx.emitProgress(result);
|
|
2314
|
-
return finishShellToolResult(environment, result, ctx);
|
|
2314
|
+
return finishShellToolResult(environment, result, ctx, options.previewBudgetTokens);
|
|
2315
2315
|
}
|
|
2316
2316
|
},
|
|
2317
2317
|
{
|
|
@@ -2338,7 +2338,7 @@ function createStandardAgentTools(options) {
|
|
|
2338
2338
|
signal: ctx.signal
|
|
2339
2339
|
});
|
|
2340
2340
|
ctx.emitProgress(result);
|
|
2341
|
-
return finishShellToolResult(environment, result, ctx);
|
|
2341
|
+
return finishShellToolResult(environment, result, ctx, options.previewBudgetTokens);
|
|
2342
2342
|
}
|
|
2343
2343
|
},
|
|
2344
2344
|
{
|
|
@@ -2362,7 +2362,7 @@ function createStandardAgentTools(options) {
|
|
|
2362
2362
|
const result = await environment.abort(parsed);
|
|
2363
2363
|
ctx.emitProgress(result);
|
|
2364
2364
|
return {
|
|
2365
|
-
...await finishShellToolResult(environment, result, ctx),
|
|
2365
|
+
...await finishShellToolResult(environment, result, ctx, options.previewBudgetTokens),
|
|
2366
2366
|
isError: false
|
|
2367
2367
|
};
|
|
2368
2368
|
}
|
|
@@ -2636,8 +2636,8 @@ function boundedPreview(text, budgetTokens) {
|
|
|
2636
2636
|
truncated: true
|
|
2637
2637
|
};
|
|
2638
2638
|
}
|
|
2639
|
-
async function finishShellToolResult(environment, result, ctx) {
|
|
2640
|
-
const previewBudgetTokens =
|
|
2639
|
+
async function finishShellToolResult(environment, result, ctx, previewBudget = shellPreviewBudgetTokens) {
|
|
2640
|
+
const previewBudgetTokens = previewBudget(ctx.model.model.contextWindow);
|
|
2641
2641
|
const exposeCommandHandle = shellCommandHandleRequired(result, previewBudgetTokens);
|
|
2642
2642
|
const toolResult = toShellToolResult(result, {
|
|
2643
2643
|
includePreview: true,
|
|
@@ -3255,6 +3255,7 @@ var ChildSupervisor = class ChildSupervisor {
|
|
|
3255
3255
|
parentCommands: inherited,
|
|
3256
3256
|
storePrefix: `${this.options.storePrefix}/subagents/${id}`,
|
|
3257
3257
|
canSpawn: input.canSpawnSubagents,
|
|
3258
|
+
notifyParentOnIdle: true,
|
|
3258
3259
|
onJobsChanged: () => job.wake?.()
|
|
3259
3260
|
});
|
|
3260
3261
|
const commands = injectSubagentCommand(inherited, job.ownSupervisor.rootCommandNode());
|
|
@@ -3278,7 +3279,8 @@ var ChildSupervisor = class ChildSupervisor {
|
|
|
3278
3279
|
},
|
|
3279
3280
|
tools: () => createStandardAgentTools({
|
|
3280
3281
|
environment: (ctx) => this.childEnvironment(job, ctx),
|
|
3281
|
-
scheduleYield: (ctx, durationMs) => job.session.scheduleYieldWakeup(durationMs, ctx.metadata)
|
|
3282
|
+
scheduleYield: (ctx, durationMs) => job.session.scheduleYieldWakeup(durationMs, ctx.metadata),
|
|
3283
|
+
...this.options.shellPreviewBudgetTokens === null ? {} : { previewBudgetTokens: this.options.shellPreviewBudgetTokens }
|
|
3282
3284
|
})
|
|
3283
3285
|
}
|
|
3284
3286
|
};
|
|
@@ -3919,6 +3921,7 @@ var AgentServer = class {
|
|
|
3919
3921
|
prepareShell;
|
|
3920
3922
|
notifyParentOnIdle;
|
|
3921
3923
|
maxLiveSubagents;
|
|
3924
|
+
shellPreviewBudgetTokens;
|
|
3922
3925
|
bindings = /* @__PURE__ */ new Set();
|
|
3923
3926
|
sessionOwnership = new SessionOwnershipRegistry();
|
|
3924
3927
|
constructor(options) {
|
|
@@ -3929,6 +3932,7 @@ var AgentServer = class {
|
|
|
3929
3932
|
this.prepareShell = options.prepareShell ?? null;
|
|
3930
3933
|
this.notifyParentOnIdle = options.subagents?.notifyParentOnIdle ?? true;
|
|
3931
3934
|
this.maxLiveSubagents = options.subagents?.maxLiveSubagents ?? 8;
|
|
3935
|
+
this.shellPreviewBudgetTokens = options.tools?.shellPreviewBudgetTokens ?? null;
|
|
3932
3936
|
}
|
|
3933
3937
|
client() {
|
|
3934
3938
|
const transports = createInProcessTransportPair();
|
|
@@ -3945,6 +3949,7 @@ var AgentServer = class {
|
|
|
3945
3949
|
prepareShell: this.prepareShell,
|
|
3946
3950
|
notifyParentOnIdle: this.notifyParentOnIdle,
|
|
3947
3951
|
maxLiveSubagents: this.maxLiveSubagents,
|
|
3952
|
+
shellPreviewBudgetTokens: this.shellPreviewBudgetTokens,
|
|
3948
3953
|
sessions: this.sessionOwnership
|
|
3949
3954
|
});
|
|
3950
3955
|
this.bindings.add(binding);
|
|
@@ -3996,6 +4001,7 @@ var AgentTransportBindingImpl = class {
|
|
|
3996
4001
|
prepareShell;
|
|
3997
4002
|
notifyParentOnIdle;
|
|
3998
4003
|
maxLiveSubagents;
|
|
4004
|
+
shellPreviewBudgetTokens;
|
|
3999
4005
|
sessions;
|
|
4000
4006
|
session = null;
|
|
4001
4007
|
currentAgent = null;
|
|
@@ -4019,6 +4025,7 @@ var AgentTransportBindingImpl = class {
|
|
|
4019
4025
|
this.prepareShell = options.prepareShell;
|
|
4020
4026
|
this.notifyParentOnIdle = options.notifyParentOnIdle;
|
|
4021
4027
|
this.maxLiveSubagents = options.maxLiveSubagents;
|
|
4028
|
+
this.shellPreviewBudgetTokens = options.shellPreviewBudgetTokens;
|
|
4022
4029
|
this.sessions = options.sessions;
|
|
4023
4030
|
this.unsubscribeTransport = this.transport.onFrame((frame) => {
|
|
4024
4031
|
this.handleFrame(frame);
|
|
@@ -4244,6 +4251,7 @@ var AgentTransportBindingImpl = class {
|
|
|
4244
4251
|
storePrefix: `agent-sessions/${agentSessionId}`,
|
|
4245
4252
|
directory,
|
|
4246
4253
|
maxLiveSubagents: this.maxLiveSubagents,
|
|
4254
|
+
shellPreviewBudgetTokens: this.shellPreviewBudgetTokens,
|
|
4247
4255
|
canSpawn: true,
|
|
4248
4256
|
onJobsChanged: null,
|
|
4249
4257
|
emit: (subagentFrame) => this.send(subagentFrame)
|
|
@@ -4258,7 +4266,8 @@ var AgentTransportBindingImpl = class {
|
|
|
4258
4266
|
scheduleYield: (ctx, durationMs) => {
|
|
4259
4267
|
if (!sessionRef) throw new Error("AgentServer: session is not ready for yield scheduling");
|
|
4260
4268
|
return sessionRef.scheduleYieldWakeup(durationMs, ctx.metadata);
|
|
4261
|
-
}
|
|
4269
|
+
},
|
|
4270
|
+
...this.shellPreviewBudgetTokens === null ? {} : { previewBudgetTokens: this.shellPreviewBudgetTokens }
|
|
4262
4271
|
});
|
|
4263
4272
|
const commandsPrompt = commandRegistry.renderHelp();
|
|
4264
4273
|
const runtime = {
|
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.23.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.23.0",
|
|
23
|
+
"@demicodes/provider": "^0.23.0",
|
|
24
|
+
"@demicodes/shell": "^0.23.0",
|
|
25
|
+
"@demicodes/utils": "^0.23.0",
|
|
26
26
|
"zod": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"license": "Apache-2.0",
|