@tangle-network/agent-provider-tangle 3.2.0 → 3.3.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 +20 -9
- package/dist/tangle-deployment-capabilities.d.ts +1 -0
- package/dist/tangle-deployment-capabilities.js +3 -0
- 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 +45 -6
- package/dist/tangle-provider.js +2 -0
- package/dist/tangle-types.d.ts +12 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ An unsupported downloader or incomplete transfer fails capture and preserves the
|
|
|
55
55
|
`modelCredentials` sends a stored credential reference and explicit endpoint before Sandbox provisions the backend.
|
|
56
56
|
This uses Sandbox's existing caller-owned model credential path instead of requesting a managed Router credential.
|
|
57
57
|
The provider does not create, copy, or renew stored secrets.
|
|
58
|
-
The Provider grants the selected reference
|
|
58
|
+
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
59
|
|
|
60
60
|
```ts
|
|
61
61
|
const provider = createTangleProvider({
|
|
@@ -94,7 +94,7 @@ Explicit `"managed"` intent also skips configured static API references.
|
|
|
94
94
|
Unmarked legacy profiles retain their existing static API configuration; mark mixed profiles explicitly or use a selector.
|
|
95
95
|
The same Provider can create a managed parent and subscription child, or a subscription parent and managed child.
|
|
96
96
|
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.
|
|
97
|
+
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
98
|
It returns one public native reference or the API reference described above.
|
|
99
99
|
It cannot change the profile, harness, model, reasoning controls, or runtime attachments.
|
|
100
100
|
|
|
@@ -143,14 +143,25 @@ Sandbox metadata records the public selection under `modelCredentials`.
|
|
|
143
143
|
This metadata key is reserved for the Provider selection.
|
|
144
144
|
Account labels are supplied bindings, not verified native principals.
|
|
145
145
|
Token values and native credential files never enter that selection or receipt.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
A static native reference stays bound to its creation account and harness on every turn.
|
|
147
|
+
Reconstructed environments recover that reference from persisted metadata and the observed backend.
|
|
148
|
+
|
|
149
|
+
A resolver selects a bootstrap credential at creation and a durable binding for each fresh turn.
|
|
150
|
+
Fresh turns require the exact inline subscription profile and a stable `turnId`.
|
|
151
|
+
Runtime supplies that profile through its maintained provider turn mapping; older Runtime callers can supply it through `taskToTurn`.
|
|
152
|
+
The binding key includes environment, session, and turn identity, so retrying the same operation retains its account after reconnect.
|
|
153
|
+
A deliberate new turn can select another eligible account. The selected reference enters the admitted request digest before dispatch.
|
|
154
|
+
The Provider grants only that named secret through the authenticated Sandbox API before native execution.
|
|
155
|
+
|
|
156
|
+
This handoff requires the SDK's `grantNativeCredential` operation and a container reporting `claudeTokenContinuations: true`.
|
|
157
|
+
Only Claude token references are qualified. Other harnesses, bundles, and files refuse dynamic handoff before inference.
|
|
158
|
+
The Sidecar retires the idle adapter, preserves its original transcript HOME and native session, and acquires the newly selected credential.
|
|
159
|
+
An active credential lease refuses replacement.
|
|
160
|
+
Exact event/result replay never selects or installs credentials and leaves the admitted request unchanged.
|
|
161
|
+
After a runtime restart, the next fresh turn grants its selected named reference before adapter acquisition.
|
|
162
|
+
The account owner must keep retry bindings and the original validity deadline durable; an unavailable grant never authorizes a paid fallback.
|
|
152
163
|
A turn carrying a profile must preserve its environment's credential source, including after recovery.
|
|
153
|
-
Changing credential sources requires a separate environment
|
|
164
|
+
Changing credential sources or harnesses requires a separate environment.
|
|
154
165
|
|
|
155
166
|
### A command owned by the account system
|
|
156
167
|
|
|
@@ -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 &&
|
|
@@ -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,7 +142,44 @@ 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)
|
|
@@ -165,8 +204,8 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
165
204
|
const dispatchRun = capabilities.streaming.detach && box.dispatchPrompt
|
|
166
205
|
? dispatchEnvironmentRun(box, providerName, environmentId)
|
|
167
206
|
: undefined;
|
|
168
|
-
const dispatch = dispatchRun === undefined ? undefined : (input) => {
|
|
169
|
-
return dispatchRun(prepareTurn(input));
|
|
207
|
+
const dispatch = dispatchRun === undefined ? undefined : async (input) => {
|
|
208
|
+
return dispatchRun(await prepareTurn(input));
|
|
170
209
|
};
|
|
171
210
|
const exactExecutionEvents = (options) => box.streamPrompt("", {
|
|
172
211
|
sessionId: options.sessionId,
|
|
@@ -196,7 +235,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
196
235
|
async *stream(input) {
|
|
197
236
|
AgentTurnInputSchema.parse(input);
|
|
198
237
|
input.signal?.throwIfAborted();
|
|
199
|
-
input = prepareTurn(input);
|
|
238
|
+
input = await prepareTurn(input);
|
|
200
239
|
const expectedExecutionId = executionIdFromTurnInput(input);
|
|
201
240
|
const expectedSessionId = input.sessionId ?? input.controlRef?.sessionId;
|
|
202
241
|
if (expectedSessionId)
|
|
@@ -269,7 +308,7 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
269
308
|
if (session.id !== id) {
|
|
270
309
|
throw new Error("sandbox session(id) returned an unrelated session");
|
|
271
310
|
}
|
|
272
|
-
const agentSession = sandboxSessionAsAgentSession(session, options?.controlRef, providerName, environmentId,
|
|
311
|
+
const agentSession = sandboxSessionAsAgentSession(session, options?.controlRef, providerName, environmentId, dispatchRun, exactExecutionEvents, retainedControl, interactionResponses, usageLog, capabilities.nativeContinuation !== undefined, prepareTurn, (executionId) => noteTangleSession(environment, id, executionId));
|
|
273
312
|
// sessions.continue was granted from the probe session and the
|
|
274
313
|
// deployment document together; this backstop holds every
|
|
275
314
|
// concrete session to that grant, so a client whose sessions
|
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.3.0",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -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",
|