@demicodes/agent 0.2.1 → 0.3.1

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,4 +1,4 @@
1
- import { d as TranscriptPatch, l as ServerFrame, n as AgentServerTransport, o as ClientFrame, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandSnapshotLike } from "./transport-DVa_82EW.mjs";
2
- import { a as AgentClientListener, i as AgentClient, n as createWebSocketClientTransport, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-Cn_rhIIX.mjs";
1
+ import { d as TranscriptPatch, l as ServerFrame, n as AgentServerTransport, o as ClientFrame, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike } from "./transport-0l1a6QD9.mjs";
2
+ import { a as AgentClientListener, i as AgentClient, n as createWebSocketClientTransport, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-C0R8AiHD.mjs";
3
3
  import { ProviderSelection } from "@demicodes/provider";
4
- export { AgentClient, type AgentClientListener, type AgentClientTransport, type AgentServerTransport, type AgentTransport, type ClientFrame, type ClientSessionEvent, type JsonWebSocket, type ProviderSelection, type ServerFrame, type ShellCommandSnapshotLike, type TranscriptPatch, createWebSocketClientTransport, createWebSocketServerTransport };
4
+ export { AgentClient, type AgentClientListener, type AgentClientTransport, type AgentServerTransport, type AgentTransport, type ClientFrame, type ClientSessionEvent, type JsonWebSocket, type ProviderSelection, type ServerFrame, type ShellCommandStatusLike, type TranscriptPatch, createWebSocketClientTransport, createWebSocketServerTransport };
@@ -1,2 +1,2 @@
1
- import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-Bod0puog.mjs";
1
+ import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-CcSuuo4T.mjs";
2
2
  export { AgentClient, createWebSocketClientTransport, createWebSocketServerTransport };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as AgentToolInvokeResult, B as DEFAULT_TURN_RETRY_POLICY, C as AgentSessionRestoreParams, D as AgentTool, E as AgentSystemPromptContext, F as CompactionWindow, H as isRetryableCode, I as DrainedTranscriptPatches, L as Transcript, M as SessionEvent, N as SessionEventListener, O as AgentToolContext, P as ToolContinuation, R as TranscriptOptions, S as AgentSessionParams, T as AgentSessionStore, U as resolveRetryPolicy, V as TurnRetryPolicy, W as retryDelayMs, _ as AgentHarnessRuntime, a as createInProcessTransportPair, b as AgentReferenceResolveContext, c as ConversationSummary, d as TranscriptPatch, f as AbortResult, g as AgentHarnessContext, h as AgentHarness, i as InProcessTransportPair, j as ExternalMutationReservation, k as AgentToolInvokeContext, l as ServerFrame, m as AgentDisposeContext, n as AgentServerTransport, o as ClientFrame, p as AbortTarget, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandSnapshotLike, v as AgentLifecycleEvent, w as AgentSessionSnapshot, x as AgentSessionOptions, y as AgentPromptContext, z as estimateTranscriptBlockTokens } from "./transport-DVa_82EW.mjs";
2
- import { a as AgentClientListener, i as AgentClient, n as createWebSocketClientTransport, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-Cn_rhIIX.mjs";
3
- import { BashEnvironment, BashEnvironmentOptions, Host, ShellCommandSnapshot } from "@demicodes/shell";
1
+ import { A as AgentToolInvokeResult, B as TurnRetryPolicy, C as AgentSessionParams, D as AgentTool, E as AgentSystemPromptContext, F as DrainedTranscriptPatches, H as resolveRetryPolicy, I as TranscriptLog, L as TranscriptOptions, M as SessionEvent, N as SessionEventListener, O as AgentToolContext, P as CompactionWindow, R as estimateTranscriptBlockTokens, S as AgentSessionOptions, T as AgentSessionStore, U as retryDelayMs, V as isRetryableCode, _ as AgentHarnessRuntime, a as createInProcessTransportPair, b as AgentReferenceResolveContext, c as ConversationSummary, d as TranscriptPatch, f as AbortResult, g as AgentHarnessContext, h as AgentHarness, i as InProcessTransportPair, j as ExternalMutationReservation, k as AgentToolInvokeContext, l as ServerFrame, m as AgentDisposeContext, n as AgentServerTransport, o as ClientFrame, p as AbortTarget, r as AgentTransport, s as ClientSessionEvent, t as AgentClientTransport, u as ShellCommandStatusLike, v as AgentLifecycleEvent, w as AgentSessionRestoreParams, x as AgentSessionCheckpoint, y as AgentPromptContext, z as DEFAULT_TURN_RETRY_POLICY } from "./transport-0l1a6QD9.mjs";
2
+ import { a as AgentClientListener, i as AgentClient, n as createWebSocketClientTransport, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-C0R8AiHD.mjs";
3
+ import { BashAuditEvent, BashEnvironment, BashEnvironmentOptions, CommandMetadataRecord, Host, ShellCommandStatus, ShellOutputChunk } from "@demicodes/shell";
4
4
  import { AgentProvider, Provider } from "@demicodes/provider";
5
5
  import { Block, Model, ModelSelection, QueuedMessage, SessionPhase, UserContentBlock } from "@demicodes/core";
6
6
  //#region src/session.d.ts
@@ -40,12 +40,12 @@ declare class AgentSession<State> {
40
40
  private persistTimer;
41
41
  private persistDirty;
42
42
  /**
43
- * Restores a session from a snapshot. Ownership of the snapshot (including
43
+ * Restores a session from a checkpoint. Ownership of the checkpoint (including
44
44
  * `state`) transfers to the session: the caller must not mutate it afterwards.
45
45
  * Passing state by reference — not a clone — lets the caller share the same
46
46
  * object with harness closures (host/commands), keeping one live state.
47
47
  */
48
- static fromSnapshot<State>(params: AgentSessionRestoreParams<State>, options?: AgentSessionOptions<State>): AgentSession<State>;
48
+ static fromCheckpoint<State>(params: AgentSessionRestoreParams<State>, options?: AgentSessionOptions<State>): AgentSession<State>;
49
49
  constructor(params: AgentSessionParams<State>, options?: AgentSessionOptions<State>);
50
50
  send(content: UserContentBlock[], options?: {
51
51
  id?: string;
@@ -78,7 +78,7 @@ declare class AgentSession<State> {
78
78
  * (e.g. a long-lived CLI subprocess). Called when the owning connection closes.
79
79
  */
80
80
  dispose(): Promise<void>;
81
- transcript(): Transcript;
81
+ transcript(): TranscriptLog;
82
82
  state(): State;
83
83
  id(): string;
84
84
  phase(): SessionPhase;
@@ -134,11 +134,11 @@ declare class AgentSession<State> {
134
134
  /**
135
135
  * Publishes transcript changes: drains the mutation journal into a patch
136
136
  * event (O(changed content), not O(transcript)) and schedules a throttled
137
- * snapshot write. Boundaries (action end, abort, dispose) flush the write.
137
+ * checkpoint write. Boundaries (action end, abort, dispose) flush the write.
138
138
  */
139
139
  private commitTranscript;
140
140
  private schedulePersist;
141
- private persistSnapshot;
141
+ private persistCheckpoint;
142
142
  private flushPersist;
143
143
  private emit;
144
144
  private resolveIdleWaiters;
@@ -252,8 +252,31 @@ interface ShellToolResultOptions {
252
252
  model?: Model;
253
253
  }
254
254
  declare function shellPreviewBudgetTokens(contextWindow: number): number;
255
- declare function toShellToolResult(result: ShellCommandSnapshot, toolCallId?: string, options?: ShellToolResultOptions): AgentToolInvokeResult;
256
- declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandSnapshot, ctx: AgentToolInvokeContext<State>): Promise<AgentToolInvokeResult>;
257
- declare function shellCommandHandleRequired(result: ShellCommandSnapshot, budgetTokens: number): boolean;
255
+ declare function toShellToolResult(result: ShellCommandStatus, options?: ShellToolResultOptions): AgentToolInvokeResult;
256
+ /** Character budget for a shell view's render window (tail-biased). */
257
+ declare const SHELL_VIEW_MAX_CHARS = 32768;
258
+ /**
259
+ * Bounded UI view of a shell command stored on the tool_call block. Full
260
+ * output lives in the command artifact (`/@/commands/<commandId>/…`), keyed by
261
+ * `commandId`; the view carries only the tail render window and never embeds
262
+ * raw or base64 bytes.
263
+ */
264
+ interface ShellToolView {
265
+ kind: 'shell';
266
+ status: 'running' | 'exited' | 'aborted';
267
+ shellId: string;
268
+ commandId: string;
269
+ exitCode?: number;
270
+ runningMs: number;
271
+ idleMs: number;
272
+ /** Tail of the merged output, capped at SHELL_VIEW_MAX_CHARS. */
273
+ chunks: ShellOutputChunk[];
274
+ /** True when chunks were capped; the artifact has the full output. */
275
+ viewTruncated: boolean;
276
+ audit?: BashAuditEvent[];
277
+ commandMeta?: CommandMetadataRecord[];
278
+ }
279
+ declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandStatus, ctx: AgentToolInvokeContext<State>): Promise<AgentToolInvokeResult>;
280
+ declare function shellCommandHandleRequired(result: ShellCommandStatus, budgetTokens: number): boolean;
258
281
  //#endregion
259
- export { AbortResult, AbortTarget, ActiveTurnPhase, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentLifecycleEvent, AgentPromptContext, AgentReferenceResolveContext, AgentServer, AgentServerOptions, AgentServerSessionOptions, AgentServerTransport, AgentSession, AgentSessionOptions, AgentSessionParams, AgentSessionRestoreParams, AgentSessionSnapshot, AgentSessionStore, AgentSystemPromptContext, AgentTool, AgentToolContext, AgentToolInvokeContext, AgentToolInvokeResult, AgentTransport, AgentTransportBinding, ClientFrame, ClientSessionEvent, CompactionWindow, ConversationSummary, DEFAULT_TURN_RETRY_POLICY, DrainedTranscriptPatches, ExternalMutationReservation, InProcessTransportPair, JsonWebSocket, PrepareSessionShell, PrepareSessionShellContext, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineSessionNotFoundError, RunCommandLineTimeoutError, ServerFrame, SessionEvent, SessionEventListener, ShellCommandSnapshotLike, ShellToolResultOptions, StandardAgentToolOptions, ToolContinuation, Transcript, TranscriptOptions, TranscriptPatch, TurnRetryPolicy, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
282
+ export { AbortResult, AbortTarget, ActiveTurnPhase, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentLifecycleEvent, AgentPromptContext, AgentReferenceResolveContext, AgentServer, AgentServerOptions, AgentServerSessionOptions, AgentServerTransport, AgentSession, AgentSessionCheckpoint, AgentSessionOptions, AgentSessionParams, AgentSessionRestoreParams, AgentSessionStore, AgentSystemPromptContext, AgentTool, AgentToolContext, AgentToolInvokeContext, AgentToolInvokeResult, AgentTransport, AgentTransportBinding, ClientFrame, ClientSessionEvent, CompactionWindow, ConversationSummary, DEFAULT_TURN_RETRY_POLICY, DrainedTranscriptPatches, ExternalMutationReservation, InProcessTransportPair, JsonWebSocket, PrepareSessionShell, PrepareSessionShellContext, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineSessionNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, ServerFrame, SessionEvent, SessionEventListener, ShellCommandStatusLike, ShellToolResultOptions, ShellToolView, StandardAgentToolOptions, TranscriptLog, TranscriptOptions, TranscriptPatch, TurnRetryPolicy, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as cloneBlocks, i as applyTranscriptPatches, n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-Bod0puog.mjs";
1
+ import { a as cloneBlocks, i as applyTranscriptPatches, n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-CcSuuo4T.mjs";
2
2
  import { AbortError, abortable, asError, asRecord, asString, bytesToBase64, createId, delay, isAbortError, isRecord, noop, parseJsonOrString, safeJsonStringify, throwIfAborted, truncate } from "@demicodes/utils";
3
3
  import { BashEnvironment, CommandRegistry, MAX_TIMEOUT_MS, heredocDelimiter, shellQuote } from "@demicodes/shell";
4
4
  import { providerRuntime } from "@demicodes/provider";
@@ -9,7 +9,7 @@ const DEFAULT_MODEL_TEXT_TAIL_CHARS = 8e3;
9
9
  const IMAGE_BASE_TOKENS = 1600;
10
10
  const IMAGE_BYTES_PER_TOKEN = 1e3;
11
11
  const DOCUMENT_BYTES_PER_TOKEN = 4;
12
- var Transcript = class {
12
+ var TranscriptLog = class {
13
13
  blocks;
14
14
  idFactory;
15
15
  now;
@@ -24,7 +24,7 @@ var Transcript = class {
24
24
  this.replayHeadChars = options.replayTextBounds?.headChars ?? DEFAULT_MODEL_TEXT_HEAD_CHARS;
25
25
  this.replayTailChars = options.replayTextBounds?.tailChars ?? DEFAULT_MODEL_TEXT_TAIL_CHARS;
26
26
  }
27
- snapshot() {
27
+ toJSON() {
28
28
  return { blocks: structuredClone(this.blocks) };
29
29
  }
30
30
  /** Monotonic revision, advanced once per drained patch batch. */
@@ -173,7 +173,7 @@ var Transcript = class {
173
173
  status: "executing",
174
174
  streamingOutput: [],
175
175
  output: [],
176
- metadata: null
176
+ view: null
177
177
  });
178
178
  case "response": return this.appendBlock({
179
179
  type: "response",
@@ -193,14 +193,14 @@ var Transcript = class {
193
193
  case "abort": return this.pushAbort(model);
194
194
  }
195
195
  }
196
- completeToolCall(toolUseId, output, isError = false, metadata = null) {
196
+ completeToolCall(toolUseId, output, isError = false, view = null) {
197
197
  const index = findPendingToolCallIndex(this.blocks, toolUseId);
198
198
  if (index === null) return null;
199
199
  const block = this.blocks[index];
200
200
  block.status = isError ? "error" : "completed";
201
201
  block.output = output;
202
202
  block.streamingOutput = [];
203
- block.metadata = metadata;
203
+ block.view = view;
204
204
  this.recordBlockReplace(index);
205
205
  return block;
206
206
  }
@@ -379,9 +379,15 @@ var Transcript = class {
379
379
  * history), it anchors the estimate and only blocks streamed after it are
380
380
  * char-estimated; otherwise the whole replay window is estimated at ~4
381
381
  * chars/token with fixed weights for images and documents.
382
+ *
383
+ * When `contextWindow` is given, an anchor larger than the window is
384
+ * discarded: a single request's usage physically cannot exceed the window,
385
+ * so such a value is a provider violation of the response-usage contract
386
+ * (e.g. a turn-cumulative total) and would poison the estimate.
382
387
  */
383
- estimateContextTokens() {
384
- const anchor = this.usageAnchor();
388
+ estimateContextTokens(contextWindow) {
389
+ let anchor = this.usageAnchor();
390
+ if (anchor !== null && contextWindow !== void 0 && contextWindow > 0 && anchor.tokens > contextWindow) anchor = null;
385
391
  if (anchor === null) return this.replayableBlocks().reduce((total, block) => total + estimateBlockTokens(block), 0);
386
392
  let total = anchor.tokens;
387
393
  for (let i = anchor.blockIndex + 1; i < this.blocks.length; i += 1) total += estimateBlockTokens(this.blocks[i]);
@@ -823,9 +829,9 @@ var CompactionController = class {
823
829
  const contextWindow = targetModel.model.contextWindow;
824
830
  if (contextWindow <= 0) return;
825
831
  const threshold = Math.floor(contextWindow * this.host.thresholdRatio);
826
- if (this.host.transcript.estimateContextTokens() < threshold) return;
832
+ if (this.host.transcript.estimateContextTokens(contextWindow) < threshold) return;
827
833
  await this.host.runWithCompactingPhase(async () => {
828
- for (let attempt = 0; attempt < 8 && this.host.transcript.estimateContextTokens() >= threshold; attempt += 1) if (!await this.run()) break;
834
+ for (let attempt = 0; attempt < 8 && this.host.transcript.estimateContextTokens(contextWindow) >= threshold; attempt += 1) if (!await this.run()) break;
829
835
  });
830
836
  }
831
837
  /** Runs one compaction pass before a turn when the current model is over threshold. */
@@ -833,7 +839,7 @@ var CompactionController = class {
833
839
  const contextWindow = this.host.model.model.contextWindow;
834
840
  if (contextWindow <= 0) return;
835
841
  const threshold = Math.floor(contextWindow * this.host.thresholdRatio);
836
- if (this.host.transcript.estimateContextTokens() < threshold) return;
842
+ if (this.host.transcript.estimateContextTokens(contextWindow) < threshold) return;
837
843
  await this.host.runWithCompactingPhase(() => this.run());
838
844
  }
839
845
  /** Runs one compaction pass; returns whether it compacted anything. */
@@ -863,7 +869,7 @@ var CompactionController = class {
863
869
  return false;
864
870
  }
865
871
  async generateSummary(blocks) {
866
- const rendered = renderItemsForSummary(new Transcript(blocks).collectInferenceItems());
872
+ const rendered = renderItemsForSummary(new TranscriptLog(blocks).collectInferenceItems());
867
873
  const policy = this.host.retryPolicy;
868
874
  for (let attempt = 1;; attempt += 1) {
869
875
  const request = buildCompactionSummaryRequest(rendered, {
@@ -1026,7 +1032,7 @@ var ProviderTurnLoop = class {
1026
1032
  }
1027
1033
  const input = parseJsonOrString(toolCall.input);
1028
1034
  const result = await this.invokeToolAsResult(tool, toolCall.toolUseId, input);
1029
- this.host.transcript.completeToolCall(toolCall.toolUseId, result.output, result.isError ?? false, result.metadata ?? result.continuation ?? null);
1035
+ this.host.transcript.completeToolCall(toolCall.toolUseId, result.output, result.isError ?? false, result.view ?? null);
1030
1036
  await this.host.runtime.lifecycle?.({
1031
1037
  type: "after_tool_call",
1032
1038
  agentSessionId: this.host.agentSessionId,
@@ -1079,7 +1085,10 @@ var ProviderTurnLoop = class {
1079
1085
  text: `Tool failed: ${normalized.message}`
1080
1086
  }],
1081
1087
  isError: true,
1082
- metadata: { error: normalized.message }
1088
+ view: {
1089
+ kind: "tool_error",
1090
+ error: normalized.message
1091
+ }
1083
1092
  };
1084
1093
  }
1085
1094
  }
@@ -1164,21 +1173,21 @@ var AgentSession = class AgentSession {
1164
1173
  persistTimer = null;
1165
1174
  persistDirty = false;
1166
1175
  /**
1167
- * Restores a session from a snapshot. Ownership of the snapshot (including
1176
+ * Restores a session from a checkpoint. Ownership of the checkpoint (including
1168
1177
  * `state`) transfers to the session: the caller must not mutate it afterwards.
1169
1178
  * Passing state by reference — not a clone — lets the caller share the same
1170
1179
  * object with harness closures (host/commands), keeping one live state.
1171
1180
  */
1172
- static fromSnapshot(params, options = {}) {
1173
- if (params.snapshot.harnessName !== params.runtime.harnessName) throw new Error(`AgentSession: snapshot harness "${params.snapshot.harnessName}" does not match "${params.runtime.harnessName}"`);
1174
- const snapshot = params.snapshot;
1181
+ static fromCheckpoint(params, options = {}) {
1182
+ if (params.checkpoint.harnessName !== params.runtime.harnessName) throw new Error(`AgentSession: checkpoint harness "${params.checkpoint.harnessName}" does not match "${params.runtime.harnessName}"`);
1183
+ const checkpoint = params.checkpoint;
1175
1184
  return new AgentSession({
1176
1185
  provider: params.provider,
1177
- model: snapshot.model,
1178
- cwd: snapshot.cwd,
1186
+ model: checkpoint.model,
1187
+ cwd: checkpoint.cwd,
1179
1188
  runtime: params.runtime,
1180
- transcript: snapshot.transcript,
1181
- state: snapshot.state
1189
+ transcript: checkpoint.transcript,
1190
+ state: checkpoint.state
1182
1191
  }, options);
1183
1192
  }
1184
1193
  constructor(params, options = {}) {
@@ -1201,7 +1210,7 @@ var AgentSession = class AgentSession {
1201
1210
  idFactory: this.idFactory,
1202
1211
  now: options.now
1203
1212
  };
1204
- this.transcriptLog = params.transcript instanceof Transcript ? params.transcript : new Transcript(params.transcript?.blocks ?? [], transcriptOptions);
1213
+ this.transcriptLog = params.transcript instanceof TranscriptLog ? params.transcript : new TranscriptLog(params.transcript?.blocks ?? [], transcriptOptions);
1205
1214
  const self = this;
1206
1215
  const compactionHost = {
1207
1216
  get transcript() {
@@ -1429,7 +1438,7 @@ var AgentSession = class AgentSession {
1429
1438
  `durationMs: ${durationMs}`
1430
1439
  ].join("\n")
1431
1440
  }],
1432
- metadata: {
1441
+ view: {
1433
1442
  kind: "yield_wakeup",
1434
1443
  wakeupId,
1435
1444
  durationMs
@@ -1948,7 +1957,7 @@ var AgentSession = class AgentSession {
1948
1957
  /**
1949
1958
  * Publishes transcript changes: drains the mutation journal into a patch
1950
1959
  * event (O(changed content), not O(transcript)) and schedules a throttled
1951
- * snapshot write. Boundaries (action end, abort, dispose) flush the write.
1960
+ * checkpoint write. Boundaries (action end, abort, dispose) flush the write.
1952
1961
  */
1953
1962
  async commitTranscript() {
1954
1963
  const drained = this.transcriptLog.takePatches();
@@ -1965,7 +1974,7 @@ var AgentSession = class AgentSession {
1965
1974
  if (this.persistTimer) return;
1966
1975
  this.persistTimer = setTimeout(() => {
1967
1976
  this.persistTimer = null;
1968
- this.persistSnapshot().catch((error) => {
1977
+ this.persistCheckpoint().catch((error) => {
1969
1978
  this.emit({
1970
1979
  type: "error",
1971
1980
  error: asError(error)
@@ -1973,11 +1982,11 @@ var AgentSession = class AgentSession {
1973
1982
  });
1974
1983
  }, this.persistIntervalMs);
1975
1984
  }
1976
- async persistSnapshot() {
1985
+ async persistCheckpoint() {
1977
1986
  if (!this.store || !this.persistDirty) return;
1978
1987
  this.persistDirty = false;
1979
- await this.store.saveSnapshot({
1980
- transcript: this.transcriptLog.snapshot(),
1988
+ await this.store.saveCheckpoint({
1989
+ transcript: this.transcriptLog.toJSON(),
1981
1990
  state: structuredClone(this.agentState),
1982
1991
  phase: this.currentPhase,
1983
1992
  queue: structuredClone(this.queuedMessages()),
@@ -1991,7 +2000,7 @@ var AgentSession = class AgentSession {
1991
2000
  clearTimeout(this.persistTimer);
1992
2001
  this.persistTimer = null;
1993
2002
  }
1994
- await this.persistSnapshot();
2003
+ await this.persistCheckpoint();
1995
2004
  }
1996
2005
  emit(event) {
1997
2006
  for (const listener of this.listeners) listener(event);
@@ -2212,7 +2221,7 @@ function createStandardAgentTools(options) {
2212
2221
  function shellPreviewBudgetTokens(contextWindow) {
2213
2222
  return contextWindow >= LARGE_CONTEXT_THRESHOLD_TOKENS ? LARGE_CONTEXT_PREVIEW_TOKENS : SMALL_CONTEXT_PREVIEW_TOKENS;
2214
2223
  }
2215
- function toShellToolResult(result, toolCallId = "", options = {}) {
2224
+ function toShellToolResult(result, options = {}) {
2216
2225
  const output = [{
2217
2226
  type: "text",
2218
2227
  text: formatShellToolResult(result, options)
@@ -2228,13 +2237,61 @@ function toShellToolResult(result, toolCallId = "", options = {}) {
2228
2237
  return {
2229
2238
  output,
2230
2239
  isError: false,
2231
- metadata: result,
2232
- continuation: result.status === "running" ? {
2233
- toolCallId,
2234
- shellId: result.shellId,
2235
- commandId: result.commandId,
2236
- status: "running"
2237
- } : void 0
2240
+ view: shellToolView(result)
2241
+ };
2242
+ }
2243
+ /** Character budget for a shell view's render window (tail-biased). */
2244
+ const SHELL_VIEW_MAX_CHARS = 32768;
2245
+ function shellToolView(result) {
2246
+ const window = tailChunkWindow(result.output.chunks, SHELL_VIEW_MAX_CHARS);
2247
+ const view = {
2248
+ kind: "shell",
2249
+ status: result.status,
2250
+ shellId: result.shellId,
2251
+ commandId: result.commandId,
2252
+ runningMs: result.runningMs,
2253
+ idleMs: result.idleMs,
2254
+ chunks: window.chunks,
2255
+ viewTruncated: window.truncated || result.output.truncated
2256
+ };
2257
+ if (result.status === "exited") {
2258
+ view.exitCode = result.exitCode;
2259
+ if (result.audit.length > 0) view.audit = result.audit;
2260
+ if (result.commandMetadata && result.commandMetadata.length > 0) view.commandMeta = result.commandMetadata;
2261
+ }
2262
+ return view;
2263
+ }
2264
+ function tailChunkWindow(chunks, maxChars) {
2265
+ const kept = [];
2266
+ let total = 0;
2267
+ for (let i = chunks.length - 1; i >= 0; i -= 1) {
2268
+ const chunk = chunks[i];
2269
+ if (chunk.text.length === 0) continue;
2270
+ const remaining = maxChars - total;
2271
+ if (remaining <= 0) return {
2272
+ chunks: kept,
2273
+ truncated: true
2274
+ };
2275
+ if (chunk.text.length <= remaining) {
2276
+ kept.unshift({
2277
+ stream: chunk.stream,
2278
+ text: chunk.text
2279
+ });
2280
+ total += chunk.text.length;
2281
+ } else {
2282
+ kept.unshift({
2283
+ stream: chunk.stream,
2284
+ text: chunk.text.slice(chunk.text.length - remaining)
2285
+ });
2286
+ return {
2287
+ chunks: kept,
2288
+ truncated: true
2289
+ };
2290
+ }
2291
+ }
2292
+ return {
2293
+ chunks: kept,
2294
+ truncated: false
2238
2295
  };
2239
2296
  }
2240
2297
  /**
@@ -2322,8 +2379,8 @@ function repeatedShellExecResult(environment, agentSessionId, script) {
2322
2379
  ].join("\n")
2323
2380
  }],
2324
2381
  isError: true,
2325
- metadata: {
2326
- kind: "repeated_identical_shell_exec",
2382
+ view: {
2383
+ kind: "repeated_shell_exec",
2327
2384
  script,
2328
2385
  count
2329
2386
  }
@@ -2381,7 +2438,7 @@ function boundedPreview(text, budgetTokens) {
2381
2438
  async function finishShellToolResult(environment, result, ctx) {
2382
2439
  const previewBudgetTokens = shellPreviewBudgetTokens(ctx.model.model.contextWindow);
2383
2440
  const exposeCommandHandle = shellCommandHandleRequired(result, previewBudgetTokens);
2384
- const toolResult = toShellToolResult(result, ctx.toolCallId, {
2441
+ const toolResult = toShellToolResult(result, {
2385
2442
  includePreview: true,
2386
2443
  previewBudgetTokens,
2387
2444
  exposeCommandHandle,
@@ -2478,8 +2535,8 @@ var AgentServer = class {
2478
2535
  /**
2479
2536
  * Tracks which transport binding currently owns each client-provided session
2480
2537
  * id. Opening a session id that is already owned takes it over: the previous
2481
- * binding's session is closed (flushing its snapshot) before the new open
2482
- * proceeds, so two connections never write the same snapshot key concurrently.
2538
+ * binding's session is closed (flushing its checkpoint) before the new open
2539
+ * proceeds, so two connections never write the same checkpoint key concurrently.
2483
2540
  */
2484
2541
  var SessionOwnershipRegistry = class {
2485
2542
  holders = /* @__PURE__ */ new Map();
@@ -2683,7 +2740,7 @@ var AgentTransportBindingImpl = class {
2683
2740
  case "sync_transcript": {
2684
2741
  const session = this.sessionFor("sync_transcript");
2685
2742
  if (!session) return;
2686
- this.sendTranscriptSnapshot(session);
2743
+ this.sendTranscriptReset(session);
2687
2744
  return;
2688
2745
  }
2689
2746
  case "close":
@@ -2715,9 +2772,9 @@ var AgentTransportBindingImpl = class {
2715
2772
  cwd: frame.cwd
2716
2773
  });
2717
2774
  const store = new HostAgentSessionStore(provisionalHost.store, agentSessionId);
2718
- const snapshot = await store.loadSnapshot();
2719
- const restoring = snapshot !== null && snapshot.harnessName === agent.name;
2720
- const state = restoring ? structuredClone(snapshot.state) : initialState;
2775
+ const checkpoint = await store.loadCheckpoint();
2776
+ const restoring = checkpoint !== null && checkpoint.harnessName === agent.name;
2777
+ const state = restoring ? structuredClone(checkpoint.state) : initialState;
2721
2778
  const harnessContext = {
2722
2779
  state,
2723
2780
  cwd: frame.cwd
@@ -2758,11 +2815,11 @@ var AgentTransportBindingImpl = class {
2758
2815
  lifecycle: (event) => agent.lifecycle?.(event),
2759
2816
  tools: () => tools
2760
2817
  };
2761
- const session = restoring ? AgentSession.fromSnapshot({
2818
+ const session = restoring ? AgentSession.fromCheckpoint({
2762
2819
  provider,
2763
2820
  runtime,
2764
- snapshot: {
2765
- ...snapshot,
2821
+ checkpoint: {
2822
+ ...checkpoint,
2766
2823
  state
2767
2824
  }
2768
2825
  }, {
@@ -2790,7 +2847,7 @@ var AgentTransportBindingImpl = class {
2790
2847
  if (restoring) session.updateModel(null, frame.provider.model);
2791
2848
  this.unsubscribeSession = this.session.subscribe((event) => this.handleSessionEvent(event));
2792
2849
  this.send({ type: "opened" });
2793
- this.sendTranscriptSnapshot(session);
2850
+ this.sendTranscriptReset(session);
2794
2851
  this.send({
2795
2852
  type: "phase",
2796
2853
  phase: this.session.phase()
@@ -2800,10 +2857,10 @@ var AgentTransportBindingImpl = class {
2800
2857
  queue: this.session.queuedMessages()
2801
2858
  });
2802
2859
  }
2803
- sendTranscriptSnapshot(session) {
2860
+ sendTranscriptReset(session) {
2804
2861
  const transcript = session.transcript();
2805
2862
  this.send({
2806
- type: "transcript_snapshot",
2863
+ type: "transcript_reset",
2807
2864
  blocks: cloneBlocks(transcript.blocks),
2808
2865
  revision: transcript.revision
2809
2866
  });
@@ -2906,10 +2963,10 @@ var AgentTransportBindingImpl = class {
2906
2963
  const keys = await host.store.list("agent-sessions/");
2907
2964
  const conversations = [];
2908
2965
  for (const key of keys) {
2909
- if (!key.endsWith("/snapshot.json")) continue;
2910
- const snapshot = await host.store.readJson(key);
2911
- if (!snapshot || snapshot.cwd !== cwd) continue;
2912
- conversations.push(summarizeConversation(key.slice(15, -14), snapshot));
2966
+ if (!key.endsWith("/checkpoint.json")) continue;
2967
+ const checkpoint = await host.store.readJson(key);
2968
+ if (!checkpoint || checkpoint.cwd !== cwd) continue;
2969
+ conversations.push(summarizeConversation(key.slice(15, -16), checkpoint));
2913
2970
  }
2914
2971
  conversations.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
2915
2972
  this.send({
@@ -3002,7 +3059,7 @@ var AgentTransportBindingImpl = class {
3002
3059
  type: "shell_output",
3003
3060
  shellId: shell.shellId,
3004
3061
  commandId: shell.commandId,
3005
- snapshot: shell.snapshot
3062
+ status: shell.status
3006
3063
  });
3007
3064
  const audit = progressToAudit(progress);
3008
3065
  if (audit.length > 0) this.send({
@@ -3016,7 +3073,7 @@ var AgentTransportBindingImpl = class {
3016
3073
  type: "shell_output",
3017
3074
  shellId: shell.shellId,
3018
3075
  commandId: shell.commandId,
3019
- snapshot: shell.snapshot
3076
+ status: shell.status
3020
3077
  });
3021
3078
  const audit = progressToAudit(progress);
3022
3079
  if (audit.length > 0) this.send({
@@ -3055,15 +3112,15 @@ var HostAgentSessionStore = class {
3055
3112
  this.store = store;
3056
3113
  this.agentSessionId = agentSessionId;
3057
3114
  }
3058
- saveSnapshot(snapshot) {
3059
- return this.store.writeJson(`agent-sessions/${this.agentSessionId}/snapshot.json`, snapshot);
3115
+ saveCheckpoint(checkpoint) {
3116
+ return this.store.writeJson(`agent-sessions/${this.agentSessionId}/checkpoint.json`, checkpoint);
3060
3117
  }
3061
- loadSnapshot() {
3062
- return this.store.readJson(`agent-sessions/${this.agentSessionId}/snapshot.json`);
3118
+ loadCheckpoint() {
3119
+ return this.store.readJson(`agent-sessions/${this.agentSessionId}/checkpoint.json`);
3063
3120
  }
3064
3121
  };
3065
- function summarizeConversation(id, snapshot) {
3066
- const blocks = snapshot.transcript.blocks;
3122
+ function summarizeConversation(id, checkpoint) {
3123
+ const blocks = checkpoint.transcript.blocks;
3067
3124
  const first = blocks[0];
3068
3125
  const last = blocks[blocks.length - 1];
3069
3126
  return {
@@ -3097,14 +3154,14 @@ function progressToShellOutput(progress) {
3097
3154
  if (!isRecord(progress.stdout) || !isRecord(progress.stderr)) return null;
3098
3155
  const stdout = progress.stdout;
3099
3156
  const stderr = progress.stderr;
3100
- if (!isStreamArtifact(stdout) || !isStreamArtifact(stderr) || typeof progress.runningMs !== "number" || typeof progress.idleMs !== "number") return null;
3157
+ if (!isShellStreamView(stdout) || !isShellStreamView(stderr) || typeof progress.runningMs !== "number" || typeof progress.idleMs !== "number") return null;
3101
3158
  return {
3102
3159
  shellId: progress.shellId,
3103
3160
  commandId: progress.commandId,
3104
- snapshot: progress
3161
+ status: progress
3105
3162
  };
3106
3163
  }
3107
- function isStreamArtifact(value) {
3164
+ function isShellStreamView(value) {
3108
3165
  return typeof value.path === "string" && typeof value.offset === "number" && typeof value.delta === "string" && typeof value.tail === "string" && typeof value.bytes === "number" && typeof value.truncated === "boolean";
3109
3166
  }
3110
3167
  function progressToAudit(progress) {
@@ -3134,4 +3191,4 @@ function createProviderMap(providers) {
3134
3191
  return map;
3135
3192
  }
3136
3193
  //#endregion
3137
- export { AgentClient, AgentServer, AgentSession, DEFAULT_TURN_RETRY_POLICY, RunCommandLineCommandNotRegisteredError, RunCommandLineSessionNotFoundError, RunCommandLineTimeoutError, Transcript, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
3194
+ export { AgentClient, AgentServer, AgentSession, DEFAULT_TURN_RETRY_POLICY, RunCommandLineCommandNotRegisteredError, RunCommandLineSessionNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, TranscriptLog, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
@@ -1,4 +1,4 @@
1
- import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-DVa_82EW.mjs";
1
+ import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-0l1a6QD9.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 { BashAuditEvent, Command, Host, ShellCommandSnapshot } from "@demicodes/shell";
1
+ import { BashAuditEvent, Command, Host, ShellCommandStatus } from "@demicodes/shell";
2
2
  import { AgentProvider, InferenceItem, ProviderEvent, ProviderSelection, ToolDefinition } from "@demicodes/provider";
3
3
  import { Block, ModelSelection, QueuedMessage, SessionPhase, ToolResultContentBlock, Transcript, UserContentBlock } from "@demicodes/core";
4
4
  //#region src/retry-policy.d.ts
@@ -48,7 +48,7 @@ interface DrainedTranscriptPatches {
48
48
  revision: number;
49
49
  patches: TranscriptPatch[];
50
50
  }
51
- declare class Transcript$1 implements Transcript {
51
+ declare class TranscriptLog implements Transcript {
52
52
  readonly blocks: Block[];
53
53
  private readonly idFactory;
54
54
  private readonly now;
@@ -57,7 +57,7 @@ declare class Transcript$1 implements Transcript {
57
57
  private readonly replayHeadChars;
58
58
  private readonly replayTailChars;
59
59
  constructor(blocks?: Block[], options?: TranscriptOptions);
60
- snapshot(): Transcript;
60
+ toJSON(): Transcript;
61
61
  /** Monotonic revision, advanced once per drained patch batch. */
62
62
  get revision(): number;
63
63
  /**
@@ -83,7 +83,7 @@ declare class Transcript$1 implements Transcript {
83
83
  type: 'user';
84
84
  }> | null;
85
85
  applyProviderEvent(model: ModelSelection, event: ProviderEvent): Block | null;
86
- completeToolCall(toolUseId: string, output: ToolResultContentBlock[], isError?: boolean, metadata?: unknown | null): Block | null;
86
+ completeToolCall(toolUseId: string, output: ToolResultContentBlock[], isError?: boolean, view?: unknown | null): Block | null;
87
87
  findPendingToolUseId(): string | null;
88
88
  pendingToolCalls(): Extract<Block, {
89
89
  type: 'tool_call';
@@ -106,8 +106,13 @@ declare class Transcript$1 implements Transcript {
106
106
  * history), it anchors the estimate and only blocks streamed after it are
107
107
  * char-estimated; otherwise the whole replay window is estimated at ~4
108
108
  * chars/token with fixed weights for images and documents.
109
+ *
110
+ * When `contextWindow` is given, an anchor larger than the window is
111
+ * discarded: a single request's usage physically cannot exceed the window,
112
+ * so such a value is a provider violation of the response-usage contract
113
+ * (e.g. a turn-cumulative total) and would poison the estimate.
109
114
  */
110
- estimateContextTokens(): number;
115
+ estimateContextTokens(contextWindow?: number): number;
111
116
  /**
112
117
  * The latest response block's usage, valid only when no compaction happened
113
118
  * after it (compaction shrinks the history the usage was measured against).
@@ -126,7 +131,7 @@ interface AgentPromptContext<State> {
126
131
  agentSessionId: string;
127
132
  state: State;
128
133
  cwd: string;
129
- transcript: Transcript$1;
134
+ transcript: TranscriptLog;
130
135
  }
131
136
  interface AgentSystemPromptContext<State> extends AgentPromptContext<State> {
132
137
  /**
@@ -146,13 +151,13 @@ interface AgentDisposeContext<State> {
146
151
  agentSessionId: string;
147
152
  state: State;
148
153
  cwd: string;
149
- transcript: Transcript$1;
154
+ transcript: TranscriptLog;
150
155
  }
151
156
  interface AgentReferenceResolveContext<State> {
152
157
  agentSessionId: string;
153
158
  state: State;
154
159
  cwd: string;
155
- transcript: Transcript$1;
160
+ transcript: TranscriptLog;
156
161
  signal: AbortSignal;
157
162
  }
158
163
  interface AgentHarnessContext<State> {
@@ -182,16 +187,10 @@ interface AgentToolInvokeContext<State> {
182
187
  interface AgentToolInvokeResult {
183
188
  output: ToolResultContentBlock[];
184
189
  isError?: boolean;
185
- metadata?: unknown | null;
186
- continuation?: ToolContinuation;
190
+ /** Bounded UI-facing view data stored on the tool_call block; see the core Block contract. */
191
+ view?: unknown | null;
187
192
  stopAfterToolResult?: boolean;
188
193
  }
189
- interface ToolContinuation {
190
- toolCallId: string;
191
- shellId: string;
192
- commandId: string;
193
- status: 'running';
194
- }
195
194
  type AbortTarget = 'active_provider_stream' | 'active_tool' | 'active_compaction' | 'active_turn' | 'queued_action' | 'queued_message' | 'pending_yield_wakeup';
196
195
  interface AbortResult {
197
196
  aborted: boolean;
@@ -205,13 +204,13 @@ type AgentLifecycleEvent<State> = {
205
204
  type: 'before_round_start';
206
205
  agentSessionId: string;
207
206
  state: State;
208
- transcript: Transcript$1;
207
+ transcript: TranscriptLog;
209
208
  content: UserContentBlock[];
210
209
  } | {
211
210
  type: 'after_tool_call';
212
211
  agentSessionId: string;
213
212
  state: State;
214
- transcript: Transcript$1;
213
+ transcript: TranscriptLog;
215
214
  toolCallId: string;
216
215
  toolName: string;
217
216
  result: AgentToolInvokeResult;
@@ -219,7 +218,7 @@ type AgentLifecycleEvent<State> = {
219
218
  type: 'after_transcript_rewrite';
220
219
  agentSessionId: string;
221
220
  state: State;
222
- transcript: Transcript$1;
221
+ transcript: TranscriptLog;
223
222
  reason: 'retry';
224
223
  };
225
224
  interface AgentHarnessRuntime<State> {
@@ -237,10 +236,10 @@ interface AgentSessionParams<State> {
237
236
  model: ModelSelection;
238
237
  cwd: string;
239
238
  runtime: AgentHarnessRuntime<State>;
240
- transcript?: Transcript | Transcript$1;
239
+ transcript?: Transcript | TranscriptLog;
241
240
  state?: State;
242
241
  }
243
- interface AgentSessionSnapshot<State> {
242
+ interface AgentSessionCheckpoint<State> {
244
243
  transcript: Transcript;
245
244
  state: State;
246
245
  phase: SessionPhase;
@@ -250,14 +249,14 @@ interface AgentSessionSnapshot<State> {
250
249
  harnessName: string;
251
250
  }
252
251
  interface AgentSessionStore<State = unknown> {
253
- saveSnapshot(snapshot: AgentSessionSnapshot<State>): Promise<void> | void;
254
- /** Load a previously saved snapshot for this session, or null if none exists. */
255
- loadSnapshot(): Promise<AgentSessionSnapshot<State> | null>;
252
+ saveCheckpoint(checkpoint: AgentSessionCheckpoint<State>): Promise<void> | void;
253
+ /** Load a previously saved checkpoint for this session, or null if none exists. */
254
+ loadCheckpoint(): Promise<AgentSessionCheckpoint<State> | null>;
256
255
  }
257
256
  interface AgentSessionRestoreParams<State> {
258
257
  provider: AgentProvider;
259
258
  runtime: AgentHarnessRuntime<State>;
260
- snapshot: AgentSessionSnapshot<State>;
259
+ checkpoint: AgentSessionCheckpoint<State>;
261
260
  }
262
261
  interface AgentSessionOptions<State = unknown> {
263
262
  agentSessionId?: string;
@@ -269,7 +268,7 @@ interface AgentSessionOptions<State = unknown> {
269
268
  preflightThresholdRatio?: number;
270
269
  };
271
270
  /**
272
- * Maximum interval between snapshot writes while a turn is streaming. Writes
271
+ * Maximum interval between checkpoint writes while a turn is streaming. Writes
273
272
  * always flush at action boundaries (turn end, abort, dispose); this only
274
273
  * bounds staleness during streaming. Default 1000ms.
275
274
  */
@@ -372,7 +371,7 @@ type ServerFrame = {
372
371
  command: string;
373
372
  reason: string;
374
373
  } | {
375
- type: 'transcript_snapshot';
374
+ type: 'transcript_reset';
376
375
  blocks: Block[];
377
376
  revision: number;
378
377
  } | {
@@ -405,7 +404,7 @@ type ServerFrame = {
405
404
  type: 'shell_output';
406
405
  shellId: string;
407
406
  commandId: string;
408
- snapshot: ShellCommandSnapshotLike;
407
+ status: ShellCommandStatusLike;
409
408
  } | {
410
409
  type: 'shell_write_result';
411
410
  commandId: string;
@@ -429,7 +428,7 @@ type ServerFrame = {
429
428
  type: 'closed';
430
429
  };
431
430
  /**
432
- * Wire patches for transcript replication. Produced directly by the Transcript's
431
+ * Wire patches for transcript replication. Produced directly by the TranscriptLog's
433
432
  * mutation journal (never diff-derived). `append_text` carries streaming deltas
434
433
  * for the `text` field of the block at the index (text/thinking blocks), keeping
435
434
  * per-delta cost O(delta) instead of O(block) or O(transcript).
@@ -454,9 +453,9 @@ type TranscriptPatch = {
454
453
  path: ['blocks'];
455
454
  value: Block[];
456
455
  };
457
- type ShellCommandSnapshotLike = ShellCommandSnapshot;
456
+ type ShellCommandStatusLike = ShellCommandStatus;
458
457
  type ClientSessionEvent = {
459
- type: 'transcript_snapshot';
458
+ type: 'transcript_reset';
460
459
  blocks: Block[];
461
460
  } | {
462
461
  type: 'transcript_patch';
@@ -488,7 +487,7 @@ type ClientSessionEvent = {
488
487
  type: 'shell_output';
489
488
  shellId: string;
490
489
  commandId: string;
491
- snapshot: ShellCommandSnapshotLike;
490
+ status: ShellCommandStatusLike;
492
491
  } | {
493
492
  type: 'shell_write_result';
494
493
  commandId: string;
@@ -529,4 +528,4 @@ interface InProcessTransportPair {
529
528
  }
530
529
  declare function createInProcessTransportPair(): InProcessTransportPair;
531
530
  //#endregion
532
- export { AgentToolInvokeResult as A, DEFAULT_TURN_RETRY_POLICY as B, AgentSessionRestoreParams as C, AgentTool as D, AgentSystemPromptContext as E, CompactionWindow as F, isRetryableCode as H, DrainedTranscriptPatches as I, Transcript$1 as L, SessionEvent as M, SessionEventListener as N, AgentToolContext as O, ToolContinuation as P, TranscriptOptions as R, AgentSessionParams as S, AgentSessionStore as T, resolveRetryPolicy as U, TurnRetryPolicy as V, retryDelayMs as W, AgentHarnessRuntime as _, createInProcessTransportPair as a, AgentReferenceResolveContext as b, ConversationSummary as c, TranscriptPatch as d, AbortResult as f, AgentHarnessContext as g, AgentHarness as h, InProcessTransportPair as i, ExternalMutationReservation as j, AgentToolInvokeContext as k, ServerFrame as l, AgentDisposeContext as m, AgentServerTransport as n, ClientFrame as o, AbortTarget as p, AgentTransport as r, ClientSessionEvent as s, AgentClientTransport as t, ShellCommandSnapshotLike as u, AgentLifecycleEvent as v, AgentSessionSnapshot as w, AgentSessionOptions as x, AgentPromptContext as y, estimateTranscriptBlockTokens as z };
531
+ export { AgentToolInvokeResult as A, TurnRetryPolicy as B, AgentSessionParams as C, AgentTool as D, AgentSystemPromptContext as E, DrainedTranscriptPatches as F, resolveRetryPolicy as H, TranscriptLog as I, TranscriptOptions as L, SessionEvent as M, SessionEventListener as N, AgentToolContext as O, CompactionWindow as P, estimateTranscriptBlockTokens as R, AgentSessionOptions as S, AgentSessionStore as T, retryDelayMs as U, isRetryableCode as V, AgentHarnessRuntime as _, createInProcessTransportPair as a, AgentReferenceResolveContext as b, ConversationSummary as c, TranscriptPatch as d, AbortResult as f, AgentHarnessContext as g, AgentHarness as h, InProcessTransportPair as i, ExternalMutationReservation as j, AgentToolInvokeContext as k, ServerFrame as l, AgentDisposeContext as m, AgentServerTransport as n, ClientFrame as o, AbortTarget as p, AgentTransport as r, ClientSessionEvent as s, AgentClientTransport as t, ShellCommandStatusLike as u, AgentLifecycleEvent as v, AgentSessionRestoreParams as w, AgentSessionCheckpoint as x, AgentPromptContext as y, DEFAULT_TURN_RETRY_POLICY as z };
@@ -1,4 +1,4 @@
1
- import { c as ConversationSummary, f as AbortResult, n as AgentServerTransport, s as ClientSessionEvent, t as AgentClientTransport } from "./transport-DVa_82EW.mjs";
1
+ import { c as ConversationSummary, f as AbortResult, n as AgentServerTransport, s as ClientSessionEvent, t as AgentClientTransport } from "./transport-0l1a6QD9.mjs";
2
2
  import { ProviderSelection } from "@demicodes/provider";
3
3
  import { Block, UserContentBlock } from "@demicodes/core";
4
4
  //#region src/client.d.ts
@@ -198,12 +198,12 @@ var AgentClient = class {
198
198
  }
199
199
  handleServerFrame(frame) {
200
200
  switch (frame.type) {
201
- case "transcript_snapshot":
201
+ case "transcript_reset":
202
202
  this.blocks = [...frame.blocks];
203
203
  this.revision = frame.revision;
204
204
  this.awaitingResync = false;
205
205
  this.emit({
206
- type: "transcript_snapshot",
206
+ type: "transcript_reset",
207
207
  blocks: this.blocks
208
208
  });
209
209
  return;
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.2.1",
4
+ "version": "0.3.1",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -22,10 +22,10 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@demicodes/core": "^0.2.1",
26
- "@demicodes/provider": "^0.2.1",
27
- "@demicodes/shell": "^0.2.1",
28
- "@demicodes/utils": "^0.2.1"
25
+ "@demicodes/core": "^0.3.1",
26
+ "@demicodes/provider": "^0.3.1",
27
+ "@demicodes/shell": "^0.3.1",
28
+ "@demicodes/utils": "^0.3.1"
29
29
  },
30
30
  "license": "Apache-2.0",
31
31
  "main": "./dist/index.mjs",