@north-light/cli 0.3.670 → 0.3.672
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/dist/api/client.js +1 -1
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/bash-jobs.d.ts +2 -0
- package/dist/api/dto/execution-start.d.ts +7 -0
- package/dist/clients/attach/viewer.js +1 -1
- package/dist/commands/node/bash.js +3 -3
- package/dist/core/bash-job-supervisor.js +3 -3
- package/dist/core/canvas/canvas.d.ts +10 -1
- package/dist/core/canvas/canvas.js +18 -18
- package/dist/core/canvas/schema-pg/022-create-request-lease.sql +5 -0
- package/dist/core/canvas/schema-pg/023-machine-calls-job-stop.sql +7 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/grants/sync.js +1 -1
- package/dist/core/runtime/broker/boot-state.d.ts +8 -0
- package/dist/core/runtime/broker/boot-state.js +1 -1
- package/dist/core/runtime/broker/cycle-start.d.ts +8 -1
- package/dist/core/runtime/broker/cycle-start.js +2 -2
- package/dist/core/runtime/broker/turn-admission.d.ts +4 -1
- package/dist/core/runtime/broker/turn-admission.js +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/runner/blaxel/image-build.d.ts +3 -0
- package/dist/core/runtime/runner/blaxel/image-build.js +5 -5
- package/dist/core/runtime/runner/machine/call.js +2 -2
- package/dist/core/runtime/runner/machine/executor.d.ts +3 -3
- package/dist/core/runtime/runner/machine/executor.js +1 -1
- package/dist/core/runtime/runner/machine/ops.d.ts +18 -1
- package/dist/core/runtime/runner/machine/ops.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +3 -3
- package/dist/daemon/api/handlers/delivery.js +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/cron/machine-fire.d.ts +3 -0
- package/dist/daemon/cron/machine-fire.js +1 -1
- package/dist/daemon/crtrd.js +16 -16
- package/dist/daemon/due-sources.d.ts +1 -1
- package/dist/daemon/due-sources.js +1 -1
- package/dist/daemon/due.js +7 -7
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/machine-link/job-sweep.d.ts +7 -0
- package/dist/daemon/machine-link/job-sweep.js +1 -1
- package/dist/daemon/reconcilers/bash-deadline.js +1 -1
- package/dist/daemon/reconcilers/machine-offline.d.ts +6 -0
- package/dist/daemon/reconcilers/machine-offline.js +7 -0
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/client.js +1 -1
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/api/dto/execution-start.js +0 -1
- package/packages/crouter-api/dist/commands/node/bash.js +7 -4
- package/packages/crouter-api/dist/core/bash-job-supervisor.js +15 -2
- package/packages/crouter-api/dist/core/canvas/canvas.js +23 -2
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/grants/sync.js +3 -0
- package/packages/crouter-api/dist/core/runtime/revive-all.js +108 -0
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/image-build.js +13 -5
- package/packages/crouter-api/dist/core/runtime/runner/machine/call.js +1 -1
- package/packages/crouter-api/dist/core/runtime/runner/machine/ops.js +1 -1
- package/packages/crouter-api/dist/daemon/api/handlers/bash-jobs.js +13 -2
- package/packages/crouter-api/dist/daemon/cron/armed-context.js +140 -0
- package/packages/crouter-api/dist/daemon/cron/capture.js +50 -0
- package/packages/crouter-api/dist/daemon/cron/closed.js +108 -0
- package/packages/crouter-api/dist/daemon/cron/disposition.js +63 -0
- package/packages/crouter-api/dist/daemon/cron/ended.js +80 -0
- package/packages/crouter-api/dist/daemon/cron/escalation.js +136 -0
- package/packages/crouter-api/dist/daemon/cron/held.js +20 -0
- package/packages/crouter-api/dist/daemon/cron/machine-fire.js +177 -0
- package/packages/crouter-api/dist/daemon/cron/narrowed.js +34 -0
- package/packages/crouter-api/dist/daemon/cron/recurrence.js +38 -0
- package/packages/crouter-api/dist/daemon/cron/run-token.js +37 -0
- package/packages/crouter-api/dist/daemon/cron/settle.js +78 -0
- package/packages/crouter-api/dist/daemon/cron/sinks.js +70 -0
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/scripts/sandbox-start.mjs +8 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { newNodeId } from '../../core/runtime/nodes.js';
|
|
2
|
+
import { nodeAgentDir } from '../../core/canvas/node-agent-paths.js';
|
|
3
|
+
import { getNode } from '../../core/canvas/canvas.js';
|
|
4
|
+
import { parseCronSink } from '../../core/canvas/crons.js';
|
|
5
|
+
import { hasNoNaturalCycle } from '../../core/runtime/revive-all.js';
|
|
6
|
+
import { isParked } from '../../core/runtime/lifecycle.js';
|
|
7
|
+
import { cronWakeOrigin } from '../../core/runtime/bearings.js';
|
|
8
|
+
import { emitEvent } from '../../core/events/emit.js';
|
|
9
|
+
import { cronBirthPrincipalOf, resolveLiveProfile, resolveLiveProfileName } from './armed-context.js';
|
|
10
|
+
import { checkCronBirth } from './authority.js';
|
|
11
|
+
/** Resolve a completed run into a durable obligation. No sink effect happens here. */
|
|
12
|
+
export async function resolveCronSink(c, runId, stdout) {
|
|
13
|
+
const sink = parseCronSink(c.sink);
|
|
14
|
+
if (sink === null)
|
|
15
|
+
return { kind: 'none', delivered: 'no sink armed — nothing delivered' };
|
|
16
|
+
if (sink.kind === 'node') {
|
|
17
|
+
const meta = await getNode(sink.node);
|
|
18
|
+
if (meta === null)
|
|
19
|
+
throw new Error(`node sink ${sink.node} is gone`);
|
|
20
|
+
if (hasNoNaturalCycle(meta) && !isParked(meta)) {
|
|
21
|
+
throw new Error(`node sink ${sink.node} has no natural cycle ahead (done or finalized)`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
kind: 'node',
|
|
25
|
+
destinationNodeId: sink.node,
|
|
26
|
+
senderNodeId: c.created_by !== null && await getNode(c.created_by) !== null ? c.created_by : null,
|
|
27
|
+
label: `⏰ cron ${c.name}`,
|
|
28
|
+
stdout,
|
|
29
|
+
urgency: c.tier,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (sink.kind === 'spawn') {
|
|
33
|
+
// The birth is checked now so a refused one settles this run `refused` (no escalation), and
|
|
34
|
+
// again when the action is delivered.
|
|
35
|
+
const stored = cronBirthPrincipalOf(c);
|
|
36
|
+
const authority = await checkCronBirth(stored, { kind: sink.spawn, cwd: c.cwd, profile: resolveLiveProfile(c) });
|
|
37
|
+
if (!authority.allowed) {
|
|
38
|
+
emitEvent({ level: 'warn', event: 'cron.birth.refused', fields: { cron_id: c.cron_id, grant_id: c.grant_id, reason: authority.reason, stage: 'enqueue' } });
|
|
39
|
+
return { kind: 'none', delivered: `refused: ${authority.reason}`, refused: true };
|
|
40
|
+
}
|
|
41
|
+
const principal = { ...stored, scopes: authority.scopes };
|
|
42
|
+
const nodeId = await newNodeId();
|
|
43
|
+
const prompt = [
|
|
44
|
+
`Scheduled cron "${c.name}" (${c.cron_id}) fired and delivered its output to you as your kickoff.`,
|
|
45
|
+
'',
|
|
46
|
+
'## Command output',
|
|
47
|
+
'',
|
|
48
|
+
stdout,
|
|
49
|
+
].join('\n');
|
|
50
|
+
return {
|
|
51
|
+
kind: 'action',
|
|
52
|
+
adapter: {
|
|
53
|
+
adapter: 'cron_spawn', cronId: c.cron_id, nodeId, kind: sink.spawn,
|
|
54
|
+
cwd: c.isolated ? await nodeAgentDir(nodeId, c.grantee) : c.cwd, isolated: c.isolated,
|
|
55
|
+
principal,
|
|
56
|
+
profile: resolveLiveProfile(c), wakeOrigin: await cronWakeOrigin(c, 'node_birth'), prompt,
|
|
57
|
+
},
|
|
58
|
+
bodyJson: { runId, stdout },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
kind: 'action',
|
|
63
|
+
adapter: {
|
|
64
|
+
adapter: 'cron_human', cronId: c.cron_id, requestId: await newNodeId(), title: `⏰ cron ${c.name}`,
|
|
65
|
+
summary: `Scheduled cron "${c.name}" delivered output for your attention.`, sessionName: `cron ${c.name} (${c.cron_id})`,
|
|
66
|
+
profileName: resolveLiveProfileName(c) ?? null,
|
|
67
|
+
},
|
|
68
|
+
bodyJson: { runId, stdout },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.672",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.672",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@north-light/api": "0.3.
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
30
|
+
"@north-light/api": "0.3.672",
|
|
31
|
+
"@north-light/identity": "0.3.672"
|
|
32
32
|
},
|
|
33
33
|
"license": "UNLICENSED",
|
|
34
34
|
"publishConfig": {
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.672",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.672",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
32
|
-
"@north-light/plugin": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.672",
|
|
32
|
+
"@north-light/plugin": "0.3.672",
|
|
33
33
|
"cron-parser": "^5.6.0",
|
|
34
34
|
"esbuild": "0.28.2",
|
|
35
35
|
"jose": "^6.2.12",
|
|
@@ -10667,17 +10667,17 @@
|
|
|
10667
10667
|
},
|
|
10668
10668
|
"packages/crouter-api": {
|
|
10669
10669
|
"name": "@north-light/api",
|
|
10670
|
-
"version": "0.3.
|
|
10670
|
+
"version": "0.3.672",
|
|
10671
10671
|
"license": "UNLICENSED"
|
|
10672
10672
|
},
|
|
10673
10673
|
"packages/crouter-env-docker": {
|
|
10674
10674
|
"name": "@north-light/env-docker",
|
|
10675
|
-
"version": "0.3.
|
|
10675
|
+
"version": "0.3.672",
|
|
10676
10676
|
"license": "UNLICENSED"
|
|
10677
10677
|
},
|
|
10678
10678
|
"packages/crouter-identity": {
|
|
10679
10679
|
"name": "@north-light/identity",
|
|
10680
|
-
"version": "0.3.
|
|
10680
|
+
"version": "0.3.672",
|
|
10681
10681
|
"license": "UNLICENSED",
|
|
10682
10682
|
"dependencies": {
|
|
10683
10683
|
"jose": "^6.2.1"
|
|
@@ -10685,21 +10685,21 @@
|
|
|
10685
10685
|
},
|
|
10686
10686
|
"packages/crouter-plugin": {
|
|
10687
10687
|
"name": "@north-light/plugin",
|
|
10688
|
-
"version": "0.3.
|
|
10688
|
+
"version": "0.3.672",
|
|
10689
10689
|
"license": "UNLICENSED",
|
|
10690
10690
|
"dependencies": {
|
|
10691
|
-
"@north-light/api": "0.3.
|
|
10692
|
-
"@north-light/identity": "0.3.
|
|
10691
|
+
"@north-light/api": "0.3.672",
|
|
10692
|
+
"@north-light/identity": "0.3.672"
|
|
10693
10693
|
}
|
|
10694
10694
|
},
|
|
10695
10695
|
"packages/crouter-sdk": {
|
|
10696
10696
|
"name": "@north-light/sdk",
|
|
10697
|
-
"version": "0.3.
|
|
10697
|
+
"version": "0.3.672",
|
|
10698
10698
|
"license": "UNLICENSED",
|
|
10699
10699
|
"dependencies": {
|
|
10700
|
-
"@north-light/api": "0.3.
|
|
10701
|
-
"@north-light/identity": "0.3.
|
|
10702
|
-
"@north-light/plugin": "0.3.
|
|
10700
|
+
"@north-light/api": "0.3.672",
|
|
10701
|
+
"@north-light/identity": "0.3.672",
|
|
10702
|
+
"@north-light/plugin": "0.3.672",
|
|
10703
10703
|
"jose": "^6.2.1"
|
|
10704
10704
|
},
|
|
10705
10705
|
"bin": {
|
|
@@ -352,6 +352,12 @@ async function start(env) {
|
|
|
352
352
|
const home = join(root, 'apps', bundle.node.app.replace(/^app:/, ''), 'home');
|
|
353
353
|
const agentDir = join(home, '.pi', 'agent');
|
|
354
354
|
const work = env.CRTR_WORK_DIR ?? '/work';
|
|
355
|
+
// The recipe image keeps a failing setup script's exit status and output (image-build.ts); starting on such an image would run without its setup.
|
|
356
|
+
const setupFailed = join(work, '.crtr', 'setup-failed');
|
|
357
|
+
if (existsSync(setupFailed)) {
|
|
358
|
+
const log = existsSync(join(work, '.crtr', 'setup.log')) ? readFileSync(join(work, '.crtr', 'setup.log'), 'utf8').trim().slice(-1500) : '';
|
|
359
|
+
throw new StartFailure('recipe_setup_failed', `the recipe image build failed (${readFileSync(setupFailed, 'utf8').trim().replace(/\n/g, '; ')}):\n${log}`);
|
|
360
|
+
}
|
|
355
361
|
mkdirSync(agentDir, { recursive: true });
|
|
356
362
|
// The recipe image installs its pi packages into one agent dir of its own (RECIPE_PI_AGENT_DIR in image-build.ts); every app's agent dir links to
|
|
357
363
|
// that install, so the packages load whichever app the node runs in.
|
|
@@ -420,7 +426,8 @@ async function start(env) {
|
|
|
420
426
|
}
|
|
421
427
|
const { dest: marketplaceDir, manifest } = marketplaces.get(key);
|
|
422
428
|
const entry = manifest.plugins.find((candidate) => candidate?.name === plugin.name);
|
|
423
|
-
|
|
429
|
+
// The Mac warns about an enabled plugin its marketplace no longer carries and goes on; so does this.
|
|
430
|
+
if (!entry || typeof entry.source !== 'string') { console.error(`crtr-sandbox-start: warning: ${plugin.name}: not found in marketplace ${manifest.name}; skipped`); continue; }
|
|
424
431
|
const target = join(pluginsDir, plugin.name);
|
|
425
432
|
mkdirSync(pluginsDir, { recursive: true });
|
|
426
433
|
rmSync(target, { recursive: true, force: true });
|