@tangle-network/agent-provider-tangle 4.3.0 → 4.4.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/README.md +26 -4
- package/dist/command-model-credentials.js +1 -1
- package/dist/http-model-credentials.js +1 -1
- package/dist/model-credential-source.d.ts +1 -8
- package/dist/model-credential-source.js +3 -3
- package/dist/tangle-create-options.d.ts +15 -1
- package/dist/tangle-create-options.js +50 -41
- package/dist/tangle-prompt.d.ts +2 -2
- package/dist/tangle-prompt.js +6 -6
- 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
|
|
|
@@ -95,9 +95,6 @@ Keep the stored secret available and valid throughout execution and recovery.
|
|
|
95
95
|
The exact profile chooses access through `model.metadata.credentialSource`.
|
|
96
96
|
Use `"subscription"` to request an enrolled account.
|
|
97
97
|
Omitting this field or using `"managed"` preserves managed access.
|
|
98
|
-
Use `"cli"` when the harness CLI authenticates its own provider, such as OpenCode's keyless free tier (`opencode/glm-5.3-flash-free`).
|
|
99
|
-
Sandbox then runs OpenCode in CLI mode: no managed key is minted, no subscription is selected, and the model never reaches the Router.
|
|
100
|
-
A `"cli"` profile runs only on the `opencode` backend and refuses `modelCredentials`; the box still needs egress to the provider's endpoint.
|
|
101
98
|
Unknown or malformed intent fails before provisioning.
|
|
102
99
|
`profileCredentialSource(profile)` exports this strict intent reader.
|
|
103
100
|
|
|
@@ -235,6 +232,31 @@ The account owner retains authority over registration, namespace verification, h
|
|
|
235
232
|
Updating a stored secret does not refresh credentials already injected into a live Sandbox.
|
|
236
233
|
Creation-time validity and the selected host's native credential lifecycle still bound long-running work.
|
|
237
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
|
+
|
|
238
260
|
## `create()` returns a ready environment
|
|
239
261
|
|
|
240
262
|
`provider.create()` does not return until the sandbox reports `running`.
|
|
@@ -41,7 +41,7 @@ export function createCommandModelCredentialResolver(options) {
|
|
|
41
41
|
return (input) => {
|
|
42
42
|
if (typeof input.profile === "string")
|
|
43
43
|
throw new Error("Tangle credential command requires an inline profile");
|
|
44
|
-
if (profileCredentialSource(input.profile)
|
|
44
|
+
if (profileCredentialSource(input.profile) === "managed")
|
|
45
45
|
return undefined;
|
|
46
46
|
if (typeof input.idempotencyKey !== "string" || input.idempotencyKey.length === 0) {
|
|
47
47
|
throw new Error("Tangle credential command requires a stable create idempotencyKey");
|
|
@@ -74,7 +74,7 @@ export function createHttpModelCredentialResolver(options) {
|
|
|
74
74
|
return async (input) => {
|
|
75
75
|
if (typeof input.profile === "string")
|
|
76
76
|
throw new Error("Tangle credential broker requires an inline profile");
|
|
77
|
-
if (profileCredentialSource(input.profile)
|
|
77
|
+
if (profileCredentialSource(input.profile) === "managed")
|
|
78
78
|
return undefined;
|
|
79
79
|
input.signal?.throwIfAborted();
|
|
80
80
|
const { signal, ...data } = input;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type { AgentProfile } from "@tangle-network/agent-interface";
|
|
2
|
-
|
|
3
|
-
* Who authenticates the profile's model.
|
|
4
|
-
* - `managed`: Tangle mints the model credential (the default).
|
|
5
|
-
* - `subscription`: a selected stored subscription credential.
|
|
6
|
-
* - `cli`: the harness CLI resolves and authenticates its own provider, such as OpenCode's
|
|
7
|
-
* keyless free tier. No managed key, no subscription seat, no credential resolver.
|
|
8
|
-
*/
|
|
9
|
-
export type ProfileCredentialSource = "managed" | "subscription" | "cli";
|
|
2
|
+
export type ProfileCredentialSource = "managed" | "subscription";
|
|
10
3
|
/** Authored profile intent is independent of the harness, vendor, and available accounts. */
|
|
11
4
|
export declare function profileCredentialSource(profile: AgentProfile): ProfileCredentialSource;
|
|
@@ -14,7 +14,7 @@ export function profileCredentialSource(profile) {
|
|
|
14
14
|
const source = metadata?.credentialSource;
|
|
15
15
|
if (source === undefined || source === "managed")
|
|
16
16
|
return "managed";
|
|
17
|
-
if (source === "subscription"
|
|
18
|
-
return
|
|
19
|
-
throw new Error('Tangle profile model.metadata.credentialSource must be "managed"
|
|
17
|
+
if (source === "subscription")
|
|
18
|
+
return "subscription";
|
|
19
|
+
throw new Error('Tangle profile model.metadata.credentialSource must be "managed" or "subscription"');
|
|
20
20
|
}
|
|
@@ -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);
|
|
@@ -71,15 +118,6 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
71
118
|
}
|
|
72
119
|
assertCliAuthReferenceSupported(backend, modelCredentials);
|
|
73
120
|
}
|
|
74
|
-
// A cli profile's harness authenticates itself (OpenCode's keyless free tier). Sandbox runs that
|
|
75
|
-
// as OpenCode CLI mode: no Router key is minted and the model never reaches the Router.
|
|
76
|
-
const cliOwned = profileCredentialSource(profile) === "cli";
|
|
77
|
-
if (cliOwned && modelCredentials !== undefined) {
|
|
78
|
-
throw new Error("Tangle cli profile takes no modelCredentials; its harness CLI authenticates itself");
|
|
79
|
-
}
|
|
80
|
-
if (cliOwned && backend !== "opencode") {
|
|
81
|
-
throw new Error(`Tangle cli profile runs only on the opencode backend, not ${backend}`);
|
|
82
|
-
}
|
|
83
121
|
if (selectedSecret !== undefined && Object.hasOwn(input.env ?? {}, selectedSecret)) {
|
|
84
122
|
throw new Error("Tangle modelCredentials cannot shadow a stored secret with inline environment data");
|
|
85
123
|
}
|
|
@@ -104,11 +142,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
104
142
|
[NATIVE_RESUME_CHECKPOINT_METADATA_KEY]: boundedIdentifier(workspace.checkpoint.checkpointId, "Tangle native resume checkpoint id"),
|
|
105
143
|
}),
|
|
106
144
|
};
|
|
107
|
-
|
|
108
|
-
throw new Error("Tangle create providerOptions are not supported");
|
|
109
|
-
}
|
|
110
|
-
if (input.providerOptions)
|
|
111
|
-
assertBoundedRecord(input.providerOptions, "Tangle create providerOptions");
|
|
145
|
+
const routing = createRoutingFromProviderOptions(input.providerOptions);
|
|
112
146
|
if (input.metadata)
|
|
113
147
|
assertBoundedRecord(input.metadata, "Tangle metadata");
|
|
114
148
|
if (input.name !== undefined) {
|
|
@@ -168,7 +202,6 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
168
202
|
...(base.backend ?? {}),
|
|
169
203
|
type: backend,
|
|
170
204
|
profile,
|
|
171
|
-
...(cliOwned ? { model: cliOwnedModel(profile) } : {}),
|
|
172
205
|
...(modelCredentials === undefined ? {} : {
|
|
173
206
|
model: "cliAuth" in modelCredentials
|
|
174
207
|
? { cliAuth: modelCredentials.cliAuth, authMode: "oauth" } : modelCredentials,
|
|
@@ -176,6 +209,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
176
209
|
...(input.runtimeAttachments === undefined ? {} : {
|
|
177
210
|
runtimeAttachments: tangleRuntimeAttachments(input.runtimeAttachments, profile),
|
|
178
211
|
}),
|
|
212
|
+
...(routing === undefined ? {} : { routing }),
|
|
179
213
|
},
|
|
180
214
|
};
|
|
181
215
|
return mapped;
|
|
@@ -217,15 +251,7 @@ function sandboxEgressPolicy(policy) {
|
|
|
217
251
|
}
|
|
218
252
|
/** Reject value-bearing secret maps before any custom mapper can drop them. */
|
|
219
253
|
export function assertNoInlineSecretValues(input, parsedWorkspace) {
|
|
220
|
-
|
|
221
|
-
if (!input.providerOptions || typeof input.providerOptions !== "object" || Array.isArray(input.providerOptions)) {
|
|
222
|
-
throw new Error("Tangle create providerOptions must be a JSON object");
|
|
223
|
-
}
|
|
224
|
-
assertBoundedJson(input.providerOptions, "Tangle create providerOptions");
|
|
225
|
-
if (Object.keys(input.providerOptions).length > 0) {
|
|
226
|
-
throw new Error("Tangle create providerOptions are not supported");
|
|
227
|
-
}
|
|
228
|
-
}
|
|
254
|
+
createRoutingFromProviderOptions(input.providerOptions);
|
|
229
255
|
if (input.workspace?.providerOptions !== undefined) {
|
|
230
256
|
const workspace = parsedWorkspace ?? WorkspaceRequestSchema.parse(input.workspace);
|
|
231
257
|
if (workspace.providerOptions && Object.keys(workspace.providerOptions).length > 0) {
|
|
@@ -318,27 +344,10 @@ export function assertCreateInputShape(input, parsedWorkspace) {
|
|
|
318
344
|
workspaceCwdPathForBase(workspace.cwd, "repository", "Tangle");
|
|
319
345
|
return workspace;
|
|
320
346
|
}
|
|
321
|
-
/** Sandbox's OpenCode CLI mode on the profile's own provider and model, with no credential. */
|
|
322
|
-
function cliOwnedModel(profile) {
|
|
323
|
-
const provider = profile.model?.provider;
|
|
324
|
-
const model = profile.model?.default;
|
|
325
|
-
return {
|
|
326
|
-
mode: "cli",
|
|
327
|
-
...(provider === undefined ? {} : { provider: boundedIdentifier(provider, "Tangle cli profile provider") }),
|
|
328
|
-
...(model === undefined ? {} : { model: boundedString(model, "Tangle cli profile model") }),
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
347
|
export function assertMappedCreateOptions(options) {
|
|
332
348
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
333
349
|
throw new Error("Tangle mapped create options must be an object");
|
|
334
350
|
}
|
|
335
|
-
if (options.backend?.profile !== undefined && profileCredentialSource(options.backend.profile) === "cli") {
|
|
336
|
-
const model = options.backend.model;
|
|
337
|
-
if (model?.mode !== "cli" || model.apiKey !== undefined || model.apiKeyEnv !== undefined ||
|
|
338
|
-
model.cliAuth !== undefined || model.authFiles !== undefined) {
|
|
339
|
-
throw new Error("Tangle mapped cli profile must run in CLI mode with no model credential");
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
351
|
assertBoundedJson(options, "Tangle mapped create options", PROFILE_AT_BACKEND_PROFILE);
|
|
343
352
|
const proxySecrets = options.proxySecrets === undefined ? undefined : captureProxySecrets(options.proxySecrets);
|
|
344
353
|
assertProxySecretAliases(proxySecrets, options.env, options.secrets);
|
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"];
|
|
@@ -167,13 +171,9 @@ function sandboxPromptBackend(value) {
|
|
|
167
171
|
? {}
|
|
168
172
|
: { metadata: sandboxPromptBackendMetadata(present.metadata) }),
|
|
169
173
|
};
|
|
170
|
-
|
|
171
|
-
if ((explicitSource === "managed" || explicitSource === "cli") &&
|
|
174
|
+
if (backend.profile?.model?.metadata?.credentialSource === "managed" &&
|
|
172
175
|
(backend.model?.cliAuth !== undefined || backend.model?.authFiles !== undefined || backend.model?.authMode === "oauth")) {
|
|
173
|
-
throw new Error(
|
|
174
|
-
}
|
|
175
|
-
if (explicitSource === "cli" && (backend.model?.apiKey !== undefined || backend.model?.apiKeyEnv !== undefined)) {
|
|
176
|
-
throw new Error("Tangle cli profile cannot receive a model API key");
|
|
176
|
+
throw new Error("Tangle explicit managed profile cannot receive native subscription credentials");
|
|
177
177
|
}
|
|
178
178
|
if (backend.profile !== undefined)
|
|
179
179
|
profileCredentialSource(backend.profile);
|
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.0",
|
|
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"
|