@sayknow-cli/agent-core 0.7.2 → 0.7.4

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/CHANGELOG.md CHANGED
@@ -2,7 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
- ## [0.7.2] - 2026-09-29
5
+ ## [0.7.4] - 2026-10-03
6
+
7
+ ### Fixed
8
+
9
+ - Managed fallback no longer kills healthy long responses. Exceeding the provisional caps (100,000 records / 16 MiB) now publishes the attempt and streams the rest live instead of failing with "exceeded the provisional event buffer limit"; `ManagedAttemptBufferOverflowError` is removed. Streamed content is also published once it has been held for `MANAGED_ATTEMPT_MAX_VISIBLE_HOLD_MS` (2 s), so long and parallel work stays visible while it streams. A published attempt is never silently discarded: a later provider failure surfaces through the ordinary session retry path with the visible output preserved.
10
+ - A provider invocation that exits by throwing (e.g. a local staging failure) now aborts its provider request. Previously the stream kept running unobserved, and the immediate retry on a Codex websocket failed with "websocket request already in progress".
11
+
12
+ ## [0.7.3] - 2026-09-30
13
+
14
+ ### Fixed
15
+
16
+ - Managed fallback now retains a lossless, owned UTF-16 forward-patch ledger instead of cumulative provisional assistant snapshots. Callback records are staged only for an actual observer, all retained owners count against the unchanged 10,000-record/16 MiB limits, and bounded replay validation precedes irreversible callback-before-update dispatch. Local staging/replay/observer failures do not authorize provider fallback.
6
17
 
7
18
  ## [0.6.7] - 2026-09-28
8
19
 
@@ -2,17 +2,27 @@
2
2
  * Agent loop that works with AgentMessage throughout.
3
3
  * Transforms to Message[] only at the LLM call boundary.
4
4
  */
5
- import { type AssistantMessage, type Context, EventStream, type TSchema } from "@sayknow-cli/ai";
5
+ import { type AssistantMessage, type AssistantMessageEvent, type Context, EventStream, type TSchema } from "@sayknow-cli/ai";
6
6
  import { type AgentRunCoverage, type AgentRunSummary } from "./run-collector";
7
7
  import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, AgentTool, StreamFn } from "./types";
8
8
  /** Sentinel returned by the abort race in `streamAssistantResponse`. */
9
9
  /**
10
- * Defensive caps for a provisional managed attempt. These are intentionally
11
- * well above ordinary streamed responses; they only bound memory when an
12
- * upstream emits an unbounded event stream before the attempt can commit.
10
+ * Defensive caps for a provisional managed attempt. They only bound memory when
11
+ * an upstream emits an unbounded event stream before the attempt can commit.
12
+ * Every streamed delta stages two records (the `message_update` event and the
13
+ * observer callback), so the record cap must sit well above the byte cap's
14
+ * effective delta count (~22k ordinary deltas at 16 MiB); a 10,000-record cap
15
+ * killed healthy ~5,000-delta responses with a non-retryable local error.
13
16
  */
14
- export declare const MANAGED_ATTEMPT_MAX_STAGED_EVENTS = 10000;
17
+ export declare const MANAGED_ATTEMPT_MAX_STAGED_EVENTS = 100000;
15
18
  export declare const MANAGED_ATTEMPT_MAX_STAGED_BYTES: number;
19
+ /**
20
+ * Longest a managed attempt may hold streamed content invisible. Failures that
21
+ * warrant a silent model fallback arrive before or at the first content; after
22
+ * this window the attempt is published so long or parallel work stays visible.
23
+ * Reaching either staging cap also publishes instead of killing the attempt.
24
+ */
25
+ export declare const MANAGED_ATTEMPT_MAX_VISIBLE_HOLD_MS = 2000;
16
26
  /**
17
27
  * Validate provider-observed escaped arguments before permitting the only
18
28
  * exception to the fail-closed tool boundary. The raw JSON must decode to the
@@ -80,6 +90,46 @@ export declare const MANAGED_SNAPSHOT_MAX_NODES = 100000;
80
90
  * callers use the default budget via {@link managedAttemptSnapshot}.
81
91
  */
82
92
  export declare function sanitizedDetachedClone<T>(value: T, maxNodes?: number): T;
93
+ interface ManagedOwnedInventory {
94
+ totalBytes: number;
95
+ structuralBytes: number;
96
+ payloadBytes: number;
97
+ peakBytes: number;
98
+ recordCount: number;
99
+ strings: Array<{
100
+ ownerId: number;
101
+ codeUnits: number;
102
+ bytes: number;
103
+ }>;
104
+ buffers: Array<{
105
+ ownerId: number;
106
+ kind: "suffix" | "typed";
107
+ bytes: number;
108
+ }>;
109
+ }
110
+ /**
111
+ * @internal Unsupported transaction/test seam, not a public config or metrics API.
112
+ * Inventory measures retained provisional ownership, never process RSS or
113
+ * postcommit EventStream/consumer snapshots.
114
+ */
115
+ export declare class ManagedAttemptTransaction {
116
+ #private;
117
+ constructor(stream: EventStream<AgentEvent, AgentMessage[]>, observer: ((message: AssistantMessage, event: AssistantMessageEvent) => void) | undefined, model: AgentLoopConfig["model"]);
118
+ /** Whether staged output has been published; later failures cannot be hidden. */
119
+ get committed(): boolean;
120
+ push(event: AgentEvent): void;
121
+ end(messages: AgentMessage[]): void;
122
+ stageAssistantMessageEvent(message: AssistantMessage, event: AssistantMessageEvent): void;
123
+ /** Inventory walks the actual retained ownership roots, not input lengths or
124
+ * an estimated snapshot savings counter. Canonical aliases share an ID;
125
+ * independently owned strings are charged even when JS values compare equal.
126
+ */
127
+ ownedInventory(): ManagedOwnedInventory;
128
+ flush(signal?: AbortSignal): boolean;
129
+ /** Consume the last exposed prefix only on a postcommit terminal exit. */
130
+ takePublishedAssistant(): AssistantMessage | undefined;
131
+ discard(): void;
132
+ }
83
133
  /**
84
134
  * Detailed-result handle returned by {@link agentLoopDetailed}. Adds the
85
135
  * run-level telemetry/coverage rollup to the existing `AgentMessage[]`
@@ -115,3 +165,4 @@ export declare function agentLoopContinueDetailed(context: AgentContext, config:
115
165
  export declare function normalizeMessagesForProvider(messages: Context["messages"], model: AgentLoopConfig["model"]): Context["messages"];
116
166
  export declare const INTENT_FIELD = "_i";
117
167
  export declare function normalizeTools(tools: AgentContext["tools"], injectIntent: boolean): Context["tools"];
168
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sayknow-cli/agent-core",
4
- "version": "0.7.2",
4
+ "version": "0.7.4",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://sayknow-cli.com",
7
7
  "author": "jaybeyond",
@@ -35,9 +35,9 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@sayknow-cli/ai": "0.7.2",
39
- "@sayknow-cli/natives": "0.7.2",
40
- "@sayknow-cli/utils": "0.7.2",
38
+ "@sayknow-cli/ai": "0.7.4",
39
+ "@sayknow-cli/natives": "0.7.4",
40
+ "@sayknow-cli/utils": "0.7.4",
41
41
  "@opentelemetry/api": "^1.9.0"
42
42
  },
43
43
  "devDependencies": {