@demicodes/agent 0.6.1 → 0.7.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 { b as AgentMetadata, 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-bAa-oKZZ.mjs";
2
- import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-mG7mSLtZ.mjs";
1
+ import { b as AgentMetadata, 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-CD53ZgRO.mjs";
2
+ import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-DrsdY12Z.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 };
@@ -1,2 +1,2 @@
1
- import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-DGk5U5EK.mjs";
1
+ import { n as createWebSocketServerTransport, r as AgentClient, t as createWebSocketClientTransport } from "./websocket-transport-D8o_MJP4.mjs";
2
2
  export { AgentClient, createWebSocketClientTransport, createWebSocketServerTransport };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,18 @@
1
- import { A as AgentToolContext, B as estimateTranscriptBlockTokens, C as AgentSessionCheckpoint, D as AgentSessionStore, E as AgentSessionRestoreParams, F as SessionEventListener, G as retryDelayMs, H as TurnRetryPolicy, I as CompactionWindow, L as DrainedTranscriptPatches, M as AgentToolInvokeResult, N as ExternalMutationReservation, O as AgentSystemPromptContext, P as SessionEvent, R as TranscriptLog, S as AgentReferenceResolveContext, T as AgentSessionParams, U as isRetryableCode, V as DEFAULT_TURN_RETRY_POLICY, W as resolveRetryPolicy, _ as AgentHarnessRuntime, a as createInProcessTransportPair, b as AgentMetadata, c as ConversationSummary, d as TranscriptPatch, f as AbortResult, g as AgentHarnessContext, h as AgentHarness, i as InProcessTransportPair, j as AgentToolInvokeContext, k as AgentTool, 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 AgentHostContext, w as AgentSessionOptions, x as AgentPromptContext, y as AgentLifecycleEvent, z as TranscriptOptions } from "./transport-bAa-oKZZ.mjs";
2
- import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-mG7mSLtZ.mjs";
1
+ import { A as AgentToolContext, B as estimateTranscriptBlockTokens, C as AgentSessionCheckpoint, D as AgentSessionStore, E as AgentSessionRestoreParams, F as SessionEventListener, G as retryDelayMs, H as TurnRetryPolicy, I as CompactionWindow, L as DrainedTranscriptPatches, M as AgentToolInvokeResult, N as ExternalMutationReservation, O as AgentSystemPromptContext, P as SessionEvent, R as TranscriptLog, S as AgentReferenceResolveContext, T as AgentSessionParams, U as isRetryableCode, V as DEFAULT_TURN_RETRY_POLICY, W as resolveRetryPolicy, _ as AgentHarnessRuntime, a as createInProcessTransportPair, b as AgentMetadata, c as ConversationSummary, d as TranscriptPatch, f as AbortResult, g as AgentHarnessContext, h as AgentHarness, i as InProcessTransportPair, j as AgentToolInvokeContext, k as AgentTool, 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 AgentHostContext, w as AgentSessionOptions, x as AgentPromptContext, y as AgentLifecycleEvent, z as TranscriptOptions } from "./transport-CD53ZgRO.mjs";
2
+ import { a as AgentClient, i as AgentActionOptions, n as createWebSocketClientTransport, o as AgentClientListener, r as createWebSocketServerTransport, t as JsonWebSocket } from "./websocket-transport-DrsdY12Z.mjs";
3
3
  import { BashAuditEvent, BashEnvironment, BashEnvironmentOptions, CommandMetadataRecord, Host, ShellCommandStatus, ShellOutputChunk } from "@demicodes/shell";
4
4
  import { AgentProvider, Provider } from "@demicodes/provider";
5
- import { Block, Model, ModelSelection, QueuedMessage, SessionPhase, UserContentBlock } from "@demicodes/core";
5
+ import { Block, Model, ModelSelection, ProviderErrorDiagnostics, QueuedMessage, SessionPhase, UserContentBlock } from "@demicodes/core";
6
+ //#region src/provider-stream-error.d.ts
7
+ /** Error carrying a provider stream's normalized code and bounded diagnostics. */
8
+ declare class ProviderStreamError extends Error {
9
+ readonly code: string | null;
10
+ readonly diagnostics: ProviderErrorDiagnostics | undefined;
11
+ constructor(message: string, code: string | null, diagnostics?: ProviderErrorDiagnostics);
12
+ }
13
+ /** Whether an error is a provider stream error reporting the context window was exceeded. */
14
+ declare function isContextLengthExceeded(error: unknown): boolean;
15
+ //#endregion
6
16
  //#region src/session.d.ts
7
17
  type ActiveTurnPhase = 'provider_streaming' | 'tool_executing' | 'compacting' | 'finalizing';
8
18
  declare class AgentSession<State> {
@@ -55,6 +65,7 @@ declare class AgentSession<State> {
55
65
  retry(options?: {
56
66
  metadata?: AgentMetadata;
57
67
  }): Promise<void>;
68
+ /** Continues from the current transcript after an abort or terminal provider error. */
58
69
  resume(options?: {
59
70
  metadata?: AgentMetadata;
60
71
  }): Promise<void>;
@@ -290,4 +301,4 @@ interface ShellToolView {
290
301
  declare function finishShellToolResult<State>(environment: BashEnvironment, result: ShellCommandStatus, ctx: AgentToolInvokeContext<State>): Promise<AgentToolInvokeResult>;
291
302
  declare function shellCommandHandleRequired(result: ShellCommandStatus, budgetTokens: number): boolean;
292
303
  //#endregion
293
- export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentHostContext, AgentLifecycleEvent, AgentMetadata, 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, PrepareShell, PrepareShellContext, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineShellNotFoundError, 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 };
304
+ export { AbortResult, AbortTarget, ActiveTurnPhase, AgentActionOptions, AgentClient, AgentClientListener, AgentClientTransport, AgentDisposeContext, AgentHarness, AgentHarnessContext, AgentHarnessRuntime, AgentHostContext, AgentLifecycleEvent, AgentMetadata, 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, PrepareShell, PrepareShellContext, ProviderStreamError, RunCommandLineCommandNotRegisteredError, RunCommandLineOptions, RunCommandLineResult, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, ServerFrame, SessionEvent, SessionEventListener, ShellCommandStatusLike, ShellToolResultOptions, ShellToolView, StandardAgentToolOptions, TranscriptLog, TranscriptOptions, TranscriptPatch, TurnRetryPolicy, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isContextLengthExceeded, 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-DGk5U5EK.mjs";
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-D8o_MJP4.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";
@@ -188,7 +188,8 @@ var TranscriptLog = class {
188
188
  createdAt: this.now(),
189
189
  model,
190
190
  message: event.message,
191
- code: event.code
191
+ code: event.code,
192
+ ...event.diagnostics ? { diagnostics: event.diagnostics } : {}
192
193
  });
193
194
  case "abort": return this.pushAbort(model);
194
195
  }
@@ -799,21 +800,6 @@ function buildCompactionSummaryRequest(rendered, context) {
799
800
  };
800
801
  }
801
802
  //#endregion
802
- //#region src/provider-stream-error.ts
803
- /** Error carrying a provider stream's error code (e.g. `context_length_exceeded`). */
804
- var ProviderStreamError = class extends Error {
805
- code;
806
- constructor(message, code) {
807
- super(message);
808
- this.name = "ProviderStreamError";
809
- this.code = code;
810
- }
811
- };
812
- /** Whether an error is a provider stream error reporting the context window was exceeded. */
813
- function isContextLengthExceeded(error) {
814
- return error instanceof ProviderStreamError && error.code === "context_length_exceeded";
815
- }
816
- //#endregion
817
803
  //#region src/compaction-controller.ts
818
804
  /**
819
805
  * Owns the compaction algorithm: pick a window of old transcript blocks, summarize
@@ -889,10 +875,16 @@ var CompactionController = class {
889
875
  if (event.type === "text_delta") summary += event.text;
890
876
  if (event.type === "abort") throw new AbortError();
891
877
  if (event.type === "error") {
892
- if (!(summary.length === 0 && attempt < policy.maxAttempts && isRetryableCode(policy, event.code))) throw new ProviderStreamError(event.message, event.code);
878
+ const diagnostics = {
879
+ source: event.diagnostics?.source ?? "unknown",
880
+ ...event.diagnostics,
881
+ clientRequestId: request.requestId
882
+ };
883
+ if (!(summary.length === 0 && attempt < policy.maxAttempts && isRetryableCode(policy, event.code))) throw new ProviderStreamError(event.message, event.code, diagnostics);
893
884
  transient = {
894
885
  code: event.code,
895
- retryAfterMs: event.retryAfterMs ?? null
886
+ retryAfterMs: event.retryAfterMs ?? null,
887
+ diagnostics
896
888
  };
897
889
  break;
898
890
  }
@@ -903,7 +895,8 @@ var CompactionController = class {
903
895
  type: "retry_scheduled",
904
896
  attempt,
905
897
  delayMs,
906
- code: transient.code
898
+ code: transient.code,
899
+ diagnostics: transient.diagnostics
907
900
  });
908
901
  await abortable(delay(delayMs), request.cancel);
909
902
  }
@@ -967,7 +960,8 @@ var ProviderTurnLoop = class {
967
960
  type: "retry_scheduled",
968
961
  attempt: outcome.attempt,
969
962
  delayMs: outcome.delayMs,
970
- code: outcome.code
963
+ code: outcome.code,
964
+ diagnostics: outcome.diagnostics
971
965
  });
972
966
  await abortable(delay(outcome.delayMs), this.host.currentSignal());
973
967
  }
@@ -980,20 +974,39 @@ var ProviderTurnLoop = class {
980
974
  const run = this.host.provider.run(request);
981
975
  let shouldAutoRecover = false;
982
976
  let produced = false;
977
+ let hasPendingThinkingStart = false;
983
978
  this.host.setActiveProviderRun(run);
984
979
  try {
985
980
  for await (const event of this.host.streamProvider(request, run)) {
986
981
  throwIfAborted(request.cancel);
987
982
  if (event.type === "abort") throw new AbortError();
983
+ if (event.type === "thinking_start") {
984
+ hasPendingThinkingStart = true;
985
+ continue;
986
+ }
988
987
  if (event.type === "error") {
989
- if (!produced && attempt < policy.maxAttempts && isRetryableCode(policy, event.code)) return {
988
+ const diagnostics = {
989
+ source: event.diagnostics?.source ?? "unknown",
990
+ ...event.diagnostics,
991
+ clientRequestId: request.requestId
992
+ };
993
+ const errorEvent = {
994
+ ...event,
995
+ diagnostics
996
+ };
997
+ if (!produced && attempt < policy.maxAttempts && isRetryableCode(policy, errorEvent.code)) return {
990
998
  type: "retry",
991
999
  attempt,
992
- delayMs: retryDelayMs(policy, attempt, event.retryAfterMs ?? null),
993
- code: event.code
1000
+ delayMs: retryDelayMs(policy, attempt, errorEvent.retryAfterMs ?? null),
1001
+ code: errorEvent.code,
1002
+ diagnostics: errorEvent.diagnostics
994
1003
  };
995
- await this.applyProviderEvent(event);
996
- throw new ProviderStreamError(event.message, event.code);
1004
+ await this.applyProviderEvent(errorEvent);
1005
+ throw new ProviderStreamError(errorEvent.message, errorEvent.code, errorEvent.diagnostics);
1006
+ }
1007
+ if (hasPendingThinkingStart) {
1008
+ await this.applyProviderEvent({ type: "thinking_start" });
1009
+ hasPendingThinkingStart = false;
997
1010
  }
998
1011
  await this.applyProviderEvent(event);
999
1012
  produced = true;
@@ -1332,6 +1345,7 @@ var AgentSession = class AgentSession {
1332
1345
  reject: noop
1333
1346
  });
1334
1347
  }
1348
+ /** Continues from the current transcript after an abort or terminal provider error. */
1335
1349
  resume(options = {}) {
1336
1350
  return this.enqueue({
1337
1351
  type: "resume",
@@ -2927,7 +2941,8 @@ var AgentTransportBindingImpl = class {
2927
2941
  type: "retry_scheduled",
2928
2942
  attempt: event.attempt,
2929
2943
  delayMs: event.delayMs,
2930
- code: event.code
2944
+ code: event.code,
2945
+ diagnostics: event.diagnostics
2931
2946
  });
2932
2947
  return;
2933
2948
  case "error":
@@ -3198,13 +3213,12 @@ var AgentTransportBindingImpl = class {
3198
3213
  sendError(error) {
3199
3214
  const normalized = error instanceof Error ? error : new Error(String(error));
3200
3215
  const code = errorCode(error);
3201
- this.send(code ? {
3216
+ const diagnostics = errorDiagnostics(error);
3217
+ this.send({
3202
3218
  type: "error",
3203
3219
  message: normalized.message,
3204
- code
3205
- } : {
3206
- type: "error",
3207
- message: normalized.message
3220
+ ...code ? { code } : {},
3221
+ ...diagnostics ? { diagnostics } : {}
3208
3222
  });
3209
3223
  }
3210
3224
  };
@@ -3285,6 +3299,10 @@ function errorCode(error) {
3285
3299
  if (!isRecord(error) || typeof error.code !== "string") return void 0;
3286
3300
  return error.code;
3287
3301
  }
3302
+ function errorDiagnostics(error) {
3303
+ if (!(error instanceof ProviderStreamError)) return void 0;
3304
+ return error.diagnostics;
3305
+ }
3288
3306
  function createProviderMap(providers) {
3289
3307
  const map = /* @__PURE__ */ new Map();
3290
3308
  for (const provider of providers) {
@@ -3294,4 +3312,4 @@ function createProviderMap(providers) {
3294
3312
  return map;
3295
3313
  }
3296
3314
  //#endregion
3297
- export { AgentClient, AgentServer, AgentSession, DEFAULT_TURN_RETRY_POLICY, RunCommandLineCommandNotRegisteredError, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, TranscriptLog, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
3315
+ export { AgentClient, AgentServer, AgentSession, DEFAULT_TURN_RETRY_POLICY, ProviderStreamError, RunCommandLineCommandNotRegisteredError, RunCommandLineShellNotFoundError, RunCommandLineTimeoutError, SHELL_VIEW_MAX_CHARS, TranscriptLog, applyTranscriptPatches, cloneBlocks, createInProcessTransportPair, createStandardAgentTools, createWebSocketClientTransport, createWebSocketServerTransport, estimateTranscriptBlockTokens, finishShellToolResult, isContextLengthExceeded, isRetryableCode, resolveRetryPolicy, retryDelayMs, shellCommandHandleRequired, shellPreviewBudgetTokens, toShellToolResult };
@@ -1,4 +1,4 @@
1
- import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-bAa-oKZZ.mjs";
1
+ import { n as AgentServerTransport, t as AgentClientTransport } from "./transport-CD53ZgRO.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,7 +1,7 @@
1
1
  import { PortableJsonValue } from "@demicodes/utils";
2
2
  import { BashAuditEvent, Command, Host, ShellCommandStatus } from "@demicodes/shell";
3
3
  import { AgentProvider, InferenceItem, ProviderEvent, ProviderSelection, ToolDefinition } from "@demicodes/provider";
4
- import { Block, ModelSelection, QueuedMessage, SessionPhase, ToolResultContentBlock, Transcript, UserContentBlock } from "@demicodes/core";
4
+ import { Block, ModelSelection, ProviderErrorDiagnostics, QueuedMessage, SessionPhase, ToolResultContentBlock, Transcript, UserContentBlock } from "@demicodes/core";
5
5
  //#region src/retry-policy.d.ts
6
6
  /**
7
7
  * Retry policy for provider requests, applied by the agent runtime (turn loop
@@ -312,6 +312,7 @@ type SessionEvent = {
312
312
  attempt: number;
313
313
  delayMs: number;
314
314
  code: string | null;
315
+ diagnostics?: ProviderErrorDiagnostics;
315
316
  } | {
316
317
  type: 'error';
317
318
  error: Error;
@@ -441,10 +442,12 @@ type ServerFrame = {
441
442
  attempt: number;
442
443
  delayMs: number;
443
444
  code: string | null;
445
+ diagnostics?: ProviderErrorDiagnostics;
444
446
  } | {
445
447
  type: 'error';
446
448
  message: string;
447
449
  code?: string;
450
+ diagnostics?: ProviderErrorDiagnostics;
448
451
  } | {
449
452
  type: 'closed';
450
453
  };
@@ -521,6 +524,7 @@ type ClientSessionEvent = {
521
524
  attempt: number;
522
525
  delayMs: number;
523
526
  code: string | null;
527
+ diagnostics?: ProviderErrorDiagnostics;
524
528
  } | {
525
529
  type: 'rejected';
526
530
  command: string;
@@ -529,6 +533,7 @@ type ClientSessionEvent = {
529
533
  type: 'error';
530
534
  message: string;
531
535
  code?: string;
536
+ diagnostics?: ProviderErrorDiagnostics;
532
537
  } | {
533
538
  type: 'opened';
534
539
  } | {
@@ -1,4 +1,21 @@
1
1
  import { parsePortableJson, stringifyPortableJson } from "@demicodes/utils";
2
+ //#region src/provider-stream-error.ts
3
+ /** Error carrying a provider stream's normalized code and bounded diagnostics. */
4
+ var ProviderStreamError = class extends Error {
5
+ code;
6
+ diagnostics;
7
+ constructor(message, code, diagnostics) {
8
+ super(message);
9
+ this.name = "ProviderStreamError";
10
+ this.code = code;
11
+ this.diagnostics = diagnostics;
12
+ }
13
+ };
14
+ /** Whether an error is a provider stream error reporting the context window was exceeded. */
15
+ function isContextLengthExceeded(error) {
16
+ return error instanceof ProviderStreamError && error.code === "context_length_exceeded";
17
+ }
18
+ //#endregion
2
19
  //#region src/patch.ts
3
20
  /**
4
21
  * Applies journal-produced transcript patches to a block list, returning a new
@@ -156,6 +173,7 @@ var AgentClient = class {
156
173
  });
157
174
  return wait;
158
175
  }
176
+ /** Continues from the current transcript after an abort or terminal provider error. */
159
177
  resume(options = {}) {
160
178
  const wait = this.waitForAction("resume");
161
179
  this.sendFrame({
@@ -284,9 +302,12 @@ var AgentClient = class {
284
302
  return;
285
303
  case "error":
286
304
  this.emit(frame);
287
- this.rejectErroredAction(new Error(frame.message));
288
- this.rejectAllSteerWaiters(new Error(frame.message));
289
- this.rejectAllAbortWaiters(new Error(frame.message));
305
+ {
306
+ const error = frame.code ? new ProviderStreamError(frame.message, frame.code, frame.diagnostics) : new Error(frame.message);
307
+ this.rejectErroredAction(error);
308
+ this.rejectAllSteerWaiters(error);
309
+ this.rejectAllAbortWaiters(error);
310
+ }
290
311
  return;
291
312
  }
292
313
  }
@@ -481,4 +502,4 @@ var WebSocketJsonTransport = class {
481
502
  }
482
503
  };
483
504
  //#endregion
484
- export { cloneBlocks as a, applyTranscriptPatches as i, createWebSocketServerTransport as n, AgentClient as r, createWebSocketClientTransport as t };
505
+ export { cloneBlocks as a, applyTranscriptPatches as i, createWebSocketServerTransport as n, ProviderStreamError as o, AgentClient as r, isContextLengthExceeded as s, createWebSocketClientTransport as t };
@@ -1,4 +1,4 @@
1
- import { b as AgentMetadata, c as ConversationSummary, f as AbortResult, n as AgentServerTransport, s as ClientSessionEvent, t as AgentClientTransport } from "./transport-bAa-oKZZ.mjs";
1
+ import { b as AgentMetadata, c as ConversationSummary, f as AbortResult, n as AgentServerTransport, s as ClientSessionEvent, t as AgentClientTransport } from "./transport-CD53ZgRO.mjs";
2
2
  import { ProviderSelection } from "@demicodes/provider";
3
3
  import { Block, UserContentBlock } from "@demicodes/core";
4
4
  //#region src/client.d.ts
@@ -40,6 +40,7 @@ declare class AgentClient {
40
40
  */
41
41
  setProvider(provider: ProviderSelection): void;
42
42
  retry(options?: AgentActionOptions): Promise<void>;
43
+ /** Continues from the current transcript after an abort or terminal provider error. */
43
44
  resume(options?: AgentActionOptions): Promise<void>;
44
45
  compact(options?: AgentActionOptions): Promise<void>;
45
46
  abort(): Promise<AbortResult>;
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.6.1",
4
+ "version": "0.7.1",
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.6.1",
23
- "@demicodes/provider": "^0.6.1",
24
- "@demicodes/shell": "^0.6.1",
25
- "@demicodes/utils": "^0.6.1"
22
+ "@demicodes/core": "^0.7.1",
23
+ "@demicodes/provider": "^0.7.1",
24
+ "@demicodes/shell": "^0.7.1",
25
+ "@demicodes/utils": "^0.7.1"
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "main": "./dist/index.mjs",