@tangle-network/agent-provider-tangle 3.3.0 → 3.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 CHANGED
@@ -30,6 +30,12 @@ const provider = createTangleProvider({
30
30
  `Sandbox` requires an explicit `baseUrl`.
31
31
  Set `TANGLE_SANDBOX_URL` to use another deployment.
32
32
 
33
+ `AgentTurnInput.profile` carries the exact per-turn profile, including mounted file contents larger than the metadata limit.
34
+ The adapter projects it into Sandbox's backend profile and enforces the existing file, inline-payload, and aggregate limits.
35
+ Previously valid `providerOptions.backend.profile` inputs remain supported.
36
+ If both locations are supplied, their canonical profile digests must match; a conflict refuses dispatch before credential selection.
37
+ Use the typed field for large profiles; generic provider metadata keeps its existing limits.
38
+
33
39
  Exact execution replay preserves the admitted request and its digest.
34
40
  An explicit replay override cannot replace the selected account, credential channel, or harness.
35
41
 
@@ -1,7 +1,7 @@
1
1
  import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
2
- import { backendFromTurnProviderOptions, backendRequestIdentity, } from "./tangle-prompt.js";
2
+ import { backendFromTurnInput, backendRequestIdentity, } from "./tangle-prompt.js";
3
3
  export function sessionPromptRequestDigest(input, provider, environmentId, sessionId, options = {}) {
4
- const backend = backendRequestIdentity(backendFromTurnProviderOptions(input.providerOptions));
4
+ const backend = backendRequestIdentity(backendFromTurnInput(input));
5
5
  return canonicalCandidateDigest({
6
6
  provider,
7
7
  environmentId,
@@ -29,7 +29,8 @@ export function sessionPromptRequestDigest(input, provider, environmentId, sessi
29
29
  });
30
30
  }
31
31
  export function hasReplayPayload(input) {
32
- return (input.prompt !== undefined ||
32
+ return (input.profile !== undefined ||
33
+ input.prompt !== undefined ||
33
34
  input.parts !== undefined ||
34
35
  input.model !== undefined ||
35
36
  input.timeoutMs !== undefined ||
@@ -184,11 +184,14 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
184
184
  // Validate explicit substitutions even on replay, without rewriting its admitted digest.
185
185
  if (replay)
186
186
  return input;
187
+ const { profile: _profile, ...backendOptions } = backend ?? {};
187
188
  return {
188
189
  ...input,
189
190
  providerOptions: {
190
191
  ...input.providerOptions,
191
- backend: { ...backend, type: harness, model: { ...selectedModel, authMode: "oauth" } },
192
+ // The next validation still sees bounded options, while projection reads
193
+ // the exact typed profile again for the actual SDK dispatch.
194
+ backend: { ...(input.profile === undefined ? backend : backendOptions), type: harness, model: { ...selectedModel, authMode: "oauth" } },
192
195
  },
193
196
  };
194
197
  };
@@ -73,6 +73,8 @@ export declare function backendFromTurnProviderOptions(providerOptions: Record<s
73
73
  * identity to the secret inside.
74
74
  */
75
75
  export declare function backendRequestIdentity(backend: SandboxPromptBackend | undefined): Record<string, unknown> | undefined;
76
+ /** Project the exact turn profile once for both dispatch and retained identity. */
77
+ export declare function backendFromTurnInput(input: AgentTurnInput): SandboxPromptBackend | undefined;
76
78
  type SandboxRunStatus = "success" | "failed" | "blocked_on_approval" | "awaiting_question" | "awaiting_interaction" | "awaiting_plan_decision";
77
79
  type ValidatedSandboxPromptResult = Record<string, unknown> & {
78
80
  success: boolean;
@@ -1,5 +1,5 @@
1
1
  import { assertCliAuthReferenceSupported, cliAuthReferenceSchema, } from "@tangle-network/sandbox/auth";
2
- import { agentProfileSchema, CONTRACT_MAX_JSON_BYTES, boundedEventContentRecordSchema, isBoundedEventContentJson, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, contextTransferResultMatchesRequest, } from "@tangle-network/agent-interface";
2
+ import { agentProfileSchema, canonicalAgentProfileDigest, CONTRACT_MAX_JSON_BYTES, boundedEventContentRecordSchema, isBoundedEventContentJson, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, contextTransferResultMatchesRequest, } from "@tangle-network/agent-interface";
3
3
  import { tokenUsageFromData } from "./tangle-result-values.js";
4
4
  import { assertBoundedJson, boundedString, PROFILE_AT_PROFILE, } from "./tangle-contract-safety.js";
5
5
  import { profileCredentialSource } from "./model-credential-source.js";
@@ -349,6 +349,24 @@ export function backendRequestIdentity(backend) {
349
349
  },
350
350
  };
351
351
  }
352
+ /** Project the exact turn profile once for both dispatch and retained identity. */
353
+ export function backendFromTurnInput(input) {
354
+ const declared = backendFromTurnProviderOptions(input.providerOptions);
355
+ let backend = declared;
356
+ if (input.profile !== undefined) {
357
+ if (declared?.profile !== undefined &&
358
+ canonicalAgentProfileDigest(declared.profile) !== canonicalAgentProfileDigest(input.profile)) {
359
+ throw new Error("Tangle turn profile conflicts with its backend profile");
360
+ }
361
+ if (declared?.type !== undefined && input.profile.harness !== undefined && declared.type !== input.profile.harness) {
362
+ throw new Error("Tangle turn profile conflicts with its backend harness");
363
+ }
364
+ // Validate the complete projected backend, including the existing file/inline
365
+ // payload bounds. The typed profile never becomes provider metadata.
366
+ backend = sandboxPromptBackend({ ...declared, profile: input.profile });
367
+ }
368
+ return backend;
369
+ }
352
370
  /**
353
371
  * Combine the turn's requested interaction posture with its backend options.
354
372
  *
@@ -359,7 +377,7 @@ export function backendRequestIdentity(backend) {
359
377
  * posture the caller did not ask for.
360
378
  */
361
379
  function turnBackendOptions(input) {
362
- const backend = backendFromTurnProviderOptions(input.providerOptions);
380
+ const backend = backendFromTurnInput(input);
363
381
  const backendModel = backend?.model?.model;
364
382
  if (input.model !== undefined &&
365
383
  backendModel !== undefined &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -120,7 +120,7 @@
120
120
  "dist/model-credential-capacity.d.ts"
121
121
  ],
122
122
  "dependencies": {
123
- "@tangle-network/agent-interface": "^2.15.0"
123
+ "@tangle-network/agent-interface": "^2.17.0"
124
124
  },
125
125
  "peerDependencies": {
126
126
  "@tangle-network/sandbox": ">=0.58.7 <1.0.0"