@tangle-network/agent-provider-tangle 3.2.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 +26 -9
- package/dist/tangle-deployment-capabilities.d.ts +1 -0
- package/dist/tangle-deployment-capabilities.js +3 -0
- package/dist/tangle-environment-control.js +4 -3
- package/dist/tangle-environment-session.d.ts +1 -1
- package/dist/tangle-environment-session.js +2 -1
- package/dist/tangle-environment.d.ts +2 -1
- package/dist/tangle-environment.js +49 -7
- package/dist/tangle-prompt.d.ts +2 -0
- package/dist/tangle-prompt.js +20 -2
- package/dist/tangle-provider.js +2 -0
- package/dist/tangle-types.d.ts +12 -1
- package/package.json +3 -3
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
|
|
|
@@ -55,7 +61,7 @@ An unsupported downloader or incomplete transfer fails capture and preserves the
|
|
|
55
61
|
`modelCredentials` sends a stored credential reference and explicit endpoint before Sandbox provisions the backend.
|
|
56
62
|
This uses Sandbox's existing caller-owned model credential path instead of requesting a managed Router credential.
|
|
57
63
|
The provider does not create, copy, or renew stored secrets.
|
|
58
|
-
The Provider grants the selected reference
|
|
64
|
+
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.
|
|
59
65
|
|
|
60
66
|
```ts
|
|
61
67
|
const provider = createTangleProvider({
|
|
@@ -94,7 +100,7 @@ Explicit `"managed"` intent also skips configured static API references.
|
|
|
94
100
|
Unmarked legacy profiles retain their existing static API configuration; mark mixed profiles explicitly or use a selector.
|
|
95
101
|
The same Provider can create a managed parent and subscription child, or a subscription parent and managed child.
|
|
96
102
|
A subscription profile requires a configured reference or successful selector result before Sandbox creation.
|
|
97
|
-
The selector receives a frozen copy of the exact create input, including its profile and idempotency key.
|
|
103
|
+
The selector receives a frozen copy of the exact create input, including its profile and idempotency key. Fresh-turn calls carry the exact profile, stable binding key, and public `metadata.nativeCredentialTurn` coordinates.
|
|
98
104
|
It returns one public native reference or the API reference described above.
|
|
99
105
|
It cannot change the profile, harness, model, reasoning controls, or runtime attachments.
|
|
100
106
|
|
|
@@ -143,14 +149,25 @@ Sandbox metadata records the public selection under `modelCredentials`.
|
|
|
143
149
|
This metadata key is reserved for the Provider selection.
|
|
144
150
|
Account labels are supplied bindings, not verified native principals.
|
|
145
151
|
Token values and native credential files never enter that selection or receipt.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
A static native reference stays bound to its creation account and harness on every turn.
|
|
153
|
+
Reconstructed environments recover that reference from persisted metadata and the observed backend.
|
|
154
|
+
|
|
155
|
+
A resolver selects a bootstrap credential at creation and a durable binding for each fresh turn.
|
|
156
|
+
Fresh turns require the exact inline subscription profile and a stable `turnId`.
|
|
157
|
+
Runtime supplies that profile through its maintained provider turn mapping; older Runtime callers can supply it through `taskToTurn`.
|
|
158
|
+
The binding key includes environment, session, and turn identity, so retrying the same operation retains its account after reconnect.
|
|
159
|
+
A deliberate new turn can select another eligible account. The selected reference enters the admitted request digest before dispatch.
|
|
160
|
+
The Provider grants only that named secret through the authenticated Sandbox API before native execution.
|
|
161
|
+
|
|
162
|
+
This handoff requires the SDK's `grantNativeCredential` operation and a container reporting `claudeTokenContinuations: true`.
|
|
163
|
+
Only Claude token references are qualified. Other harnesses, bundles, and files refuse dynamic handoff before inference.
|
|
164
|
+
The Sidecar retires the idle adapter, preserves its original transcript HOME and native session, and acquires the newly selected credential.
|
|
165
|
+
An active credential lease refuses replacement.
|
|
166
|
+
Exact event/result replay never selects or installs credentials and leaves the admitted request unchanged.
|
|
167
|
+
After a runtime restart, the next fresh turn grants its selected named reference before adapter acquisition.
|
|
168
|
+
The account owner must keep retry bindings and the original validity deadline durable; an unavailable grant never authorizes a paid fallback.
|
|
152
169
|
A turn carrying a profile must preserve its environment's credential source, including after recovery.
|
|
153
|
-
Changing credential sources requires a separate environment
|
|
170
|
+
Changing credential sources or harnesses requires a separate environment.
|
|
154
171
|
|
|
155
172
|
### A command owned by the account system
|
|
156
173
|
|
|
@@ -11,6 +11,7 @@ import type { SandboxInstanceLike, SandboxRuntimeCapabilityDocument } from "./ta
|
|
|
11
11
|
export interface DeploymentCapabilitySupport {
|
|
12
12
|
/** The selected runtime explicitly supports named native credential references. */
|
|
13
13
|
readonly cliAuthReferences: boolean;
|
|
14
|
+
readonly claudeTokenContinuations: boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Run requests carry the caller's exact `runControlRef`, and admission
|
|
16
17
|
* echoes the executionId. Detached dispatch needs both: it sends the
|
|
@@ -10,6 +10,7 @@ import { awaitWithSignal } from "./tangle-contract-safety.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export const UNPROVEN_DEPLOYMENT = {
|
|
12
12
|
cliAuthReferences: false,
|
|
13
|
+
claudeTokenContinuations: false,
|
|
13
14
|
exactDispatch: false,
|
|
14
15
|
canonicalCancellation: false,
|
|
15
16
|
eventReplay: false,
|
|
@@ -34,6 +35,7 @@ export const UNPROVEN_DEPLOYMENT = {
|
|
|
34
35
|
*/
|
|
35
36
|
export const ADAPTER_CEILING_DEPLOYMENT = {
|
|
36
37
|
cliAuthReferences: true,
|
|
38
|
+
claudeTokenContinuations: true,
|
|
37
39
|
exactDispatch: true,
|
|
38
40
|
canonicalCancellation: true,
|
|
39
41
|
eventReplay: true,
|
|
@@ -50,6 +52,7 @@ export function deploymentCapabilitySupport(document) {
|
|
|
50
52
|
return UNPROVEN_DEPLOYMENT;
|
|
51
53
|
return {
|
|
52
54
|
cliAuthReferences: document.cliAuthReferences === true,
|
|
55
|
+
claudeTokenContinuations: document.claudeTokenContinuations === true,
|
|
53
56
|
exactDispatch: document.dispatch?.runControlRef === true &&
|
|
54
57
|
document.dispatch?.executionIdOnAdmission === true,
|
|
55
58
|
canonicalCancellation: document.cancel?.canonicalRunCancellation === true &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
2
|
-
import {
|
|
2
|
+
import { backendFromTurnInput, backendRequestIdentity, } from "./tangle-prompt.js";
|
|
3
3
|
export function sessionPromptRequestDigest(input, provider, environmentId, sessionId, options = {}) {
|
|
4
|
-
const backend = backendRequestIdentity(
|
|
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.
|
|
32
|
+
return (input.profile !== undefined ||
|
|
33
|
+
input.prompt !== undefined ||
|
|
33
34
|
input.parts !== undefined ||
|
|
34
35
|
input.model !== undefined ||
|
|
35
36
|
input.timeoutMs !== undefined ||
|
|
@@ -23,5 +23,5 @@ type ExactExecutionEventStream = (options: {
|
|
|
23
23
|
* environment observation reads it, because Sandbox reports usage per
|
|
24
24
|
* execution result and never for the environment.
|
|
25
25
|
*/
|
|
26
|
-
export declare function sandboxSessionAsAgentSession(session: SandboxSessionLike, controlRef: AgentRunControlRef | undefined, provider: string, environmentId: string, dispatch: ((input: AgentTurnInput) => Promise<AgentSessionRef>) | undefined, exactExecutionEvents: ExactExecutionEventStream | undefined, retainedControl: boolean, interactionResponses: boolean, usageLog?: ExecutionUsageLog, nativeContinuation?: boolean, beforePrompt?: (input: AgentTurnInput) => AgentTurnInput | void
|
|
26
|
+
export declare function sandboxSessionAsAgentSession(session: SandboxSessionLike, controlRef: AgentRunControlRef | undefined, provider: string, environmentId: string, dispatch: ((input: AgentTurnInput) => Promise<AgentSessionRef>) | undefined, exactExecutionEvents: ExactExecutionEventStream | undefined, retainedControl: boolean, interactionResponses: boolean, usageLog?: ExecutionUsageLog, nativeContinuation?: boolean, beforePrompt?: (input: AgentTurnInput) => AgentTurnInput | void | Promise<AgentTurnInput | void>, onExecution?: (executionId: string) => void): AgentSession;
|
|
27
27
|
export {};
|
|
@@ -317,7 +317,6 @@ export function sandboxSessionAsAgentSession(session, controlRef, provider, envi
|
|
|
317
317
|
}));
|
|
318
318
|
},
|
|
319
319
|
async prompt(input) {
|
|
320
|
-
input = beforePrompt?.(input) ?? input;
|
|
321
320
|
AgentTurnInputSchema.parse(input);
|
|
322
321
|
input.signal?.throwIfAborted();
|
|
323
322
|
if (promptInFlight) {
|
|
@@ -328,6 +327,8 @@ export function sandboxSessionAsAgentSession(session, controlRef, provider, envi
|
|
|
328
327
|
if (input.sessionId !== undefined && input.sessionId !== session.id) {
|
|
329
328
|
throw new Error("Tangle sessionId conflicts with this session");
|
|
330
329
|
}
|
|
330
|
+
input = await beforePrompt?.({ ...input, sessionId: session.id }) ?? input;
|
|
331
|
+
input.signal?.throwIfAborted();
|
|
331
332
|
const requestedControlRef = resolveRetainedSessionControlRef(input.controlRef, session.id, provider, environmentId);
|
|
332
333
|
if (activeControlRef &&
|
|
333
334
|
requestedControlRef &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CliAuthReference } from "@tangle-network/sandbox/auth";
|
|
2
2
|
import type { AgentEnvironment, AgentEnvironmentCapabilities, ResourceProfile } from "@tangle-network/agent-interface/environment-provider";
|
|
3
|
-
import type { SandboxClientLike, SandboxInstanceLike, SandboxRuntimeCapabilityDocument } from "./tangle-types.js";
|
|
3
|
+
import type { SandboxClientLike, SandboxInstanceLike, SandboxRuntimeCapabilityDocument, TangleModelCredentialResolver } from "./tangle-types.js";
|
|
4
4
|
import { type ProfileCredentialSource } from "./model-credential-source.js";
|
|
5
5
|
import type { TangleConfidentialAttestationVerifier } from "./tangle-types.js";
|
|
6
6
|
/**
|
|
@@ -39,6 +39,7 @@ export declare function sandboxInstanceAsEnvironment(box: SandboxInstanceLike, p
|
|
|
39
39
|
harness: string;
|
|
40
40
|
cliAuth: CliAuthReference;
|
|
41
41
|
};
|
|
42
|
+
resolveModelCredentials?: TangleModelCredentialResolver;
|
|
42
43
|
captureCapabilities?: SandboxRuntimeCapabilityDocument;
|
|
43
44
|
captureHarness?: string;
|
|
44
45
|
}): Promise<AgentEnvironment>;
|
|
@@ -121,7 +121,9 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
121
121
|
}
|
|
122
122
|
assertNativeCaptureHarness(request.captureCapabilities, backend?.type ?? profileHarness ?? request.captureHarness);
|
|
123
123
|
};
|
|
124
|
-
const prepareTurn = (input) => {
|
|
124
|
+
const prepareTurn = async (input) => {
|
|
125
|
+
AgentTurnInputSchema.parse(input);
|
|
126
|
+
input.signal?.throwIfAborted();
|
|
125
127
|
assertCaptureInput(input);
|
|
126
128
|
if (nativeReference === undefined)
|
|
127
129
|
return input;
|
|
@@ -140,16 +142,56 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
140
142
|
canonicalCandidateDigest(model.cliAuth) !== canonicalCandidateDigest(nativeReference)) {
|
|
141
143
|
throw new Error("Tangle native credential turn cannot replace its selected account reference");
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
assertCliAuthReferenceSupported(harness, { ...model, cliAuth: nativeReference });
|
|
146
|
+
let selectedReference = nativeReference;
|
|
147
|
+
// Exact reads retain the admitted execution. A new operation obtains a new durable
|
|
148
|
+
// account-owner binding; retries of that operation present the same key after restart.
|
|
149
|
+
if (!replay && request?.resolveModelCredentials !== undefined) {
|
|
150
|
+
if (!deployment.claudeTokenContinuations || box.grantNativeCredential === undefined ||
|
|
151
|
+
harness !== "claude-code" || nativeReference.format !== "token") {
|
|
152
|
+
throw new Error("Tangle fresh subscription turns require proven Claude token continuation and named-grant support");
|
|
153
|
+
}
|
|
154
|
+
const profile = backend?.profile;
|
|
155
|
+
if (profile === undefined || profileCredentialSource(profile) !== "subscription") {
|
|
156
|
+
throw new Error("Tangle subscription turn selection requires its exact inline profile");
|
|
157
|
+
}
|
|
158
|
+
const turnId = boundedIdentifier(input.turnId, "Tangle subscription turn id");
|
|
159
|
+
const binding = {
|
|
160
|
+
kind: "native-turn-credentials.v1",
|
|
161
|
+
environmentId,
|
|
162
|
+
sessionId: input.sessionId ?? null,
|
|
163
|
+
turnId,
|
|
164
|
+
};
|
|
165
|
+
const selected = captureModelCredentials(await awaitWithSignal(Promise.resolve(request.resolveModelCredentials(Object.freeze({
|
|
166
|
+
...deepFreeze({
|
|
167
|
+
profile,
|
|
168
|
+
idempotencyKey: canonicalCandidateDigest(binding),
|
|
169
|
+
metadata: { nativeCredentialTurn: binding },
|
|
170
|
+
}),
|
|
171
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
172
|
+
}))), input.signal));
|
|
173
|
+
if (selected === undefined || !("cliAuth" in selected) || selected.cliAuth.format !== "token") {
|
|
174
|
+
throw new Error("Tangle subscription turn resolver must select a stored Claude token reference");
|
|
175
|
+
}
|
|
176
|
+
selectedReference = selected.cliAuth;
|
|
177
|
+
assertCliAuthReferenceSupported(harness, { ...model, cliAuth: selectedReference });
|
|
178
|
+
input.signal?.throwIfAborted();
|
|
179
|
+
await awaitWithSignal(box.grantNativeCredential({ harness, cliAuth: selectedReference }, input.signal ? { signal: input.signal } : undefined), input.signal);
|
|
180
|
+
input.signal?.throwIfAborted();
|
|
181
|
+
}
|
|
182
|
+
const selectedModel = { ...model, cliAuth: selectedReference };
|
|
144
183
|
assertCliAuthReferenceSupported(harness, selectedModel);
|
|
145
184
|
// Validate explicit substitutions even on replay, without rewriting its admitted digest.
|
|
146
185
|
if (replay)
|
|
147
186
|
return input;
|
|
187
|
+
const { profile: _profile, ...backendOptions } = backend ?? {};
|
|
148
188
|
return {
|
|
149
189
|
...input,
|
|
150
190
|
providerOptions: {
|
|
151
191
|
...input.providerOptions,
|
|
152
|
-
|
|
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" } },
|
|
153
195
|
},
|
|
154
196
|
};
|
|
155
197
|
};
|
|
@@ -165,8 +207,8 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
165
207
|
const dispatchRun = capabilities.streaming.detach && box.dispatchPrompt
|
|
166
208
|
? dispatchEnvironmentRun(box, providerName, environmentId)
|
|
167
209
|
: undefined;
|
|
168
|
-
const dispatch = dispatchRun === undefined ? undefined : (input) => {
|
|
169
|
-
return dispatchRun(prepareTurn(input));
|
|
210
|
+
const dispatch = dispatchRun === undefined ? undefined : async (input) => {
|
|
211
|
+
return dispatchRun(await prepareTurn(input));
|
|
170
212
|
};
|
|
171
213
|
const exactExecutionEvents = (options) => box.streamPrompt("", {
|
|
172
214
|
sessionId: options.sessionId,
|
|
@@ -196,7 +238,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
196
238
|
async *stream(input) {
|
|
197
239
|
AgentTurnInputSchema.parse(input);
|
|
198
240
|
input.signal?.throwIfAborted();
|
|
199
|
-
input = prepareTurn(input);
|
|
241
|
+
input = await prepareTurn(input);
|
|
200
242
|
const expectedExecutionId = executionIdFromTurnInput(input);
|
|
201
243
|
const expectedSessionId = input.sessionId ?? input.controlRef?.sessionId;
|
|
202
244
|
if (expectedSessionId)
|
|
@@ -269,7 +311,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
269
311
|
if (session.id !== id) {
|
|
270
312
|
throw new Error("sandbox session(id) returned an unrelated session");
|
|
271
313
|
}
|
|
272
|
-
const agentSession = sandboxSessionAsAgentSession(session, options?.controlRef, providerName, environmentId,
|
|
314
|
+
const agentSession = sandboxSessionAsAgentSession(session, options?.controlRef, providerName, environmentId, dispatchRun, exactExecutionEvents, retainedControl, interactionResponses, usageLog, capabilities.nativeContinuation !== undefined, prepareTurn, (executionId) => noteTangleSession(environment, id, executionId));
|
|
273
315
|
// sessions.continue was granted from the probe session and the
|
|
274
316
|
// deployment document together; this backstop holds every
|
|
275
317
|
// concrete session to that grant, so a client whose sessions
|
package/dist/tangle-prompt.d.ts
CHANGED
|
@@ -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;
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -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 =
|
|
380
|
+
const backend = backendFromTurnInput(input);
|
|
363
381
|
const backendModel = backend?.model?.model;
|
|
364
382
|
if (input.model !== undefined &&
|
|
365
383
|
backendModel !== undefined &&
|
package/dist/tangle-provider.js
CHANGED
|
@@ -208,6 +208,7 @@ export function createTangleProvider(options) {
|
|
|
208
208
|
? {}
|
|
209
209
|
: { resources: requestedResources }),
|
|
210
210
|
credentialSource,
|
|
211
|
+
...(resolveModelCredentials === undefined ? {} : { resolveModelCredentials }),
|
|
211
212
|
...(createOptions.backend?.model?.cliAuth === undefined ? {} : {
|
|
212
213
|
nativeAuth: { harness: createOptions.backend.type, cliAuth: createOptions.backend.model.cliAuth },
|
|
213
214
|
}),
|
|
@@ -319,6 +320,7 @@ export function createTangleProvider(options) {
|
|
|
319
320
|
const declaredCapabilities = await resolveDeclaredCapabilities(backendType);
|
|
320
321
|
return await sandboxInstanceAsEnvironment(box, providerName, options.client, declaredCapabilities, operation?.signal ? { signal: operation.signal } : undefined, {
|
|
321
322
|
...confidentialVerifierOption(options.confidentialAttestationVerifier),
|
|
323
|
+
...(resolveModelCredentials === undefined ? {} : { resolveModelCredentials }),
|
|
322
324
|
...(options.requireNativeSessionCapture ? { requireNativeSessionCapture: true } : {}),
|
|
323
325
|
...(captureCapabilities === undefined ? {} : { captureCapabilities }),
|
|
324
326
|
...(backendType === undefined ? {} : { captureHarness: backendType, credentialHarness: backendType }),
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export interface SandboxRuntimeCapabilityDocument {
|
|
|
104
104
|
schema?: number;
|
|
105
105
|
/** The selected runtime resolves stored-secret native authentication references. */
|
|
106
106
|
cliAuthReferences?: boolean;
|
|
107
|
+
claudeTokenContinuations?: boolean;
|
|
107
108
|
nativeSessionCaptureVersion?: number;
|
|
108
109
|
nativeSessionCaptureHarnesses?: readonly string[];
|
|
109
110
|
agentInterface?: string;
|
|
@@ -424,6 +425,13 @@ export interface SandboxInstanceLike {
|
|
|
424
425
|
session?(id: string, options?: {
|
|
425
426
|
signal?: AbortSignal;
|
|
426
427
|
}): SandboxSessionLike;
|
|
428
|
+
/** Owner-authorized named grant; material never crosses this consumer boundary. */
|
|
429
|
+
grantNativeCredential?(grant: {
|
|
430
|
+
harness: "claude-code";
|
|
431
|
+
cliAuth: CliAuthReference;
|
|
432
|
+
}, options?: {
|
|
433
|
+
signal?: AbortSignal;
|
|
434
|
+
}): Promise<void>;
|
|
427
435
|
read?(path: string, options?: {
|
|
428
436
|
sessionId?: string;
|
|
429
437
|
signal?: AbortSignal;
|
|
@@ -765,7 +773,7 @@ export type TangleModelCredentials = {
|
|
|
765
773
|
} | {
|
|
766
774
|
cliAuth: CliAuthReference;
|
|
767
775
|
};
|
|
768
|
-
/** Select one public stored-secret reference for
|
|
776
|
+
/** Select one public stored-secret reference for a stable create or fresh-turn identity. */
|
|
769
777
|
export type TangleModelCredentialResolver = (input: Readonly<CreateAgentEnvironmentInput>) => TangleModelCredentials | undefined | Promise<TangleModelCredentials | undefined>;
|
|
770
778
|
export interface TangleProviderOptions {
|
|
771
779
|
client: SandboxClientLike;
|
|
@@ -779,6 +787,9 @@ export interface TangleProviderOptions {
|
|
|
779
787
|
* Managed profiles skip selectors and native references; explicit managed intent skips all references.
|
|
780
788
|
* Unmarked legacy profiles retain their static API reference and grant only its selected secret.
|
|
781
789
|
* Subscription selections grant only their selected secret and record its public reference.
|
|
790
|
+
* A resolver is called again for each fresh native turn with the exact profile and a stable
|
|
791
|
+
* environment/session/turn key. Exact execution replay never selects again. Turn selection
|
|
792
|
+
* requires a runtime proving Claude token continuity and the SDK named-grant method.
|
|
782
793
|
* Cannot be combined with mapCreateInput; never accepts credential values or model overrides.
|
|
783
794
|
*/
|
|
784
795
|
modelCredentials?: TangleModelCredentials | TangleModelCredentialResolver;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "3.
|
|
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.
|
|
123
|
+
"@tangle-network/agent-interface": "^2.17.0"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
126
|
"@tangle-network/sandbox": ">=0.58.7 <1.0.0"
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
134
|
"@tangle-network/agent-provider-testkit": "0.10.0",
|
|
135
|
-
"@tangle-network/agent-runtime": "0.
|
|
135
|
+
"@tangle-network/agent-runtime": "0.292.3",
|
|
136
136
|
"@tangle-network/sandbox": "0.58.7",
|
|
137
137
|
"@types/node": "26.6.3",
|
|
138
138
|
"typescript": "7.0.2",
|