@tangle-network/agent-app 3.0.4 → 3.0.6

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.
@@ -46,6 +46,10 @@ export interface ChatTurnDefaultBackend<TContext = unknown, TResource = unknown>
46
46
  }
47
47
  export declare function defaultChatShell(projectId: string, env: ChatTurnEnvironment, config: ChatTurnDefaultBackend): SandboxRuntimeConfig;
48
48
  export declare function createDefaultChatBackend<TContext, TResource>(projectId: string, env: ChatTurnEnvironment, config: ChatTurnDefaultBackend<TContext, TResource>, bindings?: ChatTurnStoreBindings, modelPolicy?: ModelPolicy): {
49
+ prewarm: (scope: {
50
+ workspaceId: string;
51
+ userId: string;
52
+ }) => Promise<void> | Promise<import("../sandbox/prewarm.js").PrewarmResult | undefined>;
49
53
  when: (args: ChatTurnProduceArgs<TContext, TResource>) => boolean;
50
54
  router(args: ChatTurnProduceArgs<TContext, TResource>): Promise<ChatTurnHybridConfiguration>;
51
55
  sandbox: (args: ChatTurnProduceArgs<TContext, TResource>) => Promise<{
@@ -82,13 +82,13 @@ import {
82
82
  turnCarriesFiles,
83
83
  turnPromptText,
84
84
  withProducerStream
85
- } from "../chunk-JDNGAX4C.js";
85
+ } from "../chunk-VGGSCEI6.js";
86
86
  import "../chunk-SBHFMDR7.js";
87
87
  import "../chunk-H6BRJU5M.js";
88
88
  import "../chunk-4DBHC63F.js";
89
89
  import "../chunk-RN4WPTBH.js";
90
90
  import "../chunk-MM6RLOXF.js";
91
- import "../chunk-FWLVAWKR.js";
91
+ import "../chunk-FDPQ67MN.js";
92
92
  import "../chunk-F4TUZYMX.js";
93
93
  import {
94
94
  redactErrorMessage
@@ -1,2 +1,5 @@
1
- import type { CreateChatTurnRoutesOptions } from './turn-route-contracts.js';
2
- export declare function createChatPrewarm<TContext, TResource>(options: CreateChatTurnRoutesOptions<TContext, TResource>): (request: Request) => Promise<Response>;
1
+ import type { ChatTurnRequestContext, CreateChatTurnRoutesOptions } from './turn-route-contracts.js';
2
+ export declare function createChatPrewarm<TContext, TResource>(options: CreateChatTurnRoutesOptions<TContext, TResource>, box?: (scope: {
3
+ workspaceId: string;
4
+ userId: string;
5
+ }) => Promise<unknown>): (request: Request, ctx?: ChatTurnRequestContext) => Promise<Response>;
@@ -566,8 +566,8 @@ export interface ChatTurnTraceOptions<TContext> {
566
566
  export interface CreateChatTurnRoutesOptions<TContext = void, TResource = unknown> {
567
567
  /** Deployment bindings for the template defaults. Custom producers keep their own credentials and policy. */
568
568
  env?: import('./default-backend.js').ChatTurnEnvironment;
569
- /** Disable the inherited prewarm endpoint explicitly. It warms only authenticated thread locks. */
570
- prewarm?: false;
569
+ /** `false` disables the prewarm endpoint; `'box'` also brings up the default backend's box on page open (paid compute). */
570
+ prewarm?: false | 'box';
571
571
  /** Names the product in `deriveExecutionId` so retries land on the same
572
572
  * substrate execution. */
573
573
  projectId: string;
@@ -797,8 +797,8 @@ export declare const INTENT_LINE_HISTORY_MESSAGES = 6;
797
797
  export declare const INTENT_LINE_MAX_CHARS = 240;
798
798
  /** Define routes to run, replay, and list running chat turns with streaming and reconnect support */
799
799
  export interface ChatTurnRoutes {
800
- /** POST — warm the server-authorized workspace lock; verify a named thread before allowing it. Never provisions paid compute. */
801
- prewarm(request: Request): Promise<Response>;
800
+ /** POST — warm the server-authorized workspace lock (and with `prewarm: 'box'` its box, under `ctx.waitUntil`); verify a named thread first. */
801
+ prewarm(request: Request, ctx?: ChatTurnRequestContext): Promise<Response>;
802
802
  /** POST — run one turn, streaming NDJSON. First line is
803
803
  * `{type:'turn', turnId}` (the replay handle); the rest is the engine's
804
804
  * event protocol. Pass the platform's `waitUntil` so the turn keeps
@@ -822,6 +822,8 @@ async function* detachedSandboxPromptEvents(box, prompt, options, backend) {
822
822
  executionId,
823
823
  turnId,
824
824
  backend,
825
+ keepEvents: true,
826
+ ...options.signal ? { signal: options.signal } : {},
825
827
  ...options.expectedPublicProfileRequestDigest ? { expectedPublicProfileRequestDigest: options.expectedPublicProfileRequestDigest } : {},
826
828
  ...options.expectedSecretProfileReceipt ? { expectedSecretProfileReceipt: options.expectedSecretProfileReceipt } : {},
827
829
  ...options.requireVisibleAssistantOutput !== void 0 ? { requireVisibleAssistantOutput: options.requireVisibleAssistantOutput } : {},
@@ -842,9 +844,10 @@ async function* detachedSandboxPromptEvents(box, prompt, options, backend) {
842
844
  }
843
845
  }
844
846
  if (admission && (admission.sessionId !== sessionId || admission.executionId !== executionId)) {
847
+ for await (const _ of admission.events ?? []) break;
845
848
  throw new Error("sandbox.detached_admission_identity_mismatch");
846
849
  }
847
- yield* box.streamPrompt("", {
850
+ yield* admission?.events ?? box.streamPrompt("", {
848
851
  sessionId,
849
852
  executionId,
850
853
  lastEventId: lastEventId || "0",
@@ -4326,4 +4329,4 @@ export {
4326
4329
  deleteSecret,
4327
4330
  mintSandboxScopedToken
4328
4331
  };
4329
- //# sourceMappingURL=chunk-FWLVAWKR.js.map
4332
+ //# sourceMappingURL=chunk-FDPQ67MN.js.map