oasis_test_v2 2.2.76 → 2.2.77

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 (2) hide show
  1. package/dist/index.js +354 -180
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2843,12 +2843,20 @@ function deriveBoardKey(artifactId) {
2843
2843
  const sha8 = (0, import_node_crypto2.createHash)("sha256").update(artifactId).digest("hex").slice(0, 8);
2844
2844
  return ascii ? `od-${ascii}-${sha8}` : `od-${sha8}`;
2845
2845
  }
2846
+ function withOdToken(fetchImpl, token) {
2847
+ if (!token) return fetchImpl;
2848
+ return (input, init) => {
2849
+ const headers = new Headers(init?.headers);
2850
+ headers.set("authorization", `Bearer ${token}`);
2851
+ return fetchImpl(input, { ...init, headers });
2852
+ };
2853
+ }
2846
2854
  async function odApi(base, fetchImpl, method, p2, body2) {
2847
2855
  const res = await fetchImpl(`${base}${p2}`, {
2848
2856
  method,
2849
2857
  ...body2 !== void 0 ? { body: JSON.stringify(body2), headers: { "content-type": "application/json" } } : {}
2850
2858
  });
2851
- if (!res.ok) throw new Error(`od ${method} ${p2} \u2192 ${res.status}: ${(await res.text()).slice(0, 200)}`);
2859
+ if (!res.ok) throw new OdHttpError(`od ${method} ${p2} \u2192 ${res.status}: ${(await res.text()).slice(0, 200)}`, res.status);
2852
2860
  return await res.json();
2853
2861
  }
2854
2862
  async function ensureProject(base, fetchImpl, boardKey, title) {
@@ -2863,23 +2871,29 @@ async function ensureProject(base, fetchImpl, boardKey, title) {
2863
2871
  conversationId = c.conversations?.[0]?.id ?? null;
2864
2872
  }
2865
2873
  if (!conversationId) throw new Error(`od \u9879\u76EE ${boardKey} \u65E0\u53EF\u7528\u4F1A\u8BDD`);
2866
- let resolvedDir = null;
2867
- try {
2868
- const d = await odApi(base, fetchImpl, "GET", `/api/projects/${encodeURIComponent(boardKey)}`);
2869
- resolvedDir = d.resolvedDir ?? null;
2870
- } catch {
2871
- }
2872
- return { conversationId, resolvedDir };
2874
+ return { conversationId };
2873
2875
  }
2874
- function materializeContext(resolvedDir, files) {
2875
- if (!resolvedDir) return;
2876
- fs2.mkdirSync(resolvedDir, { recursive: true });
2877
- const root = path2.join(resolvedDir, "task-context");
2878
- fs2.rmSync(root, { recursive: true, force: true });
2876
+ function projectFilePath(boardKey, name) {
2877
+ return `/api/projects/${encodeURIComponent(boardKey)}/files/${encodeURIComponent(name)}`;
2878
+ }
2879
+ async function materializeContext(base, fetchImpl, boardKey, files) {
2880
+ const listing = await odApi(
2881
+ base,
2882
+ fetchImpl,
2883
+ "GET",
2884
+ `/api/projects/${encodeURIComponent(boardKey)}/files`
2885
+ );
2886
+ for (const f2 of listing.files ?? []) {
2887
+ if (!f2.path.startsWith(TASK_CONTEXT_DIR)) continue;
2888
+ await odApi(base, fetchImpl, "DELETE", projectFilePath(boardKey, f2.path)).catch((err) => {
2889
+ throw new Error(`\u6E05\u7406\u753B\u677F\u65E7\u6750\u6599 ${f2.path} \u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
2890
+ });
2891
+ }
2879
2892
  for (const [rel, content3] of Object.entries(files)) {
2880
- const f2 = path2.join(root, rel);
2881
- fs2.mkdirSync(path2.dirname(f2), { recursive: true });
2882
- fs2.writeFileSync(f2, content3);
2893
+ const name = `${TASK_CONTEXT_DIR}${rel}`;
2894
+ await odApi(base, fetchImpl, "POST", `/api/projects/${encodeURIComponent(boardKey)}/files`, { name, content: content3 }).catch((err) => {
2895
+ throw new Error(`\u4E0A\u4F20\u6750\u6599 ${name} \u5230\u753B\u677F\u5931\u8D25\uFF1A${err instanceof Error ? err.message : String(err)}`);
2896
+ });
2883
2897
  }
2884
2898
  }
2885
2899
  async function putVisibleUserTurn(base, fetchImpl, args) {
@@ -2929,7 +2943,8 @@ async function fetchBoardStatus(base, fetchImpl, artifactId) {
2929
2943
  `/api/projects/${encodeURIComponent(boardKey)}/files`
2930
2944
  );
2931
2945
  artifacts = (listing.files ?? []).filter((f2) => !f2.path.startsWith("task-context/") && f2.artifactManifest !== void 0).map((f2) => ({ path: f2.path, kind: f2.kind ?? null, status: f2.artifactManifest?.status ?? null, mtime: f2.mtime ?? null })).sort((a, b2) => (b2.mtime ?? 0) - (a.mtime ?? 0));
2932
- } catch {
2946
+ } catch (err) {
2947
+ if (err instanceof OdHttpError && (err.status === 401 || err.status === 403)) throw err;
2933
2948
  boardExists = false;
2934
2949
  }
2935
2950
  let runs = [];
@@ -3028,10 +3043,10 @@ async function harvestBoard(base, fetchImpl, publicBase, workRoot, boardKey, run
3028
3043
  return { dir, entry };
3029
3044
  }
3030
3045
  async function startDesignChatTurn(opts) {
3031
- const fetchImpl = opts.fetchImpl ?? fetch;
3046
+ const fetchImpl = withOdToken(opts.fetchImpl ?? fetch, opts.token);
3032
3047
  const boardKey = deriveBoardKey(opts.artifactId);
3033
- const { conversationId, resolvedDir } = await ensureProject(opts.base, fetchImpl, boardKey, opts.title);
3034
- if (opts.contextFiles) materializeContext(resolvedDir, opts.contextFiles);
3048
+ const { conversationId } = await ensureProject(opts.base, fetchImpl, boardKey, opts.title);
3049
+ if (opts.contextFiles) await materializeContext(opts.base, fetchImpl, boardKey, opts.contextFiles);
3035
3050
  const userMessageId = await putVisibleUserTurn(opts.base, fetchImpl, { boardKey, conversationId, content: opts.message });
3036
3051
  const runId = await startDesignRun(opts.base, fetchImpl, {
3037
3052
  agentId: opts.agentId,
@@ -3043,7 +3058,7 @@ async function startDesignChatTurn(opts) {
3043
3058
  return { boardKey, conversationId, runId, userMessageId };
3044
3059
  }
3045
3060
  async function runDesignChatTurn(opts) {
3046
- const fetchImpl = opts.fetchImpl ?? fetch;
3061
+ const fetchImpl = withOdToken(opts.fetchImpl ?? fetch, opts.token);
3047
3062
  const { boardKey, conversationId, runId, userMessageId } = await startDesignChatTurn(opts);
3048
3063
  if (opts.onLine) void pumpDesignEvents(opts.base, fetchImpl, runId, opts.onLine).catch(() => {
3049
3064
  });
@@ -3056,13 +3071,20 @@ async function runDesignChatTurn(opts) {
3056
3071
  const { artifacts, fileCount } = await fetchResultPackage(opts.base, fetchImpl, runId);
3057
3072
  return { boardKey, conversationId, runId, userMessageId, artifacts, fileCount };
3058
3073
  }
3059
- var import_node_crypto2, fs2, path2;
3074
+ var import_node_crypto2, fs2, path2, OdHttpError, TASK_CONTEXT_DIR;
3060
3075
  var init_driver = __esm({
3061
3076
  "../adapters/src/open-design/driver.ts"() {
3062
3077
  "use strict";
3063
3078
  import_node_crypto2 = require("node:crypto");
3064
3079
  fs2 = __toESM(require("node:fs"), 1);
3065
3080
  path2 = __toESM(require("node:path"), 1);
3081
+ OdHttpError = class extends Error {
3082
+ constructor(message, status) {
3083
+ super(message);
3084
+ this.status = status;
3085
+ }
3086
+ };
3087
+ TASK_CONTEXT_DIR = "task-context/";
3066
3088
  }
3067
3089
  });
3068
3090
 
@@ -204704,10 +204726,39 @@ async function writeSessionCredsFile(slug6, exports2, reuseDir) {
204704
204726
  await (0, import_promises6.writeFile)(file, body2 + "\n", { mode: 384 });
204705
204727
  return { dir, file };
204706
204728
  }
204707
- var import_promises6, import_node_os5, import_node_path13;
204729
+ function readSessionCredsFile(file) {
204730
+ const out = {};
204731
+ for (const line2 of (0, import_node_fs10.readFileSync)(file, "utf8").split("\n")) {
204732
+ const m2 = /^export ([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(line2);
204733
+ if (!m2) continue;
204734
+ const value2 = unquoteShSingle(m2[2]);
204735
+ if (value2 !== null) out[m2[1]] = value2;
204736
+ }
204737
+ return out;
204738
+ }
204739
+ function unquoteShSingle(raw) {
204740
+ let out = "";
204741
+ let i = 0;
204742
+ while (i < raw.length) {
204743
+ if (raw[i] === "'") {
204744
+ const end = raw.indexOf("'", i + 1);
204745
+ if (end < 0) return null;
204746
+ out += raw.slice(i + 1, end);
204747
+ i = end + 1;
204748
+ } else if (raw.startsWith("\\'", i)) {
204749
+ out += "'";
204750
+ i += 2;
204751
+ } else {
204752
+ return null;
204753
+ }
204754
+ }
204755
+ return out;
204756
+ }
204757
+ var import_node_fs10, import_promises6, import_node_os5, import_node_path13;
204708
204758
  var init_session_creds = __esm({
204709
204759
  "../connectors/src/_base/session-creds.ts"() {
204710
204760
  "use strict";
204761
+ import_node_fs10 = require("node:fs");
204711
204762
  import_promises6 = require("node:fs/promises");
204712
204763
  import_node_os5 = require("node:os");
204713
204764
  import_node_path13 = require("node:path");
@@ -204893,9 +204944,27 @@ var init_cli_connector = __esm({
204893
204944
  });
204894
204945
 
204895
204946
  // ../connectors/src/_base/mcp-connector.ts
204947
+ var import_promises8, McpConnector;
204896
204948
  var init_mcp_connector = __esm({
204897
204949
  "../connectors/src/_base/mcp-connector.ts"() {
204898
204950
  "use strict";
204951
+ import_promises8 = require("node:fs/promises");
204952
+ McpConnector = class {
204953
+ // ===== MCP 类的通用默认值 =====
204954
+ commandName = "";
204955
+ requiredCommands = [];
204956
+ get envPrefix() {
204957
+ return `${this.config.slug.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_`;
204958
+ }
204959
+ wrapperScriptPath() {
204960
+ return null;
204961
+ }
204962
+ async cleanup(sessionEnv) {
204963
+ const dir = sessionEnv.get(`${this.envPrefix}RUN_TMPDIR`);
204964
+ if (dir) await (0, import_promises8.rm)(dir, { recursive: true, force: true });
204965
+ for (const k2 of this.injectedEnvKeys) sessionEnv.delete(k2);
204966
+ }
204967
+ };
204899
204968
  }
204900
204969
  });
204901
204970
 
@@ -204968,7 +205037,7 @@ function parseFeishuTokenResponse(data, nowMs) {
204968
205037
  expiresAt: new Date(expiresAtMs)
204969
205038
  };
204970
205039
  }
204971
- var import_node_child_process15, import_node_util4, import_node_path14, import_node_url3, import_promises8, execFileAsync2, __dirname2, FEISHU_WELL_KNOWN_SKILLS_BASE, FEISHU_TOKEN_URL, FeishuConnector;
205040
+ var import_node_child_process15, import_node_util4, import_node_path14, import_node_url3, import_promises9, execFileAsync2, __dirname2, FEISHU_WELL_KNOWN_SKILLS_BASE, FEISHU_TOKEN_URL, FeishuConnector;
204972
205041
  var init_feishu = __esm({
204973
205042
  "../connectors/src/feishu/index.ts"() {
204974
205043
  "use strict";
@@ -204976,7 +205045,7 @@ var init_feishu = __esm({
204976
205045
  import_node_util4 = require("node:util");
204977
205046
  import_node_path14 = require("node:path");
204978
205047
  import_node_url3 = require("node:url");
204979
- import_promises8 = require("node:fs/promises");
205048
+ import_promises9 = require("node:fs/promises");
204980
205049
  init_base();
204981
205050
  execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process15.execFile);
204982
205051
  __dirname2 = (0, import_node_path14.dirname)((0, import_node_url3.fileURLToPath)(__esm_import_meta_url));
@@ -205118,7 +205187,7 @@ var init_feishu = __esm({
205118
205187
  ...userAccessToken ? { LARKSUITE_CLI_USER_ACCESS_TOKEN: userAccessToken } : {}
205119
205188
  }, sessionEnv.get("FEISHU_RUN_TMPDIR"));
205120
205189
  const configDir = (0, import_node_path14.join)(creds.dir, "lark-config");
205121
- await (0, import_promises8.mkdir)(configDir, { recursive: true, mode: 448 });
205190
+ await (0, import_promises9.mkdir)(configDir, { recursive: true, mode: 448 });
205122
205191
  sessionEnv.set("LARK_BIN", await this.resolveAbsoluteLarkBin());
205123
205192
  sessionEnv.set("FEISHU_CREDS_FILE", creds.file);
205124
205193
  sessionEnv.set("FEISHU_RUN_TMPDIR", creds.dir);
@@ -205707,13 +205776,13 @@ function normalizedRepo(value2) {
205707
205776
  const repo = value2.trim().replace(/^https?:\/\/github\.com\//i, "").replace(/\.git$/i, "").replace(/^\/+|\/+$/g, "");
205708
205777
  return /^[^/\s]+\/[^/\s]+$/.test(repo) ? repo.toLowerCase() : null;
205709
205778
  }
205710
- var import_node_path15, import_node_url4, import_promises9, __dirname3, GithubConnector;
205779
+ var import_node_path15, import_node_url4, import_promises10, __dirname3, GithubConnector;
205711
205780
  var init_github = __esm({
205712
205781
  "../connectors/src/github/index.ts"() {
205713
205782
  "use strict";
205714
205783
  import_node_path15 = require("node:path");
205715
205784
  import_node_url4 = require("node:url");
205716
- import_promises9 = require("node:fs/promises");
205785
+ import_promises10 = require("node:fs/promises");
205717
205786
  init_base();
205718
205787
  init_app_auth();
205719
205788
  __dirname3 = (0, import_node_path15.dirname)((0, import_node_url4.fileURLToPath)(__esm_import_meta_url));
@@ -205919,7 +205988,7 @@ var init_github = __esm({
205919
205988
  GITHUB_TOKEN: token
205920
205989
  }, sessionEnv.get("GH_RUN_TMPDIR"));
205921
205990
  const configDir = (0, import_node_path15.join)(creds.dir, "gh-config");
205922
- await (0, import_promises9.mkdir)(configDir, { recursive: true, mode: 448 });
205991
+ await (0, import_promises10.mkdir)(configDir, { recursive: true, mode: 448 });
205923
205992
  sessionEnv.set("GH_BIN", await this.resolveRealBin("gh"));
205924
205993
  sessionEnv.set("GH_CREDS_FILE", creds.file);
205925
205994
  sessionEnv.set("GH_RUN_TMPDIR", creds.dir);
@@ -208079,14 +208148,14 @@ function normalizeBaseUrl(value2) {
208079
208148
  function resolveBundledCli(wrapperDir) {
208080
208149
  const override = process.env["OASIS_CONNECTOR_ASSETS_DIR"];
208081
208150
  const candidates = override ? [(0, import_node_path16.resolve)(override, "outline", "outline-kb.mjs")] : [(0, import_node_path16.join)(wrapperDir, "outline-kb.mjs"), (0, import_node_path16.join)(wrapperDir, "outline", "outline-kb.mjs")];
208082
- return candidates.find((candidate) => (0, import_node_fs10.existsSync)(candidate)) ?? null;
208151
+ return candidates.find((candidate) => (0, import_node_fs11.existsSync)(candidate)) ?? null;
208083
208152
  }
208084
- var import_node_path16, import_node_fs10, import_node_url5, __dirname4, OutlineConnector;
208153
+ var import_node_path16, import_node_fs11, import_node_url5, __dirname4, OutlineConnector;
208085
208154
  var init_outline = __esm({
208086
208155
  "../connectors/src/outline/index.ts"() {
208087
208156
  "use strict";
208088
208157
  import_node_path16 = require("node:path");
208089
- import_node_fs10 = require("node:fs");
208158
+ import_node_fs11 = require("node:fs");
208090
208159
  import_node_url5 = require("node:url");
208091
208160
  init_base();
208092
208161
  init_knowledge_curator_skill();
@@ -208201,6 +208270,75 @@ var init_outline = __esm({
208201
208270
  }
208202
208271
  });
208203
208272
 
208273
+ // ../connectors/src/open-design/index.ts
208274
+ function normalizeBaseUrl2(value2) {
208275
+ const url = new URL(value2);
208276
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
208277
+ throw new Error("open-design connector: base_url must use http or https");
208278
+ }
208279
+ url.hash = "";
208280
+ url.search = "";
208281
+ return url.toString().replace(/\/$/, "");
208282
+ }
208283
+ function readOpenDesignCreds(env = process.env) {
208284
+ const file = env[OPEN_DESIGN_CREDS_FILE_ENV];
208285
+ if (!file) return null;
208286
+ let vars;
208287
+ try {
208288
+ vars = readSessionCredsFile(file);
208289
+ } catch (err) {
208290
+ throw new Error(`open-design \u8FDE\u63A5\u5668\u51ED\u636E\u6587\u4EF6\u8BFB\u4E0D\u5230\uFF08${OPEN_DESIGN_CREDS_FILE_ENV}=${file}\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`);
208291
+ }
208292
+ const baseUrl = vars["OPEN_DESIGN_BASE_URL"];
208293
+ const apiToken = vars["OPEN_DESIGN_API_TOKEN"];
208294
+ if (!baseUrl || !apiToken) {
208295
+ throw new Error(`open-design \u8FDE\u63A5\u5668\u51ED\u636E\u6587\u4EF6\u4E0D\u5B8C\u6574\uFF08${OPEN_DESIGN_CREDS_FILE_ENV}=${file}\uFF09\uFF1A\u7F3A OPEN_DESIGN_BASE_URL \u6216 OPEN_DESIGN_API_TOKEN`);
208296
+ }
208297
+ return { baseUrl, apiToken };
208298
+ }
208299
+ var OPEN_DESIGN_CREDS_FILE_ENV, OpenDesignConnector;
208300
+ var init_open_design2 = __esm({
208301
+ "../connectors/src/open-design/index.ts"() {
208302
+ "use strict";
208303
+ init_base();
208304
+ OPEN_DESIGN_CREDS_FILE_ENV = "OPEN_DESIGN_CREDS_FILE";
208305
+ OpenDesignConnector = class extends McpConnector {
208306
+ config = {
208307
+ slug: "open-design",
208308
+ type: "mcp",
208309
+ schema: [
208310
+ { key: "base_url", description: "open-design \u63A5\u53E3\u5730\u5740\uFF08\u4F8B\u5982 https://design.example.com\uFF09", secret: false, required: true },
208311
+ { key: "api_token", description: "open-design API \u4EE4\u724C\uFF08od daemon \u7684 OD_API_TOKEN\uFF09", secret: true, required: true }
208312
+ ]
208313
+ };
208314
+ credentialSources = [
208315
+ { key: "base_url", from: "OPEN_DESIGN_BASE_URL", required: true },
208316
+ { key: "api_token", from: "OPEN_DESIGN_API_TOKEN", required: true }
208317
+ ];
208318
+ sensitiveVars = ["OPEN_DESIGN_API_TOKEN"];
208319
+ injectedEnvKeys = [OPEN_DESIGN_CREDS_FILE_ENV, "OPEN_DESIGN_RUN_TMPDIR"];
208320
+ async connect(options = {}) {
208321
+ const baseUrl = options["base_url"];
208322
+ const apiToken = options["api_token"];
208323
+ if (!baseUrl || !apiToken) throw new Error("open-design connector: base_url and api_token are required");
208324
+ const normalized4 = normalizeBaseUrl2(baseUrl);
208325
+ return { credentials: { base_url: normalized4, api_token: apiToken }, canonicalUrl: normalized4 };
208326
+ }
208327
+ async inject(credentials2, sessionEnv) {
208328
+ const baseUrl = credentials2["base_url"];
208329
+ const apiToken = credentials2["api_token"];
208330
+ if (!baseUrl || !apiToken) throw new Error("open-design inject: missing base_url or api_token");
208331
+ const creds = await writeSessionCredsFile(this.config.slug, {
208332
+ OPEN_DESIGN_BASE_URL: normalizeBaseUrl2(baseUrl),
208333
+ OPEN_DESIGN_API_TOKEN: apiToken
208334
+ });
208335
+ sessionEnv.set(OPEN_DESIGN_CREDS_FILE_ENV, creds.file);
208336
+ sessionEnv.set("OPEN_DESIGN_RUN_TMPDIR", creds.dir);
208337
+ }
208338
+ };
208339
+ }
208340
+ });
208341
+
208204
208342
  // ../connectors/src/github/app-adopt.ts
208205
208343
  async function adoptGithubApp(store, args, deps = {}) {
208206
208344
  const scope2 = args.actorId ? { scope: "personal", actorId: args.actorId } : { scope: "global" };
@@ -208398,6 +208536,8 @@ function createConnectorBySlug(slug6) {
208398
208536
  return new GithubConnector();
208399
208537
  case "outline":
208400
208538
  return new OutlineConnector();
208539
+ case "open-design":
208540
+ return new OpenDesignConnector();
208401
208541
  default:
208402
208542
  return null;
208403
208543
  }
@@ -208412,7 +208552,8 @@ var init_registry2 = __esm({
208412
208552
  init_feishu();
208413
208553
  init_github();
208414
208554
  init_outline();
208415
- CONNECTOR_SLUGS = ["feishu", "github", "outline"];
208555
+ init_open_design2();
208556
+ CONNECTOR_SLUGS = ["feishu", "github", "outline", "open-design"];
208416
208557
  }
208417
208558
  });
208418
208559
 
@@ -208471,18 +208612,18 @@ async function buildConnectorProvision(ctx) {
208471
208612
  if (!hostIsolationEnabled()) {
208472
208613
  logHostIdentityFallback(pendingIsolation, "[provision]");
208473
208614
  } else {
208474
- const isolationRoot = await (0, import_promises10.mkdtemp)((0, import_node_path17.join)((0, import_node_os6.tmpdir)(), "oasis-isolate-"));
208615
+ const isolationRoot = await (0, import_promises11.mkdtemp)((0, import_node_path17.join)((0, import_node_os6.tmpdir)(), "oasis-isolate-"));
208475
208616
  let isolationUsed = false;
208476
208617
  for (const key2 of isolationKeys) {
208477
208618
  if (envOverrides[key2]) continue;
208478
208619
  const dir = (0, import_node_path17.join)(isolationRoot, key2.toLowerCase());
208479
- await (0, import_promises10.mkdir)(dir, { recursive: true, mode: 448 });
208620
+ await (0, import_promises11.mkdir)(dir, { recursive: true, mode: 448 });
208480
208621
  envOverrides[key2] = dir;
208481
208622
  isolationUsed = true;
208482
208623
  }
208483
- if (!isolationUsed) await (0, import_promises10.rm)(isolationRoot, { recursive: true, force: true });
208624
+ if (!isolationUsed) await (0, import_promises11.rm)(isolationRoot, { recursive: true, force: true });
208484
208625
  else cleanups.push(async () => {
208485
- await (0, import_promises10.rm)(isolationRoot, { recursive: true, force: true });
208626
+ await (0, import_promises11.rm)(isolationRoot, { recursive: true, force: true });
208486
208627
  });
208487
208628
  }
208488
208629
  const cleanup = async () => {
@@ -208498,7 +208639,7 @@ async function buildConnectorProvision(ctx) {
208498
208639
  cleanup
208499
208640
  };
208500
208641
  }
208501
- var import_promises10, import_node_os6, import_node_path17;
208642
+ var import_promises11, import_node_os6, import_node_path17;
208502
208643
  var init_provision = __esm({
208503
208644
  "../connectors/src/provision.ts"() {
208504
208645
  "use strict";
@@ -208506,7 +208647,7 @@ var init_provision = __esm({
208506
208647
  init_registry2();
208507
208648
  init_host_isolation();
208508
208649
  init_logger();
208509
- import_promises10 = require("node:fs/promises");
208650
+ import_promises11 = require("node:fs/promises");
208510
208651
  import_node_os6 = require("node:os");
208511
208652
  import_node_path17 = require("node:path");
208512
208653
  }
@@ -208518,7 +208659,7 @@ function loginShellShadow(commandName) {
208518
208659
  if (!home2) return "";
208519
208660
  for (const dir of [(0, import_node_path18.join)(home2, ".local", "bin"), (0, import_node_path18.join)(home2, "bin")]) {
208520
208661
  const candidate = (0, import_node_path18.join)(dir, commandName);
208521
- if ((0, import_node_fs11.existsSync)(candidate)) return candidate;
208662
+ if ((0, import_node_fs12.existsSync)(candidate)) return candidate;
208522
208663
  }
208523
208664
  return "";
208524
208665
  }
@@ -208592,7 +208733,7 @@ async function prepareConnectorsForJob(job, deps) {
208592
208733
  throw new Error(detail);
208593
208734
  }
208594
208735
  const keptLocal = localWrappers.filter((p2) => isStagedWrapperUsable(p2));
208595
- const keptRemote = remoteWrappers.filter((p2) => (0, import_node_fs11.existsSync)(p2));
208736
+ const keptRemote = remoteWrappers.filter((p2) => (0, import_node_fs12.existsSync)(p2));
208596
208737
  const droppedWrappers = remoteWrappers.length - keptRemote.length + (localWrappers.length - keptLocal.length);
208597
208738
  if (droppedWrappers > 0) log("[node-connectors]", `\u4E22\u5F03 ${droppedWrappers} \u6761\u672C\u673A\u4E0D\u53EF\u7528\u7684 wrapper \u8DEF\u5F84`);
208598
208739
  const staleKeys = /* @__PURE__ */ new Set();
@@ -208622,14 +208763,14 @@ async function prepareConnectorsForJob(job, deps) {
208622
208763
  "[node-connectors]"
208623
208764
  );
208624
208765
  } else if (isolationKeys.size > 0) {
208625
- const isolationRoot = await (0, import_promises11.mkdtemp)((0, import_node_path18.join)((0, import_node_os7.tmpdir)(), "oasis-node-isolate-"));
208766
+ const isolationRoot = await (0, import_promises12.mkdtemp)((0, import_node_path18.join)((0, import_node_os7.tmpdir)(), "oasis-node-isolate-"));
208626
208767
  for (const key2 of isolationKeys) {
208627
208768
  const dir = (0, import_node_path18.join)(isolationRoot, key2.toLowerCase());
208628
- await (0, import_promises11.mkdir)(dir, { recursive: true, mode: 448 });
208769
+ await (0, import_promises12.mkdir)(dir, { recursive: true, mode: 448 });
208629
208770
  jobEnv[key2] = dir;
208630
208771
  }
208631
208772
  cleanups.push(async () => {
208632
- await (0, import_promises11.rm)(isolationRoot, { recursive: true, force: true });
208773
+ await (0, import_promises12.rm)(isolationRoot, { recursive: true, force: true });
208633
208774
  });
208634
208775
  }
208635
208776
  if (dropped > 0) {
@@ -208706,12 +208847,12 @@ function fetchCredentialsFromServer(job) {
208706
208847
  return body2.connectorCreds ?? [];
208707
208848
  };
208708
208849
  }
208709
- var import_node_fs11, import_promises11, import_node_os7, import_node_path18, SESSION_CREDENTIAL_RENEW_INTERVAL_MS;
208850
+ var import_node_fs12, import_promises12, import_node_os7, import_node_path18, SESSION_CREDENTIAL_RENEW_INTERVAL_MS;
208710
208851
  var init_prepare_job = __esm({
208711
208852
  "../connectors/src/prepare-job.ts"() {
208712
208853
  "use strict";
208713
- import_node_fs11 = require("node:fs");
208714
- import_promises11 = require("node:fs/promises");
208854
+ import_node_fs12 = require("node:fs");
208855
+ import_promises12 = require("node:fs/promises");
208715
208856
  import_node_os7 = require("node:os");
208716
208857
  import_node_path18 = require("node:path");
208717
208858
  init_base();
@@ -208727,12 +208868,12 @@ function inspectConnectorRuntimeReadiness() {
208727
208868
  return createAllConnectors().map((connector) => {
208728
208869
  if (connector.config.type !== "cli") return { slug: connector.config.slug, ready: true };
208729
208870
  const wrapper = connector.wrapperScriptPath();
208730
- if (!wrapper || !isUsableFile(wrapper, import_node_fs12.constants.R_OK | import_node_fs12.constants.X_OK)) {
208871
+ if (!wrapper || !isUsableFile(wrapper, import_node_fs13.constants.R_OK | import_node_fs13.constants.X_OK)) {
208731
208872
  return { slug: connector.config.slug, ready: false, error: "wrapper \u8D44\u4EA7\u7F3A\u5931" };
208732
208873
  }
208733
208874
  if (connector.bundledCommand) {
208734
208875
  const assets = connector.runtimeAssetPaths?.() ?? [];
208735
- if (assets.length === 0 || assets.some((asset) => !isUsableFile(asset, import_node_fs12.constants.R_OK))) {
208876
+ if (assets.length === 0 || assets.some((asset) => !isUsableFile(asset, import_node_fs13.constants.R_OK))) {
208736
208877
  return { slug: connector.config.slug, ready: false, error: "\u968F\u5305\u547D\u4EE4\u8D44\u4EA7\u7F3A\u5931" };
208737
208878
  }
208738
208879
  }
@@ -208740,10 +208881,10 @@ function inspectConnectorRuntimeReadiness() {
208740
208881
  });
208741
208882
  }
208742
208883
  function isUsableFile(file, mode) {
208743
- if (!(0, import_node_fs12.existsSync)(file)) return false;
208884
+ if (!(0, import_node_fs13.existsSync)(file)) return false;
208744
208885
  try {
208745
- if (!(0, import_node_fs12.statSync)(file).isFile()) return false;
208746
- (0, import_node_fs12.accessSync)(file, mode);
208886
+ if (!(0, import_node_fs13.statSync)(file).isFile()) return false;
208887
+ (0, import_node_fs13.accessSync)(file, mode);
208747
208888
  return true;
208748
208889
  } catch {
208749
208890
  return false;
@@ -208757,22 +208898,22 @@ function assertConnectorRuntimeReadiness() {
208757
208898
  }
208758
208899
  return statuses2;
208759
208900
  }
208760
- var import_node_fs12;
208901
+ var import_node_fs13;
208761
208902
  var init_readiness = __esm({
208762
208903
  "../connectors/src/readiness.ts"() {
208763
208904
  "use strict";
208764
- import_node_fs12 = require("node:fs");
208905
+ import_node_fs13 = require("node:fs");
208765
208906
  init_registry2();
208766
208907
  }
208767
208908
  });
208768
208909
 
208769
208910
  // ../connectors/src/connector-adapter.ts
208770
- var import_promises12, import_node_fs13, import_node_os8, import_node_path19, ConnectorAwareAdapter;
208911
+ var import_promises13, import_node_fs14, import_node_os8, import_node_path19, ConnectorAwareAdapter;
208771
208912
  var init_connector_adapter = __esm({
208772
208913
  "../connectors/src/connector-adapter.ts"() {
208773
208914
  "use strict";
208774
- import_promises12 = require("node:fs/promises");
208775
- import_node_fs13 = require("node:fs");
208915
+ import_promises13 = require("node:fs/promises");
208916
+ import_node_fs14 = require("node:fs");
208776
208917
  import_node_os8 = require("node:os");
208777
208918
  import_node_path19 = require("node:path");
208778
208919
  init_src2();
@@ -208790,18 +208931,18 @@ var init_connector_adapter = __esm({
208790
208931
  if (missing.length) log("[adapter]", ` connector tools still missing (agent may fail): ${missing.join(", ")}`);
208791
208932
  }
208792
208933
  const prepared = await prepareConnectorsForJob(job);
208793
- const sentinelWrappers = Object.entries(prepared.job.env ?? {}).filter(([k2]) => k2.endsWith("_WRAPPER")).map(([, v2]) => v2).filter((p2) => (0, import_node_fs13.existsSync)(p2));
208934
+ const sentinelWrappers = Object.entries(prepared.job.env ?? {}).filter(([k2]) => k2.endsWith("_WRAPPER")).map(([, v2]) => v2).filter((p2) => (0, import_node_fs14.existsSync)(p2));
208794
208935
  const strippedEnv = Object.fromEntries(
208795
208936
  Object.entries(prepared.job.env ?? {}).filter(([k2]) => !k2.endsWith("_WRAPPER"))
208796
208937
  );
208797
208938
  const wrapperPaths = [...prepared.job.wrapperPaths ?? [], ...sentinelWrappers];
208798
208939
  let extraEnv = { ...strippedEnv };
208799
208940
  if (wrapperPaths.length > 0) {
208800
- const wrapperBinDir = await (0, import_promises12.mkdtemp)((0, import_node_path19.join)((0, import_node_os8.tmpdir)(), "oasis-wrappers-"));
208801
- await (0, import_promises12.mkdir)(wrapperBinDir, { recursive: true });
208941
+ const wrapperBinDir = await (0, import_promises13.mkdtemp)((0, import_node_path19.join)((0, import_node_os8.tmpdir)(), "oasis-wrappers-"));
208942
+ await (0, import_promises13.mkdir)(wrapperBinDir, { recursive: true });
208802
208943
  for (const wp of wrapperPaths) {
208803
208944
  const linkName = (0, import_node_path19.basename)(wp).replace(/\.sh$/, "");
208804
- await (0, import_promises12.symlink)(wp, (0, import_node_path19.join)(wrapperBinDir, linkName));
208945
+ await (0, import_promises13.symlink)(wp, (0, import_node_path19.join)(wrapperBinDir, linkName));
208805
208946
  }
208806
208947
  extraEnv = { ...extraEnv, PATH: [wrapperBinDir, extraEnv["PATH"] ?? ""].filter(Boolean).join(":") };
208807
208948
  log("[adapter]", ` connectors injected +${Date.now() - t0}ms wrappers=${wrapperPaths.length}`);
@@ -208838,6 +208979,7 @@ var init_src8 = __esm({
208838
208979
  init_well_known_skills();
208839
208980
  init_github();
208840
208981
  init_outline();
208982
+ init_open_design2();
208841
208983
  init_app_auth();
208842
208984
  init_app_adopt();
208843
208985
  init_app_manifest();
@@ -214017,14 +214159,14 @@ ${composed}`;
214017
214159
  if (body2.actorId && opts.resolveActorContext) {
214018
214160
  const actorCtx = await opts.resolveActorContext(body2.actorId).catch(() => null);
214019
214161
  if (actorCtx) {
214020
- const { mkdtempSync: mkdtempSync6, mkdirSync: mkdirSync25, writeFileSync: writeFileSync19 } = await import("node:fs");
214021
- const { join: join47, dirname: dirname39 } = await import("node:path");
214162
+ const { mkdtempSync: mkdtempSync6, mkdirSync: mkdirSync24, writeFileSync: writeFileSync19 } = await import("node:fs");
214163
+ const { join: join47, dirname: dirname38 } = await import("node:path");
214022
214164
  const { tmpdir: tmpdir11 } = await import("node:os");
214023
214165
  const dir = mkdtempSync6(join47(tmpdir11(), "oasis-chat-"));
214024
214166
  if (actorCtx.config?.prompt) {
214025
214167
  for (const [rel, content3] of Object.entries(splitIdentityFiles2(actorCtx.config.prompt))) {
214026
214168
  const file = join47(dir, rel);
214027
- mkdirSync25(dirname39(file), { recursive: true });
214169
+ mkdirSync24(dirname38(file), { recursive: true });
214028
214170
  writeFileSync19(file, content3);
214029
214171
  }
214030
214172
  }
@@ -214041,7 +214183,7 @@ ${composed}`;
214041
214183
  const skillFiles = await opts.materializeSkills(body2.actorId, "claude").catch(() => ({}));
214042
214184
  for (const [rel, content3] of Object.entries(skillFiles)) {
214043
214185
  const file = join47(dir, rel);
214044
- mkdirSync25(dirname39(file), { recursive: true });
214186
+ mkdirSync24(dirname38(file), { recursive: true });
214045
214187
  writeFileSync19(file, content3);
214046
214188
  }
214047
214189
  }
@@ -219288,7 +219430,7 @@ function namedError(name, message) {
219288
219430
  err.name = name;
219289
219431
  return err;
219290
219432
  }
219291
- function dirname24(path46) {
219433
+ function dirname23(path46) {
219292
219434
  const norm = path46.replace(/^\/+|\/+$/g, "");
219293
219435
  const idx = norm.lastIndexOf("/");
219294
219436
  return idx === -1 ? "" : norm.slice(0, idx);
@@ -220330,7 +220472,7 @@ var init_service4 = __esm({
220330
220472
  }
220331
220473
  for (const file of files) {
220332
220474
  const path46 = typeof file.path === "string" && file.path.trim() ? file.path : void 0;
220333
- if (path46) emitFolder(dirname24(path46), file.uploadedAt);
220475
+ if (path46) emitFolder(dirname23(path46), file.uploadedAt);
220334
220476
  const projectIdForFile = isUncategorizedProjectId(projectId2) ? projectByWorkOrder.get(file.projectId) ?? null : null;
220335
220477
  items.push({
220336
220478
  kind: "file",
@@ -230902,17 +231044,17 @@ function parseConnectorSkillId(id) {
230902
231044
  return { connectorId: rest.slice(0, i), slug: rest.slice(i + 1) };
230903
231045
  }
230904
231046
  async function collect(root, dir, out) {
230905
- for (const e of await (0, import_promises13.readdir)(dir, { withFileTypes: true })) {
231047
+ for (const e of await (0, import_promises14.readdir)(dir, { withFileTypes: true })) {
230906
231048
  const abs = (0, import_node_path20.join)(dir, e.name);
230907
231049
  if (e.isDirectory()) await collect(root, abs, out);
230908
- else if (e.isFile()) out[(0, import_node_path20.relative)(root, abs).split(/[\\/]/).join("/")] = await (0, import_promises13.readFile)(abs, "utf8");
231050
+ else if (e.isFile()) out[(0, import_node_path20.relative)(root, abs).split(/[\\/]/).join("/")] = await (0, import_promises14.readFile)(abs, "utf8");
230909
231051
  }
230910
231052
  }
230911
231053
  async function readLocalPack(dataDir, connectorId) {
230912
231054
  const root = connectorSkillsDir(dataDir, connectorId);
230913
231055
  let slugs;
230914
231056
  try {
230915
- slugs = (await (0, import_promises13.readdir)(root, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name);
231057
+ slugs = (await (0, import_promises14.readdir)(root, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name);
230916
231058
  } catch {
230917
231059
  return [];
230918
231060
  }
@@ -230936,17 +231078,17 @@ async function readLocalPack(dataDir, connectorId) {
230936
231078
  async function writePack(dataDir, connectorId, pack) {
230937
231079
  const root = connectorSkillsDir(dataDir, connectorId);
230938
231080
  const tmp = `${root}.tmp`;
230939
- await (0, import_promises13.rm)(tmp, { recursive: true, force: true });
231081
+ await (0, import_promises14.rm)(tmp, { recursive: true, force: true });
230940
231082
  for (const s2 of pack) {
230941
231083
  for (const [rel, content3] of Object.entries(s2.files)) {
230942
231084
  const abs = (0, import_node_path20.join)(tmp, s2.slug, rel);
230943
- await (0, import_promises13.mkdir)((0, import_node_path20.dirname)(abs), { recursive: true });
230944
- await (0, import_promises13.writeFile)(abs, content3, "utf8");
231085
+ await (0, import_promises14.mkdir)((0, import_node_path20.dirname)(abs), { recursive: true });
231086
+ await (0, import_promises14.writeFile)(abs, content3, "utf8");
230945
231087
  }
230946
231088
  }
230947
- await (0, import_promises13.rm)(root, { recursive: true, force: true });
230948
- await (0, import_promises13.mkdir)((0, import_node_path20.dirname)(root), { recursive: true });
230949
- await (0, import_promises13.rename)(tmp, root);
231089
+ await (0, import_promises14.rm)(root, { recursive: true, force: true });
231090
+ await (0, import_promises14.mkdir)((0, import_node_path20.dirname)(root), { recursive: true });
231091
+ await (0, import_promises14.rename)(tmp, root);
230950
231092
  }
230951
231093
  function packMatches(local, remote) {
230952
231094
  if (local.length !== remote.length) return false;
@@ -230973,11 +231115,11 @@ async function syncConnectorSkills(args) {
230973
231115
  log3(`[connector-skills] ${args.connectorId}\uFF1A\u5DF2\u4ECE\u5382\u5546\u540C\u6B65 ${fresh.length} \u4E2A\u6280\u80FD`);
230974
231116
  return { skills: fresh, outcome: "fetched" };
230975
231117
  }
230976
- var import_promises13, import_node_path20, toId;
231118
+ var import_promises14, import_node_path20, toId;
230977
231119
  var init_connector_skills = __esm({
230978
231120
  "../server/src/governance/connector-skills.ts"() {
230979
231121
  "use strict";
230980
- import_promises13 = require("node:fs/promises");
231122
+ import_promises14 = require("node:fs/promises");
230981
231123
  import_node_path20 = require("node:path");
230982
231124
  init_src8();
230983
231125
  toId = (connectorId, slug6) => `connector:${connectorId}/${slug6}`;
@@ -232635,7 +232777,7 @@ var init_routes3 = __esm({
232635
232777
  async function readCredentialAuditLog(file, filter) {
232636
232778
  let raw;
232637
232779
  try {
232638
- raw = await import_node_fs14.promises.readFile(file, "utf8");
232780
+ raw = await import_node_fs15.promises.readFile(file, "utf8");
232639
232781
  } catch {
232640
232782
  return [];
232641
232783
  }
@@ -232649,11 +232791,11 @@ async function readCredentialAuditLog(file, filter) {
232649
232791
  }
232650
232792
  return filterCredentialAudit(records, filter);
232651
232793
  }
232652
- var import_node_fs14;
232794
+ var import_node_fs15;
232653
232795
  var init_credential_audit_log = __esm({
232654
232796
  "../server/src/domains/actors/credential-audit-log.ts"() {
232655
232797
  "use strict";
232656
- import_node_fs14 = require("node:fs");
232798
+ import_node_fs15 = require("node:fs");
232657
232799
  init_service5();
232658
232800
  }
232659
232801
  });
@@ -237460,21 +237602,21 @@ function fromRow(row) {
237460
237602
  for (const [k2, v2] of opt) if (v2 !== void 0 && v2 !== null) r[k2] = v2;
237461
237603
  return r;
237462
237604
  }
237463
- var import_node_crypto55, import_node_fs15, DEFAULT_PAGE, MAX_PAGE, pageSize, MemoryNotificationStore, ident3, iso2, str2, PostgresNotificationStore;
237605
+ var import_node_crypto55, import_node_fs16, DEFAULT_PAGE, MAX_PAGE, pageSize, MemoryNotificationStore, ident3, iso2, str2, PostgresNotificationStore;
237464
237606
  var init_notification_store = __esm({
237465
237607
  "../server/src/domains/collab/notification-store.ts"() {
237466
237608
  "use strict";
237467
237609
  import_node_crypto55 = require("node:crypto");
237468
- import_node_fs15 = __toESM(require("node:fs"), 1);
237610
+ import_node_fs16 = __toESM(require("node:fs"), 1);
237469
237611
  DEFAULT_PAGE = 50;
237470
237612
  MAX_PAGE = 200;
237471
237613
  pageSize = (limit) => Math.min(Math.max(limit ?? DEFAULT_PAGE, 1), MAX_PAGE);
237472
237614
  MemoryNotificationStore = class {
237473
237615
  constructor(file) {
237474
237616
  this.file = file;
237475
- if (file && import_node_fs15.default.existsSync(file)) {
237617
+ if (file && import_node_fs16.default.existsSync(file)) {
237476
237618
  try {
237477
- const list2 = JSON.parse(import_node_fs15.default.readFileSync(file, "utf8"));
237619
+ const list2 = JSON.parse(import_node_fs16.default.readFileSync(file, "utf8"));
237478
237620
  for (const r of list2) this.rows.set(r.id, r);
237479
237621
  } catch {
237480
237622
  }
@@ -237484,8 +237626,8 @@ var init_notification_store = __esm({
237484
237626
  save() {
237485
237627
  if (!this.file) return;
237486
237628
  const tmp = `${this.file}.tmp`;
237487
- import_node_fs15.default.writeFileSync(tmp, JSON.stringify([...this.rows.values()]));
237488
- import_node_fs15.default.renameSync(tmp, this.file);
237629
+ import_node_fs16.default.writeFileSync(tmp, JSON.stringify([...this.rows.values()]));
237630
+ import_node_fs16.default.renameSync(tmp, this.file);
237489
237631
  }
237490
237632
  findLive(recipient, sourceKey, category) {
237491
237633
  for (const r of this.rows.values()) {
@@ -239638,11 +239780,11 @@ function nameKey(name) {
239638
239780
  function cleanName(name) {
239639
239781
  return name.trim().replace(/\s+/g, " ");
239640
239782
  }
239641
- var import_node_fs16, import_node_path21, import_node_crypto56, SEP, keyOf, prefixOf, MemoryWorkorderTagStore, FileWorkorderTagStore;
239783
+ var import_node_fs17, import_node_path21, import_node_crypto56, SEP, keyOf, prefixOf, MemoryWorkorderTagStore, FileWorkorderTagStore;
239642
239784
  var init_tags = __esm({
239643
239785
  "../server/src/domains/collab/tags.ts"() {
239644
239786
  "use strict";
239645
- import_node_fs16 = __toESM(require("node:fs"), 1);
239787
+ import_node_fs17 = __toESM(require("node:fs"), 1);
239646
239788
  import_node_path21 = __toESM(require("node:path"), 1);
239647
239789
  import_node_crypto56 = __toESM(require("node:crypto"), 1);
239648
239790
  SEP = "::";
@@ -239720,7 +239862,7 @@ var init_tags = __esm({
239720
239862
  super();
239721
239863
  this.file = file;
239722
239864
  try {
239723
- const raw = JSON.parse(import_node_fs16.default.readFileSync(file, "utf8"));
239865
+ const raw = JSON.parse(import_node_fs17.default.readFileSync(file, "utf8"));
239724
239866
  for (const [k2, v2] of Object.entries(raw)) {
239725
239867
  if (v2 && typeof v2 === "object" && typeof v2.id === "string" && typeof v2.name === "string") this.map.set(k2, v2);
239726
239868
  }
@@ -239729,10 +239871,10 @@ var init_tags = __esm({
239729
239871
  }
239730
239872
  persist() {
239731
239873
  try {
239732
- import_node_fs16.default.mkdirSync(import_node_path21.default.dirname(this.file), { recursive: true });
239874
+ import_node_fs17.default.mkdirSync(import_node_path21.default.dirname(this.file), { recursive: true });
239733
239875
  const tmp = `${this.file}.tmp`;
239734
- import_node_fs16.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
239735
- import_node_fs16.default.renameSync(tmp, this.file);
239876
+ import_node_fs17.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
239877
+ import_node_fs17.default.renameSync(tmp, this.file);
239736
239878
  } catch {
239737
239879
  }
239738
239880
  }
@@ -243660,7 +243802,7 @@ function nodesDomain(deps) {
243660
243802
  const here = (0, import_node_path22.dirname)((0, import_node_url6.fileURLToPath)(__esm_import_meta_url));
243661
243803
  for (const rel of ["../../../../node-daemon/package.json", "../../../../../node-daemon/package.json"]) {
243662
243804
  try {
243663
- const raw = (0, import_node_fs17.readFileSync)((0, import_node_path22.resolve)(here, rel), "utf8");
243805
+ const raw = (0, import_node_fs18.readFileSync)((0, import_node_path22.resolve)(here, rel), "utf8");
243664
243806
  const pkg = JSON.parse(raw);
243665
243807
  if (pkg.version) return { version: pkg.version, source: "monorepo" };
243666
243808
  } catch {
@@ -244266,7 +244408,7 @@ function normalizeGatewayUrl(raw) {
244266
244408
  function newNodeId() {
244267
244409
  return "node-" + (0, import_node_crypto61.randomUUID)().replace(/-/g, "").slice(0, 12);
244268
244410
  }
244269
- var import_node_crypto61, import_node_fs17, import_node_url6, import_node_path22, NODE_NAME_MAX_LENGTH;
244411
+ var import_node_crypto61, import_node_fs18, import_node_url6, import_node_path22, NODE_NAME_MAX_LENGTH;
244270
244412
  var init_routes7 = __esm({
244271
244413
  "../server/src/domains/nodes/routes.ts"() {
244272
244414
  "use strict";
@@ -244274,7 +244416,7 @@ var init_routes7 = __esm({
244274
244416
  init_faults();
244275
244417
  init_runtime_status();
244276
244418
  import_node_crypto61 = require("node:crypto");
244277
- import_node_fs17 = require("node:fs");
244419
+ import_node_fs18 = require("node:fs");
244278
244420
  import_node_url6 = require("node:url");
244279
244421
  import_node_path22 = require("node:path");
244280
244422
  init_src();
@@ -246627,10 +246769,10 @@ function tokenType(p2) {
246627
246769
  function parseOtlpMetricsUsage(body2) {
246628
246770
  const req = body2;
246629
246771
  const out = [];
246630
- for (const rm6 of req.resourceMetrics ?? []) {
246631
- const runId = attrString(rm6.resource?.attributes, "oasis.run_id");
246772
+ for (const rm7 of req.resourceMetrics ?? []) {
246773
+ const runId = attrString(rm7.resource?.attributes, "oasis.run_id");
246632
246774
  if (!runId) continue;
246633
- const actorId = attrString(rm6.resource?.attributes, "oasis.actor_id");
246775
+ const actorId = attrString(rm7.resource?.attributes, "oasis.actor_id");
246634
246776
  let input = 0;
246635
246777
  let output = 0;
246636
246778
  let cacheRead = 0;
@@ -246638,7 +246780,7 @@ function parseOtlpMetricsUsage(body2) {
246638
246780
  let costUsd = 0;
246639
246781
  let sawToken = false;
246640
246782
  let sawCost = false;
246641
- for (const sm of rm6.scopeMetrics ?? []) {
246783
+ for (const sm of rm7.scopeMetrics ?? []) {
246642
246784
  for (const m2 of sm.metrics ?? []) {
246643
246785
  const name = (m2.name ?? "").toLowerCase();
246644
246786
  const points = m2.sum?.dataPoints ?? m2.gauge?.dataPoints ?? [];
@@ -253662,11 +253804,11 @@ function normalize(patch) {
253662
253804
  ...reviewers !== void 0 ? { reviewers: [...new Set(reviewers.map((r) => r.trim()).filter(Boolean))] } : {}
253663
253805
  };
253664
253806
  }
253665
- var import_node_fs18, import_node_path23, SEP2, keyOf2, prefixOf2, MemoryPlaybookOverrideStore, FilePlaybookOverrideStore;
253807
+ var import_node_fs19, import_node_path23, SEP2, keyOf2, prefixOf2, MemoryPlaybookOverrideStore, FilePlaybookOverrideStore;
253666
253808
  var init_overrides = __esm({
253667
253809
  "../server/src/domains/playbooks/overrides.ts"() {
253668
253810
  "use strict";
253669
- import_node_fs18 = __toESM(require("node:fs"), 1);
253811
+ import_node_fs19 = __toESM(require("node:fs"), 1);
253670
253812
  import_node_path23 = __toESM(require("node:path"), 1);
253671
253813
  SEP2 = "::";
253672
253814
  keyOf2 = (companyId, ref2, nodeKey) => `${companyId}${SEP2}${ref2}${SEP2}${nodeKey}`;
@@ -253714,7 +253856,7 @@ var init_overrides = __esm({
253714
253856
  super();
253715
253857
  this.file = file;
253716
253858
  try {
253717
- const raw = JSON.parse(import_node_fs18.default.readFileSync(file, "utf8"));
253859
+ const raw = JSON.parse(import_node_fs19.default.readFileSync(file, "utf8"));
253718
253860
  for (const [k2, v2] of Object.entries(raw)) {
253719
253861
  if (v2 && typeof v2 === "object") this.map.set(k2, v2);
253720
253862
  }
@@ -253723,10 +253865,10 @@ var init_overrides = __esm({
253723
253865
  }
253724
253866
  persist() {
253725
253867
  try {
253726
- import_node_fs18.default.mkdirSync(import_node_path23.default.dirname(this.file), { recursive: true });
253868
+ import_node_fs19.default.mkdirSync(import_node_path23.default.dirname(this.file), { recursive: true });
253727
253869
  const tmp = `${this.file}.tmp`;
253728
- import_node_fs18.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
253729
- import_node_fs18.default.renameSync(tmp, this.file);
253870
+ import_node_fs19.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
253871
+ import_node_fs19.default.renameSync(tmp, this.file);
253730
253872
  } catch {
253731
253873
  }
253732
253874
  }
@@ -254825,17 +254967,17 @@ var init_dispatch_fence = __esm({
254825
254967
  });
254826
254968
 
254827
254969
  // ../server/src/side-map.ts
254828
- var import_node_fs19, import_node_path24, FileSideMap;
254970
+ var import_node_fs20, import_node_path24, FileSideMap;
254829
254971
  var init_side_map = __esm({
254830
254972
  "../server/src/side-map.ts"() {
254831
254973
  "use strict";
254832
- import_node_fs19 = __toESM(require("node:fs"), 1);
254974
+ import_node_fs20 = __toESM(require("node:fs"), 1);
254833
254975
  import_node_path24 = __toESM(require("node:path"), 1);
254834
254976
  FileSideMap = class {
254835
254977
  constructor(file) {
254836
254978
  this.file = file;
254837
254979
  try {
254838
- const raw = JSON.parse(import_node_fs19.default.readFileSync(file, "utf8"));
254980
+ const raw = JSON.parse(import_node_fs20.default.readFileSync(file, "utf8"));
254839
254981
  for (const [k2, v2] of Object.entries(raw)) if (typeof v2 === "string") this.map.set(k2, v2);
254840
254982
  } catch {
254841
254983
  }
@@ -254857,10 +254999,10 @@ var init_side_map = __esm({
254857
254999
  }
254858
255000
  persist() {
254859
255001
  try {
254860
- import_node_fs19.default.mkdirSync(import_node_path24.default.dirname(this.file), { recursive: true });
255002
+ import_node_fs20.default.mkdirSync(import_node_path24.default.dirname(this.file), { recursive: true });
254861
255003
  const tmp = `${this.file}.tmp`;
254862
- import_node_fs19.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
254863
- import_node_fs19.default.renameSync(tmp, this.file);
255004
+ import_node_fs20.default.writeFileSync(tmp, JSON.stringify(Object.fromEntries(this.map), null, 2));
255005
+ import_node_fs20.default.renameSync(tmp, this.file);
254864
255006
  } catch {
254865
255007
  }
254866
255008
  }
@@ -266946,10 +267088,10 @@ var init_postgres_model_prices = __esm({
266946
267088
  // ../storage/src/postgres-type-registry.ts
266947
267089
  async function backfillTypeRegistryFromFile(store, file) {
266948
267090
  if ((await store.list()).length > 0) return { filled: 0 };
266949
- if (!import_node_fs20.default.existsSync(file)) return { filled: 0 };
267091
+ if (!import_node_fs21.default.existsSync(file)) return { filled: 0 };
266950
267092
  let defs;
266951
267093
  try {
266952
- defs = JSON.parse(import_node_fs20.default.readFileSync(file, "utf8"));
267094
+ defs = JSON.parse(import_node_fs21.default.readFileSync(file, "utf8"));
266953
267095
  } catch {
266954
267096
  console.warn(`[type-registry-backfill] ${file} \u89E3\u6790\u5931\u8D25\uFF0C\u8DF3\u8FC7\u56DE\u586B\uFF08serve \u5C06\u7528\u4EE3\u7801\u5E38\u91CF\u64AD\u79CD\uFF09`);
266955
267097
  return { filled: 0 };
@@ -266959,11 +267101,11 @@ async function backfillTypeRegistryFromFile(store, file) {
266959
267101
  console.log(`[type-registry-backfill] \u51B3\u7B56 0062 \u56DE\u586B\uFF1A${defs.length} \u4E2A\u4EA7\u7269\u7C7B\u578B\u5DF2\u8FC1\u5165 Postgres`);
266960
267102
  return { filled: defs.length };
266961
267103
  }
266962
- var import_node_fs20, PostgresTypeRegistryStore;
267104
+ var import_node_fs21, PostgresTypeRegistryStore;
266963
267105
  var init_postgres_type_registry = __esm({
266964
267106
  "../storage/src/postgres-type-registry.ts"() {
266965
267107
  "use strict";
266966
- import_node_fs20 = __toESM(require("node:fs"), 1);
267108
+ import_node_fs21 = __toESM(require("node:fs"), 1);
266967
267109
  init_esm();
266968
267110
  init_pg_ident();
266969
267111
  PostgresTypeRegistryStore = class _PostgresTypeRegistryStore {
@@ -268605,11 +268747,11 @@ async function moveTenancyRows(pool, opts) {
268605
268747
  const insert = `INSERT INTO ${quoteIdent2(to)}.${quoteIdent2(spec.table)} (${colList}) SELECT ${colList} FROM ${quoteIdent2(from)}.${quoteIdent2(spec.table)} WHERE ${quoteIdent2(spec.key)} = ANY($1::text[])`;
268606
268748
  const del = `DELETE FROM ${quoteIdent2(from)}.${quoteIdent2(spec.table)} WHERE ${quoteIdent2(spec.key)} = ANY($1::text[])`;
268607
268749
  const ins = await client.query(insert, [ids2]);
268608
- const rm6 = await client.query(del, [ids2]);
268750
+ const rm7 = await client.query(del, [ids2]);
268609
268751
  executed.push(insert, del);
268610
- log3(`[move] ${spec.table}: +${ins.rowCount ?? 0} \u2192 ${to} / -${rm6.rowCount ?? 0} \u2190 ${from}`);
268611
- if ((ins.rowCount ?? 0) !== (rm6.rowCount ?? 0)) {
268612
- throw new Error(`${spec.table}: \u63D2\u5165 ${ins.rowCount} \u884C\u3001\u5220\u9664 ${rm6.rowCount} \u884C\uFF0C\u4E0D\u4E00\u81F4 \u2014\u2014 \u5DF2\u56DE\u6EDA`);
268752
+ log3(`[move] ${spec.table}: +${ins.rowCount ?? 0} \u2192 ${to} / -${rm7.rowCount ?? 0} \u2190 ${from}`);
268753
+ if ((ins.rowCount ?? 0) !== (rm7.rowCount ?? 0)) {
268754
+ throw new Error(`${spec.table}: \u63D2\u5165 ${ins.rowCount} \u884C\u3001\u5220\u9664 ${rm7.rowCount} \u884C\uFF0C\u4E0D\u4E00\u81F4 \u2014\u2014 \u5DF2\u56DE\u6EDA`);
268613
268755
  }
268614
268756
  }
268615
268757
  await client.query("COMMIT");
@@ -274630,26 +274772,26 @@ var init_cutover_aware_workorder_drafts = __esm({
274630
274772
 
274631
274773
  // ../server/src/governance/builtin-skills.ts
274632
274774
  async function collectDir(root, dir, out) {
274633
- const entries = await (0, import_promises14.readdir)(dir, { withFileTypes: true });
274775
+ const entries = await (0, import_promises15.readdir)(dir, { withFileTypes: true });
274634
274776
  for (const e of entries) {
274635
274777
  const abs = (0, import_node_path25.join)(dir, e.name);
274636
274778
  if (e.isDirectory()) {
274637
274779
  await collectDir(root, abs, out);
274638
274780
  } else if (e.isFile()) {
274639
- const info = await (0, import_promises14.stat)(abs);
274781
+ const info = await (0, import_promises15.stat)(abs);
274640
274782
  if (info.size > MAX_FILE_BYTES2) {
274641
274783
  console.warn(`[builtin-skills] skip oversized file (${info.size}B): ${abs}`);
274642
274784
  continue;
274643
274785
  }
274644
274786
  const rel = (0, import_node_path25.relative)(root, abs).split(/[\\/]/).join("/");
274645
- out[rel] = await (0, import_promises14.readFile)(abs, "utf8");
274787
+ out[rel] = await (0, import_promises15.readFile)(abs, "utf8");
274646
274788
  }
274647
274789
  }
274648
274790
  }
274649
274791
  async function loadBuiltinSkills(skillsDir) {
274650
274792
  let dirents;
274651
274793
  try {
274652
- dirents = await (0, import_promises14.readdir)(skillsDir, { withFileTypes: true });
274794
+ dirents = await (0, import_promises15.readdir)(skillsDir, { withFileTypes: true });
274653
274795
  } catch {
274654
274796
  return [];
274655
274797
  }
@@ -274697,11 +274839,11 @@ function applyBuiltinSkillVariants(builtins, opts) {
274697
274839
  return { ...skill, name: name || skill.id, description, files };
274698
274840
  });
274699
274841
  }
274700
- var import_promises14, import_node_path25, MAX_FILE_BYTES2, BUILTIN_SKILL_DELEGATION_VARIANT;
274842
+ var import_promises15, import_node_path25, MAX_FILE_BYTES2, BUILTIN_SKILL_DELEGATION_VARIANT;
274701
274843
  var init_builtin_skills = __esm({
274702
274844
  "../server/src/governance/builtin-skills.ts"() {
274703
274845
  "use strict";
274704
- import_promises14 = require("node:fs/promises");
274846
+ import_promises15 = require("node:fs/promises");
274705
274847
  import_node_path25 = require("node:path");
274706
274848
  init_skill_fetcher();
274707
274849
  init_skill_materializer();
@@ -274753,7 +274895,7 @@ async function fetchLatestNpmVersion(pkg) {
274753
274895
  }
274754
274896
  async function readRegisteredToolVersions(dataDir) {
274755
274897
  try {
274756
- const raw = JSON.parse(await (0, import_promises15.readFile)(connectorToolVersionsFile(dataDir), "utf8"));
274898
+ const raw = JSON.parse(await (0, import_promises16.readFile)(connectorToolVersionsFile(dataDir), "utf8"));
274757
274899
  if (!raw || typeof raw !== "object") return {};
274758
274900
  const out = {};
274759
274901
  for (const [k2, v2] of Object.entries(raw)) {
@@ -274766,11 +274908,11 @@ async function readRegisteredToolVersions(dataDir) {
274766
274908
  }
274767
274909
  async function writeRegisteredToolVersions(dataDir, versions) {
274768
274910
  const file = connectorToolVersionsFile(dataDir);
274769
- await (0, import_promises15.mkdir)((0, import_node_path26.join)(dataDir, "connector-tools"), { recursive: true });
274911
+ await (0, import_promises16.mkdir)((0, import_node_path26.join)(dataDir, "connector-tools"), { recursive: true });
274770
274912
  const tmp = `${file}.${process.pid}.tmp`;
274771
- await (0, import_promises15.writeFile)(tmp, `${JSON.stringify(versions, null, 2)}
274913
+ await (0, import_promises16.writeFile)(tmp, `${JSON.stringify(versions, null, 2)}
274772
274914
  `, "utf8");
274773
- await (0, import_promises15.rename)(tmp, file);
274915
+ await (0, import_promises16.rename)(tmp, file);
274774
274916
  }
274775
274917
  async function refreshConnectorToolVersions(opts) {
274776
274918
  const fetchLatest = opts.fetchLatest ?? fetchLatestNpmVersion;
@@ -274813,11 +274955,11 @@ function pickToolVersions(registered, tools) {
274813
274955
  }
274814
274956
  return out;
274815
274957
  }
274816
- var import_promises15, import_node_path26, NPM_PROBE_TIMEOUT_MS;
274958
+ var import_promises16, import_node_path26, NPM_PROBE_TIMEOUT_MS;
274817
274959
  var init_connector_tool_versions = __esm({
274818
274960
  "../server/src/governance/connector-tool-versions.ts"() {
274819
274961
  "use strict";
274820
- import_promises15 = require("node:fs/promises");
274962
+ import_promises16 = require("node:fs/promises");
274821
274963
  import_node_path26 = require("node:path");
274822
274964
  init_src8();
274823
274965
  NPM_PROBE_TIMEOUT_MS = 3e3;
@@ -274863,11 +275005,14 @@ var init_board_watch = __esm({
274863
275005
  constructor(deps) {
274864
275006
  this.deps = deps;
274865
275007
  }
275008
+ odGet(path46) {
275009
+ const fetchImpl = this.deps.fetchImpl ?? fetch;
275010
+ return fetchImpl(`${this.deps.odBase}${path46}`, this.deps.odToken ? { headers: { authorization: `Bearer ${this.deps.odToken}` } } : void 0);
275011
+ }
274866
275012
  /** 查一块板的交付物(排 task-context/、只算带 artifactManifest 的)。404/网络错 → null(板不存在)。 */
274867
275013
  async boardFiles(boardKey) {
274868
- const fetchImpl = this.deps.fetchImpl ?? fetch;
274869
275014
  try {
274870
- const res = await fetchImpl(`${this.deps.odBase}/api/projects/${encodeURIComponent(boardKey)}/files`);
275015
+ const res = await this.odGet(`/api/projects/${encodeURIComponent(boardKey)}/files`);
274871
275016
  if (!res.ok) return null;
274872
275017
  const body2 = await res.json();
274873
275018
  return (body2.files ?? []).filter((f2) => !f2.path.startsWith("task-context/") && f2.artifactManifest !== void 0).map((f2) => ({ path: f2.path, kind: f2.kind ?? null, mtime: f2.mtime ?? null }));
@@ -274881,9 +275026,8 @@ var init_board_watch = __esm({
274881
275026
  * 由板文件 mtime 那条慢路径兜底,绝不因为查不到 run 就压掉写信。
274882
275027
  */
274883
275028
  async boardRuns(boardKey) {
274884
- const fetchImpl = this.deps.fetchImpl ?? fetch;
274885
275029
  try {
274886
- const res = await fetchImpl(`${this.deps.odBase}/api/runs?projectId=${encodeURIComponent(boardKey)}`);
275030
+ const res = await this.odGet(`/api/runs?projectId=${encodeURIComponent(boardKey)}`);
274887
275031
  if (!res.ok) return [];
274888
275032
  const body2 = await res.json();
274889
275033
  return (body2.runs ?? []).map((r) => ({ runId: String(r["runId"] ?? r["id"] ?? ""), status: String(r["status"] ?? "unknown") })).filter((r) => r.runId.length > 0);
@@ -278486,7 +278630,7 @@ function createDiscussionRuntime(options) {
278486
278630
 
278487
278631
  // ../server/src/domains/discussions/store.ts
278488
278632
  var import_node_crypto86 = require("node:crypto");
278489
- var import_promises16 = require("node:fs/promises");
278633
+ var import_promises17 = require("node:fs/promises");
278490
278634
  var import_node_path27 = require("node:path");
278491
278635
  var key = (kind, id) => JSON.stringify([kind, id]);
278492
278636
  var MemoryDiscussionStore = class _MemoryDiscussionStore {
@@ -278498,7 +278642,7 @@ var MemoryDiscussionStore = class _MemoryDiscussionStore {
278498
278642
  static async open(filename) {
278499
278643
  const store = new _MemoryDiscussionStore(filename);
278500
278644
  try {
278501
- store.rows = JSON.parse(await (0, import_promises16.readFile)(filename, "utf8"));
278645
+ store.rows = JSON.parse(await (0, import_promises17.readFile)(filename, "utf8"));
278502
278646
  } catch (error2) {
278503
278647
  if (error2.code !== "ENOENT") throw error2;
278504
278648
  }
@@ -278529,10 +278673,10 @@ var MemoryDiscussionStore = class _MemoryDiscussionStore {
278529
278673
  const result = await run(tx);
278530
278674
  if (changed) {
278531
278675
  if (this.filename) {
278532
- await (0, import_promises16.mkdir)((0, import_node_path27.dirname)(this.filename), { recursive: true });
278676
+ await (0, import_promises17.mkdir)((0, import_node_path27.dirname)(this.filename), { recursive: true });
278533
278677
  const temp = `${this.filename}.${(0, import_node_crypto86.randomUUID)()}.tmp`;
278534
- await (0, import_promises16.writeFile)(temp, JSON.stringify(next), "utf8");
278535
- await (0, import_promises16.rename)(temp, this.filename);
278678
+ await (0, import_promises17.writeFile)(temp, JSON.stringify(next), "utf8");
278679
+ await (0, import_promises17.rename)(temp, this.filename);
278536
278680
  }
278537
278681
  this.rows = next;
278538
278682
  }
@@ -286417,11 +286561,18 @@ ${nodeFault}` : "");
286417
286561
  const boardWatchFlag = (process.env["OASIS_BOARD_WATCH"] ?? "").trim().toLowerCase();
286418
286562
  if (!["0", "false", "off"].includes(boardWatchFlag)) {
286419
286563
  const odBase = (process.env["OASIS_OPEN_DESIGN_URL"] ?? "http://127.0.0.1:7457").replace(/\/$/, "");
286420
- const boardWatcher = new BoardWatcher({ kernel: defaultCompanyKernel, odBase, boardKeyOf: deriveBoardKey, log: (m2) => console.log(m2) });
286564
+ const odToken = process.env["OASIS_OPEN_DESIGN_TOKEN"]?.trim() || void 0;
286565
+ const boardWatcher = new BoardWatcher({
286566
+ kernel: defaultCompanyKernel,
286567
+ odBase,
286568
+ ...odToken ? { odToken } : {},
286569
+ boardKeyOf: deriveBoardKey,
286570
+ log: (m2) => console.log(m2)
286571
+ });
286421
286572
  boardWatchTimer = setInterval(() => {
286422
286573
  void boardWatcher.tick().catch((err) => console.error(`[board-watch] tick \u5931\u8D25: ${String(err)}`));
286423
286574
  }, 6e4);
286424
- console.log(`[serve] \u753B\u677F\u76D1\u89C6\u5668\u5DF2\u542F\u7528\uFF08od=${odBase}\uFF0C\u9759\u9ED8\u7A97 10min\uFF0C\u6BCF\u8F6E\u4E0A\u9650 2 \u5C01\u4FE1\uFF1BOASIS_BOARD_WATCH=0 \u53EF\u5173\uFF09`);
286575
+ console.log(`[serve] \u753B\u677F\u76D1\u89C6\u5668\u5DF2\u542F\u7528\uFF08od=${odBase}${odToken ? "\uFF0C\u5E26\u4EE4\u724C" : ""}\uFF0C\u9759\u9ED8\u7A97 10min\uFF0C\u6BCF\u8F6E\u4E0A\u9650 2 \u5C01\u4FE1\uFF1BOASIS_BOARD_WATCH=0 \u53EF\u5173\uFF09`);
286425
286576
  } else {
286426
286577
  console.log(`[serve] \u753B\u677F\u76D1\u89C6\u5668\u5DF2\u88AB OASIS_BOARD_WATCH=${boardWatchFlag} \u663E\u5F0F\u5173\u95ED`);
286427
286578
  }
@@ -287454,7 +287605,7 @@ function readCodexQuota(binary, signal, timeoutMs = 15e3) {
287454
287605
 
287455
287606
  // ../cli/src/daemon/quota/claude.ts
287456
287607
  var import_node_child_process21 = require("node:child_process");
287457
- var import_promises17 = require("node:fs/promises");
287608
+ var import_promises18 = require("node:fs/promises");
287458
287609
  var import_node_os10 = require("node:os");
287459
287610
  var import_node_path28 = require("node:path");
287460
287611
  var import_node_util6 = require("node:util");
@@ -287476,8 +287627,8 @@ async function credentials(env, signal) {
287476
287627
  }
287477
287628
  if (!raw) {
287478
287629
  const file = (0, import_node_path28.join)(env.CLAUDE_CONFIG_DIR || (0, import_node_path28.join)((0, import_node_os10.homedir)(), ".claude"), ".credentials.json");
287479
- if ((await (0, import_promises17.stat)(file)).size > 256 * 1024) return void 0;
287480
- raw = await (0, import_promises17.readFile)(file, { encoding: "utf8", ...signal ? { signal } : {} });
287630
+ if ((await (0, import_promises18.stat)(file)).size > 256 * 1024) return void 0;
287631
+ raw = await (0, import_promises18.readFile)(file, { encoding: "utf8", ...signal ? { signal } : {} });
287481
287632
  }
287482
287633
  const oauth = object6(object6(JSON.parse(raw)).claudeAiOauth);
287483
287634
  if (typeof oauth.expiresAt === "number" && oauth.expiresAt <= Date.now()) return void 0;
@@ -287677,7 +287828,7 @@ function detectRuntimes() {
287677
287828
  }
287678
287829
 
287679
287830
  // ../cli/src/daemon/workdir-handler.ts
287680
- var import_node_fs21 = __toESM(require("node:fs"), 1);
287831
+ var import_node_fs22 = __toESM(require("node:fs"), 1);
287681
287832
  var import_node_path29 = __toESM(require("node:path"), 1);
287682
287833
  init_src2();
287683
287834
  init_src();
@@ -287715,7 +287866,7 @@ async function trustedCanonicalContainer(req, logicalBase, dirKind) {
287715
287866
  const trustedRoot = isLegacy ? resolveLegacyWorkRoot(req.workRoot) : resolveWorkRoot(req.workRoot);
287716
287867
  let trustedRootReal;
287717
287868
  try {
287718
- trustedRootReal = await import_node_fs21.default.promises.realpath(trustedRoot);
287869
+ trustedRootReal = await import_node_fs22.default.promises.realpath(trustedRoot);
287719
287870
  } catch {
287720
287871
  return null;
287721
287872
  }
@@ -287733,7 +287884,7 @@ async function resolveWithinWorkdir(req) {
287733
287884
  if (canonicalContainer === null) return { ok: false, code: "NOT_FOUND" };
287734
287885
  let base;
287735
287886
  try {
287736
- base = await import_node_fs21.default.promises.realpath(logicalBase);
287887
+ base = await import_node_fs22.default.promises.realpath(logicalBase);
287737
287888
  } catch {
287738
287889
  return { ok: false, code: "NOT_FOUND" };
287739
287890
  }
@@ -287745,7 +287896,7 @@ async function resolveWithinWorkdir(req) {
287745
287896
  if (relPathIsSensitive(cleanRel)) return { ok: false, code: "SENSITIVE" };
287746
287897
  let real;
287747
287898
  try {
287748
- real = await import_node_fs21.default.promises.realpath(requested);
287899
+ real = await import_node_fs22.default.promises.realpath(requested);
287749
287900
  } catch (e) {
287750
287901
  if (e.code === "ENOENT") return { ok: false, code: "NOT_FOUND" };
287751
287902
  return { ok: false, code: "PATH_ESCAPE" };
@@ -287762,7 +287913,7 @@ async function handleWorkdirList(req) {
287762
287913
  const { base, real } = resolved;
287763
287914
  let dh;
287764
287915
  try {
287765
- dh = await import_node_fs21.default.promises.open(real, import_node_fs21.default.constants.O_RDONLY | import_node_fs21.default.constants.O_NOFOLLOW | import_node_fs21.default.constants.O_NONBLOCK);
287916
+ dh = await import_node_fs22.default.promises.open(real, import_node_fs22.default.constants.O_RDONLY | import_node_fs22.default.constants.O_NOFOLLOW | import_node_fs22.default.constants.O_NONBLOCK);
287766
287917
  } catch (e) {
287767
287918
  const code2 = e.code;
287768
287919
  if (code2 === "ELOOP") return { ok: false, code: "PATH_ESCAPE" };
@@ -287776,7 +287927,7 @@ async function handleWorkdirList(req) {
287776
287927
  const anchor = verified.anchor;
287777
287928
  const dst = await dh.stat();
287778
287929
  if (!dst.isDirectory()) return { ok: false, code: "NOT_FOUND" };
287779
- const dirents = await import_node_fs21.default.promises.readdir(anchor, { withFileTypes: true });
287930
+ const dirents = await import_node_fs22.default.promises.readdir(anchor, { withFileTypes: true });
287780
287931
  const visible = dirents.filter((d) => !isSensitiveSegment(d.name));
287781
287932
  visible.sort((a, b2) => {
287782
287933
  const ad = a.isDirectory() ? 0 : 1;
@@ -287789,7 +287940,7 @@ async function handleWorkdirList(req) {
287789
287940
  for (const d of slice) {
287790
287941
  const abs = import_node_path29.default.join(anchor, d.name);
287791
287942
  try {
287792
- const st = await import_node_fs21.default.promises.lstat(abs);
287943
+ const st = await import_node_fs22.default.promises.lstat(abs);
287793
287944
  if (st.isSymbolicLink()) continue;
287794
287945
  entries.push({
287795
287946
  name: d.name,
@@ -287845,7 +287996,7 @@ async function handleWorkdirWalk(req, now = Date.now) {
287845
287996
  }
287846
287997
  async function fdCanonicalPath(fh) {
287847
287998
  try {
287848
- return await import_node_fs21.default.promises.readlink(`/proc/self/fd/${fh.fd}`);
287999
+ return await import_node_fs22.default.promises.readlink(`/proc/self/fd/${fh.fd}`);
287849
288000
  } catch {
287850
288001
  return null;
287851
288002
  }
@@ -287866,7 +288017,7 @@ async function handleWorkdirRead(req) {
287866
288017
  const { base, real } = resolved;
287867
288018
  let fh;
287868
288019
  try {
287869
- fh = await import_node_fs21.default.promises.open(real, import_node_fs21.default.constants.O_RDONLY | import_node_fs21.default.constants.O_NOFOLLOW | import_node_fs21.default.constants.O_NONBLOCK);
288020
+ fh = await import_node_fs22.default.promises.open(real, import_node_fs22.default.constants.O_RDONLY | import_node_fs22.default.constants.O_NOFOLLOW | import_node_fs22.default.constants.O_NONBLOCK);
287870
288021
  } catch (e) {
287871
288022
  const code2 = e.code;
287872
288023
  if (code2 === "ELOOP") return { ok: false, code: "PATH_ESCAPE" };
@@ -288682,7 +288833,7 @@ var RuntimeRouterAdapter = class {
288682
288833
  };
288683
288834
 
288684
288835
  // ../cli/src/daemon/reap-claude-projects.ts
288685
- var import_node_fs22 = __toESM(require("node:fs"), 1);
288836
+ var import_node_fs23 = __toESM(require("node:fs"), 1);
288686
288837
  var import_node_os12 = __toESM(require("node:os"), 1);
288687
288838
  var import_node_path30 = __toESM(require("node:path"), 1);
288688
288839
  function claudeProjectSlug(cwd) {
@@ -288695,9 +288846,9 @@ function claudeProjectsRoot() {
288695
288846
  function reapClaudeProjects(workdir, runtimeKind) {
288696
288847
  if (runtimeKind !== "claude" && runtimeKind !== "claude-code") return;
288697
288848
  const dir = import_node_path30.default.join(claudeProjectsRoot(), claudeProjectSlug(workdir));
288698
- if (!import_node_fs22.default.existsSync(dir)) return;
288849
+ if (!import_node_fs23.default.existsSync(dir)) return;
288699
288850
  try {
288700
- import_node_fs22.default.rmSync(dir, { recursive: true, force: true });
288851
+ import_node_fs23.default.rmSync(dir, { recursive: true, force: true });
288701
288852
  } catch {
288702
288853
  }
288703
288854
  }
@@ -288710,7 +288861,7 @@ function dirSizeBytes2(dir) {
288710
288861
  let total = 0;
288711
288862
  let entries;
288712
288863
  try {
288713
- entries = import_node_fs22.default.readdirSync(dir, { withFileTypes: true });
288864
+ entries = import_node_fs23.default.readdirSync(dir, { withFileTypes: true });
288714
288865
  } catch {
288715
288866
  return 0;
288716
288867
  }
@@ -288722,7 +288873,7 @@ function dirSizeBytes2(dir) {
288722
288873
  continue;
288723
288874
  }
288724
288875
  try {
288725
- total += import_node_fs22.default.statSync(p2).size;
288876
+ total += import_node_fs23.default.statSync(p2).size;
288726
288877
  } catch {
288727
288878
  }
288728
288879
  }
@@ -288919,13 +289070,13 @@ function forwardSignal(child, sig, killGroup = (pgid, signal) => {
288919
289070
 
288920
289071
  // ../cli/src/daemon/machine-id.ts
288921
289072
  var import_node_child_process23 = require("node:child_process");
288922
- var import_node_fs23 = require("node:fs");
289073
+ var import_node_fs24 = require("node:fs");
288923
289074
  var import_node_crypto89 = require("node:crypto");
288924
289075
  var import_node_os14 = require("node:os");
288925
289076
  function linuxMachineId() {
288926
289077
  for (const p2 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
288927
289078
  try {
288928
- const v2 = (0, import_node_fs23.readFileSync)(p2, "utf8").trim();
289079
+ const v2 = (0, import_node_fs24.readFileSync)(p2, "utf8").trim();
288929
289080
  if (v2) return v2;
288930
289081
  } catch {
288931
289082
  }
@@ -288996,6 +289147,24 @@ init_src();
288996
289147
  init_src7();
288997
289148
  init_src2();
288998
289149
 
289150
+ // ../cli/src/design-endpoint.ts
289151
+ init_src8();
289152
+ var OD_LOCAL_DEFAULT = "http://127.0.0.1:7457";
289153
+ function resolveOpenDesignEndpoint(flagUrl, env = process.env) {
289154
+ const creds = readOpenDesignCreds(env);
289155
+ const trim = (u) => u.replace(/\/$/, "");
289156
+ const picked = flagUrl ? { base: trim(flagUrl), source: "--od-url" } : creds ? { base: trim(creds.baseUrl), source: "\u8FDE\u63A5\u5668" } : env["OASIS_OPEN_DESIGN_URL"] ? { base: trim(env["OASIS_OPEN_DESIGN_URL"]), source: "OASIS_OPEN_DESIGN_URL" } : { base: OD_LOCAL_DEFAULT, source: "\u672C\u673A\u9ED8\u8BA4" };
289157
+ if (creds && sameOrigin(picked.base, creds.baseUrl)) return { ...picked, token: creds.apiToken };
289158
+ return picked;
289159
+ }
289160
+ function sameOrigin(a, b2) {
289161
+ try {
289162
+ return new URL(a).origin === new URL(b2).origin;
289163
+ } catch {
289164
+ return false;
289165
+ }
289166
+ }
289167
+
288999
289168
  // ../cli/src/workorder-attachments.ts
289000
289169
  var fs41 = __toESM(require("node:fs"), 1);
289001
289170
  var path35 = __toESM(require("node:path"), 1);
@@ -289608,7 +289777,7 @@ var COMMAND_DECLS = {
289608
289777
  design: {
289609
289778
  group: "\u8BBE\u8BA1\u7A3F",
289610
289779
  usage: "oasis design <chat|status> <artifactId> ...",
289611
- description: "\u8BBE\u8BA1\u4EA7\u7269\u76F8\u5173\u64CD\u4F5C\u3002",
289780
+ description: "\u8BBE\u8BA1\u4EA7\u7269\u76F8\u5173\u64CD\u4F5C\u3002\u8FDE\u54EA\u4E2A open-design\uFF1A\u5458\u5DE5\u5F00\u4E86 open-design \u8FDE\u63A5\u5668\u5C31\u8FDE\u5B83\u767B\u8BB0\u7684\u5730\u5740\u5E76\u5E26\u4EE4\u724C\uFF08\u4EFB\u610F\u8282\u70B9\u53EF\u7528\uFF09\uFF0C\u5426\u5219 $OASIS_OPEN_DESIGN_URL\uFF0C\u518D\u5426\u5219\u672C\u673A\u3002",
289612
289781
  subCommands: ["design chat", "design status"],
289613
289782
  examples: ['oasis design chat artifact:design:xyz --message "\u8BBE\u8BA1\u767B\u5F55\u9875" --async']
289614
289783
  },
@@ -291485,7 +291654,7 @@ async function waitForCommandAuthorization(base, headers, draftId, fallback) {
291485
291654
  }
291486
291655
  }
291487
291656
  }
291488
- var CLI_VERSION = "2.2.76" ? "2.2.76" : "dev";
291657
+ var CLI_VERSION = "2.2.77" ? "2.2.77" : "dev";
291489
291658
  function apiHeaders(token, company) {
291490
291659
  const headers = {
291491
291660
  authorization: `Bearer ${token}`,
@@ -293217,7 +293386,9 @@ ${res.warning}`);
293217
293386
  const artifactId = needPos(positional, 1, "oasis design chat <artifactId> --message <t>");
293218
293387
  const message = flags.get("message") ?? (["DESIGN_BRIEF.md", "TASK.md"].map((f2) => fs43.existsSync(f2) ? fs43.readFileSync(f2, "utf8") : "").find((s2) => s2.trim()) ?? "");
293219
293388
  if (!message.trim()) throw new Error("\u65E0\u5BF9\u8BDD\u5185\u5BB9\uFF1A\u7ED9 --message <text>\uFF0C\u6216\u5728\u5F53\u524D\u76EE\u5F55\u653E DESIGN_BRIEF.md / TASK.md");
293220
- const odBase = (flags.get("od-url") ?? process.env["OASIS_OPEN_DESIGN_URL"] ?? "http://127.0.0.1:7457").replace(/\/$/, "");
293389
+ const od = resolveOpenDesignEndpoint(flags.get("od-url"));
293390
+ const odBase = od.base;
293391
+ const odLabel = `${odBase}\uFF08\u5730\u5740\u6765\u81EA${od.source}${od.token ? "\uFF0C\u5E26\u4EE4\u724C" : ""}\uFF09`;
293221
293392
  const isContinue = flags.get("turn") === "continue";
293222
293393
  const contextFiles = {};
293223
293394
  if (!isContinue) {
@@ -293230,6 +293401,7 @@ ${res.warning}`);
293230
293401
  }
293231
293402
  const baseTurnOpts = {
293232
293403
  base: odBase,
293404
+ ...od.token ? { token: od.token } : {},
293233
293405
  agentId: flags.get("agent") ?? "claude",
293234
293406
  artifactId,
293235
293407
  title: flags.get("title") ?? artifactId,
@@ -293238,13 +293410,13 @@ ${res.warning}`);
293238
293410
  ...isContinue ? {} : { contextFiles }
293239
293411
  };
293240
293412
  if (flags.get("async") === "true") {
293241
- println(`[design] \u753B\u677F ${deriveBoardKey(artifactId)} \u2190 ${artifactId}\uFF1B${isContinue ? "\u7EED\u8F6E" : "\u9996\u8F6E"}\uFF08--async\uFF09\u2192 od \u5F15\u64CE ${odBase} \u2026`);
293413
+ println(`[design] \u753B\u677F ${deriveBoardKey(artifactId)} \u2190 ${artifactId}\uFF1B${isContinue ? "\u7EED\u8F6E" : "\u9996\u8F6E"}\uFF08--async\uFF09\u2192 od \u5F15\u64CE ${odLabel} \u2026`);
293242
293414
  const started = await startDesignChatTurn(baseTurnOpts);
293243
293415
  println(`[design] \u5DF2\u4E0B\u5355\uFF1Arun ${started.runId.slice(0, 8)}\uFF08board ${started.boardKey}, \u53EF\u89C1 user \u56DE\u5408 ${started.userMessageId.slice(0, 8)}\uFF09\u3002\u5F15\u64CE\u901A\u5E38\u8981 13\u201344 \u5206\u949F\u3002`);
293244
293416
  println(`[design] \u4E4B\u540E\u7528 oasis design status ${artifactId} \u67E5\u8FDB\u5EA6/\u53D6\u8D27\uFF08--pull \u62C9\u4EA7\u7269\u5230\u672C\u5730\u8BFB\uFF09\uFF1B\u4E0D\u5FC5\u5B88\u7740\u7B49\u3002`);
293245
293417
  break;
293246
293418
  }
293247
- println(`[design] \u753B\u677F ${deriveBoardKey(artifactId)} \u2190 ${artifactId}\uFF1B${isContinue ? "\u7EED\u8F6E" : "\u9996\u8F6E"}\u5BF9\u8BDD\u9A71\u52A8 od \u5F15\u64CE ${odBase} \u2026`);
293419
+ println(`[design] \u753B\u677F ${deriveBoardKey(artifactId)} \u2190 ${artifactId}\uFF1B${isContinue ? "\u7EED\u8F6E" : "\u9996\u8F6E"}\u5BF9\u8BDD\u9A71\u52A8 od \u5F15\u64CE ${odLabel} \u2026`);
293248
293420
  const turn = await runDesignChatTurn({
293249
293421
  ...baseTurnOpts,
293250
293422
  onLine: (line2) => println(`[od] ${line2.length > 500 ? line2.slice(0, 500) + "\u2026" : line2}`)
@@ -293256,8 +293428,10 @@ ${res.warning}`);
293256
293428
  }
293257
293429
  if (sub === "status") {
293258
293430
  const artifactId = needPos(positional, 1, "oasis design status <artifactId> [--pull]");
293259
- const odBase = (flags.get("od-url") ?? process.env["OASIS_OPEN_DESIGN_URL"] ?? "http://127.0.0.1:7457").replace(/\/$/, "");
293260
- const st = await fetchBoardStatus(odBase, fetch, artifactId);
293431
+ const od = resolveOpenDesignEndpoint(flags.get("od-url"));
293432
+ const odBase = od.base;
293433
+ const odFetch = withOdToken(fetch, od.token);
293434
+ const st = await fetchBoardStatus(odBase, odFetch, artifactId);
293261
293435
  if (!st.boardExists) {
293262
293436
  println(`[design] \u753B\u677F ${st.boardKey} \u5C1A\u4E0D\u5B58\u5728\u2014\u2014\u8FD8\u6CA1\u8D77\u8FC7\u4EFB\u4F55\u4E00\u8F6E\u3002\u5F00\u5DE5\uFF1Aoasis design chat ${artifactId} --message "<\u8BBE\u8BA1\u9700\u6C42+\u771F\u5B9E\u6570\u636E>" --async`);
293263
293437
  break;
@@ -293278,7 +293452,7 @@ ${res.warning}`);
293278
293452
  for (const a of st.artifacts) println(` - ${a.path}\uFF08${a.kind ?? "?"}\uFF09status=${a.status ?? "?"}${a.mtime ? ` \xB7 ${new Date(a.mtime).toISOString()}` : ""}`);
293279
293453
  if (flags.get("pull") === "true") {
293280
293454
  const odPublic = (flags.get("od-public-url") ?? process.env["OASIS_OPEN_DESIGN_PUBLIC_URL"] ?? "https://design.open-friday.com").replace(/\/$/, "");
293281
- const { dir: dir2, entry } = await harvestBoard(odBase, fetch, odPublic, os12.tmpdir(), st.boardKey, st.runs[0]?.runId ?? "status-pull");
293455
+ const { dir: dir2, entry } = await harvestBoard(odBase, odFetch, odPublic, os12.tmpdir(), st.boardKey, st.runs[0]?.runId ?? "status-pull");
293282
293456
  println(`[design] \u5DF2\u62C9\u5230\u672C\u5730\uFF1A${dir2}\uFF08\u5165\u53E3 ${entry}\uFF09`);
293283
293457
  println(`[design] \u8BFB\u5B8C\u6EE1\u610F\u5373\u4EA4\u7A3F\uFF1Aoasis propose ${artifactId} --from-dir ${dir2} --reason "<\u8FD9\u7248\u505A\u4E86\u4EC0\u4E48>"`);
293284
293458
  } else {
@@ -295142,7 +295316,7 @@ function removeInstanceFiles(name, deps) {
295142
295316
  const inst = instancePaths(name);
295143
295317
  const never2 = new Set(sharedPathsNeverRemoved());
295144
295318
  const removed = [];
295145
- const rm6 = (target) => {
295319
+ const rm7 = (target) => {
295146
295320
  const resolved = path42.resolve(target);
295147
295321
  if (never2.has(resolved)) {
295148
295322
  deps.log(`\u62D2\u7EDD\u5220\u9664\u5171\u4EAB\u8DEF\u5F84\uFF1A${resolved}`);
@@ -295166,19 +295340,19 @@ function removeInstanceFiles(name, deps) {
295166
295340
  deps.log(`\u5B9E\u4F8B\u76EE\u5F55 ${dir} \u4E0D\u5728 ${instancesRoot()} \u4E0B\uFF0C\u62D2\u7EDD\u5220\u9664`);
295167
295341
  return removed;
295168
295342
  }
295169
- rm6(dir);
295343
+ rm7(dir);
295170
295344
  return removed;
295171
295345
  }
295172
- rm6(inst.configFile);
295173
- rm6(inst.pidFile);
295174
- rm6(inst.logFile);
295175
- rm6(inst.binDir);
295176
- rm6(inst.currentLink);
295177
- rm6(inst.sessionsDir);
295346
+ rm7(inst.configFile);
295347
+ rm7(inst.pidFile);
295348
+ rm7(inst.logFile);
295349
+ rm7(inst.binDir);
295350
+ rm7(inst.currentLink);
295351
+ rm7(inst.sessionsDir);
295178
295352
  try {
295179
295353
  const base = path42.basename(inst.logFile);
295180
295354
  for (const entry of fs47.readdirSync(path42.dirname(inst.logFile))) {
295181
- if (entry.startsWith(`${base}.`)) rm6(path42.join(path42.dirname(inst.logFile), entry));
295355
+ if (entry.startsWith(`${base}.`)) rm7(path42.join(path42.dirname(inst.logFile), entry));
295182
295356
  }
295183
295357
  } catch {
295184
295358
  }
@@ -295379,7 +295553,7 @@ function shimScript() {
295379
295553
  }
295380
295554
 
295381
295555
  // src/index.ts
295382
- var PKG_VERSION = true ? "2.2.76" : "dev";
295556
+ var PKG_VERSION = true ? "2.2.77" : "dev";
295383
295557
  var LOCAL_BIN = localBin();
295384
295558
  var NPM_PREFIX = npmPrefix();
295385
295559
  var INSTANCE = DEFAULT_INSTANCE;