owenloop 0.5.0 → 0.5.1
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/CHANGELOG.md +45 -0
- package/README.md +137 -35
- package/bin/owenloop.mjs +49 -1
- package/dist/packages/work/src/agent/brief.d.ts +8 -4
- package/dist/packages/work/src/agent/brief.js +7 -3
- package/dist/packages/work/src/agent/loop.d.ts +13 -7
- package/dist/packages/work/src/agent/loop.js +136 -9
- package/dist/packages/work/src/agent/model-policy.d.ts +49 -0
- package/dist/packages/work/src/agent/model-policy.js +138 -0
- package/dist/packages/work/src/bundle/cache.d.ts +7 -5
- package/dist/packages/work/src/bundle/cache.js +20 -6
- package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
- package/dist/packages/work/src/bundle/fetch.js +27 -7
- package/dist/packages/work/src/bundle/types.d.ts +8 -4
- package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
- package/dist/packages/work/src/consumed-verifier.js +205 -0
- package/dist/packages/work/src/exec/instructions.d.ts +99 -0
- package/dist/packages/work/src/exec/instructions.js +323 -0
- package/dist/packages/work/src/exec/loop.d.ts +12 -1
- package/dist/packages/work/src/exec/loop.js +137 -20
- package/dist/packages/work/src/exec/payload.d.ts +29 -0
- package/dist/packages/work/src/exec/payload.js +54 -0
- package/dist/packages/work/src/exec/receipt.d.ts +9 -6
- package/dist/packages/work/src/exec/receipt.js +12 -1
- package/dist/packages/work/src/exec/runner.d.ts +7 -1
- package/dist/packages/work/src/exec/runner.js +74 -3
- package/dist/packages/work/src/harness/child-env.js +7 -0
- package/dist/packages/work/src/harness/claude.d.ts +20 -8
- package/dist/packages/work/src/harness/claude.js +260 -58
- package/dist/packages/work/src/harness/codex.d.ts +5 -4
- package/dist/packages/work/src/harness/codex.js +169 -41
- package/dist/packages/work/src/harness/contract.d.ts +36 -11
- package/dist/packages/work/src/harness/fake.js +1 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
- package/dist/packages/work/src/harness/permissions.d.ts +16 -3
- package/dist/packages/work/src/harness/permissions.js +102 -13
- package/dist/packages/work/src/harness/session-store.d.ts +27 -9
- package/dist/packages/work/src/harness/session-store.js +271 -67
- package/dist/packages/work/src/hold/mcp.d.ts +25 -5
- package/dist/packages/work/src/hold/mcp.js +126 -11
- package/dist/packages/work/src/hub/client.d.ts +2 -1
- package/dist/packages/work/src/hub/client.js +14 -1
- package/dist/packages/work/src/hub/types.d.ts +69 -33
- package/dist/packages/work/src/hub/types.js +8 -10
- package/dist/packages/work/src/mcp/server.js +1 -1
- package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
- package/dist/packages/work/src/owenloop-bin.js +18 -0
- package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
- package/dist/packages/work/src/roles/agent-run.js +116 -34
- package/dist/packages/work/src/roles/exec.d.ts +8 -0
- package/dist/packages/work/src/roles/exec.js +27 -2
- package/dist/packages/work/src/roles/hold.d.ts +4 -0
- package/dist/packages/work/src/roles/hold.js +44 -5
- package/dist/packages/work/src/roles/lint.d.ts +3 -4
- package/dist/packages/work/src/roles/lint.js +41 -7
- package/dist/packages/work/src/roles/settings.js +5 -0
- package/dist/packages/work/src/roles/shift.d.ts +1 -0
- package/dist/packages/work/src/roles/shift.js +23 -1
- package/dist/packages/work/src/settings/settings.d.ts +17 -1
- package/dist/packages/work/src/settings/settings.js +39 -0
- package/dist/packages/work/src/shift/loop.d.ts +14 -3
- package/dist/packages/work/src/shift/loop.js +447 -164
- package/dist/packages/work/src/shift/protocol.d.ts +4 -0
- package/dist/packages/work/src/shift/runtime.d.ts +2 -0
- package/dist/packages/work/src/shift/runtime.js +66 -3
- package/dist/packages/work/src/shift/spawn.d.ts +41 -18
- package/dist/packages/work/src/shift/spawn.js +89 -31
- package/dist/packages/work/src/shift/state.d.ts +53 -51
- package/dist/packages/work/src/shift/state.js +325 -102
- package/dist/packages/work/src/submit-proof.d.ts +36 -0
- package/dist/packages/work/src/submit-proof.js +93 -0
- package/dist/src/add.d.ts +64 -259
- package/dist/src/add.js +81 -615
- package/dist/src/archive.d.ts +97 -0
- package/dist/src/archive.js +591 -0
- package/dist/src/bundle/index.d.ts +64 -0
- package/dist/src/bundle/index.js +508 -0
- package/dist/src/bundle/manifest.d.ts +50 -0
- package/dist/src/bundle/manifest.js +435 -0
- package/dist/src/bundle/runtime.d.ts +26 -0
- package/dist/src/bundle/runtime.js +64 -0
- package/dist/src/bundle/tar.d.ts +62 -0
- package/dist/src/bundle/tar.js +238 -0
- package/dist/src/bundle/types.d.ts +105 -0
- package/dist/src/bundle/types.js +21 -0
- package/dist/src/cli.d.ts +90 -20
- package/dist/src/cli.js +2407 -365
- package/dist/src/credentials.d.ts +4 -3
- package/dist/src/credentials.js +21 -19
- package/dist/src/crypto/allowed-signers.d.ts +68 -0
- package/dist/src/crypto/allowed-signers.js +307 -0
- package/dist/src/crypto/canonical.d.ts +8 -0
- package/dist/src/crypto/canonical.js +92 -0
- package/dist/src/crypto/chain.d.ts +65 -0
- package/dist/src/crypto/chain.js +377 -0
- package/dist/src/crypto/dsse.d.ts +209 -0
- package/dist/src/crypto/dsse.js +282 -0
- package/dist/src/crypto/enrollment.d.ts +78 -0
- package/dist/src/crypto/enrollment.js +186 -0
- package/dist/src/crypto/index.d.ts +48 -0
- package/dist/src/crypto/index.js +44 -0
- package/dist/src/crypto/keys.d.ts +258 -0
- package/dist/src/crypto/keys.js +908 -0
- package/dist/src/crypto/org-root.d.ts +33 -0
- package/dist/src/crypto/org-root.js +78 -0
- package/dist/src/crypto/origin-rules.d.ts +56 -0
- package/dist/src/crypto/origin-rules.js +143 -0
- package/dist/src/crypto/policy-floor.d.ts +98 -0
- package/dist/src/crypto/policy-floor.js +353 -0
- package/dist/src/crypto/records.d.ts +316 -0
- package/dist/src/crypto/records.js +157 -0
- package/dist/src/crypto/scope.d.ts +49 -0
- package/dist/src/crypto/scope.js +83 -0
- package/dist/src/crypto/ssh.d.ts +171 -0
- package/dist/src/crypto/ssh.js +396 -0
- package/dist/src/crypto/submission.d.ts +33 -0
- package/dist/src/crypto/submission.js +47 -0
- package/dist/src/crypto/trust-roots.d.ts +29 -0
- package/dist/src/crypto/trust-roots.js +39 -0
- package/dist/src/crypto/verify-consumed.d.ts +67 -0
- package/dist/src/crypto/verify-consumed.js +259 -0
- package/dist/src/crypto/verify-origin.d.ts +50 -0
- package/dist/src/crypto/verify-origin.js +151 -0
- package/dist/src/crypto/verify-publication.d.ts +60 -0
- package/dist/src/crypto/verify-publication.js +150 -0
- package/dist/src/defs.d.ts +24 -1
- package/dist/src/defs.js +145 -25
- package/dist/src/engine.d.ts +99 -3
- package/dist/src/engine.js +238 -34
- package/dist/src/factory.d.ts +16 -0
- package/dist/src/factory.js +16 -4
- package/dist/src/global-config.d.ts +59 -0
- package/dist/src/global-config.js +84 -0
- package/dist/src/hub.d.ts +75 -21
- package/dist/src/hub.js +123 -40
- package/dist/src/index.d.ts +17 -2
- package/dist/src/index.js +20 -2
- package/dist/src/install.d.ts +538 -0
- package/dist/src/install.js +1981 -0
- package/dist/src/lock.d.ts +15 -57
- package/dist/src/lock.js +251 -143
- package/dist/src/mcp/serve.d.ts +46 -22
- package/dist/src/mcp/serve.js +167 -44
- package/dist/src/mcp/server.js +12 -1
- package/dist/src/model.d.ts +15 -0
- package/dist/src/model.js +111 -1
- package/dist/src/order-resolver.d.ts +184 -0
- package/dist/src/order-resolver.js +252 -0
- package/dist/src/package-version.d.ts +10 -0
- package/dist/src/package-version.js +42 -0
- package/dist/src/paths.d.ts +14 -1
- package/dist/src/paths.js +18 -0
- package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
- package/dist/src/schemas/index.d.ts +1416 -0
- package/dist/src/schemas/index.js +31 -0
- package/dist/src/schemas/order.v1.schema.json +106 -0
- package/dist/src/schemas/origin.v1.schema.json +68 -0
- package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
- package/dist/src/schemas/publication.v1.schema.json +31 -0
- package/dist/src/schemas/revocation.v1.schema.json +39 -0
- package/dist/src/schemas/submission.v1.schema.json +61 -0
- package/dist/src/store/def-source.d.ts +52 -0
- package/dist/src/store/def-source.js +335 -0
- package/dist/src/store/index-file.d.ts +69 -0
- package/dist/src/store/index-file.js +151 -0
- package/dist/src/store/index.d.ts +27 -0
- package/dist/src/store/index.js +22 -0
- package/dist/src/store/ingestor.d.ts +43 -0
- package/dist/src/store/ingestor.js +211 -0
- package/dist/src/store/install.d.ts +228 -0
- package/dist/src/store/install.js +555 -0
- package/dist/src/store/instruction-source.d.ts +49 -0
- package/dist/src/store/instruction-source.js +298 -0
- package/dist/src/store/origin-evidence.d.ts +21 -0
- package/dist/src/store/origin-evidence.js +66 -0
- package/dist/src/store/pre-commit-verifier.d.ts +68 -0
- package/dist/src/store/pre-commit-verifier.js +418 -0
- package/dist/src/store/resolve.d.ts +138 -0
- package/dist/src/store/resolve.js +363 -0
- package/dist/src/store/types.d.ts +288 -0
- package/dist/src/store/types.js +356 -0
- package/dist/src/types.d.ts +45 -11
- package/dist/src/untar.d.ts +8 -23
- package/dist/src/untar.js +10 -136
- package/docs/agent-runner.md +86 -0
- package/docs/authoring.md +57 -6
- package/docs/bundles.md +250 -0
- package/docs/cli.md +1171 -97
- package/docs/crypto.md +816 -0
- package/docs/design.md +342 -20
- package/docs/embedding.md +132 -25
- package/docs/wire-contracts.md +380 -0
- package/package.json +6 -1
- package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
- package/plugins/claude-code/plugin/.mcp.json +14 -0
- package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
- package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
- package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
- package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
- package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
- package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
- package/plugins/codex/.agents/plugins/marketplace.json +21 -0
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
- package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
- package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
- package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
- package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
- package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
- package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
|
@@ -38,12 +38,10 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
38
38
|
*
|
|
39
39
|
* ── WHERE THE STEP SPEC COMES FROM ──
|
|
40
40
|
*
|
|
41
|
-
* The
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* `readDispatchBundle(cacheDir, def)` → `bundle.def.hash` → `readStepSpec(...)`.
|
|
46
|
-
* That keeps the argv exactly as D6 specifies and adds no new settings surface.
|
|
41
|
+
* The order packet carries a `defDigest` reference but no authoritative prompt,
|
|
42
|
+
* harness, or permission text. The worker resolves the digest and step name
|
|
43
|
+
* through the verified local workflow store. The prepare cache remains available
|
|
44
|
+
* for routing and session state, but never supplies execution instructions.
|
|
47
45
|
*
|
|
48
46
|
* ── CREDENTIALS ──
|
|
49
47
|
*
|
|
@@ -87,12 +85,17 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
87
85
|
import "../harnesses.js";
|
|
88
86
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
89
87
|
import { hostname } from 'node:os';
|
|
90
|
-
import {
|
|
88
|
+
import { resolveCacheDir } from "../bundle/cache.js";
|
|
91
89
|
import { createAgentRunLoop } from "../agent/loop.js";
|
|
90
|
+
import { createModelPolicy } from "../agent/model-policy.js";
|
|
91
|
+
import { createDefaultStoreInstructionResolver } from "../exec/instructions.js";
|
|
92
|
+
import { createConsumedVerifier } from "../consumed-verifier.js";
|
|
92
93
|
import { createHubClient } from "../hub/client.js";
|
|
93
94
|
import { resolveBearer } from "../credentials/resolve.js";
|
|
94
95
|
import { loadSettings } from "../settings/settings.js";
|
|
95
96
|
import { adapterFor, defaultHarnessId, registeredHarnessIds } from "../harness/registry.js";
|
|
97
|
+
import { parseHarnessCarrier } from "../bundle/fetch.js";
|
|
98
|
+
import { normalizeStepPermissions, validateHarnessOptions } from "../harness/permissions.js";
|
|
96
99
|
import { appendSession, latestFor, sessionsPath } from "../harness/session-store.js";
|
|
97
100
|
import { ensureWorkDir, resolveWorkRepo, resolveWorkRoot } from "../agent/workdir.js";
|
|
98
101
|
import { resolveShiftId, resolveTarget } from "./hold.js";
|
|
@@ -151,8 +154,11 @@ export function parseArgs(args) {
|
|
|
151
154
|
parsed.origin = r.value;
|
|
152
155
|
else if (name === '--shift')
|
|
153
156
|
parsed.shift = r.value;
|
|
154
|
-
else if (name === '--harness')
|
|
157
|
+
else if (name === '--harness') {
|
|
158
|
+
if (r.value.trim() === '')
|
|
159
|
+
return { error: '--harness must be a non-empty harness id' };
|
|
155
160
|
parsed.harness = r.value;
|
|
161
|
+
}
|
|
156
162
|
else {
|
|
157
163
|
const n = positiveMs(name, r.value);
|
|
158
164
|
if ('error' in n)
|
|
@@ -192,6 +198,9 @@ export function exitCodeFor(outcome) {
|
|
|
192
198
|
case 'misroute':
|
|
193
199
|
case 'no-template':
|
|
194
200
|
case 'no-harness':
|
|
201
|
+
case 'incompatible-harness-policy':
|
|
202
|
+
case 'unverified-consumed':
|
|
203
|
+
case 'session-store-failed':
|
|
195
204
|
case 'no-submit':
|
|
196
205
|
case 'killed':
|
|
197
206
|
case 'lease-lost':
|
|
@@ -246,7 +255,7 @@ export async function run(args, deps = {}) {
|
|
|
246
255
|
usage();
|
|
247
256
|
return 2;
|
|
248
257
|
}
|
|
249
|
-
const env = process.env;
|
|
258
|
+
const env = deps.env ?? process.env;
|
|
250
259
|
let settings;
|
|
251
260
|
try {
|
|
252
261
|
settings = loadSettings(env);
|
|
@@ -255,11 +264,33 @@ export async function run(args, deps = {}) {
|
|
|
255
264
|
err(`owenloop work agent-run: ${errMsg(e)}`);
|
|
256
265
|
return 1;
|
|
257
266
|
}
|
|
267
|
+
const modelPolicy = createModelPolicy({
|
|
268
|
+
...(settings.tierMap !== undefined ? { tierMap: settings.tierMap } : {}),
|
|
269
|
+
...(settings.escalateAt !== undefined ? { escalateAt: settings.escalateAt } : {}),
|
|
270
|
+
...(settings.escalationExtensionKey !== undefined
|
|
271
|
+
? { escalationExtensionKey: settings.escalationExtensionKey }
|
|
272
|
+
: {}),
|
|
273
|
+
});
|
|
258
274
|
const origin = parsed.origin ?? settings.hubOrigin;
|
|
259
275
|
if (origin === undefined || origin.trim() === '') {
|
|
260
276
|
err('owenloop work agent-run: no hub origin — pass --origin <url> or set hubOrigin in settings');
|
|
261
277
|
return 2;
|
|
262
278
|
}
|
|
279
|
+
const consumedVerifier = deps.consumedVerifier ?? createConsumedVerifier({
|
|
280
|
+
env,
|
|
281
|
+
now: () => Date.now(),
|
|
282
|
+
});
|
|
283
|
+
const instructionCwd = deps.cwd ?? process.cwd();
|
|
284
|
+
let instructions = deps.instructions;
|
|
285
|
+
if (instructions === undefined) {
|
|
286
|
+
try {
|
|
287
|
+
instructions = createDefaultStoreInstructionResolver({ cwd: instructionCwd, env, consumedVerifier });
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
err(`owenloop work agent-run: instruction store unavailable: ${errMsg(e)}`);
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
263
294
|
let cacheDir;
|
|
264
295
|
try {
|
|
265
296
|
cacheDir = resolveCacheDir(env, settings.cacheDir);
|
|
@@ -319,11 +350,27 @@ export async function run(args, deps = {}) {
|
|
|
319
350
|
*/
|
|
320
351
|
const envHarness = env['OWENLOOP_HARNESS'];
|
|
321
352
|
const resolveAdapter = (stepHarness) => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
353
|
+
let id;
|
|
354
|
+
if (parsed.harness !== undefined) {
|
|
355
|
+
id = parsed.harness;
|
|
356
|
+
}
|
|
357
|
+
else if (envHarness !== undefined) {
|
|
358
|
+
// Definition and default selection are lower precedence. An explicit empty
|
|
359
|
+
// environment override is invalid; it must not silently fall through.
|
|
360
|
+
if (envHarness.trim() === '') {
|
|
361
|
+
return {
|
|
362
|
+
id: '<empty OWENLOOP_HARNESS>',
|
|
363
|
+
registered: registeredHarnessIds(),
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
id = envHarness;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
id =
|
|
370
|
+
(stepHarness !== undefined && stepHarness !== '' ? stepHarness : undefined) ??
|
|
371
|
+
defaultHarnessId() ??
|
|
372
|
+
'';
|
|
373
|
+
}
|
|
327
374
|
const adapter = id !== '' ? adapterFor(id) : undefined;
|
|
328
375
|
return {
|
|
329
376
|
id: id !== '' ? id : '<none>',
|
|
@@ -331,35 +378,66 @@ export async function run(args, deps = {}) {
|
|
|
331
378
|
registered: registeredHarnessIds(),
|
|
332
379
|
};
|
|
333
380
|
};
|
|
334
|
-
/** Resolve the
|
|
381
|
+
/** Resolve the verified step from the local workflow store, never the prepare cache. */
|
|
335
382
|
const loadStep = async (order) => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
383
|
+
let resolved;
|
|
384
|
+
try {
|
|
385
|
+
resolved = await instructions.resolveStep(order);
|
|
386
|
+
}
|
|
387
|
+
catch (e) {
|
|
388
|
+
err(`owenloop work agent-run: instruction refusal (integrity): ${errMsg(e)}`);
|
|
340
389
|
return null;
|
|
341
390
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
err(`owenloop work agent-run: ${dispatch.warning}`);
|
|
345
|
-
if (dispatch.bundle === null) {
|
|
346
|
-
err(`owenloop work agent-run: no cached bundle for def '${defName}' — run \`owenloop work prepare ${defName}\``);
|
|
391
|
+
if (!resolved.ok) {
|
|
392
|
+
err(`owenloop work agent-run: ${resolved.reason}`);
|
|
347
393
|
return null;
|
|
348
394
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
395
|
+
// Harness adapters build their child environment from process.env. This
|
|
396
|
+
// worker owns one agent order, so the resolver-derived bundle root is
|
|
397
|
+
// per-order state; clear it when provenance is absent to prevent stale
|
|
398
|
+
// values from reaching a later step in the same process.
|
|
399
|
+
if (resolved.bundleDir !== undefined)
|
|
400
|
+
process.env['OWENLOOP_BUNDLE_DIR'] = resolved.bundleDir;
|
|
401
|
+
else
|
|
402
|
+
delete process.env['OWENLOOP_BUNDLE_DIR'];
|
|
403
|
+
// Run identity is engine-derived from this worker's target, never a consumed
|
|
404
|
+
// artifact value. Both registered adapter paths read process.env when they
|
|
405
|
+
// build their child environments, so one setter covers both; overwrite
|
|
406
|
+
// ambient values so a nested agent sees its own identity, not its parent's.
|
|
407
|
+
process.env['OWENLOOP_WORKFLOW'] = target.workflow;
|
|
408
|
+
process.env['OWENLOOP_RUN'] = target.run;
|
|
409
|
+
let carrier;
|
|
410
|
+
const rawStep = resolved.step;
|
|
411
|
+
try {
|
|
412
|
+
carrier = parseHarnessCarrier(rawStep, order.workflow, resolved.step.name);
|
|
413
|
+
}
|
|
414
|
+
catch (e) {
|
|
415
|
+
err(`owenloop work agent-run: instruction refusal (harness-carrier): ${errMsg(e)}`);
|
|
353
416
|
return null;
|
|
354
417
|
}
|
|
355
|
-
|
|
418
|
+
if (carrier.harnessOptions !== undefined) {
|
|
419
|
+
const errors = validateHarnessOptions(carrier.harnessOptions, resolved.step.name)
|
|
420
|
+
.filter((finding) => finding.severity === 'error');
|
|
421
|
+
if (errors.length > 0) {
|
|
422
|
+
for (const finding of errors) {
|
|
423
|
+
err(`owenloop work agent-run: instruction refusal (harness-policy): step '${finding.step}' ` +
|
|
424
|
+
`x.harness.${finding.field ?? '<bag>'}: ${finding.message}`);
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
step: resolved.step.name,
|
|
431
|
+
brief: resolved.step.body,
|
|
432
|
+
...(carrier.harness !== undefined ? { harness: carrier.harness } : {}),
|
|
433
|
+
permissions: normalizeStepPermissions(carrier.harnessOptions, resolved.step),
|
|
434
|
+
};
|
|
356
435
|
};
|
|
357
436
|
/**
|
|
358
|
-
* The session-store sink. `
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* carries on. The lease, not this file, remains the record of truth.
|
|
437
|
+
* The session-store sink. A durable `active` row is a provider-work start
|
|
438
|
+
* gate: failure propagates to the loop, which abandons the turn and releases
|
|
439
|
+
* the order before delivery. Later lifecycle rows remain best-effort resume
|
|
440
|
+
* metadata and are reported without replacing the lease as the hub truth.
|
|
363
441
|
*/
|
|
364
442
|
const sessionsFile = sessionsPath(cacheDir);
|
|
365
443
|
const writeSession = (rec) => {
|
|
@@ -368,6 +446,8 @@ export async function run(args, deps = {}) {
|
|
|
368
446
|
}
|
|
369
447
|
catch (e) {
|
|
370
448
|
err(`owenloop work agent-run: could not record the session in ${sessionsFile}: ${errMsg(e)}`);
|
|
449
|
+
if (rec.status === 'active')
|
|
450
|
+
throw e;
|
|
371
451
|
}
|
|
372
452
|
};
|
|
373
453
|
/**
|
|
@@ -418,6 +498,8 @@ export async function run(args, deps = {}) {
|
|
|
418
498
|
cwd: workCwd,
|
|
419
499
|
loadStep,
|
|
420
500
|
resolveAdapter,
|
|
501
|
+
modelPolicy,
|
|
502
|
+
consumedVerifier,
|
|
421
503
|
appendSession: writeSession,
|
|
422
504
|
nextAttempt: (workflow, run, step) => {
|
|
423
505
|
const prev = latestFor(sessionsFile, workflow, run, step);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type HubClient } from '../hub/client.ts';
|
|
2
2
|
import { type ExecOutcome } from '../exec/loop.ts';
|
|
3
|
+
import { type InstructionResolver } from '../exec/instructions.ts';
|
|
3
4
|
import { type CommandRunner } from '../exec/runner.ts';
|
|
5
|
+
import { type ConsumedVerifier } from '../consumed-verifier.ts';
|
|
4
6
|
import { type SignalHost } from './signals.ts';
|
|
5
7
|
interface ParsedArgs {
|
|
6
8
|
orderId?: string;
|
|
@@ -29,10 +31,16 @@ export interface RunDeps {
|
|
|
29
31
|
signalHost?: SignalHost;
|
|
30
32
|
hub?: HubClient;
|
|
31
33
|
runner?: CommandRunner;
|
|
34
|
+
/** Store-backed instruction resolver; injected tests may provide a fake. */
|
|
35
|
+
instructions?: InstructionResolver;
|
|
36
|
+
/** Consume-side verifier; injected tests may provide a fake. */
|
|
37
|
+
consumedVerifier?: ConsumedVerifier;
|
|
32
38
|
out?: (line: string) => void;
|
|
33
39
|
err?: (line: string) => void;
|
|
34
40
|
/** cwd for a command order that carries no `workdir` (default `process.cwd()`). */
|
|
35
41
|
cwd?: string;
|
|
42
|
+
/** Environment used to derive the global workflow-store root. */
|
|
43
|
+
env?: Record<string, string | undefined>;
|
|
36
44
|
/** Holder id override (default `<hostname>:<pid>`) — pinned in tests. */
|
|
37
45
|
holderId?: string;
|
|
38
46
|
}
|
|
@@ -36,7 +36,9 @@ import { createHubClient } from "../hub/client.js";
|
|
|
36
36
|
import { resolveBearer } from "../credentials/resolve.js";
|
|
37
37
|
import { loadSettings } from "../settings/settings.js";
|
|
38
38
|
import { createExecLoop } from "../exec/loop.js";
|
|
39
|
+
import { createDefaultStoreInstructionResolver } from "../exec/instructions.js";
|
|
39
40
|
import { createDefaultRunner } from "../exec/runner.js";
|
|
41
|
+
import { createConsumedVerifier } from "../consumed-verifier.js";
|
|
40
42
|
import { resolveShiftId, resolveTarget } from "./hold.js";
|
|
41
43
|
import { installSignalHandlers } from "./signals.js";
|
|
42
44
|
const DEFAULT_INTERVAL_MS = 60_000;
|
|
@@ -115,14 +117,19 @@ export function exitCodeFor(outcome) {
|
|
|
115
117
|
switch (outcome) {
|
|
116
118
|
case 'submitted':
|
|
117
119
|
case 'completed':
|
|
120
|
+
case 'rejected':
|
|
121
|
+
case 'judge-rejected':
|
|
118
122
|
return 0;
|
|
119
123
|
case 'misroute':
|
|
124
|
+
case 'unresolved-instructions':
|
|
120
125
|
case 'killed':
|
|
121
126
|
case 'lease-lost':
|
|
122
127
|
case 'ownership-error':
|
|
123
128
|
case 'hub-unreachable':
|
|
124
129
|
case 'submit-rejected':
|
|
125
130
|
case 'submit-failed':
|
|
131
|
+
case 'judge-no-verdict':
|
|
132
|
+
case 'reject-failed':
|
|
126
133
|
case 'stopped':
|
|
127
134
|
return 1;
|
|
128
135
|
}
|
|
@@ -147,7 +154,7 @@ export async function run(args, deps = {}) {
|
|
|
147
154
|
usage();
|
|
148
155
|
return 2;
|
|
149
156
|
}
|
|
150
|
-
const env = process.env;
|
|
157
|
+
const env = deps.env ?? process.env;
|
|
151
158
|
let settings;
|
|
152
159
|
try {
|
|
153
160
|
settings = loadSettings(env);
|
|
@@ -156,11 +163,26 @@ export async function run(args, deps = {}) {
|
|
|
156
163
|
err(`owenloop work exec: ${errMsg(e)}`);
|
|
157
164
|
return 1;
|
|
158
165
|
}
|
|
166
|
+
const consumedVerifier = deps.consumedVerifier ?? createConsumedVerifier({
|
|
167
|
+
env,
|
|
168
|
+
now: () => Date.now(),
|
|
169
|
+
});
|
|
159
170
|
const origin = parsed.origin ?? settings.hubOrigin;
|
|
160
171
|
if (origin === undefined || origin.trim() === '') {
|
|
161
172
|
err('owenloop work exec: no hub origin — pass --origin <url> or set hubOrigin in settings');
|
|
162
173
|
return 2;
|
|
163
174
|
}
|
|
175
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
176
|
+
let instructions = deps.instructions;
|
|
177
|
+
if (instructions === undefined) {
|
|
178
|
+
try {
|
|
179
|
+
instructions = createDefaultStoreInstructionResolver({ cwd, env, consumedVerifier });
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
err(`owenloop work exec: instruction store unavailable: ${errMsg(e)}`);
|
|
183
|
+
return 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
164
186
|
const account = env['OWENLOOP_ACCOUNT'] ?? 'default';
|
|
165
187
|
const bearer = await resolveBearer({ origin, account, env });
|
|
166
188
|
if (!bearer.ok) {
|
|
@@ -181,8 +203,11 @@ export async function run(args, deps = {}) {
|
|
|
181
203
|
runner,
|
|
182
204
|
workflow: target.workflow,
|
|
183
205
|
run: target.run,
|
|
206
|
+
origin,
|
|
207
|
+
env,
|
|
184
208
|
holder,
|
|
185
|
-
|
|
209
|
+
instructions,
|
|
210
|
+
cwd,
|
|
186
211
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
187
212
|
now: () => Date.now(),
|
|
188
213
|
out,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type HubClient } from '../hub/client.ts';
|
|
2
2
|
import { type HoldOutcome } from '../hold/loop.ts';
|
|
3
|
+
import { type HoldMcpToolName } from '../hold/mcp.ts';
|
|
3
4
|
import type { ContactHolder } from '../hub/types.ts';
|
|
4
5
|
import { type SignalHost, type StdinHost } from './signals.ts';
|
|
5
6
|
interface ParsedArgs {
|
|
@@ -13,6 +14,7 @@ interface ParsedArgs {
|
|
|
13
14
|
jumpToleranceMs?: number;
|
|
14
15
|
ignoreStdin: boolean;
|
|
15
16
|
mcp: boolean;
|
|
17
|
+
mcpTools?: HoldMcpToolName[];
|
|
16
18
|
error?: string;
|
|
17
19
|
}
|
|
18
20
|
/** Parse `--flag value` and `--flag=value`; unknown flags are an error. */
|
|
@@ -63,6 +65,8 @@ export interface RunDeps {
|
|
|
63
65
|
hub?: HubClient;
|
|
64
66
|
out?: (line: string) => void;
|
|
65
67
|
err?: (line: string) => void;
|
|
68
|
+
/** Environment used for settings and local trust-root resolution. */
|
|
69
|
+
env?: Record<string, string | undefined>;
|
|
66
70
|
}
|
|
67
71
|
export declare function run(args: string[], deps?: RunDeps): Promise<number>;
|
|
68
72
|
export {};
|
|
@@ -41,13 +41,31 @@ import { createHubClient } from "../hub/client.js";
|
|
|
41
41
|
import { resolveBearer } from "../credentials/resolve.js";
|
|
42
42
|
import { loadSettings } from "../settings/settings.js";
|
|
43
43
|
import { createHoldLoop } from "../hold/loop.js";
|
|
44
|
-
import { createHoldMcp } from "../hold/mcp.js";
|
|
44
|
+
import { createHoldMcp, HOLD_MCP_TOOL_NAMES } from "../hold/mcp.js";
|
|
45
|
+
import { createConsumedVerifier } from "../consumed-verifier.js";
|
|
45
46
|
import { createMcpServer, pumpStdin } from "../mcp/server.js";
|
|
46
47
|
import { installSignalHandlers, watchStdinEof } from "./signals.js";
|
|
47
48
|
const DEFAULT_INTERVAL_MS = 60_000;
|
|
48
49
|
// Deliberate duplicate of main.ts's VERSION (also '0.0.0'): the roles must not
|
|
49
50
|
// import the CLI entry module, and the MCP serverInfo version is cosmetic.
|
|
50
51
|
const VERSION = '0.0.0';
|
|
52
|
+
function parseMcpTools(value) {
|
|
53
|
+
const names = value.split(',');
|
|
54
|
+
if (names.length === 0 || names.some((name) => name === '')) {
|
|
55
|
+
return { error: '--mcp-tools must be a comma-separated list with no empty names' };
|
|
56
|
+
}
|
|
57
|
+
const allowed = new Set(HOLD_MCP_TOOL_NAMES);
|
|
58
|
+
const unknown = names.filter((name) => !allowed.has(name));
|
|
59
|
+
if (unknown.length > 0) {
|
|
60
|
+
return {
|
|
61
|
+
error: `--mcp-tools contains unknown tool(s): ${unknown.join(', ')}; expected ${HOLD_MCP_TOOL_NAMES.join(',')}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (new Set(names).size !== names.length) {
|
|
65
|
+
return { error: '--mcp-tools must not contain duplicate names' };
|
|
66
|
+
}
|
|
67
|
+
return names;
|
|
68
|
+
}
|
|
51
69
|
/** Parse `--flag value` and `--flag=value`; unknown flags are an error. */
|
|
52
70
|
export function parseArgs(args) {
|
|
53
71
|
const parsed = { ignoreStdin: false, mcp: false };
|
|
@@ -77,7 +95,8 @@ export function parseArgs(args) {
|
|
|
77
95
|
case '--as':
|
|
78
96
|
case '--shift':
|
|
79
97
|
case '--heartbeat-interval':
|
|
80
|
-
case '--jump-tolerance':
|
|
98
|
+
case '--jump-tolerance':
|
|
99
|
+
case '--mcp-tools': {
|
|
81
100
|
const r = takeValue(a, i);
|
|
82
101
|
if ('error' in r)
|
|
83
102
|
return { ignoreStdin: false, mcp: false, error: r.error };
|
|
@@ -94,6 +113,12 @@ export function parseArgs(args) {
|
|
|
94
113
|
parsed.as = r.value;
|
|
95
114
|
else if (name === '--shift')
|
|
96
115
|
parsed.shift = r.value;
|
|
116
|
+
else if (name === '--mcp-tools') {
|
|
117
|
+
const selected = parseMcpTools(r.value);
|
|
118
|
+
if ('error' in selected)
|
|
119
|
+
return { ignoreStdin: false, mcp: false, error: selected.error };
|
|
120
|
+
parsed.mcpTools = selected;
|
|
121
|
+
}
|
|
97
122
|
else if (name === '--heartbeat-interval') {
|
|
98
123
|
const n = Number(r.value);
|
|
99
124
|
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) {
|
|
@@ -145,6 +170,7 @@ export function resolveTarget(order, workflowFlag) {
|
|
|
145
170
|
function usage() {
|
|
146
171
|
process.stderr.write('usage: owenloop work hold --order <workflow>/<run> [--origin <url>] [--as <account>] [--session <id>]\n' +
|
|
147
172
|
' [--shift <id>] [--heartbeat-interval <ms>] [--jump-tolerance <ms>] [--ignore-stdin] [--mcp]\n' +
|
|
173
|
+
' [--mcp-tools <get_order,submit,reject>]\n' +
|
|
148
174
|
' or: owenloop work hold --order <run> --workflow <wf> [...]\n');
|
|
149
175
|
}
|
|
150
176
|
function errMsg(err) {
|
|
@@ -213,13 +239,18 @@ export async function run(args, deps = {}) {
|
|
|
213
239
|
usage();
|
|
214
240
|
return 2;
|
|
215
241
|
}
|
|
242
|
+
if (parsed.mcpTools !== undefined && !parsed.mcp) {
|
|
243
|
+
err('owenloop work hold: --mcp-tools requires --mcp');
|
|
244
|
+
usage();
|
|
245
|
+
return 2;
|
|
246
|
+
}
|
|
216
247
|
const target = resolveTarget(parsed.order, parsed.workflow);
|
|
217
248
|
if ('error' in target) {
|
|
218
249
|
err(`owenloop work hold: ${target.error}`);
|
|
219
250
|
usage();
|
|
220
251
|
return 2;
|
|
221
252
|
}
|
|
222
|
-
const env = process.env;
|
|
253
|
+
const env = deps.env ?? process.env;
|
|
223
254
|
let settings;
|
|
224
255
|
try {
|
|
225
256
|
settings = loadSettings(env);
|
|
@@ -247,8 +278,9 @@ export async function run(args, deps = {}) {
|
|
|
247
278
|
const shiftId = resolveShiftId(parsed.shift, env);
|
|
248
279
|
const holder = resolveHolder(parsed.session, env, { shiftId });
|
|
249
280
|
const hub = deps.hub ?? createHubClient({ origin, getToken: async () => token });
|
|
250
|
-
// --mcp: run the born-bound work-holder as a stdio MCP server
|
|
251
|
-
// submit
|
|
281
|
+
// --mcp: run the born-bound work-holder as a stdio MCP server. The default
|
|
282
|
+
// registers get_order/submit/reject; --mcp-tools selects an exact positive
|
|
283
|
+
// subset. The lease loop stays warm underneath. stdout is the JSON-RPC
|
|
252
284
|
// channel, so every diagnostic (and the loop's own lines) goes to stderr;
|
|
253
285
|
// stdin is the transport, and its EOF (the session died) fires the final
|
|
254
286
|
// breath.
|
|
@@ -257,6 +289,13 @@ export async function run(args, deps = {}) {
|
|
|
257
289
|
hub,
|
|
258
290
|
workflow: target.workflow,
|
|
259
291
|
run: target.run,
|
|
292
|
+
...(parsed.mcpTools !== undefined ? { tools: parsed.mcpTools } : {}),
|
|
293
|
+
origin,
|
|
294
|
+
env,
|
|
295
|
+
consumedVerifier: createConsumedVerifier({
|
|
296
|
+
env,
|
|
297
|
+
now: () => Date.now(),
|
|
298
|
+
}),
|
|
260
299
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
261
300
|
now: () => Date.now(),
|
|
262
301
|
err,
|
|
@@ -39,10 +39,9 @@ export declare function run(args: string[]): Promise<number>;
|
|
|
39
39
|
* Findings for ONE step: resolve which adapter would run it, then hand that
|
|
40
40
|
* adapter the step's option bag.
|
|
41
41
|
*
|
|
42
|
-
* A step
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* and carries no options is clean even in a build with an empty registry.
|
|
42
|
+
* A step that omits both the harness id and the `x.harness` bag is silent — lint
|
|
43
|
+
* has no explicit selection or options to judge. An explicit id is checked even
|
|
44
|
+
* when no option bag exists, because dispatch would still try to resolve that id.
|
|
46
45
|
*
|
|
47
46
|
* ONE finding is raised HERE rather than by the adapter: the bag-`model` /
|
|
48
47
|
* first-class-`model` conflict. The harness contract's `lintStep(bag, step)`
|
|
@@ -35,6 +35,7 @@ import "../harnesses.js";
|
|
|
35
35
|
import { existsSync, readFileSync } from 'node:fs';
|
|
36
36
|
import { parse as parseYaml } from 'yaml';
|
|
37
37
|
import { adapterFor, defaultHarnessId } from "../harness/registry.js";
|
|
38
|
+
import { normalizeStepPermissions, preflightStepPermissions, validateHarnessOptions, } from "../harness/permissions.js";
|
|
38
39
|
import { parseHarnessCarrier } from "../bundle/fetch.js";
|
|
39
40
|
import { readLatestBundle, resolveCacheDir } from "../bundle/cache.js";
|
|
40
41
|
import { loadSettings } from "../settings/settings.js";
|
|
@@ -86,10 +87,9 @@ export async function run(args) {
|
|
|
86
87
|
* Findings for ONE step: resolve which adapter would run it, then hand that
|
|
87
88
|
* adapter the step's option bag.
|
|
88
89
|
*
|
|
89
|
-
* A step
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* and carries no options is clean even in a build with an empty registry.
|
|
90
|
+
* A step that omits both the harness id and the `x.harness` bag is silent — lint
|
|
91
|
+
* has no explicit selection or options to judge. An explicit id is checked even
|
|
92
|
+
* when no option bag exists, because dispatch would still try to resolve that id.
|
|
93
93
|
*
|
|
94
94
|
* ONE finding is raised HERE rather than by the adapter: the bag-`model` /
|
|
95
95
|
* first-class-`model` conflict. The harness contract's `lintStep(bag, step)`
|
|
@@ -105,9 +105,20 @@ export async function run(args) {
|
|
|
105
105
|
*/
|
|
106
106
|
export function lintOneStep(step) {
|
|
107
107
|
const bag = step.harnessOptions;
|
|
108
|
+
const id = step.harness ?? defaultHarnessId();
|
|
109
|
+
// An explicit id is independently lintable: naming an adapter this build does
|
|
110
|
+
// not have is an error even when the step carries no adapter option fields.
|
|
111
|
+
// Omission with no bag remains clean because there is nothing to validate.
|
|
112
|
+
if (step.harness !== undefined && adapterFor(step.harness) === undefined) {
|
|
113
|
+
return [{
|
|
114
|
+
severity: 'error',
|
|
115
|
+
step: step.name,
|
|
116
|
+
message: `unknown harness '${step.harness}' — this build cannot run it`,
|
|
117
|
+
field: 'id',
|
|
118
|
+
}];
|
|
119
|
+
}
|
|
108
120
|
if (bag === undefined)
|
|
109
121
|
return [];
|
|
110
|
-
const id = step.harness ?? defaultHarnessId();
|
|
111
122
|
if (id === undefined) {
|
|
112
123
|
return [{
|
|
113
124
|
severity: 'error',
|
|
@@ -124,7 +135,23 @@ export function lintOneStep(step) {
|
|
|
124
135
|
field: 'id',
|
|
125
136
|
}];
|
|
126
137
|
}
|
|
127
|
-
const
|
|
138
|
+
const permissions = normalizeStepPermissions(bag, step);
|
|
139
|
+
const findings = [
|
|
140
|
+
...validateHarnessOptions(bag, step.name),
|
|
141
|
+
...preflightStepPermissions(permissions).map((issue) => ({
|
|
142
|
+
severity: 'error',
|
|
143
|
+
step: step.name,
|
|
144
|
+
message: issue.message,
|
|
145
|
+
...(issue.field !== undefined ? { field: issue.field } : {}),
|
|
146
|
+
})),
|
|
147
|
+
...adapter.preflight(permissions).map((issue) => ({
|
|
148
|
+
severity: 'error',
|
|
149
|
+
step: step.name,
|
|
150
|
+
message: issue.message,
|
|
151
|
+
...(issue.field !== undefined ? { field: issue.field } : {}),
|
|
152
|
+
})),
|
|
153
|
+
...(adapter.lintStep?.(bag, step.name) ?? []),
|
|
154
|
+
];
|
|
128
155
|
if (step.model !== undefined && 'model' in bag) {
|
|
129
156
|
findings.push({
|
|
130
157
|
severity: 'warning',
|
|
@@ -133,7 +160,14 @@ export function lintOneStep(step) {
|
|
|
133
160
|
message: `bag sets model but the step's first-class model wins (step model: '${step.model}')`,
|
|
134
161
|
});
|
|
135
162
|
}
|
|
136
|
-
|
|
163
|
+
const seen = new Set();
|
|
164
|
+
return findings.filter((finding) => {
|
|
165
|
+
const key = `${finding.severity}\0${finding.step}\0${finding.field ?? ''}\0${finding.message}`;
|
|
166
|
+
if (seen.has(key))
|
|
167
|
+
return false;
|
|
168
|
+
seen.add(key);
|
|
169
|
+
return true;
|
|
170
|
+
});
|
|
137
171
|
}
|
|
138
172
|
/** Load the steps to lint from a yaml def, a json bundle, or a bare name. */
|
|
139
173
|
function loadSteps(target) {
|
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
* the file is malformed JSON or a known key has the wrong type · 2 on stray
|
|
13
13
|
* args (there are no options in v1).
|
|
14
14
|
*/
|
|
15
|
+
import { DEFAULT_TIER_MAP } from "../agent/model-policy.js";
|
|
15
16
|
import { inspectSettings, KNOWN_SETTINGS_KEYS } from "../settings/settings.js";
|
|
16
17
|
/** Built-in defaults shown for knobs absent from the file (else `unset`). */
|
|
17
18
|
const DEFAULT_NOTE = {
|
|
18
19
|
dispatchCap: '3',
|
|
19
20
|
commandRouting: 'shift',
|
|
21
|
+
defPolicy: 'warn',
|
|
22
|
+
tierMap: JSON.stringify(DEFAULT_TIER_MAP),
|
|
23
|
+
escalateAt: '3',
|
|
24
|
+
escalationExtensionKey: 'delivery',
|
|
20
25
|
};
|
|
21
26
|
function errMsg(err) {
|
|
22
27
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -8,5 +8,6 @@ declare function resolveSocketPath(flag: string | undefined): {
|
|
|
8
8
|
path?: string;
|
|
9
9
|
error?: string;
|
|
10
10
|
};
|
|
11
|
+
export declare function shiftDaemonClientPlatformError(command: 'next' | 'status' | 'end', platform?: NodeJS.Platform): string | undefined;
|
|
11
12
|
export declare function run(args: string[]): Promise<number>;
|
|
12
13
|
export { parseStartArgs, resolveSocketPath };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { loadSettings } from "../settings/settings.js";
|
|
9
9
|
import { resolveStateDir } from "../shift/state.js";
|
|
10
|
-
import { resolveStateDirOverride, runShiftRuntime } from "../shift/runtime.js";
|
|
10
|
+
import { assertShiftDaemonPlatform, resolveStateDirOverride, runShiftRuntime, } from "../shift/runtime.js";
|
|
11
11
|
import { noDaemonMessage, parseNextArgs, parseStateDirArgs, requestShift, ShiftClientError, shiftSocketPath, } from "../shift/client.js";
|
|
12
12
|
import { isShiftError } from "../shift/protocol.js";
|
|
13
13
|
function usage() {
|
|
@@ -114,6 +114,22 @@ function resolveSocketPath(flag) {
|
|
|
114
114
|
function printJson(value) {
|
|
115
115
|
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
116
116
|
}
|
|
117
|
+
export function shiftDaemonClientPlatformError(command, platform = process.platform) {
|
|
118
|
+
try {
|
|
119
|
+
assertShiftDaemonPlatform(platform);
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return `owenloop shift ${command}: ${error instanceof Error ? error.message : String(error)}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function rejectUnsupportedDaemonClient(command) {
|
|
127
|
+
const error = shiftDaemonClientPlatformError(command);
|
|
128
|
+
if (error === undefined)
|
|
129
|
+
return false;
|
|
130
|
+
process.stderr.write(`${error}\n`);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
117
133
|
async function runNext(args) {
|
|
118
134
|
const parsed = parseNextArgs(args);
|
|
119
135
|
if (parsed.error !== undefined) {
|
|
@@ -121,6 +137,8 @@ async function runNext(args) {
|
|
|
121
137
|
usage();
|
|
122
138
|
return 2;
|
|
123
139
|
}
|
|
140
|
+
if (rejectUnsupportedDaemonClient('next'))
|
|
141
|
+
return 1;
|
|
124
142
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
125
143
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
126
144
|
process.stderr.write(`owenloop shift next: ${socket.error ?? 'cannot resolve state directory'}\n`);
|
|
@@ -147,6 +165,8 @@ async function runStatus(args) {
|
|
|
147
165
|
usage();
|
|
148
166
|
return 2;
|
|
149
167
|
}
|
|
168
|
+
if (rejectUnsupportedDaemonClient('status'))
|
|
169
|
+
return 1;
|
|
150
170
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
151
171
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
152
172
|
process.stderr.write(`owenloop shift status: ${socket.error ?? 'cannot resolve state directory'}\n`);
|
|
@@ -177,6 +197,8 @@ async function runEnd(args) {
|
|
|
177
197
|
usage();
|
|
178
198
|
return 2;
|
|
179
199
|
}
|
|
200
|
+
if (rejectUnsupportedDaemonClient('end'))
|
|
201
|
+
return 1;
|
|
180
202
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
181
203
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
182
204
|
process.stderr.write(`owenloop shift end: ${socket.error ?? 'cannot resolve state directory'}\n`);
|