@nowcrew/daemon 0.5.26 → 0.5.28

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 (67) hide show
  1. package/package.json +1 -1
  2. package/dist/attachments.js +0 -196
  3. package/dist/bound-im-decision.js +0 -22
  4. package/dist/completion-retransmitter.js +0 -77
  5. package/dist/computer-cli.js +0 -274
  6. package/dist/computer-profile-lock.js +0 -395
  7. package/dist/computer-profile.js +0 -364
  8. package/dist/computer-service.js +0 -358
  9. package/dist/config.js +0 -82
  10. package/dist/console-collapse.js +0 -13
  11. package/dist/console-formatter.js +0 -77
  12. package/dist/console-payload.js +0 -73
  13. package/dist/console.js +0 -329
  14. package/dist/daemon-startup-error.js +0 -30
  15. package/dist/execution-backend.js +0 -44
  16. package/dist/execution-event-limit.js +0 -64
  17. package/dist/execution-journal-lock.js +0 -421
  18. package/dist/execution-journal.js +0 -716
  19. package/dist/execution-protocol.js +0 -342
  20. package/dist/execution-recovery.js +0 -95
  21. package/dist/execution-runner.js +0 -659
  22. package/dist/execution-supervisor-child.js +0 -236
  23. package/dist/execution-supervisor.js +0 -302
  24. package/dist/execution-telemetry-journal.js +0 -71
  25. package/dist/external-output.js +0 -114
  26. package/dist/i18n.js +0 -64
  27. package/dist/json-result.js +0 -27
  28. package/dist/list-models.js +0 -92
  29. package/dist/local-executor.js +0 -439
  30. package/dist/log-format.js +0 -10
  31. package/dist/machine-info.js +0 -124
  32. package/dist/main.js +0 -118
  33. package/dist/normalize.js +0 -170
  34. package/dist/origin-decision.js +0 -44
  35. package/dist/platform.js +0 -8
  36. package/dist/prompt.js +0 -307
  37. package/dist/provider-env.js +0 -90
  38. package/dist/runner.js +0 -234
  39. package/dist/runtime-cancellation.js +0 -74
  40. package/dist/runtime-capabilities.js +0 -43
  41. package/dist/runtime-path.js +0 -60
  42. package/dist/runtimes/claude.js +0 -51
  43. package/dist/runtimes/codex-app-server-runner.js +0 -340
  44. package/dist/runtimes/codex-deepseek-catalog.js +0 -7
  45. package/dist/runtimes/codex-deepseek-config.js +0 -50
  46. package/dist/runtimes/codex.js +0 -53
  47. package/dist/runtimes/kimi-acp-runner.js +0 -364
  48. package/dist/runtimes/kimi.js +0 -45
  49. package/dist/runtimes/progress-watchdog.js +0 -26
  50. package/dist/scheduled-report.js +0 -51
  51. package/dist/scheduled-run-report.js +0 -57
  52. package/dist/serve-lifecycle.js +0 -82
  53. package/dist/serve.js +0 -868
  54. package/dist/session.js +0 -82
  55. package/dist/shared-execution-slots.js +0 -68
  56. package/dist/shutdown-deadline.js +0 -32
  57. package/dist/skill-preview.js +0 -21
  58. package/dist/skills.js +0 -56
  59. package/dist/slog.js +0 -228
  60. package/dist/supervised-runtime.js +0 -104
  61. package/dist/token.js +0 -24
  62. package/dist/unified-diff.js +0 -84
  63. package/dist/websocket-shutdown.js +0 -53
  64. package/dist/win32-job-object.js +0 -193
  65. package/dist/workspace-fs.js +0 -80
  66. package/dist/workspace-import.js +0 -127
  67. package/dist/workspace.js +0 -148
package/dist/workspace.js DELETED
@@ -1,148 +0,0 @@
1
- /**
2
- * 准备 agent 在本机的工作区:
3
- * <agentsRoot>/<handle>/
4
- * ├── MEMORY.md 长期记忆/角色 (首次创建种子)
5
- * ├── .crew/prompts/<execution>.md 按 execution 隔离的系统提示词
6
- * └── .crew/crew 注入 PATH 的 CLI wrapper (0755)
7
- *
8
- * spawn runtime 时把 <ws>/.crew 置于 PATH 最前,于是 agent 的 `crew ...` 命中 wrapper。
9
- */
10
- import { mkdir, writeFile, readFile, chmod, access } from "node:fs/promises";
11
- import { createHash, randomUUID } from "node:crypto";
12
- import { join } from "node:path";
13
- /** 文件系统安全的 taskKey:仅留 [\w.-],其余转 _,截断,避免路径穿越/超长。 */
14
- export function safeKey(key) {
15
- return key.replace(/[^\w.-]+/g, "_").replace(/^[-.]+/, "").slice(0, 80) || "default";
16
- }
17
- /** Stable, collision-resistant single path component for server-provided opaque identifiers. */
18
- export function opaqueKey(key) {
19
- const readable = safeKey(key).slice(0, 40);
20
- const digest = createHash("sha256").update(key, "utf8").digest("hex");
21
- return `${readable}-${digest}`;
22
- }
23
- function workspaceKey(key, mode) {
24
- return mode === "opaque" ? opaqueKey(key) : safeKey(key);
25
- }
26
- async function exists(p) {
27
- try {
28
- await access(p);
29
- return true;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- export async function prepareWorkspace(input) {
36
- const dir = join(input.agentsRoot, input.handle);
37
- const crewDir = join(dir, ".crew");
38
- await mkdir(crewDir, { recursive: true });
39
- // MEMORY.md:首次创建"索引 + Active Context"骨架,之后由 agent 自己维护
40
- const memoryPath = join(dir, "MEMORY.md");
41
- if (!(await exists(memoryPath))) {
42
- await writeFile(memoryPath, memorySeed(input.handle, input.description), "utf8");
43
- }
44
- const memory = await readFile(memoryPath, "utf8");
45
- // 系统提示词按 execution 隔离;省略 identity 的兼容调用每次使用随机路径。
46
- const promptDir = join(crewDir, "prompts");
47
- await mkdir(promptDir, { recursive: true });
48
- const systemPromptPath = join(promptDir, `${opaqueKey(input.executionId ?? randomUUID())}.md`);
49
- if (input.systemPrompt != null)
50
- await writeFile(systemPromptPath, input.systemPrompt, "utf8");
51
- // crew wrapper:exec 构建后的 CLI;凭证/地址经 env 注入,故 wrapper 极简
52
- const wrapper = join(crewDir, "crew");
53
- await writeFile(wrapper, `#!/bin/sh\nexec node ${JSON.stringify(input.cliPath)} "$@"\n`, "utf8");
54
- await chmod(wrapper, 0o755);
55
- // win32 侧 wrapper:cmd/PowerShell 不认 shebang 脚本,并存 crew.cmd(unix 下无害不会被命中)
56
- await writeFile(join(crewDir, "crew.cmd"), `@echo off\r\nnode ${JSON.stringify(input.cliPath)} %*\r\n`, "utf8");
57
- // 每个 agent 独立的 XDG 配置根:隔离第三方 CLI 凭证,避免 agent 之间互相串号
58
- const homeDir = join(dir, ".home");
59
- await mkdir(join(homeDir, ".config"), { recursive: true });
60
- await mkdir(join(homeDir, ".local", "share"), { recursive: true });
61
- await mkdir(join(homeDir, ".cache"), { recursive: true });
62
- // 每任务隔离的运行目录(并行运行互不干扰的 cwd)+ per-task work-log。
63
- // 无 taskKey(罕见)时回退到共享 dir(单运行旧行为)。
64
- let runDir = dir;
65
- let workLogPath = join(dir, "tasks", "default", "work-log.md");
66
- if (input.taskKey) {
67
- runDir = join(dir, "tasks", workspaceKey(input.taskKey, input.keyMode));
68
- await mkdir(runDir, { recursive: true });
69
- workLogPath = join(runDir, "work-log.md");
70
- }
71
- const workLog = (await exists(workLogPath)) ? await readFile(workLogPath, "utf8") : "";
72
- // resumeKey 可跨不同 task cwd 维持同一底层会话;协议键用 opaque 映射,legacy 保持 safeKey。
73
- const sessionDir = input.resumeKey
74
- ? join(crewDir, "sessions", workspaceKey(input.resumeKey, input.keyMode))
75
- : runDir;
76
- if (input.resumeKey)
77
- await mkdir(sessionDir, { recursive: true });
78
- let agentSessionId = null;
79
- let sessionResume = false;
80
- if (input.taskKey || input.resumeKey) {
81
- const sessionPath = join(sessionDir, ".session");
82
- if (await exists(sessionPath)) {
83
- agentSessionId = (await readFile(sessionPath, "utf8")).trim() || null;
84
- sessionResume = !!agentSessionId;
85
- }
86
- if (!agentSessionId) {
87
- agentSessionId = randomUUID();
88
- await writeFile(sessionPath, agentSessionId, "utf8");
89
- }
90
- }
91
- return {
92
- dir,
93
- crewDir,
94
- systemPromptPath,
95
- memory,
96
- homeDir,
97
- runDir,
98
- workLogPath,
99
- workLog,
100
- agentSessionId,
101
- sessionResume,
102
- sessionDir,
103
- };
104
- }
105
- /**
106
- * 冷启动时轮换会话 id:写入新 uuid 到 <runDir>/.session 并返回。
107
- * 已有会话但本轮决定不续用(warm 窗口过期 / CREW_RESUME=off)时调用——起一个全新会话,
108
- * 避免拿已存在的 id 走 `--session-id`(claude 会判定 id 冲突),同时保持「一线程一(当前)会话」。
109
- */
110
- export async function rotateAgentSession(sessionDir) {
111
- const id = randomUUID();
112
- await writeFile(join(sessionDir, ".session"), id, "utf8");
113
- return id;
114
- }
115
- /**
116
- * MEMORY.md 种子骨架:分层记忆的"索引 + Active Context"结构。
117
- * 第一次准备工作区时写入;之后 agent 自己维护(系统提示词里有协议)。
118
- * 建 agent 时填了 description,则用它种子化 ## Role(否则留占位符,由 agent 自填)。
119
- */
120
- function memorySeed(handle, description) {
121
- const role = description?.trim()
122
- ? description.trim()
123
- : "(Who you are and what you're responsible for. Keep it to a few lines.)";
124
- return `# ${handle}
125
-
126
- ## Role
127
- ${role}
128
-
129
- ## Core Goals
130
- (What you optimize for.)
131
-
132
- ## Knowledge Index
133
- <!-- The map to your detailed notes. Add a line here whenever you create a note. -->
134
- <!-- e.g. - [Channels](notes/channels.md) — what each channel is for -->
135
- <!-- e.g. - [User Preferences](notes/user-preferences.md) — conventions to follow -->
136
-
137
- ## Active Context
138
- <!-- Running log of what you're doing now: in-progress tasks, next steps, what you owe whom.
139
- Write an entry here BEFORE a long task so you can resume after sleep/compaction. -->
140
-
141
- ---
142
- How to maintain this file:
143
- - This is the FIRST file read on every startup (including after context compaction).
144
- - Keep it self-sufficient: reading only this file should tell you who you are, what you
145
- know (and which note to read for detail), what you're working on, and what you owe.
146
- - Put details in notes/<topic>.md; keep this file an index + active context.
147
- `;
148
- }