@nowcrew/daemon 0.6.80-beta.2 → 0.6.80-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.
Files changed (31) hide show
  1. package/dist/computer-cli.js +3 -12
  2. package/dist/computer-service.js +12 -0
  3. package/dist/daemon-local-home.js +23 -0
  4. package/dist/daemon-update-eligibility.js +7 -4
  5. package/dist/local-executor.js +7 -10
  6. package/dist/main.js +5 -12
  7. package/dist/managed-service-lifecycle.js +6 -2
  8. package/dist/package-manager-env.js +75 -0
  9. package/dist/project-skills/capability.js +109 -0
  10. package/dist/project-skills/controller-convergence.js +57 -0
  11. package/dist/project-skills/projection-set-switch.js +419 -0
  12. package/dist/project-skills/projection-state-domain.js +170 -0
  13. package/dist/project-skills/projection-state-store.js +842 -0
  14. package/dist/project-skills/projection-state-transaction.js +322 -0
  15. package/dist/project-skills/projection-state.js +3 -0
  16. package/dist/project-skills/runtime-root-bootstrap.js +47 -0
  17. package/dist/project-skills/runtime-root-domain.js +268 -0
  18. package/dist/project-skills/runtime-root-gc.js +293 -0
  19. package/dist/project-skills/runtime-root-lease-artifact.js +46 -0
  20. package/dist/project-skills/runtime-root-leases.js +487 -0
  21. package/dist/project-skills/runtime-root-source-identity.js +60 -0
  22. package/dist/project-skills/runtime-root-startup.js +49 -0
  23. package/dist/project-skills/runtime-root-state-artifact-domain.js +143 -0
  24. package/dist/project-skills/runtime-root-state-index.js +356 -0
  25. package/dist/project-skills/runtime-root-store.js +722 -0
  26. package/dist/project-skills/serve-capability.js +28 -0
  27. package/dist/project-skills/serve-startup.js +37 -0
  28. package/dist/runner.js +1 -1
  29. package/dist/runtime-env.js +21 -0
  30. package/dist/serve.js +1 -1
  31. package/package.json +9 -10
@@ -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/runner.js CHANGED
@@ -12,7 +12,7 @@ import { readBoundImDecisionFile, resetBoundImDecisionFile } from "./bound-im-de
12
12
  import { launchSupervisedRuntime } from "./supervised-runtime.js";
13
13
  import { awaitWithCancellation, } from "./runtime-cancellation.js";
14
14
  export { awaitExit, exitActivity } from "./local-executor.js";
15
- export { sanitizeEnvVars } from "./provider-env.js";
15
+ export { sanitizeEnvVars } from "./runtime-env.js";
16
16
  const ICON = {
17
17
  init: "🟢", text: "💬", reading: "📖", sending: "📨", checking: "🔎",
18
18
  claiming: "📌", crew: "⚙️", tool: "🛠️", tool_result: "↩️", done: "✅", error: "❌",
@@ -0,0 +1,21 @@
1
+ const ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
2
+ export const RESERVED_ENV = new Set([
3
+ "PATH",
4
+ "XDG_CONFIG_HOME",
5
+ "XDG_DATA_HOME",
6
+ "XDG_CACHE_HOME",
7
+ "GH_CONFIG_DIR",
8
+ "CLOUDSDK_CONFIG",
9
+ "NPM_CONFIG_USERCONFIG",
10
+ "YARN_REGISTRY",
11
+ "NPM_CONFIG_ALWAYS_AUTH",
12
+ ]);
13
+ /** 用户自定义环境只能补充普通变量,不能覆盖 daemon 维护的运行时契约。 */
14
+ export function sanitizeEnvVars(raw) {
15
+ if (!raw)
16
+ return {};
17
+ return Object.fromEntries(Object.entries(raw).filter(([key, value]) => typeof value === "string"
18
+ && ENV_KEY_RE.test(key)
19
+ && !key.toUpperCase().startsWith("CREW_")
20
+ && !RESERVED_ENV.has(key.toUpperCase())));
21
+ }
package/dist/serve.js CHANGED
@@ -106,7 +106,7 @@ export function serve(config, opts = {}) {
106
106
  const cancellations = new Map();
107
107
  const legacyRuns = new Map();
108
108
  const updateEligibility = opts.update?.eligibility
109
- ?? (() => detectDaemonUpdateEligibility(opts.profileName));
109
+ ?? (() => detectDaemonUpdateEligibility(opts.profileName, { localHome }));
110
110
  const updateController = createDaemonUpdateController({
111
111
  eligibility: updateEligibility,
112
112
  install: opts.update?.install ?? ((input) => installExactDaemonUpdate({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowcrew/daemon",
3
- "version": "0.6.80-beta.2",
3
+ "version": "0.6.80-beta.3",
4
4
  "type": "module",
5
5
  "description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
6
6
  "license": "Apache-2.0",
@@ -16,14 +16,6 @@
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
- },
27
19
  "dependencies": {
28
20
  "@agentclientprotocol/sdk": "1.2.1",
29
21
  "@nowcrew/cli": "0.4.13",
@@ -44,5 +36,12 @@
44
36
  "tsx": "^4.19.0",
45
37
  "typescript": "^5.6.0",
46
38
  "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"
47
46
  }
48
- }
47
+ }