@tangle-network/agent-app 0.63.6 → 0.63.8
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/default-backend.d.ts +46 -0
- package/dist/chat-routes/dispatch-first.d.ts +3 -2
- package/dist/chat-routes/index.d.ts +1 -0
- package/dist/chat-routes/index.js +13 -345
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/route-prewarm.d.ts +2 -0
- package/dist/chat-routes/route-storage.d.ts +13 -4
- package/dist/chat-routes/sandbox-model-source.d.ts +1 -0
- package/dist/chat-routes/turn-ownership.d.ts +2 -1
- package/dist/chat-routes/turn-route-contracts.d.ts +21 -5
- package/dist/{chunk-JRTWTADT.js → chunk-E3AOUTIR.js} +5 -2
- package/dist/chunk-E3AOUTIR.js.map +1 -0
- package/dist/{chunk-IDG2XR5O.js → chunk-EKXG4JSN.js} +2 -2
- package/dist/chunk-EKXG4JSN.js.map +1 -0
- package/dist/{chunk-YCMVNXAX.js → chunk-NUWSPR5O.js} +2 -2
- package/dist/{chunk-OCR36QGZ.js → chunk-UVMKP5IK.js} +65 -28
- package/dist/chunk-UVMKP5IK.js.map +1 -0
- package/dist/{chunk-XYSKMHWG.js → chunk-ZTFM2UDY.js} +549 -15
- package/dist/chunk-ZTFM2UDY.js.map +1 -0
- package/dist/public-consultation/index.js +3 -3
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/router-turn.d.ts +2 -2
- package/dist/runtime/router-turn.js +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/sandbox/prompt-events.d.ts +1 -1
- package/dist/sandbox/sandbox-run-error.d.ts +8 -0
- package/dist/sandbox/sandbox-run-tool.d.ts +5 -9
- package/dist/signoff/cli.js +1 -1
- package/dist/signoff/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-IDG2XR5O.js.map +0 -1
- package/dist/chunk-JRTWTADT.js.map +0 -1
- package/dist/chunk-OCR36QGZ.js.map +0 -1
- package/dist/chunk-XYSKMHWG.js.map +0 -1
- /package/dist/{chunk-YCMVNXAX.js.map → chunk-NUWSPR5O.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Shared D1 replay and authenticated
|
|
1
|
+
/** Shared D1 replay and authenticated workspace locks from the application's bindings. */
|
|
2
2
|
import { type TurnEventStore, type D1LikeForTurns } from '../stream/turn-buffer';
|
|
3
3
|
import { type TurnStreamNamespaceLike, type TurnStreamAuth, type TurnStreamLocationHint } from '../turn-stream/adapters';
|
|
4
4
|
import type { CreateChatTurnRoutesOptions } from './turn-route-contracts';
|
|
@@ -13,7 +13,7 @@ export interface ChatTurnStoreBindings {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
/** Keep the workspace-channel identity, authentication and region the same in both routes. */
|
|
16
|
-
export declare function createDefaultTurnLock<TContext>(store: ChatTurnStoreBindings): {
|
|
16
|
+
export declare function createDefaultTurnLock<TContext>(store: Pick<ChatTurnStoreBindings, 'lock' | 'region'>): {
|
|
17
17
|
acquire(args: import("../turn-stream").TurnLockSeamArgs<TContext>): Promise<import("../turn-stream").TurnLockSeamResult>;
|
|
18
18
|
release(handle: unknown): Promise<void>;
|
|
19
19
|
warm(target: {
|
|
@@ -21,7 +21,16 @@ export declare function createDefaultTurnLock<TContext>(store: ChatTurnStoreBind
|
|
|
21
21
|
threadId?: string;
|
|
22
22
|
}): Promise<void>;
|
|
23
23
|
};
|
|
24
|
-
export type ResolvedChatTurnRoutesOptions<TContext, TResource = unknown> = Omit<CreateChatTurnRoutesOptions<TContext, TResource>, 'turnStore'> & {
|
|
24
|
+
export type ResolvedChatTurnRoutesOptions<TContext, TResource = unknown> = Omit<CreateChatTurnRoutesOptions<TContext, TResource>, 'turnStore' | 'turnLock' | 'produce'> & {
|
|
25
25
|
turnStore: TurnEventStore;
|
|
26
|
+
turnLock?: Exclude<CreateChatTurnRoutesOptions<TContext, TResource>['turnLock'], false>;
|
|
27
|
+
produce: Exclude<CreateChatTurnRoutesOptions<TContext, TResource>['produce'], undefined | import('./default-backend').ChatTurnDefaultBackend>;
|
|
28
|
+
};
|
|
29
|
+
export declare function turnStorageBindings(options: {
|
|
30
|
+
turnStore: TurnEventStore | ChatTurnStoreBindings;
|
|
31
|
+
env?: import('./default-backend').ChatTurnEnvironment;
|
|
32
|
+
}): ChatTurnStoreBindings | undefined;
|
|
33
|
+
export declare function resolveTurnStorage<TContext, TResource>(options: CreateChatTurnRoutesOptions<TContext, TResource>): {
|
|
34
|
+
turnStore: TurnEventStore;
|
|
35
|
+
turnLock: import("./turn-route-contracts").ChatTurnLock<TContext, TResource> | undefined;
|
|
26
36
|
};
|
|
27
|
-
export declare function resolveTurnStorage<TContext, TResource>(options: CreateChatTurnRoutesOptions<TContext, TResource>): ResolvedChatTurnRoutesOptions<TContext, TResource>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { AssistantDraftWriter } from './draft-persistence';
|
|
2
2
|
import type { NativeCompletionHandoffOptions, NativeTimingTransfer } from './native-turn-timing';
|
|
3
3
|
import type { BufferedTurnTap } from '../stream/index';
|
|
4
|
-
import type { ChatTurnLock } from './turn-route-contracts';
|
|
4
|
+
import type { ChatTurnLock, ChatTurnRouteProducer } from './turn-route-contracts';
|
|
5
5
|
interface OwnershipState {
|
|
6
|
+
producer?: ChatTurnRouteProducer;
|
|
6
7
|
completionHandoff: boolean;
|
|
7
8
|
completionHandoffPromise: Promise<void> | undefined;
|
|
8
9
|
nativeTiming: NativeTimingTransfer | undefined;
|
|
@@ -72,7 +72,7 @@ export interface ChatTurnRouteProducer extends ChatTurnProducer {
|
|
|
72
72
|
* with the request's waitUntil, including when admission refuses an early
|
|
73
73
|
* Router call. Cleanup must handle and report its own failures. */
|
|
74
74
|
cleanup?: Promise<void>;
|
|
75
|
-
/**
|
|
75
|
+
/** No unconfirmed native execution remains: a terminal was observed or local preflight prevented dispatch. */
|
|
76
76
|
terminalObserved?(): boolean;
|
|
77
77
|
assistantParts?(): Array<Record<string, unknown>>;
|
|
78
78
|
/** MID-STREAM snapshot of the same projection, safe to call while the turn
|
|
@@ -158,7 +158,9 @@ export interface ChatTurnAuthorizeArgs {
|
|
|
158
158
|
body?: ChatTurnRequestPayload | ChatTurnCancelRequest;
|
|
159
159
|
/** The buffered turn id being replayed (replay intent only). */
|
|
160
160
|
turnId?: string;
|
|
161
|
-
/** The thread whose running turns are being discovered
|
|
161
|
+
/** The thread whose running turns are being discovered. Prewarm also uses
|
|
162
|
+
* running authorization, without a thread on page-open; the product may
|
|
163
|
+
* authorize its verified workspace or refuse that operation. */
|
|
162
164
|
threadId?: string;
|
|
163
165
|
/** The turn's trace (turn intent only). A product records its own child spans (a billing read, a workspace check) so the
|
|
164
166
|
* admission wait is named by step; the route already records `admission.authorize` around the whole call. */
|
|
@@ -397,6 +399,9 @@ interface ChatTurnLifecycleBase<TContext> {
|
|
|
397
399
|
executionId: string;
|
|
398
400
|
turnStreamId: string;
|
|
399
401
|
context: TContext;
|
|
402
|
+
/** Member row and backend observation facts, also reported on persistence failure. */
|
|
403
|
+
userMessageId?: string | null;
|
|
404
|
+
backendTerminal?: boolean;
|
|
400
405
|
}
|
|
401
406
|
/** When the turn's first visible word streamed, measured from `onTurnStart`. Absent when no word streamed. */
|
|
402
407
|
interface ChatTurnLifecycleTiming {
|
|
@@ -473,6 +478,10 @@ export interface ChatTurnLifecycle<TContext> {
|
|
|
473
478
|
/** What a settled turn reports to `onTurnComplete` — the product's
|
|
474
479
|
* post-processing seam (billing, titles, audit). */
|
|
475
480
|
export interface ChatTurnCompleteInput<TContext> {
|
|
481
|
+
/** Persisted member row for this execution, when insertion was enabled. */
|
|
482
|
+
userMessageId?: string | null;
|
|
483
|
+
/** False when a detached backend has not been observed to stop; its workspace stays fenced. */
|
|
484
|
+
backendTerminal?: boolean;
|
|
476
485
|
identity: ChatTurnIdentity;
|
|
477
486
|
finalText: string;
|
|
478
487
|
context: TContext;
|
|
@@ -518,6 +527,10 @@ export interface ChatTurnTraceOptions<TContext> {
|
|
|
518
527
|
}
|
|
519
528
|
/** Define options to configure chat turn routes including authorization, storage, and event buffering */
|
|
520
529
|
export interface CreateChatTurnRoutesOptions<TContext = void, TResource = unknown> {
|
|
530
|
+
/** Deployment bindings for the template defaults. Custom producers keep their own credentials and policy. */
|
|
531
|
+
env?: import('./default-backend').ChatTurnEnvironment;
|
|
532
|
+
/** Disable the inherited prewarm endpoint explicitly. It warms only authenticated thread locks. */
|
|
533
|
+
prewarm?: false;
|
|
521
534
|
/** Names the product in `deriveExecutionId` so retries land on the same
|
|
522
535
|
* substrate execution. */
|
|
523
536
|
projectId: string;
|
|
@@ -592,7 +605,7 @@ export interface CreateChatTurnRoutesOptions<TContext = void, TResource = unknow
|
|
|
592
605
|
* when selects the Router backend (default true); false selects sandbox,
|
|
593
606
|
* which always starts after admission. A function also starts after admission.
|
|
594
607
|
* Reused user rows always finish admission before either backend starts. */
|
|
595
|
-
produce
|
|
608
|
+
produce?: import('./default-backend').ChatTurnDefaultBackend | ((args: ChatTurnProduceArgs<TContext, TResource>) => ChatTurnRouteProducer | Promise<ChatTurnRouteProducer>) | {
|
|
596
609
|
router(args: ChatTurnProduceArgs<TContext, TResource>): ChatTurnRouterBackend | Promise<ChatTurnRouterBackend>;
|
|
597
610
|
when?(args: ChatTurnProduceArgs<TContext, TResource>): boolean;
|
|
598
611
|
sandbox?(args: ChatTurnProduceArgs<TContext, TResource>): ChatTurnSandboxBackend | Promise<ChatTurnSandboxBackend>;
|
|
@@ -600,8 +613,9 @@ export interface CreateChatTurnRoutesOptions<TContext = void, TResource = unknow
|
|
|
600
613
|
/** Single-flight lock acquired before durable effects and released once when
|
|
601
614
|
* the turn settles (including short-circuit/throw). `/turn-stream`'s
|
|
602
615
|
* `createDurableTurnLock` is the shared DO-backed implementation. Omit →
|
|
603
|
-
*
|
|
604
|
-
|
|
616
|
+
* the binding-derived workspace lock. `false` explicitly disables it. Native
|
|
617
|
+
* producers retain it until backend termination is observed. */
|
|
618
|
+
turnLock?: ChatTurnLock<TContext, TResource> | false;
|
|
605
619
|
/** Pre-turn readiness gate that can short-circuit with a product `Response`
|
|
606
620
|
* before the producer runs (the user row is already persisted). Runs after
|
|
607
621
|
* `turnLock.acquire`, before `beforeTurn`. Omit → always proceed.
|
|
@@ -741,6 +755,8 @@ export declare const INTENT_LINE_HISTORY_MESSAGES = 6;
|
|
|
741
755
|
export declare const INTENT_LINE_MAX_CHARS = 240;
|
|
742
756
|
/** Define routes to run, replay, and list running chat turns with streaming and reconnect support */
|
|
743
757
|
export interface ChatTurnRoutes {
|
|
758
|
+
/** POST — warm the server-authorized workspace lock; verify a named thread before allowing it. Never provisions paid compute. */
|
|
759
|
+
prewarm(request: Request): Promise<Response>;
|
|
744
760
|
/** POST — run one turn, streaming NDJSON. First line is
|
|
745
761
|
* `{type:'turn', turnId}` (the replay handle); the rest is the engine's
|
|
746
762
|
* event protocol. Pass the platform's `waitUntil` so the turn keeps
|
|
@@ -301,6 +301,9 @@ function firstOutputRow(kind, pin, sources, traceWired, calls, exports) {
|
|
|
301
301
|
function prewarmRow(sources) {
|
|
302
302
|
const usesBox = filesMatching(sources, /@tangle-network\/agent-app\/sandbox|\bensureWorkspaceSandbox\b/).length > 0;
|
|
303
303
|
if (!usesBox) return { id: "prewarm", label: "prewarm route", status: "na", detail: "the app opens no workspace box" };
|
|
304
|
+
const assembled = filesMatching(sources, /\bcreateChatTurnRoutes\s*[(<]/)[0];
|
|
305
|
+
const mounted = filesMatching(sources, /\bprewarm\s*:\s*[\w.]+\.prewarm\b|\.prewarm\s*\(\s*(?:request|c\.req\.raw)/)[0];
|
|
306
|
+
if (assembled && mounted) return { id: "prewarm", label: "prewarm route", status: "ok", detail: `assembled route in ${assembled.path}; mounted in ${mounted.path}` };
|
|
304
307
|
const shared = filesMatching(sources, /\bcreateWorkspacePrewarmRoute\b/)[0];
|
|
305
308
|
if (shared) return { id: "prewarm", label: "prewarm route", status: "ok", detail: `shared route in ${shared.path}` };
|
|
306
309
|
const local = sources.find((file) => /prewarm/i.test(file.path) || /['"`/]prewarm['"`/]/.test(file.text));
|
|
@@ -415,7 +418,7 @@ function checkAppDefaults(repoRoot, options = {}) {
|
|
|
415
418
|
{ row: trace.row, id: "turn-trace", optedOut: trace.optedOut },
|
|
416
419
|
{ row: firstOutputRow("visible", pin, sources, traceWired, calls, options.exports), id: "first-visible", optedOut: null },
|
|
417
420
|
{ row: firstOutputRow("text", pin, sources, traceWired, calls, options.exports), id: "first-text", optedOut: null },
|
|
418
|
-
{ row: prewarmRow(sources), id: "prewarm", optedOut: null },
|
|
421
|
+
{ row: prewarmRow(sources), id: "prewarm", optedOut: filesMatching(sources, /\bprewarm\s*:\s*false\b/).length ? "prewarm: false disables the inherited route" : null },
|
|
419
422
|
{ row: placementRow(configs), id: "placement", optedOut: null },
|
|
420
423
|
{ row: toolCountRow(), id: null, optedOut: null },
|
|
421
424
|
{ row: limitAlarmsRow(sources), id: "limit-alarms", optedOut: null },
|
|
@@ -2895,4 +2898,4 @@ export {
|
|
|
2895
2898
|
formatWorkspaceSurfaceReport,
|
|
2896
2899
|
runWorkspaceSurfaceCli
|
|
2897
2900
|
};
|
|
2898
|
-
//# sourceMappingURL=chunk-
|
|
2901
|
+
//# sourceMappingURL=chunk-E3AOUTIR.js.map
|