@nowcrew/daemon 0.6.98-beta.7 → 0.6.98-beta.8

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 (35) hide show
  1. package/README.md +20 -16
  2. package/dist/automatic-daemon-installer.js +15 -11
  3. package/dist/automatic-service-capture.js +27 -0
  4. package/dist/computer-main.js +0 -0
  5. package/dist/execution-journal-lock.js +51 -2
  6. package/dist/execution-protocol.js +2 -0
  7. package/dist/execution-runner.js +19 -13
  8. package/dist/host-execution-coordinator.js +10 -0
  9. package/dist/local-executor.js +8 -1
  10. package/dist/machine-info.js +4 -1
  11. package/dist/machine-runtime-environment.js +1 -0
  12. package/dist/main.js +0 -0
  13. package/dist/managed-service-lifecycle.js +10 -0
  14. package/dist/project-skills/execution-projection.js +4 -5
  15. package/dist/project-skills/reconciler.js +8 -9
  16. package/dist/project-skills/scanner.js +9 -2
  17. package/dist/project-skills/source-directory.js +13 -0
  18. package/dist/runtime-observation.js +219 -0
  19. package/dist/runtime-tool-update-bridge.js +126 -0
  20. package/dist/runtime-tool-update-controller.js +151 -0
  21. package/dist/runtime-tool-update-protocol.js +24 -0
  22. package/dist/runtime-tool-update-serve.js +54 -0
  23. package/dist/runtimes/claude-observation-runner.js +55 -0
  24. package/dist/runtimes/claude-thread-runner.js +17 -3
  25. package/dist/runtimes/claude.js +5 -3
  26. package/dist/runtimes/codex-app-server-runner.js +16 -2
  27. package/dist/runtimes/deepseek-harness-runner.js +16 -0
  28. package/dist/runtimes/kimi-acp-runner.js +19 -0
  29. package/dist/runtimes/observation-context.js +18 -0
  30. package/dist/runtimes/observation-mapper.js +314 -0
  31. package/dist/runtimes/opencode-runner.js +18 -4
  32. package/dist/runtimes/pi-runner.js +17 -1
  33. package/dist/serve.js +9 -0
  34. package/dist/token.js +4 -1
  35. package/package.json +9 -10
@@ -6,11 +6,24 @@ import spawn from "cross-spawn";
6
6
  import { augmentedPath } from "../runtime-path.js";
7
7
  import { prepareThreadDelivery } from "../thread-input-delivery.js";
8
8
  import { buildPiArgs, createPiEventDecoder } from "./pi.js";
9
+ import { createRuntimeObservationCapture } from "../runtime-observation.js";
10
+ import { createObservationMapper } from "./observation-mapper.js";
9
11
  async function readInput() { process.stdin.setEncoding("utf8"); let text = ""; for await (const chunk of process.stdin)
10
12
  text += String(chunk); return JSON.parse(text); }
11
13
  async function emit(event) { if (process.stdout.write(`${JSON.stringify(event)}\n`))
12
14
  return; await once(process.stdout, "drain"); }
13
15
  export async function runPi(bin) {
16
+ const capture = createRuntimeObservationCapture("pi");
17
+ const observer = createObservationMapper("pi", capture);
18
+ try {
19
+ return await runPiObserved(bin, observer);
20
+ }
21
+ finally {
22
+ observer.finish();
23
+ capture.finish();
24
+ }
25
+ }
26
+ async function runPiObserved(bin, observer) {
14
27
  const input = await readInput();
15
28
  // Pi 不持久化原生会话,每轮都须在启动模型前补齐当前线程快照。
16
29
  const delivery = await prepareThreadDelivery({
@@ -27,11 +40,14 @@ export async function runPi(bin) {
27
40
  let inputError;
28
41
  child.stdin.on("error", error => { inputError = error; });
29
42
  // Pi print 模式读取 stdin;完整线程历史不能塞进受长度限制的 argv。
43
+ observer.context({ systemPrompt: input.systemPrompt, prompt: delivery.prompt });
30
44
  child.stdin.end(delivery.prompt);
31
45
  const decoder = createPiEventDecoder();
32
46
  for await (const line of createInterface({ input: child.stdout })) {
33
47
  try {
34
- for (const event of decoder.push(JSON.parse(line)))
48
+ const raw = JSON.parse(line);
49
+ observer.observe(raw);
50
+ for (const event of decoder.push(raw))
35
51
  await emit(event);
36
52
  }
37
53
  catch { }
package/dist/serve.js CHANGED
@@ -48,6 +48,7 @@ import { initializedProjectSkillsReconciler } from "./project-skills/initialized
48
48
  import { parseMemoryPruneTraceId } from "./memory-prune-diagnostics.js";
49
49
  import { probeRuntimeHealth } from "./runtime-health.js";
50
50
  import { createServeMarketplace } from "./marketplace-serve.js";
51
+ import { createServeRuntimeToolUpdates } from "./runtime-tool-update-serve.js";
51
52
  import { buildControlPlaneUrl } from "./control-plane-url.js";
52
53
  import { resolveDaemonLocalStateRootFromEnv } from "./daemon-local-home.js";
53
54
  import { bindStorageServerIdentity, createStorageIdentityAdmission, } from "./storage-serve-adapter.js";
@@ -210,6 +211,7 @@ export function serve(config, opts = {}) {
210
211
  onError: (code, context) => dslog("execution.runtime_detection_failed", "机器环境或 runtime 探测失败", { level: "ERROR", error_code: code, ...context }),
211
212
  });
212
213
  machineRuntime.prewarm();
214
+ const runtimeToolUpdates = createServeRuntimeToolUpdates(config, localSlots, hostCoordinator, async () => ({ ...(await machineRuntime.provider.acquire()).env }), () => machineRuntime.refresh());
213
215
  const initializedProjectSkills = initializedProjectSkillsReconciler(() => projectSkillsController.ensureScanned(), projectSkillsReconciler);
214
216
  const configuredCapabilities = opts.machineInfo?.capabilities ?? daemonCapabilities(process.platform);
215
217
  const prepareCapabilities = async () => daemonCapabilityBindings(process.platform, [...configuredCapabilities, ...await managedDaemonCapabilities(updateEligibility)]);
@@ -842,6 +844,12 @@ export function serve(config, opts = {}) {
842
844
  }
843
845
  return;
844
846
  }
847
+ const runtimeUpdateSocket = ws;
848
+ if (runtimeToolUpdates.handle(msg, frame => { try {
849
+ runtimeUpdateSocket?.send(JSON.stringify(frame));
850
+ }
851
+ catch { /* Server reconciles via status. */ } }))
852
+ return;
845
853
  if (marketplace.handle(msg, frame => { try {
846
854
  ws?.send(JSON.stringify(frame));
847
855
  }
@@ -1326,6 +1334,7 @@ export function serve(config, opts = {}) {
1326
1334
  webSocketClosed,
1327
1335
  updateController.drain(),
1328
1336
  marketplace.stop(),
1337
+ runtimeToolUpdates.stop(),
1329
1338
  executionFrameQueue,
1330
1339
  ...executionRuns.values(),
1331
1340
  ...[...legacyRuns.values()].map((run) => run.done),
package/dist/token.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { parseObservabilityPolicy } from "./runtime-observation.js";
1
2
  export async function mintAgentToken(serverUrl, machineToken, handle, displayName, options = {}, fetchImpl = fetch) {
2
3
  const res = await fetchImpl(`${serverUrl}/daemon/agents/token`, {
3
4
  method: "POST",
@@ -19,5 +20,7 @@ export async function mintAgentToken(serverUrl, machineToken, handle, displayNam
19
20
  if (!res.ok || !body?.success || !body.data) {
20
21
  throw new Error(`换取 agent 令牌失败 (HTTP ${res.status}): ${body?.error?.message ?? ""}`);
21
22
  }
22
- return body.data;
23
+ const { observability: rawPolicy, ...credential } = body.data;
24
+ const observability = options.executionId ? parseObservabilityPolicy(rawPolicy) : undefined;
25
+ return { ...credential, ...(observability ? { observability } : {}) };
23
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowcrew/daemon",
3
- "version": "0.6.98-beta.7",
3
+ "version": "0.6.98-beta.8",
4
4
  "type": "module",
5
5
  "description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
6
6
  "license": "Apache-2.0",
@@ -18,14 +18,6 @@
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "scripts": {
22
- "daemon": "pnpm --filter @nowcrew/cli build && tsx src/main.ts",
23
- "build": "tsc -p tsconfig.json",
24
- "prepublishOnly": "pnpm build && node ../scripts/daemon-release-artifact.mjs --strict-registry",
25
- "test": "vitest run",
26
- "test:release-critical": "vitest run test/automatic-daemon-installer.test.ts test/automatic-install-target.test.ts test/automatic-service-migration.test.ts test/computer-cli.test.ts test/computer-service.test.ts test/computer-setup-client.test.ts test/computer-setup-orchestration.test.ts test/computer-setup.test.ts test/daemon-release-version.test.ts test/daemon-update-controller.test.ts test/daemon-update-eligibility.test.ts test/daemon-updater.test.ts test/execution-protocol.test.ts test/machine-info.test.ts --maxWorkers=2 --minWorkers=1",
27
- "typecheck": "tsc --noEmit"
28
- },
29
21
  "dependencies": {
30
22
  "@agentclientprotocol/sdk": "1.2.1",
31
23
  "@nowcrew/cli": "0.4.17",
@@ -47,5 +39,12 @@
47
39
  "tsx": "^4.19.0",
48
40
  "typescript": "^5.6.0",
49
41
  "vitest": "^2.1.0"
42
+ },
43
+ "scripts": {
44
+ "daemon": "pnpm --filter @nowcrew/cli build && tsx src/main.ts",
45
+ "build": "tsc -p tsconfig.json",
46
+ "test": "vitest run",
47
+ "test:release-critical": "vitest run test/automatic-daemon-installer.test.ts test/automatic-install-target.test.ts test/automatic-service-migration.test.ts test/computer-cli.test.ts test/computer-service.test.ts test/computer-setup-client.test.ts test/computer-setup-orchestration.test.ts test/computer-setup.test.ts test/daemon-release-version.test.ts test/daemon-update-controller.test.ts test/daemon-update-eligibility.test.ts test/daemon-updater.test.ts test/execution-protocol.test.ts test/machine-info.test.ts --maxWorkers=2 --minWorkers=1",
48
+ "typecheck": "tsc --noEmit"
50
49
  }
51
- }
50
+ }