@tangle-network/agent-app 3.0.5 → 3.0.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.
@@ -82,13 +82,13 @@ import {
82
82
  turnCarriesFiles,
83
83
  turnPromptText,
84
84
  withProducerStream
85
- } from "../chunk-7YFJ7YCM.js";
85
+ } from "../chunk-LKDPKY7R.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-T6ZDWHP5.js";
92
92
  import "../chunk-F4TUZYMX.js";
93
93
  import {
94
94
  redactErrorMessage
@@ -28,7 +28,7 @@ import {
28
28
  sandboxRunFailureDetail,
29
29
  streamSandboxPrompt,
30
30
  turnStorageBindings
31
- } from "./chunk-FWLVAWKR.js";
31
+ } from "./chunk-T6ZDWHP5.js";
32
32
  import {
33
33
  redactErrorMessage
34
34
  } from "./chunk-MH74DY2I.js";
@@ -4154,4 +4154,4 @@ export {
4154
4154
  createChatTurnRoutes,
4155
4155
  streamChatRouteAsSandboxEvents
4156
4156
  };
4157
- //# sourceMappingURL=chunk-7YFJ7YCM.js.map
4157
+ //# sourceMappingURL=chunk-LKDPKY7R.js.map
@@ -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",
@@ -2009,12 +2012,13 @@ var RECENT_LIMIT = 1e3;
2009
2012
  var REASONS = ["page-open", "composer-focus", "heartbeat"];
2010
2013
  var THREAD_ID = /^[A-Za-z0-9_:.-]{1,128}$/;
2011
2014
  async function requestIntent(request) {
2012
- if (Number(request.headers.get("content-length") ?? 0) > 1024) return { reason: "page-open" };
2015
+ if (Number(request.headers.get("content-length") ?? 0) > 1024) return void 0;
2013
2016
  try {
2014
2017
  const body = await request.clone().json();
2015
2018
  const reason = REASONS.find((known) => known === body?.reason) ?? "page-open";
2016
- const threadId = typeof body?.threadId === "string" && THREAD_ID.test(body.threadId) ? body.threadId : void 0;
2017
- return { reason, ...threadId ? { threadId } : {} };
2019
+ const threadId = body?.threadId;
2020
+ if (threadId !== void 0 && (typeof threadId !== "string" || !THREAD_ID.test(threadId))) return void 0;
2021
+ return { reason, ...typeof threadId === "string" ? { threadId } : {} };
2018
2022
  } catch {
2019
2023
  return { reason: "page-open" };
2020
2024
  }
@@ -2129,9 +2133,11 @@ function createWorkspacePrewarmRoute(options) {
2129
2133
  return new Response(null, { status: 405, headers: { Allow: "POST" } });
2130
2134
  }
2131
2135
  if (isAutomatedPrewarmRequest(request)) return reply({ outcome: "automated", ms: 0 });
2136
+ const intent = await requestIntent(request);
2137
+ if (!intent) return reply({ outcome: "declined", ms: now() - started, reason: "invalid_thread" });
2132
2138
  let auth;
2133
2139
  try {
2134
- auth = await options.authorize({ request, context, ...await requestIntent(request) });
2140
+ auth = await options.authorize({ request, context, ...intent });
2135
2141
  } catch (err) {
2136
2142
  emit({ type: "failed", key: "", ms: now() - started, error: err instanceof Error ? err.message : String(err) });
2137
2143
  return reply({ outcome: "failed", ms: now() - started });
@@ -4326,4 +4332,4 @@ export {
4326
4332
  deleteSecret,
4327
4333
  mintSandboxScopedToken
4328
4334
  };
4329
- //# sourceMappingURL=chunk-FWLVAWKR.js.map
4335
+ //# sourceMappingURL=chunk-T6ZDWHP5.js.map