@tangle-network/agent-app 0.45.19 → 0.45.21

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.
@@ -66,8 +66,9 @@ type ToolAuthResult = {
66
66
  * than after — verifying against an absent subject is not a check at all.
67
67
  */
68
68
  declare function authenticateToolRequest(request: Request, opts: AuthenticateOptions): Promise<ToolAuthResult>;
69
- /** Read a tool's argument object from the request body, tolerant of MCP host
70
- * aliases (`args` / `arguments`) or a bare body. Returns null on non-JSON. */
69
+ /** Read a tool's argument object from the request body, tolerant of direct
70
+ * aliases (`args` / `arguments`), Streamable HTTP MCP (`params.arguments`),
71
+ * or a bare body. Returns null on non-JSON. */
71
72
  declare function readToolArgs<T>(request: Request): Promise<T | null>;
72
73
 
73
74
  export { type AuthenticateOptions as A, type CapabilitySubject as C, DEFAULT_HEADER_NAMES as D, type ToolHeaderNames as T, type ToolAuthResult as a, authenticateToolRequest as b, readToolArgs as r };
@@ -16,7 +16,7 @@ import '../contract-OxG_jVMx.js';
16
16
  import '../types-CCeYywdS.js';
17
17
  import '../plans/index.js';
18
18
  import '@tangle-network/sandbox/core';
19
- import '../auth-B69PcJjv.js';
19
+ import '../auth-DJjJBtYw.js';
20
20
  import '../types-DbU-oO5h.js';
21
21
  import '../harness/index.js';
22
22
  import '../model-CdCDfBA9.js';
@@ -100,11 +100,11 @@ import {
100
100
  flattenHistory,
101
101
  readSandboxBinaryBytes,
102
102
  statSandboxFileSize
103
- } from "../chunk-OS62B34S.js";
103
+ } from "../chunk-7V2I3JGZ.js";
104
104
  import "../chunk-TH7L265V.js";
105
105
  import "../chunk-LWSJK546.js";
106
- import "../chunk-C5OIABSB.js";
107
- import "../chunk-YOFQO4R6.js";
106
+ import "../chunk-ZSGTG6PK.js";
107
+ import "../chunk-KBJL6LIW.js";
108
108
  import "../chunk-YEFFHORB.js";
109
109
  import "../chunk-S5SRJJQG.js";
110
110
  import "../chunk-JML7WKWU.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-LWSJK546.js";
8
8
  import {
9
9
  buildAppToolMcpServer
10
- } from "./chunk-YOFQO4R6.js";
10
+ } from "./chunk-KBJL6LIW.js";
11
11
  import {
12
12
  resolveTangleExecutionEnvironment,
13
13
  trimOrNull
@@ -897,6 +897,38 @@ async function resolveSandboxClientCredentials(options = {}) {
897
897
  `Sandbox credentials are required for ${environment} (provide a provision callback${directHint}).`
898
898
  );
899
899
  }
900
+ function isWellFormedDomainPattern(pattern) {
901
+ if (!pattern || pattern.startsWith(".") || pattern.includes("..")) return false;
902
+ const labels = pattern.split(".");
903
+ if (labels.some((label) => label.length === 0)) return false;
904
+ for (let index = 1; index < labels.length; index += 1) {
905
+ if (labels[index].includes("*")) return false;
906
+ }
907
+ const head = labels[0];
908
+ if (head === "*" || head === "**") return labels.length >= 2;
909
+ return !head.includes("*");
910
+ }
911
+ var PYPI_EGRESS_DOMAINS = ["pypi.org", "files.pythonhosted.org", "pypi.python.org"];
912
+ function buildProductEgressPolicy(publicOrigin, extraDomains = []) {
913
+ const origin = typeof publicOrigin === "string" ? new URL(publicOrigin) : publicOrigin;
914
+ if (origin.protocol !== "http:" && origin.protocol !== "https:") {
915
+ throw new Error(`Product egress origin must use http or https: ${origin.protocol}`);
916
+ }
917
+ if (!origin.hostname) throw new Error("Product egress origin must include a hostname");
918
+ const domains = /* @__PURE__ */ new Set([origin.hostname.toLowerCase(), "models.dev"]);
919
+ for (const value of extraDomains) {
920
+ const domain = value.trim().toLowerCase().replace(/\.$/, "");
921
+ if (!domain || domain.includes("://") || domain.includes("/") || domain.includes(":") || !isWellFormedDomainPattern(domain)) {
922
+ throw new Error(`Product egress domain must be a hostname or wildcard: ${value}`);
923
+ }
924
+ domains.add(domain);
925
+ }
926
+ return {
927
+ mode: "strict",
928
+ allowDomains: [...domains],
929
+ includeImplicitDomains: false
930
+ };
931
+ }
900
932
  var DEFAULT_SIDECAR_PROCESS_PATTERN = "opencode|claude|codex";
901
933
  var DEFAULT_SANDBOX_RESOURCES = {
902
934
  image: "universal",
@@ -1595,7 +1627,7 @@ async function peekWorkspaceSandbox(shell, options) {
1595
1627
  return { status: "running", box: match };
1596
1628
  }
1597
1629
  async function finalizeExistingBox(shell, client, box, stage, name, workspaceId, userId, harness, scope) {
1598
- await assertExistingBoxEgress(box, shell.egressPolicy, stage, name);
1630
+ await assertExistingBoxEgress(box, shell.egressPolicy, shell.migrateEgressPolicy, stage, name);
1599
1631
  const written = await materializeDeferredFilesForExistingBox(
1600
1632
  shell,
1601
1633
  client,
@@ -1635,7 +1667,7 @@ function normalizedEgressPolicy(policy) {
1635
1667
  }
1636
1668
  return JSON.stringify(canonicalizeJson(normalized));
1637
1669
  }
1638
- async function assertExistingBoxEgress(box, desired, stage, name) {
1670
+ async function assertExistingBoxEgress(box, desired, migrate, stage, name) {
1639
1671
  if (!desired) return;
1640
1672
  let current;
1641
1673
  try {
@@ -1649,6 +1681,20 @@ async function assertExistingBoxEgress(box, desired, stage, name) {
1649
1681
  const matchingPolicy = normalizedEgressPolicy(current.policy) === normalizedEgressPolicy(desired);
1650
1682
  const explicitSource = current.source !== "platform";
1651
1683
  if (matchingPolicy && explicitSource) return;
1684
+ if (migrate) {
1685
+ try {
1686
+ await box.egress.update(desired);
1687
+ const migrated = await box.egress.get();
1688
+ const migratedPolicy = normalizedEgressPolicy(migrated.policy) === normalizedEgressPolicy(desired);
1689
+ if (migratedPolicy && migrated.source !== "platform") return;
1690
+ current = migrated;
1691
+ } catch (cause) {
1692
+ const error = cause instanceof Error ? cause : new Error(String(cause));
1693
+ throw new Error(`egress policy migration failed on ${stage} box ${name}: ${error.message}`, {
1694
+ cause: error
1695
+ });
1696
+ }
1697
+ }
1652
1698
  throw new SandboxEgressPolicyMismatchError(
1653
1699
  stage,
1654
1700
  name,
@@ -2222,6 +2268,8 @@ export {
2222
2268
  PREWARM_CLAIM_TABLE_DDL,
2223
2269
  createD1PrewarmClaimStore,
2224
2270
  resolveSandboxClientCredentials,
2271
+ PYPI_EGRESS_DOMAINS,
2272
+ buildProductEgressPolicy,
2225
2273
  DEFAULT_SIDECAR_PROCESS_PATTERN,
2226
2274
  DEFAULT_SANDBOX_RESOURCES,
2227
2275
  getClient,
@@ -2268,4 +2316,4 @@ export {
2268
2316
  isTerminalPromptEvent,
2269
2317
  detectInteractiveQuestion
2270
2318
  };
2271
- //# sourceMappingURL=chunk-OS62B34S.js.map
2319
+ //# sourceMappingURL=chunk-7V2I3JGZ.js.map