@nowcrew/daemon 0.6.102-beta.2 → 0.6.102-beta.4
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.
- package/README.md +20 -16
- package/dist/automatic-daemon-installer.js +15 -11
- package/dist/automatic-service-capture.js +27 -0
- package/dist/computer-main.js +0 -0
- package/dist/main.js +0 -0
- package/dist/managed-service-lifecycle.js +10 -0
- package/dist/project-skills/execution-projection.js +4 -5
- package/dist/project-skills/reconciler.js +8 -9
- package/dist/project-skills/scanner.js +9 -2
- package/dist/project-skills/source-directory.js +13 -0
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -434,23 +434,27 @@ path-free inventory and logical `(projectId, skillName)` bindings. The local pat
|
|
|
434
434
|
while an add command is forwarded to the selected online Computer; it is not written to the workspace
|
|
435
435
|
database, structured logs, inventory frames, or responses. Project Skills are disabled on Windows.
|
|
436
436
|
|
|
437
|
-
|
|
437
|
+
Skill entries may be real directories or directory symlinks, including relative, absolute, chained,
|
|
438
|
+
and shared directories outside the project. Only direct, non-hidden entries are scanned. Broken,
|
|
439
|
+
cyclic, inaccessible, and non-directory links count as invalid Skills without hiding healthy entries;
|
|
440
|
+
the existing frontmatter, size, name-conflict, and inventory limits apply to linked Skills too.
|
|
441
|
+
|
|
442
|
+
Each execution projects its binding set into a private Runtime discovery directory:
|
|
438
443
|
|
|
439
444
|
```text
|
|
440
|
-
<agentsRoot>/<handle>/.
|
|
441
|
-
<agentsRoot>/<handle>/.crew/claude-skills/.claude/skills/<name> # Claude symlink
|
|
445
|
+
<agentsRoot>/<handle>/.crew/project-skills/exec-<executionId>/runtime/.claude/skills/<name>
|
|
442
446
|
```
|
|
443
447
|
|
|
444
|
-
The
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
+
The scanner retains the entry path. Binding checks and execution startup resolve its current real
|
|
449
|
+
directory and check for `SKILL.md`; missing sources warn and are omitted without blocking other work.
|
|
450
|
+
Each execution links to that resolved directory, so retargeting an entry affects subsequent executions
|
|
451
|
+
while active executions keep their original target. Source file edits remain live. The projection is
|
|
452
|
+
removed after the runtime process tree stops; source directories and user-created links are preserved.
|
|
453
|
+
These are ordinary writable symlinks, not snapshots or a sandbox: an Agent running as the daemon user
|
|
454
|
+
can modify the source Skill through them. That write-through risk is intentionally accepted.
|
|
448
455
|
|
|
449
|
-
Codex
|
|
450
|
-
|
|
451
|
-
root and adds it to Codex `project_root_markers`, so upward discovery reaches `.agents/skills` without
|
|
452
|
-
changing the task cwd. Claude receives
|
|
453
|
-
`--add-dir <agentsRoot>/<handle>/.crew/claude-skills`; Claude treats those Skills as `projectSettings`,
|
|
456
|
+
Codex registers the execution's `runtime/.claude/skills` through `skills/extraRoots/set`. Claude receives
|
|
457
|
+
the execution's `runtime` directory through `--add-dir`; Claude treats those Skills as `projectSettings`,
|
|
454
458
|
so a machine policy that disables project settings also disables this source even when the projection is
|
|
455
459
|
healthy.
|
|
456
460
|
|
|
@@ -467,10 +471,10 @@ scope is merged. The policy version in Codex's session fingerprint cold-starts o
|
|
|
467
471
|
once, then subsequent runs can resume normally. Explicit `shell_environment_policy.set` entries, shell
|
|
468
472
|
startup scripts and Agent notes remain separate configuration; this change does not correct them.
|
|
469
473
|
|
|
470
|
-
Binding changes
|
|
471
|
-
complete binding set for every Agent assigned to that Computer, including empty sets
|
|
472
|
-
|
|
473
|
-
|
|
474
|
+
Binding changes are checked immediately when the Computer is online. On reconnect the server sends the
|
|
475
|
+
complete binding set for every Agent assigned to that Computer, including empty sets. Each execution
|
|
476
|
+
uses its server-snapshotted binding set and revalidates local source paths immediately before Runtime
|
|
477
|
+
launch. Skill file content changes
|
|
474
478
|
are visible through the symlink immediately; adding, deleting, renaming, or changing frontmatter requires
|
|
475
479
|
a rescan. Web descriptions remain at the last inventory value until that rescan.
|
|
476
480
|
|
|
@@ -6,7 +6,8 @@ import { assertProfileAgentsRootUnique, listProfiles, loadProfile, MachineTokenS
|
|
|
6
6
|
import { buildServiceSpec, captureExactService, hardenWindowsProfile, replaceExactService, restoreExactService, serviceAction, serviceStatus, systemCommandRunner, uninstallService, } from "./computer-service.js";
|
|
7
7
|
import { daemonGlobalInstallation } from "./daemon-installation.js";
|
|
8
8
|
import { buildManagedServiceRecord, installManagedService, uninstallManagedService, } from "./managed-service-lifecycle.js";
|
|
9
|
-
import {
|
|
9
|
+
import { readManagedServiceRegistry, } from "./managed-service-registry.js";
|
|
10
|
+
import { captureManagedServiceForSetup } from "./automatic-service-capture.js";
|
|
10
11
|
import { resolveAutomaticInstallTarget, } from "./automatic-install-target.js";
|
|
11
12
|
import { acquireDaemonInstallationLease, } from "./daemon-installation-lease.js";
|
|
12
13
|
import { daemonVersion } from "./machine-info.js";
|
|
@@ -80,7 +81,6 @@ function defaultDependencies() {
|
|
|
80
81
|
},
|
|
81
82
|
captureService: async (spec, target) => {
|
|
82
83
|
if (platform !== "win32") {
|
|
83
|
-
managedRecords = await readManagedServiceRegistry({ userHome, localHome: localHomeForTarget(target, platform) });
|
|
84
84
|
const entryPath = spec.daemonCommand[1];
|
|
85
85
|
const installation = daemonGlobalInstallation(entryPath, platform);
|
|
86
86
|
if (installation === null) {
|
|
@@ -94,14 +94,13 @@ function defaultDependencies() {
|
|
|
94
94
|
entryPath,
|
|
95
95
|
...installation,
|
|
96
96
|
});
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
97
|
+
const captured = await captureManagedServiceForSetup({
|
|
98
|
+
spec, record: candidate, runner,
|
|
99
|
+
registry: { userHome, localHome: localHomeForTarget(target, platform) },
|
|
100
|
+
});
|
|
101
|
+
managedRecords = captured.managedRecords;
|
|
102
|
+
previousManagedRecord = captured.previousManagedRecord;
|
|
103
|
+
return captured.snapshot;
|
|
105
104
|
}
|
|
106
105
|
return captureExactService(spec, runner);
|
|
107
106
|
},
|
|
@@ -175,7 +174,12 @@ function defaultDependencies() {
|
|
|
175
174
|
? localHome
|
|
176
175
|
: localHomeForNpmPrefix(previousManagedRecord.npmPrefix, platform);
|
|
177
176
|
const current = (await readManagedServiceRegistry({ userHome, localHome: restoreLocalHome })).find((record) => record.serviceId === spec.id);
|
|
178
|
-
|
|
177
|
+
const onlyHashChanged = current !== undefined && previousManagedRecord !== undefined
|
|
178
|
+
&& JSON.stringify({ ...current, descriptorSha256: previousManagedRecord.descriptorSha256 })
|
|
179
|
+
=== JSON.stringify(previousManagedRecord);
|
|
180
|
+
// Preflight may have captured the exact descriptor while leaving a stale
|
|
181
|
+
// registry hash untouched. Let installManagedService reconcile it in place.
|
|
182
|
+
if (current !== undefined && !onlyHashChanged && JSON.stringify(current) !== JSON.stringify(previousManagedRecord)) {
|
|
179
183
|
await uninstallManagedService({
|
|
180
184
|
spec,
|
|
181
185
|
record: current,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { captureExactService } from "./computer-service.js";
|
|
2
|
+
import { ManagedServiceConflictError, ManagedServiceRegistryError, managedServiceConflict, managedServiceIdentityMatches, readManagedServiceRegistry, } from "./managed-service-registry.js";
|
|
3
|
+
/** Read-only preflight; keep the record needed to restore the captured service. */
|
|
4
|
+
export async function captureManagedServiceForSetup(input) {
|
|
5
|
+
const managedRecords = await readManagedServiceRegistry(input.registry);
|
|
6
|
+
const { generation: _generation, createdAt: _createdAt, ...expected } = input.record;
|
|
7
|
+
const registered = managedRecords.find((record) => managedServiceIdentityMatches(record, {
|
|
8
|
+
...expected, descriptorSha256: record.descriptorSha256,
|
|
9
|
+
}));
|
|
10
|
+
if (registered === undefined) {
|
|
11
|
+
const conflict = managedServiceConflict(managedRecords, input.record);
|
|
12
|
+
if (conflict !== null) {
|
|
13
|
+
throw new ManagedServiceConflictError(conflict.resource, input.record, conflict.owner);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const snapshot = await captureExactService(input.spec, input.runner);
|
|
17
|
+
if (registered !== undefined && registered.descriptorSha256 !== expected.descriptorSha256
|
|
18
|
+
&& (!snapshot.installed || !snapshot.exact)) {
|
|
19
|
+
throw new ManagedServiceRegistryError(`Installed descriptor for '${input.spec.id}' does not match the requested identity`);
|
|
20
|
+
}
|
|
21
|
+
// A stale hash may be reconciled later under the registry lock. Rollback must
|
|
22
|
+
// refer to the descriptor we actually captured, not the stale registry hash.
|
|
23
|
+
const previousManagedRecord = registered === undefined ? undefined : {
|
|
24
|
+
...registered, descriptorSha256: expected.descriptorSha256,
|
|
25
|
+
};
|
|
26
|
+
return { managedRecords, previousManagedRecord, snapshot };
|
|
27
|
+
}
|
package/dist/computer-main.js
CHANGED
|
File without changes
|
package/dist/main.js
CHANGED
|
File without changes
|
|
@@ -103,6 +103,16 @@ export async function installManagedService(input) {
|
|
|
103
103
|
&& record.daemonHome === input.record.daemonHome);
|
|
104
104
|
if (registered !== undefined && sameManagedResource(registered, input.record)) {
|
|
105
105
|
const current = await readServiceDescriptor(input.spec);
|
|
106
|
+
// Descriptor replacement and registry commit can be interrupted separately.
|
|
107
|
+
// Adopt only the exact requested descriptor with all resource fields intact.
|
|
108
|
+
if (current === requestedDescriptor) {
|
|
109
|
+
assertRecordDescribesSpec(input);
|
|
110
|
+
await ensureServiceEnabled(input.spec, input.runner);
|
|
111
|
+
await replace(services.map((record) => record === registered
|
|
112
|
+
? { ...record, descriptorSha256: expectedDescriptorHash }
|
|
113
|
+
: record));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
106
116
|
if (current === null || serviceDescriptorSha256(current) !== registered.descriptorSha256) {
|
|
107
117
|
throw new ManagedServiceRegistryError(`Installed descriptor for '${input.spec.id}' does not match its registry record`);
|
|
108
118
|
}
|
|
@@ -85,11 +85,10 @@ export async function materializeExecutionProjection(input) {
|
|
|
85
85
|
continue;
|
|
86
86
|
let projected;
|
|
87
87
|
try {
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!sourceExists)
|
|
88
|
+
// 源路径已由 reconciler 解析;拒绝解析后消失、变成文件或被替换为链接的目录。
|
|
89
|
+
// POSIX symlink() 本身允许断链,不能用“创建链接成功”代替源目录检查。
|
|
90
|
+
const source = await lstat(record.sourcePath).catch(() => null);
|
|
91
|
+
if (!source?.isDirectory() || source.isSymbolicLink())
|
|
93
92
|
throw new ExecutionProjectionError("link_failed");
|
|
94
93
|
projected = await project(record.sourcePath, join(root.codexSkillRoot, record.skillName), platform);
|
|
95
94
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project Skill 解析 + 执行编排。
|
|
3
|
-
* reconcile: server
|
|
3
|
+
* reconcile: server 同步绑定时只读取"哪些 skill 在本机可用",不写入投影。
|
|
4
4
|
* prepareAndLaunch: 为这一次 execution 建独占投影目录 → 启动 runtime → 进程树确认退出后删除。
|
|
5
5
|
* 没有共享目录,所以没有锁、租约、manifest、GC。ownership 未确认时目录保留,交给启动 sweep。
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { stat } from "node:fs/promises";
|
|
8
8
|
import { join, resolve, sep } from "node:path";
|
|
9
9
|
import { ExecutionProjectionError, materializeExecutionProjection, removeExecutionProjection, } from "./execution-projection.js";
|
|
10
10
|
import { projectSkillResolutionRecords } from "./scanner.js";
|
|
11
|
+
import { resolveProjectSkillDirectory } from "./source-directory.js";
|
|
11
12
|
import { compareProjectSkillRefs, } from "./types.js";
|
|
12
13
|
export class ProjectProjectionError extends Error {
|
|
13
14
|
code;
|
|
@@ -46,16 +47,14 @@ const canonicalConflictFreeBindings = (bindings) => {
|
|
|
46
47
|
}
|
|
47
48
|
return Object.freeze(unique);
|
|
48
49
|
};
|
|
49
|
-
/**
|
|
50
|
+
/** 每次从扫描入口解析真实目录,固定本次执行的链接目标;不可用则 warning,不阻断。 */
|
|
50
51
|
const actualResolutionRecords = async (bindings, projects, platform) => Object.freeze(await Promise.all(projectSkillResolutionRecords(bindings, projects, platform).map(async (record) => {
|
|
51
52
|
if (record.mode === "missing" || record.sourcePath === null)
|
|
52
53
|
return record;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (source?.isDirectory() === true && !source.isSymbolicLink() && skillFile?.isFile() === true) {
|
|
58
|
-
return record;
|
|
54
|
+
const directory = await resolveProjectSkillDirectory(record.sourcePath);
|
|
55
|
+
const skillFile = directory === null ? null : await stat(join(directory, "SKILL.md")).catch(() => null);
|
|
56
|
+
if (directory !== null && skillFile?.isFile() === true) {
|
|
57
|
+
return Object.freeze({ ...record, sourcePath: directory });
|
|
59
58
|
}
|
|
60
59
|
return Object.freeze({
|
|
61
60
|
projectId: record.projectId,
|
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { compareProjectSkillRefs, isProjectSkillName, MAX_MACHINE_PROJECT_SKILLS, MAX_PROJECT_SKILL_DESCRIPTION_LENGTH, MAX_PROJECT_SKILL_FILE_BYTES, MAX_PROJECT_SKILLS_PER_PROJECT, } from "./types.js";
|
|
4
4
|
import { parseSkillFrontmatter } from "../skill-frontmatter.js";
|
|
5
5
|
import { normalizeProjectSkillResolutionRecords } from "./resolution-records.js";
|
|
6
|
+
import { resolveProjectSkillDirectory } from "./source-directory.js";
|
|
6
7
|
const unavailable = (projectId, scannedAt, errorCode) => Object.freeze({
|
|
7
8
|
inventory: Object.freeze({
|
|
8
9
|
projectId,
|
|
@@ -45,10 +46,15 @@ export async function scanProject(project, now = () => new Date()) {
|
|
|
45
46
|
let invalidSkillCount = 0;
|
|
46
47
|
const candidates = [];
|
|
47
48
|
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
48
|
-
if (entry.name.startsWith(".") || !entry.isDirectory())
|
|
49
|
+
if (entry.name.startsWith(".") || (!entry.isDirectory() && !entry.isSymbolicLink()))
|
|
49
50
|
continue;
|
|
50
51
|
const sourcePath = join(skillsRoot, entry.name);
|
|
51
|
-
const
|
|
52
|
+
const directory = await resolveProjectSkillDirectory(sourcePath);
|
|
53
|
+
if (directory === null) {
|
|
54
|
+
invalidSkillCount += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const skillPath = join(directory, "SKILL.md");
|
|
52
58
|
const skillStat = await stat(skillPath).catch(() => null);
|
|
53
59
|
if (!skillStat?.isFile() || skillStat.size > MAX_PROJECT_SKILL_FILE_BYTES) {
|
|
54
60
|
invalidSkillCount += 1;
|
|
@@ -70,6 +76,7 @@ export async function scanProject(project, now = () => new Date()) {
|
|
|
70
76
|
invalidSkillCount += 1;
|
|
71
77
|
continue;
|
|
72
78
|
}
|
|
79
|
+
// 保留入口:执行前重新解析,才能识别链接删除或改指。
|
|
73
80
|
candidates.push(Object.freeze({ name, description, sourcePath }));
|
|
74
81
|
}
|
|
75
82
|
const counts = new Map();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { lstat, realpath } from "node:fs/promises";
|
|
2
|
+
/** 跟随用户放置的源链接;只在本次操作中使用真实目录,不把它缓存为扫描入口。 */
|
|
3
|
+
export async function resolveProjectSkillDirectory(sourcePath) {
|
|
4
|
+
try {
|
|
5
|
+
const directory = await realpath(sourcePath);
|
|
6
|
+
const info = await lstat(directory);
|
|
7
|
+
return info.isDirectory() && !info.isSymbolicLink() ? directory : null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
// 断链、循环或权限不足只使这个 Skill 不可用,不影响其它 Skill。
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nowcrew/daemon",
|
|
3
|
-
"version": "0.6.102-beta.
|
|
3
|
+
"version": "0.6.102-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,6 +18,14 @@
|
|
|
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
|
+
},
|
|
21
29
|
"dependencies": {
|
|
22
30
|
"@agentclientprotocol/sdk": "1.2.1",
|
|
23
31
|
"@nowcrew/cli": "0.4.17",
|
|
@@ -39,12 +47,5 @@
|
|
|
39
47
|
"tsx": "^4.19.0",
|
|
40
48
|
"typescript": "^5.6.0",
|
|
41
49
|
"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"
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
}
|