@tangle-network/agent-provider-cli-bridge 2.0.11 → 2.0.13
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/dist/capability-discovery.js +3 -0
- package/dist/environment-identity.d.ts +1 -1
- package/dist/environment-identity.js +5 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +6 -14
- package/dist/wire.js +8 -1
- package/package.json +1 -1
|
@@ -159,6 +159,9 @@ export function narrowCliBridgeCapabilities(adapter, reported, selectedBackend,
|
|
|
159
159
|
placement: adapter.placement && reported.placement,
|
|
160
160
|
usage: adapter.usage && reported.usage,
|
|
161
161
|
confidential: adapter.confidential && reported.confidential,
|
|
162
|
+
// Bridge discovery documents carry no create block, so they cannot deny
|
|
163
|
+
// the create inputs this adapter forwards (wire.ts runtime_attachments).
|
|
164
|
+
...(adapter.create === undefined ? {} : { create: adapter.create }),
|
|
162
165
|
// Observation is measured by this adapter, not by the remote backend document.
|
|
163
166
|
...(observation === undefined ? {} : { observation }),
|
|
164
167
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { CONTRACT_MAX_IDENTIFIER_LENGTH } from "@tangle-network/agent-interface";
|
|
2
3
|
const CLI_BRIDGE_ENVIRONMENT_ID_PREFIX = "cb1.";
|
|
3
|
-
const MAX_ENVIRONMENT_ID_LENGTH = 512;
|
|
4
4
|
/**
|
|
5
5
|
* Keep the exact route and create digest inside the provider-owned id.
|
|
6
6
|
* The nonce hides a caller idempotency key while repeated creates stay stable.
|
|
@@ -17,8 +17,8 @@ export function cliBridgeEnvironmentId(route, createDigest, idempotencyKey) {
|
|
|
17
17
|
nonce,
|
|
18
18
|
]);
|
|
19
19
|
const id = `${CLI_BRIDGE_ENVIRONMENT_ID_PREFIX}${Buffer.from(payload).toString("base64url")}`;
|
|
20
|
-
if (id.length >
|
|
21
|
-
throw new Error(
|
|
20
|
+
if (id.length > CONTRACT_MAX_IDENTIFIER_LENGTH) {
|
|
21
|
+
throw new Error(`cli-bridge route is too long to retain in an environment id of at most ${CONTRACT_MAX_IDENTIFIER_LENGTH} characters`);
|
|
22
22
|
}
|
|
23
23
|
return id;
|
|
24
24
|
}
|
|
@@ -27,7 +27,7 @@ export function cliBridgeEnvironmentRoute(id) {
|
|
|
27
27
|
if (!id.startsWith(CLI_BRIDGE_ENVIRONMENT_ID_PREFIX)) {
|
|
28
28
|
throw new Error("cli-bridge environment id is not a provider-owned retained identity");
|
|
29
29
|
}
|
|
30
|
-
if (id.length >
|
|
30
|
+
if (id.length > CONTRACT_MAX_IDENTIFIER_LENGTH) {
|
|
31
31
|
throw new Error("cli-bridge environment id has invalid retained route data");
|
|
32
32
|
}
|
|
33
33
|
const encoded = id.slice(CLI_BRIDGE_ENVIRONMENT_ID_PREFIX.length);
|
|
@@ -72,7 +72,7 @@ function optionalRouteValue(value) {
|
|
|
72
72
|
function routeValue(value) {
|
|
73
73
|
return (typeof value === "string" &&
|
|
74
74
|
value.length > 0 &&
|
|
75
|
-
value.length <=
|
|
75
|
+
value.length <= CONTRACT_MAX_IDENTIFIER_LENGTH &&
|
|
76
76
|
value.trim() === value);
|
|
77
77
|
}
|
|
78
78
|
function sha256Digest(value) {
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,5 @@ export interface CliBridgeProvider extends AgentEnvironmentProvider {
|
|
|
12
12
|
lookupRun(input: CliBridgeRunLookupInput): Promise<AgentExactRunControlRef | null>;
|
|
13
13
|
}
|
|
14
14
|
export declare function createCliBridgeProvider(options: CliBridgeProviderOptions): CliBridgeProvider;
|
|
15
|
-
/**
|
|
16
|
-
* Describe the bridge backend, not this adapter.
|
|
17
|
-
*
|
|
18
|
-
* The adapter forwards an AgentProfile but does not own harness prompt controls.
|
|
19
|
-
*/
|
|
15
|
+
/** Bridge capabilities. The adapter forwards an AgentProfile and does not own harness prompt controls. */
|
|
20
16
|
export declare function defaultCliBridgeCapabilities(harness?: HarnessType): AgentEnvironmentCapabilities;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { agentEnvironmentCreateInputDigest, createAgentEnvironmentWithIdempotency, AgentEnvironmentGetOptionsSchema, } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
-
import { harnessTypeSchema, harnessSystemPromptIntents, snapshotAgentProfile, deepFreeze, ContextTransferReceiptSchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface";
|
|
2
|
+
import { CONTRACT_MAX_IDENTIFIER_LENGTH, harnessTypeSchema, harnessSystemPromptIntents, snapshotAgentProfile, deepFreeze, ContextTransferReceiptSchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface";
|
|
3
3
|
import { createCliBridgeEnvironment, } from "./retained-environment.js";
|
|
4
4
|
import { lookupExactCliBridgeRun, } from "./retained-control.js";
|
|
5
5
|
import { cachedCliBridgeCapabilityDiscovery, narrowCliBridgeCapabilities, } from "./capability-discovery.js";
|
|
@@ -61,9 +61,6 @@ export function createCliBridgeProvider(options) {
|
|
|
61
61
|
if (input.workspace?.snapshot !== undefined) {
|
|
62
62
|
throw new Error("CLI Bridge provider does not support portable workspace snapshots");
|
|
63
63
|
}
|
|
64
|
-
if (input.runtimeAttachments !== undefined) {
|
|
65
|
-
throw new Error("CLI Bridge provider does not support runtime MCP attachments");
|
|
66
|
-
}
|
|
67
64
|
if (typeof input.profile === "string") {
|
|
68
65
|
throw new Error(`createCliBridgeProvider requires an inline AgentProfile; named profile "${input.profile}" is unsupported`);
|
|
69
66
|
}
|
|
@@ -202,16 +199,12 @@ function selectedBackendFromRoute(route) {
|
|
|
202
199
|
}
|
|
203
200
|
function assertRequestedEnvironmentId(value) {
|
|
204
201
|
if (value.length === 0 ||
|
|
205
|
-
value.length >
|
|
202
|
+
value.length > CONTRACT_MAX_IDENTIFIER_LENGTH ||
|
|
206
203
|
!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(value)) {
|
|
207
|
-
throw new Error(
|
|
204
|
+
throw new Error(`cli-bridge requested environment id must be 1-${CONTRACT_MAX_IDENTIFIER_LENGTH} URL-safe characters`);
|
|
208
205
|
}
|
|
209
206
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Describe the bridge backend, not this adapter.
|
|
212
|
-
*
|
|
213
|
-
* The adapter forwards an AgentProfile but does not own harness prompt controls.
|
|
214
|
-
*/
|
|
207
|
+
/** Bridge capabilities. The adapter forwards an AgentProfile and does not own harness prompt controls. */
|
|
215
208
|
export function defaultCliBridgeCapabilities(harness) {
|
|
216
209
|
return {
|
|
217
210
|
profile: {
|
|
@@ -284,9 +277,8 @@ export function defaultCliBridgeCapabilities(harness) {
|
|
|
284
277
|
placement: true,
|
|
285
278
|
usage: true,
|
|
286
279
|
confidential: false,
|
|
287
|
-
|
|
288
|
-
// It provisions no compute and holds no account
|
|
289
|
-
// describe provisioned resources and billing are never claimed.
|
|
280
|
+
create: { runtimeAttachments: { mcp: true } },
|
|
281
|
+
// cli-bridge measures turn cost and forwarding. It provisions no compute and holds no account.
|
|
290
282
|
observation: {
|
|
291
283
|
identity: true,
|
|
292
284
|
lifecycle: true,
|
package/dist/wire.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { AgentExactRunControlRefSchema, CONTRACT_MAX_ARRAY_LENGTH, RequestedInteractionsSchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface";
|
|
2
|
+
import { AgentExactRunControlRefSchema, AgentRuntimeAttachmentsSchema, CONTRACT_MAX_ARRAY_LENGTH, RequestedInteractionsSchema, WorkspaceRequestSchema, workspaceCwdPathForBase, } from "@tangle-network/agent-interface";
|
|
3
|
+
function runtimeAttachmentsField(input) {
|
|
4
|
+
if (input.runtimeAttachments === undefined)
|
|
5
|
+
return {};
|
|
6
|
+
return { runtime_attachments: AgentRuntimeAttachmentsSchema.parse(input.runtimeAttachments) };
|
|
7
|
+
}
|
|
3
8
|
export function toChatCompletionsBody(options, environmentInput, turn, coordinates) {
|
|
4
9
|
const profile = inlineProfile(environmentInput.profile);
|
|
5
10
|
const execution = executionFromInput(options, environmentInput);
|
|
@@ -25,6 +30,7 @@ export function toChatCompletionsBody(options, environmentInput, turn, coordinat
|
|
|
25
30
|
...(workspaceCwd === undefined ? {} : { cwd: workspaceCwd }),
|
|
26
31
|
...(execution ? { execution } : {}),
|
|
27
32
|
...(interactions === undefined ? {} : { interactions }),
|
|
33
|
+
...runtimeAttachmentsField(environmentInput),
|
|
28
34
|
...(turn.contextTransfer === undefined
|
|
29
35
|
? {}
|
|
30
36
|
: { context_transfer: turn.contextTransfer }),
|
|
@@ -72,6 +78,7 @@ export function toRetainedSessionBody(options, environmentInput, profile, sessio
|
|
|
72
78
|
...(environmentInput.providerOptions !== undefined
|
|
73
79
|
? { provider_options: environmentInput.providerOptions }
|
|
74
80
|
: {}),
|
|
81
|
+
...runtimeAttachmentsField(environmentInput),
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
84
|
/** Encode the exact retained turn contract without moving posture into metadata. */
|
package/package.json
CHANGED