@tangle-network/agent-provider-tangle 4.5.6 → 4.5.7
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/dist/tangle-create-options.d.ts +2 -2
- package/dist/tangle-prompt.d.ts +5 -24
- package/dist/tangle-prompt.js +28 -50
- package/dist/tangle-provider.js +9 -9
- package/dist/tangle-proxy-secrets.d.ts +3 -2
- package/dist/tangle-proxy-secrets.js +9 -10
- package/dist/tangle-types.d.ts +6 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BackendType, type
|
|
1
|
+
import { type BackendType, 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. */
|
|
@@ -31,7 +31,7 @@ export declare function sandboxRestoreFromCheckpoint(checkpoint: WorkspaceReques
|
|
|
31
31
|
/** Reject value-bearing secret maps before any custom mapper can drop them. */
|
|
32
32
|
export declare function assertNoInlineSecretValues(input: CreateAgentEnvironmentInput, parsedWorkspace?: WorkspaceRequest): void;
|
|
33
33
|
/** Validate mapped stored names and bindings without resolving their values. */
|
|
34
|
-
export declare function assertMappedSecretNames(options:
|
|
34
|
+
export declare function assertMappedSecretNames(options: TangleCreateSandboxOptions): void;
|
|
35
35
|
export declare function assertCreateInputShape(input: CreateAgentEnvironmentInput, parsedWorkspace?: WorkspaceRequest): WorkspaceRequest | undefined;
|
|
36
36
|
export declare function assertMappedCreateOptions(options: TangleCreateSandboxOptions): void;
|
|
37
37
|
export {};
|
package/dist/tangle-prompt.d.ts
CHANGED
|
@@ -11,36 +11,16 @@ export declare function promptOptionsFromTurnInput(input: AgentTurnInput, target
|
|
|
11
11
|
}): PromptOptions;
|
|
12
12
|
/** The SDK owns isolated session creation and the executor's private admission receipt. */
|
|
13
13
|
export declare function preparePromptOptions(box: SandboxInstanceLike | undefined, options: PromptOptions, provider: string): Promise<PromptOptions>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* A turn may carry any of them and nothing else. An undeclared field is
|
|
18
|
-
* refused instead of forwarded, because the SDK drops what it does not
|
|
19
|
-
* declare: the turn would then run on different settings with no error
|
|
20
|
-
* anywhere, which is the silent substitution the SDK's own `model` field
|
|
21
|
-
* exists to prevent.
|
|
22
|
-
*/
|
|
23
|
-
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"];
|
|
24
|
-
/**
|
|
25
|
-
* The `BackendConfig["model"]` fields the Sandbox prompt options declare.
|
|
26
|
-
*
|
|
27
|
-
* This is the block that carries per-turn credentials — `authMode: "oauth"`
|
|
28
|
-
* with `authFiles` for a subscription seat — so it is checked field by field
|
|
29
|
-
* rather than passed through as opaque JSON.
|
|
30
|
-
*/
|
|
14
|
+
/** Canonical backend controls plus the legacy model aliases folded below. */
|
|
15
|
+
declare const SANDBOX_BACKEND_FIELD_LIST: readonly ["runtimeAttachments", "runtimeSecrets", "type", "profile", "model", "server", "interactions", "metadata"];
|
|
31
16
|
declare const SANDBOX_BACKEND_MODEL_FIELD_LIST: readonly ["provider", "model", "apiKey", "baseUrl", "maxThinkingTokens", "mode", "apiKeyEnv", "cliAuth", "authMode", "authFiles", "routing"];
|
|
32
|
-
/**
|
|
33
|
-
* These lists cover the SDK's field sets, restated as values because a
|
|
34
|
-
* TypeScript type cannot be read at run time. This pin keeps them exact in
|
|
35
|
-
* both directions: a field the SDK adds, renames, or removes fails the build
|
|
36
|
-
* here rather than reaching a caller as a wrong refusal or a silent drop.
|
|
37
|
-
*/
|
|
17
|
+
/** SDK canonical fields stay exhaustive; legacy aliases are explicitly projected into model. */
|
|
38
18
|
type Exhaustive<T extends never> = T;
|
|
39
19
|
type SandboxBackendModel = NonNullable<BackendConfig["model"]>;
|
|
40
20
|
declare const SANDBOX_AUTH_FILE_FIELD_LIST: readonly ["path", "content", "mode"];
|
|
41
21
|
type SandboxAuthFile = NonNullable<SandboxBackendModel["authFiles"]>[number];
|
|
42
22
|
type FieldDifference<T, Fields extends readonly PropertyKey[]> = Exclude<keyof T, Fields[number]> | Exclude<Fields[number], keyof T>;
|
|
43
|
-
export type SandboxBackendFieldCoverage = Exhaustive<FieldDifference<BackendConfig, typeof SANDBOX_BACKEND_FIELD_LIST> | FieldDifference<SandboxBackendModel, typeof SANDBOX_BACKEND_MODEL_FIELD_LIST> | FieldDifference<SandboxAuthFile, typeof SANDBOX_AUTH_FILE_FIELD_LIST>>;
|
|
23
|
+
export type SandboxBackendFieldCoverage = Exhaustive<FieldDifference<Omit<BackendConfig, Exclude<(typeof SANDBOX_BACKEND_MODEL_FIELD_LIST)[number], "model"> | "modelId">, typeof SANDBOX_BACKEND_FIELD_LIST> | FieldDifference<SandboxBackendModel, typeof SANDBOX_BACKEND_MODEL_FIELD_LIST> | FieldDifference<SandboxAuthFile, typeof SANDBOX_AUTH_FILE_FIELD_LIST>>;
|
|
44
24
|
type SandboxPromptBackend = NonNullable<PromptOptions["backend"]>;
|
|
45
25
|
/**
|
|
46
26
|
* Read the per-turn backend options a caller sent through `providerOptions`.
|
|
@@ -52,6 +32,7 @@ type SandboxPromptBackend = NonNullable<PromptOptions["backend"]>;
|
|
|
52
32
|
* declare, and the result is bounded JSON the SDK reads once.
|
|
53
33
|
*/
|
|
54
34
|
export declare function backendFromTurnProviderOptions(providerOptions: Record<string, unknown> | undefined): SandboxPromptBackend | undefined;
|
|
35
|
+
export declare function normalizeTangleBackend(value: unknown, allowRouting?: boolean): BackendConfig | undefined;
|
|
55
36
|
/**
|
|
56
37
|
* The part of the backend options that decides which work a turn is.
|
|
57
38
|
*
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { normalizeRuntimeBackendConfig } from "@tangle-network/sandbox";
|
|
3
3
|
import { projectAgentTerminalRecord } from "@tangle-network/sandbox/runtime";
|
|
4
4
|
import { assertCliAuthReferenceSupported, cliAuthReferenceSchema, } from "@tangle-network/sandbox/auth";
|
|
5
|
-
import { agentProfileSchema, canonicalAgentProfileDigest, boundedEventContentRecordSchema, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, contextTransferResultMatchesRequest, } from "@tangle-network/agent-interface";
|
|
5
|
+
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, boundedEventContentRecordSchema, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, contextTransferResultMatchesRequest, } from "@tangle-network/agent-interface";
|
|
6
6
|
import { tokenUsageFromData } from "./tangle-result-values.js";
|
|
7
7
|
import { TangleCredentialCapacityError } from "./model-credential-capacity.js";
|
|
8
8
|
import { assertBoundedJson, awaitWithSignal, boundedString, PROFILE_AT_PROFILE, } from "./tangle-contract-safety.js";
|
|
@@ -96,45 +96,10 @@ export async function preparePromptOptions(box, options, provider) {
|
|
|
96
96
|
options.signal?.throwIfAborted();
|
|
97
97
|
return { ...options, sessionId, backend, expectedPublicProfileRequestDigest, expectedSecretProfileReceipt };
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* The `BackendConfig` fields this adapter forwards to Sandbox prompt options.
|
|
101
|
-
*
|
|
102
|
-
* A turn may carry any of them and nothing else. An undeclared field is
|
|
103
|
-
* refused instead of forwarded, because the SDK drops what it does not
|
|
104
|
-
* declare: the turn would then run on different settings with no error
|
|
105
|
-
* anywhere, which is the silent substitution the SDK's own `model` field
|
|
106
|
-
* exists to prevent.
|
|
107
|
-
*/
|
|
99
|
+
/** Canonical backend controls plus the legacy model aliases folded below. */
|
|
108
100
|
const SANDBOX_BACKEND_FIELD_LIST = [
|
|
109
|
-
"runtimeAttachments",
|
|
110
|
-
"runtimeSecrets",
|
|
111
|
-
"modelId",
|
|
112
|
-
"provider",
|
|
113
|
-
"apiKey",
|
|
114
|
-
"baseUrl",
|
|
115
|
-
"maxThinkingTokens",
|
|
116
|
-
"mode",
|
|
117
|
-
"apiKeyEnv",
|
|
118
|
-
"cliAuth",
|
|
119
|
-
"authMode",
|
|
120
|
-
"authFiles",
|
|
121
|
-
"type",
|
|
122
|
-
"profile",
|
|
123
|
-
"model",
|
|
124
|
-
"server",
|
|
125
|
-
"interactions",
|
|
126
|
-
"metadata",
|
|
127
|
-
// Creation-only: the SDK normalizer refuses it on a turn.
|
|
128
|
-
"routing",
|
|
101
|
+
"runtimeAttachments", "runtimeSecrets", "type", "profile", "model", "server", "interactions", "metadata",
|
|
129
102
|
];
|
|
130
|
-
const SANDBOX_BACKEND_FIELDS = new Set(SANDBOX_BACKEND_FIELD_LIST);
|
|
131
|
-
/**
|
|
132
|
-
* The `BackendConfig["model"]` fields the Sandbox prompt options declare.
|
|
133
|
-
*
|
|
134
|
-
* This is the block that carries per-turn credentials — `authMode: "oauth"`
|
|
135
|
-
* with `authFiles` for a subscription seat — so it is checked field by field
|
|
136
|
-
* rather than passed through as opaque JSON.
|
|
137
|
-
*/
|
|
138
103
|
const SANDBOX_BACKEND_MODEL_FIELD_LIST = [
|
|
139
104
|
"provider",
|
|
140
105
|
"model",
|
|
@@ -150,6 +115,8 @@ const SANDBOX_BACKEND_MODEL_FIELD_LIST = [
|
|
|
150
115
|
"routing",
|
|
151
116
|
];
|
|
152
117
|
const SANDBOX_BACKEND_MODEL_FIELDS = new Set(SANDBOX_BACKEND_MODEL_FIELD_LIST);
|
|
118
|
+
const SANDBOX_BACKEND_FIELDS = new Set([...SANDBOX_BACKEND_FIELD_LIST,
|
|
119
|
+
...SANDBOX_BACKEND_MODEL_FIELD_LIST.map((field) => field === "model" ? "modelId" : field)]);
|
|
153
120
|
const SANDBOX_AUTH_FILE_FIELD_LIST = ["path", "content", "mode"];
|
|
154
121
|
/**
|
|
155
122
|
* Read the per-turn backend options a caller sent through `providerOptions`.
|
|
@@ -168,19 +135,30 @@ export function backendFromTurnProviderOptions(providerOptions) {
|
|
|
168
135
|
return undefined;
|
|
169
136
|
return sandboxPromptBackend(providerOptions.backend);
|
|
170
137
|
}
|
|
138
|
+
export function normalizeTangleBackend(value, allowRouting = false) {
|
|
139
|
+
if (value === undefined)
|
|
140
|
+
return undefined;
|
|
141
|
+
const source = plainRecord(value, "Tangle backend options"), canonical = { ...source };
|
|
142
|
+
assertDeclaredFields(source, SANDBOX_BACKEND_FIELDS, "Tangle backend options");
|
|
143
|
+
const model = source.model === undefined ? {} : { ...plainRecord(source.model, "Tangle backend model") };
|
|
144
|
+
assertDeclaredFields(model, SANDBOX_BACKEND_MODEL_FIELDS, "Tangle backend model");
|
|
145
|
+
for (const field of SANDBOX_BACKEND_MODEL_FIELD_LIST) {
|
|
146
|
+
const alias = field === "model" ? "modelId" : field, selected = source[alias];
|
|
147
|
+
if (selected === undefined)
|
|
148
|
+
continue;
|
|
149
|
+
if (model[field] !== undefined && canonicalCandidateDigest(model[field]) !== canonicalCandidateDigest(selected))
|
|
150
|
+
throw new Error(`Tangle backend ${alias} conflicts with model.${field}`);
|
|
151
|
+
model[field] = selected;
|
|
152
|
+
delete canonical[alias];
|
|
153
|
+
}
|
|
154
|
+
if (source.model !== undefined || Object.keys(model).length)
|
|
155
|
+
canonical.model = model;
|
|
156
|
+
if (canonical.server !== undefined)
|
|
157
|
+
plainRecord(canonical.server, "Tangle backend server");
|
|
158
|
+
return normalizeRuntimeBackendConfig(canonical, { allowRuntimeSecrets: true, allowRouting });
|
|
159
|
+
}
|
|
171
160
|
function sandboxPromptBackend(value) {
|
|
172
|
-
const
|
|
173
|
-
assertDeclaredFields(source, SANDBOX_BACKEND_FIELDS, "Tangle prompt backend options");
|
|
174
|
-
// Normalization can omit falsy nested values or replace them with flat fields.
|
|
175
|
-
// Reject malformed declarations before that loses the caller's input.
|
|
176
|
-
for (const field of ["model", "server"]) {
|
|
177
|
-
if (source[field] !== undefined) {
|
|
178
|
-
plainRecord(source[field], `Tangle prompt backend ${field} options`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const present = normalizeRuntimeBackendConfig(source, {
|
|
182
|
-
allowRuntimeSecrets: true,
|
|
183
|
-
}) ?? {};
|
|
161
|
+
const present = normalizeTangleBackend(value) ?? {};
|
|
184
162
|
const backend = {
|
|
185
163
|
...(present.type === undefined
|
|
186
164
|
? {}
|
package/dist/tangle-provider.js
CHANGED
|
@@ -6,8 +6,9 @@ import { sandboxInstanceAsEnvironment } from "./tangle-environment.js";
|
|
|
6
6
|
import { tangleProfileValidator } from "./tangle-profile-validation.js";
|
|
7
7
|
import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
|
8
8
|
import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, createRoutingFromProviderOptions, NATIVE_RESUME_CHECKPOINT_METADATA_KEY, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
|
|
9
|
-
import {
|
|
9
|
+
import { captureProxySecrets, mergeProxySecrets, proxySecretsFromInput, sandboxSecretBindingIdentity, sandboxSecretBindings, PROXY_SECRETS_METADATA_KEY } from "./tangle-proxy-secrets.js";
|
|
10
10
|
import { statusFromUnknown } from "./tangle-environment-values.js";
|
|
11
|
+
import { normalizeTangleBackend } from "./tangle-prompt.js";
|
|
11
12
|
import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
12
13
|
import { awaitSandboxRunning, DEFAULT_TANGLE_READY_TIMEOUT_MS, } from "./tangle-readiness.js";
|
|
13
14
|
import { profileCredentialSource } from "./model-credential-source.js";
|
|
@@ -111,7 +112,7 @@ export function createTangleProvider(options) {
|
|
|
111
112
|
throw new Error("Tangle owns metadata.tangleProxySecrets");
|
|
112
113
|
}
|
|
113
114
|
const requestedProxySecrets = proxySecretsFromInput(input);
|
|
114
|
-
|
|
115
|
+
const requestedSecrets = structuredClone(sandboxSecretBindings(input.secrets, requestedProxySecrets, input.env));
|
|
115
116
|
const credentialSource = typeof input.profile === "string" ? "managed" : profileCredentialSource(input.profile);
|
|
116
117
|
const subscription = credentialSource === "subscription";
|
|
117
118
|
if (Object.hasOwn(input.metadata ?? {}, "modelCredentials")) {
|
|
@@ -142,19 +143,18 @@ export function createTangleProvider(options) {
|
|
|
142
143
|
if (mappedInput.proxySecrets !== undefined && canonicalCandidateDigest(mappedInput.proxySecrets) !== canonicalCandidateDigest(selectedProxySecrets)) {
|
|
143
144
|
throw new Error("Tangle mapped proxy-secret declarations differ from the requested bindings");
|
|
144
145
|
}
|
|
145
|
-
const { proxySecrets: _legacy, secrets: selection, ...mapped } = mappedInput;
|
|
146
|
+
const { proxySecrets: _legacy, secrets: selection, ...mapped } = { ...mappedInput, backend: normalizeTangleBackend(mappedInput.backend, true) };
|
|
146
147
|
const secrets = sandboxSecretBindings(selection, selectedProxySecrets, mapped.env);
|
|
147
148
|
const mappedOptions = { ...mapped, ...(secrets === undefined ? {} : { secrets }) };
|
|
148
|
-
for (const entry of
|
|
149
|
+
for (const entry of requestedSecrets ?? []) {
|
|
149
150
|
if (typeof entry === "string")
|
|
150
151
|
continue;
|
|
151
|
-
if (!Array.isArray(mappedOptions.secrets) || !mappedOptions.secrets.some((selected) =>
|
|
152
|
-
throw new Error("Tangle mapped secrets must preserve the requested
|
|
152
|
+
if (!Array.isArray(mappedOptions.secrets) || !mappedOptions.secrets.some((selected) => sandboxSecretBindingIdentity(selected) === sandboxSecretBindingIdentity(entry))) {
|
|
153
|
+
throw new Error("Tangle mapped secrets must preserve the requested delivery selection");
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
assertMappedCreateOptions(mappedOptions);
|
|
156
|
-
|
|
157
|
-
const mappedRouting = mappedOptions.backend?.routing ?? mappedOptions.backend?.model?.routing;
|
|
157
|
+
const mappedRouting = mappedOptions.backend?.model?.routing;
|
|
158
158
|
if (canonicalCandidateDigest(mappedRouting ?? null) !== canonicalCandidateDigest(requestedRouting ?? null)) {
|
|
159
159
|
throw new Error("Tangle mapped create options must carry exactly the requested providerOptions.routing");
|
|
160
160
|
}
|
|
@@ -341,7 +341,7 @@ export function createTangleProvider(options) {
|
|
|
341
341
|
return {
|
|
342
342
|
name: providerName,
|
|
343
343
|
...(exactProcess ? { exactProcess } : {}),
|
|
344
|
-
...(options.client.secrets
|
|
344
|
+
...(typeof options.client.secrets?.update !== "function" ? {} : { secrets: options.client.secrets }),
|
|
345
345
|
...(workspaceBranching === undefined ? {} : { workspaceBranching }),
|
|
346
346
|
capabilities: resolveCapabilities,
|
|
347
347
|
validateProfile: tangleProfileValidator(options.validateProfile),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CreateAgentEnvironmentInput, type ProxySecretBinding } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TangleCreateSandboxOptions } from "./tangle-types.js";
|
|
3
3
|
/** Provider-owned public declarations bind recovery; they contain no authority or values. */
|
|
4
4
|
export declare const PROXY_SECRETS_METADATA_KEY = "tangleProxySecrets";
|
|
5
5
|
export declare function captureProxySecrets(value: unknown): ProxySecretBinding[];
|
|
@@ -7,4 +7,5 @@ export declare function proxySecretsFromInput(input: CreateAgentEnvironmentInput
|
|
|
7
7
|
export declare function mergeProxySecrets(requested: ProxySecretBinding[] | undefined, selected: ProxySecretBinding[] | undefined): ProxySecretBinding[] | undefined;
|
|
8
8
|
export declare function assertProxySecretAliases(bindings: ProxySecretBinding[] | undefined, env: Record<string, string> | undefined, secrets: unknown): void;
|
|
9
9
|
/** Lower portable declarations to the single host binding actually served by Sandbox. */
|
|
10
|
-
export declare function sandboxSecretBindings(secrets: CreateAgentEnvironmentInput["secrets"] | "all", bindings?: readonly ProxySecretBinding[], env?: Record<string, string>): Exclude<
|
|
10
|
+
export declare function sandboxSecretBindings(secrets: CreateAgentEnvironmentInput["secrets"] | "all", bindings?: readonly ProxySecretBinding[], env?: Record<string, string>): Exclude<TangleCreateSandboxOptions["secrets"], "all">;
|
|
11
|
+
export declare const sandboxSecretBindingIdentity: (entry: Extract<CreateAgentEnvironmentInput["secrets"], unknown[]>[number]) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProxySecretsSchema, mergeProxySecretBindings
|
|
1
|
+
import { ProxySecretsSchema, mergeProxySecretBindings } from "@tangle-network/agent-interface/environment-provider";
|
|
2
2
|
import { canonicalCandidateDigest, deepFreeze } from "@tangle-network/agent-interface";
|
|
3
3
|
import { boundedIdentifier, MAX_ARRAY_LENGTH } from "./tangle-contract-safety.js";
|
|
4
4
|
/** Provider-owned public declarations bind recovery; they contain no authority or values. */
|
|
@@ -17,12 +17,11 @@ export function mergeProxySecrets(requested, selected) {
|
|
|
17
17
|
? undefined : deepFreeze(mergeProxySecretBindings(requested, selected));
|
|
18
18
|
}
|
|
19
19
|
export function assertProxySecretAliases(bindings, env, secrets) {
|
|
20
|
-
if (bindings !== undefined && secrets !== undefined && !Array.isArray(secrets))
|
|
20
|
+
if (bindings !== undefined && secrets !== undefined && !Array.isArray(secrets))
|
|
21
21
|
throw new Error("Tangle proxy-secret custody cannot use all or raw readable secret selection");
|
|
22
|
-
}
|
|
23
22
|
for (const binding of bindings ?? []) {
|
|
24
23
|
for (const alias of [binding.envName, binding.secretRef.key]) {
|
|
25
|
-
if (Object.hasOwn(env ?? {}, alias) || (Array.isArray(secrets) && secrets.
|
|
24
|
+
if (Object.hasOwn(env ?? {}, alias) || (Array.isArray(secrets) && secrets.some((entry) => typeof entry === "string" ? entry === alias : entry?.name === alias && "exposeInBox" in entry))) {
|
|
26
25
|
throw new Error("Tangle proxy-secret reference or alias cannot receive raw readable secret delivery");
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -49,17 +48,16 @@ export function sandboxSecretBindings(secrets, bindings, env) {
|
|
|
49
48
|
const name = typeof entry === "string" ? entry : entry.name;
|
|
50
49
|
boundedIdentifier(name, "Tangle stored-secret name");
|
|
51
50
|
if (typeof entry !== "string") {
|
|
52
|
-
if (Object.keys(entry).some((key) => !["name", "host", "header"].includes(key)) ||
|
|
51
|
+
if (("host" in entry ? Object.keys(entry).some((key) => !["name", "host", "header"].includes(key)) ||
|
|
53
52
|
typeof entry.host !== "string" || entry.host.length > 253 ||
|
|
54
53
|
!/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(entry.host) ||
|
|
55
|
-
(entry.header !== undefined && (typeof entry.header !== "string" || !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(entry.header)))
|
|
54
|
+
(entry.header !== undefined && (typeof entry.header !== "string" || !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(entry.header))) :
|
|
55
|
+
Object.keys(entry).some((key) => !["name", "exposeInBox"].includes(key)) || entry.exposeInBox !== true) ||
|
|
56
56
|
Object.hasOwn(env ?? {}, name))
|
|
57
|
-
throw new Error("Invalid or shadowed Tangle
|
|
57
|
+
throw new Error("Invalid or shadowed Tangle secret selection");
|
|
58
58
|
}
|
|
59
59
|
const previous = entries.get(name);
|
|
60
|
-
|
|
61
|
-
{ name: value.name, host: value.host, header: (value.header ?? "Authorization").toLowerCase() };
|
|
62
|
-
if (previous !== undefined && canonicalCandidateDigest(identity(previous)) !== canonicalCandidateDigest(identity(entry)))
|
|
60
|
+
if (previous !== undefined && sandboxSecretBindingIdentity(previous) !== sandboxSecretBindingIdentity(entry))
|
|
63
61
|
throw new Error("Conflicting Tangle secret delivery");
|
|
64
62
|
entries.set(name, entry);
|
|
65
63
|
}
|
|
@@ -67,3 +65,4 @@ export function sandboxSecretBindings(secrets, bindings, env) {
|
|
|
67
65
|
throw new Error("Tangle stored-secret selection exceeds its bound");
|
|
68
66
|
return [...entries.values()];
|
|
69
67
|
}
|
|
68
|
+
export const sandboxSecretBindingIdentity = (entry) => canonicalCandidateDigest(typeof entry !== "string" && "host" in entry ? { ...entry, header: (entry.header ?? "Authorization").toLowerCase() } : entry);
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliAuthReference } from "@tangle-network/sandbox/auth";
|
|
2
|
-
import type { BackendRegistryEntry, BackendRegistryResponse, BackendType, CreateSandboxOptions, ExecResult as SandboxExecResult, PromptOptions, PromptResult, SandboxInstance, SandboxEvent } from "@tangle-network/sandbox";
|
|
2
|
+
import type { BackendConfig, BackendRegistryEntry, BackendRegistryResponse, BackendType, CreateSandboxOptions, ExecResult as SandboxExecResult, PromptOptions, PromptResult, SandboxInstance, SandboxEvent } from "@tangle-network/sandbox";
|
|
3
3
|
import type { AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionAttach, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStatus, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentInteractiveTerminalSession, ConfidentialAttestation, ConfidentialExecutionEnvironment, InputPart, InteractionRequest, InteractionResponseCommand } from "@tangle-network/agent-interface";
|
|
4
4
|
import type { AgentEnvironmentCapabilities, AgentEnvironmentProvider, CreateAgentEnvironmentInput, ProxySecretBinding, ProxySecretCapabilities, ProxySecretReceipt } from "@tangle-network/agent-interface/environment-provider";
|
|
5
5
|
/**
|
|
@@ -24,7 +24,11 @@ export interface SandboxCreateReceiptLike {
|
|
|
24
24
|
export interface TangleExactProcessOptions {
|
|
25
25
|
teamId?: string;
|
|
26
26
|
}
|
|
27
|
-
export type TangleCreateSandboxOptions = CreateSandboxOptions & {
|
|
27
|
+
export type TangleCreateSandboxOptions = Omit<CreateSandboxOptions, "secrets" | "backend"> & {
|
|
28
|
+
backend?: BackendConfig & Omit<NonNullable<BackendConfig["model"]>, "model"> & {
|
|
29
|
+
modelId?: string;
|
|
30
|
+
};
|
|
31
|
+
secrets?: "all" | Extract<CreateAgentEnvironmentInput["secrets"], unknown[]>;
|
|
28
32
|
proxySecrets?: ProxySecretBinding[];
|
|
29
33
|
};
|
|
30
34
|
export interface SandboxClientLike {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.7",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
36
|
+
"@tangle-network/agent-interface": "^5.10.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@tangle-network/sandbox": ">=0.60.88 <2.0.0"
|