oasis_test_v2 2.2.15 → 2.2.16

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.js CHANGED
@@ -51348,7 +51348,7 @@ var require_websocket = __commonJS({
51348
51348
  var http2 = require("http");
51349
51349
  var net = require("net");
51350
51350
  var tls = require("tls");
51351
- var { randomBytes: randomBytes13, createHash: createHash37 } = require("crypto");
51351
+ var { randomBytes: randomBytes13, createHash: createHash38 } = require("crypto");
51352
51352
  var { Duplex, Readable } = require("stream");
51353
51353
  var { URL: URL2 } = require("url");
51354
51354
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -52016,7 +52016,7 @@ var require_websocket = __commonJS({
52016
52016
  abortHandshake(websocket, socket, "Invalid Upgrade header");
52017
52017
  return;
52018
52018
  }
52019
- const digest = createHash37("sha1").update(key + GUID).digest("base64");
52019
+ const digest = createHash38("sha1").update(key + GUID).digest("base64");
52020
52020
  if (res.headers["sec-websocket-accept"] !== digest) {
52021
52021
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
52022
52022
  return;
@@ -52385,7 +52385,7 @@ var require_websocket_server = __commonJS({
52385
52385
  var EventEmitter = require("events");
52386
52386
  var http2 = require("http");
52387
52387
  var { Duplex } = require("stream");
52388
- var { createHash: createHash37 } = require("crypto");
52388
+ var { createHash: createHash38 } = require("crypto");
52389
52389
  var extension3 = require_extension();
52390
52390
  var PerMessageDeflate2 = require_permessage_deflate();
52391
52391
  var subprotocol2 = require_subprotocol();
@@ -52692,7 +52692,7 @@ var require_websocket_server = __commonJS({
52692
52692
  );
52693
52693
  }
52694
52694
  if (this._state > RUNNING) return abortHandshake(socket, 503);
52695
- const digest = createHash37("sha1").update(key + GUID).digest("base64");
52695
+ const digest = createHash38("sha1").update(key + GUID).digest("base64");
52696
52696
  const headers = [
52697
52697
  "HTTP/1.1 101 Switching Protocols",
52698
52698
  "Upgrade: websocket",
@@ -197867,41 +197867,6 @@ function stageConnectorWrapper(connector) {
197867
197867
  stagedBinDirs.set(cacheKey, binDir);
197868
197868
  return link;
197869
197869
  }
197870
- function clearLoginShellShadow(connector) {
197871
- const commandName = connector.commandName;
197872
- if (!commandName) return [];
197873
- const home2 = process.env["HOME"] ?? (0, import_node_os3.homedir)();
197874
- if (!home2) return [];
197875
- const moved = [];
197876
- for (const parts of LOGIN_SHELL_FRONT_DIRS) {
197877
- const dir = (0, import_node_path9.join)(home2, ...parts);
197878
- if (!(0, import_node_fs8.existsSync)(dir)) continue;
197879
- const target = (0, import_node_path9.join)(dir, commandName);
197880
- try {
197881
- (0, import_node_fs8.lstatSync)(target);
197882
- } catch {
197883
- continue;
197884
- }
197885
- if (isOasisWrapperPath(target)) continue;
197886
- const backup = (0, import_node_path9.join)(dir, `${commandName}${DISPLACED_SUFFIX}`);
197887
- const dest = (0, import_node_fs8.existsSync)(backup) || safeLstat(backup) ? `${backup}.${Date.now()}` : backup;
197888
- try {
197889
- (0, import_node_fs8.renameSync)(target, dest);
197890
- moved.push({ from: target, to: dest });
197891
- } catch {
197892
- continue;
197893
- }
197894
- }
197895
- return moved;
197896
- }
197897
- function safeLstat(p2) {
197898
- try {
197899
- (0, import_node_fs8.lstatSync)(p2);
197900
- return true;
197901
- } catch {
197902
- return false;
197903
- }
197904
- }
197905
197870
  function isStagedWrapperUsable(link) {
197906
197871
  try {
197907
197872
  (0, import_node_fs8.lstatSync)(link);
@@ -197910,7 +197875,7 @@ function isStagedWrapperUsable(link) {
197910
197875
  }
197911
197876
  return (0, import_node_fs8.existsSync)(link);
197912
197877
  }
197913
- var import_node_fs8, import_node_os3, import_node_path9, stagedBinDirs, LOGIN_SHELL_FRONT_DIRS, DISPLACED_SUFFIX;
197878
+ var import_node_fs8, import_node_os3, import_node_path9, stagedBinDirs;
197914
197879
  var init_stage = __esm({
197915
197880
  "../connectors/src/_base/stage.ts"() {
197916
197881
  "use strict";
@@ -197919,8 +197884,6 @@ var init_stage = __esm({
197919
197884
  import_node_path9 = require("node:path");
197920
197885
  init_wrapper_assets();
197921
197886
  stagedBinDirs = /* @__PURE__ */ new Map();
197922
- LOGIN_SHELL_FRONT_DIRS = [[".local", "bin"], ["bin"]];
197923
- DISPLACED_SUFFIX = ".oasis-displaced";
197924
197887
  }
197925
197888
  });
197926
197889
 
@@ -201952,19 +201915,12 @@ async function prepareConnectorsForJob(job, deps) {
201952
201915
  localWrappers.push(staged);
201953
201916
  status.wrapperReady = true;
201954
201917
  }
201955
- const moved = clearLoginShellShadow(connector);
201956
- for (const m2 of moved) {
201957
- log(
201958
- "[node-connectors]",
201959
- `${slug6}: \u632A\u5F00\u767B\u5F55 shell \u906E\u6321 ${m2.from} \u2192 ${m2.to}\uFF08$HOME/.local/bin \u4F1A\u88AB ~/.profile \u63D2\u5230 PATH \u6700\u524D\uFF0C\u538B\u8FC7\u6CE8\u5165\u7684 wrapper\uFF1B\u6539\u540D\u4E0D\u5220\u9664\uFF0Cwrapper \u89E3\u6790\u94FE\u6700\u540E\u4E00\u6863\u4ECD\u80FD\u6361\u56DE\u5B83\uFF09`
201960
- );
201961
- }
201962
201918
  const shadow = loginShellShadow(connector.commandName);
201963
201919
  if (shadow) {
201964
201920
  status.shadowedBy = shadow;
201965
201921
  log(
201966
201922
  "[node-connectors]",
201967
- `\u26A0 ${slug6}: creds + wrapper \u5DF2\u843D\u5728\u672C\u673A\uFF0C\u4F46 **${shadow} \u4ECD\u5728\u767B\u5F55 shell \u91CC\u6321\u7740 wrapper**\uFF0C\u800C\u4E14\u632A\u4E0D\u52A8\u5B83\u3002agent \u4E00\u65E6\u7528 \`bash -lc\` \u8C03 ${connector.commandName}\uFF0C\u8D70\u5230\u7684\u662F\u90A3\u4E2A\u5BBF\u4E3B\u526F\u672C\u3001\u914D\u7F6E\u76EE\u5F55\u53C8\u88AB\u9694\u79BB\u6210\u7A7A\u7684\uFF0C\u7ED3\u679C\u5C31\u662F\u300C\u672A\u914D\u7F6E\u300D\u3002`
201923
+ `\u26A0 ${slug6}: creds + wrapper \u5DF2\u843D\u5728\u672C\u673A\uFF0C\u4F46 **${shadow} \u4F1A\u5728\u767B\u5F55 shell \u91CC\u6321\u4F4F wrapper**\u2014\u2014Ubuntu \u7684 ~/.profile \u628A $HOME/.local/bin \u524D\u7F6E\u5230 PATH \u6700\u524D\u3002agent \u4E00\u65E6\u7528 \`bash -lc\` \u8C03 ${connector.commandName}\uFF0C\u8D70\u5230\u7684\u662F\u90A3\u4E2A\u5BBF\u4E3B\u526F\u672C\u3001\u914D\u7F6E\u76EE\u5F55\u53C8\u88AB\u9694\u79BB\u6210\u7A7A\u7684\uFF0C\u7ED3\u679C\u5C31\u662F\u300C\u672A\u914D\u7F6E\u300D\u3002`
201968
201924
  );
201969
201925
  } else {
201970
201926
  log("[node-connectors]", `${slug6}: creds + wrapper \u5DF2\u843D\u5728\u672C\u673A`);
@@ -205876,13 +205832,22 @@ async function startOasisServer(opts) {
205876
205832
  if (url.pathname === "/api/chat/attachments" && req.method === "POST" && opts.uploadChatAttachment) {
205877
205833
  try {
205878
205834
  const body2 = JSON.parse(rawBody);
205879
- if (typeof body2.contentBase64 !== "string" || !body2.contentBase64) throw new Error("\u7F3A\u5C11 contentBase64");
205880
- const MAX_BASE64_LEN = Math.ceil(CHAT_ATTACHMENT_MAX_BYTES * 4 / 3) + 4096;
205835
+ if (typeof body2.contentBase64 !== "string") throw new Error("\u7F3A\u5C11 contentBase64");
205836
+ const MAX_BASE64_LEN = 4 * Math.ceil(CHAT_ATTACHMENT_MAX_BYTES / 3);
205881
205837
  if (body2.contentBase64.length > MAX_BASE64_LEN) {
205882
205838
  res.writeHead(413, { "content-type": "application/json" });
205883
205839
  res.end(JSON.stringify({ error: { code: "ATTACHMENT_TOO_LARGE", message: `\u9644\u4EF6\u8D85\u8FC7 ${CHAT_ATTACHMENT_MAX_BYTES / 1024 / 1024}MB \u4E0A\u9650` } }));
205884
205840
  return;
205885
205841
  }
205842
+ if (body2.contentBase64.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(body2.contentBase64)) {
205843
+ throw new Error("\u9644\u4EF6\u7F16\u7801\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6");
205844
+ }
205845
+ if (Buffer.from(body2.contentBase64, "base64").byteLength > CHAT_ATTACHMENT_MAX_BYTES) {
205846
+ res.writeHead(413, { "content-type": "application/json" }).end(JSON.stringify({
205847
+ error: { code: "ATTACHMENT_TOO_LARGE", message: `\u9644\u4EF6\u8D85\u8FC7 ${CHAT_ATTACHMENT_MAX_BYTES / 1024 / 1024}MB \u4E0A\u9650` }
205848
+ }));
205849
+ return;
205850
+ }
205886
205851
  const out = await opts.uploadChatAttachment({
205887
205852
  contentBase64: body2.contentBase64,
205888
205853
  ...typeof body2.contentType === "string" ? { contentType: body2.contentType } : {},
@@ -211505,7 +211470,7 @@ var init_service4 = __esm({
211505
211470
  }
211506
211471
  };
211507
211472
  ProjectsService = class {
211508
- constructor(projects, artifacts, kernel, oplog, actorNames, blobs, actorDirectory, resolveActorContext, loadActorResolver) {
211473
+ constructor(projects, artifacts, kernel, oplog, actorNames, blobs, actorDirectory, resolveActorContext, loadActorResolver, listChatFiles) {
211509
211474
  this.projects = projects;
211510
211475
  this.artifacts = artifacts;
211511
211476
  this.kernel = kernel;
@@ -211515,6 +211480,7 @@ var init_service4 = __esm({
211515
211480
  this.actorDirectory = actorDirectory;
211516
211481
  this.resolveActorContext = resolveActorContext;
211517
211482
  this.loadActorResolver = loadActorResolver;
211483
+ this.listChatFiles = listChatFiles;
211518
211484
  }
211519
211485
  projectCreatedHandler;
211520
211486
  onProjectNameChanged;
@@ -212102,6 +212068,18 @@ var init_service4 = __esm({
212102
212068
  });
212103
212069
  }
212104
212070
  const files = await this.collectProjectFiles(projectId2);
212071
+ const existingFiles = /* @__PURE__ */ new Set([
212072
+ ...items.filter((item) => item.blobRef).map((item) => `${item.name}\0${item.blobRef}`),
212073
+ ...files.map((file) => `${file.name}\0${file.blobId}`)
212074
+ ]);
212075
+ if (this.listChatFiles && !isUncategorizedProjectId(projectId2)) {
212076
+ for (const file of await this.listChatFiles(projectId2)) {
212077
+ const key = `${file.name}\0${file.blobId}`;
212078
+ if (existingFiles.has(key)) continue;
212079
+ existingFiles.add(key);
212080
+ files.push(file);
212081
+ }
212082
+ }
212105
212083
  for (const file of files) {
212106
212084
  const path41 = typeof file.path === "string" && file.path.trim() ? file.path : void 0;
212107
212085
  if (path41) emitFolder(dirname24(path41), file.uploadedAt);
@@ -228074,6 +228052,245 @@ var init_collab = __esm({
228074
228052
  }
228075
228053
  });
228076
228054
 
228055
+ // ../server/src/domains/chat-sessions/files-view.ts
228056
+ function reasonFromWorkdirCode(code2) {
228057
+ switch (code2) {
228058
+ case "NODE_OFFLINE":
228059
+ return "NODE_OFFLINE";
228060
+ case "TIMEOUT":
228061
+ return "TIMEOUT";
228062
+ default:
228063
+ return "ERROR";
228064
+ }
228065
+ }
228066
+ function joinRel(dir, name) {
228067
+ return dir ? `${dir}/${name}` : name;
228068
+ }
228069
+ async function collectWorkdirFiles(bridge, loc, now = Date.now) {
228070
+ const deadline = now() + WORKDIR_WALK_BUDGET_MS;
228071
+ const items = [];
228072
+ let listCalls = 0;
228073
+ let truncated = false;
228074
+ const listDir = (path41) => {
228075
+ listCalls += 1;
228076
+ return bridge.list(loc.nodeId, {
228077
+ workdirKey: loc.workdirKey,
228078
+ runtimeKind: loc.runtimeKind,
228079
+ rtId: loc.rtId,
228080
+ path: path41
228081
+ });
228082
+ };
228083
+ const root = await listDir("");
228084
+ if (!root.ok) {
228085
+ if (root.code === "NOT_FOUND") return { ok: true, items: [], truncated: false };
228086
+ return { ok: false, reason: reasonFromWorkdirCode(root.code) };
228087
+ }
228088
+ let level = [{ path: "", outcome: root }];
228089
+ for (let depth = 0; depth <= WORKDIR_WALK_MAX_DEPTH; depth += 1) {
228090
+ const nextDirs = [];
228091
+ for (const { path: dir, outcome } of level) {
228092
+ if (!outcome.ok) {
228093
+ truncated = true;
228094
+ continue;
228095
+ }
228096
+ if (outcome.truncated) truncated = true;
228097
+ for (const entry of outcome.entries) {
228098
+ if (entry.type === "dir") {
228099
+ nextDirs.push(joinRel(dir, entry.name));
228100
+ continue;
228101
+ }
228102
+ if (items.length >= WORKDIR_WALK_MAX_ENTRIES) {
228103
+ truncated = true;
228104
+ continue;
228105
+ }
228106
+ const rel = joinRel(dir, entry.name);
228107
+ items.push({
228108
+ id: `workdir:${rel}`,
228109
+ name: entry.name,
228110
+ kind: "file",
228111
+ // 节点侧列目录只报 name/type/size/mtime,没有 MIME——诚实留 null,
228112
+ // 不拿后缀猜(红线:取不到就是取不到,别拿别的字段顶)。
228113
+ content_type: null,
228114
+ size: entry.size,
228115
+ updated_at: entry.mtime,
228116
+ source: "workdir",
228117
+ blob_ref: null,
228118
+ path: rel,
228119
+ message_id: null,
228120
+ // 工作区文件本期不开写回(brief §4①:要动 node↔server 协议帧,超预算)。
228121
+ // 这里是**按能力不渲染**的判据,不是置灰假钮。
228122
+ editable: false
228123
+ });
228124
+ }
228125
+ }
228126
+ if (depth === WORKDIR_WALK_MAX_DEPTH || nextDirs.length === 0) {
228127
+ if (nextDirs.length > 0) truncated = true;
228128
+ break;
228129
+ }
228130
+ const budget = WORKDIR_WALK_MAX_LIST_CALLS - listCalls;
228131
+ if (budget <= 0 || now() >= deadline) {
228132
+ truncated = true;
228133
+ break;
228134
+ }
228135
+ const take = nextDirs.slice(0, budget);
228136
+ if (take.length < nextDirs.length) truncated = true;
228137
+ const outcomes = await Promise.all(take.map((p2) => listDir(p2)));
228138
+ level = take.map((p2, i) => ({ path: p2, outcome: outcomes[i] }));
228139
+ }
228140
+ return { ok: true, items, truncated };
228141
+ }
228142
+ async function collectMessageFiles(messages, blobs) {
228143
+ const rows = [];
228144
+ for (const message of messages) {
228145
+ if (!Array.isArray(message.attachments)) continue;
228146
+ message.attachments.forEach((attachment, index2) => {
228147
+ if (!attachment || typeof attachment.name !== "string" || !attachment.name) return;
228148
+ const blobRef = typeof attachment.blobRef === "string" && attachment.blobRef ? attachment.blobRef : null;
228149
+ rows.push({
228150
+ item: {
228151
+ id: `msg:${message.id}:${index2}`,
228152
+ name: attachment.name,
228153
+ kind: "file",
228154
+ updated_at: attachment.updatedAt ?? message.createdAt,
228155
+ source: "message",
228156
+ blob_ref: blobRef,
228157
+ path: null,
228158
+ message_id: message.id,
228159
+ // 没有 blobRef 的是**历史纯文本附件**(契约注释:legacy text attachments may only
228160
+ // contain `name`)——没有可写回的载体,一律不给编辑入口。
228161
+ editable: blobRef !== null && isEditableFileName(attachment.name)
228162
+ },
228163
+ blobRef,
228164
+ declaredType: typeof attachment.contentType === "string" && attachment.contentType ? attachment.contentType : null
228165
+ });
228166
+ });
228167
+ }
228168
+ const metaCache = /* @__PURE__ */ new Map();
228169
+ const metaOf = (ref2) => {
228170
+ if (!blobs) return Promise.resolve(null);
228171
+ let hit = metaCache.get(ref2);
228172
+ if (!hit) {
228173
+ hit = blobs.meta(ref2).catch(() => null);
228174
+ metaCache.set(ref2, hit);
228175
+ }
228176
+ return hit;
228177
+ };
228178
+ return Promise.all(rows.map(async ({ item, blobRef, declaredType }) => {
228179
+ const meta = blobRef ? await metaOf(blobRef) : null;
228180
+ return {
228181
+ ...item,
228182
+ content_type: declaredType ?? meta?.contentType ?? null,
228183
+ size: meta?.size ?? null
228184
+ };
228185
+ }));
228186
+ }
228187
+ function mergeChatSessionFiles(messageItems, workdirItems, materializedCopies = /* @__PURE__ */ new Set()) {
228188
+ const out = [];
228189
+ const seenMessageKeys = /* @__PURE__ */ new Set();
228190
+ for (const item of [...messageItems].sort((a, b2) => b2.updated_at.localeCompare(a.updated_at))) {
228191
+ const key = `${item.name}\0${item.blob_ref ?? ""}`;
228192
+ if (seenMessageKeys.has(key)) continue;
228193
+ seenMessageKeys.add(key);
228194
+ out.push(item);
228195
+ }
228196
+ const seenWorkdirPaths = /* @__PURE__ */ new Set();
228197
+ for (const item of workdirItems) {
228198
+ if (item.path && materializedCopies.has(item.path)) continue;
228199
+ if (seenWorkdirPaths.has(item.id)) continue;
228200
+ seenWorkdirPaths.add(item.id);
228201
+ out.push(item);
228202
+ }
228203
+ out.sort((a, b2) => b2.updated_at.localeCompare(a.updated_at) || a.name.localeCompare(b2.name));
228204
+ return out;
228205
+ }
228206
+ async function findMaterializedAttachmentCopies(messageItems, workdirItems, read) {
228207
+ const copies = /* @__PURE__ */ new Set();
228208
+ const attachments = messageItems.filter((item) => item.blob_ref && /^[a-f0-9]{64}$/.test(item.blob_ref));
228209
+ let budget = CHAT_ATTACHMENT_MAX_BYTES;
228210
+ const deadline = Date.now() + WORKDIR_WALK_BUDGET_MS;
228211
+ let reads = 0;
228212
+ for (const file of workdirItems) {
228213
+ const rootFile = file.path === file.name;
228214
+ const inputFile = file.path?.startsWith("inputs/attachments/") && !file.path.slice("inputs/attachments/".length).includes("/");
228215
+ if (!file.path || !rootFile && !inputFile) continue;
228216
+ const candidates = attachments.filter((attachment) => {
228217
+ const safe = safeAttachmentName(attachment.name);
228218
+ const numbered = file.name.endsWith(`-${safe}`) && /^\d+$/.test(file.name.slice(0, -(safe.length + 1)));
228219
+ return (rootFile ? file.name === attachment.name : file.name === safe || numbered) && attachment.size !== null && attachment.size === file.size;
228220
+ });
228221
+ if (Date.now() >= deadline) break;
228222
+ if (!candidates.length || file.size === null || file.size > budget || reads >= 10) continue;
228223
+ reads += 1;
228224
+ budget -= file.size;
228225
+ let timer;
228226
+ try {
228227
+ const result = await Promise.race([
228228
+ read(file.path, file.size),
228229
+ new Promise((resolve10) => {
228230
+ timer = setTimeout(() => resolve10(null), Math.max(0, deadline - Date.now()));
228231
+ })
228232
+ ]);
228233
+ if (!result?.ok) continue;
228234
+ const bytes2 = Buffer.from(result.contentBase64, "base64");
228235
+ if (bytes2.length !== file.size) continue;
228236
+ const hash2 = (0, import_node_crypto51.createHash)("sha256").update(bytes2).digest("hex");
228237
+ if (candidates.some((attachment) => attachment.blob_ref === hash2)) copies.add(file.path);
228238
+ } catch {
228239
+ } finally {
228240
+ if (timer) clearTimeout(timer);
228241
+ }
228242
+ }
228243
+ return copies;
228244
+ }
228245
+ var import_node_crypto51, WORKDIR_WALK_MAX_DEPTH, WORKDIR_WALK_MAX_ENTRIES, WORKDIR_WALK_MAX_LIST_CALLS, WORKDIR_WALK_BUDGET_MS;
228246
+ var init_files_view = __esm({
228247
+ "../server/src/domains/chat-sessions/files-view.ts"() {
228248
+ "use strict";
228249
+ import_node_crypto51 = require("node:crypto");
228250
+ init_chat_attachment_files();
228251
+ init_src();
228252
+ WORKDIR_WALK_MAX_DEPTH = 3;
228253
+ WORKDIR_WALK_MAX_ENTRIES = 200;
228254
+ WORKDIR_WALK_MAX_LIST_CALLS = 20;
228255
+ WORKDIR_WALK_BUDGET_MS = 1e4;
228256
+ }
228257
+ });
228258
+
228259
+ // ../server/src/domains/projects/chat-files.ts
228260
+ async function collectProjectChatFiles(chat, projectId2, meta) {
228261
+ if (!chat.listAttachmentMessages) return [];
228262
+ const messages = await chat.listAttachmentMessages(projectId2);
228263
+ const sessions = new Map(await Promise.all([...new Set(messages.map((m2) => m2.sessionId))].map(async (id) => [id, await chat.getSession(id)])));
228264
+ const visible = messages.filter((m2) => {
228265
+ const session = sessions.get(m2.sessionId);
228266
+ return session?.projectId === projectId2 && session.visibility !== "internal" && !session.analyzedRunId;
228267
+ });
228268
+ const byMessage = new Map(visible.map((m2) => [m2.messageId, m2]));
228269
+ const rows = await collectMessageFiles(visible.map((m2) => ({ ...m2, id: m2.messageId })), {
228270
+ meta
228271
+ });
228272
+ return mergeChatSessionFiles(rows, []).filter((row) => row.blob_ref !== null).map((row) => {
228273
+ const message = byMessage.get(row.message_id);
228274
+ const session = sessions.get(message.sessionId);
228275
+ return {
228276
+ projectId: projectId2,
228277
+ fileId: `chat:${message.sessionId}:${row.id}`,
228278
+ name: row.name,
228279
+ blobId: row.blob_ref,
228280
+ contentType: row.content_type ?? void 0,
228281
+ size: row.size,
228282
+ uploadedBy: session.humanActorId,
228283
+ uploadedAt: row.updated_at
228284
+ };
228285
+ });
228286
+ }
228287
+ var init_chat_files2 = __esm({
228288
+ "../server/src/domains/projects/chat-files.ts"() {
228289
+ "use strict";
228290
+ init_files_view();
228291
+ }
228292
+ });
228293
+
228077
228294
  // ../server/src/domains/projects/index.ts
228078
228295
  function createProjectsDomain(opts) {
228079
228296
  const build = (companyId, deps) => {
@@ -228089,7 +228306,8 @@ function createProjectsDomain(opts) {
228089
228306
  opts.listMembers ? async () => buildResolver(
228090
228307
  deps?.actorDirectory ?? opts.actorDirectory,
228091
228308
  await memberNameResolver(opts.listMembers, companyId)
228092
- ) : void 0
228309
+ ) : void 0,
228310
+ opts.listChatFiles ? (projectId2) => opts.listChatFiles(companyId, projectId2) : void 0
228093
228311
  );
228094
228312
  if (opts.onProjectNameChangedFor) {
228095
228313
  const handler = opts.onProjectNameChangedFor(companyId);
@@ -228141,6 +228359,7 @@ var init_projects = __esm({
228141
228359
  init_routes5();
228142
228360
  init_service4();
228143
228361
  init_collab();
228362
+ init_chat_files2();
228144
228363
  init_routes5();
228145
228364
  init_service4();
228146
228365
  init_projection();
@@ -228156,11 +228375,11 @@ async function isEmployedElsewhere(store, companyId, accountId) {
228156
228375
  const memberships = await store.listMembershipsForAccount(accountId);
228157
228376
  return memberships.some((m2) => m2.companyId !== companyId);
228158
228377
  }
228159
- var import_node_crypto51, ROLES, INVITABLE_ROLES, INVITATION_TTL_MS, INVITE_LINK_TTL_MS, INVITE_LINK_TOKEN_BYTES, INVITE_LINK_ROLE, SLUG_RE, CompanyError, CompaniesService;
228378
+ var import_node_crypto52, ROLES, INVITABLE_ROLES, INVITATION_TTL_MS, INVITE_LINK_TTL_MS, INVITE_LINK_TOKEN_BYTES, INVITE_LINK_ROLE, SLUG_RE, CompanyError, CompaniesService;
228160
228379
  var init_service6 = __esm({
228161
228380
  "../server/src/domains/companies/service.ts"() {
228162
228381
  "use strict";
228163
- import_node_crypto51 = require("node:crypto");
228382
+ import_node_crypto52 = require("node:crypto");
228164
228383
  init_console_url();
228165
228384
  ROLES = ["owner", "admin", "member"];
228166
228385
  INVITABLE_ROLES = ["admin", "member"];
@@ -228252,7 +228471,7 @@ var init_service6 = __esm({
228252
228471
  const existing = await this.store.getAccountByEmail(normalized4);
228253
228472
  if (existing) return existing;
228254
228473
  const account = {
228255
- id: `actor:human:${(0, import_node_crypto51.randomUUID)()}`,
228474
+ id: `actor:human:${(0, import_node_crypto52.randomUUID)()}`,
228256
228475
  email: normalized4,
228257
228476
  name: name ?? normalized4,
228258
228477
  status: "active"
@@ -228461,7 +228680,7 @@ var init_service6 = __esm({
228461
228680
  }
228462
228681
  const nowMs = Date.parse(this.now());
228463
228682
  const invitation = {
228464
- id: `invitation:${(0, import_node_crypto51.randomUUID)()}`,
228683
+ id: `invitation:${(0, import_node_crypto52.randomUUID)()}`,
228465
228684
  companyId,
228466
228685
  email: mail,
228467
228686
  role,
@@ -228592,7 +228811,7 @@ var init_service6 = __esm({
228592
228811
  const nowMs = Date.parse(this.now());
228593
228812
  const link = {
228594
228813
  companyId,
228595
- token: (0, import_node_crypto51.randomBytes)(INVITE_LINK_TOKEN_BYTES).toString("base64url"),
228814
+ token: (0, import_node_crypto52.randomBytes)(INVITE_LINK_TOKEN_BYTES).toString("base64url"),
228596
228815
  role: INVITE_LINK_ROLE,
228597
228816
  createdAt: new Date(nowMs).toISOString(),
228598
228817
  expiresAt: new Date(nowMs + INVITE_LINK_TTL_MS).toISOString(),
@@ -228649,7 +228868,7 @@ var init_service6 = __esm({
228649
228868
  const reusable = existing.find((inv) => !this.isExpired(inv));
228650
228869
  if (reusable) return reusable;
228651
228870
  const invitation = {
228652
- id: `invitation:${(0, import_node_crypto51.randomUUID)()}`,
228871
+ id: `invitation:${(0, import_node_crypto52.randomUUID)()}`,
228653
228872
  companyId: link.companyId,
228654
228873
  email: mail,
228655
228874
  role: link.role,
@@ -228887,11 +229106,11 @@ var init_service6 = __esm({
228887
229106
  });
228888
229107
 
228889
229108
  // ../server/src/domains/companies/offboarding.ts
228890
- var import_node_crypto52, MemberOffboardingService;
229109
+ var import_node_crypto53, MemberOffboardingService;
228891
229110
  var init_offboarding = __esm({
228892
229111
  "../server/src/domains/companies/offboarding.ts"() {
228893
229112
  "use strict";
228894
- import_node_crypto52 = require("node:crypto");
229113
+ import_node_crypto53 = require("node:crypto");
228895
229114
  init_service6();
228896
229115
  MemberOffboardingService = class {
228897
229116
  store;
@@ -228963,7 +229182,7 @@ var init_offboarding = __esm({
228963
229182
  const { ownedAgents, inFlight } = await this.snapshot(companyId, accountId);
228964
229183
  const at = this.now();
228965
229184
  const started = await this.store.startMemberOffboarding({
228966
- operationId: `off:${(0, import_node_crypto52.randomUUID)()}`,
229185
+ operationId: `off:${(0, import_node_crypto53.randomUUID)()}`,
228967
229186
  companyId,
228968
229187
  accountId,
228969
229188
  initiatedBy,
@@ -229473,18 +229692,18 @@ var init_routes6 = __esm({
229473
229692
 
229474
229693
  // ../server/src/domains/companies/agent-credentials.ts
229475
229694
  function hashAgentToken(token, secret) {
229476
- return HASH_PREFIX + (0, import_node_crypto53.createHmac)("sha256", secret).update(`agent-token:${token}`).digest("base64url");
229695
+ return HASH_PREFIX + (0, import_node_crypto54.createHmac)("sha256", secret).update(`agent-token:${token}`).digest("base64url");
229477
229696
  }
229478
229697
  function safeEqual(a, b2) {
229479
229698
  const ba = Buffer.from(a);
229480
229699
  const bb = Buffer.from(b2);
229481
- return ba.length === bb.length && (0, import_node_crypto53.timingSafeEqual)(ba, bb);
229700
+ return ba.length === bb.length && (0, import_node_crypto54.timingSafeEqual)(ba, bb);
229482
229701
  }
229483
- var import_node_crypto53, HASH_PREFIX, TOKEN_PREFIX, AgentCredentialService;
229702
+ var import_node_crypto54, HASH_PREFIX, TOKEN_PREFIX, AgentCredentialService;
229484
229703
  var init_agent_credentials = __esm({
229485
229704
  "../server/src/domains/companies/agent-credentials.ts"() {
229486
229705
  "use strict";
229487
- import_node_crypto53 = require("node:crypto");
229706
+ import_node_crypto54 = require("node:crypto");
229488
229707
  init_service6();
229489
229708
  HASH_PREFIX = "ac1$";
229490
229709
  TOKEN_PREFIX = "oak_";
@@ -229509,7 +229728,7 @@ var init_agent_credentials = __esm({
229509
229728
  if (employee.status !== "active") {
229510
229729
  throw new CompanyError(409, "AGENT_LEFT", `\u6570\u5B57\u5458\u5DE5\u5DF2\u79BB\u5F00\uFF0C\u4E0D\u80FD\u7B7E\u53D1\u51ED\u8BC1\uFF1A${agentId}`);
229511
229730
  }
229512
- const token = `${TOKEN_PREFIX}${(0, import_node_crypto53.randomBytes)(32).toString("base64url")}`;
229731
+ const token = `${TOKEN_PREFIX}${(0, import_node_crypto54.randomBytes)(32).toString("base64url")}`;
229513
229732
  const credential = {
229514
229733
  tokenHash: hashAgentToken(token, this.secret),
229515
229734
  companyId,
@@ -229929,7 +230148,7 @@ function gatewayInstanceSlug(gatewayUrl) {
229929
230148
  }
229930
230149
  function connectInstanceName(gatewayUrl, token, companyId) {
229931
230150
  const scope = companyId?.trim();
229932
- const suffix = scope ? `c${(0, import_node_crypto54.createHash)("sha256").update(`${gatewayUrl}\0${scope}`).digest("hex").slice(0, 10)}` : token.replace(/[^a-z0-9]/gi, "").slice(-8).toLowerCase() || "enroll";
230151
+ const suffix = scope ? `c${(0, import_node_crypto55.createHash)("sha256").update(`${gatewayUrl}\0${scope}`).digest("hex").slice(0, 10)}` : token.replace(/[^a-z0-9]/gi, "").slice(-8).toLowerCase() || "enroll";
229933
230152
  const base = gatewayInstanceSlug(gatewayUrl);
229934
230153
  return base.slice(0, Math.max(1, 64 - suffix.length - 1)) + "-" + suffix;
229935
230154
  }
@@ -230258,12 +230477,12 @@ function buildNpxCmd(p2) {
230258
230477
  const prefix = daemonNpmPrefix();
230259
230478
  return `npm install -g --prefer-online --prefix ${prefix} ${DAEMON_NPM_PACKAGE}@latest && ${prefix}/bin/oasis daemon start --instance ${shellQuote(instanceName)} --server-ws ${shellQuote(p2.gatewayUrl)}${companyPart}${namePart} --pkg ${shellQuote(DAEMON_NPM_PACKAGE)} --upgrade --enroll-token ${shellQuote(p2.token)}`;
230260
230479
  }
230261
- var import_node_crypto54;
230480
+ var import_node_crypto55;
230262
230481
  var init_connect_script = __esm({
230263
230482
  "../server/src/domains/nodes/connect-script.ts"() {
230264
230483
  "use strict";
230265
230484
  init_src();
230266
- import_node_crypto54 = require("node:crypto");
230485
+ import_node_crypto55 = require("node:crypto");
230267
230486
  }
230268
230487
  });
230269
230488
 
@@ -230697,7 +230916,7 @@ function nodesDomain(deps) {
230697
230916
  }
230698
230917
  deps.enrollTokens.setIssuedNodeId(enrollToken, nodeId);
230699
230918
  } else {
230700
- nodeId = `node-${(0, import_node_crypto55.randomUUID)().slice(0, 8)}`;
230919
+ nodeId = `node-${(0, import_node_crypto56.randomUUID)().slice(0, 8)}`;
230701
230920
  deps.enrollTokens.setIssuedNodeId(enrollToken, nodeId);
230702
230921
  }
230703
230922
  const existingNode = await deps.nodeStore.getNode(nodeId);
@@ -230859,13 +231078,13 @@ function normalizeGatewayUrl(raw) {
230859
231078
  }
230860
231079
  }
230861
231080
  function newNodeId() {
230862
- return "node-" + (0, import_node_crypto55.randomUUID)().replace(/-/g, "").slice(0, 12);
231081
+ return "node-" + (0, import_node_crypto56.randomUUID)().replace(/-/g, "").slice(0, 12);
230863
231082
  }
230864
- var import_node_crypto55, import_node_fs15, import_node_url6, import_node_path21;
231083
+ var import_node_crypto56, import_node_fs15, import_node_url6, import_node_path21;
230865
231084
  var init_routes7 = __esm({
230866
231085
  "../server/src/domains/nodes/routes.ts"() {
230867
231086
  "use strict";
230868
- import_node_crypto55 = require("node:crypto");
231087
+ import_node_crypto56 = require("node:crypto");
230869
231088
  import_node_fs15 = require("node:fs");
230870
231089
  import_node_url6 = require("node:url");
230871
231090
  import_node_path21 = require("node:path");
@@ -231346,7 +231565,7 @@ function createBundle(root, target, input) {
231346
231565
  }
231347
231566
  }
231348
231567
  const bytes2 = fs25.statSync(absBundle).size;
231349
- const digest = (0, import_node_crypto56.createHash)("sha256").update(fs25.readFileSync(absBundle)).digest("hex");
231568
+ const digest = (0, import_node_crypto57.createHash)("sha256").update(fs25.readFileSync(absBundle)).digest("hex");
231350
231569
  const relBase = `inputs/git-bundles/${safeRepo}-${commit.slice(0, 12)}`;
231351
231570
  return {
231352
231571
  absoluteBundlePath: absBundle,
@@ -231442,12 +231661,12 @@ function classifyGitError(fallback, err, where) {
231442
231661
  function oneLine(msg) {
231443
231662
  return msg.split("\n").map((s2) => s2.trim()).filter(Boolean).slice(0, 3).join(" ");
231444
231663
  }
231445
- var import_node_child_process17, import_node_crypto56, fs25, os7, path25, GitReadonlyBundleError, HEX40, FETCH_TIMEOUT_MS2;
231664
+ var import_node_child_process17, import_node_crypto57, fs25, os7, path25, GitReadonlyBundleError, HEX40, FETCH_TIMEOUT_MS2;
231446
231665
  var init_readonly_bundle = __esm({
231447
231666
  "../server/src/git/readonly-bundle.ts"() {
231448
231667
  "use strict";
231449
231668
  import_node_child_process17 = require("node:child_process");
231450
- import_node_crypto56 = require("node:crypto");
231669
+ import_node_crypto57 = require("node:crypto");
231451
231670
  fs25 = __toESM(require("node:fs"), 1);
231452
231671
  os7 = __toESM(require("node:os"), 1);
231453
231672
  path25 = __toESM(require("node:path"), 1);
@@ -231467,7 +231686,7 @@ var init_readonly_bundle = __esm({
231467
231686
 
231468
231687
  // ../server/src/domains/collab/create-seeded-workorder.ts
231469
231688
  function makeSeededWorkorderCreator(deps) {
231470
- const genWorkspace = deps.genWorkspace ?? (() => `ws:wo-${(0, import_node_crypto57.randomUUID)().slice(0, 8)}`);
231689
+ const genWorkspace = deps.genWorkspace ?? (() => `ws:wo-${(0, import_node_crypto58.randomUUID)().slice(0, 8)}`);
231471
231690
  return async (input) => {
231472
231691
  const company = input.companyId && deps.resolveCompany ? await deps.resolveCompany(input.companyId) : void 0;
231473
231692
  const kernel = company?.kernel ?? deps.kernel;
@@ -231560,7 +231779,7 @@ function makeSeededWorkorderCreator(deps) {
231560
231779
  };
231561
231780
  }
231562
231781
  function workspaceForKey(key) {
231563
- return `ws:wo-${(0, import_node_crypto57.createHash)("sha256").update(key).digest("hex").slice(0, 8)}`;
231782
+ return `ws:wo-${(0, import_node_crypto58.createHash)("sha256").update(key).digest("hex").slice(0, 8)}`;
231564
231783
  }
231565
231784
  function existingWorkorder(kernel, workspace) {
231566
231785
  const arts = [...kernel.model.artifacts.values()].filter((a) => a.workspace === workspace);
@@ -231573,11 +231792,11 @@ function existingWorkorder(kernel, workspace) {
231573
231792
  spawned: arts.map((a) => ({ id: a.id, type: a.type, owner: a.owner }))
231574
231793
  };
231575
231794
  }
231576
- var import_node_crypto57, enc2;
231795
+ var import_node_crypto58, enc2;
231577
231796
  var init_create_seeded_workorder = __esm({
231578
231797
  "../server/src/domains/collab/create-seeded-workorder.ts"() {
231579
231798
  "use strict";
231580
- import_node_crypto57 = require("node:crypto");
231799
+ import_node_crypto58 = require("node:crypto");
231581
231800
  init_uncategorized_project();
231582
231801
  init_planner();
231583
231802
  enc2 = (s2) => new TextEncoder().encode(s2);
@@ -232974,12 +233193,12 @@ function stateFromAttempt(attempt, handoff, checkpoint, now, stalledAfterMs, ope
232974
233193
  if (attempt.status === "no-output") return handoff?.unresolvedIssues.length ? "blocked" : "no_change";
232975
233194
  return "failed";
232976
233195
  }
232977
- var import_node_crypto58, BLOCKING_STATES, HANDOFF_OUTCOMES2, RESUME_EXTERNAL_EFFECT_LIMIT, RESUME_SNAPSHOT_PREFIX, RESUME_SNAPSHOT_SUFFIX, ExecutionContinuityService;
233196
+ var import_node_crypto59, BLOCKING_STATES, HANDOFF_OUTCOMES2, RESUME_EXTERNAL_EFFECT_LIMIT, RESUME_SNAPSHOT_PREFIX, RESUME_SNAPSHOT_SUFFIX, ExecutionContinuityService;
232978
233197
  var init_service8 = __esm({
232979
233198
  "../server/src/domains/execution-continuity/service.ts"() {
232980
233199
  "use strict";
232981
233200
  init_src();
232982
- import_node_crypto58 = require("node:crypto");
233201
+ import_node_crypto59 = require("node:crypto");
232983
233202
  init_src5();
232984
233203
  BLOCKING_STATES = /* @__PURE__ */ new Set(["stalled", "failed", "blocked"]);
232985
233204
  HANDOFF_OUTCOMES2 = /* @__PURE__ */ new Set(["succeeded", "no-output", "failed", "cancelled", "timeout", "orphaned"]);
@@ -233210,7 +233429,7 @@ var init_service8 = __esm({
233210
233429
  if (typeof expectedHash !== "string" || !this.readBundleFile) return null;
233211
233430
  const injectedResume = this.readBundleFile(attempt.id, "execution/RESUME.md");
233212
233431
  if (!injectedResume) return null;
233213
- const actualHash = (0, import_node_crypto58.createHash)("sha256").update(injectedResume).digest("hex");
233432
+ const actualHash = (0, import_node_crypto59.createHash)("sha256").update(injectedResume).digest("hex");
233214
233433
  if (actualHash !== expectedHash) return null;
233215
233434
  const recoverySnapshot = parseResumePackSnapshot(injectedResume);
233216
233435
  if (!recoverySnapshot || recoverySnapshot.scenario !== "redispatch" || !recoverySnapshot.previousAttempt || recoverySnapshot.node.nodeId !== attempt.nodeId || recoverySnapshot.jobKey !== attempt.jobKey || recoverySnapshot.part !== attempt.part) return null;
@@ -233801,171 +234020,6 @@ var init_execution_continuity2 = __esm({
233801
234020
  }
233802
234021
  });
233803
234022
 
233804
- // ../server/src/domains/chat-sessions/files-view.ts
233805
- function reasonFromWorkdirCode(code2) {
233806
- switch (code2) {
233807
- case "NODE_OFFLINE":
233808
- return "NODE_OFFLINE";
233809
- case "TIMEOUT":
233810
- return "TIMEOUT";
233811
- default:
233812
- return "ERROR";
233813
- }
233814
- }
233815
- function joinRel(dir, name) {
233816
- return dir ? `${dir}/${name}` : name;
233817
- }
233818
- async function collectWorkdirFiles(bridge, loc, now = Date.now) {
233819
- const deadline = now() + WORKDIR_WALK_BUDGET_MS;
233820
- const items = [];
233821
- let listCalls = 0;
233822
- let truncated = false;
233823
- const listDir = (path41) => {
233824
- listCalls += 1;
233825
- return bridge.list(loc.nodeId, {
233826
- workdirKey: loc.workdirKey,
233827
- runtimeKind: loc.runtimeKind,
233828
- rtId: loc.rtId,
233829
- path: path41
233830
- });
233831
- };
233832
- const root = await listDir("");
233833
- if (!root.ok) {
233834
- if (root.code === "NOT_FOUND") return { ok: true, items: [], truncated: false };
233835
- return { ok: false, reason: reasonFromWorkdirCode(root.code) };
233836
- }
233837
- let level = [{ path: "", outcome: root }];
233838
- for (let depth = 0; depth <= WORKDIR_WALK_MAX_DEPTH; depth += 1) {
233839
- const nextDirs = [];
233840
- for (const { path: dir, outcome } of level) {
233841
- if (!outcome.ok) {
233842
- truncated = true;
233843
- continue;
233844
- }
233845
- if (outcome.truncated) truncated = true;
233846
- for (const entry of outcome.entries) {
233847
- if (entry.type === "dir") {
233848
- nextDirs.push(joinRel(dir, entry.name));
233849
- continue;
233850
- }
233851
- if (items.length >= WORKDIR_WALK_MAX_ENTRIES) {
233852
- truncated = true;
233853
- continue;
233854
- }
233855
- const rel = joinRel(dir, entry.name);
233856
- items.push({
233857
- id: `workdir:${rel}`,
233858
- name: entry.name,
233859
- kind: "file",
233860
- // 节点侧列目录只报 name/type/size/mtime,没有 MIME——诚实留 null,
233861
- // 不拿后缀猜(红线:取不到就是取不到,别拿别的字段顶)。
233862
- content_type: null,
233863
- size: entry.size,
233864
- updated_at: entry.mtime,
233865
- source: "workdir",
233866
- blob_ref: null,
233867
- path: rel,
233868
- message_id: null,
233869
- // 工作区文件本期不开写回(brief §4①:要动 node↔server 协议帧,超预算)。
233870
- // 这里是**按能力不渲染**的判据,不是置灰假钮。
233871
- editable: false
233872
- });
233873
- }
233874
- }
233875
- if (depth === WORKDIR_WALK_MAX_DEPTH || nextDirs.length === 0) {
233876
- if (nextDirs.length > 0) truncated = true;
233877
- break;
233878
- }
233879
- const budget = WORKDIR_WALK_MAX_LIST_CALLS - listCalls;
233880
- if (budget <= 0 || now() >= deadline) {
233881
- truncated = true;
233882
- break;
233883
- }
233884
- const take = nextDirs.slice(0, budget);
233885
- if (take.length < nextDirs.length) truncated = true;
233886
- const outcomes = await Promise.all(take.map((p2) => listDir(p2)));
233887
- level = take.map((p2, i) => ({ path: p2, outcome: outcomes[i] }));
233888
- }
233889
- return { ok: true, items, truncated };
233890
- }
233891
- async function collectMessageFiles(messages, blobs) {
233892
- const rows = [];
233893
- for (const message of messages) {
233894
- if (!Array.isArray(message.attachments)) continue;
233895
- message.attachments.forEach((attachment, index2) => {
233896
- if (!attachment || typeof attachment.name !== "string" || !attachment.name) return;
233897
- const blobRef = typeof attachment.blobRef === "string" && attachment.blobRef ? attachment.blobRef : null;
233898
- rows.push({
233899
- item: {
233900
- id: `msg:${message.id}:${index2}`,
233901
- name: attachment.name,
233902
- kind: "file",
233903
- updated_at: attachment.updatedAt ?? message.createdAt,
233904
- source: "message",
233905
- blob_ref: blobRef,
233906
- path: null,
233907
- message_id: message.id,
233908
- // 没有 blobRef 的是**历史纯文本附件**(契约注释:legacy text attachments may only
233909
- // contain `name`)——没有可写回的载体,一律不给编辑入口。
233910
- editable: blobRef !== null && isEditableFileName(attachment.name)
233911
- },
233912
- blobRef,
233913
- declaredType: typeof attachment.contentType === "string" && attachment.contentType ? attachment.contentType : null
233914
- });
233915
- });
233916
- }
233917
- const metaCache = /* @__PURE__ */ new Map();
233918
- const metaOf = (ref2) => {
233919
- if (!blobs) return Promise.resolve(null);
233920
- let hit = metaCache.get(ref2);
233921
- if (!hit) {
233922
- hit = blobs.meta(ref2).catch(() => null);
233923
- metaCache.set(ref2, hit);
233924
- }
233925
- return hit;
233926
- };
233927
- return Promise.all(rows.map(async ({ item, blobRef, declaredType }) => {
233928
- const meta = blobRef ? await metaOf(blobRef) : null;
233929
- return {
233930
- ...item,
233931
- content_type: declaredType ?? meta?.contentType ?? null,
233932
- size: meta?.size ?? null
233933
- };
233934
- }));
233935
- }
233936
- function mergeChatSessionFiles(messageItems, workdirItems) {
233937
- const out = [];
233938
- const seenMessageKeys = /* @__PURE__ */ new Set();
233939
- const messageNames = /* @__PURE__ */ new Set();
233940
- for (const item of messageItems) {
233941
- const key = `${item.name}\0${item.blob_ref ?? ""}`;
233942
- if (seenMessageKeys.has(key)) continue;
233943
- seenMessageKeys.add(key);
233944
- messageNames.add(item.name);
233945
- out.push(item);
233946
- }
233947
- const seenWorkdirPaths = /* @__PURE__ */ new Set();
233948
- for (const item of workdirItems) {
233949
- if (item.path === item.name && messageNames.has(item.name)) continue;
233950
- if (seenWorkdirPaths.has(item.id)) continue;
233951
- seenWorkdirPaths.add(item.id);
233952
- out.push(item);
233953
- }
233954
- out.sort((a, b2) => b2.updated_at.localeCompare(a.updated_at) || a.name.localeCompare(b2.name));
233955
- return out;
233956
- }
233957
- var WORKDIR_WALK_MAX_DEPTH, WORKDIR_WALK_MAX_ENTRIES, WORKDIR_WALK_MAX_LIST_CALLS, WORKDIR_WALK_BUDGET_MS;
233958
- var init_files_view = __esm({
233959
- "../server/src/domains/chat-sessions/files-view.ts"() {
233960
- "use strict";
233961
- init_src();
233962
- WORKDIR_WALK_MAX_DEPTH = 3;
233963
- WORKDIR_WALK_MAX_ENTRIES = 200;
233964
- WORKDIR_WALK_MAX_LIST_CALLS = 20;
233965
- WORKDIR_WALK_BUDGET_MS = 1e4;
233966
- }
233967
- });
233968
-
233969
234023
  // ../server/src/domains/collab/gap-thread.ts
233970
234024
  function gapThreadSessionId(executorActorId) {
233971
234025
  return `${GAP_THREAD_SESSION_PREFIX}${executorActorId}`;
@@ -234470,7 +234524,7 @@ function createChatSessionsDomain(opts) {
234470
234524
  if (!text5.trim()) throw new ApiError(400, "BAD_REQUEST", "text required");
234471
234525
  const now = Date.now();
234472
234526
  sweepDrafts(now);
234473
- const id = `cd_${(0, import_node_crypto59.randomUUID)()}`;
234527
+ const id = `cd_${(0, import_node_crypto60.randomUUID)()}`;
234474
234528
  drafts.set(id, { text: text5, actor: req.auth.actor, expiresAt: now + DRAFT_TTL_MS });
234475
234529
  return { status: 201, body: { id, expiresInMs: DRAFT_TTL_MS } };
234476
234530
  });
@@ -234522,7 +234576,7 @@ function createChatSessionsDomain(opts) {
234522
234576
  const runtimeId = await currentRuntimeId(body2.aiActorId) ?? "unknown";
234523
234577
  const now = (/* @__PURE__ */ new Date()).toISOString();
234524
234578
  const session = {
234525
- id: (0, import_node_crypto59.randomUUID)(),
234579
+ id: (0, import_node_crypto60.randomUUID)(),
234526
234580
  humanActorId: req.auth.actor,
234527
234581
  // 注:这里**刻意不写 companyId**。新会话要不要带公司归属,按 ws:wo-6d588f8e 的 ADR
234528
234582
  // (每公司 schema、最终移除表内 company 列)统一定,不在本节点自行发明。
@@ -234628,7 +234682,7 @@ function createChatSessionsDomain(opts) {
234628
234682
  if (body2.role !== "user" && body2.role !== "assistant") throw new ApiError(400, "BAD_REQUEST", "role must be user or assistant");
234629
234683
  const role = body2.role;
234630
234684
  const msg = await store2.appendMessage({
234631
- id: (0, import_node_crypto59.randomUUID)(),
234685
+ id: (0, import_node_crypto60.randomUUID)(),
234632
234686
  sessionId: req.params.id,
234633
234687
  role,
234634
234688
  content: role === "user" ? stripInjectedChatContext(body2.content) : body2.content,
@@ -234669,7 +234723,7 @@ function createChatSessionsDomain(opts) {
234669
234723
  const known = key ? cur.find((x2) => x2.clientKey === key) : void 0;
234670
234724
  if (!known && cur.length >= QUEUE_MAX) throw new ApiError(409, "QUEUE_FULL", `\u961F\u5217\u5DF2\u6EE1\uFF08\u4E0A\u9650 ${QUEUE_MAX} \u6761\uFF09`);
234671
234725
  const item = await store.enqueuePendingMessage({
234672
- id: (0, import_node_crypto59.randomUUID)(),
234726
+ id: (0, import_node_crypto60.randomUUID)(),
234673
234727
  chatSessionId: sid,
234674
234728
  text: text5,
234675
234729
  ...attachments.length ? { attachments } : {},
@@ -235024,6 +235078,7 @@ function createChatSessionsDomain(opts) {
235024
235078
  const blobAccess = opts.resolveBlobs ? await opts.resolveBlobs(req.auth?.companyId) : opts.blobs;
235025
235079
  const messageItems = await collectMessageFiles(attachmentRows, blobAccess);
235026
235080
  let workdirItems = [];
235081
+ let materializedCopies = /* @__PURE__ */ new Set();
235027
235082
  let workdirAvailable = false;
235028
235083
  let workdirTruncated = false;
235029
235084
  let workdirReason = "NOT_ENABLED";
@@ -235037,13 +235092,18 @@ function createChatSessionsDomain(opts) {
235037
235092
  if (outcome.ok) {
235038
235093
  workdirAvailable = true;
235039
235094
  workdirItems = outcome.items;
235095
+ materializedCopies = await findMaterializedAttachmentCopies(
235096
+ messageItems,
235097
+ workdirItems,
235098
+ (path41, maxBytes) => bridge.read(located.loc.nodeId, { ...located.loc, path: path41 }, maxBytes)
235099
+ );
235040
235100
  workdirTruncated = outcome.truncated;
235041
235101
  } else {
235042
235102
  workdirReason = outcome.reason;
235043
235103
  }
235044
235104
  }
235045
235105
  }
235046
- const items = mergeChatSessionFiles(messageItems, workdirItems);
235106
+ const items = mergeChatSessionFiles(messageItems, workdirItems, materializedCopies);
235047
235107
  const body2 = {
235048
235108
  total: items.length,
235049
235109
  items,
@@ -235112,11 +235172,11 @@ function createChatSessionsDomain(opts) {
235112
235172
  });
235113
235173
  };
235114
235174
  }
235115
- var import_node_crypto59, DEFAULT_SNAPSHOT_ITEMS, MAX_SNAPSHOT_ITEMS, WORKDIR_READ_MAX_BYTES;
235175
+ var import_node_crypto60, DEFAULT_SNAPSHOT_ITEMS, MAX_SNAPSHOT_ITEMS, WORKDIR_READ_MAX_BYTES;
235116
235176
  var init_chat_sessions = __esm({
235117
235177
  "../server/src/domains/chat-sessions/index.ts"() {
235118
235178
  "use strict";
235119
- import_node_crypto59 = require("node:crypto");
235179
+ import_node_crypto60 = require("node:crypto");
235120
235180
  init_src();
235121
235181
  init_chat_session();
235122
235182
  init_files_view();
@@ -236520,7 +236580,7 @@ function busyError(chatSessionId, blockedBy) {
236520
236580
  return `\u76EE\u6807\u4F1A\u8BDD ${chatSessionId} \u6B63\u6709\u4E00\u8F6E\u5728\u8DD1${blockedBy ? `\uFF08${blockedBy}\uFF09` : ""}\u2014\u2014\u672C\u6B21\u89E6\u53D1\u5DF2\u4E22\u5F03\uFF0C\u4E0D\u6392\u961F\u3001\u4E0D\u8865\u8DD1`;
236521
236581
  }
236522
236582
  function genWebhookToken() {
236523
- return `owt_${(0, import_node_crypto60.randomBytes)(32).toString("base64url")}`;
236583
+ return `owt_${(0, import_node_crypto61.randomBytes)(32).toString("base64url")}`;
236524
236584
  }
236525
236585
  function validateTitleTemplate(tpl) {
236526
236586
  const residue = tpl.replace(DATE_TOKEN, "");
@@ -236576,11 +236636,11 @@ function appendSourceNote(brief, automation, source, atIso) {
236576
236636
  ---
236577
236637
  \u672C\u5DE5\u5355\u7531\u81EA\u52A8\u5316\u300C${automation.name}\u300D\u4E8E ${atIso} \u89E6\u53D1\uFF08\u6765\u6E90\uFF1A${source}\uFF09\u3002\u5F00\u5DE5\u540E\u8BF7\u628A\u5DE5\u5355\u6807\u9898\u6539\u6210\u51C6\u786E\u53CD\u6620\u5B9E\u9645\u5DE5\u4F5C\u7684\u63CF\u8FF0\u3002`;
236578
236638
  }
236579
- var import_node_crypto60, DATE_TOKEN, AutomationsService, EVENT_RETRY_BASE_MS, EVENT_RETRY_MAX_MS, EVENT_RETRY_MAX_ATTEMPTS, eventAttempts, eventLastAttemptAt, eventLastError, CHAT_REPLY_MAX;
236639
+ var import_node_crypto61, DATE_TOKEN, AutomationsService, EVENT_RETRY_BASE_MS, EVENT_RETRY_MAX_MS, EVENT_RETRY_MAX_ATTEMPTS, eventAttempts, eventLastAttemptAt, eventLastError, CHAT_REPLY_MAX;
236580
236640
  var init_service9 = __esm({
236581
236641
  "../server/src/domains/automations/service.ts"() {
236582
236642
  "use strict";
236583
- import_node_crypto60 = require("node:crypto");
236643
+ import_node_crypto61 = require("node:crypto");
236584
236644
  init_src();
236585
236645
  init_registry3();
236586
236646
  init_attribution();
@@ -237394,11 +237454,11 @@ function verifySignature(rawBody, headers, secret) {
237394
237454
  if (!secret) return "not_required";
237395
237455
  const given = header1(headers, "x-hub-signature-256");
237396
237456
  if (!given) return "missing";
237397
- const expected = `sha256=${(0, import_node_crypto61.createHmac)("sha256", secret).update(rawBody).digest("hex")}`;
237457
+ const expected = `sha256=${(0, import_node_crypto62.createHmac)("sha256", secret).update(rawBody).digest("hex")}`;
237398
237458
  const a = Buffer.from(given);
237399
237459
  const b2 = Buffer.from(expected);
237400
237460
  if (a.length !== b2.length) return "invalid";
237401
- return (0, import_node_crypto61.timingSafeEqual)(a, b2) ? "valid" : "invalid";
237461
+ return (0, import_node_crypto62.timingSafeEqual)(a, b2) ? "valid" : "invalid";
237402
237462
  }
237403
237463
  function eventAllowed(filters, envelope) {
237404
237464
  if (!filters || filters.length === 0) return true;
@@ -237428,11 +237488,11 @@ function splitEvent(envelope) {
237428
237488
  }
237429
237489
  return { eventName, actionCandidates: candidates };
237430
237490
  }
237431
- var import_node_crypto61, MAX_BODY_BYTES, AutomationWebhookService, header1, PROVIDER_PREFIXES;
237491
+ var import_node_crypto62, MAX_BODY_BYTES, AutomationWebhookService, header1, PROVIDER_PREFIXES;
237432
237492
  var init_webhook = __esm({
237433
237493
  "../server/src/domains/automations/webhook.ts"() {
237434
237494
  "use strict";
237435
- import_node_crypto61 = require("node:crypto");
237495
+ import_node_crypto62 = require("node:crypto");
237436
237496
  MAX_BODY_BYTES = 256 * 1024;
237437
237497
  AutomationWebhookService = class {
237438
237498
  store;
@@ -238588,7 +238648,7 @@ function playbooksDomain(opts) {
238588
238648
  opts.overrides.set(companyOf(req), ref2, nodeKey, nextOverride);
238589
238649
  try {
238590
238650
  await opts.audit?.({
238591
- id: `reg_${(0, import_node_crypto62.randomUUID)()}`,
238651
+ id: `reg_${(0, import_node_crypto63.randomUUID)()}`,
238592
238652
  actor: req.auth.actor,
238593
238653
  kind: "registry_change",
238594
238654
  target: `playbook:${ref2}#${nodeKey}`,
@@ -238605,11 +238665,11 @@ function playbooksDomain(opts) {
238605
238665
  });
238606
238666
  };
238607
238667
  }
238608
- var import_node_crypto62;
238668
+ var import_node_crypto63;
238609
238669
  var init_routes12 = __esm({
238610
238670
  "../server/src/domains/playbooks/routes.ts"() {
238611
238671
  "use strict";
238612
- import_node_crypto62 = require("node:crypto");
238672
+ import_node_crypto63 = require("node:crypto");
238613
238673
  init_router();
238614
238674
  init_registry3();
238615
238675
  init_planner();
@@ -238723,17 +238783,17 @@ function completionFingerprint(workspace, members) {
238723
238783
  workspace,
238724
238784
  members: [...members].sort((a, b2) => a.artifactId < b2.artifactId ? -1 : a.artifactId > b2.artifactId ? 1 : 0).map((m2) => ({ artifactId: m2.artifactId, currentRevisionId: m2.currentRevisionId ?? null }))
238725
238785
  });
238726
- return (0, import_node_crypto63.createHash)("sha256").update(canonical).digest("hex");
238786
+ return (0, import_node_crypto64.createHash)("sha256").update(canonical).digest("hex");
238727
238787
  }
238728
238788
  function eventConsumptionKey(args) {
238729
238789
  const raw = `project-event:${EVENT_KEY_VERSION}:${args.triggerId}:${args.event}:${args.workspace}:${args.fingerprint}`;
238730
- return raw.length <= 200 ? raw : `project-event:${EVENT_KEY_VERSION}:sha256:${(0, import_node_crypto63.createHash)("sha256").update(raw).digest("hex")}`;
238790
+ return raw.length <= 200 ? raw : `project-event:${EVENT_KEY_VERSION}:sha256:${(0, import_node_crypto64.createHash)("sha256").update(raw).digest("hex")}`;
238731
238791
  }
238732
- var import_node_crypto63, EVENT_KEY_VERSION, EMPTY_METRICS, AUTOMATION_EVENT_HANDLERS, ProjectEventPoller;
238792
+ var import_node_crypto64, EVENT_KEY_VERSION, EMPTY_METRICS, AUTOMATION_EVENT_HANDLERS, ProjectEventPoller;
238733
238793
  var init_project_event_poller = __esm({
238734
238794
  "../server/src/automations/project-event-poller.ts"() {
238735
238795
  "use strict";
238736
- import_node_crypto63 = require("node:crypto");
238796
+ import_node_crypto64 = require("node:crypto");
238737
238797
  EVENT_KEY_VERSION = "v1";
238738
238798
  EMPTY_METRICS = () => ({
238739
238799
  scanDurationMs: 0,
@@ -238941,7 +239001,7 @@ function routeToSession(hub, nodeId, dispatchId, msg) {
238941
239001
  function remoteAppendInput(hub, nodeId, dispatchId, entry, input, timeoutMs) {
238942
239002
  const unknownIfInterrupting = input.interrupt ? { interrupt: "unknown" } : {};
238943
239003
  if (entry.exited) return Promise.resolve({ accepted: false, reason: "session-closing", ...unknownIfInterrupting });
238944
- const requestId = (0, import_node_crypto64.randomUUID)();
239004
+ const requestId = (0, import_node_crypto65.randomUUID)();
238945
239005
  const sent = routeToSession(hub, nodeId, dispatchId, { type: "append_input", dispatchId, input, requestId });
238946
239006
  if (!sent) return Promise.resolve({ accepted: false, reason: "session-closing", ...unknownIfInterrupting });
238947
239007
  return new Promise((resolve10) => {
@@ -238954,11 +239014,11 @@ function remoteAppendInput(hub, nodeId, dispatchId, entry, input, timeoutMs) {
238954
239014
  entry.appendWaiters.push({ requestId, resolve: resolve10, timer });
238955
239015
  });
238956
239016
  }
238957
- var import_node_crypto64, STASH_TTL_MS, STASH_MAX_FRAMES_PER_ID, STASH_MAX_IDS, DaemonHubAdapter, BindingRouterAdapter, WorkdirBridge;
239017
+ var import_node_crypto65, STASH_TTL_MS, STASH_MAX_FRAMES_PER_ID, STASH_MAX_IDS, DaemonHubAdapter, BindingRouterAdapter, WorkdirBridge;
238958
239018
  var init_daemon_adapter = __esm({
238959
239019
  "../server/src/daemon-adapter.ts"() {
238960
239020
  "use strict";
238961
- import_node_crypto64 = require("node:crypto");
239021
+ import_node_crypto65 = require("node:crypto");
238962
239022
  init_src();
238963
239023
  STASH_TTL_MS = 5 * 6e4;
238964
239024
  STASH_MAX_FRAMES_PER_ID = 500;
@@ -239308,7 +239368,7 @@ var init_daemon_adapter = __esm({
239308
239368
  async spawn(job) {
239309
239369
  const nodeId = job.binding?.nodeId;
239310
239370
  if (!nodeId) throw new Error("DaemonHubAdapter \u9700\u8981 job.binding.nodeId\uFF08\u8DEF\u7531\u9519\u8BEF\uFF09");
239311
- const dispatchId = job.dispatchId ?? `dispatch:${(0, import_node_crypto64.randomUUID)()}`;
239371
+ const dispatchId = job.dispatchId ?? `dispatch:${(0, import_node_crypto65.randomUUID)()}`;
239312
239372
  if (job.dispatchId && this.pending.has(dispatchId)) {
239313
239373
  return this.recover(dispatchId, nodeId, job.binding?.runtimeKind, job.actor);
239314
239374
  }
@@ -239522,7 +239582,7 @@ var init_daemon_adapter = __esm({
239522
239582
  }));
239523
239583
  }
239524
239584
  request(nodeId, buildFrame) {
239525
- const requestId = (0, import_node_crypto64.randomUUID)();
239585
+ const requestId = (0, import_node_crypto65.randomUUID)();
239526
239586
  const sent = this.hub.dispatch(nodeId, buildFrame(requestId));
239527
239587
  if (!sent) return Promise.resolve({ ok: false, code: "NODE_OFFLINE" });
239528
239588
  return new Promise((resolve10) => {
@@ -239630,13 +239690,13 @@ function classifyPage(page, lastPushedHash, serviceAccount) {
239630
239690
  if (sha(body2) === lastPushedHash) return { kind: "echo" };
239631
239691
  return { kind: "human-edit", content: body2, updatedBy: page.updatedBy };
239632
239692
  }
239633
- var import_node_crypto65, sha, enc3, dec, MirrorEngine, MapMirrorIdentities;
239693
+ var import_node_crypto66, sha, enc3, dec, MirrorEngine, MapMirrorIdentities;
239634
239694
  var init_engine = __esm({
239635
239695
  "../server/src/mirror/engine.ts"() {
239636
239696
  "use strict";
239637
- import_node_crypto65 = require("node:crypto");
239697
+ import_node_crypto66 = require("node:crypto");
239638
239698
  init_src();
239639
- sha = (s2) => (0, import_node_crypto65.createHash)("sha256").update(s2, "utf8").digest("hex");
239699
+ sha = (s2) => (0, import_node_crypto66.createHash)("sha256").update(s2, "utf8").digest("hex");
239640
239700
  enc3 = (s2) => new TextEncoder().encode(s2);
239641
239701
  dec = (b2) => new TextDecoder().decode(b2);
239642
239702
  MirrorEngine = class {
@@ -239883,11 +239943,11 @@ function humanExitCause(exit3) {
239883
239943
  const base = (exit3.reason ? label[exit3.reason] : void 0) ?? `\u4F1A\u8BDD\u5F02\u5E38\u7ED3\u675F\uFF08${exit3.reason ?? "\u65E0\u9000\u51FA\u4FE1\u606F"}\uFF09`;
239884
239944
  return exit3.errorMessage ? `${base}\uFF1A${exit3.errorMessage.slice(0, 200)}` : base;
239885
239945
  }
239886
- var import_node_crypto66, AUTONOMOUS_ETHOS, CONVERSATIONAL_ETHOS, SHARED_GRAPH_BODY, AUTONOMOUS_RECOVERY_TOOLS, HIGH_RISK_COMMANDS, COORDINATOR_SYSTEM_PROMPT, CONVERSATIONAL_RECOVERY_TOOLS, CONVERSATIONAL_ESCALATION_TOOLS, CONVERSATIONAL_MANAGER_BODY, MACHINE_EXIT_CODES, CoordinatorWorker;
239946
+ var import_node_crypto67, AUTONOMOUS_ETHOS, CONVERSATIONAL_ETHOS, SHARED_GRAPH_BODY, AUTONOMOUS_RECOVERY_TOOLS, HIGH_RISK_COMMANDS, COORDINATOR_SYSTEM_PROMPT, CONVERSATIONAL_RECOVERY_TOOLS, CONVERSATIONAL_ESCALATION_TOOLS, CONVERSATIONAL_MANAGER_BODY, MACHINE_EXIT_CODES, CoordinatorWorker;
239887
239947
  var init_worker = __esm({
239888
239948
  "../server/src/coordinator/worker.ts"() {
239889
239949
  "use strict";
239890
- import_node_crypto66 = require("node:crypto");
239950
+ import_node_crypto67 = require("node:crypto");
239891
239951
  init_src5();
239892
239952
  init_identity();
239893
239953
  AUTONOMOUS_ETHOS = `\u4F60\u662F\u8FD9\u4E2A\u5DE5\u5355\u7684**\u7BA1\u7406\u8005**\u2014\u2014\u804C\u8D23\u662F\u8BA9\u5B83\u987A\u7545\u8DD1\u5B8C\u3002\u7CFB\u7EDF\u5728\u67D0\u4E2A\u8282\u70B9\u5361\u4F4F\u3001\u673A\u68B0\u5206\u8BCA\u786E\u8BA4"\u9700\u8981\u4F60"\u65F6\u5524\u8D77\u4F60\uFF08\u65E0\u4EBA\u5728\u573A\uFF0C\u4F60\u8FD9\u4E00\u8F6E\u628A\u80FD\u505A\u7684\u505A\u6389\uFF09\u3002\u4F60\u7684\u624B\u6BB5\u5F88\u5BBD\uFF1A
@@ -240156,7 +240216,7 @@ ${HIGH_RISK_COMMANDS}`;
240156
240216
  return this.deps.kernel.model.lastSeq.get(artifactId) ?? 0;
240157
240217
  }
240158
240218
  evaluationKey(kind, artifactId, evidence) {
240159
- const fingerprint2 = (0, import_node_crypto66.createHash)("sha256").update(JSON.stringify(evidence)).digest("hex");
240219
+ const fingerprint2 = (0, import_node_crypto67.createHash)("sha256").update(JSON.stringify(evidence)).digest("hex");
240160
240220
  return `${kind}:${artifactId}:${fingerprint2}`;
240161
240221
  }
240162
240222
  artifactEvidence(id) {
@@ -240535,8 +240595,8 @@ ${ctx.nodeFault}
240535
240595
  this.deps.log?.(`[coordinator] ${workspace} \u5168\u5C40\u4E0A\u4E0B\u6587\u8BFB\u53D6\u5931\u8D25\uFF0C\u7EE7\u7EED\u6CBF\u7528\u539F\u534F\u8C03\u8005\u4EFB\u52A1\uFF1A${String(error2)}`);
240536
240596
  }
240537
240597
  }
240538
- const runtimeSessionId = opts?.resumeSessionId ?? (0, import_node_crypto66.randomUUID)();
240539
- const coordinatorRunId = `coordinate:${(0, import_node_crypto66.randomUUID)()}`;
240598
+ const runtimeSessionId = opts?.resumeSessionId ?? (0, import_node_crypto67.randomUUID)();
240599
+ const coordinatorRunId = `coordinate:${(0, import_node_crypto67.randomUUID)()}`;
240540
240600
  const taskWithContext = coordinatorContext ? [
240541
240601
  task,
240542
240602
  ``,
@@ -240580,7 +240640,7 @@ ${ctx.nodeFault}
240580
240640
  const startedAtMs = Date.now();
240581
240641
  let trajectoryStarted = false;
240582
240642
  if (this.deps.trajectory) {
240583
- const bundleManifest = Object.fromEntries(Object.entries(job.bundle.files).map(([name, content3]) => [name, (0, import_node_crypto66.createHash)("sha256").update(content3).digest("hex")]));
240643
+ const bundleManifest = Object.fromEntries(Object.entries(job.bundle.files).map(([name, content3]) => [name, (0, import_node_crypto67.createHash)("sha256").update(content3).digest("hex")]));
240584
240644
  const session = {
240585
240645
  runId: coordinatorRunId,
240586
240646
  runtimeSessionId,
@@ -240785,11 +240845,11 @@ var init_pg_ident = __esm({
240785
240845
  });
240786
240846
 
240787
240847
  // ../storage/src/postgres.ts
240788
- var import_node_crypto67, ident3, isUniqueViolation, PostgresOplogStore, PostgresBlobStore;
240848
+ var import_node_crypto68, ident3, isUniqueViolation, PostgresOplogStore, PostgresBlobStore;
240789
240849
  var init_postgres = __esm({
240790
240850
  "../storage/src/postgres.ts"() {
240791
240851
  "use strict";
240792
- import_node_crypto67 = require("node:crypto");
240852
+ import_node_crypto68 = require("node:crypto");
240793
240853
  init_pg_ident();
240794
240854
  init_esm();
240795
240855
  init_src();
@@ -240969,7 +241029,7 @@ var init_postgres = __esm({
240969
241029
  return new _PostgresBlobStore(pool, schema);
240970
241030
  }
240971
241031
  async put(bytes2) {
240972
- const hash2 = (0, import_node_crypto67.createHash)("sha256").update(bytes2).digest("hex");
241032
+ const hash2 = (0, import_node_crypto68.createHash)("sha256").update(bytes2).digest("hex");
240973
241033
  await this.pool.query(
240974
241034
  `INSERT INTO ${this.t} (hash, bytes, size, content_type) VALUES ($1, $2, $3, $4) ON CONFLICT (hash) DO NOTHING`,
240975
241035
  [hash2, Buffer.from(bytes2), bytes2.byteLength, sniffContentType(bytes2) ?? null]
@@ -249392,11 +249452,11 @@ var init_postgres_delegations = __esm({
249392
249452
  });
249393
249453
 
249394
249454
  // ../storage/src/postgres-nodes.ts
249395
- var import_node_crypto68, ident12, PostgresNodeStore, PostgresNodeTokenStore, rowToNode, rowToRuntime;
249455
+ var import_node_crypto69, ident12, PostgresNodeStore, PostgresNodeTokenStore, rowToNode, rowToRuntime;
249396
249456
  var init_postgres_nodes = __esm({
249397
249457
  "../storage/src/postgres-nodes.ts"() {
249398
249458
  "use strict";
249399
- import_node_crypto68 = require("node:crypto");
249459
+ import_node_crypto69 = require("node:crypto");
249400
249460
  init_pg_ident();
249401
249461
  init_esm();
249402
249462
  ident12 = (s2) => {
@@ -249606,7 +249666,7 @@ var init_postgres_nodes = __esm({
249606
249666
  return store;
249607
249667
  }
249608
249668
  issue(nodeId) {
249609
- const token = `ont_${(0, import_node_crypto68.randomBytes)(24).toString("base64url")}`;
249669
+ const token = `ont_${(0, import_node_crypto69.randomBytes)(24).toString("base64url")}`;
249610
249670
  this.cache.set(token, nodeId);
249611
249671
  void this.pool.query(`INSERT INTO ${this.s}.node_tokens (token,node_id) VALUES ($1,$2)`, [token, nodeId]);
249612
249672
  return token;
@@ -249872,11 +249932,11 @@ var init_postgres_type_registry = __esm({
249872
249932
  });
249873
249933
 
249874
249934
  // ../storage/src/postgres-actor-memory.ts
249875
- var import_node_crypto69, matchClause, ident14, PostgresActorMemoryStore, rowToIndexEntry, rowToRecord;
249935
+ var import_node_crypto70, matchClause, ident14, PostgresActorMemoryStore, rowToIndexEntry, rowToRecord;
249876
249936
  var init_postgres_actor_memory = __esm({
249877
249937
  "../storage/src/postgres-actor-memory.ts"() {
249878
249938
  "use strict";
249879
- import_node_crypto69 = require("node:crypto");
249939
+ import_node_crypto70 = require("node:crypto");
249880
249940
  init_pg_ident();
249881
249941
  init_src();
249882
249942
  matchClause = (q2) => q2.requireMatch && q2.keywords.length > 0 ? " WHERE m > 0" : "";
@@ -250086,7 +250146,7 @@ var init_postgres_actor_memory = __esm({
250086
250146
  }
250087
250147
  async write(input, now) {
250088
250148
  if (input.memId === void 0) {
250089
- const memId = `mem:${(0, import_node_crypto69.randomUUID)()}`;
250149
+ const memId = `mem:${(0, import_node_crypto70.randomUUID)()}`;
250090
250150
  const r2 = await this.pool.query(
250091
250151
  `INSERT INTO ${this.s}.actor_memories
250092
250152
  (mem_id, actor_id, project_id, keywords, content, version, created_at, updated_at, accessed_at, source_artifact_id, source_session_id)
@@ -251533,14 +251593,14 @@ function companySchemaName(companyId) {
251533
251593
  if (typeof companyId !== "string" || !companyId.trim()) {
251534
251594
  throw new Error("company schema mapping \u9700\u8981\u975E\u7A7A companyId\uFF08fail-closed\uFF1A\u4E0D\u56DE\u9000\u9ED8\u8BA4\u516C\u53F8\uFF09");
251535
251595
  }
251536
- const hex = (0, import_node_crypto70.createHash)("sha256").update(companyId, "utf8").digest("hex");
251596
+ const hex = (0, import_node_crypto71.createHash)("sha256").update(companyId, "utf8").digest("hex");
251537
251597
  return `${COMPANY_SCHEMA_PREFIX}${hex.slice(0, DIGEST_HEX_LEN)}`;
251538
251598
  }
251539
- var import_node_crypto70, COMPANY_SCHEMA_PREFIX, DIGEST_HEX_LEN, SchemaMappingConflictError, TenantStorageLocationStore;
251599
+ var import_node_crypto71, COMPANY_SCHEMA_PREFIX, DIGEST_HEX_LEN, SchemaMappingConflictError, TenantStorageLocationStore;
251540
251600
  var init_tenant_schema_mapping = __esm({
251541
251601
  "../storage/src/tenant-schema-mapping.ts"() {
251542
251602
  "use strict";
251543
- import_node_crypto70 = require("node:crypto");
251603
+ import_node_crypto71 = require("node:crypto");
251544
251604
  init_esm();
251545
251605
  init_pg_ident();
251546
251606
  COMPANY_SCHEMA_PREFIX = "c_";
@@ -251614,7 +251674,7 @@ var init_tenant_schema_mapping = __esm({
251614
251674
 
251615
251675
  // ../storage/src/company-data-plane-schema.ts
251616
251676
  function canonicalTypeDefHash(def) {
251617
- return `sha256:${(0, import_node_crypto71.createHash)("sha256").update(JSON.stringify(def), "utf8").digest("hex")}`;
251677
+ return `sha256:${(0, import_node_crypto72.createHash)("sha256").update(JSON.stringify(def), "utf8").digest("hex")}`;
251618
251678
  }
251619
251679
  function defaultArtifactTypeTemplate() {
251620
251680
  return [
@@ -251794,11 +251854,11 @@ async function seedDefaultArtifactTypes(pool, schema, templates = defaultArtifac
251794
251854
  }
251795
251855
  return { inserted };
251796
251856
  }
251797
- var import_node_crypto71, DEFAULT_ARTIFACT_TYPE_TEMPLATE_VERSION;
251857
+ var import_node_crypto72, DEFAULT_ARTIFACT_TYPE_TEMPLATE_VERSION;
251798
251858
  var init_company_data_plane_schema = __esm({
251799
251859
  "../storage/src/company-data-plane-schema.ts"() {
251800
251860
  "use strict";
251801
- import_node_crypto71 = require("node:crypto");
251861
+ import_node_crypto72 = require("node:crypto");
251802
251862
  init_esm();
251803
251863
  init_pg_ident();
251804
251864
  DEFAULT_ARTIFACT_TYPE_TEMPLATE_VERSION = "4c368e5c-types-v1";
@@ -251877,11 +251937,11 @@ function rowToFile2(row) {
251877
251937
  updatedAt: new Date(row.updated_at).toISOString()
251878
251938
  };
251879
251939
  }
251880
- var import_node_crypto72, COMPANY_CONFLICT_MSG, CompanyIdentifierConflictError, CompanyOwnedRegistryStore;
251940
+ var import_node_crypto73, COMPANY_CONFLICT_MSG, CompanyIdentifierConflictError, CompanyOwnedRegistryStore;
251881
251941
  var init_company_owned_registry_store = __esm({
251882
251942
  "../storage/src/company-owned-registry-store.ts"() {
251883
251943
  "use strict";
251884
- import_node_crypto72 = require("node:crypto");
251944
+ import_node_crypto73 = require("node:crypto");
251885
251945
  init_esm();
251886
251946
  init_src();
251887
251947
  init_pg_ident();
@@ -252266,7 +252326,7 @@ var init_company_owned_registry_store = __esm({
252266
252326
  enabled: skill.enabled,
252267
252327
  files: files.map((f2) => ({ path: f2.path, blobHash: f2.blobHash }))
252268
252328
  });
252269
- return (0, import_node_crypto72.createHash)("sha256").update(body2).digest("hex");
252329
+ return (0, import_node_crypto73.createHash)("sha256").update(body2).digest("hex");
252270
252330
  }
252271
252331
  };
252272
252332
  }
@@ -254742,7 +254802,7 @@ function sourceSetConservation(input) {
254742
254802
  return input.sourceFinal === input.copied + input.approvedRuntimeConversion + input.approvedArchive + input.approvedDiscard;
254743
254803
  }
254744
254804
  function payloadChecksum(value2) {
254745
- return (0, import_node_crypto73.createHash)("sha256").update(JSON.stringify(value2)).digest("hex");
254805
+ return (0, import_node_crypto74.createHash)("sha256").update(JSON.stringify(value2)).digest("hex");
254746
254806
  }
254747
254807
  async function copyWorkorderDraftsIdempotent(pool, companyId, companySchema, manifestId, opts) {
254748
254808
  const cs = quoteIdent2(companySchema);
@@ -255130,11 +255190,11 @@ async function copyTraceFamilyIdempotent(pool, companyId, companySchema, manifes
255130
255190
  sequences
255131
255191
  };
255132
255192
  }
255133
- var import_node_crypto73, MissingInstallerActorsError, TypeCatalogNotCoveredError, ORG_REGISTRY_TABLES, TRACE_FAMILY;
255193
+ var import_node_crypto74, MissingInstallerActorsError, TypeCatalogNotCoveredError, ORG_REGISTRY_TABLES, TRACE_FAMILY;
255134
255194
  var init_tenant_migration_operator = __esm({
255135
255195
  "../storage/src/tenant-migration-operator.ts"() {
255136
255196
  "use strict";
255137
- import_node_crypto73 = require("node:crypto");
255197
+ import_node_crypto74 = require("node:crypto");
255138
255198
  init_esm();
255139
255199
  init_pg_ident();
255140
255200
  init_tenancy_attribution();
@@ -255366,8 +255426,8 @@ var init_tenant_new_company_provision = __esm({
255366
255426
  // ../storage/src/knowledge-snapshot-crypto.ts
255367
255427
  function sealSnapshot(snapshot, key) {
255368
255428
  if (snapshot.content.startsWith(PREFIX3)) return structuredClone(snapshot);
255369
- const iv = (0, import_node_crypto74.randomBytes)(12);
255370
- const cipher = (0, import_node_crypto74.createCipheriv)("aes-256-gcm", bytes(key), iv);
255429
+ const iv = (0, import_node_crypto75.randomBytes)(12);
255430
+ const cipher = (0, import_node_crypto75.createCipheriv)("aes-256-gcm", bytes(key), iv);
255371
255431
  cipher.setAAD(aad2(snapshot));
255372
255432
  const encrypted = Buffer.concat([cipher.update(snapshot.content, "utf8"), cipher.final()]);
255373
255433
  return { ...structuredClone(snapshot), content: `${PREFIX3}${iv.toString("base64url")}.${cipher.getAuthTag().toString("base64url")}.${encrypted.toString("base64url")}` };
@@ -255377,7 +255437,7 @@ function openSnapshot(snapshot, key) {
255377
255437
  const packed = snapshot.content.slice(PREFIX3.length).split(".");
255378
255438
  if (packed.length !== 3 || packed.some((part) => !part)) throw new Error(`knowledge snapshot ${snapshot.ref} ciphertext is malformed`);
255379
255439
  const [iv, tag, data] = packed;
255380
- const decipher = (0, import_node_crypto74.createDecipheriv)("aes-256-gcm", bytes(key), Buffer.from(iv, "base64url"));
255440
+ const decipher = (0, import_node_crypto75.createDecipheriv)("aes-256-gcm", bytes(key), Buffer.from(iv, "base64url"));
255381
255441
  decipher.setAAD(aad2(snapshot));
255382
255442
  decipher.setAuthTag(Buffer.from(tag, "base64url"));
255383
255443
  return {
@@ -255385,11 +255445,11 @@ function openSnapshot(snapshot, key) {
255385
255445
  content: Buffer.concat([decipher.update(Buffer.from(data, "base64url")), decipher.final()]).toString("utf8")
255386
255446
  };
255387
255447
  }
255388
- var import_node_crypto74, PREFIX3, bytes, aad2;
255448
+ var import_node_crypto75, PREFIX3, bytes, aad2;
255389
255449
  var init_knowledge_snapshot_crypto = __esm({
255390
255450
  "../storage/src/knowledge-snapshot-crypto.ts"() {
255391
255451
  "use strict";
255392
- import_node_crypto74 = require("node:crypto");
255452
+ import_node_crypto75 = require("node:crypto");
255393
255453
  PREFIX3 = "oasis-knowledge:v1:";
255394
255454
  bytes = (key) => {
255395
255455
  const value2 = Buffer.from(key);
@@ -257620,20 +257680,20 @@ var fs44 = __toESM(require("node:fs"));
257620
257680
  var os14 = __toESM(require("node:os"));
257621
257681
  var path40 = __toESM(require("node:path"));
257622
257682
  var import_node_child_process23 = require("node:child_process");
257623
- var import_node_crypto81 = require("node:crypto");
257683
+ var import_node_crypto82 = require("node:crypto");
257624
257684
 
257625
257685
  // ../cli/src/cli.ts
257626
257686
  var fs39 = __toESM(require("node:fs"), 1);
257627
257687
  var os12 = __toESM(require("node:os"), 1);
257628
257688
  var path35 = __toESM(require("node:path"), 1);
257629
- var import_node_crypto79 = require("node:crypto");
257689
+ var import_node_crypto80 = require("node:crypto");
257630
257690
 
257631
257691
  // ../cli/src/serve.ts
257632
257692
  var fs33 = __toESM(require("node:fs"), 1);
257633
257693
  var os8 = __toESM(require("node:os"), 1);
257634
257694
  var path29 = __toESM(require("node:path"), 1);
257635
257695
  var import_node_child_process18 = require("node:child_process");
257636
- var import_node_crypto75 = require("node:crypto");
257696
+ var import_node_crypto76 = require("node:crypto");
257637
257697
  var import_node_url7 = require("node:url");
257638
257698
 
257639
257699
  // ../cli/src/artifact-discovery-source.ts
@@ -258318,7 +258378,7 @@ init_src9();
258318
258378
  init_src();
258319
258379
  init_trajectory();
258320
258380
  function deterministicUuid2(seed) {
258321
- const h = (0, import_node_crypto75.createHash)("sha256").update(seed).digest();
258381
+ const h = (0, import_node_crypto76.createHash)("sha256").update(seed).digest();
258322
258382
  const b2 = Buffer.from(h.subarray(0, 16));
258323
258383
  b2[6] = b2[6] & 15 | 80;
258324
258384
  b2[8] = b2[8] & 63 | 128;
@@ -258518,7 +258578,7 @@ function oasisWrapperScript() {
258518
258578
  const repoRoot = (0, import_node_url7.fileURLToPath)(new URL("../../../", __esm_import_meta_url));
258519
258579
  const tsx = path29.join(repoRoot, "node_modules/.bin/tsx");
258520
258580
  const main = path29.join(repoRoot, "packages/cli/src/main.ts");
258521
- const key = (0, import_node_crypto75.createHash)("sha256").update(repoRoot).digest("hex").slice(0, 12);
258581
+ const key = (0, import_node_crypto76.createHash)("sha256").update(repoRoot).digest("hex").slice(0, 12);
258522
258582
  const uid = typeof process.getuid === "function" ? process.getuid() : "na";
258523
258583
  const stable = path29.join(os8.tmpdir(), `oasis-cli-wrapper-${uid}-${key}`);
258524
258584
  let dir;
@@ -258899,7 +258959,7 @@ async function startServe(opts) {
258899
258959
  if (!hub) return Promise.resolve({ ok: false, reason: "\u672C\u8FDB\u7A0B\u6CA1\u6709\u8282\u70B9\u7F51\u5173" });
258900
258960
  const online = hub.connectedDaemons().some((d) => d.daemonId === nodeId);
258901
258961
  if (!online) return Promise.resolve({ ok: false, reason: "\u8282\u70B9\u5F53\u524D\u4E0D\u5728\u7EBF\uFF0C\u7528\u7684\u662F\u5B83\u4E0A\u6B21\u62A5\u7684\u6E05\u5355" });
258902
- const requestId = (0, import_node_crypto75.randomUUID)();
258962
+ const requestId = (0, import_node_crypto76.randomUUID)();
258903
258963
  const task = new Promise((resolve10) => {
258904
258964
  const timer = setTimeout(() => {
258905
258965
  modelRefreshWaiters.delete(requestId);
@@ -259151,6 +259211,20 @@ async function startServe(opts) {
259151
259211
  const defaultBranchResolver = makeDefaultBranchResolver({ log: (m2) => console.warn(m2) });
259152
259212
  const perCompanyActorNames = /* @__PURE__ */ new Map();
259153
259213
  const projectsDomain2 = createProjectsDomain({
259214
+ listChatFiles: async (companyId, projectId2) => {
259215
+ const chat = await chatStoreFor(companyId);
259216
+ const facts = await blobStoreFor(companyId);
259217
+ return collectProjectChatFiles(chat, projectId2, async (ref2) => {
259218
+ for (const cabinet of [assets, facts]) {
259219
+ try {
259220
+ const meta = await cabinet.meta?.(ref2);
259221
+ if (meta) return meta;
259222
+ } catch {
259223
+ }
259224
+ }
259225
+ return null;
259226
+ });
259227
+ },
259154
259228
  projects: projectStateStore,
259155
259229
  artifacts: artifactStateStore,
259156
259230
  kernel: defaultCompanyKernel,
@@ -259597,7 +259671,7 @@ async function startServe(opts) {
259597
259671
  const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
259598
259672
  if (buf || session.runId) {
259599
259673
  await turnStore.appendMessage({
259600
- id: (0, import_node_crypto75.randomUUID)(),
259674
+ id: (0, import_node_crypto76.randomUUID)(),
259601
259675
  sessionId: chatSessionId,
259602
259676
  role: "assistant",
259603
259677
  content: buf,
@@ -259643,7 +259717,7 @@ async function startServe(opts) {
259643
259717
  chatTargets: {
259644
259718
  inspect: inspectChatTarget,
259645
259719
  createTargetSession: async ({ companyId, agentId, ownerHumanActorId, title }) => {
259646
- const sessionId = (0, import_node_crypto75.randomUUID)();
259720
+ const sessionId = (0, import_node_crypto76.randomUUID)();
259647
259721
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
259648
259722
  const binding = await registryStore.getBinding(agentId).catch(() => null);
259649
259723
  await (await chatStoreFor(companyId)).createSession({
@@ -260646,7 +260720,7 @@ async function startServe(opts) {
260646
260720
  }));
260647
260721
  }
260648
260722
  const limits = { wallClockMs: wallClockForKind("planner") };
260649
- const artifactId = `artifact:planner:${(0, import_node_crypto75.randomUUID)()}`;
260723
+ const artifactId = `artifact:planner:${(0, import_node_crypto76.randomUUID)()}`;
260650
260724
  const handle = await chatRemoteAdapter.spawn({
260651
260725
  actor: planner.id,
260652
260726
  // companyId 同协调者:planner 用的就是默认公司的 actors 服务,漏签会让它一调公司域端点就 404。
@@ -261498,10 +261572,10 @@ async function startServe(opts) {
261498
261572
  if (isDeletedActor(dispatchTarget)) {
261499
261573
  throw new ApiError(409, ACTOR_DELETED_ERROR_CODE, ACTOR_DELETED_CHAT_MESSAGE);
261500
261574
  }
261501
- const runtimeSessionId = sessionId ?? (requestDispatchId ? deterministicUuid2(`chat-runtime:${requestDispatchId}`) : (0, import_node_crypto75.randomUUID)());
261575
+ const runtimeSessionId = sessionId ?? (requestDispatchId ? deterministicUuid2(`chat-runtime:${requestDispatchId}`) : (0, import_node_crypto76.randomUUID)());
261502
261576
  const resumeRuntimeSession = Boolean(sessionId);
261503
- const traceRunId = requestDispatchId ? `chat-run:${deterministicUuid2(`chat-trace:${requestDispatchId}`)}` : `chat-run:${(0, import_node_crypto75.randomUUID)()}`;
261504
- const artifactId = requestDispatchId ? `artifact:chat:${deterministicUuid2(`chat-artifact:${requestDispatchId}`)}` : `artifact:chat:${(0, import_node_crypto75.randomUUID)()}`;
261577
+ const traceRunId = requestDispatchId ? `chat-run:${deterministicUuid2(`chat-trace:${requestDispatchId}`)}` : `chat-run:${(0, import_node_crypto76.randomUUID)()}`;
261578
+ const artifactId = requestDispatchId ? `artifact:chat:${deterministicUuid2(`chat-artifact:${requestDispatchId}`)}` : `artifact:chat:${(0, import_node_crypto76.randomUUID)()}`;
261505
261579
  let stableDispatch = requestDispatchId ? await resolveStableChatDispatch({ store: await traceStoreFor(runCompanyId), runId: traceRunId }) : null;
261506
261580
  if (stableDispatch && !stableDispatch.shouldDispatch) {
261507
261581
  return {
@@ -262623,7 +262697,7 @@ async function startServe(opts) {
262623
262697
  console.log(`[new-engine] dispatchWork ${workId} \u662F human work\u2014\u2014\u4E0D\u6D3E runtime\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u5904\u7406`);
262624
262698
  return;
262625
262699
  }
262626
- const ledgerId = `dispatch:${(0, import_node_crypto75.randomUUID)()}`;
262700
+ const ledgerId = `dispatch:${(0, import_node_crypto76.randomUUID)()}`;
262627
262701
  try {
262628
262702
  await (await dispatchLedgerFor(companyId)).insertOpen({
262629
262703
  id: ledgerId,
@@ -262708,7 +262782,7 @@ async function startServe(opts) {
262708
262782
  const kernelModel = newKernel.model;
262709
262783
  const art = kernelModel.artifacts.get(nodeId);
262710
262784
  const revWid = art?.workspace ?? "";
262711
- const ledgerId = `dispatch:${(0, import_node_crypto75.randomUUID)()}`;
262785
+ const ledgerId = `dispatch:${(0, import_node_crypto76.randomUUID)()}`;
262712
262786
  try {
262713
262787
  await (await dispatchLedgerFor(companyId)).insertOpen({
262714
262788
  id: ledgerId,
@@ -263086,7 +263160,7 @@ async function startServe(opts) {
263086
263160
  resolveSupplementalContext: server.knowledgeGovernance ? async ({ actorId, artifactId, workOrderId, action, part, runtimeKind, taskMarkdown }) => {
263087
263161
  try {
263088
263162
  const governance = server.knowledgeGovernance;
263089
- const taskFingerprint = (0, import_node_crypto75.createHash)("sha256").update(JSON.stringify({ artifactId, workOrderId, action, part: part ?? null, taskMarkdown })).digest("hex");
263163
+ const taskFingerprint = (0, import_node_crypto76.createHash)("sha256").update(JSON.stringify({ artifactId, workOrderId, action, part: part ?? null, taskMarkdown })).digest("hex");
263090
263164
  const requestContext = {
263091
263165
  organizationId: companyId,
263092
263166
  actorId,
@@ -264976,7 +265050,7 @@ var SessionProcessState = class {
264976
265050
  // ../cli/src/daemon/ws-client.ts
264977
265051
  init_wrapper();
264978
265052
  var import_node_os9 = require("node:os");
264979
- var import_node_crypto76 = require("node:crypto");
265053
+ var import_node_crypto77 = require("node:crypto");
264980
265054
  init_src8();
264981
265055
  init_src6();
264982
265056
 
@@ -265699,7 +265773,7 @@ var DaemonWsClient = class {
265699
265773
  */
265700
265774
  async queryArtifactStates(artifactIds, timeoutMs = 15e3) {
265701
265775
  if (artifactIds.length === 0) return {};
265702
- const requestId = (0, import_node_crypto76.randomUUID)();
265776
+ const requestId = (0, import_node_crypto77.randomUUID)();
265703
265777
  return new Promise((resolve10, reject) => {
265704
265778
  const timer = setTimeout(() => {
265705
265779
  this.gcPending.delete(requestId);
@@ -266099,7 +266173,7 @@ function forwardSignal(child, sig, killGroup = (pgid, signal) => {
266099
266173
  // ../cli/src/daemon/machine-id.ts
266100
266174
  var import_node_child_process21 = require("node:child_process");
266101
266175
  var import_node_fs21 = require("node:fs");
266102
- var import_node_crypto77 = require("node:crypto");
266176
+ var import_node_crypto78 = require("node:crypto");
266103
266177
  var import_node_os12 = require("node:os");
266104
266178
  function linuxMachineId() {
266105
266179
  for (const p2 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
@@ -266165,7 +266239,7 @@ var defaultSources = {
266165
266239
  function resolveNodeId(sources = {}) {
266166
266240
  const s2 = { ...defaultSources, ...sources };
266167
266241
  const material = `${s2.machineFingerprint()}:${s2.osUser()}`;
266168
- const digest = (0, import_node_crypto77.createHash)("sha256").update(material).digest("hex").slice(0, 12);
266242
+ const digest = (0, import_node_crypto78.createHash)("sha256").update(material).digest("hex").slice(0, 12);
266169
266243
  return `node-${digest}`;
266170
266244
  }
266171
266245
 
@@ -267936,13 +268010,13 @@ function ownFlagsFromDecl(command) {
267936
268010
  }
267937
268011
 
267938
268012
  // ../cli/src/connector-effect-runner.ts
267939
- var import_node_crypto78 = require("node:crypto");
268013
+ var import_node_crypto79 = require("node:crypto");
267940
268014
  var import_node_child_process22 = require("node:child_process");
267941
268015
  init_src8();
267942
268016
  function stableKey(effect) {
267943
268017
  const keyFields = Object.fromEntries(Object.entries(effect.keyFields).sort(([a], [b2]) => a.localeCompare(b2)));
267944
268018
  const canonical = JSON.stringify({ kind: effect.kind, target: effect.target, keyFields });
267945
- return `sha256:${(0, import_node_crypto78.createHash)("sha256").update(canonical).digest("hex")}`;
268019
+ return `sha256:${(0, import_node_crypto79.createHash)("sha256").update(canonical).digest("hex")}`;
267946
268020
  }
267947
268021
  async function runConnectorEffect(connector, toolArgs, deps) {
267948
268022
  const effect = connector.describeExternalEffect?.(toolArgs) ?? null;
@@ -268152,7 +268226,7 @@ async function waitForCommandAuthorization(base, headers, draftId, fallback) {
268152
268226
  const timeoutMs = resolveAuthWaitMs();
268153
268227
  const controller = new AbortController();
268154
268228
  const timer = setTimeout(() => controller.abort(), timeoutMs);
268155
- const waiterId = (0, import_node_crypto79.randomUUID)();
268229
+ const waiterId = (0, import_node_crypto80.randomUUID)();
268156
268230
  process.stderr.write(
268157
268231
  `\u7B49\u5F85\u4EBA\u5DE5\u6388\u6743\u4E2D\u2026\u2026\u6700\u591A ${Math.round(timeoutMs / 1e3)} \u79D2\uFF0C\u8D85\u65F6\u4F1A\u81EA\u52A8\u8F6C\u4E3A\u5F85\u5BA1\uFF1B\u8FD9\u4E0D\u662F\u9519\u8BEF\uFF0C\u8BF7\u52FF\u91CD\u8BD5\u540C\u4E00\u6761\u547D\u4EE4\u3002
268158
268232
  `
@@ -268574,7 +268648,7 @@ async function runCli(argv, println = console.log, progressln = console.error) {
268574
268648
  const store = createNodeTokenStore(path35.join(dir, "node-tokens.json"));
268575
268649
  const sub = positional[0];
268576
268650
  if (sub === "issue") {
268577
- const id = flags.get("id") ?? `node-${(0, import_node_crypto79.randomUUID)()}`;
268651
+ const id = flags.get("id") ?? `node-${(0, import_node_crypto80.randomUUID)()}`;
268578
268652
  const token2 = store.issue(id);
268579
268653
  println(token2);
268580
268654
  process.stderr.write(
@@ -271587,13 +271661,13 @@ var LEGACY_SYSTEMD_UNIT = "oasis-node.service";
271587
271661
  var LEGACY_LAUNCHD_LABEL = "com.oasis.node";
271588
271662
 
271589
271663
  // src/install.ts
271590
- var import_node_crypto80 = require("node:crypto");
271664
+ var import_node_crypto81 = require("node:crypto");
271591
271665
  var fs43 = __toESM(require("node:fs"));
271592
271666
  var path39 = __toESM(require("node:path"));
271593
271667
  function versionLabel(sourceFile, pkgVersion, npmPrefixDir, pkgName = LEGACY_PKG_NAME) {
271594
271668
  const tag = pkgName === LEGACY_PKG_NAME ? "" : `+pkg.${pkgName.replace(/[^A-Za-z0-9-]/g, "-")}`;
271595
271669
  if (isFromNpmPrefix(sourceFile, npmPrefixDir)) return `${pkgVersion}${tag}`;
271596
- const digest = (0, import_node_crypto80.createHash)("sha256").update(fs43.readFileSync(sourceFile)).digest("hex").slice(0, 8);
271670
+ const digest = (0, import_node_crypto81.createHash)("sha256").update(fs43.readFileSync(sourceFile)).digest("hex").slice(0, 8);
271597
271671
  return tag ? `${pkgVersion}${tag}.local.${digest}` : `${pkgVersion}+local.${digest}`;
271598
271672
  }
271599
271673
  function isFromNpmPrefix(sourceFile, npmPrefixDir) {
@@ -271716,7 +271790,7 @@ function shimScript() {
271716
271790
  }
271717
271791
 
271718
271792
  // src/index.ts
271719
- var PKG_VERSION = true ? "2.2.15" : "dev";
271793
+ var PKG_VERSION = true ? "2.2.16" : "dev";
271720
271794
  var LOCAL_BIN = localBin();
271721
271795
  var NPM_PREFIX = npmPrefix();
271722
271796
  var INSTANCE = DEFAULT_INSTANCE;
@@ -272001,7 +272075,7 @@ function newInstanceName() {
272001
272075
  const existing = new Set(listInstances());
272002
272076
  if (!existing.has(DEFAULT_INSTANCE)) return DEFAULT_INSTANCE;
272003
272077
  for (; ; ) {
272004
- const n = `inst-${(0, import_node_crypto81.randomBytes)(3).toString("hex")}`;
272078
+ const n = `inst-${(0, import_node_crypto82.randomBytes)(3).toString("hex")}`;
272005
272079
  if (!existing.has(n)) return n;
272006
272080
  }
272007
272081
  }