@tangle-network/agent-app 0.63.6 → 0.63.7

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.
Files changed (35) hide show
  1. package/dist/chat-routes/default-backend.d.ts +46 -0
  2. package/dist/chat-routes/dispatch-first.d.ts +3 -2
  3. package/dist/chat-routes/index.d.ts +1 -0
  4. package/dist/chat-routes/index.js +13 -345
  5. package/dist/chat-routes/index.js.map +1 -1
  6. package/dist/chat-routes/route-prewarm.d.ts +2 -0
  7. package/dist/chat-routes/route-storage.d.ts +13 -4
  8. package/dist/chat-routes/sandbox-model-source.d.ts +1 -0
  9. package/dist/chat-routes/turn-ownership.d.ts +2 -1
  10. package/dist/chat-routes/turn-route-contracts.d.ts +21 -5
  11. package/dist/{chunk-XYSKMHWG.js → chunk-42QCR4CV.js} +548 -15
  12. package/dist/chunk-42QCR4CV.js.map +1 -0
  13. package/dist/{chunk-JRTWTADT.js → chunk-E3AOUTIR.js} +5 -2
  14. package/dist/chunk-E3AOUTIR.js.map +1 -0
  15. package/dist/{chunk-IDG2XR5O.js → chunk-EKXG4JSN.js} +2 -2
  16. package/dist/chunk-EKXG4JSN.js.map +1 -0
  17. package/dist/{chunk-YCMVNXAX.js → chunk-NUWSPR5O.js} +2 -2
  18. package/dist/{chunk-OCR36QGZ.js → chunk-UVMKP5IK.js} +65 -28
  19. package/dist/chunk-UVMKP5IK.js.map +1 -0
  20. package/dist/public-consultation/index.js +3 -3
  21. package/dist/runtime/index.js +2 -2
  22. package/dist/runtime/router-turn.d.ts +2 -2
  23. package/dist/runtime/router-turn.js +1 -1
  24. package/dist/sandbox/index.js +1 -1
  25. package/dist/sandbox/prompt-events.d.ts +1 -1
  26. package/dist/sandbox/sandbox-run-error.d.ts +8 -0
  27. package/dist/sandbox/sandbox-run-tool.d.ts +5 -9
  28. package/dist/signoff/cli.js +1 -1
  29. package/dist/signoff/index.js +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-IDG2XR5O.js.map +0 -1
  32. package/dist/chunk-JRTWTADT.js.map +0 -1
  33. package/dist/chunk-OCR36QGZ.js.map +0 -1
  34. package/dist/chunk-XYSKMHWG.js.map +0 -1
  35. /package/dist/{chunk-YCMVNXAX.js.map → chunk-NUWSPR5O.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import type { CreateChatTurnRoutesOptions } from './turn-route-contracts';
2
+ export declare function createChatPrewarm<TContext, TResource>(options: CreateChatTurnRoutesOptions<TContext, TResource>): (request: Request) => Promise<Response>;
@@ -1,4 +1,4 @@
1
- /** Shared D1 replay and authenticated thread locks from the application's bindings. */
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>;
@@ -16,5 +16,6 @@ export declare function createSandboxModelSource(options: SandboxChatProducerOpt
16
16
  modelState: {
17
17
  effectiveBackend: ReturnType<typeof parseEffectiveBackend>;
18
18
  };
19
+ openAttempts: () => number;
19
20
  };
20
21
  export {};
@@ -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
- /** Actual backend result/done was observed; transport EOF/error alone is not completion. */
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 (running intent only). */
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: ((args: ChatTurnProduceArgs<TContext, TResource>) => ChatTurnRouteProducer | Promise<ChatTurnRouteProducer>) | {
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
- * no lock. */
604
- turnLock?: ChatTurnLock<TContext, TResource>;
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