owenloop 0.5.0 → 0.5.2
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 +67 -0
- package/README.md +144 -35
- package/bin/owenloop.mjs +49 -1
- package/dist/packages/work/src/agent/brief.d.ts +29 -4
- package/dist/packages/work/src/agent/brief.js +49 -4
- package/dist/packages/work/src/agent/capability-model.d.ts +123 -0
- package/dist/packages/work/src/agent/capability-model.js +148 -0
- package/dist/packages/work/src/agent/loop.d.ts +56 -7
- package/dist/packages/work/src/agent/loop.js +166 -9
- 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 +29 -1
- package/dist/packages/work/src/exec/loop.js +313 -35
- 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 +84 -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 +30 -10
- package/dist/packages/work/src/harness/session-store.js +317 -89
- package/dist/packages/work/src/hold/mcp.d.ts +25 -5
- package/dist/packages/work/src/hold/mcp.js +134 -12
- package/dist/packages/work/src/hub/client.d.ts +8 -1
- package/dist/packages/work/src/hub/client.js +15 -1
- package/dist/packages/work/src/hub/types.d.ts +137 -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 +115 -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 +6 -0
- package/dist/packages/work/src/roles/hold.js +83 -13
- 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 +19 -2
- package/dist/packages/work/src/roles/shift.d.ts +1 -0
- package/dist/packages/work/src/roles/shift.js +36 -2
- package/dist/packages/work/src/settings/settings.d.ts +70 -1
- package/dist/packages/work/src/settings/settings.js +90 -4
- package/dist/packages/work/src/shift/logretention.d.ts +253 -0
- package/dist/packages/work/src/shift/logretention.js +407 -0
- package/dist/packages/work/src/shift/logsink.d.ts +14 -0
- package/dist/packages/work/src/shift/logsink.js +98 -0
- package/dist/packages/work/src/shift/loop.d.ts +32 -4
- package/dist/packages/work/src/shift/loop.js +687 -166
- package/dist/packages/work/src/shift/protocol.d.ts +128 -1
- package/dist/packages/work/src/shift/protocol.js +14 -0
- package/dist/packages/work/src/shift/runtime.d.ts +16 -0
- package/dist/packages/work/src/shift/runtime.js +291 -5
- package/dist/packages/work/src/shift/server.d.ts +13 -0
- package/dist/packages/work/src/shift/server.js +61 -36
- package/dist/packages/work/src/shift/spawn.d.ts +115 -19
- package/dist/packages/work/src/shift/spawn.js +234 -30
- package/dist/packages/work/src/shift/state.d.ts +76 -49
- package/dist/packages/work/src/shift/state.js +350 -103
- package/dist/packages/work/src/shift/truncate.d.ts +35 -0
- package/dist/packages/work/src/shift/truncate.js +73 -0
- package/dist/packages/work/src/submit-proof.d.ts +61 -0
- package/dist/packages/work/src/submit-proof.js +119 -0
- package/dist/packages/work/src/submit-value.d.ts +48 -0
- package/dist/packages/work/src/submit-value.js +118 -0
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +11 -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/capabilities.d.ts +93 -0
- package/dist/src/capabilities.js +101 -0
- package/dist/src/cli.d.ts +90 -20
- package/dist/src/cli.js +2421 -374
- 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 +319 -0
- package/dist/src/crypto/records.js +168 -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 +335 -27
- package/dist/src/engine.d.ts +211 -6
- package/dist/src/engine.js +459 -59
- 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 +102 -32
- package/dist/src/hub.js +147 -58
- package/dist/src/index.d.ts +19 -2
- package/dist/src/index.js +23 -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 +174 -44
- package/dist/src/mcp/server.js +12 -1
- package/dist/src/model.d.ts +51 -0
- package/dist/src/model.js +157 -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 +1433 -0
- package/dist/src/schemas/index.js +31 -0
- package/dist/src/schemas/order.v1.schema.json +120 -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/store.d.ts +33 -1
- package/dist/src/store.js +57 -4
- package/dist/src/types.d.ts +146 -12
- 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 +64 -6
- package/docs/bundles.md +350 -0
- package/docs/cli.md +1298 -106
- package/docs/crypto.md +832 -0
- package/docs/design.md +342 -20
- package/docs/embedding.md +132 -25
- package/docs/shift-logs.md +642 -0
- package/docs/wire-contracts.md +395 -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
|
@@ -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) {
|
|
@@ -13,10 +13,18 @@
|
|
|
13
13
|
* args (there are no options in v1).
|
|
14
14
|
*/
|
|
15
15
|
import { inspectSettings, KNOWN_SETTINGS_KEYS } from "../settings/settings.js";
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Built-in defaults shown for knobs absent from the file (else `unset`).
|
|
18
|
+
*
|
|
19
|
+
* `capabilityModels` is deliberately absent: it HAS no built-in default. A shift
|
|
20
|
+
* with no row for an order's capability refuses that order rather than falling
|
|
21
|
+
* back to some default model, so printing a default here would describe
|
|
22
|
+
* behaviour that does not exist.
|
|
23
|
+
*/
|
|
17
24
|
const DEFAULT_NOTE = {
|
|
18
25
|
dispatchCap: '3',
|
|
19
26
|
commandRouting: 'shift',
|
|
27
|
+
defPolicy: 'warn',
|
|
20
28
|
};
|
|
21
29
|
function errMsg(err) {
|
|
22
30
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -38,7 +46,7 @@ export async function run(args, deps = {}) {
|
|
|
38
46
|
err(`owenloop work settings: ${errMsg(e)}`);
|
|
39
47
|
return 1;
|
|
40
48
|
}
|
|
41
|
-
const { path, exists, settings, unrecognized } = inspection;
|
|
49
|
+
const { path, exists, settings, unrecognized, warnings } = inspection;
|
|
42
50
|
out(`settings file: ${path}`);
|
|
43
51
|
out(`exists: ${exists ? 'yes' : 'no'}`);
|
|
44
52
|
out('');
|
|
@@ -58,6 +66,15 @@ export async function run(args, deps = {}) {
|
|
|
58
66
|
out('');
|
|
59
67
|
out(`unrecognized keys (ignored — likely typos): ${unrecognized.join(', ')}`);
|
|
60
68
|
}
|
|
69
|
+
// Warnings are keys owenloop still recognizes but no longer acts on. They do
|
|
70
|
+
// not fail the load and so do not change the exit code; a shift that starts on
|
|
71
|
+
// this file starts fine. They print because the alternative is the operator
|
|
72
|
+
// continuing to believe a dead knob does something.
|
|
73
|
+
if (warnings.length > 0) {
|
|
74
|
+
out('');
|
|
75
|
+
for (const warning of warnings)
|
|
76
|
+
out(`warning: ${warning}`);
|
|
77
|
+
}
|
|
61
78
|
return 0;
|
|
62
79
|
}
|
|
63
80
|
/** Render a settings value for display: strings bare, everything else JSON. */
|
|
@@ -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,13 +7,14 @@
|
|
|
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() {
|
|
14
14
|
process.stderr.write('usage: owenloop shift start <crew...> [--all] [--origin <url>] [--as <account>] [--name <n>]\n' +
|
|
15
15
|
' [--cap <n>] [--max-agents <n>] [--poll-interval <ms>] [--once]\n' +
|
|
16
16
|
' [--cache-dir <p>] [--state-dir <p>]\n' +
|
|
17
|
+
' [--log-dir <p>] [--log-max-age <ms>]\n' +
|
|
17
18
|
' owenloop shift next [--wait <seconds>] [--state-dir <p>]\n' +
|
|
18
19
|
' owenloop shift status [--state-dir <p>]\n' +
|
|
19
20
|
' owenloop shift end [--state-dir <p>]\n');
|
|
@@ -27,7 +28,10 @@ function intValue(raw, flag) {
|
|
|
27
28
|
}
|
|
28
29
|
function parseStartArgs(args) {
|
|
29
30
|
const parsed = { crews: [] };
|
|
30
|
-
const valueFlags = new Set([
|
|
31
|
+
const valueFlags = new Set([
|
|
32
|
+
'--origin', '--as', '--name', '--cap', '--max-agents', '--poll-interval',
|
|
33
|
+
'--cache-dir', '--state-dir', '--log-dir', '--log-max-age',
|
|
34
|
+
]);
|
|
31
35
|
for (let i = 0; i < args.length; i++) {
|
|
32
36
|
const raw = args[i];
|
|
33
37
|
const name = raw.startsWith('--') && raw.includes('=') ? raw.slice(0, raw.indexOf('=')) : raw;
|
|
@@ -57,6 +61,14 @@ function parseStartArgs(args) {
|
|
|
57
61
|
parsed.cacheDir = value;
|
|
58
62
|
else if (name === '--state-dir')
|
|
59
63
|
parsed.stateDir = value;
|
|
64
|
+
else if (name === '--log-dir')
|
|
65
|
+
parsed.logDir = value;
|
|
66
|
+
else if (name === '--log-max-age') {
|
|
67
|
+
const n = intValue(value, '--log-max-age');
|
|
68
|
+
if (typeof n !== 'number')
|
|
69
|
+
return { crews: parsed.crews, error: n };
|
|
70
|
+
parsed.logMaxAgeMs = n;
|
|
71
|
+
}
|
|
60
72
|
else if (name === '--cap') {
|
|
61
73
|
const n = intValue(value, '--cap');
|
|
62
74
|
if (typeof n !== 'number')
|
|
@@ -114,6 +126,22 @@ function resolveSocketPath(flag) {
|
|
|
114
126
|
function printJson(value) {
|
|
115
127
|
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
116
128
|
}
|
|
129
|
+
export function shiftDaemonClientPlatformError(command, platform = process.platform) {
|
|
130
|
+
try {
|
|
131
|
+
assertShiftDaemonPlatform(platform);
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return `owenloop shift ${command}: ${error instanceof Error ? error.message : String(error)}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function rejectUnsupportedDaemonClient(command) {
|
|
139
|
+
const error = shiftDaemonClientPlatformError(command);
|
|
140
|
+
if (error === undefined)
|
|
141
|
+
return false;
|
|
142
|
+
process.stderr.write(`${error}\n`);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
117
145
|
async function runNext(args) {
|
|
118
146
|
const parsed = parseNextArgs(args);
|
|
119
147
|
if (parsed.error !== undefined) {
|
|
@@ -121,6 +149,8 @@ async function runNext(args) {
|
|
|
121
149
|
usage();
|
|
122
150
|
return 2;
|
|
123
151
|
}
|
|
152
|
+
if (rejectUnsupportedDaemonClient('next'))
|
|
153
|
+
return 1;
|
|
124
154
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
125
155
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
126
156
|
process.stderr.write(`owenloop shift next: ${socket.error ?? 'cannot resolve state directory'}\n`);
|
|
@@ -147,6 +177,8 @@ async function runStatus(args) {
|
|
|
147
177
|
usage();
|
|
148
178
|
return 2;
|
|
149
179
|
}
|
|
180
|
+
if (rejectUnsupportedDaemonClient('status'))
|
|
181
|
+
return 1;
|
|
150
182
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
151
183
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
152
184
|
process.stderr.write(`owenloop shift status: ${socket.error ?? 'cannot resolve state directory'}\n`);
|
|
@@ -177,6 +209,8 @@ async function runEnd(args) {
|
|
|
177
209
|
usage();
|
|
178
210
|
return 2;
|
|
179
211
|
}
|
|
212
|
+
if (rejectUnsupportedDaemonClient('end'))
|
|
213
|
+
return 1;
|
|
180
214
|
const socket = resolveSocketPath(parsed.stateDir);
|
|
181
215
|
if (socket.error !== undefined || socket.path === undefined) {
|
|
182
216
|
process.stderr.write(`owenloop shift end: ${socket.error ?? 'cannot resolve state directory'}\n`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CapabilityModelRow } from '../agent/capability-model.ts';
|
|
1
2
|
/**
|
|
2
3
|
* The settings surface — every knob optional, a missing file loading as `{}`.
|
|
3
4
|
* Each field is the lowest-precedence fallback for a role option (a CLI flag
|
|
@@ -10,7 +11,12 @@
|
|
|
10
11
|
* (below `OWENLOOP_STATE_DIR`).
|
|
11
12
|
* - `dispatchCap` — shift max in-flight exec children; below `--cap`,
|
|
12
13
|
* above the built-in default of 3. A positive integer.
|
|
14
|
+
* - `shiftLogDir` — where `shift.log` and `<run>.log` are written; below
|
|
15
|
+
* `--log-dir` and `OWENLOOP_SHIFT_LOG_DIR`, above the state dir.
|
|
16
|
+
* - `shiftLogMaxAgeMs` — worker-log retention in ms; below `--log-max-age`
|
|
17
|
+
* and `OWENLOOP_SHIFT_LOG_MAX_AGE_MS`, above the 14-day default.
|
|
13
18
|
* - `commandRouting` — who runs `executor: 'command'` steps this machine sees.
|
|
19
|
+
* - `defPolicy` — local publication trust policy (`warn` by default).
|
|
14
20
|
*/
|
|
15
21
|
export interface Settings {
|
|
16
22
|
/** Default hub origin when `--origin` is omitted. */
|
|
@@ -21,6 +27,24 @@ export interface Settings {
|
|
|
21
27
|
stateDir?: string;
|
|
22
28
|
/** Shift dispatch cap (positive integer); fallback below `--cap`, default 3. */
|
|
23
29
|
dispatchCap?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Directory holding the shift's own `shift.log` and each worker's `<run>.log`.
|
|
32
|
+
* Fallback below `--log-dir` and `OWENLOOP_SHIFT_LOG_DIR`; defaults to the
|
|
33
|
+
* resolved `stateDir`, which puts `<run>.log` beside its `<run>.json`.
|
|
34
|
+
*/
|
|
35
|
+
shiftLogDir?: string;
|
|
36
|
+
/**
|
|
37
|
+
* How long a worker's `<run>.log` is kept, in milliseconds. Fallback below
|
|
38
|
+
* `--log-max-age` and `OWENLOOP_SHIFT_LOG_MAX_AGE_MS`; defaults to 14 days.
|
|
39
|
+
*
|
|
40
|
+
* A NON-NEGATIVE integer, unlike `dispatchCap`, which must be positive: `0`
|
|
41
|
+
* is meaningful here and means "reap every worker log whose run has
|
|
42
|
+
* completed, at the next shift startup".
|
|
43
|
+
*
|
|
44
|
+
* Applies ONLY to per-worker `<run>.log` files. `shift.log` is never reaped
|
|
45
|
+
* and never rotated — see `docs/shift-logs.md`.
|
|
46
|
+
*/
|
|
47
|
+
shiftLogMaxAgeMs?: number;
|
|
24
48
|
/**
|
|
25
49
|
* Who runs `executor: 'command'` steps this machine sees: `'shift'` (default)
|
|
26
50
|
* lets the shift auto-dispatch them; `'manual'` leaves them for a human/
|
|
@@ -29,6 +53,15 @@ export interface Settings {
|
|
|
29
53
|
* most restrictive wins (see src/shift/routing.ts).
|
|
30
54
|
*/
|
|
31
55
|
commandRouting?: 'shift' | 'manual';
|
|
56
|
+
/**
|
|
57
|
+
* Publication trust policy for installed workflow definitions. `warn` is the
|
|
58
|
+
* built-in default; `enforce` refuses unsigned/unverifiable definitions and
|
|
59
|
+
* `off` suppresses those warnings for agent orders only. Command workers
|
|
60
|
+
* always require a verified definition regardless of this value.
|
|
61
|
+
*/
|
|
62
|
+
defPolicy?: 'enforce' | 'warn' | 'off';
|
|
63
|
+
/** Policy for signed consumed artifact values; defaults to `warn`. */
|
|
64
|
+
artifactPolicy?: 'enforce' | 'warn' | 'off';
|
|
32
65
|
/**
|
|
33
66
|
* Max in-flight `agent-run` children (positive integer, default 4 —
|
|
34
67
|
* `DEFAULT_MAX_AGENTS` in `src/roles/shift.ts`). A SEPARATE
|
|
@@ -66,9 +99,31 @@ export interface Settings {
|
|
|
66
99
|
* of the MACHINE running the shift, not of the workflow.
|
|
67
100
|
*/
|
|
68
101
|
workRepo?: string;
|
|
102
|
+
/**
|
|
103
|
+
* How THIS machine serves each capability: a flat map from capability to
|
|
104
|
+
* `{model, effort}`, keyed by the composed capability (`wise:deep`) or by the
|
|
105
|
+
* bare name (`wise`). See `src/agent/capability-model.ts` for the lookup rule
|
|
106
|
+
* and for why this replaced `tierMap`/`tierProfiles` outright.
|
|
107
|
+
*
|
|
108
|
+
* Carry a bare row per capability the shift's crews serve. The bare row is
|
|
109
|
+
* what makes a hub name-match fallback order resolvable — the hub can stamp
|
|
110
|
+
* `wise:deep` on an order claimed by a crew bound only to `wise:standard`,
|
|
111
|
+
* and that shift has no `wise:deep` row by construction.
|
|
112
|
+
*/
|
|
113
|
+
capabilityModels?: Record<string, CapabilityModelRow>;
|
|
69
114
|
}
|
|
70
115
|
/** The known settings keys, in the order `owenloop work settings` prints them. */
|
|
71
|
-
export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "commandRouting", "maxConcurrentAgents", "workRoot", "workRepo"];
|
|
116
|
+
export declare const KNOWN_SETTINGS_KEYS: readonly ["hubOrigin", "cacheDir", "stateDir", "dispatchCap", "shiftLogDir", "shiftLogMaxAgeMs", "commandRouting", "defPolicy", "artifactPolicy", "maxConcurrentAgents", "workRoot", "workRepo", "capabilityModels"];
|
|
117
|
+
/**
|
|
118
|
+
* Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
|
|
119
|
+
* warning naming what replaced it, and is excluded from `unrecognized` so the
|
|
120
|
+
* same key is not also reported as a likely typo.
|
|
121
|
+
*
|
|
122
|
+
* Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
|
|
123
|
+
* those would leave the shift with no capability map and refuse every order,
|
|
124
|
+
* whereas ignoring these changes nothing about how a shift runs.
|
|
125
|
+
*/
|
|
126
|
+
export declare const RETIRED_IGNORED_KEYS: readonly ["escalateAt", "escalationExtensionKey"];
|
|
72
127
|
/**
|
|
73
128
|
* A validated load: the typed `settings` (unknown keys retained for forward
|
|
74
129
|
* compatibility — consumers ignore them), plus the list of keys that are NOT
|
|
@@ -78,6 +133,20 @@ export interface ValidatedSettings {
|
|
|
78
133
|
settings: Settings;
|
|
79
134
|
/** Keys present in the file that owenloop does not recognize. */
|
|
80
135
|
unrecognized: string[];
|
|
136
|
+
/**
|
|
137
|
+
* Non-fatal findings from validation, in the order they were noticed.
|
|
138
|
+
*
|
|
139
|
+
* A SEPARATE CHANNEL FROM `unrecognized` because it answers a different
|
|
140
|
+
* question. `unrecognized` says "owenloop does not know this key at all,
|
|
141
|
+
* probably a typo"; a warning says "the key is known, but something about it
|
|
142
|
+
* is worth your attention" — today, only `RETIRED_IGNORED_KEYS`: a key
|
|
143
|
+
* owenloop still recognizes and no longer acts on.
|
|
144
|
+
*
|
|
145
|
+
* Callers decide what to do with these. `owenloop work settings` prints them;
|
|
146
|
+
* the shift prints them once at startup. Nothing here ever blocks a load —
|
|
147
|
+
* anything that should block throws instead.
|
|
148
|
+
*/
|
|
149
|
+
warnings: string[];
|
|
81
150
|
}
|
|
82
151
|
/** The result of inspecting the settings file: where it is, whether it exists, and its validated contents. */
|
|
83
152
|
export interface SettingsInspection extends ValidatedSettings {
|
|
@@ -14,17 +14,33 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync, readFileSync } from 'node:fs';
|
|
16
16
|
import { join } from 'node:path';
|
|
17
|
+
import { validateCapabilityModels } from "../agent/capability-model.js";
|
|
17
18
|
/** The known settings keys, in the order `owenloop work settings` prints them. */
|
|
18
19
|
export const KNOWN_SETTINGS_KEYS = [
|
|
19
20
|
'hubOrigin',
|
|
20
21
|
'cacheDir',
|
|
21
22
|
'stateDir',
|
|
22
23
|
'dispatchCap',
|
|
24
|
+
'shiftLogDir',
|
|
25
|
+
'shiftLogMaxAgeMs',
|
|
23
26
|
'commandRouting',
|
|
27
|
+
'defPolicy',
|
|
28
|
+
'artifactPolicy',
|
|
24
29
|
'maxConcurrentAgents',
|
|
25
30
|
'workRoot',
|
|
26
31
|
'workRepo',
|
|
32
|
+
'capabilityModels',
|
|
27
33
|
];
|
|
34
|
+
/**
|
|
35
|
+
* Keys owenloop still RECOGNIZES but no longer acts on. Each one produces a
|
|
36
|
+
* warning naming what replaced it, and is excluded from `unrecognized` so the
|
|
37
|
+
* same key is not also reported as a likely typo.
|
|
38
|
+
*
|
|
39
|
+
* Distinct from `tierMap`/`tierProfiles`, which are a hard error: ignoring
|
|
40
|
+
* those would leave the shift with no capability map and refuse every order,
|
|
41
|
+
* whereas ignoring these changes nothing about how a shift runs.
|
|
42
|
+
*/
|
|
43
|
+
export const RETIRED_IGNORED_KEYS = ['escalateAt', 'escalationExtensionKey'];
|
|
28
44
|
/**
|
|
29
45
|
* Resolve the settings file path from the caller's env:
|
|
30
46
|
* `$XDG_CONFIG_HOME/owenloop/settings.json` when `XDG_CONFIG_HOME` is set and
|
|
@@ -56,11 +72,20 @@ export function validateSettings(raw, path) {
|
|
|
56
72
|
throw new Error(`invalid settings file at ${path}: expected a JSON object, got ${got}`);
|
|
57
73
|
}
|
|
58
74
|
const obj = raw;
|
|
75
|
+
const warnings = [];
|
|
59
76
|
const bad = (key, expected, value) => new Error(`invalid settings file at ${path}: '${key}' must be ${expected}, got ${JSON.stringify(value)}`);
|
|
60
|
-
for (const key of ['hubOrigin', 'cacheDir', 'stateDir', 'workRoot', 'workRepo']) {
|
|
77
|
+
for (const key of ['hubOrigin', 'cacheDir', 'stateDir', 'shiftLogDir', 'workRoot', 'workRepo']) {
|
|
61
78
|
if (key in obj && typeof obj[key] !== 'string')
|
|
62
79
|
throw bad(key, 'a string', obj[key]);
|
|
63
80
|
}
|
|
81
|
+
if ('shiftLogMaxAgeMs' in obj) {
|
|
82
|
+
// NON-NEGATIVE, not positive: 0 means "reap every completed run's log at the
|
|
83
|
+
// next startup", which is a legitimate setting on a disk-constrained host.
|
|
84
|
+
const v = obj['shiftLogMaxAgeMs'];
|
|
85
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v < 0) {
|
|
86
|
+
throw bad('shiftLogMaxAgeMs', 'a non-negative integer', v);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
64
89
|
if ('dispatchCap' in obj) {
|
|
65
90
|
const v = obj['dispatchCap'];
|
|
66
91
|
if (typeof v !== 'number' || !Number.isInteger(v) || v <= 0) {
|
|
@@ -73,14 +98,75 @@ export function validateSettings(raw, path) {
|
|
|
73
98
|
throw bad('maxConcurrentAgents', 'a positive integer', v);
|
|
74
99
|
}
|
|
75
100
|
}
|
|
101
|
+
// RETIRED KEYS ARE A HARD ERROR, NOT AN IGNORED ONE. A file still naming
|
|
102
|
+
// `tierMap` or `tierProfiles` describes a routing scheme that no longer
|
|
103
|
+
// exists; passing it over as an unrecognized key would start the shift with
|
|
104
|
+
// NO capability map at all, and every agent order would then be refused at
|
|
105
|
+
// dispatch with a message about capabilities the operator never wrote.
|
|
106
|
+
for (const retired of ['tierMap', 'tierProfiles']) {
|
|
107
|
+
if (retired in obj) {
|
|
108
|
+
throw new Error(`invalid settings file at ${path}: '${retired}' was removed — tiers are replaced by ` +
|
|
109
|
+
`'capabilityModels', a flat map from capability to { model, effort } ` +
|
|
110
|
+
`(e.g. {"capabilityModels": {"wise:deep": {"model": "<model-id>", "effort": "xhigh"}}}). ` +
|
|
111
|
+
`Depth now rides on the capability's modifier suffix, not on a tier rung.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if ('capabilityModels' in obj) {
|
|
115
|
+
const v = obj['capabilityModels'];
|
|
116
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v)) {
|
|
117
|
+
throw bad('capabilityModels', 'an object of { model, effort } per capability', v);
|
|
118
|
+
}
|
|
119
|
+
// Row shape and effort validity are checked at LOAD, not at resolution: a
|
|
120
|
+
// shift whose map is wrong should fail when it starts, not on the first
|
|
121
|
+
// order that happens to land on the broken row, hours later.
|
|
122
|
+
try {
|
|
123
|
+
validateCapabilityModels(v);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
throw new Error(`invalid settings file at ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// RETIRED, BUT ONLY A WARNING — a different case from `tierMap` above, and the
|
|
130
|
+
// difference is what happens if the key is silently ignored.
|
|
131
|
+
//
|
|
132
|
+
// These two configured the WORKER-LOCAL escalation that bumped an order's
|
|
133
|
+
// model after N judgment rejections. Escalation is now entirely the engine's:
|
|
134
|
+
// it re-offers the step composed with the def's `escalation.modifier`, and the
|
|
135
|
+
// shift resolves that new compound like any other. So a file still carrying
|
|
136
|
+
// these describes a mechanism that no longer runs — but escalation itself
|
|
137
|
+
// still happens, correctly, without them. Ignoring them changes no behavior;
|
|
138
|
+
// it only leaves the operator believing a knob does something. A warning says
|
|
139
|
+
// exactly that, and does not stop a shift from starting.
|
|
140
|
+
for (const retired of RETIRED_IGNORED_KEYS) {
|
|
141
|
+
if (retired in obj) {
|
|
142
|
+
warnings.push(`'${retired}' no longer does anything and is ignored — retry escalation moved into the engine, ` +
|
|
143
|
+
`which re-offers a rejected step at the def's 'escalation.modifier'. Remove the key.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
76
146
|
if ('commandRouting' in obj) {
|
|
77
147
|
const v = obj['commandRouting'];
|
|
78
148
|
if (v !== 'shift' && v !== 'manual')
|
|
79
149
|
throw bad('commandRouting', "'shift' or 'manual'", v);
|
|
80
150
|
}
|
|
81
|
-
|
|
151
|
+
if ('defPolicy' in obj) {
|
|
152
|
+
const v = obj['defPolicy'];
|
|
153
|
+
if (v !== 'enforce' && v !== 'warn' && v !== 'off') {
|
|
154
|
+
throw bad('defPolicy', "'enforce', 'warn', or 'off'", v);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if ('artifactPolicy' in obj) {
|
|
158
|
+
const v = obj['artifactPolicy'];
|
|
159
|
+
if (v !== 'enforce' && v !== 'warn' && v !== 'off') {
|
|
160
|
+
throw bad('artifactPolicy', "'enforce', 'warn', or 'off'", v);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// The retired-but-warned keys count as KNOWN for this purpose. They are not
|
|
164
|
+
// typos — owenloop recognizes them perfectly well and has already said, in a
|
|
165
|
+
// warning, that they no longer take effect. Listing them again under
|
|
166
|
+
// "unrecognized keys (ignored — likely typos)" would contradict that.
|
|
167
|
+
const known = new Set([...KNOWN_SETTINGS_KEYS, ...RETIRED_IGNORED_KEYS]);
|
|
82
168
|
const unrecognized = Object.keys(obj).filter((k) => !known.has(k));
|
|
83
|
-
return { settings: obj, unrecognized };
|
|
169
|
+
return { settings: obj, unrecognized, warnings };
|
|
84
170
|
}
|
|
85
171
|
/**
|
|
86
172
|
* Inspect the settings file: resolve its path, whether it exists, and its
|
|
@@ -92,7 +178,7 @@ export function validateSettings(raw, path) {
|
|
|
92
178
|
export function inspectSettings(env) {
|
|
93
179
|
const path = settingsPath(env);
|
|
94
180
|
if (!existsSync(path))
|
|
95
|
-
return { path, exists: false, settings: {}, unrecognized: [] };
|
|
181
|
+
return { path, exists: false, settings: {}, unrecognized: [], warnings: [] };
|
|
96
182
|
const raw = readFileSync(path, 'utf8');
|
|
97
183
|
let parsed;
|
|
98
184
|
try {
|