archal 0.9.15 → 0.9.17

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const version = "0.9.15";
3
+ const version = "0.9.17";
4
4
  const archal = { version };
5
5
 
6
6
  archal.default = archal;
@@ -94,16 +94,37 @@ var SESSION_STOP_CONFIRM_MAX_ATTEMPTS = 40;
94
94
  var ARCHAL_WORKSPACE_HEADER = "x-archal-workspace";
95
95
  var SESSION_RESPONSE_SCOPE_HEADER = "x-archal-session-response";
96
96
  var CLI_SESSION_TRANSPORT_SCOPE = "cli-transport";
97
+ var INFRASTRUCTURE_DETAIL_PATTERN = /(?:archal[-_\s]?(?:proxy|runtime|control[-_\s]?plane|service[-_\s]?gateway|openclaw[-_\s]?gateway)|control[-_\s]?plane|CLI_JWT_SECRET|CONTROL_PLANE|JWT_SECRET|ARCHAL_|runtime provider|runtime\/session|worker[-_\s]?endpoint|x[-_]?archal|service[-_\s]?gateway|service[-_\s]?runtime|provider[-_\s]?gateway|graphql[-_\s]?gateway|workflow[-_\s]?(?:runtime|harness|session)|harness[-_\s]?bootstrap|service_mcp_servers|\/service-gateway|tls intercept|sidecar|openclaw[-_\s]?gateway|credential_issuance_seed|hosted\s+clone|cloud(?:Clone|Twin)Urls|(?:clone|twin)[-_]access[-_]denied|twin[-_]not[-_]in[-_]catalog|pre[-_\s]?migration|stale[-_\s]?data)/i;
98
+ function publicHostedSessionDetail(detail) {
99
+ if (!detail?.trim()) {
100
+ return "";
101
+ }
102
+ return INFRASTRUCTURE_DETAIL_PATTERN.test(detail) ? "service routing failed to prepare the requested services." : detail;
103
+ }
104
+ function hostedSessionRequestErrorMessage(method, path2, status, detail) {
105
+ const publicDetail = publicHostedSessionDetail(detail);
106
+ return `Hosted session request failed (${method} ${path2}, HTTP ${status}${publicDetail ? `: ${publicDetail}` : ""}).`;
107
+ }
97
108
  var HostedSessionRequestError = class extends Error {
98
109
  constructor(method, path2, status, detail) {
99
- super(
100
- `Hosted session request failed (${method} ${path2}, HTTP ${status}${detail ? `: ${detail}` : ""}).`
101
- );
110
+ super(hostedSessionRequestErrorMessage(method, path2, status, detail));
102
111
  this.method = method;
103
112
  this.path = path2;
104
113
  this.status = status;
105
- this.detail = detail;
106
114
  this.name = "HostedSessionRequestError";
115
+ this.detail = publicHostedSessionDetail(detail);
116
+ Object.defineProperty(this, "internalDetail", {
117
+ value: detail,
118
+ enumerable: false,
119
+ configurable: false,
120
+ writable: false
121
+ });
122
+ }
123
+ detail;
124
+ internalDetail;
125
+ /** @internal */
126
+ getInternalDetailForRetry() {
127
+ return this.internalDetail;
107
128
  }
108
129
  };
109
130
  function trimEnv(name) {
@@ -215,7 +236,7 @@ function isTransientHostedSessionStartError(error48) {
215
236
  if (error48.status === 401 || error48.status === 429 || error48.status === 500 || error48.status === 502 || error48.status === 503 || error48.status === 504) {
216
237
  return true;
217
238
  }
218
- return detailLooksTransient(error48.detail);
239
+ return detailLooksTransient(error48.getInternalDetailForRetry());
219
240
  }
220
241
  if (error48 instanceof Error) {
221
242
  if (error48.message.startsWith("Hosted session timed out waiting for readiness")) {
@@ -21,7 +21,7 @@ import {
21
21
  requestedSeedsMatchSession,
22
22
  sleep,
23
23
  trimEnv
24
- } from "./chunk-WVRVNHAX.js";
24
+ } from "./chunk-CJJ32YQF.js";
25
25
 
26
26
  // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
27
27
  var require_code = __commonJS({
@@ -6793,7 +6793,7 @@ var require_dist = __commonJS({
6793
6793
  });
6794
6794
 
6795
6795
  // src/runtime-module-resolution.ts
6796
- import { dirname, extname, resolve } from "path";
6796
+ import { dirname, extname, isAbsolute, resolve } from "path";
6797
6797
  import { fileURLToPath } from "url";
6798
6798
  function resolveRuntimeModuleExtension(currentExtension, buildExtension) {
6799
6799
  if (currentExtension === ".ts" || currentExtension === ".mts" || currentExtension === ".cts") {
@@ -6807,7 +6807,7 @@ function resolveRuntimeModuleFromFile(currentModuleFile, relativePath, buildExte
6807
6807
  return resolve(dirname(currentModuleFile), relativePath.replace(/\.js$/, resolvedExtension));
6808
6808
  }
6809
6809
  function resolveRuntimeModule(relativePath, buildExtension) {
6810
- const currentModuleFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
6810
+ const currentModuleFile = typeof __filename === "string" && isAbsolute(__filename) ? __filename : fileURLToPath(import.meta.url);
6811
6811
  return resolveRuntimeModuleFromFile(currentModuleFile, relativePath, buildExtension);
6812
6812
  }
6813
6813
 
@@ -6843,6 +6843,7 @@ var RouteRuntimePolicyError = class extends Error {
6843
6843
 
6844
6844
  // ../route-runtime-core/src/runtime.ts
6845
6845
  import { createRequire } from "module";
6846
+ import { isAbsolute as isAbsolute2 } from "path";
6846
6847
 
6847
6848
  // ../../twins/core/src/errors.ts
6848
6849
  function errorMessage(error48) {
@@ -7094,7 +7095,7 @@ var discordRouteManifest = {
7094
7095
  ],
7095
7096
  diagnostics: {
7096
7097
  undeclared: ({ url: url2 }) => `Blocked Discord traffic to ${url2}. Declare discord in archalVitestProject({ services: { discord: { mode: "route" } } }) before calling the Discord REST API in Vitest.`,
7097
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Discord escape to ${url2}. Discord route mode is configured, but this domain is outside the approved Discord REST route surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7098
+ declaredEscape: ({ url: url2 }) => `Blocked Discord escape to ${url2}. Discord route mode is configured, but this domain is outside the approved Discord REST route surface.`,
7098
7099
  warning: ({ url: url2 }) => `Observed adjacent Discord domain ${url2}. Archal did not reroute this request because it is outside the approved Discord REST route surface.`
7099
7100
  },
7100
7101
  sdkIdentifiers: ["discord.js", "@discordjs/rest"],
@@ -7142,7 +7143,7 @@ var githubRouteManifest = {
7142
7143
  ],
7143
7144
  diagnostics: {
7144
7145
  undeclared: ({ url: url2 }) => `Blocked GitHub traffic to ${url2}. Declare github in archalVitestProject({ services: { github: { mode: "route" } } }) before using the official GitHub SDK.`,
7145
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked GitHub escape to ${url2}. GitHub route mode is configured, but this domain is outside the primary routed GitHub surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7146
+ declaredEscape: ({ url: url2 }) => `Blocked GitHub escape to ${url2}. GitHub route mode is configured, but this domain is outside the primary routed GitHub surface.`,
7146
7147
  warning: ({ url: url2 }) => `Observed adjacent GitHub domain ${url2}. Archal did not reroute this request because it is outside the primary GitHub API route surface.`
7147
7148
  },
7148
7149
  sdkIdentifiers: ["@octokit/rest"],
@@ -7170,7 +7171,7 @@ var googleWorkspaceRouteManifest = {
7170
7171
  ],
7171
7172
  diagnostics: {
7172
7173
  undeclared: ({ url: url2 }) => `Blocked Google Workspace traffic to ${url2}. Declare google-workspace in archalVitestProject({ services: { 'google-workspace': { mode: "route" } } }) before using the official Google client.`,
7173
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Google Workspace escape to ${url2}. Google Workspace route mode is configured, but this domain is outside the primary routed surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7174
+ declaredEscape: ({ url: url2 }) => `Blocked Google Workspace escape to ${url2}. Google Workspace route mode is configured, but this domain is outside the primary routed surface.`,
7174
7175
  warning: ({ url: url2 }) => `Observed adjacent Google Workspace domain ${url2}. Archal did not reroute this request because it is outside the primary Google Workspace API route surface.`
7175
7176
  },
7176
7177
  sdkIdentifiers: ["googleapis"],
@@ -7192,7 +7193,7 @@ var apifyRouteManifest = {
7192
7193
  ],
7193
7194
  diagnostics: {
7194
7195
  undeclared: ({ url: url2 }) => `Blocked Apify traffic to ${url2}. Declare apify before using the official Apify client.`,
7195
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Apify escape to ${url2}. Apify route mode is configured, but this domain is outside the primary routed Apify API surface. Configured clone base URL: ${configuredBaseUrl ?? "unknown"}.`,
7196
+ declaredEscape: ({ url: url2 }) => `Blocked Apify escape to ${url2}. Apify route mode is configured, but this domain is outside the primary routed Apify API surface.`,
7196
7197
  warning: ({ url: url2 }) => `Observed adjacent Apify domain ${url2}. Archal did not reroute this request because it is outside the primary Apify API route surface.`
7197
7198
  },
7198
7199
  sdkIdentifiers: ["apify-client", "apify"],
@@ -7217,7 +7218,7 @@ var jiraRouteManifest = {
7217
7218
  ],
7218
7219
  diagnostics: {
7219
7220
  undeclared: ({ url: url2 }) => `Blocked Jira traffic to ${url2}. Declare jira in archalVitestProject({ services: { jira: { mode: "route" } } }) before using the official Jira SDK.`,
7220
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Jira escape to ${url2}. Jira route mode is configured, but this domain is outside the primary routed Jira surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7221
+ declaredEscape: ({ url: url2 }) => `Blocked Jira escape to ${url2}. Jira route mode is configured, but this domain is outside the primary routed Jira surface.`,
7221
7222
  warning: ({ url: url2 }) => `Observed adjacent Jira domain ${url2}. Archal did not reroute this request because it is outside the primary Jira route surface.`
7222
7223
  },
7223
7224
  sdkIdentifiers: ["jira.js"],
@@ -7238,7 +7239,7 @@ var linearRouteManifest = {
7238
7239
  ],
7239
7240
  diagnostics: {
7240
7241
  undeclared: ({ url: url2 }) => `Blocked Linear traffic to ${url2}. Declare linear in archalVitestProject({ services: { linear: { mode: "route" } } }) before using the official Linear SDK.`,
7241
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Linear escape to ${url2}. Linear route mode is configured, but this domain is outside the primary routed Linear API surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7242
+ declaredEscape: ({ url: url2 }) => `Blocked Linear escape to ${url2}. Linear route mode is configured, but this domain is outside the primary routed Linear API surface.`,
7242
7243
  warning: ({ url: url2 }) => `Observed adjacent Linear domain ${url2}. Archal did not reroute this request because it is outside the primary Linear API route surface.`
7243
7244
  },
7244
7245
  sdkIdentifiers: ["@linear/sdk"],
@@ -7260,7 +7261,7 @@ var rampRouteManifest = {
7260
7261
  ],
7261
7262
  diagnostics: {
7262
7263
  undeclared: ({ url: url2 }) => `Blocked Ramp traffic to ${url2}. Declare ramp in archalVitestProject({ services: { ramp: { mode: "route" } } }) before using the official Ramp client.`,
7263
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Ramp escape to ${url2}. Ramp route mode is configured, but this domain is outside the primary routed Ramp API surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7264
+ declaredEscape: ({ url: url2 }) => `Blocked Ramp escape to ${url2}. Ramp route mode is configured, but this domain is outside the primary routed Ramp API surface.`,
7264
7265
  warning: ({ url: url2 }) => `Observed adjacent Ramp domain ${url2}. Archal did not reroute this request because it is outside the primary Ramp API route surface.`
7265
7266
  },
7266
7267
  sdkIdentifiers: ["ramp"],
@@ -7293,7 +7294,7 @@ var slackRouteManifest = {
7293
7294
  ],
7294
7295
  diagnostics: {
7295
7296
  undeclared: ({ url: url2 }) => `Blocked Slack traffic to ${url2}. Declare slack in archalVitestProject({ services: { slack: { mode: "route" } } }) before using the official Slack SDK.`,
7296
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Slack escape to ${url2}. Slack route mode is configured, but this domain is outside the primary routed Slack surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7297
+ declaredEscape: ({ url: url2 }) => `Blocked Slack escape to ${url2}. Slack route mode is configured, but this domain is outside the primary routed Slack surface.`,
7297
7298
  warning: ({ url: url2 }) => `Observed adjacent Slack domain ${url2}. Archal did not reroute this request because it is outside the primary Slack API route surface.`
7298
7299
  },
7299
7300
  sdkIdentifiers: ["@slack/web-api"],
@@ -7361,7 +7362,7 @@ var stripeRouteManifest = {
7361
7362
  ],
7362
7363
  diagnostics: {
7363
7364
  undeclared: ({ url: url2 }) => `Blocked Stripe traffic to ${url2}. Declare stripe in archalVitestProject({ services: { stripe: { mode: "route" } } }) before using the official Stripe SDK.`,
7364
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Stripe escape to ${url2}. Stripe route mode is configured, but this Stripe-owned domain is outside the current routed surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7365
+ declaredEscape: ({ url: url2 }) => `Blocked Stripe escape to ${url2}. Stripe route mode is configured, but this Stripe-owned domain is outside the current routed surface.`,
7365
7366
  warning: ({ url: url2 }) => `Observed adjacent Stripe domain ${url2}. Archal did not reroute this request because it is outside the primary Stripe API route surface.`
7366
7367
  },
7367
7368
  runtimeSurface: stripeRuntimeSurface,
@@ -7384,7 +7385,7 @@ var supabaseRouteManifest = {
7384
7385
  ],
7385
7386
  diagnostics: {
7386
7387
  undeclared: ({ url: url2 }) => `Blocked Supabase traffic to ${url2}. Declare supabase in archalVitestProject({ services: { supabase: { mode: "route" } } }) before using the official Supabase SDK.`,
7387
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Supabase escape to ${url2}. Supabase route mode is configured, but this domain is outside the primary routed Supabase surface. Configured twin base URL: ${configuredBaseUrl ?? "unknown"}.`,
7388
+ declaredEscape: ({ url: url2 }) => `Blocked Supabase escape to ${url2}. Supabase route mode is configured, but this domain is outside the primary routed Supabase surface.`,
7388
7389
  warning: ({ url: url2 }) => `Observed adjacent Supabase domain ${url2}. Archal did not reroute this request because it is outside the primary Supabase route surface.`
7389
7390
  },
7390
7391
  sdkIdentifiers: ["@supabase/supabase-js"],
@@ -7406,7 +7407,7 @@ var tavilyRouteManifest = {
7406
7407
  ],
7407
7408
  diagnostics: {
7408
7409
  undeclared: ({ url: url2 }) => `Blocked Tavily traffic to ${url2}. Declare tavily before using the official Tavily client.`,
7409
- declaredEscape: ({ url: url2, configuredBaseUrl }) => `Blocked Tavily escape to ${url2}. Tavily route mode is configured, but this domain is outside the primary routed Tavily API surface. Configured clone base URL: ${configuredBaseUrl ?? "unknown"}.`,
7410
+ declaredEscape: ({ url: url2 }) => `Blocked Tavily escape to ${url2}. Tavily route mode is configured, but this domain is outside the primary routed Tavily API surface.`,
7410
7411
  warning: ({ url: url2 }) => `Observed adjacent Tavily domain ${url2}. Archal did not reroute this request because it is outside the primary Tavily API route surface.`
7411
7412
  },
7412
7413
  sdkIdentifiers: ["@tavily/core", "tavily"],
@@ -7450,10 +7451,25 @@ function buildServiceCompatibilityProfile(manifest) {
7450
7451
  }
7451
7452
 
7452
7453
  // ../route-runtime-core/src/runtime.ts
7453
- var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
7454
+ var require2 = createRequire(
7455
+ typeof __filename === "string" && isAbsolute2(__filename) ? __filename : import.meta.url
7456
+ );
7454
7457
  var httpModule = require2("node:http");
7455
7458
  var httpsModule = require2("node:https");
7456
7459
  var SHARED_SERVICE_PROFILES = listSharedRouteManifests().map(buildServiceCompatibilityProfile);
7460
+ var CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE = "Network request failed";
7461
+ function createClientVisibleNetworkError() {
7462
+ return new TypeError(CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE);
7463
+ }
7464
+ function sanitizeClientVisibleNetworkError(error48) {
7465
+ const visibleError = error48;
7466
+ for (const key of Reflect.ownKeys(error48)) {
7467
+ delete visibleError[key];
7468
+ }
7469
+ error48.name = "TypeError";
7470
+ error48.message = CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE;
7471
+ error48.stack = `${error48.name}: ${error48.message}`;
7472
+ }
7457
7473
  function now() {
7458
7474
  return (/* @__PURE__ */ new Date()).toISOString();
7459
7475
  }
@@ -7657,7 +7673,7 @@ var NodeRouteRuntime = class {
7657
7673
  response3 = await this.originalFetch(
7658
7674
  buildRoutedFetchRequest(originalRequest, decision.targetUrl, service, init)
7659
7675
  );
7660
- } catch (error48) {
7676
+ } catch {
7661
7677
  this.traceRequest({
7662
7678
  method,
7663
7679
  sourceUrl: sourceUrl.toString(),
@@ -7667,9 +7683,9 @@ var NodeRouteRuntime = class {
7667
7683
  outcome: "failed",
7668
7684
  reason: "network_error",
7669
7685
  targetUrl,
7670
- error: errorMessage(error48)
7686
+ error: CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE
7671
7687
  });
7672
- throw error48;
7688
+ throw createClientVisibleNetworkError();
7673
7689
  }
7674
7690
  this.traceRequest({
7675
7691
  method,
@@ -7693,7 +7709,7 @@ var NodeRouteRuntime = class {
7693
7709
  ...init,
7694
7710
  headers
7695
7711
  });
7696
- } catch (error48) {
7712
+ } catch {
7697
7713
  this.traceRequest({
7698
7714
  method,
7699
7715
  sourceUrl: sourceUrl.toString(),
@@ -7703,9 +7719,9 @@ var NodeRouteRuntime = class {
7703
7719
  outcome: "failed",
7704
7720
  reason: "network_error",
7705
7721
  targetUrl,
7706
- error: errorMessage(error48)
7722
+ error: CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE
7707
7723
  });
7708
- throw error48;
7724
+ throw createClientVisibleNetworkError();
7709
7725
  }
7710
7726
  this.traceRequest({
7711
7727
  method,
@@ -8115,28 +8131,29 @@ var NodeRouteRuntime = class {
8115
8131
  if (record2.target === "twin") {
8116
8132
  request.once("response", sanitizeIncomingResponseHeaders);
8117
8133
  }
8118
- if (!this.traceEnabled) {
8119
- return request;
8120
- }
8121
8134
  let settled = false;
8122
- request.once("response", (response) => {
8123
- settled = true;
8124
- this.traceRequest({
8125
- ...record2,
8126
- statusCode: response.statusCode,
8127
- statusText: response.statusMessage
8135
+ if (this.traceEnabled) {
8136
+ request.once("response", (response) => {
8137
+ settled = true;
8138
+ this.traceRequest({
8139
+ ...record2,
8140
+ statusCode: response.statusCode,
8141
+ statusText: response.statusMessage
8142
+ });
8128
8143
  });
8129
- });
8144
+ }
8130
8145
  request.once("error", (error48) => {
8131
- if (settled) {
8132
- return;
8146
+ if (this.traceEnabled && !settled) {
8147
+ this.traceRequest({
8148
+ ...record2,
8149
+ outcome: "failed",
8150
+ reason: "network_error",
8151
+ error: record2.target === "twin" ? CLIENT_VISIBLE_BLOCKED_REQUEST_MESSAGE : error48.message
8152
+ });
8153
+ }
8154
+ if (record2.target === "twin") {
8155
+ sanitizeClientVisibleNetworkError(error48);
8133
8156
  }
8134
- this.traceRequest({
8135
- ...record2,
8136
- outcome: "failed",
8137
- reason: "network_error",
8138
- error: error48.message
8139
- });
8140
8157
  });
8141
8158
  return request;
8142
8159
  }
@@ -27592,7 +27609,7 @@ import { readFileSync as readFileSync2, renameSync, writeFileSync } from "fs";
27592
27609
  // ../../twins/core/src/seed-loader.ts
27593
27610
  import { readFile } from "fs/promises";
27594
27611
  import { existsSync, readFileSync, readdirSync } from "fs";
27595
- import { resolve as resolve2, dirname as dirname2, relative, isAbsolute } from "path";
27612
+ import { resolve as resolve2, dirname as dirname2, relative, isAbsolute as isAbsolute3 } from "path";
27596
27613
  import { fileURLToPath as fileURLToPath2 } from "url";
27597
27614
 
27598
27615
  // ../../twins/core/src/mcp/mcp-handler-runtime.ts
@@ -29085,7 +29102,7 @@ function isTruthyEnv(value) {
29085
29102
  }
29086
29103
  function formatTraceRecord(record2) {
29087
29104
  const manifestStatus = record2.manifestMatched ? `matched ${record2.service ?? "manifest"}` : "no manifest match";
29088
- const destination = record2.target === "twin" ? `twin${record2.targetUrl ? ` ${record2.targetUrl}` : ""}` : record2.target === "upstream" ? "real upstream" : "blocked";
29105
+ const destination = record2.target === "twin" ? "service endpoint" : record2.target === "upstream" ? "real upstream" : "blocked";
29089
29106
  const status = record2.statusCode === void 0 ? record2.error ? `error=${record2.error}` : "no status" : `${record2.statusCode}${record2.statusText ? ` ${record2.statusText}` : ""}`;
29090
29107
  return `\x1B[2m[archal:route] ${record2.method} ${record2.sourceUrl} | ${manifestStatus} | ${record2.outcome} -> ${destination} | ${status}\x1B[0m
29091
29108
  `;