@tangle-network/agent-app 0.48.4 → 0.49.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.
- package/dist/chat-routes/completed-sandbox-turn.d.ts +8 -1
- package/dist/chat-routes/index.d.ts +1 -0
- package/dist/chat-routes/index.js +256 -58
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/native-completion.d.ts +76 -0
- package/dist/chat-routes/turn-routes.d.ts +11 -0
- package/dist/{chunk-3SIQ4CDA.js → chunk-7S24DNVP.js} +10 -3
- package/dist/chunk-7S24DNVP.js.map +1 -0
- package/dist/{chunk-N4RR4WAI.js → chunk-HXTJXODG.js} +29 -6
- package/dist/chunk-HXTJXODG.js.map +1 -0
- package/dist/{chunk-MFLUDFD3.js → chunk-V4YGTOCS.js} +41 -9
- package/dist/chunk-V4YGTOCS.js.map +1 -0
- package/dist/preset-cloudflare/detached-turn-workflow.d.ts +11 -6
- package/dist/preset-cloudflare/index.d.ts +1 -0
- package/dist/preset-cloudflare/index.js +36 -1
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/preset-cloudflare/native-completion-workflow.d.ts +42 -0
- package/dist/public-consultation/index.js +2 -2
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/stream/index.js +1 -1
- package/dist/stream/turn-buffer.d.ts +17 -0
- package/dist/turn-stream/index.js +3 -1
- package/dist/turn-stream/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-3SIQ4CDA.js.map +0 -1
- package/dist/chunk-MFLUDFD3.js.map +0 -1
- package/dist/chunk-N4RR4WAI.js.map +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact terminal observation for a native Sandbox execution that another
|
|
3
|
+
* request already admitted. This module never sends a prompt, calls
|
|
4
|
+
* `driveTurn`, or cancels a run.
|
|
5
|
+
*/
|
|
6
|
+
import type { SandboxInstance } from '@tangle-network/sandbox';
|
|
7
|
+
import type { ChatTurnUsage } from './turn-routes';
|
|
8
|
+
export interface NativeCompletionReceipt {
|
|
9
|
+
state: 'completed' | 'failed';
|
|
10
|
+
text: string;
|
|
11
|
+
parts: Array<Record<string, unknown>>;
|
|
12
|
+
/** An empty object is an unknown usage receipt, never a measured zero. */
|
|
13
|
+
usage: ChatTurnUsage;
|
|
14
|
+
servedModel?: string;
|
|
15
|
+
servedProvider?: string;
|
|
16
|
+
servedSource?: 'request' | 'environment' | 'profile';
|
|
17
|
+
error?: string;
|
|
18
|
+
completedTurnIds: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface NativeCompletionAdmission {
|
|
21
|
+
executionId: string;
|
|
22
|
+
state: 'open' | 'closed';
|
|
23
|
+
admittedTurnIds: readonly string[];
|
|
24
|
+
ownerLeaseUntil: Date | number;
|
|
25
|
+
updatedAt?: Date | number;
|
|
26
|
+
closedAt?: Date | number | null;
|
|
27
|
+
}
|
|
28
|
+
/** Product persistence for the one admission that authorizes this observer. */
|
|
29
|
+
export interface NativeCompletionAdmissionStore {
|
|
30
|
+
read(executionId: string): Promise<NativeCompletionAdmission | null>;
|
|
31
|
+
renew(executionId: string, now: Date): Promise<NativeCompletionAdmission | null>;
|
|
32
|
+
closeExpired(executionId: string, now: Date): Promise<NativeCompletionAdmission | null>;
|
|
33
|
+
}
|
|
34
|
+
/** The official Sandbox reads needed for exact native completion observation. */
|
|
35
|
+
export type NativeCompletionSessionSource = Pick<SandboxInstance, 'findCompletedTurn' | 'session'>;
|
|
36
|
+
export interface NativeCompletionObservationOptions {
|
|
37
|
+
/** Null when the product cannot currently resolve the admitted Sandbox. */
|
|
38
|
+
source: NativeCompletionSessionSource | null;
|
|
39
|
+
admissionStore: NativeCompletionAdmissionStore;
|
|
40
|
+
executionId: string;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
turnId: string;
|
|
43
|
+
registeredAt: number;
|
|
44
|
+
absentDispatchDeadlineMs?: number;
|
|
45
|
+
receiptDeadlineMs?: number;
|
|
46
|
+
now?: number;
|
|
47
|
+
}
|
|
48
|
+
export type NativeCompletionObservation = {
|
|
49
|
+
state: 'running';
|
|
50
|
+
} | {
|
|
51
|
+
state: 'completed';
|
|
52
|
+
receipt: NativeCompletionReceipt;
|
|
53
|
+
} | {
|
|
54
|
+
state: 'failed';
|
|
55
|
+
receipt: NativeCompletionReceipt;
|
|
56
|
+
};
|
|
57
|
+
/** One exact turn receipt before an admission's ordered aggregate. */
|
|
58
|
+
export interface NativeCompletionTurnReceipt {
|
|
59
|
+
turnId: string;
|
|
60
|
+
state: 'completed' | 'failed';
|
|
61
|
+
text: string;
|
|
62
|
+
parts: Array<Record<string, unknown>>;
|
|
63
|
+
usage: ChatTurnUsage;
|
|
64
|
+
servedModel?: string;
|
|
65
|
+
servedProvider?: string;
|
|
66
|
+
servedSource?: 'request' | 'environment' | 'profile';
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Assemble admitted exact receipts in dispatch order. Missing usage stays unknown. */
|
|
70
|
+
export declare function aggregateNativeCompletionReceipts(turns: readonly NativeCompletionTurnReceipt[]): NativeCompletionReceipt;
|
|
71
|
+
/**
|
|
72
|
+
* Observe only the turns admitted under `executionId`. Transport failures throw
|
|
73
|
+
* so the durable owner retries. A missing or partial terminal record remains
|
|
74
|
+
* `running` until the configured deadline; it never starts another run.
|
|
75
|
+
*/
|
|
76
|
+
export declare function observeNativeCompletion(options: NativeCompletionObservationOptions): Promise<NativeCompletionObservation>;
|
|
@@ -244,6 +244,17 @@ export interface ChatTurnProduceArgs<TContext> {
|
|
|
244
244
|
* resolved without a usable id.
|
|
245
245
|
* - a string — the row id, for `contextGate`, `beforeTurn`, and `produce`. */
|
|
246
246
|
userMessageId?: string | null;
|
|
247
|
+
/**
|
|
248
|
+
* Transfer completion ownership to a product-owned durable runner. The
|
|
249
|
+
* product MUST first register that runner durably, then await this callback
|
|
250
|
+
* before dispatching native execution. Once it resolves, this route remains
|
|
251
|
+
* a live event projector only: it no longer writes or settles the assistant
|
|
252
|
+
* transcript, lifecycle hooks, lock, or replay-buffer status.
|
|
253
|
+
*
|
|
254
|
+
* Optional for source compatibility with synthetic producers. Every
|
|
255
|
+
* `createChatTurnRoutes` invocation supplies it before `produce` runs.
|
|
256
|
+
*/
|
|
257
|
+
handoffCompletion?: () => Promise<void>;
|
|
247
258
|
}
|
|
248
259
|
/** One event as it crosses the route: the producer's own vocabulary, or an
|
|
249
260
|
* injected keepalive. Same shape the engine forwards verbatim.
|
|
@@ -1547,8 +1547,11 @@ async function listStopped(client, name) {
|
|
|
1547
1547
|
}
|
|
1548
1548
|
async function deleteBox(box) {
|
|
1549
1549
|
try {
|
|
1550
|
-
await box.delete();
|
|
1550
|
+
const acknowledgement = await box.delete({ until: "removed" });
|
|
1551
1551
|
livenessVerifiedAt.delete(box.id);
|
|
1552
|
+
if (acknowledgement.removal === "pending") {
|
|
1553
|
+
return fail(new Error(`sandbox ${box.id} removal is still pending; retry replacement after removal completes`));
|
|
1554
|
+
}
|
|
1552
1555
|
return ok(void 0);
|
|
1553
1556
|
} catch (err) {
|
|
1554
1557
|
return fail(err);
|
|
@@ -2010,7 +2013,11 @@ async function provisionWorkspaceSandbox(shell, options) {
|
|
|
2010
2013
|
let replacementRequested = false;
|
|
2011
2014
|
const resources = shell.resources ?? DEFAULT_SANDBOX_RESOURCES;
|
|
2012
2015
|
const resumeTimeout = shell.provisionTimeoutMs ?? DEFAULT_PROVISION_TIMEOUT_MS;
|
|
2013
|
-
|
|
2016
|
+
let existing = await listRunning(client, name);
|
|
2017
|
+
if (forceNew && existing.succeeded && !existing.value) {
|
|
2018
|
+
existing = await listStopped(client, name);
|
|
2019
|
+
}
|
|
2020
|
+
if (forceNew && !existing.succeeded) throw existing.error;
|
|
2014
2021
|
if (existing.succeeded && existing.value) {
|
|
2015
2022
|
const found = existing.value;
|
|
2016
2023
|
if (forceNew) {
|
|
@@ -2837,4 +2844,4 @@ export {
|
|
|
2837
2844
|
isTerminalPromptEvent,
|
|
2838
2845
|
detectInteractiveQuestion
|
|
2839
2846
|
};
|
|
2840
|
-
//# sourceMappingURL=chunk-
|
|
2847
|
+
//# sourceMappingURL=chunk-7S24DNVP.js.map
|