@tangle-network/agent-provider-tangle 5.0.1 → 5.0.3
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/exact-process.js
CHANGED
|
@@ -182,10 +182,6 @@ function exactSandboxOptions(input, defaults, providerName, identityDigest) {
|
|
|
182
182
|
input.provisionTimeoutMs < 1)) {
|
|
183
183
|
throw new Error("exact process provisionTimeoutMs must be a positive integer");
|
|
184
184
|
}
|
|
185
|
-
if (input.egress.mode === "strict" &&
|
|
186
|
-
input.egress.allowDomains.length === 0) {
|
|
187
|
-
throw new Error("strict exact process egress requires at least one domain");
|
|
188
|
-
}
|
|
189
185
|
const resources = sandboxResourcesFromRequest(input.resources);
|
|
190
186
|
return {
|
|
191
187
|
environment: input.image,
|
|
@@ -200,7 +196,7 @@ function exactSandboxOptions(input, defaults, providerName, identityDigest) {
|
|
|
200
196
|
? { mode: "blocked" }
|
|
201
197
|
: {
|
|
202
198
|
mode: "strict",
|
|
203
|
-
allowDomains:
|
|
199
|
+
allowDomains: input.egress.allowDomains.map((e) => typeof e === "string" ? e : { ...e, allowPrivateIps: [...e.allowPrivateIps] }),
|
|
204
200
|
includeImplicitDomains: false,
|
|
205
201
|
},
|
|
206
202
|
maxLifetimeSeconds: input.maxLifetimeMs / 1_000,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
1
|
+
import { AgentEnvironmentEgressAllowDomainSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
2
2
|
export const MAX_EXACT_FILE_BYTES = 64 * 1024 * 1024;
|
|
3
3
|
export const MAX_LIST_RESULTS = 100_000;
|
|
4
4
|
/** Sandbox caps list responses at 1,000 resources. */
|
|
@@ -50,6 +50,8 @@ export const MAX_INLINE_PAYLOAD_BYTES = 1024 * 1024 - 8 * 1024;
|
|
|
50
50
|
*/
|
|
51
51
|
export const MAX_TOTAL_PAYLOAD_BYTES = 64 * 1024 * 1024;
|
|
52
52
|
export const MAX_ARRAY_LENGTH = 1_024;
|
|
53
|
+
/** Strict exact-process egress: the interface entry shape, one to {@link MAX_ARRAY_LENGTH} entries. */
|
|
54
|
+
const EXACT_PROCESS_ALLOW_DOMAINS = AgentEnvironmentEgressAllowDomainSchema.array().min(1).max(MAX_ARRAY_LENGTH);
|
|
53
55
|
export const MAX_MAP_ENTRIES = 256;
|
|
54
56
|
export const MAX_JSON_DEPTH = 16;
|
|
55
57
|
export const MAX_JSON_NODES = 8_192;
|
|
@@ -438,17 +440,9 @@ export function validateExactProcessCreateInput(input, providerName, options) {
|
|
|
438
440
|
throw new Error("strict exact process egress has unsupported fields");
|
|
439
441
|
}
|
|
440
442
|
if (input.egress.mode === "strict") {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if (input.egress.allowDomains.length > MAX_ARRAY_LENGTH) {
|
|
445
|
-
throw new Error("exact process egress allowDomains has too many entries");
|
|
446
|
-
}
|
|
447
|
-
if (input.egress.allowDomains.length === 0) {
|
|
448
|
-
throw new Error("strict exact process egress requires at least one domain");
|
|
449
|
-
}
|
|
450
|
-
for (const domain of input.egress.allowDomains) {
|
|
451
|
-
boundedIdentifier(domain, "exact process egress domain");
|
|
443
|
+
// The interface schema owns the entry shape; strict exact egress also needs one entry.
|
|
444
|
+
if (!EXACT_PROCESS_ALLOW_DOMAINS.safeParse(input.egress.allowDomains).success) {
|
|
445
|
+
throw new Error("strict exact process egress requires one to 1024 valid allowDomains entries");
|
|
452
446
|
}
|
|
453
447
|
}
|
|
454
448
|
if (!Number.isSafeInteger(input.maxLifetimeMs) ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertCliAuthReferenceSupported, cliAuthReferenceSchema, } from "@tangle-network/sandbox/auth";
|
|
2
2
|
import { parseBackendType, } from "@tangle-network/sandbox";
|
|
3
|
-
import { AgentEnvironmentEgressPolicySchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface/environment-provider";
|
|
3
|
+
import { AgentEnvironmentEgressAllowDomainSchema, AgentEnvironmentEgressPolicySchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface/environment-provider";
|
|
4
4
|
import { assertBoundedJson, boundedIdentifier, boundedString, MAX_ARRAY_LENGTH, MAX_MAP_ENTRIES, PROFILE_AT_BACKEND_PROFILE, PROFILE_AT_ROOT, } from "./tangle-contract-safety.js";
|
|
5
5
|
import { profileCredentialSource } from "./model-credential-source.js";
|
|
6
6
|
import { sandboxResourcesFromResourceRequest } from "./tangle-resources.js";
|
|
@@ -199,7 +199,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
199
199
|
...(input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey }),
|
|
200
200
|
backend: {
|
|
201
201
|
type: backend,
|
|
202
|
-
profile,
|
|
202
|
+
profile: profile,
|
|
203
203
|
...(modelCredentials === undefined ? {} : {
|
|
204
204
|
model: "cliAuth" in modelCredentials
|
|
205
205
|
? { cliAuth: modelCredentials.cliAuth, authMode: "oauth" } : { apiKeyEnv: modelCredentials.apiKeyEnv, baseUrl: modelCredentials.baseUrl },
|
|
@@ -383,18 +383,11 @@ export function assertMappedCreateOptions(options) {
|
|
|
383
383
|
throw new Error("Tangle mapped egress policy allows domains only in strict mode");
|
|
384
384
|
}
|
|
385
385
|
// The default path is schema-checked, so this gate holds a custom mapper to the same shape.
|
|
386
|
-
// A
|
|
386
|
+
// A malformed or padded host reaches the platform, matches nothing, and leaves the caller
|
|
387
387
|
// believing an allowlist is in force that is not.
|
|
388
|
-
if (options.egressPolicy.allowDomains !== undefined
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
if (options.egressPolicy.allowDomains.length > MAX_ARRAY_LENGTH) {
|
|
393
|
-
throw new Error("Tangle mapped egress allowed domains exceed their bound");
|
|
394
|
-
}
|
|
395
|
-
for (const domain of options.egressPolicy.allowDomains) {
|
|
396
|
-
boundedIdentifier(domain, "Tangle mapped egress allowed domain");
|
|
397
|
-
}
|
|
388
|
+
if (options.egressPolicy.allowDomains !== undefined &&
|
|
389
|
+
!AgentEnvironmentEgressAllowDomainSchema.array().max(MAX_ARRAY_LENGTH).safeParse(options.egressPolicy.allowDomains).success) {
|
|
390
|
+
throw new Error("Tangle mapped egress allowed domain is invalid");
|
|
398
391
|
}
|
|
399
392
|
}
|
|
400
393
|
if (options.env !== undefined)
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -89,6 +89,13 @@ function containsProxyReceipt(full, subset) {
|
|
|
89
89
|
return full.sandboxId === subset.sandboxId && full.generation === subset.generation &&
|
|
90
90
|
subset.bindings.every((binding) => full.bindings.some((member) => canonicalCandidateDigest(member) === canonicalCandidateDigest(binding)));
|
|
91
91
|
}
|
|
92
|
+
/** The sidecar's answer when it serves no public revision root: 409 with this exact text. Any other prepare failure stays an error. */
|
|
93
|
+
function publicPreparationRefusal(error) {
|
|
94
|
+
if (error instanceof Error && error.status === 409 &&
|
|
95
|
+
error.message.includes("Concurrent public profile materialization is disabled"))
|
|
96
|
+
return undefined;
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
92
99
|
/** Prepare one exact launch; legacy and cursor replay retain their existing path. */
|
|
93
100
|
export async function preparePromptOptions(box, options, provider, bindings) {
|
|
94
101
|
if (options.lastEventId !== undefined)
|
|
@@ -122,7 +129,10 @@ export async function preparePromptOptions(box, options, provider, bindings) {
|
|
|
122
129
|
validatePrepared(prepared.proxySecretReceipt);
|
|
123
130
|
}
|
|
124
131
|
else {
|
|
125
|
-
const prepared = await awaitWithSignal(box.preparePublicProfileRevision(args), options.signal);
|
|
132
|
+
const prepared = await awaitWithSignal(box.preparePublicProfileRevision(args), options.signal).catch(publicPreparationRefusal);
|
|
133
|
+
// A sidecar with no public revision root refuses every prepare, so its launch runs unprepared in the session just created.
|
|
134
|
+
if (prepared === undefined)
|
|
135
|
+
return { ...options, sessionId, backend };
|
|
126
136
|
options = { ...options, sessionId, backend, expectedPublicProfileRequestDigest: prepared.expectedPublicProfileRequestDigest, expectedPublicProfileRevision: prepared.expectedPublicProfileRevision };
|
|
127
137
|
validatePrepared(prepared.proxySecretReceipt);
|
|
128
138
|
}
|
|
@@ -255,10 +265,8 @@ function sandboxPromptBackendModel(value) {
|
|
|
255
265
|
model[field] = boundedString(present[field], `Tangle prompt backend model ${field}`);
|
|
256
266
|
}
|
|
257
267
|
if (present.maxThinkingTokens !== undefined) {
|
|
258
|
-
if (!Number.isSafeInteger(present.maxThinkingTokens) ||
|
|
259
|
-
present.maxThinkingTokens < 0) {
|
|
268
|
+
if (!Number.isSafeInteger(present.maxThinkingTokens) || present.maxThinkingTokens < 0)
|
|
260
269
|
throw new Error("Tangle prompt backend model maxThinkingTokens must be a non-negative integer");
|
|
261
|
-
}
|
|
262
270
|
model.maxThinkingTokens = present.maxThinkingTokens;
|
|
263
271
|
}
|
|
264
272
|
if (present.mode !== undefined) {
|
|
@@ -268,9 +276,8 @@ function sandboxPromptBackendModel(value) {
|
|
|
268
276
|
model.mode = present.mode;
|
|
269
277
|
}
|
|
270
278
|
if (present.authMode !== undefined) {
|
|
271
|
-
if (present.authMode !== "api-key" && present.authMode !== "oauth")
|
|
279
|
+
if (present.authMode !== "api-key" && present.authMode !== "oauth")
|
|
272
280
|
throw new Error('Tangle prompt backend model authMode must be "api-key" or "oauth"');
|
|
273
|
-
}
|
|
274
281
|
model.authMode = present.authMode;
|
|
275
282
|
}
|
|
276
283
|
if (present.authFiles !== undefined) {
|
|
@@ -289,11 +296,8 @@ function sandboxPromptBackendServer(value) {
|
|
|
289
296
|
assertDeclaredFields(present, new Set(["port", "hostname"]), "Tangle prompt backend server options");
|
|
290
297
|
const server = {};
|
|
291
298
|
if (present.port !== undefined) {
|
|
292
|
-
if (!Number.isSafeInteger(present.port) ||
|
|
293
|
-
present.port < 1 ||
|
|
294
|
-
present.port > 65_535) {
|
|
299
|
+
if (!Number.isSafeInteger(present.port) || present.port < 1 || present.port > 65_535)
|
|
295
300
|
throw new Error("Tangle prompt backend server port must be a TCP port number");
|
|
296
|
-
}
|
|
297
301
|
server.port = present.port;
|
|
298
302
|
}
|
|
299
303
|
if (present.hostname !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
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.10"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tangle-network/sandbox": ">=1.0.
|
|
39
|
+
"@tangle-network/sandbox": ">=1.0.141 <2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@tangle-network/sandbox": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tangle-network/agent-provider-testkit": "0.12.
|
|
47
|
+
"@tangle-network/agent-provider-testkit": "0.12.2",
|
|
48
48
|
"@tangle-network/agent-runtime": "0.349.0",
|
|
49
|
-
"@tangle-network/sandbox": "1.0.
|
|
49
|
+
"@tangle-network/sandbox": "1.0.141",
|
|
50
50
|
"@types/node": "26.6.5",
|
|
51
51
|
"typescript": "6.0.3",
|
|
52
52
|
"vitest": "5.0.5"
|