@nowcrew/daemon 0.6.101-beta.3 → 0.6.101-beta.5

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 (64) hide show
  1. package/dist/cloud-report-upload.js +1 -10
  2. package/dist/execution-journal-lock.js +51 -2
  3. package/dist/execution-journal.js +3 -1
  4. package/dist/execution-protocol.js +1 -1
  5. package/dist/execution-runner.js +4 -1
  6. package/dist/host-execution-coordinator.js +10 -0
  7. package/dist/local-execution-prompt.js +8 -3
  8. package/dist/local-executor.js +78 -55
  9. package/dist/local-memory/commit-telemetry.js +30 -0
  10. package/dist/local-memory/execution-workspace.js +117 -0
  11. package/dist/local-memory/full-index-search.js +47 -0
  12. package/dist/local-memory/index-budget.js +9 -3
  13. package/dist/local-memory/initialization-identity.js +36 -0
  14. package/dist/local-memory/inventory-cli.js +52 -8
  15. package/dist/local-memory/inventory-source.js +15 -8
  16. package/dist/local-memory/inventory-v2.js +362 -0
  17. package/dist/local-memory/legacy-adapter.js +233 -0
  18. package/dist/local-memory/migration-access.js +242 -0
  19. package/dist/local-memory/migration-cli.js +54 -0
  20. package/dist/local-memory/migration-io.js +199 -0
  21. package/dist/local-memory/migration-pending.js +9 -0
  22. package/dist/local-memory/migration-plan.js +432 -0
  23. package/dist/local-memory/migration-schema.js +58 -0
  24. package/dist/local-memory/migration-state-invariants.js +65 -0
  25. package/dist/local-memory/migration-store.js +414 -0
  26. package/dist/local-memory/migration-tool-entry.js +21 -0
  27. package/dist/local-memory/pending-query.js +5 -2
  28. package/dist/local-memory/pending-schema.js +1 -1
  29. package/dist/local-memory/pending.js +16 -2
  30. package/dist/local-memory/prompt.js +21 -5
  31. package/dist/local-memory/read-cli.js +98 -76
  32. package/dist/local-memory/release-artifact-guard.js +55 -0
  33. package/dist/local-memory/rollout.js +79 -11
  34. package/dist/local-memory/runtime.js +191 -17
  35. package/dist/local-memory/source-path.js +13 -0
  36. package/dist/local-memory/storage-format.js +249 -0
  37. package/dist/local-memory/write.js +190 -21
  38. package/dist/local-memory/writer-mode.js +13 -0
  39. package/dist/local-memory-diagnostics.js +96 -15
  40. package/dist/local-memory-telemetry.js +31 -3
  41. package/dist/machine-info.js +6 -1
  42. package/dist/machine-runtime-environment.js +1 -0
  43. package/dist/marketplace-protocol.js +1 -1
  44. package/dist/marketplace-remote.js +1 -1
  45. package/dist/marketplace-runner.js +1 -1
  46. package/dist/memory-migration-controller.js +89 -0
  47. package/dist/memory-migration-inspect.js +116 -0
  48. package/dist/memory-migration-journal.js +14 -0
  49. package/dist/memory-migration-protocol.js +14 -0
  50. package/dist/memory-migration-runtime.js +367 -0
  51. package/dist/memory-prune-diagnostics.js +74 -4
  52. package/dist/message-file-preview.js +11 -1
  53. package/dist/prompt.js +9 -17
  54. package/dist/runner.js +1 -1
  55. package/dist/runtime-tool-update-bridge.js +126 -0
  56. package/dist/runtime-tool-update-controller.js +151 -0
  57. package/dist/runtime-tool-update-protocol.js +24 -0
  58. package/dist/runtime-tool-update-serve.js +54 -0
  59. package/dist/runtimes/claude-thread-runner.js +25 -4
  60. package/dist/serve.js +47 -3
  61. package/dist/token.js +1 -0
  62. package/dist/workspace-control-handler.js +16 -3
  63. package/dist/workspace.js +23 -4
  64. package/package.json +1 -1
package/dist/workspace.js CHANGED
@@ -8,12 +8,23 @@
8
8
  *
9
9
  * spawn runtime 时把 <ws>/.crew 置于 PATH 最前,于是 agent 的 `crew ...` 命中 wrapper。
10
10
  */
11
- import { mkdir, writeFile, readFile, chmod, access, lstat } from "node:fs/promises";
11
+ import { mkdir, writeFile, readFile, chmod, access, lstat, realpath } from "node:fs/promises";
12
12
  import { createHash, randomUUID } from "node:crypto";
13
13
  import { dirname, join } from "node:path";
14
14
  import { fileURLToPath, pathToFileURL } from "node:url";
15
15
  import { createRequire } from "node:module";
16
16
  import { dslog } from "./slog.js";
17
+ import { MigrationStateSchema } from "./local-memory/migration-schema.js";
18
+ import { assertMigrationStateIntegrity } from "./local-memory/migration-state-invariants.js";
19
+ import { detectLocalMemoryStorageVersion } from "./local-memory/storage-format.js";
20
+ export class LocalMemoryWorkspacePrepareError extends Error {
21
+ cause;
22
+ constructor(code, cause) {
23
+ super(code);
24
+ this.name = "LocalMemoryWorkspacePrepareError";
25
+ this.cause = cause;
26
+ }
27
+ }
17
28
  /** 文件系统安全的 taskKey:仅留 [\w.-],其余转 _,截断,避免路径穿越/超长。 */
18
29
  export function safeKey(key) {
19
30
  return key.replace(/[^\w.-]+/g, "_").replace(/^[-.]+/, "").slice(0, 80) || "default";
@@ -49,7 +60,15 @@ async function hasLocalMemoryV2Marker(agentDir) {
49
60
  const stat = await lstat(markerPath);
50
61
  if (!stat.isFile() || stat.isSymbolicLink())
51
62
  return false;
52
- return (await readFile(markerPath, "utf8")) === "1\n";
63
+ if ((await readFile(markerPath, "utf8")) !== "1\n")
64
+ return false;
65
+ const root = await realpath(agentDir);
66
+ const state = MigrationStateSchema.parse(JSON.parse(await readFile(join(memoryDir, "migration.v1.json"), "utf8")));
67
+ assertMigrationStateIntegrity(state, state.identity);
68
+ return state.phase === "committed" && state.storageVersion === 2
69
+ && state.identity.rootFingerprint === createHash("sha256").update(root).digest("hex")
70
+ && state.identity.ownerIdentity === String((await lstat(root)).uid)
71
+ && detectLocalMemoryStorageVersion(await readFile(join(root, "MEMORY.md"), "utf8")) === 2;
53
72
  }
54
73
  catch {
55
74
  return false;
@@ -73,7 +92,7 @@ export async function prepareWorkspace(input) {
73
92
  }
74
93
  catch (error) {
75
94
  logMemoryPrepareFailure(input, "memory_seed_write", error);
76
- throw error;
95
+ throw new LocalMemoryWorkspacePrepareError("local_memory_workspace_seed_write_failed", error);
77
96
  }
78
97
  }
79
98
  let memory = "";
@@ -83,7 +102,7 @@ export async function prepareWorkspace(input) {
83
102
  }
84
103
  catch (error) {
85
104
  logMemoryPrepareFailure(input, "memory_read", error);
86
- throw error;
105
+ throw new LocalMemoryWorkspacePrepareError("local_memory_workspace_read_failed", error);
87
106
  }
88
107
  }
89
108
  // 系统提示词按 execution 隔离;省略 identity 的兼容调用每次使用随机路径。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowcrew/daemon",
3
- "version": "0.6.101-beta.3",
3
+ "version": "0.6.101-beta.5",
4
4
  "type": "module",
5
5
  "description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
6
6
  "license": "Apache-2.0",