@sema-agent/core 7.58.0 → 7.59.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/CHANGELOG.md +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
package/dist/brain/anthropic.js
CHANGED
|
@@ -2,14 +2,14 @@ import {} from "../internal/llm.js";
|
|
|
2
2
|
import { BrainError } from "./errors.js";
|
|
3
3
|
import { startsWithInputTooLongAnchor } from "./input-too-long.js";
|
|
4
4
|
import { DEGENERATE_MESSAGE, trimDegenerateTail } from "./repetition.js";
|
|
5
|
-
import { STREAM_TORN_WARNING, createRepetitionPoll, createStreamEndLedger, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes, truncationCauseClause } from "./stream-shared.js";
|
|
5
|
+
import { NO_WORD, STREAM_TORN_WARNING, createRepetitionPoll, createStreamEndLedger, droppedFramesNote, endingInNoWord, endingWordOf, memberReader, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes, truncationCauseClause } from "./stream-shared.js";
|
|
6
6
|
import { admitToolCallId, providerResultIds, providerToolCallId, responseToolCallIds } from "./tool-call-id.js";
|
|
7
7
|
import { emitBrainTelemetry, reportReasoningWireFacts } from "./status-sink.js";
|
|
8
8
|
import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, imageWithholdOf, reportImagesWithheld, sendableImages } from "./media-degrade.js";
|
|
9
9
|
import { ANTHROPIC_RESERVED, OUTPUT_CAP_KEYS, applyExtraBody, declaredRequestValues, effectiveOutputCap, headerBagOnce, headerListEntries, lockHeader, mergeHeaders, takeHeaderSpellings } from "./request-params.js";
|
|
10
10
|
import { admitRouteRequest, applyRouteCredentialHeaders, assertServableRequestRoot, brainConfigSnapshot, createBrainRouteJudge, joinRequestUrl, resolveRequestRootOf, resolveRouteCredential } from "./route-adjudicator.js";
|
|
11
11
|
import { requestRouteOf } from "./request-route.js";
|
|
12
|
-
import { NAMES_AS_WRITTEN, resolveProviderDialect, endpointToolNames } from "./provider-dialect.js";
|
|
12
|
+
import { NAMES_AS_WRITTEN, judgeInBandError, resolveProviderDialect, endpointToolNames } from "./provider-dialect.js";
|
|
13
13
|
import { applyReasoningToRequest, mergeReasoningHeaders } from "./reasoning-request.js";
|
|
14
14
|
import { runStreamingBrain } from "./stream-engine.js";
|
|
15
15
|
import { refuseRetiredTimeoutKnobs } from "./timeout.js";
|
|
@@ -222,6 +222,92 @@ function closeToolUseBlock(acc, responseIds, closed) {
|
|
|
222
222
|
acc.closedTc = { type: "toolCall", id: engineId, ...(wireId !== engineId ? { wireId } : {}), name: acc.toolName, arguments: args };
|
|
223
223
|
return acc.closedTc;
|
|
224
224
|
}
|
|
225
|
+
const DELTA_MEMBER = Object.freeze({
|
|
226
|
+
text_delta: "text",
|
|
227
|
+
thinking_delta: "thinking",
|
|
228
|
+
input_json_delta: "partial_json",
|
|
229
|
+
signature_delta: "signature",
|
|
230
|
+
});
|
|
231
|
+
function readEvent(raw) {
|
|
232
|
+
const frame = memberReader();
|
|
233
|
+
const usageSeat = memberReader();
|
|
234
|
+
const unreadable = (mayCarryCall, index) => ({
|
|
235
|
+
event: { kind: "unreadable", mayCarryCall, ...(index !== undefined ? { index } : {}) },
|
|
236
|
+
outOfShape: true,
|
|
237
|
+
usageUnreadable: usageSeat.outOfShape,
|
|
238
|
+
});
|
|
239
|
+
const evt = typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : undefined;
|
|
240
|
+
if (evt === undefined)
|
|
241
|
+
return unreadable(false);
|
|
242
|
+
const type = frame.word(evt.type);
|
|
243
|
+
if (type === undefined)
|
|
244
|
+
return unreadable(true);
|
|
245
|
+
const usageOf = (v) => {
|
|
246
|
+
const u = usageSeat.object(v);
|
|
247
|
+
if (u === undefined)
|
|
248
|
+
return undefined;
|
|
249
|
+
return {
|
|
250
|
+
input_tokens: usageSeat.count(u.input_tokens),
|
|
251
|
+
output_tokens: usageSeat.count(u.output_tokens),
|
|
252
|
+
cache_read_input_tokens: usageSeat.count(u.cache_read_input_tokens),
|
|
253
|
+
cache_creation_input_tokens: usageSeat.count(u.cache_creation_input_tokens),
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const done = (event) => ({ event, outOfShape: frame.outOfShape, usageUnreadable: usageSeat.outOfShape });
|
|
257
|
+
switch (type) {
|
|
258
|
+
case "message_start": {
|
|
259
|
+
const msg = frame.object(evt.message);
|
|
260
|
+
const usage = usageOf(msg?.usage);
|
|
261
|
+
return done({ kind: "message_start", model: msg?.model, ...(usage !== undefined ? { usage } : {}) });
|
|
262
|
+
}
|
|
263
|
+
case "content_block_start":
|
|
264
|
+
case "content_block_delta":
|
|
265
|
+
case "content_block_stop": {
|
|
266
|
+
const index = frame.count(evt.index);
|
|
267
|
+
if (index === undefined)
|
|
268
|
+
return unreadable(true);
|
|
269
|
+
if (type === "content_block_stop")
|
|
270
|
+
return done({ kind: "content_block_stop", index });
|
|
271
|
+
const body = frame.object(type === "content_block_start" ? evt.content_block : evt.delta);
|
|
272
|
+
const bodyType = frame.word(body?.type);
|
|
273
|
+
if (body === undefined || bodyType === undefined)
|
|
274
|
+
return unreadable(true, index);
|
|
275
|
+
if (type === "content_block_start") {
|
|
276
|
+
const block = bodyType === "tool_use"
|
|
277
|
+
? { type: bodyType, id: frame.word(body.id), name: frame.word(body.name) }
|
|
278
|
+
: bodyType === "redacted_thinking"
|
|
279
|
+
? { type: bodyType, data: frame.word(body.data) }
|
|
280
|
+
: bodyType === "thinking"
|
|
281
|
+
? { type: bodyType, thinking: frame.word(body.thinking), signature: frame.word(body.signature) }
|
|
282
|
+
: { type: bodyType };
|
|
283
|
+
return done({ kind: "content_block_start", index, block });
|
|
284
|
+
}
|
|
285
|
+
const member = Object.hasOwn(DELTA_MEMBER, bodyType) ? DELTA_MEMBER[bodyType] : undefined;
|
|
286
|
+
const delta = member === undefined ? { type: bodyType } : { type: bodyType, [member]: frame.word(body[member]) };
|
|
287
|
+
return done({ kind: "content_block_delta", index, delta });
|
|
288
|
+
}
|
|
289
|
+
case "message_delta": {
|
|
290
|
+
const delta = frame.object(evt.delta);
|
|
291
|
+
const details = frame.object(delta?.stop_details);
|
|
292
|
+
const usage = usageOf(evt.usage);
|
|
293
|
+
return done({
|
|
294
|
+
kind: "message_delta",
|
|
295
|
+
stop: endingWordOf(delta?.stop_reason),
|
|
296
|
+
stopInNoWord: endingInNoWord(delta?.stop_reason),
|
|
297
|
+
...(details !== undefined ? { stopDetails: { category: frame.word(details.category), explanation: frame.word(details.explanation) } } : {}),
|
|
298
|
+
...(usage !== undefined ? { usage } : {}),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
case "message_stop":
|
|
302
|
+
return done({ kind: "message_stop" });
|
|
303
|
+
case "error": {
|
|
304
|
+
const e = frame.object(evt.error);
|
|
305
|
+
return done({ kind: "error", ...(e !== undefined ? { error: { type: frame.word(e.type), message: frame.word(e.message) } } : {}) });
|
|
306
|
+
}
|
|
307
|
+
default:
|
|
308
|
+
return done({ kind: "other" });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
225
311
|
export const ANTHROPIC_DEFAULT_BASE_URL = "https://api.anthropic.com";
|
|
226
312
|
const ANTHROPIC_KEY_HEADER = "x-api-key";
|
|
227
313
|
export function createAnthropicBrain(given = {}) {
|
|
@@ -307,7 +393,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
307
393
|
mergeReasoningHeaders(headers, reasoningHeaders);
|
|
308
394
|
lockHeader(headers, "content-type", "application/json");
|
|
309
395
|
lockHeader(headers, "anthropic-version", config.version ?? "2023-06-01");
|
|
310
|
-
if (apiKey)
|
|
396
|
+
if (apiKey !== undefined)
|
|
311
397
|
lockHeader(headers, ANTHROPIC_KEY_HEADER, apiKey);
|
|
312
398
|
const builtThinkingRequested = reasoningBody.thinking !== undefined;
|
|
313
399
|
const builtMaxTokens = reasoningBody.max_tokens;
|
|
@@ -345,10 +431,17 @@ export function createAnthropicBrain(given = {}) {
|
|
|
345
431
|
const responseIds = responseToolCallIds();
|
|
346
432
|
const usageRaw = {};
|
|
347
433
|
let stopReason = null;
|
|
434
|
+
let stopInNoWord = false;
|
|
348
435
|
let stopDetails;
|
|
349
436
|
let nextContentIndex = 0;
|
|
350
437
|
let malformedFrames = 0;
|
|
351
438
|
let malformedSample;
|
|
439
|
+
const dropFrame = (data) => {
|
|
440
|
+
malformedFrames++;
|
|
441
|
+
malformedSample ??= ctrl.providerWords(data).slice(0, 160);
|
|
442
|
+
};
|
|
443
|
+
let usageUnreadable = false;
|
|
444
|
+
let callsUnreadable = false;
|
|
352
445
|
let degenerate = false;
|
|
353
446
|
let degenTextBlock;
|
|
354
447
|
const rep = createRepetitionPoll();
|
|
@@ -373,35 +466,43 @@ export function createAnthropicBrain(given = {}) {
|
|
|
373
466
|
};
|
|
374
467
|
const reportedUsage = () => ({
|
|
375
468
|
usage: computeUsage(model, usageRaw),
|
|
376
|
-
...(Object.keys(usageRaw).length === 0 ? { usageMissing: true } : {}),
|
|
469
|
+
...(Object.keys(usageRaw).length === 0 || usageUnreadable ? { usageMissing: true } : {}),
|
|
377
470
|
});
|
|
378
|
-
const wordOf = (v) => (typeof v === "string" && v !== "" ? v :
|
|
379
|
-
const refuseAfterEnd = (evt) => {
|
|
380
|
-
switch (evt.
|
|
381
|
-
case "message_delta":
|
|
471
|
+
const wordOf = (v) => (typeof v === "string" && v !== "" ? v : NO_WORD);
|
|
472
|
+
const refuseAfterEnd = ({ event: evt, outOfShape }) => {
|
|
473
|
+
switch (evt.kind) {
|
|
474
|
+
case "message_delta":
|
|
382
475
|
mergeDeltaUsage(evt.usage);
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
476
|
+
if (evt.stop !== null && evt.stop !== stopReason)
|
|
477
|
+
afterEnd.note("ending", evt.stop);
|
|
478
|
+
else if (outOfShape)
|
|
479
|
+
afterEnd.note("content", NO_WORD);
|
|
386
480
|
return;
|
|
387
|
-
}
|
|
388
481
|
case "content_block_start":
|
|
389
|
-
afterEnd.note("content", wordOf(evt.
|
|
482
|
+
afterEnd.note("content", wordOf(evt.block.type));
|
|
390
483
|
return;
|
|
391
484
|
case "content_block_delta":
|
|
392
|
-
afterEnd.note("content", wordOf(evt.delta
|
|
485
|
+
afterEnd.note("content", wordOf(evt.delta.type));
|
|
393
486
|
return;
|
|
394
487
|
case "content_block_stop":
|
|
395
488
|
case "message_start":
|
|
396
|
-
afterEnd.note("content", evt.
|
|
489
|
+
afterEnd.note("content", evt.kind);
|
|
397
490
|
return;
|
|
398
491
|
case "error":
|
|
399
492
|
afterEnd.note("error", wordOf(evt.error?.type));
|
|
400
493
|
return;
|
|
494
|
+
case "unreadable":
|
|
495
|
+
afterEnd.note("content", NO_WORD);
|
|
496
|
+
return;
|
|
401
497
|
default:
|
|
402
498
|
return;
|
|
403
499
|
}
|
|
404
500
|
};
|
|
501
|
+
const blockFrameOutOfShape = (index) => {
|
|
502
|
+
const acc = index === undefined ? undefined : blocks.get(index);
|
|
503
|
+
if (acc === undefined || acc.type === "tool_use")
|
|
504
|
+
callsUnreadable = true;
|
|
505
|
+
};
|
|
405
506
|
const assembleTurn = (stampOn) => {
|
|
406
507
|
const finalContent = [];
|
|
407
508
|
const toolCalls = [];
|
|
@@ -436,7 +537,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
436
537
|
(nameMissingCause(closed) === "truncated" ? malformed : unnamed).push(`id="${ctrl.providerWords(acc.toolId || "?")}"(${ctrl.providerWords(acc.toolJson).slice(0, 200)})`);
|
|
437
538
|
}
|
|
438
539
|
else {
|
|
439
|
-
const tc = closeToolUseBlock(acc, responseIds, closed);
|
|
540
|
+
const tc = callsUnreadable && !acc.closedTc ? undefined : closeToolUseBlock(acc, responseIds, closed);
|
|
440
541
|
if (tc) {
|
|
441
542
|
toolCalls.push(tc);
|
|
442
543
|
finalContent.push(tc);
|
|
@@ -455,21 +556,32 @@ export function createAnthropicBrain(given = {}) {
|
|
|
455
556
|
notes.push({ cause: "unnamed", count: unnamed.length, text: `\n[note: ${unnamed.length} tool call(s) arrived with no tool name and were dropped — re-issue them next turn with an explicit tool name: ${unnamed.join("; ")}]` });
|
|
456
557
|
}
|
|
457
558
|
if (malformedFrames > 0) {
|
|
458
|
-
notes.push({ cause: "bad_frame", count: malformedFrames, text:
|
|
559
|
+
notes.push({ cause: "bad_frame", count: malformedFrames, text: droppedFramesNote(malformedFrames, malformedSample) });
|
|
459
560
|
}
|
|
460
561
|
placeTurnNotes(stampOn, finalContent, notes);
|
|
461
562
|
return { content: finalContent, toolCalls, malformed, unnamed, anyText, reasoningSeen };
|
|
462
563
|
};
|
|
463
|
-
const handleEvent = (
|
|
564
|
+
const handleEvent = (reading, data) => {
|
|
565
|
+
const evt = reading.event;
|
|
464
566
|
if (streamEnded()) {
|
|
465
|
-
|
|
567
|
+
if (reading.usageUnreadable && evt.kind === "message_delta")
|
|
568
|
+
usageUnreadable = true;
|
|
569
|
+
refuseAfterEnd(reading);
|
|
466
570
|
return;
|
|
467
571
|
}
|
|
468
|
-
|
|
572
|
+
if (reading.usageUnreadable)
|
|
573
|
+
usageUnreadable = true;
|
|
574
|
+
if (reading.outOfShape) {
|
|
575
|
+
dropFrame(data);
|
|
576
|
+
if (evt.kind === "unreadable" && evt.mayCarryCall)
|
|
577
|
+
blockFrameOutOfShape(evt.index);
|
|
578
|
+
else if (evt.kind === "content_block_delta")
|
|
579
|
+
blockFrameOutOfShape(evt.index);
|
|
580
|
+
}
|
|
581
|
+
switch (evt.kind) {
|
|
469
582
|
case "message_start": {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
const u = msg?.usage;
|
|
583
|
+
noteResponseModel(partial, evt.model, model.id);
|
|
584
|
+
const u = evt.usage;
|
|
473
585
|
if (u) {
|
|
474
586
|
usageRaw.input_tokens = u.input_tokens;
|
|
475
587
|
usageRaw.cache_read_input_tokens = u.cache_read_input_tokens;
|
|
@@ -480,7 +592,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
480
592
|
case "content_block_start": {
|
|
481
593
|
ctrl.sawContentToken();
|
|
482
594
|
const idx = evt.index;
|
|
483
|
-
const cb = evt.
|
|
595
|
+
const cb = evt.block;
|
|
484
596
|
const acc = { type: "text", text: "", signature: "", toolId: "", toolName: "", toolJson: "" };
|
|
485
597
|
if (cb.type === "thinking" || cb.type === "redacted_thinking") {
|
|
486
598
|
acc.type = "thinking";
|
|
@@ -489,9 +601,9 @@ export function createAnthropicBrain(given = {}) {
|
|
|
489
601
|
acc.signature = cb.data ?? "";
|
|
490
602
|
}
|
|
491
603
|
else {
|
|
492
|
-
if (
|
|
604
|
+
if (cb.thinking)
|
|
493
605
|
acc.text = cb.thinking;
|
|
494
|
-
if (
|
|
606
|
+
if (cb.signature)
|
|
495
607
|
acc.startSignature = cb.signature;
|
|
496
608
|
}
|
|
497
609
|
acc.pb = { type: "thinking", thinking: "" };
|
|
@@ -515,6 +627,8 @@ export function createAnthropicBrain(given = {}) {
|
|
|
515
627
|
}
|
|
516
628
|
blocks.set(idx, acc);
|
|
517
629
|
nextContentIndex = Math.max(nextContentIndex, idx + 1);
|
|
630
|
+
if (reading.outOfShape)
|
|
631
|
+
blockFrameOutOfShape(idx);
|
|
518
632
|
break;
|
|
519
633
|
}
|
|
520
634
|
case "content_block_delta": {
|
|
@@ -552,7 +666,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
552
666
|
}
|
|
553
667
|
}
|
|
554
668
|
}
|
|
555
|
-
else if (d.type === "signature_delta" &&
|
|
669
|
+
else if (d.type === "signature_delta" && d.signature) {
|
|
556
670
|
acc.signature += d.signature;
|
|
557
671
|
}
|
|
558
672
|
else if (d.type === "input_json_delta" && d.partial_json) {
|
|
@@ -572,7 +686,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
572
686
|
out.push({ type: "text_end", contentIndex: idx, content: acc.text, partial: { ...partial } });
|
|
573
687
|
}
|
|
574
688
|
else if (acc?.type === "tool_use") {
|
|
575
|
-
const tc = closeToolUseBlock(acc, responseIds, true);
|
|
689
|
+
const tc = callsUnreadable ? undefined : closeToolUseBlock(acc, responseIds, true);
|
|
576
690
|
if (tc) {
|
|
577
691
|
out.push({ type: "toolcall_end", contentIndex: idx, toolCall: tc, partial: { ...partial } });
|
|
578
692
|
}
|
|
@@ -580,14 +694,15 @@ export function createAnthropicBrain(given = {}) {
|
|
|
580
694
|
break;
|
|
581
695
|
}
|
|
582
696
|
case "message_delta": {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
697
|
+
if (evt.stop !== null) {
|
|
698
|
+
stopReason = evt.stop;
|
|
699
|
+
stopInNoWord = evt.stopInNoWord;
|
|
700
|
+
}
|
|
701
|
+
const raw = evt.stopDetails;
|
|
702
|
+
if (raw !== undefined) {
|
|
588
703
|
stopDetails = {
|
|
589
|
-
...(
|
|
590
|
-
...(
|
|
704
|
+
...(raw.category !== undefined ? { category: ctrl.providerWords(raw.category) } : {}),
|
|
705
|
+
...(raw.explanation !== undefined ? { explanation: ctrl.providerWords(raw.explanation) } : {}),
|
|
591
706
|
};
|
|
592
707
|
}
|
|
593
708
|
mergeDeltaUsage(evt.usage);
|
|
@@ -597,14 +712,15 @@ export function createAnthropicBrain(given = {}) {
|
|
|
597
712
|
messageStopped = true;
|
|
598
713
|
break;
|
|
599
714
|
case "error": {
|
|
600
|
-
const
|
|
601
|
-
const e = typeof rawError === "object" && rawError !== null && !Array.isArray(rawError)
|
|
602
|
-
? rawError
|
|
603
|
-
: undefined;
|
|
715
|
+
const e = evt.error;
|
|
604
716
|
const inputTooLong = e?.type === "request_too_large" ||
|
|
605
717
|
(e?.type === "invalid_request_error" && typeof e.message === "string" && startsWithInputTooLongAnchor(e.message));
|
|
606
718
|
ctrl.keepOutput({ content: assembleTurn({}).content, ...reportedUsage() });
|
|
607
|
-
throw new BrainError(anthropicStreamErrorCode(e?.type), `anthropic stream error ${ctrl.providerWords(`(${e?.type ?? "unknown"}): ${e?.message ?? ""}`)}`, undefined, {
|
|
719
|
+
throw new BrainError(anthropicStreamErrorCode(e?.type), `anthropic stream error ${ctrl.providerWords(`(${e?.type ?? "unknown"}): ${e?.message ?? ""}`)}`, undefined, {
|
|
720
|
+
apiError: true,
|
|
721
|
+
...(e === undefined ? {} : inputTooLong ? { inputTooLong: true } : { inputTooLongRuledOut: true }),
|
|
722
|
+
...(e !== undefined && judgeInBandError(undefined, e).imageUnprocessable ? { imageUnprocessable: true } : {}),
|
|
723
|
+
});
|
|
608
724
|
}
|
|
609
725
|
default:
|
|
610
726
|
break;
|
|
@@ -638,16 +754,15 @@ export function createAnthropicBrain(given = {}) {
|
|
|
638
754
|
const data = line.slice(5).trim();
|
|
639
755
|
if (!data)
|
|
640
756
|
return;
|
|
641
|
-
let
|
|
757
|
+
let parsed;
|
|
642
758
|
try {
|
|
643
|
-
|
|
759
|
+
parsed = JSON.parse(data);
|
|
644
760
|
}
|
|
645
761
|
catch {
|
|
646
|
-
|
|
647
|
-
malformedSample ??= ctrl.providerWords(data).slice(0, 160);
|
|
762
|
+
dropFrame(data);
|
|
648
763
|
return;
|
|
649
764
|
}
|
|
650
|
-
handleEvent(
|
|
765
|
+
handleEvent(readEvent(parsed), data);
|
|
651
766
|
},
|
|
652
767
|
finalize(opts) {
|
|
653
768
|
const { content: finalContent, toolCalls, malformed, unnamed, anyText, reasoningSeen } = assembleTurn(partial);
|
|
@@ -717,6 +832,7 @@ export function createAnthropicBrain(given = {}) {
|
|
|
717
832
|
...(errorKind ? { errorKind } : {}),
|
|
718
833
|
...(modelOutputInvalid !== undefined ? { modelOutputInvalid } : {}),
|
|
719
834
|
...(tornWithContent ? { partialFinalized: true } : {}),
|
|
835
|
+
...(stopInNoWord ? { finishReasonUnknown: NO_WORD } : {}),
|
|
720
836
|
...(rep.cut !== undefined || rep.spared.length > 0
|
|
721
837
|
? { repetition: { ...(rep.cut !== undefined ? { cut: rep.cut } : {}), ...(rep.spared.length > 0 ? { spared: rep.spared } : {}) } }
|
|
722
838
|
: {}),
|
package/dist/brain/errors.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ export declare class BrainError extends Error {
|
|
|
81
81
|
* verdict, word or context-limit reading came from it, and the prefix quoted in the message is no evidence
|
|
82
82
|
* either. Lifted onto `AssistantMessage.errorBodyIncomplete`. */
|
|
83
83
|
readonly errorBodyIncomplete?: true;
|
|
84
|
+
/** The provider stated, in its envelope's diagnostic, that an image in the request could not be processed (the
|
|
85
|
+
* dialect table's image row, `provider-dialect.ts`). Lifted onto `AssistantMessage.errorKind: "image_unprocessable"`
|
|
86
|
+
* at the terminal-shell mint. Never inferred from `detail` prose after construction. */
|
|
87
|
+
readonly imageUnprocessable?: true;
|
|
84
88
|
constructor(code: BrainErrorCode, detail: string, status?: number, opts?: {
|
|
85
89
|
inputTooLong?: boolean;
|
|
86
90
|
inputTooLongRuledOut?: boolean;
|
|
@@ -92,6 +96,7 @@ export declare class BrainError extends Error {
|
|
|
92
96
|
resetAtMs?: number;
|
|
93
97
|
};
|
|
94
98
|
errorBodyIncomplete?: boolean;
|
|
99
|
+
imageUnprocessable?: boolean;
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
/** The provider's diagnostic object out of a JSON error body, or undefined when the body establishes no provenance
|
|
@@ -256,11 +261,12 @@ export declare function abortLikeName(err: unknown): "AbortError" | "TimeoutErro
|
|
|
256
261
|
* rather than testing `instanceof BrainError`, which walks a chain a revoked proxy traps — and the one
|
|
257
262
|
* site that did so sits in an async IIFE with no `.catch`. */
|
|
258
263
|
export declare function brainErrorCodeOf(e: unknown): BrainErrorCode | undefined;
|
|
259
|
-
/** What a thrown brain failure says about itself in machine words: its code, and the structural
|
|
260
|
-
*
|
|
264
|
+
/** What a thrown brain failure says about itself in machine words: its code, and the structural cause its minter
|
|
265
|
+
* declared (input too long, or ruled out; an image the provider could not process). Empty for a value that carries no
|
|
266
|
+
* brain code. */
|
|
261
267
|
export interface ThrownBrainFailure {
|
|
262
268
|
readonly code?: BrainErrorCode;
|
|
263
|
-
readonly errorKind?: "input_too_long";
|
|
269
|
+
readonly errorKind?: "input_too_long" | "image_unprocessable";
|
|
264
270
|
readonly inputTooLongRuledOut?: true;
|
|
265
271
|
}
|
|
266
272
|
/**
|
package/dist/brain/errors.js
CHANGED
|
@@ -23,6 +23,7 @@ export class BrainError extends Error {
|
|
|
23
23
|
providerConditionSource;
|
|
24
24
|
providerResetAtMs;
|
|
25
25
|
errorBodyIncomplete;
|
|
26
|
+
imageUnprocessable;
|
|
26
27
|
constructor(code, detail, status, opts) {
|
|
27
28
|
super(`[${code}] ${detail}`);
|
|
28
29
|
this.name = "BrainError";
|
|
@@ -44,6 +45,8 @@ export class BrainError extends Error {
|
|
|
44
45
|
}
|
|
45
46
|
if (opts?.errorBodyIncomplete === true)
|
|
46
47
|
this.errorBodyIncomplete = true;
|
|
48
|
+
if (opts?.imageUnprocessable === true)
|
|
49
|
+
this.imageUnprocessable = true;
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
export function providerErrorObject(body) {
|
|
@@ -253,7 +256,10 @@ export function thrownBrainFailure(e) {
|
|
|
253
256
|
return {};
|
|
254
257
|
if (readMember(e, "inputTooLong") === true)
|
|
255
258
|
return { code, errorKind: "input_too_long" };
|
|
256
|
-
|
|
259
|
+
const ruledOut = readMember(e, "inputTooLongRuledOut") === true;
|
|
260
|
+
if (readMember(e, "imageUnprocessable") === true)
|
|
261
|
+
return { code, errorKind: "image_unprocessable", ...(ruledOut ? { inputTooLongRuledOut: true } : {}) };
|
|
262
|
+
if (ruledOut)
|
|
257
263
|
return { code, inputTooLongRuledOut: true };
|
|
258
264
|
return { code };
|
|
259
265
|
}
|
package/dist/brain/failover.js
CHANGED
|
@@ -41,7 +41,8 @@ export function createFailoverBrain(brains) {
|
|
|
41
41
|
const cleanUpfrontFailure = message.stopReason === "error" &&
|
|
42
42
|
options?.signal?.aborted !== true &&
|
|
43
43
|
!sawContent &&
|
|
44
|
-
message.errorKind !== "length_empty"
|
|
44
|
+
message.errorKind !== "length_empty" &&
|
|
45
|
+
message.errorKind !== "image_unprocessable";
|
|
45
46
|
if (cleanUpfrontFailure && !isLast) {
|
|
46
47
|
lastFailedCode = extractErrorCode(message.errorMessage);
|
|
47
48
|
continue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from "../internal/llm.js";
|
|
2
2
|
import { BrainError } from "./errors.js";
|
|
3
3
|
import { DEGENERATE_MESSAGE, trimDegenerateTail } from "./repetition.js";
|
|
4
|
-
import { STREAM_TORN_WARNING, createRepetitionPoll, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes } from "./stream-shared.js";
|
|
4
|
+
import { STREAM_TORN_WARNING, createRepetitionPoll, droppedFramesNote, modelOutputInvalidOf, noteResponseModel, nameMissingCause, parseStreamedToolArgs, placeTurnNotes } from "./stream-shared.js";
|
|
5
5
|
import { admitToolCallId, providerResultIds, providerToolCallId, responseToolCallIds } from "./tool-call-id.js";
|
|
6
6
|
import { emitBrainTelemetry } from "./status-sink.js";
|
|
7
7
|
import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, imageWithholdOf, imagesOmittedNoVisionNote, reportImagesWithheld, sendableImages } from "./media-degrade.js";
|
|
@@ -283,7 +283,7 @@ export function createOpenResponsesBrain(given = {}) {
|
|
|
283
283
|
applyRouteCredentialHeaders(headers, routeCredential);
|
|
284
284
|
const declared = declaredRequestValues([modelHeaders, config.headers, optionsHeaders, headers], [], apiKey);
|
|
285
285
|
lockHeader(headers, "content-type", "application/json");
|
|
286
|
-
if (apiKey)
|
|
286
|
+
if (apiKey !== undefined)
|
|
287
287
|
lockHeader(headers, OPEN_RESPONSES_KEY_HEADER, `Bearer ${apiKey}`);
|
|
288
288
|
const { body: wire, dropped: extraBodyDropped } = applyExtraBody(reasoningBody, model, RESPONSES_RESERVED);
|
|
289
289
|
return {
|
|
@@ -687,7 +687,7 @@ export function createOpenResponsesBrain(given = {}) {
|
|
|
687
687
|
notes.push({ cause: "unnamed", count: unnamed.length, text: `\n[note: ${unnamed.length} tool call(s) arrived with no tool name and were dropped — re-issue them next turn with an explicit tool name: ${unnamed.join("; ")}]` });
|
|
688
688
|
}
|
|
689
689
|
if (malformedFrames > 0) {
|
|
690
|
-
notes.push({ cause: "bad_frame", count: malformedFrames, text:
|
|
690
|
+
notes.push({ cause: "bad_frame", count: malformedFrames, text: droppedFramesNote(malformedFrames, malformedSample) });
|
|
691
691
|
}
|
|
692
692
|
placeTurnNotes(partial, finalContent, notes);
|
|
693
693
|
const truncated = incompleteReason === INCOMPLETE_MAX_OUTPUT_TOKENS;
|