@tangle-network/agent-provider-tangle 4.2.2 → 4.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 +3 -0
- package/dist/command-model-credentials.js +1 -1
- package/dist/http-model-credentials.js +1 -1
- package/dist/model-credential-source.d.ts +8 -1
- package/dist/model-credential-source.js +3 -3
- package/dist/tangle-create-options.js +27 -0
- package/dist/tangle-prompt.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,6 +95,9 @@ Keep the stored secret available and valid throughout execution and recovery.
|
|
|
95
95
|
The exact profile chooses access through `model.metadata.credentialSource`.
|
|
96
96
|
Use `"subscription"` to request an enrolled account.
|
|
97
97
|
Omitting this field or using `"managed"` preserves managed access.
|
|
98
|
+
Use `"cli"` when the harness CLI authenticates its own provider, such as OpenCode's keyless free tier (`opencode/glm-5.3-flash-free`).
|
|
99
|
+
Sandbox then runs OpenCode in CLI mode: no managed key is minted, no subscription is selected, and the model never reaches the Router.
|
|
100
|
+
A `"cli"` profile runs only on the `opencode` backend and refuses `modelCredentials`; the box still needs egress to the provider's endpoint.
|
|
98
101
|
Unknown or malformed intent fails before provisioning.
|
|
99
102
|
`profileCredentialSource(profile)` exports this strict intent reader.
|
|
100
103
|
|
|
@@ -41,7 +41,7 @@ export function createCommandModelCredentialResolver(options) {
|
|
|
41
41
|
return (input) => {
|
|
42
42
|
if (typeof input.profile === "string")
|
|
43
43
|
throw new Error("Tangle credential command requires an inline profile");
|
|
44
|
-
if (profileCredentialSource(input.profile)
|
|
44
|
+
if (profileCredentialSource(input.profile) !== "subscription")
|
|
45
45
|
return undefined;
|
|
46
46
|
if (typeof input.idempotencyKey !== "string" || input.idempotencyKey.length === 0) {
|
|
47
47
|
throw new Error("Tangle credential command requires a stable create idempotencyKey");
|
|
@@ -74,7 +74,7 @@ export function createHttpModelCredentialResolver(options) {
|
|
|
74
74
|
return async (input) => {
|
|
75
75
|
if (typeof input.profile === "string")
|
|
76
76
|
throw new Error("Tangle credential broker requires an inline profile");
|
|
77
|
-
if (profileCredentialSource(input.profile)
|
|
77
|
+
if (profileCredentialSource(input.profile) !== "subscription")
|
|
78
78
|
return undefined;
|
|
79
79
|
input.signal?.throwIfAborted();
|
|
80
80
|
const { signal, ...data } = input;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { AgentProfile } from "@tangle-network/agent-interface";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Who authenticates the profile's model.
|
|
4
|
+
* - `managed`: Tangle mints the model credential (the default).
|
|
5
|
+
* - `subscription`: a selected stored subscription credential.
|
|
6
|
+
* - `cli`: the harness CLI resolves and authenticates its own provider, such as OpenCode's
|
|
7
|
+
* keyless free tier. No managed key, no subscription seat, no credential resolver.
|
|
8
|
+
*/
|
|
9
|
+
export type ProfileCredentialSource = "managed" | "subscription" | "cli";
|
|
3
10
|
/** Authored profile intent is independent of the harness, vendor, and available accounts. */
|
|
4
11
|
export declare function profileCredentialSource(profile: AgentProfile): ProfileCredentialSource;
|
|
@@ -14,7 +14,7 @@ export function profileCredentialSource(profile) {
|
|
|
14
14
|
const source = metadata?.credentialSource;
|
|
15
15
|
if (source === undefined || source === "managed")
|
|
16
16
|
return "managed";
|
|
17
|
-
if (source === "subscription")
|
|
18
|
-
return
|
|
19
|
-
throw new Error('Tangle profile model.metadata.credentialSource must be "managed" or "
|
|
17
|
+
if (source === "subscription" || source === "cli")
|
|
18
|
+
return source;
|
|
19
|
+
throw new Error('Tangle profile model.metadata.credentialSource must be "managed", "subscription" or "cli"');
|
|
20
20
|
}
|
|
@@ -71,6 +71,15 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
71
71
|
}
|
|
72
72
|
assertCliAuthReferenceSupported(backend, modelCredentials);
|
|
73
73
|
}
|
|
74
|
+
// A cli profile's harness authenticates itself (OpenCode's keyless free tier). Sandbox runs that
|
|
75
|
+
// as OpenCode CLI mode: no Router key is minted and the model never reaches the Router.
|
|
76
|
+
const cliOwned = profileCredentialSource(profile) === "cli";
|
|
77
|
+
if (cliOwned && modelCredentials !== undefined) {
|
|
78
|
+
throw new Error("Tangle cli profile takes no modelCredentials; its harness CLI authenticates itself");
|
|
79
|
+
}
|
|
80
|
+
if (cliOwned && backend !== "opencode") {
|
|
81
|
+
throw new Error(`Tangle cli profile runs only on the opencode backend, not ${backend}`);
|
|
82
|
+
}
|
|
74
83
|
if (selectedSecret !== undefined && Object.hasOwn(input.env ?? {}, selectedSecret)) {
|
|
75
84
|
throw new Error("Tangle modelCredentials cannot shadow a stored secret with inline environment data");
|
|
76
85
|
}
|
|
@@ -159,6 +168,7 @@ export function sandboxOptionsFromCreateInput(input, defaultBackend, parsedWorks
|
|
|
159
168
|
...(base.backend ?? {}),
|
|
160
169
|
type: backend,
|
|
161
170
|
profile,
|
|
171
|
+
...(cliOwned ? { model: cliOwnedModel(profile) } : {}),
|
|
162
172
|
...(modelCredentials === undefined ? {} : {
|
|
163
173
|
model: "cliAuth" in modelCredentials
|
|
164
174
|
? { cliAuth: modelCredentials.cliAuth, authMode: "oauth" } : modelCredentials,
|
|
@@ -308,10 +318,27 @@ export function assertCreateInputShape(input, parsedWorkspace) {
|
|
|
308
318
|
workspaceCwdPathForBase(workspace.cwd, "repository", "Tangle");
|
|
309
319
|
return workspace;
|
|
310
320
|
}
|
|
321
|
+
/** Sandbox's OpenCode CLI mode on the profile's own provider and model, with no credential. */
|
|
322
|
+
function cliOwnedModel(profile) {
|
|
323
|
+
const provider = profile.model?.provider;
|
|
324
|
+
const model = profile.model?.default;
|
|
325
|
+
return {
|
|
326
|
+
mode: "cli",
|
|
327
|
+
...(provider === undefined ? {} : { provider: boundedIdentifier(provider, "Tangle cli profile provider") }),
|
|
328
|
+
...(model === undefined ? {} : { model: boundedString(model, "Tangle cli profile model") }),
|
|
329
|
+
};
|
|
330
|
+
}
|
|
311
331
|
export function assertMappedCreateOptions(options) {
|
|
312
332
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
313
333
|
throw new Error("Tangle mapped create options must be an object");
|
|
314
334
|
}
|
|
335
|
+
if (options.backend?.profile !== undefined && profileCredentialSource(options.backend.profile) === "cli") {
|
|
336
|
+
const model = options.backend.model;
|
|
337
|
+
if (model?.mode !== "cli" || model.apiKey !== undefined || model.apiKeyEnv !== undefined ||
|
|
338
|
+
model.cliAuth !== undefined || model.authFiles !== undefined) {
|
|
339
|
+
throw new Error("Tangle mapped cli profile must run in CLI mode with no model credential");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
315
342
|
assertBoundedJson(options, "Tangle mapped create options", PROFILE_AT_BACKEND_PROFILE);
|
|
316
343
|
const proxySecrets = options.proxySecrets === undefined ? undefined : captureProxySecrets(options.proxySecrets);
|
|
317
344
|
assertProxySecretAliases(proxySecrets, options.env, options.secrets);
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -167,9 +167,13 @@ function sandboxPromptBackend(value) {
|
|
|
167
167
|
? {}
|
|
168
168
|
: { metadata: sandboxPromptBackendMetadata(present.metadata) }),
|
|
169
169
|
};
|
|
170
|
-
|
|
170
|
+
const explicitSource = backend.profile?.model?.metadata?.credentialSource;
|
|
171
|
+
if ((explicitSource === "managed" || explicitSource === "cli") &&
|
|
171
172
|
(backend.model?.cliAuth !== undefined || backend.model?.authFiles !== undefined || backend.model?.authMode === "oauth")) {
|
|
172
|
-
throw new Error(
|
|
173
|
+
throw new Error(`Tangle explicit ${explicitSource} profile cannot receive native subscription credentials`);
|
|
174
|
+
}
|
|
175
|
+
if (explicitSource === "cli" && (backend.model?.apiKey !== undefined || backend.model?.apiKeyEnv !== undefined)) {
|
|
176
|
+
throw new Error("Tangle cli profile cannot receive a model API key");
|
|
173
177
|
}
|
|
174
178
|
if (backend.profile !== undefined)
|
|
175
179
|
profileCredentialSource(backend.profile);
|