@tangle-network/agent-provider-tangle 4.3.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/tangle-create-options.d.ts +15 -1
- package/dist/tangle-create-options.js +50 -14
- package/dist/tangle-evidence.d.ts +2 -0
- package/dist/tangle-evidence.js +70 -5
- package/dist/tangle-prompt.d.ts +2 -2
- package/dist/tangle-prompt.js +4 -0
- package/dist/tangle-provider.js +7 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @tangle-network/agent-provider-tangle
|
|
2
2
|
|
|
3
3
|
Wraps `@tangle-network/sandbox` as an `AgentEnvironmentProvider`.
|
|
4
|
-
The Sandbox peer range is `>=0.60.
|
|
4
|
+
The Sandbox peer range is `>=0.60.88 <1.0.0`; the minimum version declares create-time `backend.routing`.
|
|
5
5
|
|
|
6
6
|
Terminal `result` and `done` events use the Sandbox SDK's `projectAgentTerminalRecord` summary. Cumulative tool history stays in native evidence; bounded approval identity survives projection, and malformed or conflicting approval sources fail closed. Terminal events omit the duplicate raw `providerEvent` payload.
|
|
7
7
|
|
|
@@ -232,6 +232,31 @@ The account owner retains authority over registration, namespace verification, h
|
|
|
232
232
|
Updating a stored secret does not refresh credentials already injected into a live Sandbox.
|
|
233
233
|
Creation-time validity and the selected host's native credential lifecycle still bound long-running work.
|
|
234
234
|
|
|
235
|
+
## Router routing at creation
|
|
236
|
+
|
|
237
|
+
`CreateAgentEnvironmentInput.providerOptions.routing` sets the Tangle Router provider routing for every model call the environment makes.
|
|
238
|
+
It reaches the Sandbox create call as `backend.routing`.
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
const environment = await provider.create({
|
|
242
|
+
profile,
|
|
243
|
+
providerOptions: {
|
|
244
|
+
routing: { only: ["zai"], allowFallbacks: false, requireModel: true },
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`only` lists the Router provider ids the calls may use.
|
|
250
|
+
`allowFallbacks: false` stops the Router from falling back to another provider.
|
|
251
|
+
`requireModel: true` fails the call rather than substituting another model.
|
|
252
|
+
Routing is set at creation: the Sandbox SDK refuses `backend.routing` on a turn.
|
|
253
|
+
A workspace fork sends no backend, so a forked environment's routing is whatever the platform copies from its parent.
|
|
254
|
+
The Sandbox platform accepts it only for Router-backed OpenCode.
|
|
255
|
+
|
|
256
|
+
`routing` is the only create `providerOptions` field; any other field is refused.
|
|
257
|
+
Unknown routing fields are refused too; the accepted set is pinned to the SDK's `RouterRoutingOptions` at compile time.
|
|
258
|
+
A custom `mapCreateInput` must carry exactly the requested routing, on `backend.routing` or `backend.model.routing`, and none when none was requested; otherwise creation is refused before any request.
|
|
259
|
+
|
|
235
260
|
## `create()` returns a ready environment
|
|
236
261
|
|
|
237
262
|
`provider.create()` does not return until the sandbox reports `running`.
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { type BackendType, type CreateSandboxOptions } from "@tangle-network/sandbox";
|
|
1
|
+
import { type BackendType, type CreateSandboxOptions, type RouterRoutingOptions } from "@tangle-network/sandbox";
|
|
2
2
|
import type { CreateAgentEnvironmentInput, WorkspaceRequest } from "@tangle-network/agent-interface/environment-provider";
|
|
3
3
|
import type { TangleCreateSandboxOptions, TangleModelCredentials } from "./tangle-types.js";
|
|
4
4
|
/** Immutable create evidence used to bind a later native resume to its restored snapshot. */
|
|
5
5
|
export declare const NATIVE_RESUME_CHECKPOINT_METADATA_KEY = "tangleNativeResumeCheckpointId";
|
|
6
6
|
export declare function captureModelCredentials(value: TangleModelCredentials | undefined): TangleModelCredentials | undefined;
|
|
7
|
+
declare const ROUTING_FIELD_LIST: readonly ["only", "allowFallbacks", "requireModel"];
|
|
8
|
+
type Exhaustive<T extends never> = T;
|
|
9
|
+
type UncoveredRoutingField = Exhaustive<Exclude<keyof RouterRoutingOptions, (typeof ROUTING_FIELD_LIST)[number]>>;
|
|
10
|
+
type StaleRoutingField = Exhaustive<Exclude<(typeof ROUTING_FIELD_LIST)[number], keyof RouterRoutingOptions>>;
|
|
11
|
+
export type RoutingFieldCoverage = [UncoveredRoutingField, StaleRoutingField];
|
|
12
|
+
/**
|
|
13
|
+
* Read create `providerOptions`, whose only field is `routing`: the Tangle
|
|
14
|
+
* Router provider routing every model call in the environment uses.
|
|
15
|
+
*
|
|
16
|
+
* Routing is fixed when the sandbox is created; the Sandbox SDK refuses it on
|
|
17
|
+
* a turn. Any other field is refused rather than dropped.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createRoutingFromProviderOptions(providerOptions: Record<string, unknown> | undefined): RouterRoutingOptions | undefined;
|
|
7
20
|
export declare function sandboxOptionsFromCreateInput(input: CreateAgentEnvironmentInput, defaultBackend?: BackendType, parsedWorkspace?: WorkspaceRequest, modelCredentials?: TangleModelCredentials, subscriptionSelection?: boolean): TangleCreateSandboxOptions;
|
|
8
21
|
/**
|
|
9
22
|
* Project a portable workspace checkpoint onto the Sandbox restore fields.
|
|
@@ -21,3 +34,4 @@ export declare function assertNoInlineSecretValues(input: CreateAgentEnvironment
|
|
|
21
34
|
export declare function assertMappedSecretNames(options: CreateSandboxOptions): void;
|
|
22
35
|
export declare function assertCreateInputShape(input: CreateAgentEnvironmentInput, parsedWorkspace?: WorkspaceRequest): WorkspaceRequest | undefined;
|
|
23
36
|
export declare function assertMappedCreateOptions(options: TangleCreateSandboxOptions): void;
|
|
37
|
+
export {};
|
|
@@ -45,6 +45,53 @@ export function captureModelCredentials(value) {
|
|
|
45
45
|
}
|
|
46
46
|
return Object.freeze({ apiKeyEnv, baseUrl });
|
|
47
47
|
}
|
|
48
|
+
const ROUTING_FIELD_LIST = ["only", "allowFallbacks", "requireModel"];
|
|
49
|
+
/**
|
|
50
|
+
* Read create `providerOptions`, whose only field is `routing`: the Tangle
|
|
51
|
+
* Router provider routing every model call in the environment uses.
|
|
52
|
+
*
|
|
53
|
+
* Routing is fixed when the sandbox is created; the Sandbox SDK refuses it on
|
|
54
|
+
* a turn. Any other field is refused rather than dropped.
|
|
55
|
+
*/
|
|
56
|
+
export function createRoutingFromProviderOptions(providerOptions) {
|
|
57
|
+
if (providerOptions === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (!providerOptions || typeof providerOptions !== "object" || Array.isArray(providerOptions)) {
|
|
60
|
+
throw new Error("Tangle create providerOptions must be a JSON object");
|
|
61
|
+
}
|
|
62
|
+
assertBoundedJson(providerOptions, "Tangle create providerOptions");
|
|
63
|
+
if (Object.keys(providerOptions).some((key) => key !== "routing")) {
|
|
64
|
+
throw new Error("Tangle create providerOptions accept only routing");
|
|
65
|
+
}
|
|
66
|
+
const routing = providerOptions.routing;
|
|
67
|
+
if (routing === undefined)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (!routing || typeof routing !== "object" || Array.isArray(routing)) {
|
|
70
|
+
throw new Error("Tangle create providerOptions.routing must be an object");
|
|
71
|
+
}
|
|
72
|
+
const fields = routing;
|
|
73
|
+
if (Object.keys(fields).some((key) => !ROUTING_FIELD_LIST.includes(key))) {
|
|
74
|
+
throw new Error(`Tangle create providerOptions.routing accepts only ${ROUTING_FIELD_LIST.join(", ")}`);
|
|
75
|
+
}
|
|
76
|
+
const { only, allowFallbacks, requireModel } = fields;
|
|
77
|
+
if (only !== undefined) {
|
|
78
|
+
if (!Array.isArray(only) || only.length === 0 || only.length > MAX_ARRAY_LENGTH) {
|
|
79
|
+
throw new Error("Tangle create providerOptions.routing.only must be a non-empty list of Router provider ids");
|
|
80
|
+
}
|
|
81
|
+
for (const provider of only)
|
|
82
|
+
boundedIdentifier(provider, "Tangle routing provider id");
|
|
83
|
+
}
|
|
84
|
+
for (const [name, value] of [["allowFallbacks", allowFallbacks], ["requireModel", requireModel]]) {
|
|
85
|
+
if (value !== undefined && typeof value !== "boolean") {
|
|
86
|
+
throw new Error(`Tangle create providerOptions.routing.${name} must be a boolean`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
...(only === undefined ? {} : { only: [...only] }),
|
|
91
|
+
...(allowFallbacks === undefined ? {} : { allowFallbacks: allowFallbacks }),
|
|
92
|
+
...(requireModel === undefined ? {} : { requireModel: requireModel }),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
48
95
|
export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorkspace, modelCredentials, subscriptionSelection = false) {
|
|
49
96
|
const workspace = assertCreateInputShape(input, parsedWorkspace) ?? {};
|
|
50
97
|
const profile = inlineAgentProfile(input.profile);
|
|
@@ -95,11 +142,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
95
142
|
[NATIVE_RESUME_CHECKPOINT_METADATA_KEY]: boundedIdentifier(workspace.checkpoint.checkpointId, "Tangle native resume checkpoint id"),
|
|
96
143
|
}),
|
|
97
144
|
};
|
|
98
|
-
|
|
99
|
-
throw new Error("Tangle create providerOptions are not supported");
|
|
100
|
-
}
|
|
101
|
-
if (input.providerOptions)
|
|
102
|
-
assertBoundedRecord(input.providerOptions, "Tangle create providerOptions");
|
|
145
|
+
const routing = createRoutingFromProviderOptions(input.providerOptions);
|
|
103
146
|
if (input.metadata)
|
|
104
147
|
assertBoundedRecord(input.metadata, "Tangle metadata");
|
|
105
148
|
if (input.name !== undefined) {
|
|
@@ -166,6 +209,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
166
209
|
...(input.runtimeAttachments === undefined ? {} : {
|
|
167
210
|
runtimeAttachments: tangleRuntimeAttachments(input.runtimeAttachments, profile),
|
|
168
211
|
}),
|
|
212
|
+
...(routing === undefined ? {} : { routing }),
|
|
169
213
|
},
|
|
170
214
|
};
|
|
171
215
|
return mapped;
|
|
@@ -207,15 +251,7 @@ function sandboxEgressPolicy(policy) {
|
|
|
207
251
|
}
|
|
208
252
|
/** Reject value-bearing secret maps before any custom mapper can drop them. */
|
|
209
253
|
export function assertNoInlineSecretValues(input, parsedWorkspace) {
|
|
210
|
-
|
|
211
|
-
if (!input.providerOptions || typeof input.providerOptions !== "object" || Array.isArray(input.providerOptions)) {
|
|
212
|
-
throw new Error("Tangle create providerOptions must be a JSON object");
|
|
213
|
-
}
|
|
214
|
-
assertBoundedJson(input.providerOptions, "Tangle create providerOptions");
|
|
215
|
-
if (Object.keys(input.providerOptions).length > 0) {
|
|
216
|
-
throw new Error("Tangle create providerOptions are not supported");
|
|
217
|
-
}
|
|
218
|
-
}
|
|
254
|
+
createRoutingFromProviderOptions(input.providerOptions);
|
|
219
255
|
if (input.workspace?.providerOptions !== undefined) {
|
|
220
256
|
const workspace = parsedWorkspace ?? WorkspaceRequestSchema.parse(input.workspace);
|
|
221
257
|
if (workspace.providerOptions && Object.keys(workspace.providerOptions).length > 0) {
|
|
@@ -127,6 +127,8 @@ export interface TangleEnvironmentEvidence {
|
|
|
127
127
|
sizeBytes: number;
|
|
128
128
|
sha256: string | null;
|
|
129
129
|
linkTarget: string | null;
|
|
130
|
+
/** Metadata only: the bytes are a harness's own install, not session state. */
|
|
131
|
+
contentOmitted?: "harness-install";
|
|
130
132
|
}>;
|
|
131
133
|
excludedPaths: Array<{
|
|
132
134
|
sourceId?: string;
|
package/dist/tangle-evidence.js
CHANGED
|
@@ -352,6 +352,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
352
352
|
}
|
|
353
353
|
const counts = { events: 0, messages: 0 };
|
|
354
354
|
const eventCountsByExecutionId = {};
|
|
355
|
+
const transportPartText = new Map();
|
|
355
356
|
const events = new EvidenceJsonArray(undefined, async function* () {
|
|
356
357
|
for (const executionId of executionIds) {
|
|
357
358
|
eventCountsByExecutionId[executionId] = 0;
|
|
@@ -367,7 +368,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
367
368
|
}
|
|
368
369
|
counts.events++;
|
|
369
370
|
eventCountsByExecutionId[executionId] += 1;
|
|
370
|
-
yield { executionId, event };
|
|
371
|
+
yield { executionId, event: { ...event, data: withoutRepeatedPartText(event.data, transportPartText) } };
|
|
371
372
|
}
|
|
372
373
|
}
|
|
373
374
|
});
|
|
@@ -389,7 +390,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
389
390
|
}
|
|
390
391
|
});
|
|
391
392
|
await writer.writeChunks(`__retention__/sessions/${id}.json`, 0o600, evidenceJsonChunks({ kind: "tangle-session-transport.v1", environmentId: box.id, sessionId: id,
|
|
392
|
-
executionIds, status, events, messages, messageScope: "session" }));
|
|
393
|
+
executionIds, status, events, messages, messageScope: "session", partText: PART_TEXT_ENCODING }));
|
|
393
394
|
capturedBytes = writer.byteLength;
|
|
394
395
|
let nativeSessionId = null;
|
|
395
396
|
let sidecarImageDigest = null;
|
|
@@ -530,13 +531,17 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
530
531
|
nativePaths.add(identity);
|
|
531
532
|
if (!nativeStatMetadata(entry))
|
|
532
533
|
throw new Error("Tangle raw session entry metadata is invalid");
|
|
533
|
-
|
|
534
|
+
const harnessInstall = entry.kind === "file" && harnessInstallPath(path);
|
|
535
|
+
if (entry.kind === "file" && !harnessInstall) {
|
|
534
536
|
const contentPath = "__retention__/sessions/" + id + "/native/" +
|
|
535
537
|
(entry.sourceId === undefined ? "" : entry.sourceId + "/") + entry.rootScope + "/" + path;
|
|
536
538
|
await retainNativeContent(entry, contentPath, entry.mode & 0o777);
|
|
537
539
|
contentRefs.push({ jsonPointer: `/files/${index}/contentBase64`, path: contentPath });
|
|
538
540
|
capturedBytes = writer.byteLength;
|
|
539
541
|
}
|
|
542
|
+
else if (entry.kind === "file") {
|
|
543
|
+
// The entry, its size and its digest stay in the inventory below.
|
|
544
|
+
}
|
|
540
545
|
else if (entry.kind === "directory" || entry.kind === "symlink") {
|
|
541
546
|
if (entry.contentBase64 !== undefined || entry.sha256 !== undefined ||
|
|
542
547
|
(entry.kind === "symlink" && (typeof entry.linkTarget !== "string" || entry.linkTarget.includes("\0")))) {
|
|
@@ -552,6 +557,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
552
557
|
rootScope: entry.rootScope, path, kind: entry.kind, mode: entry.mode,
|
|
553
558
|
uid: entry.uid, gid: entry.gid, mtimeMs: entry.mtimeMs, ctimeMs: entry.ctimeMs,
|
|
554
559
|
sizeBytes: entry.sizeBytes, sha256: entry.sha256 ?? null, linkTarget: entry.linkTarget ?? null,
|
|
560
|
+
...(harnessInstall ? { contentOmitted: "harness-install" } : {}),
|
|
555
561
|
});
|
|
556
562
|
}
|
|
557
563
|
for (const exclusion of native.excluded) {
|
|
@@ -725,9 +731,14 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
725
731
|
for (const sourceId of missingSpoolSources) {
|
|
726
732
|
missing.push(`Sandbox session ${id} has no original process source: ${sourceId}`);
|
|
727
733
|
}
|
|
734
|
+
const nativePartText = new Map();
|
|
728
735
|
manifestSource = {
|
|
729
736
|
...native,
|
|
730
|
-
|
|
737
|
+
events: native.events.map((record) => withoutRepeatedFrameText(record, nativePartText)),
|
|
738
|
+
files: native.files.map((entry) => entry.kind !== "file" ? entry
|
|
739
|
+
: harnessInstallPath(entry.path)
|
|
740
|
+
? { ...withoutNativeContent(entry), contentOmitted: "harness-install" }
|
|
741
|
+
: withoutNativeContent(entry)),
|
|
731
742
|
processIo: frameMetadata,
|
|
732
743
|
processSources: native.processSources.map(withoutNativeContent),
|
|
733
744
|
};
|
|
@@ -754,7 +765,9 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
754
765
|
throw new Error("Tangle raw session capture status is invalid");
|
|
755
766
|
}
|
|
756
767
|
await writer.writeChunks("__retention__/sessions/" + id + "/raw-manifest.json", 0o600, evidenceJsonChunks({ kind: "tangle-native-session-evidence.v1", source: manifestSource,
|
|
757
|
-
contentEncoding: "base64", contentRefs
|
|
768
|
+
contentEncoding: "base64", contentRefs,
|
|
769
|
+
// An unavailable capture keeps the producer's record unchanged.
|
|
770
|
+
...(manifestSource === native ? {} : { partText: PART_TEXT_ENCODING }) }));
|
|
758
771
|
capturedBytes = writer.byteLength;
|
|
759
772
|
}
|
|
760
773
|
sessions.push({
|
|
@@ -885,6 +898,58 @@ async function downloadWorkspaceEvidenceFile(fs, sourcePath, expectedSize, maxBy
|
|
|
885
898
|
}
|
|
886
899
|
}
|
|
887
900
|
/** Keep every source field; store validated binary content once in the archive. */
|
|
901
|
+
/**
|
|
902
|
+
* A streamed text part arrives as `message.part.updated` carrying the whole text so far plus
|
|
903
|
+
* its `delta`, so retaining every update stores the text once per update. One 117 KB reasoning
|
|
904
|
+
* part over 12,965 updates made an 802 MB transport file and a 637 MB manifest on 2026-10-19
|
|
905
|
+
* (queens21-h22-malloc2-root-2-20261019b), past what a reader can parse. An update whose text is
|
|
906
|
+
* exactly the part's previous text plus its delta keeps the delta and drops the text, marked
|
|
907
|
+
* `textFromDeltas`. Any other update (the first, a replayed duplicate, a reset) keeps its text.
|
|
908
|
+
* To read it: per part id, in file order, a marked update's text is that part's previous text
|
|
909
|
+
* plus its delta; an unmarked update's text is its own.
|
|
910
|
+
*/
|
|
911
|
+
const PART_TEXT_ENCODING = "delta-when-text-equals-previous-plus-delta";
|
|
912
|
+
function withoutRepeatedPartText(data, previous) {
|
|
913
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
914
|
+
return data;
|
|
915
|
+
const record = data;
|
|
916
|
+
const part = record.part;
|
|
917
|
+
if (record.type !== "message.part.updated" || !part || typeof part !== "object" || Array.isArray(part))
|
|
918
|
+
return data;
|
|
919
|
+
const { id, text } = part;
|
|
920
|
+
if (typeof id !== "string" || typeof text !== "string")
|
|
921
|
+
return data;
|
|
922
|
+
const before = previous.get(id);
|
|
923
|
+
previous.set(id, text);
|
|
924
|
+
if (before === undefined || typeof record.delta !== "string" || before + record.delta !== text)
|
|
925
|
+
return data;
|
|
926
|
+
const { text: _text, ...rest } = part;
|
|
927
|
+
return { ...record, part: { ...rest, textFromDeltas: true } };
|
|
928
|
+
}
|
|
929
|
+
function withoutRepeatedFrameText(record, previous) {
|
|
930
|
+
if (!record || typeof record !== "object" || Array.isArray(record))
|
|
931
|
+
return record;
|
|
932
|
+
const frames = record.frames;
|
|
933
|
+
const compact = (frame) => !frame || typeof frame !== "object" || Array.isArray(frame) ? frame
|
|
934
|
+
: { ...frame, data: withoutRepeatedPartText(frame.data, previous) };
|
|
935
|
+
// A directory capture streams its native frames from disk.
|
|
936
|
+
if (frames instanceof EvidenceJsonArray) {
|
|
937
|
+
return {
|
|
938
|
+
...record,
|
|
939
|
+
frames: new EvidenceJsonArray(frames.count, async function* () {
|
|
940
|
+
for await (const frame of frames.entries())
|
|
941
|
+
yield compact(frame);
|
|
942
|
+
}),
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
if (!Array.isArray(frames))
|
|
946
|
+
return record;
|
|
947
|
+
return { ...record, frames: frames.map(compact) };
|
|
948
|
+
}
|
|
949
|
+
/** A harness's installed packages under its home, e.g. `.config/opencode/node_modules`. */
|
|
950
|
+
function harnessInstallPath(path) {
|
|
951
|
+
return path.split("/").includes("node_modules");
|
|
952
|
+
}
|
|
888
953
|
function withoutNativeContent(source) {
|
|
889
954
|
const metadata = { ...source };
|
|
890
955
|
delete metadata.contentBase64;
|
package/dist/tangle-prompt.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function promptOptionsFromTurnInput(input: AgentTurnInput, target
|
|
|
17
17
|
* anywhere, which is the silent substitution the SDK's own `model` field
|
|
18
18
|
* exists to prevent.
|
|
19
19
|
*/
|
|
20
|
-
declare const SANDBOX_BACKEND_FIELD_LIST: readonly ["runtimeAttachments", "runtimeSecrets", "modelId", "provider", "apiKey", "baseUrl", "maxThinkingTokens", "mode", "apiKeyEnv", "cliAuth", "authMode", "authFiles", "type", "profile", "model", "server", "interactions", "metadata"];
|
|
20
|
+
declare const SANDBOX_BACKEND_FIELD_LIST: readonly ["runtimeAttachments", "runtimeSecrets", "modelId", "provider", "apiKey", "baseUrl", "maxThinkingTokens", "mode", "apiKeyEnv", "cliAuth", "authMode", "authFiles", "type", "profile", "model", "server", "interactions", "metadata", "routing"];
|
|
21
21
|
/**
|
|
22
22
|
* The `BackendConfig["model"]` fields the Sandbox prompt options declare.
|
|
23
23
|
*
|
|
@@ -25,7 +25,7 @@ declare const SANDBOX_BACKEND_FIELD_LIST: readonly ["runtimeAttachments", "runti
|
|
|
25
25
|
* with `authFiles` for a subscription seat — so it is checked field by field
|
|
26
26
|
* rather than passed through as opaque JSON.
|
|
27
27
|
*/
|
|
28
|
-
declare const SANDBOX_BACKEND_MODEL_FIELD_LIST: readonly ["provider", "model", "apiKey", "baseUrl", "maxThinkingTokens", "mode", "apiKeyEnv", "cliAuth", "authMode", "authFiles"];
|
|
28
|
+
declare const SANDBOX_BACKEND_MODEL_FIELD_LIST: readonly ["provider", "model", "apiKey", "baseUrl", "maxThinkingTokens", "mode", "apiKeyEnv", "cliAuth", "authMode", "authFiles", "routing"];
|
|
29
29
|
/**
|
|
30
30
|
* These lists cover the SDK's field sets, restated as values because a
|
|
31
31
|
* TypeScript type cannot be read at run time. This pin keeps them exact in
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -91,6 +91,8 @@ const SANDBOX_BACKEND_FIELD_LIST = [
|
|
|
91
91
|
"server",
|
|
92
92
|
"interactions",
|
|
93
93
|
"metadata",
|
|
94
|
+
// Creation-only: the SDK normalizer refuses it on a turn.
|
|
95
|
+
"routing",
|
|
94
96
|
];
|
|
95
97
|
const SANDBOX_BACKEND_FIELDS = new Set(SANDBOX_BACKEND_FIELD_LIST);
|
|
96
98
|
/**
|
|
@@ -111,6 +113,8 @@ const SANDBOX_BACKEND_MODEL_FIELD_LIST = [
|
|
|
111
113
|
"cliAuth",
|
|
112
114
|
"authMode",
|
|
113
115
|
"authFiles",
|
|
116
|
+
// Creation-only: the SDK normalizer refuses it on a turn.
|
|
117
|
+
"routing",
|
|
114
118
|
];
|
|
115
119
|
const SANDBOX_BACKEND_MODEL_FIELDS = new Set(SANDBOX_BACKEND_MODEL_FIELD_LIST);
|
|
116
120
|
const SANDBOX_AUTH_FILE_FIELD_LIST = ["path", "content", "mode"];
|
package/dist/tangle-provider.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createTangleExactProcessProvider, } from "./exact-process.js";
|
|
|
4
4
|
import { capabilitiesForClient, defaultTangleSandboxCapabilities, narrowTangleCapabilitiesToBackend, } from "./tangle-capabilities.js";
|
|
5
5
|
import { sandboxInstanceAsEnvironment } from "./tangle-environment.js";
|
|
6
6
|
import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
|
7
|
-
import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, NATIVE_RESUME_CHECKPOINT_METADATA_KEY, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
|
|
7
|
+
import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, createRoutingFromProviderOptions, NATIVE_RESUME_CHECKPOINT_METADATA_KEY, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
|
|
8
8
|
import { assertProxySecretAliases, captureProxySecrets, mergeProxySecrets, proxySecretsFromInput, proxySecretCapabilityFromDocument, PROXY_SECRETS_METADATA_KEY, rebindProxySecrets, requireProxySecretCapability } from "./tangle-proxy-secrets.js";
|
|
9
9
|
import { statusFromUnknown } from "./tangle-environment-values.js";
|
|
10
10
|
import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
@@ -91,9 +91,7 @@ export function createTangleProvider(options) {
|
|
|
91
91
|
const parsedWorkspace = assertCreateInputShape(input);
|
|
92
92
|
input.signal?.throwIfAborted();
|
|
93
93
|
assertNoInlineSecretValues(input, parsedWorkspace);
|
|
94
|
-
|
|
95
|
-
throw new Error("Tangle create providerOptions are not supported");
|
|
96
|
-
}
|
|
94
|
+
const requestedRouting = createRoutingFromProviderOptions(input.providerOptions);
|
|
97
95
|
if (Object.hasOwn(input.metadata ?? {}, PROXY_SECRETS_METADATA_KEY)) {
|
|
98
96
|
throw new Error("Tangle owns metadata.tangleProxySecrets");
|
|
99
97
|
}
|
|
@@ -139,6 +137,11 @@ export function createTangleProvider(options) {
|
|
|
139
137
|
requireProxySecretCapability(peerCapabilities, selectedProxySecrets);
|
|
140
138
|
}
|
|
141
139
|
assertMappedCreateOptions(mappedOptions);
|
|
140
|
+
// A custom mapper builds its own backend; requested routing must survive it.
|
|
141
|
+
const mappedRouting = mappedOptions.backend?.routing ?? mappedOptions.backend?.model?.routing;
|
|
142
|
+
if (canonicalCandidateDigest(mappedRouting ?? null) !== canonicalCandidateDigest(requestedRouting ?? null)) {
|
|
143
|
+
throw new Error("Tangle mapped create options must carry exactly the requested providerOptions.routing");
|
|
144
|
+
}
|
|
142
145
|
if (Object.hasOwn(mappedOptions.metadata ?? {}, "modelCredentials") &&
|
|
143
146
|
(!subscription || selectedCredentials === undefined ||
|
|
144
147
|
canonicalCandidateDigest(mappedOptions.metadata?.modelCredentials) !== canonicalCandidateDigest(selectedCredentials))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@tangle-network/agent-interface": "^5.6.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tangle-network/sandbox": ">=0.60.
|
|
39
|
+
"@tangle-network/sandbox": ">=0.60.88 <1.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@tangle-network/sandbox": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@tangle-network/agent-provider-testkit": "0.12.0",
|
|
48
48
|
"@tangle-network/agent-runtime": "0.292.3",
|
|
49
|
-
"@tangle-network/sandbox": "0.60.
|
|
49
|
+
"@tangle-network/sandbox": "0.60.88",
|
|
50
50
|
"@types/node": "26.6.3",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
52
|
"vitest": "5.0.2"
|