stitchkit 0.127.0 → 0.128.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 +137 -6
- package/dist/agent-executor/acp/v1-connect.d.ts +9 -1
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +8 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +8 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +20 -2
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -1
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude/transcript.d.ts +7 -4
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +4 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +4 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +26 -2
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts +3 -1
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +71 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +0 -3
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-runtime/agent-tool.d.ts +21 -7
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +1 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +5 -2
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +9 -9
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +45 -32
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +12 -6
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-source.d.ts +13 -1
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +64 -0
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-tools.d.ts +82 -5
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +12 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts +6 -3
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +50 -8
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocations.d.ts +20 -9
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/postgres.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +30 -0
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-invocation-payload.d.ts +48 -0
- package/dist/agent-runtime/schemas-invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -1
- package/dist/agent-runtime/sql-session.d.ts +11 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +55 -0
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +12 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +7 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/declaration/declaration.d.ts +6 -3
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +23 -12
- package/dist/entrypoints/agent-executor/claude-sdk.js +26 -10
- package/dist/entrypoints/agent-executor/claude.js +35 -16
- package/dist/entrypoints/agent-executor/codex.js +81 -21
- package/dist/entrypoints/agent-executor.js +1 -1
- package/dist/entrypoints/agent-runtime/harness.js +5 -6
- package/dist/entrypoints/agent-runtime/openrouter.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +8 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
- package/dist/entrypoints/agent-runtime/testing.js +6 -6
- package/dist/entrypoints/agent-runtime.d.ts +9 -7
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +246 -199
- package/dist/entrypoints/application/diagnostic-journal.js +4 -4
- package/dist/entrypoints/application/directory-inbox.js +8 -8
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +10 -9
- package/dist/entrypoints/declaration.js +0 -1
- package/dist/entrypoints/files.js +40 -17
- package/dist/entrypoints/node.js +4 -4
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/server.js +7 -7
- package/dist/entrypoints/service-host/macos.js +4 -4
- package/dist/entrypoints/service-host.d.ts +4 -1
- package/dist/entrypoints/service-host.d.ts.map +1 -1
- package/dist/entrypoints/service-host.js +831 -220
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/telegram.js +4 -4
- package/dist/entrypoints/tools/agent.js +4 -3
- package/dist/entrypoints/tools/invoker.js +3 -2
- package/dist/entrypoints/tools/mcp.js +4 -3
- package/dist/entrypoints/tools/toolkit.js +6 -5
- package/dist/entrypoints/tools.d.ts +1 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +10 -8
- package/dist/files/directory-appearance.d.ts +20 -9
- package/dist/files/directory-appearance.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts.map +1 -1
- package/dist/files/regular-file.d.ts +15 -5
- package/dist/files/regular-file.d.ts.map +1 -1
- package/dist/{index-z4k0hqp9.js → index-0gqs8ght.js} +106 -24
- package/dist/{index-caywx1c0.js → index-13dnv6d0.js} +107 -10
- package/dist/{index-a725ayvz.js → index-1qwrczr1.js} +1 -1
- package/dist/{index-xtkw9866.js → index-2c5w2d1d.js} +1 -1
- package/dist/{index-g1q7fwn9.js → index-2nwvn7m2.js} +1 -1
- package/dist/{index-4s2w4g37.js → index-3tnwtz38.js} +80 -2
- package/dist/{index-5e0zsbf7.js → index-4j8efqr3.js} +1 -1
- package/dist/{index-p1m9djt6.js → index-5v5vg85s.js} +1 -1
- package/dist/{index-x90w78yz.js → index-673drwkn.js} +23 -8
- package/dist/{index-7xp05h20.js → index-6wp4dn9d.js} +6 -6
- package/dist/{index-0hdm5sx6.js → index-8x22nprv.js} +6 -2
- package/dist/{index-j13gzgdv.js → index-bz3gn6cs.js} +8 -4
- package/dist/{index-d96c1n1q.js → index-c5gp2gh6.js} +20 -19
- package/dist/{index-wbnpa8z6.js → index-d54npte7.js} +4 -4
- package/dist/{index-kmbpej2y.js → index-emgrmavr.js} +102 -61
- package/dist/{index-bbzvrq66.js → index-g3e57qj6.js} +455 -202
- package/dist/index-gf92hc87.js +100 -0
- package/dist/{index-3djgv3ch.js → index-gzny6zsw.js} +25 -10
- package/dist/{index-3b31z0pc.js → index-hj1zq7mh.js} +12 -6
- package/dist/{index-8xr2eq99.js → index-jfecdk1e.js} +3 -3
- package/dist/{index-dvd1qdwa.js → index-ke02kxsr.js} +3 -3
- package/dist/{index-83n766x4.js → index-m18xm96h.js} +15 -9
- package/dist/{index-qnzhmk2s.js → index-n7f89hjw.js} +90 -47
- package/dist/{index-3agqmmrg.js → index-pn5b11ce.js} +7 -9
- package/dist/{index-3gwp8ez6.js → index-pwskmywy.js} +12 -17
- package/dist/{index-9wh98cpa.js → index-rxnyygke.js} +130 -90
- package/dist/{index-0djnptn8.js → index-rzeezh79.js} +10 -3
- package/dist/{index-nbv44x0x.js → index-s2e3h616.js} +137 -36
- package/dist/{index-5zwac8ft.js → index-t7wa7k12.js} +2 -2
- package/dist/{index-xypxnzhp.js → index-v1mxss62.js} +2 -2
- package/dist/index-vgzhw2zk.js +304 -0
- package/dist/{index-jrka9029.js → index-vmbxj75t.js} +2 -2
- package/dist/{index-j516jaaz.js → index-waa6t4zx.js} +49 -2
- package/dist/{index-fcw255hd.js → index-xv9jb84s.js} +2 -2
- package/dist/{index-dwa6pskj.js → index-y065r8g5.js} +82 -43
- package/dist/internal/bounded-file-confirm.d.ts +32 -0
- package/dist/internal/bounded-file-confirm.d.ts.map +1 -0
- package/dist/internal/bounded-file-read.d.ts +10 -7
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +5 -1
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +8 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/unix-socket.d.ts +3 -1
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +7 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/systemd-inspect.d.ts +3 -1
- package/dist/service-host/systemd-inspect.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts +64 -0
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +31 -26
- package/dist/service-host/systemd-render.d.ts.map +1 -1
- package/dist/service-host/systemd-timer-render.d.ts +31 -0
- package/dist/service-host/systemd-timer-render.d.ts.map +1 -0
- package/dist/service-host/systemd-timer-rollback.d.ts +26 -0
- package/dist/service-host/systemd-timer-rollback.d.ts.map +1 -0
- package/dist/service-host/systemd-timer.d.ts +82 -0
- package/dist/service-host/systemd-timer.d.ts.map +1 -0
- package/dist/service-host/systemd-unit-ops.d.ts +26 -0
- package/dist/service-host/systemd-unit-ops.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +1 -1
- package/dist/service-host/systemd.d.ts.map +1 -1
- package/dist/tools/access.d.ts +30 -1
- package/dist/tools/access.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +2 -2
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +5 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +11 -5
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +2 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -3
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +5 -5
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +10 -6
- package/llms/agent-executor-claude-sdk.txt +1 -1
- package/llms/agent-executor-claude.txt +1 -1
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-runtime.4.txt +21 -9
- package/llms/cli.3.txt +4 -4
- package/llms/cli.txt +1 -0
- package/llms/declaration.txt +2 -2
- package/llms/files.txt +1 -1
- package/llms/node.txt +2 -2
- package/llms/server.5.txt +2 -2
- package/llms/service-host.txt +5 -5
- package/llms/stitchkit.txt +81 -77
- package/llms/tools.3.txt +3 -2
- package/llms/upgrading-0.128.0.txt +147 -0
- package/llms/upgrading.txt +1 -0
- package/llms-full.txt +272 -113
- package/llms.txt +14 -13
- package/package.json +1 -1
- package/dist/index-ajmtxsky.js +0 -193
- package/dist/index-ax3wns1a.js +0 -93
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
AgentProviderResponseSchema2
|
|
12
12
|
} from "./index-97rp94ff.js";
|
|
13
13
|
import {
|
|
14
|
-
ModelInvocationTraceSchema2,
|
|
15
14
|
InvocationPayloadSchema,
|
|
15
|
+
ModelInvocationTraceSchema2,
|
|
16
16
|
assistantStatus
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-vgzhw2zk.js";
|
|
18
18
|
import {
|
|
19
19
|
agentDurableEventId2
|
|
20
20
|
} from "./index-paff5y0r.js";
|
|
@@ -688,6 +688,19 @@ function invocationJson(value) {
|
|
|
688
688
|
function invocationHash(value) {
|
|
689
689
|
return createHash("sha256").update(serializeCanonicalJson(invocationJson(value))).digest("hex");
|
|
690
690
|
}
|
|
691
|
+
|
|
692
|
+
class InvocationPayloadTooLargeError2 extends RangeError {
|
|
693
|
+
bytes;
|
|
694
|
+
maxBytes;
|
|
695
|
+
sha256;
|
|
696
|
+
constructor(bytes, maxBytes, sha256) {
|
|
697
|
+
super(`Invocation payload (${bytes} bytes) exceeds maxPayloadBytes (${maxBytes})`);
|
|
698
|
+
this.name = "InvocationPayloadTooLargeError";
|
|
699
|
+
this.bytes = bytes;
|
|
700
|
+
this.maxBytes = maxBytes;
|
|
701
|
+
this.sha256 = sha256;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
691
704
|
function createInvocationPayloads(store, key, maxBytes) {
|
|
692
705
|
if (key.byteLength !== 32)
|
|
693
706
|
throw new TypeError("Invocation payload key must contain 32 bytes");
|
|
@@ -696,10 +709,11 @@ function createInvocationPayloads(store, key, maxBytes) {
|
|
|
696
709
|
maxBytes,
|
|
697
710
|
async write(identity, value) {
|
|
698
711
|
const data = Buffer.from(serializeCanonicalJson(invocationJson(value)));
|
|
699
|
-
if (data.byteLength > maxBytes)
|
|
700
|
-
throw new RangeError("Invocation payload exceeds maxPayloadBytes");
|
|
701
|
-
const artifactId = randomUUID();
|
|
702
712
|
const sha256 = createHash("sha256").update(data).digest("hex");
|
|
713
|
+
if (data.byteLength > maxBytes) {
|
|
714
|
+
throw new InvocationPayloadTooLargeError2(data.byteLength, maxBytes, sha256);
|
|
715
|
+
}
|
|
716
|
+
const artifactId = randomUUID();
|
|
703
717
|
const iv = randomBytes(12);
|
|
704
718
|
const cipher = createCipheriv("aes-256-gcm", encryptionKey, iv);
|
|
705
719
|
cipher.setAAD(Buffer.from(JSON.stringify([identity.conversationId, identity.invocationId, artifactId])));
|
|
@@ -794,7 +808,16 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
794
808
|
const begin = async (params) => invocationAudit(async () => {
|
|
795
809
|
const context = { ...writer.identity, step, attemptId: randomUUID2() };
|
|
796
810
|
const { headers: _headers, abortSignal: _signal, ...payload } = params;
|
|
797
|
-
|
|
811
|
+
let artifact;
|
|
812
|
+
let omittedSha256;
|
|
813
|
+
try {
|
|
814
|
+
artifact = await writer.payloads.write(writer.identity, payload);
|
|
815
|
+
} catch (error) {
|
|
816
|
+
if (!(error instanceof InvocationPayloadTooLargeError2))
|
|
817
|
+
throw error;
|
|
818
|
+
writer.receiptErrors.push(error);
|
|
819
|
+
omittedSha256 = error.sha256;
|
|
820
|
+
}
|
|
798
821
|
await writer.append({
|
|
799
822
|
...writer.identity,
|
|
800
823
|
type: "provider/request",
|
|
@@ -808,8 +831,8 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
808
831
|
sent: {
|
|
809
832
|
modelId: model.modelId,
|
|
810
833
|
provider: model.provider,
|
|
811
|
-
payloadSha256: artifact.sha256,
|
|
812
|
-
artifactId: artifact.artifactId,
|
|
834
|
+
payloadSha256: artifact ? artifact.sha256 : omittedSha256 ?? "",
|
|
835
|
+
...artifact ? { artifactId: artifact.artifactId } : { payloadOmitted: "max-payload-bytes" },
|
|
813
836
|
tools: params.tools?.length ?? 0
|
|
814
837
|
}
|
|
815
838
|
});
|
|
@@ -825,7 +848,16 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
825
848
|
writer.receiptErrors.push(error);
|
|
826
849
|
});
|
|
827
850
|
const recordResponse = async (context, status, payload, usage, response, providerMetadata) => invocationAudit(async () => {
|
|
828
|
-
|
|
851
|
+
let artifact;
|
|
852
|
+
let omittedSha256;
|
|
853
|
+
try {
|
|
854
|
+
artifact = await writer.payloads.write(writer.identity, boundedEvidence(payload, Math.floor(writer.payloads.maxBytes / 2)));
|
|
855
|
+
} catch (error) {
|
|
856
|
+
if (!(error instanceof InvocationPayloadTooLargeError2))
|
|
857
|
+
throw error;
|
|
858
|
+
writer.receiptErrors.push(error);
|
|
859
|
+
omittedSha256 = error.sha256;
|
|
860
|
+
}
|
|
829
861
|
await writer.append({
|
|
830
862
|
...writer.identity,
|
|
831
863
|
type: "provider/response",
|
|
@@ -838,8 +870,8 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
838
870
|
responseId: response?.id ?? null
|
|
839
871
|
},
|
|
840
872
|
usage: reportedUsage(selected, usage, providerMetadata),
|
|
841
|
-
artifactId: artifact.artifactId,
|
|
842
|
-
payloadSha256: artifact.sha256
|
|
873
|
+
...artifact ? { artifactId: artifact.artifactId } : { payloadOmitted: "max-payload-bytes" },
|
|
874
|
+
payloadSha256: artifact ? artifact.sha256 : omittedSha256 ?? ""
|
|
843
875
|
});
|
|
844
876
|
});
|
|
845
877
|
return wrapLanguageModel({
|
|
@@ -879,59 +911,68 @@ function wrapInvocationModel(writer, selected, step, model = selected.model) {
|
|
|
879
911
|
});
|
|
880
912
|
throw markProviderOrigin(error);
|
|
881
913
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
if (ended)
|
|
889
|
-
return;
|
|
890
|
-
ended = true;
|
|
891
|
-
await finish(context, status, evidence.payload(value), usage, response, metadata);
|
|
892
|
-
};
|
|
893
|
-
return {
|
|
894
|
-
...result,
|
|
895
|
-
stream: new ReadableStream({
|
|
896
|
-
async pull(controller) {
|
|
897
|
-
let next;
|
|
898
|
-
try {
|
|
899
|
-
next = await currentAttempt.run(context, () => reader.read());
|
|
900
|
-
} catch (error) {
|
|
901
|
-
await end(params.abortSignal?.aborted ? "cancelled" : "failed", { error });
|
|
902
|
-
controller.error(markProviderOrigin(error));
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
if (next.done) {
|
|
906
|
-
await end("failed", { reason: "stream-ended-without-finish" });
|
|
907
|
-
controller.close();
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
const part = next.value;
|
|
911
|
-
if (part.type === "response-metadata")
|
|
912
|
-
response = part;
|
|
913
|
-
if (part.type === "finish") {
|
|
914
|
-
await end(failed || part.finishReason.unified === "error" ? "failed" : "succeeded", part, part.usage, part.providerMetadata);
|
|
915
|
-
} else {
|
|
916
|
-
if (part.type === "error")
|
|
917
|
-
failed = true;
|
|
918
|
-
evidence.record(part);
|
|
919
|
-
}
|
|
920
|
-
controller.enqueue(part);
|
|
921
|
-
},
|
|
922
|
-
async cancel(reason) {
|
|
923
|
-
try {
|
|
924
|
-
await currentAttempt.run(context, () => reader.cancel(reason));
|
|
925
|
-
} finally {
|
|
926
|
-
await end("cancelled", { reason: "consumer-cancelled" });
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
})
|
|
930
|
-
};
|
|
914
|
+
return wrapInvocationStreamResult(result, {
|
|
915
|
+
context,
|
|
916
|
+
abortSignal: params.abortSignal,
|
|
917
|
+
maxEvidenceBytes: Math.floor(writer.payloads.maxBytes / 2),
|
|
918
|
+
finish
|
|
919
|
+
});
|
|
931
920
|
}
|
|
932
921
|
}
|
|
933
922
|
});
|
|
934
923
|
}
|
|
924
|
+
function wrapInvocationStreamResult(result, options) {
|
|
925
|
+
const { context, abortSignal, maxEvidenceBytes, finish } = options;
|
|
926
|
+
const reader = result.stream.getReader();
|
|
927
|
+
let ended = false;
|
|
928
|
+
let failed = false;
|
|
929
|
+
let response;
|
|
930
|
+
const evidence = streamEvidence(maxEvidenceBytes);
|
|
931
|
+
const end = async (status, value, usage, metadata) => {
|
|
932
|
+
if (ended)
|
|
933
|
+
return;
|
|
934
|
+
ended = true;
|
|
935
|
+
await finish(context, status, evidence.payload(value), usage, response, metadata);
|
|
936
|
+
};
|
|
937
|
+
return {
|
|
938
|
+
...result,
|
|
939
|
+
stream: new ReadableStream({
|
|
940
|
+
async pull(controller) {
|
|
941
|
+
let next;
|
|
942
|
+
try {
|
|
943
|
+
next = await currentAttempt.run(context, () => reader.read());
|
|
944
|
+
} catch (error) {
|
|
945
|
+
await end(abortSignal?.aborted ? "cancelled" : "failed", { error });
|
|
946
|
+
controller.error(markProviderOrigin(error));
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (next.done) {
|
|
950
|
+
await end("failed", { reason: "stream-ended-without-finish" });
|
|
951
|
+
controller.close();
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
const part = next.value;
|
|
955
|
+
if (part.type === "response-metadata")
|
|
956
|
+
response = part;
|
|
957
|
+
if (part.type === "finish") {
|
|
958
|
+
await end(failed || part.finishReason.unified === "error" ? "failed" : "succeeded", part, part.usage, part.providerMetadata);
|
|
959
|
+
} else {
|
|
960
|
+
if (part.type === "error")
|
|
961
|
+
failed = true;
|
|
962
|
+
evidence.record(part);
|
|
963
|
+
}
|
|
964
|
+
controller.enqueue(part);
|
|
965
|
+
},
|
|
966
|
+
async cancel(reason) {
|
|
967
|
+
try {
|
|
968
|
+
await currentAttempt.run(context, () => reader.cancel(reason));
|
|
969
|
+
} finally {
|
|
970
|
+
await end("cancelled", { reason: "consumer-cancelled" });
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
})
|
|
974
|
+
};
|
|
975
|
+
}
|
|
935
976
|
function boundedEvidence(payload, limit) {
|
|
936
977
|
const serialized = JSON.stringify(invocationJson(payload));
|
|
937
978
|
const bytes = Buffer.byteLength(serialized);
|
|
@@ -1149,4 +1190,4 @@ function validateAgentModelSnapshot2(input, policy) {
|
|
|
1149
1190
|
return snapshot;
|
|
1150
1191
|
}
|
|
1151
1192
|
|
|
1152
|
-
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun, jsonValue, providerEnvelope, providerResponseIdentity, appendText, abortTerminalReason, addUsage, mergeModelTotals, statedUsage, unknownUsage, normalizeSdkUsage, createIdleDeadline, adoptSnapshot, transientSequence, runUsage, updateReasoning, checkpoint, DEFAULT_STEP_SPEND_TIMEOUT_MS, AgentStepSpendPhaseSchema2, AgentStepSpendProviderSchema, AgentStepSpendSchema2, normalizeStepUsage, recordStepSpend, InvocationReceiptError, invocationHash, createInvocationPayloads, isOwnInputRefusal, markProviderOrigin, hasProviderOrigin, markProviderStream, currentModelInvocationAttempt2, wrapInvocationModel, AgentModelCapabilitySchema2, AgentModelDescriptorSchema2, AgentModelRegistrySnapshotSchema2, AgentModelPriceSchema2, AgentModelMetricSchema2, AgentModelPopularitySchema2, AgentModelCatalogEntrySchema2, AgentModelCatalogSchema2, AgentModelSelectionSchema2, AgentModelSearchInputSchema2, AgentModelSearchResultSchema2, searchAgentModelCatalog2, createMemoryAgentModelSelectionStore2, defineModelRegistry2, validateAgentModelSnapshot2 };
|
|
1193
|
+
export { withStoreRetries, AgentRuntimeConflictError2, AgentRunUnsettledError2, appliedSnapshot, terminalOfSnapshot, terminalOfRunView, commitAgentRunTerminal, findRun, jsonValue, providerEnvelope, providerResponseIdentity, appendText, abortTerminalReason, addUsage, mergeModelTotals, statedUsage, unknownUsage, normalizeSdkUsage, createIdleDeadline, adoptSnapshot, transientSequence, runUsage, updateReasoning, checkpoint, DEFAULT_STEP_SPEND_TIMEOUT_MS, AgentStepSpendPhaseSchema2, AgentStepSpendProviderSchema, AgentStepSpendSchema2, normalizeStepUsage, recordStepSpend, InvocationReceiptError, invocationHash, InvocationPayloadTooLargeError2, createInvocationPayloads, isOwnInputRefusal, markProviderOrigin, hasProviderOrigin, markProviderStream, currentModelInvocationAttempt2, wrapInvocationModel, AgentModelCapabilitySchema2, AgentModelDescriptorSchema2, AgentModelRegistrySnapshotSchema2, AgentModelPriceSchema2, AgentModelMetricSchema2, AgentModelPopularitySchema2, AgentModelCatalogEntrySchema2, AgentModelCatalogSchema2, AgentModelSelectionSchema2, AgentModelSearchInputSchema2, AgentModelSearchResultSchema2, searchAgentModelCatalog2, createMemoryAgentModelSelectionStore2, defineModelRegistry2, validateAgentModelSnapshot2 };
|