@nowcrew/daemon 0.6.88 → 0.6.90
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 +66 -4
- package/dist/agent-ability/controller.js +11 -1
- package/dist/agent-ability/git-errors.js +22 -0
- package/dist/agent-ability/materializer.js +21 -10
- package/dist/agent-ability/resolver.js +12 -4
- package/dist/agent-environment-contract.js +55 -0
- package/dist/agent-environment-control.js +24 -0
- package/dist/agent-environment-execution.js +98 -0
- package/dist/agent-environments.js +275 -0
- package/dist/automatic-daemon-installer.js +51 -2
- package/dist/automatic-install-target.js +8 -0
- package/dist/computer-main.js +18 -0
- package/dist/computer-profile.js +17 -4
- package/dist/computer-setup-client.js +318 -0
- package/dist/computer-setup-orchestration.js +203 -0
- package/dist/computer-setup.js +244 -0
- package/dist/config.js +30 -12
- package/dist/console-formatter.js +3 -3
- package/dist/console.js +15 -2
- package/dist/daemon-update-eligibility.js +1 -1
- package/dist/execution-journal.js +9 -6
- package/dist/execution-protocol.js +1 -0
- package/dist/execution-runner.js +13 -8
- package/dist/i18n.js +19 -0
- package/dist/list-models.js +12 -12
- package/dist/local-execution-lease.js +22 -0
- package/dist/local-executor.js +57 -84
- package/dist/local-memory/candidate.js +43 -0
- package/dist/local-memory/index-budget.js +8 -0
- package/dist/local-memory/inventory-cli.js +61 -0
- package/dist/local-memory/inventory-preview.js +159 -0
- package/dist/local-memory/inventory-source.js +159 -0
- package/dist/local-memory/pending-match.js +29 -0
- package/dist/local-memory/pending-query.js +100 -0
- package/dist/local-memory/pending-schema.js +29 -0
- package/dist/local-memory/pending-source.js +126 -0
- package/dist/local-memory/pending.js +34 -84
- package/dist/local-memory/prompt.js +19 -12
- package/dist/local-memory/read-cli.js +97 -12
- package/dist/local-memory/rollout.js +82 -0
- package/dist/local-memory/runtime.js +23 -17
- package/dist/local-memory/work-log-execution.js +31 -0
- package/dist/local-memory/work-log.js +58 -0
- package/dist/local-memory/write.js +27 -58
- package/dist/local-runtime-environment.js +50 -0
- package/dist/machine-environment-cache.js +147 -0
- package/dist/machine-environment-contract.js +10 -0
- package/dist/machine-environment-control.js +27 -0
- package/dist/machine-environment-policy.js +75 -0
- package/dist/machine-environment-process.js +110 -0
- package/dist/machine-info.js +70 -25
- package/dist/machine-runtime-environment.js +189 -0
- package/dist/machine-shell-environment-capture.js +135 -0
- package/dist/machine-windows-environment-capture.js +215 -0
- package/dist/machine-windows-environment-script.js +158 -0
- package/dist/main.js +4 -69
- package/dist/marketplace-command.js +21 -0
- package/dist/marketplace-controller.js +80 -0
- package/dist/marketplace-protocol.js +38 -0
- package/dist/marketplace-remote.js +48 -0
- package/dist/marketplace-runner.js +235 -0
- package/dist/marketplace-serve.js +17 -0
- package/dist/marketplace-source.js +103 -0
- package/dist/message-file-preview.js +246 -0
- package/dist/pre-admission-rejection.js +64 -0
- package/dist/project-skills/execution-adapter.js +3 -2
- package/dist/project-skills/runtime-launch.js +14 -0
- package/dist/provider-env.js +26 -15
- package/dist/runner.js +17 -4
- package/dist/runtime-environment-merge.js +16 -0
- package/dist/runtime-health-handler.js +10 -0
- package/dist/runtime-health.js +3 -1
- package/dist/runtime-path.js +22 -12
- package/dist/runtime-probe.js +35 -6
- package/dist/runtimes/acp-probe-transport.js +69 -0
- package/dist/runtimes/claude-models.js +20 -9
- package/dist/runtimes/deepseek-harness-launch.js +10 -0
- package/dist/runtimes/deepseek-harness-profile.js +92 -0
- package/dist/runtimes/deepseek-harness-runner.js +226 -0
- package/dist/runtimes/deepseek-harness.js +76 -15
- package/dist/runtimes/harness-probe-retry.js +42 -0
- package/dist/runtimes/hermes-models.js +2 -1
- package/dist/runtimes/kimi-acp-runner.js +78 -13
- package/dist/runtimes/opencode.js +2 -2
- package/dist/serve.js +88 -176
- package/dist/server-url.js +25 -0
- package/dist/slog.js +2 -1
- package/dist/storage-identity.js +0 -3
- package/dist/storage-runtime.js +2 -2
- package/dist/storage-serve-adapter.js +6 -72
- package/dist/supervised-runtime.js +17 -2
- package/dist/token.js +0 -1
- package/dist/workspace-control-handler.js +27 -0
- package/dist/workspace-fs.js +66 -15
- package/dist/workspace.js +1 -1
- package/package.json +6 -4
- package/dist/codex-home-launch.js +0 -7
- package/dist/codex-home-mode-controller.js +0 -68
- package/dist/daemon-migration-controller.js +0 -211
- package/dist/daemon-migration-wiring.js +0 -22
- package/dist/runtimes/codex-home-migration-cli.js +0 -26
- package/dist/runtimes/codex-home-migration.js +0 -112
- package/dist/runtimes/codex-home.js +0 -236
- package/dist/storage-control.js +0 -212
- package/dist/storage-copy.js +0 -628
- package/dist/storage-credential-guard.js +0 -21
- package/dist/storage-doctor.js +0 -228
- package/dist/storage-manifest.js +0 -1027
- package/dist/storage-migration-controller.js +0 -440
- package/dist/storage-migration-manifest.js +0 -105
- package/dist/storage-migration-policy.js +0 -100
- package/dist/storage-runtime-controller.js +0 -381
- package/dist/storage-runtime-readiness.js +0 -240
- package/dist/storage-safe-fs.js +0 -302
- package/dist/storage-status-delivery.js +0 -224
- package/dist/storage-status-replay.js +0 -140
- package/dist/storage-target-confirmation.js +0 -129
- package/dist/storage-worker-command.js +0 -37
- package/dist/storage-worker-executor.js +0 -449
- package/dist/storage-worker-handoff.js +0 -151
- package/dist/storage-worker-operation.js +0 -294
- package/dist/storage-worker-status.js +0 -259
package/dist/storage-doctor.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { constants } from "node:fs";
|
|
2
|
-
import { access, lstat, readdir, realpath, statfs } from "node:fs/promises";
|
|
3
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
-
import { generateStorageManifest, persistStorageManifestChunks, verifyStorageManifestChunkStore, parseStorageManifest, storageManifestDigest, } from "./storage-manifest.js";
|
|
5
|
-
import { validateStorageEnvironment } from "./storage-layout.js";
|
|
6
|
-
export class StorageDoctorAbortError extends Error {
|
|
7
|
-
code = "preflight_aborted";
|
|
8
|
-
scannedEntries;
|
|
9
|
-
constructor(scannedEntries, cause) {
|
|
10
|
-
super("storage doctor preflight was aborted", { cause });
|
|
11
|
-
this.name = "StorageDoctorAbortError";
|
|
12
|
-
this.scannedEntries = scannedEntries;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function discoverLegacyStorageSources(input) {
|
|
16
|
-
if (!isAbsolute(input.legacyRoot))
|
|
17
|
-
throw new Error("legacy root must be absolute");
|
|
18
|
-
for (const value of [input.daemonDirectory, input.agentsDirectory]) {
|
|
19
|
-
if (!/^[a-z0-9][a-z0-9_-]{0,127}$/u.test(value))
|
|
20
|
-
throw new Error("legacy directory name is invalid");
|
|
21
|
-
}
|
|
22
|
-
return Object.freeze([
|
|
23
|
-
Object.freeze({ kind: "daemon-home", root: join(input.legacyRoot, input.daemonDirectory), logicalPrefix: "daemon" }),
|
|
24
|
-
Object.freeze({ kind: "agents-root", root: join(input.legacyRoot, input.agentsDirectory), logicalPrefix: "agent-items" }),
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
|
-
async function nearestExistingAncestor(path) {
|
|
28
|
-
let candidate = path;
|
|
29
|
-
for (;;) {
|
|
30
|
-
try {
|
|
31
|
-
await lstat(candidate);
|
|
32
|
-
return candidate;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error.code !== "ENOENT")
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
const parent = dirname(candidate);
|
|
39
|
-
if (parent === candidate)
|
|
40
|
-
throw new Error("target storage has no existing ancestor");
|
|
41
|
-
candidate = parent;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function canonicalPotentialPath(path) {
|
|
45
|
-
const absolute = resolve(path);
|
|
46
|
-
const ancestor = await nearestExistingAncestor(absolute);
|
|
47
|
-
const canonicalAncestor = await realpath(ancestor);
|
|
48
|
-
return resolve(canonicalAncestor, relative(ancestor, absolute));
|
|
49
|
-
}
|
|
50
|
-
async function pathsOverlap(left, right) {
|
|
51
|
-
const [canonicalLeft, canonicalRight] = await Promise.all([
|
|
52
|
-
canonicalPotentialPath(left),
|
|
53
|
-
canonicalPotentialPath(right),
|
|
54
|
-
]);
|
|
55
|
-
const leftToRight = relative(canonicalLeft, canonicalRight);
|
|
56
|
-
const rightToLeft = relative(canonicalRight, canonicalLeft);
|
|
57
|
-
const contained = (value) => value === "" || (!value.startsWith("..") && !isAbsolute(value));
|
|
58
|
-
return contained(leftToRight) || contained(rightToLeft);
|
|
59
|
-
}
|
|
60
|
-
async function defaultProbeTarget(targetWorkspaceRoot) {
|
|
61
|
-
try {
|
|
62
|
-
const ancestor = await nearestExistingAncestor(targetWorkspaceRoot);
|
|
63
|
-
await access(ancestor, constants.R_OK | constants.W_OK);
|
|
64
|
-
let targetState = "absent";
|
|
65
|
-
try {
|
|
66
|
-
const target = await lstat(targetWorkspaceRoot);
|
|
67
|
-
targetState = target.isDirectory() && (await readdir(targetWorkspaceRoot)).length === 0 ? "empty" : "non_empty";
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error.code !== "ENOENT")
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
const filesystem = await statfs(ancestor, { bigint: true });
|
|
74
|
-
const available = filesystem.bavail * filesystem.bsize;
|
|
75
|
-
return Object.freeze({
|
|
76
|
-
status: "available",
|
|
77
|
-
targetState,
|
|
78
|
-
availableBytes: available > BigInt(Number.MAX_SAFE_INTEGER) ? Number.MAX_SAFE_INTEGER : Number(available),
|
|
79
|
-
writable: true,
|
|
80
|
-
// Staging and final roots are siblings on this filesystem. A destructive rename probe belongs
|
|
81
|
-
// to the separately approved write preflight, not this read-only doctor.
|
|
82
|
-
atomicRenameSupported: true,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
const code = error.code;
|
|
87
|
-
return Object.freeze({
|
|
88
|
-
status: code === "EACCES" || code === "EPERM" ? "permission_denied" : "unavailable",
|
|
89
|
-
targetState: "absent",
|
|
90
|
-
availableBytes: 0,
|
|
91
|
-
writable: false,
|
|
92
|
-
atomicRenameSupported: false,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const issue = (code, detail) => Object.freeze({ code, detail });
|
|
97
|
-
function inspectManifestLinks(manifest) {
|
|
98
|
-
const warnings = [];
|
|
99
|
-
const blockers = [];
|
|
100
|
-
const credentialLinks = manifest.entries.filter((entry) => entry.link?.classification === "external" && entry.reason === "credential_material").length;
|
|
101
|
-
const unapprovedLinks = manifest.entries.filter((entry) => entry.link?.classification === "external" && entry.reason !== "credential_material" && entry.reason !== "local_runtime").length;
|
|
102
|
-
const brokenLinks = manifest.entries.filter((entry) => entry.link?.classification === "broken").length;
|
|
103
|
-
const unsupportedItems = manifest.entries.filter((entry) => entry.type === "unsupported").length;
|
|
104
|
-
if (credentialLinks > 0)
|
|
105
|
-
warnings.push(issue("credential_link_excluded", `${credentialLinks} credential link(s) excluded from migration`));
|
|
106
|
-
if (unapprovedLinks > 0)
|
|
107
|
-
blockers.push(issue("external_symlink_unapproved", `${unapprovedLinks} external link(s) require an explicit exclusion or portable mapping`));
|
|
108
|
-
if (brokenLinks > 0)
|
|
109
|
-
blockers.push(issue("broken_symlink", `${brokenLinks} broken link(s) cannot be migrated safely`));
|
|
110
|
-
if (unsupportedItems > 0)
|
|
111
|
-
blockers.push(issue("unsupported_file_type", `${unsupportedItems} unsupported filesystem item(s) found`));
|
|
112
|
-
if (manifest.summary.transformations > 0) {
|
|
113
|
-
warnings.push(issue("target_transformations_required", `${manifest.summary.transformations} target-only transformation(s) must be verified during apply`));
|
|
114
|
-
}
|
|
115
|
-
return { warnings, blockers };
|
|
116
|
-
}
|
|
117
|
-
export async function runStorageDoctor(input, dependencies = {}) {
|
|
118
|
-
const environment = validateStorageEnvironment(input.environment);
|
|
119
|
-
let scannedEntries = 0;
|
|
120
|
-
const onProgress = (progress) => {
|
|
121
|
-
scannedEntries = progress.scannedEntries;
|
|
122
|
-
input.onProgress?.(progress);
|
|
123
|
-
};
|
|
124
|
-
if (input.signal?.aborted)
|
|
125
|
-
throw new StorageDoctorAbortError(scannedEntries);
|
|
126
|
-
const manifest = typeof input.manifest === "string"
|
|
127
|
-
? parseStorageManifest(input.manifest)
|
|
128
|
-
: input.manifest === undefined
|
|
129
|
-
? await (input.manifestStoreRoot === undefined
|
|
130
|
-
? generateStorageManifest({
|
|
131
|
-
migrationId: input.migrationId,
|
|
132
|
-
generatedAt: input.generatedAt,
|
|
133
|
-
environment,
|
|
134
|
-
workspaceId: input.workspaceId,
|
|
135
|
-
targetWorkspaceRoot: input.targetWorkspaceRoot,
|
|
136
|
-
sources: input.sources,
|
|
137
|
-
policy: input.policy,
|
|
138
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
139
|
-
onProgress,
|
|
140
|
-
...(input.progressIntervalEntries === undefined ? {} : { progressIntervalEntries: input.progressIntervalEntries }),
|
|
141
|
-
})
|
|
142
|
-
: persistStorageManifestChunks({
|
|
143
|
-
migrationId: input.migrationId,
|
|
144
|
-
generatedAt: input.generatedAt,
|
|
145
|
-
environment,
|
|
146
|
-
workspaceId: input.workspaceId,
|
|
147
|
-
targetWorkspaceRoot: input.targetWorkspaceRoot,
|
|
148
|
-
sources: input.sources,
|
|
149
|
-
policy: input.policy,
|
|
150
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
151
|
-
onProgress,
|
|
152
|
-
...(input.progressIntervalEntries === undefined ? {} : { progressIntervalEntries: input.progressIntervalEntries }),
|
|
153
|
-
}, { root: input.manifestStoreRoot })).catch((error) => {
|
|
154
|
-
if (error.code === "preflight_aborted") {
|
|
155
|
-
throw new StorageDoctorAbortError(scannedEntries, error);
|
|
156
|
-
}
|
|
157
|
-
throw error;
|
|
158
|
-
})
|
|
159
|
-
: parseStorageManifest(JSON.stringify(input.manifest));
|
|
160
|
-
const target = await (dependencies.probeTarget ?? defaultProbeTarget)(input.targetWorkspaceRoot);
|
|
161
|
-
const warnings = [];
|
|
162
|
-
const blockers = [];
|
|
163
|
-
try {
|
|
164
|
-
await verifyStorageManifestChunkStore(manifest);
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
blockers.push(issue("manifest_chunk_store_invalid", error instanceof Error ? error.message : "manifest chunk store is invalid"));
|
|
168
|
-
}
|
|
169
|
-
if (manifest.migrationId !== input.migrationId || manifest.workspaceId !== input.workspaceId.toLowerCase()
|
|
170
|
-
|| manifest.environment !== environment || manifest.targetWorkspaceRoot !== input.targetWorkspaceRoot) {
|
|
171
|
-
blockers.push(issue("manifest_identity_mismatch", "manifest identity does not match the requested migration"));
|
|
172
|
-
}
|
|
173
|
-
if (!input.state.profileIdentityExact)
|
|
174
|
-
blockers.push(issue("profile_identity_drift", "profile, service or managed registry identity drifted"));
|
|
175
|
-
if ((await Promise.all(input.sources.map((source) => pathsOverlap(source.root, input.targetWorkspaceRoot))))
|
|
176
|
-
.some(Boolean)) {
|
|
177
|
-
blockers.push(issue("source_target_overlap", "target workspace and source roots must not contain one another"));
|
|
178
|
-
}
|
|
179
|
-
if (input.state.duplicateWorkspaceMappings > 0)
|
|
180
|
-
blockers.push(issue("duplicate_workspace_mapping", "more than one profile maps to this workspace"));
|
|
181
|
-
if (input.state.activeAgentExecutions > 0 || input.state.activeScheduledRuns > 0) {
|
|
182
|
-
blockers.push(issue("active_execution", "active agent execution or scheduled run must finish before migration"));
|
|
183
|
-
}
|
|
184
|
-
if (target.status === "unavailable")
|
|
185
|
-
blockers.push(issue("target_unavailable", "target storage is unavailable"));
|
|
186
|
-
if (target.status === "permission_denied" || !target.writable)
|
|
187
|
-
blockers.push(issue("target_permission_denied", "target storage is not writable by the daemon user"));
|
|
188
|
-
if (target.targetState === "non_empty")
|
|
189
|
-
blockers.push(issue("target_non_empty", "target workspace root is not empty"));
|
|
190
|
-
const multiplier = input.freeSpaceMultiplier ?? 1.2;
|
|
191
|
-
if (!Number.isFinite(multiplier) || multiplier < 1)
|
|
192
|
-
throw new Error("free space multiplier must be at least 1");
|
|
193
|
-
const requiredBytes = Math.ceil(manifest.summary.bytesToCopy * multiplier);
|
|
194
|
-
if (target.status === "available" && target.availableBytes < requiredBytes) {
|
|
195
|
-
blockers.push(issue("insufficient_space", `target requires at least ${requiredBytes} available bytes`));
|
|
196
|
-
}
|
|
197
|
-
if (!target.atomicRenameSupported)
|
|
198
|
-
blockers.push(issue("atomic_rename_unsupported", "target filesystem rename semantics are not verified"));
|
|
199
|
-
const links = inspectManifestLinks(manifest);
|
|
200
|
-
warnings.push(...links.warnings);
|
|
201
|
-
blockers.push(...links.blockers);
|
|
202
|
-
if (manifest.chunkStore !== undefined) {
|
|
203
|
-
if (manifest.chunkStore.credentialLinks > 0)
|
|
204
|
-
warnings.push(issue("credential_link_excluded", `${manifest.chunkStore.credentialLinks} credential link(s) excluded from migration`));
|
|
205
|
-
if (manifest.chunkStore.unapprovedLinks > 0)
|
|
206
|
-
blockers.push(issue("external_symlink_unapproved", `${manifest.chunkStore.unapprovedLinks} external link(s) require an explicit exclusion or portable mapping`));
|
|
207
|
-
if (manifest.chunkStore.brokenLinks > 0)
|
|
208
|
-
blockers.push(issue("broken_symlink", `${manifest.chunkStore.brokenLinks} broken link(s) cannot be migrated safely`));
|
|
209
|
-
if (manifest.chunkStore.unsupportedItems > 0)
|
|
210
|
-
blockers.push(issue("unsupported_file_type", `${manifest.chunkStore.unsupportedItems} unsupported filesystem item(s) found`));
|
|
211
|
-
}
|
|
212
|
-
const applyAllowed = blockers.length === 0;
|
|
213
|
-
const status = !applyAllowed ? "blocked" : warnings.length > 0 ? "warnings" : "safe";
|
|
214
|
-
const exitCode = status === "safe" ? 0 : status === "warnings" ? 2 : 3;
|
|
215
|
-
return Object.freeze({
|
|
216
|
-
status,
|
|
217
|
-
exitCode,
|
|
218
|
-
applyAllowed,
|
|
219
|
-
environment,
|
|
220
|
-
workspaceId: input.workspaceId.toLowerCase(),
|
|
221
|
-
profile: input.profile,
|
|
222
|
-
manifest,
|
|
223
|
-
manifestDigest: storageManifestDigest(manifest),
|
|
224
|
-
target,
|
|
225
|
-
warnings: Object.freeze(warnings),
|
|
226
|
-
blockers: Object.freeze(blockers),
|
|
227
|
-
});
|
|
228
|
-
}
|