@nowcrew/daemon 0.6.87-beta.2 → 0.6.87-beta.3

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.
@@ -0,0 +1,28 @@
1
+ import { WebSocket } from "ws";
2
+ import { daemonCapabilityBindings, } from "../machine-info.js";
3
+ import { prepareProjectSkillConnectionCapabilities, } from "./capability.js";
4
+ export function createProjectSkillConnectionCapabilityProvider(input) {
5
+ return async () => daemonCapabilityBindings(input.platform, await prepareProjectSkillConnectionCapabilities(input));
6
+ }
7
+ export function createProjectSkillMachineHelloPublisher(input) {
8
+ let latest = null;
9
+ let latestSocket = null;
10
+ const republish = () => {
11
+ if (latest === null || latestSocket?.readyState !== WebSocket.OPEN)
12
+ return;
13
+ const hello = input.effective(latest, input.status());
14
+ try {
15
+ latestSocket.send(JSON.stringify(hello));
16
+ input.onSent(hello);
17
+ }
18
+ catch { /* 非 OPEN,忽略 */ }
19
+ };
20
+ return Object.freeze({
21
+ publish: (hello, socket) => {
22
+ latest = hello;
23
+ latestSocket = socket;
24
+ republish();
25
+ },
26
+ republish,
27
+ });
28
+ }
@@ -0,0 +1,37 @@
1
+ import { createExecutionJournal } from "../execution-journal.js";
2
+ import { reconcileExecutionJournal } from "../execution-recovery.js";
3
+ import { dslog, flushSlog } from "../slog.js";
4
+ export async function initializeProjectSkillProtectedExecutionJournal(input) {
5
+ return input.startup.initializeAfterLeaseProtection(input.config.agentsRoot, async (snapshot) => {
6
+ input.protectedExecutionIds.clear();
7
+ for (const executionId of snapshot)
8
+ input.protectedExecutionIds.add(executionId);
9
+ const journal = input.injectedJournal ?? createExecutionJournal(input.config.agentsRoot, {
10
+ protectedExecutionIds: () => input.protectedExecutionIds,
11
+ onOperationTiming: (event) => {
12
+ if (event.operation !== "mark_runtime_ready"
13
+ && event.queueWaitMs < 250
14
+ && event.operationMs < 250)
15
+ return;
16
+ dslog("execution.journal_operation", "execution journal 操作完成", {
17
+ level: event.outcome === "succeeded" ? "INFO" : "ERROR",
18
+ execution_id: event.executionId,
19
+ operation: event.operation,
20
+ outcome: event.outcome,
21
+ queue_wait_ms: event.queueWaitMs,
22
+ operation_ms: event.operationMs,
23
+ total_ms: event.queueWaitMs + event.operationMs,
24
+ });
25
+ },
26
+ });
27
+ await reconcileExecutionJournal(journal, {
28
+ agentsRoot: input.config.agentsRoot,
29
+ serverUrl: input.config.serverUrl,
30
+ ...(input.profileName === undefined ? {} : { profileName: input.profileName }),
31
+ log: dslog,
32
+ flush: flushSlog,
33
+ writeStderr: (line) => process.stderr.write(line),
34
+ });
35
+ return journal;
36
+ });
37
+ }
package/dist/prompt.js CHANGED
@@ -279,6 +279,9 @@ ${newThreadRule}
279
279
 
280
280
  ## Skill 指定
281
281
  - 如果用户输入 \`/xxxx\`、或消息开头/正文中有形如 \`/skill-name\` 的片段,优先判断用户是否在精准指定某个 skill。若该 skill 可用且适合当前任务,按该 skill 的工作流处理;若名称不明确或不可用,先说明不确定并按最接近的可用能力处理。`;
282
+ const memoryWritePolicy = ctx.localMemoryV2Enabled
283
+ ? "- **V2 结构化本地记忆**:普通任务不得直接编辑共享 `$CREW_HOME/MEMORY.md` 或 notes/;即使用户明确要求长期记忆,也只记录到 `$CREW_TASK_LOG`,由任务结束时的 memory-prune 结构化提交。只有 memory-prune 收尾提示明确要求写入 daemon result 文件时才提交候选。"
284
+ : "- **当前请求明确要求更新或记住长期记忆,明确表达需要跨后续任务持续生效的具体规则、偏好或约束,或当前消息是对本线程紧邻记忆方案的无歧义确认时**,可以按最小范围直接写共享记忆。例如“以后所有测试报告统一按五部分写”属于明确长期意图,即使没有使用“记忆”一词。先读取相关索引和 note,语义已存在时不重复追加,不要把 Agent 自己判断值得记住视为用户授权。";
282
285
  return `你是 "${ctx.handle}",${product}(一个让人类与 AI agent 协作的共享工作区)中的 AI 成员。${product} 为可能运行在不同机器上的人与 agent 提供共享的消息服务。
283
286
 
284
287
  ## 你是谁
@@ -293,7 +296,7 @@ ${newThreadRule}
293
296
  ## 并行与记忆(CRITICAL — 防冲突 + 防上下文膨胀)
294
297
  你**可能同时在处理多个任务**(你自己的多个并行进程)。为避免互相覆盖、并保持上下文精简,严格遵守:
295
298
  - **普通任务默认只写两处**:① 本任务的隔离 cwd(代码/草稿);② 本任务的工作日志 **\`$CREW_TASK_LOG\`**(每任务一份,别人不会碰)。默认不要修改共享 \`$CREW_HOME/MEMORY.md\` 或 notes/;只有当前用户明确要求更新或记住长期记忆,或明确表达具体且跨后续任务持续生效的规则、偏好或约束时,才按下方条件写入相关共享文件。在工作日志里记:当前阶段 / 下一步 / 卡在谁 / 关键结论(每条尽量 ≤3 行)。
296
- - **当前请求明确要求更新或记住长期记忆,明确表达需要跨后续任务持续生效的具体规则、偏好或约束,或当前消息是对本线程紧邻记忆方案的无歧义确认时**,可以按最小范围直接写共享记忆。例如“以后所有测试报告统一按五部分写”属于明确长期意图,即使没有使用“记忆”一词。先读取相关索引和 note,语义已存在时不重复追加,不要把 Agent 自己判断值得记住视为用户授权。
299
+ ${memoryWritePolicy}
297
300
  - 本节的直接更新共享记忆和相关 task 流转仅适用于用户消息触发的普通交互执行。memory_prune 和 scheduled 执行只遵守各自唤醒指令,不得依据本节认领、创建、重开或推进 task。
298
301
  ${memoryTaskReadRule}
299
302
  - 普通交互执行将写共享记忆时,使用当前线程唯一的普通 task:已有非终态 task 时先按归属规则确保当前 Agent 成功认领;当前线程没有 task 时先创建并认领一个普通 task;已有 task 为 done/closed 时不得由 Agent 重开,done 报告当前轻量方案无法安全复用终态 task,closed 保持人工终态。遇到终态或归属问题时报告冲突且不得创建第二个 task 或新的任务类型。完成写入后,只有任务本身的全部工作已完成时才推进终态以触发 prune。
package/dist/runner.js CHANGED
@@ -30,6 +30,7 @@ export async function runAgent(config, input, onActivity = defaultPrint, onConso
30
30
  }), dependencies.cancellation);
31
31
  const providerConfig = credential.config ?? {};
32
32
  const runtime = runtimeName(providerConfig.runtime ?? config.runtimeBin);
33
+ const localMemoryV2Enabled = config.localMemoryV2Handles?.has(input.handle) === true;
33
34
  const reasoning = ReasoningSchema.safeParse(providerConfig.reasoning);
34
35
  const baseWake = input.wake ?? buildWakePrompt(input.channelId);
35
36
  const executionId = input.runId ?? `legacy-${randomUUID()}`;
@@ -61,6 +62,7 @@ export async function runAgent(config, input, onActivity = defaultPrint, onConso
61
62
  memory: capMemoryForInject(workspace.memory),
62
63
  ...(resuming ? {} : { workLog: capWorkLogForInject(workspace.workLog) }),
63
64
  collaborationToolsEnabled: config.codexCollaborationTools && runtime === "codex",
65
+ localMemoryV2Enabled,
64
66
  }),
65
67
  wakePrompt: ({ resuming, rotatedForBudget, nearBudget }) => {
66
68
  const distillHint = nearBudget
@@ -111,7 +113,7 @@ export async function runAgent(config, input, onActivity = defaultPrint, onConso
111
113
  softTokens: config.sessionSoftTokens,
112
114
  maxTurns: config.sessionMaxTurns,
113
115
  },
114
- localMemoryV2Enabled: config.localMemoryV2Handles?.has(input.handle) === true,
116
+ localMemoryV2Enabled,
115
117
  }, {
116
118
  onActivity,
117
119
  onConsole,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowcrew/daemon",
3
- "version": "0.6.87-beta.2",
3
+ "version": "0.6.87-beta.3",
4
4
  "type": "module",
5
5
  "description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
6
6
  "license": "Apache-2.0",
@@ -16,6 +16,14 @@
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
19
+ "scripts": {
20
+ "daemon": "pnpm --filter @nowcrew/cli build && tsx src/main.ts",
21
+ "build": "tsc -p tsconfig.json",
22
+ "codex-home:migrate": "tsx src/runtimes/codex-home-migration-cli.ts",
23
+ "prepublishOnly": "pnpm build && node ../scripts/daemon-release-artifact.mjs --strict-registry",
24
+ "test": "vitest run",
25
+ "typecheck": "tsc --noEmit"
26
+ },
19
27
  "dependencies": {
20
28
  "@agentclientprotocol/sdk": "1.2.1",
21
29
  "@nowcrew/cli": "0.4.13",
@@ -36,12 +44,5 @@
36
44
  "tsx": "^4.19.0",
37
45
  "typescript": "^5.6.0",
38
46
  "vitest": "^2.1.0"
39
- },
40
- "scripts": {
41
- "daemon": "pnpm --filter @nowcrew/cli build && tsx src/main.ts",
42
- "build": "tsc -p tsconfig.json",
43
- "codex-home:migrate": "tsx src/runtimes/codex-home-migration-cli.ts",
44
- "test": "vitest run",
45
- "typecheck": "tsc --noEmit"
46
47
  }
47
- }
48
+ }