agentfootprint 9.24.0 → 9.26.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/AGENTS.md +1 -1
- package/CLAUDE.md +7 -1
- package/README.md +3 -1
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/code/local.js +102 -2
- package/dist/adapters/code/local.js.map +1 -1
- package/dist/adapters/hosting/agentcore.js +11 -0
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/adapters/identity/jwks.js +277 -0
- package/dist/adapters/identity/jwks.js.map +1 -0
- package/dist/adapters/types.js +18 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/artifacts/fileArtifacts.js +144 -17
- package/dist/artifacts/fileArtifacts.js.map +1 -1
- package/dist/artifacts/gcsArtifacts.js +398 -0
- package/dist/artifacts/gcsArtifacts.js.map +1 -0
- package/dist/artifacts/index.js +17 -1
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/objectStore.js +264 -0
- package/dist/artifacts/objectStore.js.map +1 -0
- package/dist/artifacts/payload.js +41 -2
- package/dist/artifacts/payload.js.map +1 -1
- package/dist/artifacts/recordingArtifact.js +88 -0
- package/dist/artifacts/recordingArtifact.js.map +1 -0
- package/dist/artifacts/s3Artifacts.js +542 -0
- package/dist/artifacts/s3Artifacts.js.map +1 -0
- package/dist/artifacts/scopePath.js +87 -0
- package/dist/artifacts/scopePath.js.map +1 -0
- package/dist/artifacts/streaming.js +132 -0
- package/dist/artifacts/streaming.js.map +1 -0
- package/dist/artifacts/types.js +10 -2
- package/dist/artifacts/types.js.map +1 -1
- package/dist/core/Agent.js +176 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +20 -0
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/repeatedCall.js +190 -0
- package/dist/core/agent/repeatedCall.js.map +1 -0
- package/dist/core/agent/stages/toolCalls.js +50 -0
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/codeRunnerTool.js +149 -12
- package/dist/core/codeRunnerTool.js.map +1 -1
- package/dist/esm/adapters/code/local.d.ts +16 -0
- package/dist/esm/adapters/code/local.js +102 -2
- package/dist/esm/adapters/code/local.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.js +11 -0
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/adapters/identity/jwks.d.ts +124 -0
- package/dist/esm/adapters/identity/jwks.js +249 -0
- package/dist/esm/adapters/identity/jwks.js.map +1 -0
- package/dist/esm/adapters/types.d.ts +86 -0
- package/dist/esm/adapters/types.js +16 -0
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/artifacts/fileArtifacts.d.ts +13 -1
- package/dist/esm/artifacts/fileArtifacts.js +145 -18
- package/dist/esm/artifacts/fileArtifacts.js.map +1 -1
- package/dist/esm/artifacts/gcsArtifacts.d.ts +142 -0
- package/dist/esm/artifacts/gcsArtifacts.js +394 -0
- package/dist/esm/artifacts/gcsArtifacts.js.map +1 -0
- package/dist/esm/artifacts/index.d.ts +5 -1
- package/dist/esm/artifacts/index.js +4 -0
- package/dist/esm/artifacts/index.js.map +1 -1
- package/dist/esm/artifacts/objectStore.d.ts +166 -0
- package/dist/esm/artifacts/objectStore.js +252 -0
- package/dist/esm/artifacts/objectStore.js.map +1 -0
- package/dist/esm/artifacts/payload.d.ts +36 -4
- package/dist/esm/artifacts/payload.js +38 -1
- package/dist/esm/artifacts/payload.js.map +1 -1
- package/dist/esm/artifacts/recordingArtifact.d.ts +76 -0
- package/dist/esm/artifacts/recordingArtifact.js +83 -0
- package/dist/esm/artifacts/recordingArtifact.js.map +1 -0
- package/dist/esm/artifacts/s3Artifacts.d.ts +149 -0
- package/dist/esm/artifacts/s3Artifacts.js +538 -0
- package/dist/esm/artifacts/s3Artifacts.js.map +1 -0
- package/dist/esm/artifacts/scopePath.d.ts +50 -0
- package/dist/esm/artifacts/scopePath.js +80 -0
- package/dist/esm/artifacts/scopePath.js.map +1 -0
- package/dist/esm/artifacts/streaming.d.ts +82 -0
- package/dist/esm/artifacts/streaming.js +123 -0
- package/dist/esm/artifacts/streaming.js.map +1 -0
- package/dist/esm/artifacts/types.d.ts +71 -5
- package/dist/esm/artifacts/types.js +10 -2
- package/dist/esm/artifacts/types.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +66 -2
- package/dist/esm/core/Agent.js +176 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.js +20 -0
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/repeatedCall.d.ts +150 -0
- package/dist/esm/core/agent/repeatedCall.js +184 -0
- package/dist/esm/core/agent/repeatedCall.js.map +1 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +12 -0
- package/dist/esm/core/agent/stages/toolCalls.js +50 -0
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +82 -0
- package/dist/esm/core/codeRunnerTool.d.ts +31 -0
- package/dist/esm/core/codeRunnerTool.js +149 -12
- package/dist/esm/core/codeRunnerTool.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +22 -0
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/hosting/admission.d.ts +180 -0
- package/dist/esm/hosting/admission.js +188 -0
- package/dist/esm/hosting/admission.js.map +1 -0
- package/dist/esm/hosting/artifactWire.d.ts +8 -5
- package/dist/esm/hosting/artifactWire.js +14 -9
- package/dist/esm/hosting/artifactWire.js.map +1 -1
- package/dist/esm/hosting/envelope.d.ts +34 -0
- package/dist/esm/hosting/envelope.js +81 -0
- package/dist/esm/hosting/envelope.js.map +1 -1
- package/dist/esm/hosting/errors.d.ts +131 -0
- package/dist/esm/hosting/errors.js +195 -0
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/httpHost.d.ts +21 -0
- package/dist/esm/hosting/httpHost.js +44 -2
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/identityVerification.d.ts +154 -0
- package/dist/esm/hosting/identityVerification.js +135 -0
- package/dist/esm/hosting/identityVerification.js.map +1 -0
- package/dist/esm/hosting/index.d.ts +12 -3
- package/dist/esm/hosting/index.js +16 -2
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/memorySessions.d.ts +9 -0
- package/dist/esm/hosting/memorySessions.js +86 -0
- package/dist/esm/hosting/memorySessions.js.map +1 -1
- package/dist/esm/hosting/nodeHost.js +8 -0
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/sessionWire.d.ts +126 -0
- package/dist/esm/hosting/sessionWire.js +95 -0
- package/dist/esm/hosting/sessionWire.js.map +1 -0
- package/dist/esm/hosting/sqliteSessions.js +122 -5
- package/dist/esm/hosting/sqliteSessions.js.map +1 -1
- package/dist/esm/hosting/standingAgent.js +299 -8
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/types.d.ts +166 -6
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/hosting/wireOps.d.ts +52 -0
- package/dist/esm/hosting/wireOps.js +60 -0
- package/dist/esm/hosting/wireOps.js.map +1 -0
- package/dist/esm/identity.d.ts +1 -0
- package/dist/esm/identity.js +6 -0
- package/dist/esm/identity.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +10 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +27 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js +13 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/esm/lib/injection-engine/index.d.ts +1 -0
- package/dist/esm/lib/injection-engine/index.js +7 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraph.js +9 -1
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillSteps.d.ts +16 -0
- package/dist/esm/lib/injection-engine/skillSteps.js +5 -0
- package/dist/esm/lib/injection-engine/skillSteps.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillVocabulary.d.ts +83 -0
- package/dist/esm/lib/injection-engine/skillVocabulary.js +218 -0
- package/dist/esm/lib/injection-engine/skillVocabulary.js.map +1 -0
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/admission.js +194 -0
- package/dist/hosting/admission.js.map +1 -0
- package/dist/hosting/artifactWire.js +14 -9
- package/dist/hosting/artifactWire.js.map +1 -1
- package/dist/hosting/envelope.js +84 -1
- package/dist/hosting/envelope.js.map +1 -1
- package/dist/hosting/errors.js +203 -1
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/httpHost.js +43 -1
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/identityVerification.js +140 -0
- package/dist/hosting/identityVerification.js.map +1 -0
- package/dist/hosting/index.js +38 -1
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/memorySessions.js +86 -0
- package/dist/hosting/memorySessions.js.map +1 -1
- package/dist/hosting/nodeHost.js +8 -0
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/sessionWire.js +100 -0
- package/dist/hosting/sessionWire.js.map +1 -0
- package/dist/hosting/sqliteSessions.js +121 -4
- package/dist/hosting/sqliteSessions.js.map +1 -1
- package/dist/hosting/standingAgent.js +297 -6
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/hosting/types.js.map +1 -1
- package/dist/hosting/wireOps.js +65 -0
- package/dist/hosting/wireOps.js.map +1 -0
- package/dist/identity.js +9 -1
- package/dist/identity.js.map +1 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineSkill.js +13 -0
- package/dist/lib/injection-engine/factories/defineSkill.js.map +1 -1
- package/dist/lib/injection-engine/index.js +10 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +9 -1
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/skillGraphCheckup.js.map +1 -1
- package/dist/lib/injection-engine/skillSteps.js +5 -0
- package/dist/lib/injection-engine/skillSteps.js.map +1 -1
- package/dist/lib/injection-engine/skillVocabulary.js +224 -0
- package/dist/lib/injection-engine/skillVocabulary.js.map +1 -0
- package/dist/types/adapters/code/local.d.ts +16 -0
- package/dist/types/adapters/code/local.d.ts.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/identity/jwks.d.ts +125 -0
- package/dist/types/adapters/identity/jwks.d.ts.map +1 -0
- package/dist/types/adapters/types.d.ts +86 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/artifacts/fileArtifacts.d.ts +13 -1
- package/dist/types/artifacts/fileArtifacts.d.ts.map +1 -1
- package/dist/types/artifacts/gcsArtifacts.d.ts +143 -0
- package/dist/types/artifacts/gcsArtifacts.d.ts.map +1 -0
- package/dist/types/artifacts/index.d.ts +5 -1
- package/dist/types/artifacts/index.d.ts.map +1 -1
- package/dist/types/artifacts/objectStore.d.ts +167 -0
- package/dist/types/artifacts/objectStore.d.ts.map +1 -0
- package/dist/types/artifacts/payload.d.ts +36 -4
- package/dist/types/artifacts/payload.d.ts.map +1 -1
- package/dist/types/artifacts/recordingArtifact.d.ts +77 -0
- package/dist/types/artifacts/recordingArtifact.d.ts.map +1 -0
- package/dist/types/artifacts/s3Artifacts.d.ts +150 -0
- package/dist/types/artifacts/s3Artifacts.d.ts.map +1 -0
- package/dist/types/artifacts/scopePath.d.ts +51 -0
- package/dist/types/artifacts/scopePath.d.ts.map +1 -0
- package/dist/types/artifacts/streaming.d.ts +83 -0
- package/dist/types/artifacts/streaming.d.ts.map +1 -0
- package/dist/types/artifacts/types.d.ts +71 -5
- package/dist/types/artifacts/types.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +66 -2
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/repeatedCall.d.ts +151 -0
- package/dist/types/core/agent/repeatedCall.d.ts.map +1 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts +12 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +82 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/codeRunnerTool.d.ts +31 -0
- package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +22 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/hosting/admission.d.ts +181 -0
- package/dist/types/hosting/admission.d.ts.map +1 -0
- package/dist/types/hosting/artifactWire.d.ts +8 -5
- package/dist/types/hosting/artifactWire.d.ts.map +1 -1
- package/dist/types/hosting/envelope.d.ts +34 -0
- package/dist/types/hosting/envelope.d.ts.map +1 -1
- package/dist/types/hosting/errors.d.ts +131 -0
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts +21 -0
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/identityVerification.d.ts +155 -0
- package/dist/types/hosting/identityVerification.d.ts.map +1 -0
- package/dist/types/hosting/index.d.ts +12 -3
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/memorySessions.d.ts +9 -0
- package/dist/types/hosting/memorySessions.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/sessionWire.d.ts +127 -0
- package/dist/types/hosting/sessionWire.d.ts.map +1 -0
- package/dist/types/hosting/sqliteSessions.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/types.d.ts +166 -6
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/hosting/wireOps.d.ts +53 -0
- package/dist/types/hosting/wireOps.d.ts.map +1 -0
- package/dist/types/identity.d.ts +1 -0
- package/dist/types/identity.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts +27 -0
- package/dist/types/lib/injection-engine/factories/defineSkill.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraphCheckup.d.ts +1 -1
- package/dist/types/lib/injection-engine/skillGraphCheckup.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillSteps.d.ts +16 -0
- package/dist/types/lib/injection-engine/skillSteps.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillVocabulary.d.ts +84 -0
- package/dist/types/lib/injection-engine/skillVocabulary.d.ts.map +1 -0
- package/package.json +15 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* artifacts/streaming — the OPTIONAL leg of the port, and how to ask for it.
|
|
4
|
+
*
|
|
5
|
+
* A claim check exists so a 6 MB result never rides the conversation. It does
|
|
6
|
+
* not follow that the 6 MB should ride the PROCESS: a store that can accept
|
|
7
|
+
* bytes as they arrive, and hand them back the same way, lets a report be
|
|
8
|
+
* written to a bucket without ever existing whole in memory. That is what
|
|
9
|
+
* `putStream` / `getStream` are for.
|
|
10
|
+
*
|
|
11
|
+
* ── Why OPTIONAL members and not two more verbs ─────────────────────────────
|
|
12
|
+
* Not every backend can honor the promise, and the ones that cannot must say
|
|
13
|
+
* so by ABSENCE rather than by faking it. A `Map`-backed store "streaming"
|
|
14
|
+
* bytes it already holds whole would be theatre: the memory was already spent,
|
|
15
|
+
* and a consumer that chose it to bound memory would have been told a
|
|
16
|
+
* falsehood in the shape of a capability. So:
|
|
17
|
+
*
|
|
18
|
+
* • `fileArtifacts` — YES. The bytes go to a sibling file as they arrive.
|
|
19
|
+
* • object stores — YES, through the SDK's own streaming upload/download.
|
|
20
|
+
* • `sqliteArtifacts`— NO. `node:sqlite` reads and writes a BLOB whole;
|
|
21
|
+
* there is no incremental blob I/O to build on, so a
|
|
22
|
+
* stream here would buffer everything and call it a
|
|
23
|
+
* stream.
|
|
24
|
+
* • `inMemoryArtifacts` — NO, by design. It holds payloads whole, under a
|
|
25
|
+
* byte budget; streaming into it would defeat both.
|
|
26
|
+
*
|
|
27
|
+
* ── Web streams, one shape ──────────────────────────────────────────────────
|
|
28
|
+
* `ReadableStream<Uint8Array>` — the shape that exists in every supported Node
|
|
29
|
+
* AND in a browser, so the port stays the same object everywhere the rest of
|
|
30
|
+
* this folder already works (the Buffer-free base64 law in `payload.ts`, for
|
|
31
|
+
* the same reason). Node-native adapters bridge at their own edge with
|
|
32
|
+
* `Readable.toWeb` / `Readable.fromWeb`; that bridge is an ADAPTER detail and
|
|
33
|
+
* never leaks into the port.
|
|
34
|
+
*
|
|
35
|
+
* ── What `ctx.artifacts` does NOT get, and why (a decision, not an omission) ─
|
|
36
|
+
* The tool-facing capability keeps FIVE verbs this phase. A tool receives its
|
|
37
|
+
* artifacts pre-scoped and answers a model; the model cannot hold a stream,
|
|
38
|
+
* and a tool that genuinely moves gigabytes wants the store itself, with its
|
|
39
|
+
* own lifecycle and its own error handling. So a tool that needs streaming
|
|
40
|
+
* holds the store (it already constructed it) and calls it directly — while
|
|
41
|
+
* `ctx.artifacts` stays the small, safe, scope-bound surface a model-driven
|
|
42
|
+
* tool can be trusted with.
|
|
43
|
+
*/
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.assertStreamBytes = exports.bytesAsStream = exports.collectStream = exports.canStreamArtifacts = exports.canGetArtifactStream = exports.canPutArtifactStream = void 0;
|
|
46
|
+
const types_js_1 = require("./types.js");
|
|
47
|
+
/**
|
|
48
|
+
* Can this store take a streamed put? Narrowing type guard — the answer is
|
|
49
|
+
* the type, so a consumer branches once and the compiler carries it.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* if (canPutArtifactStream(store)) await store.putStream(scope, input, body);
|
|
53
|
+
* else await store.put(scope, { ...input, data: await collect(body) });
|
|
54
|
+
*/
|
|
55
|
+
function canPutArtifactStream(store) {
|
|
56
|
+
return typeof store.putStream === 'function';
|
|
57
|
+
}
|
|
58
|
+
exports.canPutArtifactStream = canPutArtifactStream;
|
|
59
|
+
/** Can this store hand back a stream? Narrowing type guard. */
|
|
60
|
+
function canGetArtifactStream(store) {
|
|
61
|
+
return typeof store.getStream === 'function';
|
|
62
|
+
}
|
|
63
|
+
exports.canGetArtifactStream = canGetArtifactStream;
|
|
64
|
+
/** Both halves at once — for a consumer that needs the round trip. */
|
|
65
|
+
function canStreamArtifacts(store) {
|
|
66
|
+
return canPutArtifactStream(store) && canGetArtifactStream(store);
|
|
67
|
+
}
|
|
68
|
+
exports.canStreamArtifacts = canStreamArtifacts;
|
|
69
|
+
/**
|
|
70
|
+
* Read a stream to its bytes, refusing at a ceiling instead of growing until
|
|
71
|
+
* the process dies.
|
|
72
|
+
*
|
|
73
|
+
* Adapters that must hold the payload to store it (an object `put` of a
|
|
74
|
+
* declared length) use this, and so does any consumer bridging a stream into
|
|
75
|
+
* `put`. The ceiling is the caller's declared `bytes`: a producer that says
|
|
76
|
+
* 10 MB and sends 11 is refused rather than trusted, because the meta it
|
|
77
|
+
* would otherwise mint describes a payload that does not exist.
|
|
78
|
+
*/
|
|
79
|
+
async function collectStream(body, ceiling) {
|
|
80
|
+
const reader = body.getReader();
|
|
81
|
+
const chunks = [];
|
|
82
|
+
let total = 0;
|
|
83
|
+
try {
|
|
84
|
+
for (;;) {
|
|
85
|
+
const { done, value } = await reader.read();
|
|
86
|
+
if (done)
|
|
87
|
+
break;
|
|
88
|
+
if (value === undefined)
|
|
89
|
+
continue;
|
|
90
|
+
total += value.byteLength;
|
|
91
|
+
if (total > ceiling) {
|
|
92
|
+
await reader.cancel();
|
|
93
|
+
return { bytes: new Uint8Array(0), overflowed: true };
|
|
94
|
+
}
|
|
95
|
+
chunks.push(value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
reader.releaseLock();
|
|
100
|
+
}
|
|
101
|
+
const out = new Uint8Array(total);
|
|
102
|
+
let offset = 0;
|
|
103
|
+
for (const chunk of chunks) {
|
|
104
|
+
out.set(chunk, offset);
|
|
105
|
+
offset += chunk.byteLength;
|
|
106
|
+
}
|
|
107
|
+
return { bytes: out, overflowed: false };
|
|
108
|
+
}
|
|
109
|
+
exports.collectStream = collectStream;
|
|
110
|
+
/** One chunk of bytes as a web stream — how a store that HOLDS the payload
|
|
111
|
+
* answers `getStream` honestly (it never claimed to be lazy; it is handing
|
|
112
|
+
* over what it has, in the port's shape). */
|
|
113
|
+
function bytesAsStream(bytes) {
|
|
114
|
+
return new ReadableStream({
|
|
115
|
+
start(controller) {
|
|
116
|
+
controller.enqueue(bytes);
|
|
117
|
+
controller.close();
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.bytesAsStream = bytesAsStream;
|
|
122
|
+
/** The stated `bytes` on a streamed put, checked before anything is stored. */
|
|
123
|
+
function assertStreamBytes(adapter, bytes) {
|
|
124
|
+
if (typeof bytes !== 'number' || !Number.isFinite(bytes) || bytes < 0) {
|
|
125
|
+
throw new types_js_1.InvalidArtifactError(`${adapter}: putStream needs a stated \`bytes\` (got ${JSON.stringify(bytes)}). A stream ` +
|
|
126
|
+
`has no length until it ends, and both the retention plan and the upload need the size ` +
|
|
127
|
+
`BEFORE the first chunk. State the exact byte length, or use put() with the payload.`);
|
|
128
|
+
}
|
|
129
|
+
return Math.floor(bytes);
|
|
130
|
+
}
|
|
131
|
+
exports.assertStreamBytes = assertStreamBytes;
|
|
132
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../src/artifacts/streaming.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;AAEH,yCAAsE;AAYtE;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,KAAoB;IACvD,OAAO,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC;AAC/C,CAAC;AAFD,oDAEC;AAED,+DAA+D;AAC/D,SAAgB,oBAAoB,CAAC,KAAoB;IACvD,OAAO,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC;AAC/C,CAAC;AAFD,oDAEC;AAED,sEAAsE;AACtE,SAAgB,kBAAkB,CAAC,KAAoB;IACrD,OAAO,oBAAoB,CAAC,KAAK,CAAC,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAFD,gDAEC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,aAAa,CACjC,IAAgC,EAChC,OAAe;IAEf,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;YAC1B,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;gBACpB,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtB,OAAO,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;YACxD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC;AA7BD,sCA6BC;AAED;;8CAE8C;AAC9C,SAAgB,aAAa,CAAC,KAAiB;IAC7C,OAAO,IAAI,cAAc,CAAa;QACpC,KAAK,CAAC,UAAU;YACd,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1B,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAPD,sCAOC;AAED,+EAA+E;AAC/E,SAAgB,iBAAiB,CAAC,OAAe,EAAE,KAAc;IAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,+BAAoB,CAC5B,GAAG,OAAO,6CAA6C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc;YACxF,wFAAwF;YACxF,qFAAqF,CACxF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AATD,8CASC"}
|
package/dist/artifacts/types.js
CHANGED
|
@@ -25,11 +25,19 @@
|
|
|
25
25
|
* `put · head · get · delete · list`. The moment this port grows `query()` or
|
|
26
26
|
* `transform()` we are building a database — compute belongs to the code leg,
|
|
27
27
|
* and that refusal is written here so a future round can be refused by
|
|
28
|
-
* citation.
|
|
29
|
-
* a stream (streaming is a later, feature-detected addition — not Phase 1).
|
|
28
|
+
* citation.
|
|
30
29
|
*
|
|
31
30
|
* `head` earns its place because it IS the render-by-ref decision: a consumer
|
|
32
31
|
* picks what to do from `kind` and `bytes` without paying for the payload.
|
|
32
|
+
*
|
|
33
|
+
* ── …and two OPTIONAL ones (9.25.0) ─────────────────────────────────────────
|
|
34
|
+
* `putStream?` / `getStream?` are feature-detected members, not a sixth and
|
|
35
|
+
* seventh verb: a store that cannot move a payload without holding it whole
|
|
36
|
+
* LEAVES THEM ABSENT, and a consumer that calls one it did not detect gets a
|
|
37
|
+
* type error rather than a runtime surprise. An adapter must never fake a
|
|
38
|
+
* stream over bytes it already holds — a fake stream is an accepted-and-
|
|
39
|
+
* silently-wrong promise about memory. See {@link ArtifactStreamPutInput} for
|
|
40
|
+
* the two things streaming costs you (a stated `bytes`, and no digest).
|
|
33
41
|
*/
|
|
34
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
43
|
exports.InvalidArtifactError = exports.ArtifactIntegrityError = exports.UnknownParentRefError = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/artifacts/types.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/artifacts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;;;AA6OH,wEAAwE;AAExE;;;;;GAKG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IACrC,IAAI,GAAG,wBAAiC,CAAC;IAClD,0CAA0C;IACjC,UAAU,CAAyB;IAE5C,YAAY,UAAkC;QAC5C,KAAK,CACH,uCAAuC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAClF,oFAAoF;YACpF,qFAAqF;YACrF,wFAAwF,CAC3F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAfD,sDAeC;AAED;;;;;GAKG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IACtC,IAAI,GAAG,wBAAiC,CAAC;IACzC,GAAG,CAAc;IAC1B,gCAAgC;IACvB,QAAQ,CAAS;IAC1B,uDAAuD;IAC9C,MAAM,CAAS;IAExB,YAAY,GAAgB,EAAE,QAAgB,EAAE,MAAc;QAC5D,KAAK,CACH,oBAAoB,GAAG,8DAA8D;YACnF,oBAAoB,QAAQ,cAAc,MAAM,mCAAmC;YACnF,sFAAsF;YACtF,+EAA+E;YAC/E,2BAA2B,CAC9B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AArBD,wDAqBC;AAED;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IACpC,IAAI,GAAG,sBAA+B,CAAC;IAEhD,YAAY,MAAc;QACxB,KAAK,CAAC,4BAA4B,MAAM,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAPD,oDAOC"}
|
package/dist/core/Agent.js
CHANGED
|
@@ -26,6 +26,8 @@ const skillBrains_js_1 = require("./agent/skillBrains.js");
|
|
|
26
26
|
const conventions_js_1 = require("../conventions.js");
|
|
27
27
|
const pause_js_1 = require("./pause.js");
|
|
28
28
|
const placement_js_1 = require("../artifacts/placement.js");
|
|
29
|
+
const recordingArtifact_js_1 = require("../artifacts/recordingArtifact.js");
|
|
30
|
+
const recordRun_js_1 = require("../recorders/observability/recordRun.js");
|
|
29
31
|
const CredentialConsentRequiredError_js_1 = require("../identity/CredentialConsentRequiredError.js");
|
|
30
32
|
const ContextRecorder_js_1 = require("../recorders/core/ContextRecorder.js");
|
|
31
33
|
const ContextEvaluatedRecorder_js_1 = require("../recorders/core/ContextEvaluatedRecorder.js");
|
|
@@ -237,6 +239,13 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
237
239
|
/** The placement threshold (9.22.0) — the operator's ref-ing dial from the
|
|
238
240
|
* object form of AgentOptions.artifacts. Only ever set beside a store. */
|
|
239
241
|
artifactPlacement;
|
|
242
|
+
/** Recordings-as-artifacts (9.26.0) — the operator's dial from the object
|
|
243
|
+
* form of AgentOptions.artifacts. Only ever set beside a store; absent
|
|
244
|
+
* means no recorder is ever attached and no run is ever recorded. */
|
|
245
|
+
artifactRecordings;
|
|
246
|
+
/** The repeated-call nudge (9.26.0) — `false` only when the operator turned
|
|
247
|
+
* it off. See AgentOptions.repeatedCallNudge. */
|
|
248
|
+
repeatedCallNudge;
|
|
240
249
|
/** What a run does when a declared credential needs 3LO consent (8.6.0).
|
|
241
250
|
* Default `'pause'`. See AgentOptions.onAuthorizationRequired. */
|
|
242
251
|
onAuthorizationRequired;
|
|
@@ -514,6 +523,11 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
514
523
|
this.observerDeliveryOptions = opts.observerDeliveryOptions;
|
|
515
524
|
if (opts.credentials)
|
|
516
525
|
this.credentialProvider = opts.credentials;
|
|
526
|
+
// Kept only when it says something: `undefined` and `true` are the same
|
|
527
|
+
// default, and storing `true` would make the thread-when-off rule below
|
|
528
|
+
// read as a coincidence.
|
|
529
|
+
if (opts.repeatedCallNudge === false)
|
|
530
|
+
this.repeatedCallNudge = false;
|
|
517
531
|
// The claim-check seam (9.21.0). One store per agent, attached at
|
|
518
532
|
// construction — idempotent by shape: there is no second door to attach a
|
|
519
533
|
// competing one through, so "one per agent" is a fact of the type rather
|
|
@@ -537,6 +551,16 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
537
551
|
if (opts.artifacts.placement !== undefined) {
|
|
538
552
|
this.artifactPlacement = opts.artifacts.placement;
|
|
539
553
|
}
|
|
554
|
+
// The recordings dial (9.26.0). `true` and `{ … }` normalize to ONE
|
|
555
|
+
// shape here, so every downstream reader asks a single question
|
|
556
|
+
// ("is there a recordings option?") rather than re-deriving the union.
|
|
557
|
+
if (opts.artifacts.recordings === true) {
|
|
558
|
+
this.artifactRecordings = {};
|
|
559
|
+
}
|
|
560
|
+
else if (typeof opts.artifacts.recordings === 'object' &&
|
|
561
|
+
opts.artifacts.recordings !== null) {
|
|
562
|
+
this.artifactRecordings = opts.artifacts.recordings;
|
|
563
|
+
}
|
|
540
564
|
}
|
|
541
565
|
else {
|
|
542
566
|
this.artifactStore = opts.artifacts;
|
|
@@ -629,6 +653,134 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
629
653
|
getArtifactStore() {
|
|
630
654
|
return this.artifactStore;
|
|
631
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Start recording this run — or do nothing at all (9.26.0).
|
|
658
|
+
*
|
|
659
|
+
* Zero-cost when unused is not a claim here, it is the control flow: with
|
|
660
|
+
* `recordings` unset this returns `undefined` before touching the agent, so
|
|
661
|
+
* no listener is subscribed, no boundary recorder is attached, and the run
|
|
662
|
+
* is byte-identical to every earlier release.
|
|
663
|
+
*
|
|
664
|
+
* It is deliberately the SAME `recordRun` a consumer would call by hand.
|
|
665
|
+
* Nothing about this feature is a second recording implementation — the
|
|
666
|
+
* three connections that a hand-rolled version gets wrong (attach,
|
|
667
|
+
* subscribe, getCommitCount) are wired in exactly one place in this package,
|
|
668
|
+
* and this is a caller of it.
|
|
669
|
+
*/
|
|
670
|
+
startRunRecording() {
|
|
671
|
+
if (this.artifactRecordings === undefined || this.artifactStore === undefined)
|
|
672
|
+
return undefined;
|
|
673
|
+
return (0, recordRun_js_1.recordRun)(this);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* File the finished recording into the artifact store.
|
|
677
|
+
*
|
|
678
|
+
* ── When ────────────────────────────────────────────────────────────────
|
|
679
|
+
* After the answer is composed, and only for a run that COMPLETED. A pause
|
|
680
|
+
* is not a finished run (the turn continues, and the resume mints its own);
|
|
681
|
+
* a throw never reaches here at all.
|
|
682
|
+
*
|
|
683
|
+
* ── Why it is awaited ───────────────────────────────────────────────────
|
|
684
|
+
* The answer is final before this begins and this cannot change it — but
|
|
685
|
+
* `run()` does return after the write rather than before, and that is a
|
|
686
|
+
* choice rather than an oversight. A fire-and-forget write is a recording
|
|
687
|
+
* lost whenever the process exits with the reply, which is precisely the
|
|
688
|
+
* serverless deployment that wants recordings most. The cost is one store
|
|
689
|
+
* write per turn, stated on the option.
|
|
690
|
+
*
|
|
691
|
+
* ── Why it can never fail the run ───────────────────────────────────────
|
|
692
|
+
* A full store, an unserializable snapshot, a bucket that 500s — none of
|
|
693
|
+
* them are facts about the ANSWER, which is already correct and already
|
|
694
|
+
* paid for. Turning "your recording was not filed" into "your request
|
|
695
|
+
* failed" would be the library deciding that its observability matters more
|
|
696
|
+
* than the user's turn. So every failure degrades to today's path: the
|
|
697
|
+
* answer is returned unchanged and the reason lands on the record as
|
|
698
|
+
* `agentfootprint.artifacts.refused`, where a sink can count it.
|
|
699
|
+
*
|
|
700
|
+
* The recording is FROZEN before the mint, so it can never contain the
|
|
701
|
+
* `artifacts.minted` event describing itself.
|
|
702
|
+
*/
|
|
703
|
+
async fileRunRecording(recorder, outcome) {
|
|
704
|
+
const store = this.artifactStore;
|
|
705
|
+
if (recorder === undefined || store === undefined || this.artifactRecordings === undefined) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if ((0, pause_js_1.isPaused)(outcome))
|
|
709
|
+
return;
|
|
710
|
+
const runId = this.currentRunContext?.runId;
|
|
711
|
+
let input;
|
|
712
|
+
try {
|
|
713
|
+
input = (0, recordingArtifact_js_1.recordingPutInput)(recorder.toRecording(), {
|
|
714
|
+
...(runId !== undefined && { runId }),
|
|
715
|
+
...(this.artifactRecordings.label !== undefined && {
|
|
716
|
+
label: this.artifactRecordings.label,
|
|
717
|
+
}),
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
catch (err) {
|
|
721
|
+
this.reportRecordingRefused(err, 'invalid-input');
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
try {
|
|
725
|
+
const result = await store.put(this.runArtifactScope(), input);
|
|
726
|
+
// Sweeps ride the put result, so retention that evicted an older
|
|
727
|
+
// recording to make room says so on the record — the same law a tool's
|
|
728
|
+
// own mint follows.
|
|
729
|
+
for (const swept of result.swept) {
|
|
730
|
+
this.emit('agentfootprint.artifacts.expired', {
|
|
731
|
+
ref: swept.ref,
|
|
732
|
+
reason: swept.reason,
|
|
733
|
+
kind: swept.kind,
|
|
734
|
+
bytes: swept.bytes,
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
this.emit('agentfootprint.artifacts.minted', {
|
|
738
|
+
ref: result.meta.ref,
|
|
739
|
+
kind: result.meta.kind,
|
|
740
|
+
mediaType: result.meta.mediaType,
|
|
741
|
+
bytes: result.meta.bytes,
|
|
742
|
+
...(result.meta.label !== undefined && { label: result.meta.label }),
|
|
743
|
+
...(result.meta.expiresAt !== undefined && { expiresAt: result.meta.expiresAt }),
|
|
744
|
+
...(result.meta.origin !== undefined && { origin: result.meta.origin }),
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
catch (err) {
|
|
748
|
+
this.reportRecordingRefused(err, 'invalid-input');
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
/** One refusal fact for a recording that could not be filed. The message is
|
|
752
|
+
* the store's own, which never carries a payload — only what went wrong. */
|
|
753
|
+
reportRecordingRefused(err, reason) {
|
|
754
|
+
this.emit('agentfootprint.artifacts.refused', {
|
|
755
|
+
op: 'put',
|
|
756
|
+
reason,
|
|
757
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* The run's artifact scope, read from the finished run's own state.
|
|
762
|
+
*
|
|
763
|
+
* The SAME tuple `ctx.artifacts` bound during the run (`scope.runIdentity`,
|
|
764
|
+
* composed by seed from the caller's identity or derived from the session).
|
|
765
|
+
* Read rather than recomposed: a second derivation here could disagree with
|
|
766
|
+
* the one the run's tools used, and a recording filed in a different scope
|
|
767
|
+
* from the artifacts it describes is a recording nobody can find.
|
|
768
|
+
*/
|
|
769
|
+
runArtifactScope() {
|
|
770
|
+
const identity = this.getLastSnapshot()?.sharedState
|
|
771
|
+
?.runIdentity;
|
|
772
|
+
if (identity === undefined) {
|
|
773
|
+
// No state to read means no run happened, which this path cannot reach —
|
|
774
|
+
// but a scope is required and inventing a tenant would be worse than a
|
|
775
|
+
// conversation id that names the run itself.
|
|
776
|
+
return { conversationId: this.currentRunContext?.runId ?? 'unknown' };
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
conversationId: identity.conversationId,
|
|
780
|
+
...(identity.tenant !== undefined && { tenant: identity.tenant }),
|
|
781
|
+
...(identity.principal !== undefined && { principal: identity.principal }),
|
|
782
|
+
};
|
|
783
|
+
}
|
|
632
784
|
/**
|
|
633
785
|
* The footprintjs `RuntimeSnapshot` from the most recent `run()` /
|
|
634
786
|
* `resume()`. Feeds Lens's Trace tab (ExplainableShell `runtimeSnapshot`
|
|
@@ -854,6 +1006,12 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
854
1006
|
// so a continued turn stays in the namespace it started in.
|
|
855
1007
|
this.lastRunIdentity =
|
|
856
1008
|
runInput.identity ?? options?.identity ?? (continued ? continued.identity : undefined);
|
|
1009
|
+
// Recordings-as-artifacts (9.26.0). BEFORE `createExecutor`, because
|
|
1010
|
+
// `attach()` collects recorders for the executor that has not been built
|
|
1011
|
+
// yet — a recording started one line later would be missing its
|
|
1012
|
+
// boundaries, which is the failure mode `recordRun` exists to prevent.
|
|
1013
|
+
// Returns `undefined` (and touches nothing) unless the dial is on.
|
|
1014
|
+
const recording = this.startRunRecording();
|
|
857
1015
|
// (helper used in the catch block below — module-private function
|
|
858
1016
|
// declared at file end via hoisting)
|
|
859
1017
|
const executor = this.createExecutor(options);
|
|
@@ -895,6 +1053,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
895
1053
|
this.lastRunAnswer = finalized;
|
|
896
1054
|
this.recordPendingQuestion(finalized);
|
|
897
1055
|
await this.endRunToolSessions(finalized);
|
|
1056
|
+
// The answer is FINISHED before this line and cannot be changed by it.
|
|
1057
|
+
// See `fileRunRecording` for why the write is awaited rather than left
|
|
1058
|
+
// in flight, and why it can never fail the run.
|
|
1059
|
+
await this.fileRunRecording(recording, finalized);
|
|
898
1060
|
return finalized;
|
|
899
1061
|
}
|
|
900
1062
|
catch (cause) {
|
|
@@ -955,6 +1117,9 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
955
1117
|
throw cause;
|
|
956
1118
|
}
|
|
957
1119
|
finally {
|
|
1120
|
+
// Always released: a recording left subscribed would keep listening
|
|
1121
|
+
// through the next run and grow a tail nobody reads.
|
|
1122
|
+
recording?.stop();
|
|
958
1123
|
stopTracking();
|
|
959
1124
|
this.inFlightRunId = undefined;
|
|
960
1125
|
// `seed` consumes the restored conversation on its way past. A run that
|
|
@@ -1203,6 +1368,11 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
1203
1368
|
// `checkpoint.sharedState` (and nested subflow states) automatically
|
|
1204
1369
|
// on a fresh executor's `resume()`. No need to retain a paused
|
|
1205
1370
|
// executor between run/resume.
|
|
1371
|
+
// Recorded on the same terms a fresh run is (9.26.0) — and the recording
|
|
1372
|
+
// covers the RESUMED run, which is what the recorder saw. A turn that
|
|
1373
|
+
// paused and resumed is two runs, and each mints its own recording when
|
|
1374
|
+
// (and only when) it completes.
|
|
1375
|
+
const recording = this.startRunRecording();
|
|
1206
1376
|
const executor = this.createExecutor(options);
|
|
1207
1377
|
this.inFlightRunId = this.currentRunContext.runId;
|
|
1208
1378
|
this.lastRunAnswer = undefined;
|
|
@@ -1217,6 +1387,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
1217
1387
|
// AGAIN has asked a new one, and that one is outstanding from here.
|
|
1218
1388
|
this.recordPendingQuestion(finalized);
|
|
1219
1389
|
await this.endRunToolSessions(finalized);
|
|
1390
|
+
await this.fileRunRecording(recording, finalized);
|
|
1220
1391
|
return finalized;
|
|
1221
1392
|
}
|
|
1222
1393
|
catch (cause) {
|
|
@@ -1224,6 +1395,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
1224
1395
|
throw cause;
|
|
1225
1396
|
}
|
|
1226
1397
|
finally {
|
|
1398
|
+
recording?.stop();
|
|
1227
1399
|
this.inFlightRunId = undefined;
|
|
1228
1400
|
}
|
|
1229
1401
|
}
|
|
@@ -2516,6 +2688,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
2516
2688
|
...(this.maxToolResultChars !== undefined && {
|
|
2517
2689
|
maxToolResultChars: this.maxToolResultChars,
|
|
2518
2690
|
}),
|
|
2691
|
+
// The repeated-call nudge (9.26.0). Threaded ONLY when switched off —
|
|
2692
|
+
// the VALUE-conditional pattern, so an agent on the default hands the
|
|
2693
|
+
// handler exactly the deps object it always did.
|
|
2694
|
+
...(this.repeatedCallNudge === false && { repeatedCallNudge: false }),
|
|
2519
2695
|
// Skill-graph read_skill gate: bound the model's read_skill jumps to the
|
|
2520
2696
|
// reachable set from the current cursor. Undefined → gate off (back-compat).
|
|
2521
2697
|
...(this.skillGraphReachable && {
|