@tangle-network/agent-provider-tangle 5.0.0 → 5.0.1
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/tangle-environment-dispatch.d.ts +2 -1
- package/dist/tangle-environment-dispatch.js +4 -4
- package/dist/tangle-environment-session.d.ts +4 -16
- package/dist/tangle-environment-session.js +285 -307
- package/dist/tangle-environment.d.ts +1 -23
- package/dist/tangle-environment.js +198 -221
- package/dist/tangle-prompt.d.ts +6 -24
- package/dist/tangle-prompt.js +91 -89
- package/dist/tangle-types.d.ts +4 -10
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { AgentSessionRef, AgentTurnInput } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
+
import type { PromptOptions } from "@tangle-network/sandbox";
|
|
2
3
|
import type { SandboxInstanceLike } from "./tangle-types.js";
|
|
3
|
-
export declare function dispatchEnvironmentRun(box: SandboxInstanceLike, provider: string, environmentId: string): (input: AgentTurnInput) => Promise<AgentSessionRef>;
|
|
4
|
+
export declare function dispatchEnvironmentRun(box: SandboxInstanceLike, provider: string, environmentId: string, prepare: (options: PromptOptions) => Promise<PromptOptions>): (input: AgentTurnInput) => Promise<AgentSessionRef>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { promptFromTurnInput, promptOptionsFromTurnInput,
|
|
1
|
+
import { promptFromTurnInput, promptOptionsFromTurnInput, } from "./tangle-prompt.js";
|
|
2
2
|
import { retainedSessionControlRef, sessionPromptExecutionId, sessionPromptSessionId, sessionRefFromSandboxDispatch, } from "./tangle-session-control.js";
|
|
3
3
|
import { awaitWithSignal } from "./tangle-contract-safety.js";
|
|
4
4
|
import { interruptAfterAbort, sessionPromptRequestDigest, } from "./tangle-environment-control.js";
|
|
5
|
-
export function dispatchEnvironmentRun(box, provider, environmentId) {
|
|
5
|
+
export function dispatchEnvironmentRun(box, provider, environmentId, prepare) {
|
|
6
6
|
return async (input) => {
|
|
7
7
|
input.signal?.throwIfAborted();
|
|
8
8
|
const options = promptOptionsFromTurnInput(input, { provider, environmentId });
|
|
@@ -23,12 +23,12 @@ export function dispatchEnvironmentRun(box, provider, environmentId) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
const runControlRef = retainedSessionControlRef(expectedSessionId, expectedExecutionId, provider, environmentId, requestDigest, callerControlRef?.runId);
|
|
26
|
-
const promise = box.dispatchPrompt?.(promptFromTurnInput(input), await
|
|
26
|
+
const promise = box.dispatchPrompt?.(promptFromTurnInput(input), await prepare({
|
|
27
27
|
...options,
|
|
28
28
|
sessionId: expectedSessionId,
|
|
29
29
|
executionId: expectedExecutionId,
|
|
30
30
|
runControlRef,
|
|
31
|
-
}
|
|
31
|
+
}));
|
|
32
32
|
let dispatched;
|
|
33
33
|
try {
|
|
34
34
|
dispatched = await awaitWithSignal(promise, input.signal);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentSession, AgentSessionRef, AgentTurnInput } from "@tangle-network/agent-interface/environment-provider";
|
|
2
2
|
import type { AgentExactRunControlRef, AgentRunControlRef } from "@tangle-network/agent-interface";
|
|
3
|
-
import type { SandboxEvent } from "@tangle-network/sandbox";
|
|
4
|
-
import type {
|
|
3
|
+
import type { SandboxEvent, PromptOptions } from "@tangle-network/sandbox";
|
|
4
|
+
import type { SandboxSessionLike } from "./tangle-types.js";
|
|
5
5
|
import type { ExecutionUsageLog } from "./tangle-usage-log.js";
|
|
6
6
|
type ExactExecutionEventStream = (options: {
|
|
7
7
|
sessionId: string;
|
|
@@ -10,18 +10,6 @@ type ExactExecutionEventStream = (options: {
|
|
|
10
10
|
signal?: AbortSignal;
|
|
11
11
|
controlRef?: AgentExactRunControlRef;
|
|
12
12
|
}) => AsyncIterable<SandboxEvent>;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
* document grants retained control. Canonical cancellation is offered only
|
|
16
|
-
* under that grant: a `cancelRun` method the deployment does not honor is an
|
|
17
|
-
* action the caller selects and finds rejected on the wire.
|
|
18
|
-
* @param interactionResponses Whether the environment's narrowed capability
|
|
19
|
-
* document claims interaction responses. The method is offered only under
|
|
20
|
-
* that claim, so a caller never selects an answer the deployment cannot
|
|
21
|
-
* record.
|
|
22
|
-
* @param usageLog Sink for the token usage each execution measured. The
|
|
23
|
-
* environment observation reads it, because Sandbox reports usage per
|
|
24
|
-
* execution result and never for the environment.
|
|
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 | Promise<AgentTurnInput | void>, onExecution?: (executionId: string) => void, box?: SandboxInstanceLike): AgentSession;
|
|
13
|
+
/** Compose exact session control, replay, prompt preparation and usage. */
|
|
14
|
+
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, prepareOptions?: (options: PromptOptions) => Promise<PromptOptions>): AgentSession;
|
|
27
15
|
export {};
|