@tangle-network/agent-provider-tangle 5.0.2 → 5.0.4

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.
@@ -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 },
@@ -5,7 +5,7 @@ import { assertCliAuthReferenceSupported, cliAuthReferenceSchema, } from "@tangl
5
5
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, boundedEventContentRecordSchema, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, ProxySecretReceiptSchema, deepFreeze, isProxySecretScopeAttenuation, proxySecretPresentationsEqual, 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
- import { assertBoundedJson, awaitWithSignal, boundedString, PROFILE_AT_PROFILE, } from "./tangle-contract-safety.js";
8
+ import { assertBoundedJson, awaitWithSignal, boundedString, MAX_INLINE_PAYLOAD_BYTES, PROFILE_AT_PROFILE, } from "./tangle-contract-safety.js";
9
9
  import { profileCredentialSource } from "./model-credential-source.js";
10
10
  import { tangleRuntimeAttachments } from "./tangle-runtime-attachments.js";
11
11
  import { sessionPromptSessionId } from "./tangle-session-control.js";
@@ -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)
@@ -111,6 +118,9 @@ export async function preparePromptOptions(box, options, provider, bindings) {
111
118
  const sessionId = options.sessionId ?? sessionPromptSessionId(provider, box.id, options.turnId ?? options.executionId) ?? randomUUID();
112
119
  const backend = isolated ? { ...options.backend, metadata: { ...options.backend?.metadata, profileSecretIsolation: true } } : options.backend ?? {};
113
120
  const { runtimeSecrets: _turnOnly, ...persisted } = backend;
121
+ // createSession posts the whole backend unprimed, so a native turn whose profile exceeds the gateway bound cannot be prepared: it launches unprepared, and the SDK stages the profile's files like create-time mounts.
122
+ if (!isolated && new TextEncoder().encode(JSON.stringify(persisted)).length > MAX_INLINE_PAYLOAD_BYTES)
123
+ return options;
114
124
  const created = await awaitWithSignal(box.createSession({ sessionId, retention: "workspace", backend: persisted }), options.signal);
115
125
  if (created.session.id !== sessionId || created.info.id !== sessionId)
116
126
  throw new Error("Tangle profile preparation changed its exact session identity");
@@ -122,7 +132,10 @@ export async function preparePromptOptions(box, options, provider, bindings) {
122
132
  validatePrepared(prepared.proxySecretReceipt);
123
133
  }
124
134
  else {
125
- const prepared = await awaitWithSignal(box.preparePublicProfileRevision(args), options.signal);
135
+ const prepared = await awaitWithSignal(box.preparePublicProfileRevision(args), options.signal).catch(publicPreparationRefusal);
136
+ // A sidecar with no public revision root refuses every prepare, so its launch runs unprepared in the session just created.
137
+ if (prepared === undefined)
138
+ return { ...options, sessionId, backend };
126
139
  options = { ...options, sessionId, backend, expectedPublicProfileRequestDigest: prepared.expectedPublicProfileRequestDigest, expectedPublicProfileRevision: prepared.expectedPublicProfileRevision };
127
140
  validatePrepared(prepared.proxySecretReceipt);
128
141
  }
@@ -255,22 +268,18 @@ function sandboxPromptBackendModel(value) {
255
268
  model[field] = boundedString(present[field], `Tangle prompt backend model ${field}`);
256
269
  }
257
270
  if (present.maxThinkingTokens !== undefined) {
258
- if (!Number.isSafeInteger(present.maxThinkingTokens) ||
259
- present.maxThinkingTokens < 0) {
271
+ if (!Number.isSafeInteger(present.maxThinkingTokens) || present.maxThinkingTokens < 0)
260
272
  throw new Error("Tangle prompt backend model maxThinkingTokens must be a non-negative integer");
261
- }
262
273
  model.maxThinkingTokens = present.maxThinkingTokens;
263
274
  }
264
275
  if (present.mode !== undefined) {
265
- if (present.mode !== "api" && present.mode !== "cli") {
276
+ if (present.mode !== "api" && present.mode !== "cli")
266
277
  throw new Error('Tangle prompt backend model mode must be "api" or "cli"');
267
- }
268
278
  model.mode = present.mode;
269
279
  }
270
280
  if (present.authMode !== undefined) {
271
- if (present.authMode !== "api-key" && present.authMode !== "oauth") {
281
+ if (present.authMode !== "api-key" && present.authMode !== "oauth")
272
282
  throw new Error('Tangle prompt backend model authMode must be "api-key" or "oauth"');
273
- }
274
283
  model.authMode = present.authMode;
275
284
  }
276
285
  if (present.authFiles !== undefined) {
@@ -289,17 +298,13 @@ function sandboxPromptBackendServer(value) {
289
298
  assertDeclaredFields(present, new Set(["port", "hostname"]), "Tangle prompt backend server options");
290
299
  const server = {};
291
300
  if (present.port !== undefined) {
292
- if (!Number.isSafeInteger(present.port) ||
293
- present.port < 1 ||
294
- present.port > 65_535) {
301
+ if (!Number.isSafeInteger(present.port) || present.port < 1 || present.port > 65_535)
295
302
  throw new Error("Tangle prompt backend server port must be a TCP port number");
296
- }
297
303
  server.port = present.port;
298
304
  }
299
305
  if (present.hostname !== undefined) {
300
- if (typeof present.hostname !== "string" || present.hostname === "") {
306
+ if (typeof present.hostname !== "string" || present.hostname === "")
301
307
  throw new Error("Tangle prompt backend server hostname must be a non-empty string");
302
- }
303
308
  server.hostname = boundedString(present.hostname, "Tangle prompt backend server hostname");
304
309
  }
305
310
  return server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,7 +44,7 @@
44
44
  }
45
45
  },
46
46
  "devDependencies": {
47
- "@tangle-network/agent-provider-testkit": "0.12.1",
47
+ "@tangle-network/agent-provider-testkit": "0.12.3",
48
48
  "@tangle-network/agent-runtime": "0.349.0",
49
49
  "@tangle-network/sandbox": "1.0.141",
50
50
  "@types/node": "26.6.5",