@tangle-network/agent-provider-tangle 0.13.0 → 0.13.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { harnessSystemPromptIntents } from "@tangle-network/agent-interface";
|
|
1
|
+
import { deepFreeze, harnessSystemPromptIntents } from "@tangle-network/agent-interface";
|
|
2
2
|
import { SandboxInstance } from "@tangle-network/sandbox";
|
|
3
3
|
import { ADAPTER_CEILING_DEPLOYMENT, deploymentBacksInteractiveAgent, deploymentBacksRetainedControl, } from "./tangle-deployment-capabilities.js";
|
|
4
4
|
import { clientObservationSurfaceSupport, observationSurfaceSupport, } from "./tangle-observation.js";
|
|
@@ -428,11 +428,7 @@ export function capabilitiesForClient(declared, client) {
|
|
|
428
428
|
* mutated flag would describe a surface this environment does not have.
|
|
429
429
|
*/
|
|
430
430
|
export function frozenCapabilityDocument(document) {
|
|
431
|
-
|
|
432
|
-
return document;
|
|
433
|
-
for (const value of Object.values(document))
|
|
434
|
-
frozenCapabilityDocument(value);
|
|
435
|
-
return Object.freeze(document);
|
|
431
|
+
return deepFreeze(document);
|
|
436
432
|
}
|
|
437
433
|
/**
|
|
438
434
|
* Narrow a declared capability document to what this Sandbox instance backs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AgentEnvironmentStatus, AgentSessionStatus, PlacementInfo } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
-
import type { SandboxInstanceLike } from "./tangle-types.js";
|
|
1
|
+
import type { AgentEnvironmentCreation, AgentEnvironmentStatus, AgentSessionStatus, PlacementInfo } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
+
import type { SandboxCreateReceiptLike, SandboxInstanceLike } from "./tangle-types.js";
|
|
3
3
|
export declare function nonEmptyString(value: unknown): string | undefined;
|
|
4
4
|
export declare function optionalNonEmptyString(value: unknown, label: string): string | undefined;
|
|
5
5
|
export declare function placementInfoFromLoopPlacement(placement: unknown, box: SandboxInstanceLike): PlacementInfo;
|
|
@@ -16,3 +16,9 @@ export declare function sessionStatusFromUnknown(status: unknown): AgentSessionS
|
|
|
16
16
|
* "unknown" instead of fabricating an execution-scoped answer.
|
|
17
17
|
*/
|
|
18
18
|
export declare function executionBoundSessionStatus(payload: unknown, executionId: string): AgentSessionStatus;
|
|
19
|
+
/**
|
|
20
|
+
* Map the platform create receipt to the environment creation verdict. An
|
|
21
|
+
* `unknown` outcome, a null receipt, and an SDK without receipts all leave the
|
|
22
|
+
* verdict absent, so a consumer cannot read them as proof of creation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function creationFromSandboxCreateReceipt(receipt: SandboxCreateReceiptLike | null | undefined): AgentEnvironmentCreation | undefined;
|
|
@@ -117,3 +117,24 @@ export function executionBoundSessionStatus(payload, executionId) {
|
|
|
117
117
|
return sessionStatus;
|
|
118
118
|
return "unknown";
|
|
119
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Map the platform create receipt to the environment creation verdict. An
|
|
122
|
+
* `unknown` outcome, a null receipt, and an SDK without receipts all leave the
|
|
123
|
+
* verdict absent, so a consumer cannot read them as proof of creation.
|
|
124
|
+
*/
|
|
125
|
+
export function creationFromSandboxCreateReceipt(receipt) {
|
|
126
|
+
if (receipt === null || receipt === undefined)
|
|
127
|
+
return undefined;
|
|
128
|
+
switch (receipt.outcome) {
|
|
129
|
+
case "created":
|
|
130
|
+
return "created";
|
|
131
|
+
case "idempotent_replay":
|
|
132
|
+
return "replayed";
|
|
133
|
+
case "unknown":
|
|
134
|
+
return undefined;
|
|
135
|
+
default: {
|
|
136
|
+
const outcome = receipt.outcome;
|
|
137
|
+
throw new Error(`Tangle create receipt reported an unknown outcome: ${String(outcome)}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AgentTurnInputSchema } from "@tangle-network/agent-interface";
|
|
1
|
+
import { AgentTurnInputSchema, deepFreeze } from "@tangle-network/agent-interface";
|
|
2
2
|
import { AgentEnvironmentCapabilitiesSchema } from "@tangle-network/agent-interface/environment-provider";
|
|
3
3
|
import { environmentEventFromSandboxEvent } from "./tangle-events.js";
|
|
4
4
|
import { executionIdFromTurnInput, promptFromTurnInput, promptOptionsFromTurnInput, } from "./tangle-prompt.js";
|
|
5
5
|
import { resolveRetainedSessionControlRef } from "./tangle-session-control.js";
|
|
6
|
-
import { placementInfoFromLoopPlacement, statusFromUnknown, } from "./tangle-environment-values.js";
|
|
6
|
+
import { creationFromSandboxCreateReceipt, placementInfoFromLoopPlacement, statusFromUnknown, } from "./tangle-environment-values.js";
|
|
7
7
|
import { execResultFromSandboxExecResult } from "./tangle-result-values.js";
|
|
8
8
|
import { capabilitiesForSandbox, frozenCapabilityDocument, sandboxCapabilitySupport, } from "./tangle-capabilities.js";
|
|
9
9
|
import { readDeploymentCapabilitySupport } from "./tangle-deployment-capabilities.js";
|
|
@@ -76,9 +76,11 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
76
76
|
...(options.signal ? { signal: options.signal } : {}),
|
|
77
77
|
...(options.controlRef ? { runControlRef: options.controlRef } : {}),
|
|
78
78
|
});
|
|
79
|
+
const creation = creationFromSandboxCreateReceipt(box.createReceipt?.());
|
|
79
80
|
return {
|
|
80
81
|
id: environmentId,
|
|
81
82
|
provider: providerName,
|
|
83
|
+
...(creation === undefined ? {} : { creation }),
|
|
82
84
|
...(box.name ? { name: boundedString(box.name, "Tangle environment name") } : {}),
|
|
83
85
|
...(box.metadata ? { metadata: snapshotMetadata(box.metadata) } : {}),
|
|
84
86
|
capabilities,
|
|
@@ -302,11 +304,3 @@ export async function sandboxInstanceAsEnvironment(box, providerName, client, de
|
|
|
302
304
|
function snapshotMetadata(metadata) {
|
|
303
305
|
return deepFreeze(structuredClone(metadata));
|
|
304
306
|
}
|
|
305
|
-
function deepFreeze(value, seen = new Set()) {
|
|
306
|
-
if (value === null || typeof value !== "object" || seen.has(value))
|
|
307
|
-
return value;
|
|
308
|
-
seen.add(value);
|
|
309
|
-
for (const child of Object.values(value))
|
|
310
|
-
deepFreeze(child, seen);
|
|
311
|
-
return Object.freeze(value);
|
|
312
|
-
}
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { BackendRegistryEntry, BackendRegistryResponse, BackendType, CreateSandboxOptions, ExecResult as SandboxExecResult, PromptOptions, PromptResult, SandboxEvent } from "@tangle-network/sandbox";
|
|
2
2
|
import type { AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, AgentExecutionPreparationReceipt, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentProfile, InputPart, InteractionRequest, InteractionResponseCommand } from "@tangle-network/agent-interface";
|
|
3
3
|
import type { AgentEnvironmentCapabilities, AgentEnvironmentProvider, CreateAgentEnvironmentInput } from "@tangle-network/agent-interface/environment-provider";
|
|
4
|
+
/**
|
|
5
|
+
* The platform verdict for the create call that returned a sandbox.
|
|
6
|
+
* `created` means the call allocated the sandbox; `idempotent_replay` means an
|
|
7
|
+
* earlier call with the same idempotency key allocated it; `unknown` means the
|
|
8
|
+
* platform cannot prove either outcome.
|
|
9
|
+
*/
|
|
10
|
+
export interface SandboxCreateReceiptLike {
|
|
11
|
+
outcome: "created" | "idempotent_replay" | "unknown";
|
|
12
|
+
idempotencyKeyApplied: boolean;
|
|
13
|
+
}
|
|
4
14
|
export interface TangleExactProcessOptions {
|
|
5
15
|
teamId?: string;
|
|
6
16
|
}
|
|
@@ -367,6 +377,12 @@ export interface SandboxInstanceLike {
|
|
|
367
377
|
resourceUsage?(): Promise<SandboxResourceUsageLike | null>;
|
|
368
378
|
/** Interactive terminal transport. Absent on a client that cannot serve a PTY. */
|
|
369
379
|
terminals?: SandboxTerminalsLike;
|
|
380
|
+
/**
|
|
381
|
+
* The platform verdict for the create call that returned this instance.
|
|
382
|
+
* Absent on a Sandbox SDK older than 0.30.1; null for an instance resolved
|
|
383
|
+
* by id or when the platform reported no receipt.
|
|
384
|
+
*/
|
|
385
|
+
createReceipt?(): SandboxCreateReceiptLike | null;
|
|
370
386
|
refresh?(options?: {
|
|
371
387
|
signal?: AbortSignal;
|
|
372
388
|
}): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"LICENSE"
|
|
86
86
|
],
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@tangle-network/agent-interface": "^1.0
|
|
88
|
+
"@tangle-network/agent-interface": "^1.5.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@tangle-network/sandbox": ">=0.30.1 <1.0.0"
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"@types/node": "25.6.0",
|
|
103
103
|
"typescript": "^6.0.3",
|
|
104
104
|
"vitest": "^4.1.5",
|
|
105
|
-
"@tangle-network/agent-provider-testkit": "0.8.
|
|
105
|
+
"@tangle-network/agent-provider-testkit": "0.8.4"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"build": "tsc -p tsconfig.json",
|