@tangle-network/agent-provider-tangle 4.5.7 → 5.0.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 +13 -13
- package/dist/tangle-create-options.d.ts +5 -2
- package/dist/tangle-create-options.js +33 -28
- package/dist/tangle-provider.js +13 -11
- package/dist/tangle-proxy-secrets.d.ts +1 -3
- package/dist/tangle-proxy-secrets.js +13 -43
- package/dist/tangle-types.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -66,12 +66,17 @@ Aggregate limits, credential exclusions, and exact native-session proof remain e
|
|
|
66
66
|
Capture lists no directory below a credential directory such as `.opencode` or `.config`: it records the directory as excluded and accounts for its subtree with one complete usage scan, so the workspace totals still reconcile.
|
|
67
67
|
An unsupported downloader or incomplete transfer fails capture and preserves the source environment.
|
|
68
68
|
|
|
69
|
+
## Profile credentials
|
|
70
|
+
|
|
71
|
+
Declare proxy-held credentials in `profile.proxySecrets` or create input `proxySecrets` using the same `ProxySecretsSchema`. The Provider forwards the full declaration unchanged, including aliases, destinations, methods, paths, presentation and expiry. Trusted Sandbox resolution owns tenant authorization, stored identity and proxy installation. The SDK transport must support the top-level canonical field.
|
|
72
|
+
|
|
73
|
+
Legacy stored names, `"all"` and host objects retain their delivery selection. The API binds known hosts or preserves prior delivery for unbound names; explicit canonical scope governs protected names. Explicit readable requests use the existing `{name, exposeInBox:true}` consent and `metadata.reason` or a retained store reason. A mapper cannot replace authored custody or erase its reason. Source and local HTTP proof do not establish deployed proxy enforcement.
|
|
74
|
+
|
|
69
75
|
## Named model credentials at creation
|
|
70
76
|
|
|
71
77
|
`modelCredentials` sends a stored credential reference and explicit endpoint before Sandbox provisions the backend.
|
|
72
78
|
This uses Sandbox's existing caller-owned model credential path instead of requesting a managed Router credential.
|
|
73
|
-
The provider does not create, copy, or renew stored secrets.
|
|
74
|
-
The Provider grants the selected reference at create, alongside unrelated caller-requested secrets. Qualified native selectors also grant their selected reference before each fresh turn.
|
|
79
|
+
The provider does not create, copy, or renew stored secrets. The Provider forwards the selected reference at create, alongside unrelated caller-requested secrets. Qualified native selectors also grant their selected reference before each fresh turn.
|
|
75
80
|
|
|
76
81
|
```ts
|
|
77
82
|
const provider = createTangleProvider({
|
|
@@ -86,8 +91,7 @@ const environment = await provider.create({
|
|
|
86
91
|
});
|
|
87
92
|
```
|
|
88
93
|
|
|
89
|
-
The configuration accepts only the reference and endpoint, not credential values or model selection.
|
|
90
|
-
The authored profile, selected backend, runtime attachments, and create identity remain unchanged.
|
|
94
|
+
The configuration accepts only the reference and endpoint, not credential values or model selection. The authored profile, selected backend, runtime attachments, and create identity remain unchanged.
|
|
91
95
|
The provider snapshots this configuration when constructed and refuses combining it with `mapCreateInput`.
|
|
92
96
|
Omitting it preserves managed creation.
|
|
93
97
|
The endpoint must use HTTP or HTTPS without credentials, query parameters, or fragments.
|
|
@@ -147,20 +151,16 @@ The Provider validates native channels with the maintained CLI Registry before p
|
|
|
147
151
|
Each selector must use the exact profile harness.
|
|
148
152
|
Native execution also requires the selected container to report `cliAuthReferences: true`.
|
|
149
153
|
A missing or unreadable capability refuses creation or dispatch before inference.
|
|
150
|
-
|
|
154
|
+
Native selectors retain their existing selected stored name beside unrelated requests; the native owner controls resolution and bundle delivery.
|
|
151
155
|
Keep pool-wide account credentials out of the create input's `secrets` list.
|
|
152
|
-
Static native references grant their selected secret
|
|
153
|
-
|
|
154
|
-
Inline environment values cannot shadow the selected stored secret.
|
|
155
|
-
Undefined, malformed, unsupported, or failed subscription selections stop before Sandbox creation.
|
|
156
|
+
Static native references select their credential only for subscription profiles. Static API references grant their selected secret for unmarked legacy profiles and subscription profiles.
|
|
157
|
+
Inline environment values cannot shadow the selected stored secret. Undefined, malformed, unsupported, or failed subscription selections stop before Sandbox creation.
|
|
156
158
|
Subscription failures never fall back to managed Router access.
|
|
157
159
|
|
|
158
|
-
Sandbox metadata records the public selection under `modelCredentials`.
|
|
159
|
-
This metadata key is reserved for the Provider selection.
|
|
160
|
+
Sandbox metadata records the public selection under `modelCredentials`. This metadata key is reserved for the Provider selection.
|
|
160
161
|
Account labels are supplied bindings, not verified native principals.
|
|
161
162
|
Token values and native credential files never enter that selection or receipt.
|
|
162
|
-
A static native reference stays bound to its creation account and harness on every turn.
|
|
163
|
-
Reconstructed environments recover that reference from persisted metadata and the observed backend.
|
|
163
|
+
A static native reference stays bound to its creation account and harness on every turn. Reconstructed environments recover that reference from persisted metadata and the observed backend.
|
|
164
164
|
|
|
165
165
|
A resolver selects a bootstrap credential at creation and a durable binding for each fresh turn.
|
|
166
166
|
Fresh turns require the exact inline subscription profile and a stable `turnId`.
|
|
@@ -30,8 +30,11 @@ export declare function sandboxRestoreFromCheckpoint(checkpoint: WorkspaceReques
|
|
|
30
30
|
} | undefined;
|
|
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
|
-
/**
|
|
34
|
-
export declare function assertMappedSecretNames(options:
|
|
33
|
+
/** Preserve legacy stored selections while canonical declarations travel separately. */
|
|
34
|
+
export declare function assertMappedSecretNames(options: {
|
|
35
|
+
secrets?: unknown;
|
|
36
|
+
env?: Record<string, string>;
|
|
37
|
+
}): void;
|
|
35
38
|
export declare function assertCreateInputShape(input: CreateAgentEnvironmentInput, parsedWorkspace?: WorkspaceRequest): WorkspaceRequest | undefined;
|
|
36
39
|
export declare function assertMappedCreateOptions(options: TangleCreateSandboxOptions): void;
|
|
37
40
|
export {};
|
|
@@ -6,7 +6,7 @@ import { profileCredentialSource } from "./model-credential-source.js";
|
|
|
6
6
|
import { sandboxResourcesFromResourceRequest } from "./tangle-resources.js";
|
|
7
7
|
import { tangleRuntimeAttachments } from "./tangle-runtime-attachments.js";
|
|
8
8
|
import { deepFreeze } from "@tangle-network/agent-interface";
|
|
9
|
-
import { assertProxySecretAliases, captureProxySecrets, mergeProxySecrets, proxySecretsFromInput,
|
|
9
|
+
import { assertProxySecretAliases, captureProxySecrets, mergeProxySecrets, proxySecretsFromInput, sandboxSecretBindingIdentity } from "./tangle-proxy-secrets.js";
|
|
10
10
|
/** Immutable create evidence used to bind a later native resume to its restored snapshot. */
|
|
11
11
|
export const NATIVE_RESUME_CHECKPOINT_METADATA_KEY = "tangleNativeResumeCheckpointId";
|
|
12
12
|
export function captureModelCredentials(value) {
|
|
@@ -99,9 +99,8 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
99
99
|
? parseBackendType(defaultBackend ?? profile.harness ?? "opencode")
|
|
100
100
|
: input.backend;
|
|
101
101
|
assertNoInlineSecretValues(input, workspace);
|
|
102
|
-
const selectedSecret = modelCredentials === undefined ? undefined
|
|
103
|
-
: "cliAuth" in modelCredentials ? modelCredentials.cliAuth?.secretEnv : modelCredentials.apiKeyEnv;
|
|
104
102
|
const nativeCredentials = modelCredentials !== undefined && "cliAuth" in modelCredentials;
|
|
103
|
+
const selectedSecret = nativeCredentials ? modelCredentials.cliAuth?.secretEnv : modelCredentials?.apiKeyEnv;
|
|
105
104
|
const proxySecrets = mergeProxySecrets(proxySecretsFromInput(input), modelCredentials?.proxySecrets);
|
|
106
105
|
assertProxySecretAliases(proxySecrets, input.env, input.secrets);
|
|
107
106
|
const proxySelected = proxySecrets?.some((binding) => binding.envName === selectedSecret || binding.secretRef.key === selectedSecret) === true ||
|
|
@@ -123,13 +122,11 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
123
122
|
throw new Error("Tangle modelCredentials cannot shadow a stored secret with inline environment data");
|
|
124
123
|
}
|
|
125
124
|
const requestedSecrets = Array.isArray(input.secrets) ? input.secrets : undefined;
|
|
126
|
-
const
|
|
125
|
+
const secrets = input.secrets === "all" ? "all" : selectedSecret !== undefined && !proxySelected
|
|
127
126
|
? [...new Set([...(requestedSecrets ?? []), selectedSecret])]
|
|
128
127
|
: requestedSecrets ?? (proxySecrets === undefined ? undefined : []);
|
|
129
|
-
|
|
130
|
-
if (secrets !== undefined && secrets.length > MAX_ARRAY_LENGTH) {
|
|
128
|
+
if (Array.isArray(secrets) && secrets.length > MAX_ARRAY_LENGTH)
|
|
131
129
|
throw new Error("Tangle selected credential exceeds the stored-secret grant bound");
|
|
132
|
-
}
|
|
133
130
|
const recordsCredential = nativeCredentials || subscriptionSelection;
|
|
134
131
|
if (recordsCredential && Object.hasOwn(input.metadata ?? {}, "modelCredentials")) {
|
|
135
132
|
throw new Error("Tangle credential selection owns metadata.modelCredentials");
|
|
@@ -193,7 +190,8 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
193
190
|
...(resources ? { resources } : {}),
|
|
194
191
|
...(restore ?? {}),
|
|
195
192
|
...(input.env ? { env: input.env } : {}),
|
|
196
|
-
...(
|
|
193
|
+
...(secrets === undefined ? {} : { secrets }),
|
|
194
|
+
...(proxySecrets === undefined ? {} : { proxySecrets }),
|
|
197
195
|
...(input.egress === undefined ? {} : { egressPolicy: sandboxEgressPolicy(input.egress) }),
|
|
198
196
|
...(input.billingOwner === undefined ? {} : { billingOwnerId: input.billingOwner }),
|
|
199
197
|
...(Object.keys(metadata).length > 0 ? { metadata } : {}),
|
|
@@ -228,18 +226,7 @@ export function sandboxRestoreFromCheckpoint(checkpoint) {
|
|
|
228
226
|
fromSandboxId: boundedIdentifier(checkpoint.source.environmentId, "Tangle workspace checkpoint source"),
|
|
229
227
|
};
|
|
230
228
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Project the portable egress policy onto the Sandbox policy.
|
|
233
|
-
*
|
|
234
|
-
* The schema is a strict discriminated union, so a domain list outside `strict` is refused rather
|
|
235
|
-
* than sent: Sandbox IGNORES `allowDomains` in `open` and `blocked` mode, and a silently ignored
|
|
236
|
-
* allowlist is a policy the caller believes is in force and is not.
|
|
237
|
-
*
|
|
238
|
-
* `includeImplicitDomains` stays unset, which is the Sandbox default of false. A strict policy
|
|
239
|
-
* therefore reaches the named domains plus the model endpoints the platform provisioned, matching
|
|
240
|
-
* what {@link AgentEnvironmentEgressPolicy} states; opting in would silently add ~40 hosts,
|
|
241
|
-
* including public source hosts.
|
|
242
|
-
*/
|
|
229
|
+
/** Strict allowlists remain exact; implicit domains stay disabled. */
|
|
243
230
|
function sandboxEgressPolicy(policy) {
|
|
244
231
|
const parsed = AgentEnvironmentEgressPolicySchema.parse(policy);
|
|
245
232
|
if (parsed.mode !== "strict")
|
|
@@ -267,13 +254,31 @@ export function assertNoInlineSecretValues(input, parsedWorkspace) {
|
|
|
267
254
|
throw new Error("Tangle resource providerOptions are not supported");
|
|
268
255
|
}
|
|
269
256
|
}
|
|
270
|
-
|
|
257
|
+
assertMappedSecretNames(input);
|
|
271
258
|
}
|
|
272
|
-
/**
|
|
259
|
+
/** Preserve legacy stored selections while canonical declarations travel separately. */
|
|
273
260
|
export function assertMappedSecretNames(options) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
261
|
+
const { secrets, env } = options;
|
|
262
|
+
if (secrets === undefined || secrets === "all")
|
|
263
|
+
return;
|
|
264
|
+
if (!Array.isArray(secrets) || secrets.length > MAX_ARRAY_LENGTH)
|
|
265
|
+
throw new Error("Tangle secrets require bounded explicit stored selection");
|
|
266
|
+
const selected = new Map();
|
|
267
|
+
for (const entry of secrets) {
|
|
268
|
+
const name = typeof entry === "string" ? entry : entry?.name;
|
|
269
|
+
boundedIdentifier(name, "Tangle stored-secret name");
|
|
270
|
+
if (typeof entry !== "string" && (!entry || Object.hasOwn(env ?? {}, name) || ("host" in entry
|
|
271
|
+
? Object.keys(entry).some((key) => !["name", "host", "header"].includes(key)) ||
|
|
272
|
+
typeof entry.host !== "string" || entry.host.length > 253 ||
|
|
273
|
+
!/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(entry.host) ||
|
|
274
|
+
(entry.header !== undefined && (typeof entry.header !== "string" || !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(entry.header)))
|
|
275
|
+
: Object.keys(entry).some((key) => !["name", "exposeInBox"].includes(key)) || entry.exposeInBox !== true)))
|
|
276
|
+
throw new Error("Invalid or shadowed Tangle secret selection");
|
|
277
|
+
const identity = sandboxSecretBindingIdentity(entry);
|
|
278
|
+
if (selected.has(name) && selected.get(name) !== identity)
|
|
279
|
+
throw new Error("Conflicting Tangle stored-secret selection");
|
|
280
|
+
selected.set(name, identity);
|
|
281
|
+
}
|
|
277
282
|
}
|
|
278
283
|
export function assertCreateInputShape(input, parsedWorkspace) {
|
|
279
284
|
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
@@ -345,9 +350,9 @@ export function assertMappedCreateOptions(options) {
|
|
|
345
350
|
throw new Error("Tangle mapped native credentials must use the exact profile harness");
|
|
346
351
|
}
|
|
347
352
|
const selectedSecret = options.backend.model.cliAuth.secretEnv;
|
|
348
|
-
if (!Array.isArray(options.secrets)
|
|
349
|
-
|
|
350
|
-
|
|
353
|
+
if (options.secrets !== "all" && !(Array.isArray(options.secrets) && options.secrets.some((entry) => (typeof entry === "string" ? entry : entry.name) === selectedSecret)) &&
|
|
354
|
+
!options.proxySecrets?.some((binding) => binding.envName === selectedSecret || binding.secretRef.key === selectedSecret))
|
|
355
|
+
throw new Error("Tangle mapped native credential must retain its stored selection");
|
|
351
356
|
if (Object.hasOwn(options.env ?? {}, selectedSecret)) {
|
|
352
357
|
throw new Error("Tangle mapped native credential cannot shadow a stored secret with inline environment data");
|
|
353
358
|
}
|
package/dist/tangle-provider.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AgentEnvironmentCapabilitiesSchema, AgentEnvironmentGetOptionsSchema, createAgentEnvironmentWithIdempotency, } from "@tangle-network/agent-interface/environment-provider";
|
|
2
2
|
import { canonicalCandidateDigest, deepFreeze, harnessTypeSchema } from "@tangle-network/agent-interface";
|
|
3
|
-
import { createTangleExactProcessProvider
|
|
3
|
+
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 { 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 { captureProxySecrets, mergeProxySecrets, proxySecretsFromInput,
|
|
9
|
+
import { captureProxySecrets, mergeProxySecrets, proxySecretsFromInput, assertProxySecretAliases, sandboxSecretBindingIdentity, PROXY_SECRETS_METADATA_KEY } from "./tangle-proxy-secrets.js";
|
|
10
10
|
import { statusFromUnknown } from "./tangle-environment-values.js";
|
|
11
11
|
import { normalizeTangleBackend } from "./tangle-prompt.js";
|
|
12
12
|
import { requireNativeCaptureCapability, requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
@@ -72,9 +72,6 @@ export function createTangleProvider(options) {
|
|
|
72
72
|
configured = { ...configured, profile: { ...configured.profile },
|
|
73
73
|
...(configured.create === undefined ? {} : { create: { ...configured.create } }),
|
|
74
74
|
};
|
|
75
|
-
delete configured.profile.proxySecrets;
|
|
76
|
-
if (configured.create !== undefined)
|
|
77
|
-
delete configured.create.proxySecrets;
|
|
78
75
|
if (configured.create?.workspaceSnapshot === true) {
|
|
79
76
|
throw new Error("Tangle provider does not support portable workspace snapshots in this receiver deployment");
|
|
80
77
|
}
|
|
@@ -112,7 +109,9 @@ export function createTangleProvider(options) {
|
|
|
112
109
|
throw new Error("Tangle owns metadata.tangleProxySecrets");
|
|
113
110
|
}
|
|
114
111
|
const requestedProxySecrets = proxySecretsFromInput(input);
|
|
115
|
-
|
|
112
|
+
assertProxySecretAliases(requestedProxySecrets, input.env, input.secrets);
|
|
113
|
+
const requestedSecrets = structuredClone(Array.isArray(input.secrets) ? input.secrets : undefined);
|
|
114
|
+
const requestedReason = requestedSecrets?.some((entry) => typeof entry !== "string" && "exposeInBox" in entry) ? input.metadata?.reason : undefined;
|
|
116
115
|
const credentialSource = typeof input.profile === "string" ? "managed" : profileCredentialSource(input.profile);
|
|
117
116
|
const subscription = credentialSource === "subscription";
|
|
118
117
|
if (Object.hasOwn(input.metadata ?? {}, "modelCredentials")) {
|
|
@@ -140,12 +139,13 @@ export function createTangleProvider(options) {
|
|
|
140
139
|
const mappedInput = mapCreateInput?.(input) ??
|
|
141
140
|
(subscription && resolveModelCredentials !== undefined ? sandboxOptionsFromCreateInput(input, options.defaultBackend, parsedWorkspace, selectedCredentials, true) : defaultOptions);
|
|
142
141
|
const selectedProxySecrets = mergeProxySecrets(requestedProxySecrets, selectedCredentials?.proxySecrets);
|
|
143
|
-
|
|
142
|
+
const mappedProxySecrets = mergeProxySecrets(selectedProxySecrets, proxySecretsFromInput({ profile: mappedInput.backend?.profile ?? {}, proxySecrets: mappedInput.proxySecrets }));
|
|
143
|
+
if (canonicalCandidateDigest(mappedProxySecrets ?? []) !== canonicalCandidateDigest(selectedProxySecrets ?? []))
|
|
144
144
|
throw new Error("Tangle mapped proxy-secret declarations differ from the requested bindings");
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
const mappedOptions = { ...mappedInput, backend: normalizeTangleBackend(mappedInput.backend, true), ...(selectedProxySecrets === undefined ? {} : { proxySecrets: selectedProxySecrets }) };
|
|
146
|
+
assertProxySecretAliases(selectedProxySecrets, mappedOptions.env, mappedOptions.secrets);
|
|
147
|
+
if (input.secrets === "all" && mappedOptions.secrets !== "all")
|
|
148
|
+
throw new Error("Tangle mapped secrets must preserve all selection");
|
|
149
149
|
for (const entry of requestedSecrets ?? []) {
|
|
150
150
|
if (typeof entry === "string")
|
|
151
151
|
continue;
|
|
@@ -153,6 +153,8 @@ export function createTangleProvider(options) {
|
|
|
153
153
|
throw new Error("Tangle mapped secrets must preserve the requested delivery selection");
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
if (requestedReason !== undefined && canonicalCandidateDigest(mappedOptions.metadata?.reason ?? null) !== canonicalCandidateDigest(requestedReason))
|
|
157
|
+
throw new Error("Tangle mapped raw consent must preserve its named reason");
|
|
156
158
|
assertMappedCreateOptions(mappedOptions);
|
|
157
159
|
const mappedRouting = mappedOptions.backend?.model?.routing;
|
|
158
160
|
if (canonicalCandidateDigest(mappedRouting ?? null) !== canonicalCandidateDigest(requestedRouting ?? null)) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type CreateAgentEnvironmentInput, type ProxySecretBinding } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
-
import type { TangleCreateSandboxOptions } from "./tangle-types.js";
|
|
3
2
|
/** Provider-owned public declarations bind recovery; they contain no authority or values. */
|
|
4
3
|
export declare const PROXY_SECRETS_METADATA_KEY = "tangleProxySecrets";
|
|
5
4
|
export declare function captureProxySecrets(value: unknown): ProxySecretBinding[];
|
|
6
5
|
export declare function proxySecretsFromInput(input: CreateAgentEnvironmentInput): ProxySecretBinding[] | undefined;
|
|
7
6
|
export declare function mergeProxySecrets(requested: ProxySecretBinding[] | undefined, selected: ProxySecretBinding[] | undefined): ProxySecretBinding[] | undefined;
|
|
8
7
|
export declare function assertProxySecretAliases(bindings: ProxySecretBinding[] | undefined, env: Record<string, string> | undefined, secrets: unknown): void;
|
|
9
|
-
/**
|
|
10
|
-
export declare function sandboxSecretBindings(secrets: CreateAgentEnvironmentInput["secrets"] | "all", bindings?: readonly ProxySecretBinding[], env?: Record<string, string>): Exclude<TangleCreateSandboxOptions["secrets"], "all">;
|
|
8
|
+
/** Legacy selection identity stays at the compatibility boundary. */
|
|
11
9
|
export declare const sandboxSecretBindingIdentity: (entry: Extract<CreateAgentEnvironmentInput["secrets"], unknown[]>[number]) => string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ProxySecretsSchema, mergeProxySecretBindings } from "@tangle-network/agent-interface/environment-provider";
|
|
2
2
|
import { canonicalCandidateDigest, deepFreeze } from "@tangle-network/agent-interface";
|
|
3
|
-
import { boundedIdentifier, MAX_ARRAY_LENGTH } from "./tangle-contract-safety.js";
|
|
4
3
|
/** Provider-owned public declarations bind recovery; they contain no authority or values. */
|
|
5
4
|
export const PROXY_SECRETS_METADATA_KEY = "tangleProxySecrets";
|
|
6
5
|
export function captureProxySecrets(value) {
|
|
@@ -17,52 +16,23 @@ export function mergeProxySecrets(requested, selected) {
|
|
|
17
16
|
? undefined : deepFreeze(mergeProxySecretBindings(requested, selected));
|
|
18
17
|
}
|
|
19
18
|
export function assertProxySecretAliases(bindings, env, secrets) {
|
|
20
|
-
if (bindings !== undefined && secrets !== undefined && !Array.isArray(secrets))
|
|
21
|
-
throw new Error("Tangle proxy-secret custody cannot use all or raw readable secret selection");
|
|
22
19
|
for (const binding of bindings ?? []) {
|
|
23
20
|
for (const alias of [binding.envName, binding.secretRef.key]) {
|
|
24
|
-
if (Object.hasOwn(env ?? {}, alias) || (Array.isArray(secrets) && secrets.some((entry) =>
|
|
25
|
-
|
|
21
|
+
if (Object.hasOwn(env ?? {}, alias) || (Array.isArray(secrets) && secrets.some((entry) => {
|
|
22
|
+
if (typeof entry === "string" || entry?.name !== alias)
|
|
23
|
+
return false;
|
|
24
|
+
if ("exposeInBox" in entry)
|
|
25
|
+
return true;
|
|
26
|
+
if (!("host" in entry))
|
|
27
|
+
return false;
|
|
28
|
+
const header = (entry.header ?? "Authorization").toLowerCase();
|
|
29
|
+
return !binding.hosts.includes(entry.host) || binding.presentation.type === "query" ||
|
|
30
|
+
header !== (binding.presentation.type === "header" ? binding.presentation.name.toLowerCase() : "authorization");
|
|
31
|
+
}))) {
|
|
32
|
+
throw new Error("Tangle proxy-secret scope conflicts with readable or legacy delivery");
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
/**
|
|
31
|
-
export function sandboxSecretBindings(secrets, bindings, env) {
|
|
32
|
-
assertProxySecretAliases(bindings === undefined ? undefined : [...bindings], env, secrets);
|
|
33
|
-
const lowered = (bindings ?? []).map((binding) => {
|
|
34
|
-
if (binding.hosts.length !== 1 || binding.methods !== undefined || binding.paths !== undefined ||
|
|
35
|
-
binding.presentation.type === "query" || binding.placeholderFormat === "jwt" ||
|
|
36
|
-
binding.ttlSeconds !== undefined || binding.envName !== binding.secretRef.key) {
|
|
37
|
-
throw new Error("Tangle host bindings cannot enforce aliases, multiple hosts, methods, paths, query, jwt or expiry");
|
|
38
|
-
}
|
|
39
|
-
return { name: binding.secretRef.key, host: binding.hosts[0],
|
|
40
|
-
header: binding.presentation.type === "header" ? binding.presentation.name : "Authorization" };
|
|
41
|
-
});
|
|
42
|
-
if (secrets === undefined && bindings === undefined)
|
|
43
|
-
return undefined;
|
|
44
|
-
if (secrets !== undefined && !Array.isArray(secrets))
|
|
45
|
-
throw new Error("Tangle secrets must be stored names or host bindings");
|
|
46
|
-
const entries = new Map();
|
|
47
|
-
for (const entry of [...(secrets ?? []), ...lowered]) {
|
|
48
|
-
const name = typeof entry === "string" ? entry : entry.name;
|
|
49
|
-
boundedIdentifier(name, "Tangle stored-secret name");
|
|
50
|
-
if (typeof entry !== "string") {
|
|
51
|
-
if (("host" in entry ? Object.keys(entry).some((key) => !["name", "host", "header"].includes(key)) ||
|
|
52
|
-
typeof entry.host !== "string" || entry.host.length > 253 ||
|
|
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) ||
|
|
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
|
-
Object.hasOwn(env ?? {}, name))
|
|
57
|
-
throw new Error("Invalid or shadowed Tangle secret selection");
|
|
58
|
-
}
|
|
59
|
-
const previous = entries.get(name);
|
|
60
|
-
if (previous !== undefined && sandboxSecretBindingIdentity(previous) !== sandboxSecretBindingIdentity(entry))
|
|
61
|
-
throw new Error("Conflicting Tangle secret delivery");
|
|
62
|
-
entries.set(name, entry);
|
|
63
|
-
}
|
|
64
|
-
if (entries.size > MAX_ARRAY_LENGTH)
|
|
65
|
-
throw new Error("Tangle stored-secret selection exceeds its bound");
|
|
66
|
-
return [...entries.values()];
|
|
67
|
-
}
|
|
37
|
+
/** Legacy selection identity stays at the compatibility boundary. */
|
|
68
38
|
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
|
@@ -24,12 +24,12 @@ export interface SandboxCreateReceiptLike {
|
|
|
24
24
|
export interface TangleExactProcessOptions {
|
|
25
25
|
teamId?: string;
|
|
26
26
|
}
|
|
27
|
-
export type TangleCreateSandboxOptions = Omit<CreateSandboxOptions, "secrets" | "backend"> & {
|
|
27
|
+
export type TangleCreateSandboxOptions = Omit<CreateSandboxOptions, "secrets" | "backend" | "proxySecrets"> & {
|
|
28
28
|
backend?: BackendConfig & Omit<NonNullable<BackendConfig["model"]>, "model"> & {
|
|
29
29
|
modelId?: string;
|
|
30
30
|
};
|
|
31
31
|
secrets?: "all" | Extract<CreateAgentEnvironmentInput["secrets"], unknown[]>;
|
|
32
|
-
proxySecrets?:
|
|
32
|
+
proxySecrets?: CreateAgentEnvironmentInput["proxySecrets"];
|
|
33
33
|
};
|
|
34
34
|
export interface SandboxClientLike {
|
|
35
35
|
readonly secrets?: AgentEnvironmentProvider["secrets"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
36
|
+
"@tangle-network/agent-interface": "^5.10.9"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tangle-network/sandbox": ">=0.
|
|
39
|
+
"@tangle-network/sandbox": ">=1.0.111 <2.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.1",
|
|
48
48
|
"@tangle-network/agent-runtime": "0.349.0",
|
|
49
|
-
"@tangle-network/sandbox": "0.
|
|
49
|
+
"@tangle-network/sandbox": "1.0.111",
|
|
50
50
|
"@types/node": "26.6.5",
|
|
51
51
|
"typescript": "6.0.3",
|
|
52
52
|
"vitest": "5.0.5"
|