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
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
* A born-bound work-holder: the D2 stamped Step Agent's frontmatter declares
|
|
5
5
|
* `mcpServers.owenloop = owenloop work hold --order <wf>/<run> --origin <url> --mcp`,
|
|
6
6
|
* so when the Step Agent session boots it launches THIS as a stdio MCP server. The
|
|
7
|
-
* server exposes
|
|
7
|
+
* server exposes three bare tools the model uses to do its order:
|
|
8
8
|
* - `get_order` → the order packet (prompt, inputs, owed outputs) for the run
|
|
9
9
|
* this holder is bound to. No ids are arguments — they came in on argv, never
|
|
10
10
|
* through the model.
|
|
11
11
|
* - `submit` → post a receipt for an owed output path; when the hub reports
|
|
12
12
|
* the submit CLOSED the run, the lease loop is stopped with `release:false`
|
|
13
13
|
* (the claim is already gone).
|
|
14
|
+
* - `reject` → invalidate a consumed artifact through the claiming step's
|
|
15
|
+
* server-derived authority; the client never supplies `by`. A CLOSED reject
|
|
16
|
+
* also stops the lease loop without releasing the already-closed claim.
|
|
14
17
|
*
|
|
15
18
|
* Underneath the tools, the SAME lease loop the CLI `hold` runs keeps the order's
|
|
16
19
|
* lease warm: `createHoldMcp` builds the loop with `onOrder` wired to capture the
|
|
@@ -24,7 +27,9 @@
|
|
|
24
27
|
* clock. The role (`src/roles/hold.ts`) owns the real stdin/stdout pump.
|
|
25
28
|
*/
|
|
26
29
|
import { textResult } from "../mcp/server.js";
|
|
30
|
+
import { buildSubmitProof } from "../submit-proof.js";
|
|
27
31
|
import { createHoldLoop } from "./loop.js";
|
|
32
|
+
export const HOLD_MCP_TOOL_NAMES = ['get_order', 'submit', 'reject'];
|
|
28
33
|
function errMsg(e) {
|
|
29
34
|
return e instanceof Error ? e.message : String(e);
|
|
30
35
|
}
|
|
@@ -33,20 +38,24 @@ function orderView(res) {
|
|
|
33
38
|
return { workflow: res.workflow, run: res.run, order: res.order, text: res.text };
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
|
-
* Build the hold MCP mount: the lease loop plus
|
|
37
|
-
*
|
|
38
|
-
*
|
|
41
|
+
* Build the hold MCP mount: the lease loop plus a positive tool selection. The
|
|
42
|
+
* default selection is the full `get_order`/`submit`/`reject` surface. A caller
|
|
43
|
+
* can request an exact subset; future registrations do not enter that subset
|
|
44
|
+
* unless the caller names them. The role creates the MCP server around `tools`,
|
|
45
|
+
* starts `loop.run()`, and pumps stdin — stopping the loop on stdin EOF.
|
|
39
46
|
*/
|
|
40
47
|
export function createHoldMcp(deps) {
|
|
41
48
|
const { hub, workflow, run } = deps;
|
|
42
49
|
const holderReq = deps.holder !== undefined ? { holder: deps.holder } : {};
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
50
|
+
// The loop's first contact arrives synchronously, but consume-side verification
|
|
51
|
+
// is asynchronous. Keep the unverified response in a private pending slot until
|
|
52
|
+
// a tool call gates it; only a gated response may populate `captured` and reach
|
|
53
|
+
// either the model or submit-proof construction.
|
|
54
|
+
let firstContact;
|
|
46
55
|
let captured;
|
|
47
56
|
// Set the moment the lease loop's run() settles (lease-lost, completed,
|
|
48
57
|
// released, …): from then on this mount no longer holds the order, so BOTH
|
|
49
|
-
// tools fast-fail with isError and never touch the hub again (plan section 4
|
|
58
|
+
// registered tools fast-fail with isError and never touch the hub again (plan section 4
|
|
50
59
|
// — a lost claim must not be worked or double-submitted).
|
|
51
60
|
let terminal;
|
|
52
61
|
const inner = createHoldLoop({
|
|
@@ -59,7 +68,7 @@ export function createHoldMcp(deps) {
|
|
|
59
68
|
out: deps.err,
|
|
60
69
|
err: deps.err,
|
|
61
70
|
onOrder: (res) => {
|
|
62
|
-
|
|
71
|
+
firstContact = res;
|
|
63
72
|
},
|
|
64
73
|
...(deps.holder !== undefined ? { holder: deps.holder } : {}),
|
|
65
74
|
...(deps.heartbeatIntervalMs !== undefined ? { heartbeatIntervalMs: deps.heartbeatIntervalMs } : {}),
|
|
@@ -81,6 +90,30 @@ export function createHoldMcp(deps) {
|
|
|
81
90
|
return undefined;
|
|
82
91
|
return textResult({ error: `order no longer held (${terminal}) — stop` }, true);
|
|
83
92
|
}
|
|
93
|
+
async function gate(res) {
|
|
94
|
+
if (res.order === null)
|
|
95
|
+
return undefined;
|
|
96
|
+
const hasConsumedData = Object.keys(res.order.consumes).length > 0
|
|
97
|
+
|| res.order.owes.some((owed) => owed.reasons.length > 0 || owed.proof !== undefined);
|
|
98
|
+
if (deps.consumedVerifier === undefined) {
|
|
99
|
+
if (!hasConsumedData)
|
|
100
|
+
return undefined;
|
|
101
|
+
return textResult({
|
|
102
|
+
error: `consumed artifact refusal (prerequisite) for ${res.workflow}/${res.run}: consume-side verifier is not configured; dynamic values cannot be admitted to the MCP model`,
|
|
103
|
+
}, true);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const checked = await deps.consumedVerifier(res.order, { hardRule: false });
|
|
107
|
+
if (!checked.ok)
|
|
108
|
+
return textResult({ error: checked.reason }, true);
|
|
109
|
+
for (const warning of checked.warnings)
|
|
110
|
+
deps.err(warning);
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return textResult({ error: `consumed artifact refusal (prerequisite) for ${res.workflow}/${res.run}: ${errMsg(error)}` }, true);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
84
117
|
const getOrderTool = {
|
|
85
118
|
name: 'get_order',
|
|
86
119
|
description: "Return this work-holder's order — the prompt, consumed inputs, and owed output paths for the run it is bound to. Takes no arguments (the run is fixed at launch).",
|
|
@@ -89,10 +122,24 @@ export function createHoldMcp(deps) {
|
|
|
89
122
|
const gone = terminalGuard();
|
|
90
123
|
if (gone !== undefined)
|
|
91
124
|
return gone;
|
|
92
|
-
if (captured !== undefined)
|
|
125
|
+
if (captured !== undefined) {
|
|
126
|
+
const refused = await gate(captured);
|
|
127
|
+
if (refused !== undefined)
|
|
128
|
+
return refused;
|
|
93
129
|
return textResult(orderView(captured));
|
|
130
|
+
}
|
|
131
|
+
if (firstContact !== undefined) {
|
|
132
|
+
const refused = await gate(firstContact);
|
|
133
|
+
if (refused !== undefined)
|
|
134
|
+
return refused;
|
|
135
|
+
captured = firstContact;
|
|
136
|
+
return textResult(orderView(firstContact));
|
|
137
|
+
}
|
|
94
138
|
try {
|
|
95
139
|
const res = await hub.getOrder({ workflow, run, ...holderReq });
|
|
140
|
+
const refused = await gate(res);
|
|
141
|
+
if (refused !== undefined)
|
|
142
|
+
return refused;
|
|
96
143
|
captured = res;
|
|
97
144
|
return textResult(orderView(res));
|
|
98
145
|
}
|
|
@@ -127,12 +174,39 @@ export function createHoldMcp(deps) {
|
|
|
127
174
|
}
|
|
128
175
|
const done = args['done'];
|
|
129
176
|
try {
|
|
177
|
+
// Submit is also a dynamic-data boundary. Fetch and gate the bound
|
|
178
|
+
// packet even when no origin was supplied for submit-proof signing;
|
|
179
|
+
// otherwise a direct submit call could bypass MCP consume-side
|
|
180
|
+
// verification without first calling get_order.
|
|
181
|
+
let orderResponse = captured ?? firstContact;
|
|
182
|
+
if (orderResponse === undefined) {
|
|
183
|
+
orderResponse = await hub.getOrder({ workflow, run, ...holderReq });
|
|
184
|
+
}
|
|
185
|
+
const refused = await gate(orderResponse);
|
|
186
|
+
if (refused !== undefined)
|
|
187
|
+
return refused;
|
|
188
|
+
captured = orderResponse;
|
|
189
|
+
let proof;
|
|
190
|
+
if (deps.origin !== undefined && orderResponse.order !== null) {
|
|
191
|
+
proof = await buildSubmitProof({
|
|
192
|
+
origin: deps.origin,
|
|
193
|
+
order: orderResponse.order,
|
|
194
|
+
path,
|
|
195
|
+
value: args['value'],
|
|
196
|
+
now: deps.now,
|
|
197
|
+
warn: deps.err,
|
|
198
|
+
...(deps.principalKeys !== undefined ? { principalKeys: deps.principalKeys } : {}),
|
|
199
|
+
...(deps.env !== undefined ? { env: deps.env } : {}),
|
|
200
|
+
...(deps.sshProcess !== undefined ? { sshProcess: deps.sshProcess } : {}),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
130
203
|
const res = await hub.submit({
|
|
131
204
|
workflow,
|
|
132
205
|
run,
|
|
133
206
|
path,
|
|
134
207
|
value: args['value'],
|
|
135
208
|
...(typeof done === 'boolean' ? { done } : {}),
|
|
209
|
+
...(proof !== undefined ? { proof } : {}),
|
|
136
210
|
...holderReq,
|
|
137
211
|
});
|
|
138
212
|
// The run closed — stop holding WITHOUT releasing (the claim is gone).
|
|
@@ -145,5 +219,46 @@ export function createHoldMcp(deps) {
|
|
|
145
219
|
}
|
|
146
220
|
},
|
|
147
221
|
};
|
|
148
|
-
|
|
222
|
+
const rejectTool = {
|
|
223
|
+
name: 'reject',
|
|
224
|
+
description: 'Reject a consumed artifact path with a reason. The hub derives the rejecting step from this held run; the client cannot supply `by`.',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
required: ['path', 'text'],
|
|
228
|
+
properties: {
|
|
229
|
+
path: { type: 'string', description: 'The consumed artifact path to reject.' },
|
|
230
|
+
text: { type: 'string', description: 'The reason for rejecting the artifact.' },
|
|
231
|
+
},
|
|
232
|
+
additionalProperties: false,
|
|
233
|
+
},
|
|
234
|
+
handler: async (args) => {
|
|
235
|
+
const gone = terminalGuard();
|
|
236
|
+
if (gone !== undefined)
|
|
237
|
+
return gone;
|
|
238
|
+
const path = args['path'];
|
|
239
|
+
const text = args['text'];
|
|
240
|
+
if (typeof path !== 'string' || path.trim() === '') {
|
|
241
|
+
return textResult({ error: 'reject requires a non-empty string "path"' }, true);
|
|
242
|
+
}
|
|
243
|
+
if (typeof text !== 'string' || text.trim() === '') {
|
|
244
|
+
return textResult({ error: 'reject requires a non-empty string "text"' }, true);
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const res = await hub.reject({ workflow, run, path, text });
|
|
248
|
+
if (res.closed === true)
|
|
249
|
+
loop.stop('submitted', { release: false });
|
|
250
|
+
return textResult({ ok: res.ok, closed: res.closed ?? false, text: res.text });
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
return textResult({ error: errMsg(e) }, true);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
const registrations = {
|
|
258
|
+
get_order: getOrderTool,
|
|
259
|
+
submit: submitTool,
|
|
260
|
+
reject: rejectTool,
|
|
261
|
+
};
|
|
262
|
+
const selected = deps.tools ?? HOLD_MCP_TOOL_NAMES;
|
|
263
|
+
return { tools: selected.map((name) => registrations[name]), loop };
|
|
149
264
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetOrderRequest, GetOrderResponse, HeartbeatRequest, HeartbeatResponse, PresencePingRequest, PresencePingResponse, ReleaseRequest, ReleaseResponse, SubmitRequest, SubmitResponse, WakeResponse, WhatsNextRequest, WhatsNextResponse, WhoamiResponse } from './types.ts';
|
|
1
|
+
import type { GetOrderRequest, GetOrderResponse, HeartbeatRequest, HeartbeatResponse, PresencePingRequest, PresencePingResponse, ReleaseRequest, ReleaseResponse, RejectRequest, RejectResponse, SubmitRequest, SubmitResponse, WakeResponse, WhatsNextRequest, WhatsNextResponse, WhoamiResponse } from './types.ts';
|
|
2
2
|
export interface HubClientOptions {
|
|
3
3
|
/** Hub origin, e.g. `https://hub.owenloop.dev` (no trailing slash needed). */
|
|
4
4
|
origin: string;
|
|
@@ -13,6 +13,7 @@ export interface HubClient {
|
|
|
13
13
|
heartbeat(req: HeartbeatRequest): Promise<HeartbeatResponse>;
|
|
14
14
|
release(req: ReleaseRequest): Promise<ReleaseResponse>;
|
|
15
15
|
submit(req: SubmitRequest): Promise<SubmitResponse>;
|
|
16
|
+
reject(req: RejectRequest): Promise<RejectResponse>;
|
|
16
17
|
whoami(): Promise<WhoamiResponse>;
|
|
17
18
|
/** B5 cheap wake pre-check; `cursor` rides the query string only when set. */
|
|
18
19
|
wake(cursor?: number): Promise<WakeResponse>;
|
|
@@ -28,6 +28,18 @@ export function createHubClient(opts) {
|
|
|
28
28
|
'content-type': 'application/json',
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
function retryAfterMs(res) {
|
|
32
|
+
const raw = res.headers.get('retry-after')?.trim();
|
|
33
|
+
if (!raw)
|
|
34
|
+
return undefined;
|
|
35
|
+
const seconds = Number(raw);
|
|
36
|
+
if (Number.isFinite(seconds) && seconds >= 0)
|
|
37
|
+
return Math.ceil(seconds * 1_000);
|
|
38
|
+
const at = Date.parse(raw);
|
|
39
|
+
if (!Number.isFinite(at))
|
|
40
|
+
return undefined;
|
|
41
|
+
return Math.max(0, at - Date.now());
|
|
42
|
+
}
|
|
31
43
|
async function parse(res) {
|
|
32
44
|
const raw = await res.text();
|
|
33
45
|
if (!res.ok) {
|
|
@@ -43,7 +55,7 @@ export function createHubClient(opts) {
|
|
|
43
55
|
catch {
|
|
44
56
|
// Not JSON — keep the raw text as the message.
|
|
45
57
|
}
|
|
46
|
-
throw new HubError(res.status, message, code);
|
|
58
|
+
throw new HubError(res.status, message, code, retryAfterMs(res));
|
|
47
59
|
}
|
|
48
60
|
return JSON.parse(raw);
|
|
49
61
|
}
|
|
@@ -69,6 +81,7 @@ export function createHubClient(opts) {
|
|
|
69
81
|
heartbeat: (req) => post('heartbeat', req),
|
|
70
82
|
release: (req) => post('release', req),
|
|
71
83
|
submit: (req) => post('submit', req),
|
|
84
|
+
reject: (req) => post('reject', req),
|
|
72
85
|
whoami: () => get('whoami'),
|
|
73
86
|
// Cursor is an opaque non-negative integer; omit it entirely to bootstrap
|
|
74
87
|
// (the hub treats missing/invalid as a `changed: true` first sweep).
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed request/response shapes for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (B3 lifecycle verbs are merged). Every REST verb returns `{ text, ...data }`
|
|
6
|
-
* where `data` is always an object, so each response extends `HubResponse`.
|
|
7
|
-
*
|
|
8
|
-
* Response payloads are typed LOOSELY on purpose: the roles that consume the
|
|
9
|
-
* data fields (whats_next orders, get_order body, …) land in C3–C5. Honest-loose
|
|
10
|
-
* (`unknown[]` + a TODO) beats invented-precise shapes no consumer reads yet.
|
|
2
|
+
* Typed request/response shapes for the remote coordinator's transport surface.
|
|
3
|
+
* Every response carries human-readable `text` plus the verb-specific data.
|
|
4
|
+
* Payloads stay loose where callers do not consume a field directly.
|
|
11
5
|
*/
|
|
12
6
|
/** Common envelope: every verb returns a human-readable `text` plus verb data. */
|
|
13
7
|
export interface HubResponse {
|
|
@@ -19,18 +13,31 @@ export interface WhatsNextRequest {
|
|
|
19
13
|
serve_crews?: string[];
|
|
20
14
|
}
|
|
21
15
|
/**
|
|
22
|
-
* One work order from a per-workflow `whats_next` sweep.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* read yet (consumes/expected_outputs/feedback/advisory/submit_hint) are
|
|
27
|
-
* mirrored for completeness — C4/C5 consume them.
|
|
16
|
+
* One work order from a per-workflow `whats_next` sweep. `run` is the order
|
|
17
|
+
* identifier used by the other transport verbs. The work order is routing and
|
|
18
|
+
* dynamic input data; authored instruction text is resolved from the local
|
|
19
|
+
* workflow store by the worker.
|
|
28
20
|
*/
|
|
29
21
|
export interface WorkOrder {
|
|
30
22
|
workflow: string;
|
|
31
23
|
run: string;
|
|
32
24
|
step: string;
|
|
33
|
-
|
|
25
|
+
/** Target reference-order fields; optional because the deployed hub may omit them. */
|
|
26
|
+
key?: string;
|
|
27
|
+
index?: number;
|
|
28
|
+
defDigest?: string;
|
|
29
|
+
/** Authoritative worker lane on modern whats_next responses. */
|
|
30
|
+
worker?: string;
|
|
31
|
+
consumedFingerprint?: Record<string, number>;
|
|
32
|
+
owes?: Array<{
|
|
33
|
+
path: string;
|
|
34
|
+
/** Claim-time committed version when a version-aware hub projects it. */
|
|
35
|
+
version?: number;
|
|
36
|
+
judgmentRejects: number;
|
|
37
|
+
schemaRejects: number;
|
|
38
|
+
reasons: ReasonEntry[];
|
|
39
|
+
proof?: string;
|
|
40
|
+
}>;
|
|
34
41
|
consumes: Record<string, unknown>;
|
|
35
42
|
expected_outputs: Array<{
|
|
36
43
|
path: string;
|
|
@@ -151,12 +158,11 @@ export interface Lease {
|
|
|
151
158
|
outcome?: string;
|
|
152
159
|
}
|
|
153
160
|
/**
|
|
154
|
-
* The persisted
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* engine never parses it; exec is the one process that shells it out.
|
|
161
|
+
* The persisted order packet re-served by the transport. The packet carries
|
|
162
|
+
* the definition projection digest and dynamic routing/state fields only.
|
|
163
|
+
* Workers must resolve authored command or prompt text from the local store.
|
|
164
|
+
* Proof/version fields describe the target protocol and remain optional because
|
|
165
|
+
* the deployed hub can omit them; optionality does not imply end-to-end support.
|
|
160
166
|
*/
|
|
161
167
|
export interface OrderPacket {
|
|
162
168
|
run: string;
|
|
@@ -164,26 +170,34 @@ export interface OrderPacket {
|
|
|
164
170
|
step: string;
|
|
165
171
|
key: string;
|
|
166
172
|
index?: number;
|
|
173
|
+
/** Projection digest identifying the installed definition snapshot. */
|
|
174
|
+
defDigest: string;
|
|
167
175
|
inputs: string[];
|
|
168
176
|
outputs: string[];
|
|
169
|
-
/** Opaque location hint —
|
|
177
|
+
/** Opaque location hint — the worker's cwd when set. */
|
|
170
178
|
workdir?: string;
|
|
171
179
|
model?: string;
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
|
|
180
|
+
/** Worker kind; `'command'` for command orders, absent means agent. */
|
|
181
|
+
worker?: string;
|
|
182
|
+
/** Artifact stem this order's judge step must verdict, when present. */
|
|
183
|
+
judge?: string;
|
|
176
184
|
spec?: Record<string, unknown>;
|
|
177
185
|
x?: Record<string, unknown>;
|
|
178
|
-
prompt: string;
|
|
179
186
|
consumes: Record<string, unknown>;
|
|
180
|
-
/**
|
|
187
|
+
/** Claim-time consumed versions when a compatible hub preserves the map. */
|
|
188
|
+
consumedFingerprint?: Record<string, number>;
|
|
189
|
+
/** Target-protocol proof map; the deployed hub currently omits this field. */
|
|
190
|
+
consumesProof?: string;
|
|
191
|
+
/** The owed outputs and their reason threads. */
|
|
181
192
|
owes: Array<{
|
|
182
193
|
path: string;
|
|
183
|
-
|
|
194
|
+
/** Claim-time committed version when a version-aware hub projects it. */
|
|
195
|
+
version?: number;
|
|
184
196
|
judgmentRejects: number;
|
|
185
197
|
schemaRejects: number;
|
|
186
198
|
reasons: ReasonEntry[];
|
|
199
|
+
/** Target-protocol reason-thread proof; the deployed hub may omit it. */
|
|
200
|
+
proof?: string;
|
|
187
201
|
}>;
|
|
188
202
|
cause?: string;
|
|
189
203
|
}
|
|
@@ -249,6 +263,8 @@ export interface SubmitRequest {
|
|
|
249
263
|
path: string;
|
|
250
264
|
value: unknown;
|
|
251
265
|
done?: boolean;
|
|
266
|
+
/** Target-protocol DSSE envelope; production submit transport currently drops it. */
|
|
267
|
+
proof?: string;
|
|
252
268
|
/** W7: who produced this submission (D4) — carried on all three submit paths. */
|
|
253
269
|
holder?: ContactHolder;
|
|
254
270
|
}
|
|
@@ -258,13 +274,31 @@ export interface SubmitRequest {
|
|
|
258
274
|
* commit verdict: `green`/`submitted` are success (the value landed);
|
|
259
275
|
* `schema-rejected`/`born-rejected`/`artifact-too-large`/
|
|
260
276
|
* `artifact-normalization-failed` are failures. `closed` reports whether that
|
|
261
|
-
* submit closed the run (only present on a `green`/`submitted` outcome).
|
|
262
|
-
*
|
|
277
|
+
* submit closed the run (only present on a `green`/`submitted` outcome). The
|
|
278
|
+
* deployed response does not return the committed version, the next target
|
|
279
|
+
* version, proof acceptance, or an idempotency result. exec treats any
|
|
280
|
+
* non-green/submitted outcome as a failed submit (exit 1).
|
|
263
281
|
*/
|
|
264
282
|
export interface SubmitResponse extends HubResponse {
|
|
265
283
|
outcome?: string;
|
|
266
284
|
closed?: boolean;
|
|
267
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Invalidate an artifact through the claiming worker's consume-edge authority.
|
|
288
|
+
* `by` is deliberately absent: the hub derives the actor from the claiming
|
|
289
|
+
* run's step, so a worker cannot impersonate another step.
|
|
290
|
+
*/
|
|
291
|
+
export interface RejectRequest {
|
|
292
|
+
workflow: string;
|
|
293
|
+
run: string;
|
|
294
|
+
path: string;
|
|
295
|
+
text: string;
|
|
296
|
+
}
|
|
297
|
+
/** The reject verb's flattened response envelope. */
|
|
298
|
+
export interface RejectResponse extends HubResponse {
|
|
299
|
+
ok: boolean;
|
|
300
|
+
closed?: boolean;
|
|
301
|
+
}
|
|
268
302
|
export interface WhoamiResponse extends HubResponse {
|
|
269
303
|
orgId: string;
|
|
270
304
|
orgName: string;
|
|
@@ -286,5 +320,7 @@ export interface WhoamiResponse extends HubResponse {
|
|
|
286
320
|
export declare class HubError extends Error {
|
|
287
321
|
readonly status: number;
|
|
288
322
|
readonly code?: string;
|
|
289
|
-
|
|
323
|
+
/** Server-requested delay before retrying, normalized from Retry-After. */
|
|
324
|
+
readonly retryAfterMs?: number;
|
|
325
|
+
constructor(status: number, message: string, code?: string, retryAfterMs?: number);
|
|
290
326
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed request/response shapes for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (B3 lifecycle verbs are merged). Every REST verb returns `{ text, ...data }`
|
|
6
|
-
* where `data` is always an object, so each response extends `HubResponse`.
|
|
7
|
-
*
|
|
8
|
-
* Response payloads are typed LOOSELY on purpose: the roles that consume the
|
|
9
|
-
* data fields (whats_next orders, get_order body, …) land in C3–C5. Honest-loose
|
|
10
|
-
* (`unknown[]` + a TODO) beats invented-precise shapes no consumer reads yet.
|
|
2
|
+
* Typed request/response shapes for the remote coordinator's transport surface.
|
|
3
|
+
* Every response carries human-readable `text` plus the verb-specific data.
|
|
4
|
+
* Payloads stay loose where callers do not consume a field directly.
|
|
11
5
|
*/
|
|
12
6
|
// ---- errors -----------------------------------------------------------------
|
|
13
7
|
/**
|
|
@@ -18,11 +12,15 @@
|
|
|
18
12
|
export class HubError extends Error {
|
|
19
13
|
status;
|
|
20
14
|
code;
|
|
21
|
-
|
|
15
|
+
/** Server-requested delay before retrying, normalized from Retry-After. */
|
|
16
|
+
retryAfterMs;
|
|
17
|
+
constructor(status, message, code, retryAfterMs) {
|
|
22
18
|
super(message);
|
|
23
19
|
this.name = 'HubError';
|
|
24
20
|
this.status = status;
|
|
25
21
|
if (code !== undefined)
|
|
26
22
|
this.code = code;
|
|
23
|
+
if (retryAfterMs !== undefined)
|
|
24
|
+
this.retryAfterMs = retryAfterMs;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -37,7 +37,7 @@ const RECOGNIZED_PROTOCOL_VERSIONS = new Set([
|
|
|
37
37
|
'2024-11-05',
|
|
38
38
|
'2025-03-26',
|
|
39
39
|
'2025-06-18',
|
|
40
|
-
'2025-11-
|
|
40
|
+
'2025-11-25',
|
|
41
41
|
]);
|
|
42
42
|
/** The version we answer with when the client's is missing or unrecognized. */
|
|
43
43
|
const OUR_PROTOCOL_VERSION = '2025-06-18';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveOwenloopBin(): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve this installation's packaged Owenloop entrypoint.
|
|
3
|
+
*
|
|
4
|
+
* Source-driven tests import `packages/work/src/**`, while built/runtime code
|
|
5
|
+
* imports `dist/packages/work/src/**`; those layouts are one parent apart.
|
|
6
|
+
* Every child Owenloop process must use this resolver so a stale executable
|
|
7
|
+
* earlier on PATH cannot split a Shift, its worker, and the worker's born-bound
|
|
8
|
+
* MCP server across different installations.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
export function resolveOwenloopBin() {
|
|
13
|
+
const candidates = [
|
|
14
|
+
new URL('../../../bin/owenloop.mjs', import.meta.url),
|
|
15
|
+
new URL('../../../../bin/owenloop.mjs', import.meta.url),
|
|
16
|
+
].map((url) => fileURLToPath(url));
|
|
17
|
+
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
|
|
18
|
+
}
|
|
@@ -30,12 +30,10 @@
|
|
|
30
30
|
*
|
|
31
31
|
* ── WHERE THE STEP SPEC COMES FROM ──
|
|
32
32
|
*
|
|
33
|
-
* The
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `readDispatchBundle(cacheDir, def)` → `bundle.def.hash` → `readStepSpec(...)`.
|
|
38
|
-
* That keeps the argv exactly as D6 specifies and adds no new settings surface.
|
|
33
|
+
* The order packet carries a `defDigest` reference but no authoritative prompt,
|
|
34
|
+
* harness, or permission text. The worker resolves the digest and step name
|
|
35
|
+
* through the verified local workflow store. The prepare cache remains available
|
|
36
|
+
* for routing and session state, but never supplies execution instructions.
|
|
39
37
|
*
|
|
40
38
|
* ── CREDENTIALS ──
|
|
41
39
|
*
|
|
@@ -71,6 +69,8 @@
|
|
|
71
69
|
*/
|
|
72
70
|
import '../harnesses.ts';
|
|
73
71
|
import { type AgentRunOutcome } from '../agent/loop.ts';
|
|
72
|
+
import { type InstructionResolver } from '../exec/instructions.ts';
|
|
73
|
+
import { type ConsumedVerifier } from '../consumed-verifier.ts';
|
|
74
74
|
import { type HubClient } from '../hub/client.ts';
|
|
75
75
|
import { type SignalHost } from './signals.ts';
|
|
76
76
|
interface ParsedArgs {
|
|
@@ -105,6 +105,12 @@ export interface RunDeps {
|
|
|
105
105
|
hub?: HubClient;
|
|
106
106
|
out?: (line: string) => void;
|
|
107
107
|
err?: (line: string) => void;
|
|
108
|
+
/** Store-backed instruction resolver; injected tests may provide a fake. */
|
|
109
|
+
instructions?: InstructionResolver;
|
|
110
|
+
/** Consume-side verifier; injected tests may provide a fake. */
|
|
111
|
+
consumedVerifier?: ConsumedVerifier;
|
|
112
|
+
/** Environment used to derive the global workflow-store root. */
|
|
113
|
+
env?: Record<string, string | undefined>;
|
|
108
114
|
/** cwd for an order that carries no `workdir` (default `process.cwd()`). */
|
|
109
115
|
cwd?: string;
|
|
110
116
|
/**
|