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
package/dist/src/mcp/serve.d.ts
CHANGED
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
* client, the tool registrations, the enrollment capability gate, and the
|
|
34
34
|
* command body — lives here.
|
|
35
35
|
*/
|
|
36
|
+
import { PrincipalKeyManager } from '../crypto/index.ts';
|
|
36
37
|
import type { CredentialIO } from '../credentials.ts';
|
|
38
|
+
import type { SshProcessAdapter } from '../crypto/ssh.ts';
|
|
37
39
|
import type { LineStream } from './server.ts';
|
|
38
40
|
/**
|
|
39
41
|
* The IO surface `runMcpCommand` needs — a strict subset of the CLI's `CliIO`,
|
|
@@ -45,41 +47,63 @@ export interface McpIo extends CredentialIO {
|
|
|
45
47
|
out: (line: string) => void;
|
|
46
48
|
err: (line: string) => void;
|
|
47
49
|
stdinStream?: LineStream;
|
|
50
|
+
principalKeys?: Pick<PrincipalKeyManager, 'inspect' | 'resolveRef' | 'withSigningKey'>;
|
|
51
|
+
/** Injectable ssh-keygen seam for hermetic submit-proof tests. */
|
|
52
|
+
sshProcess?: SshProcessAdapter;
|
|
48
53
|
}
|
|
49
|
-
/** The exit-2 ambiguity outcome; the caller prints `message` to stderr and returns 2. */
|
|
50
|
-
type OriginResolution = {
|
|
51
|
-
origin: string;
|
|
52
|
-
} | {
|
|
53
|
-
exitCode: 2;
|
|
54
|
-
message: string;
|
|
55
|
-
};
|
|
56
54
|
/**
|
|
57
55
|
* Resolve the hub origin this server binds to, precedence:
|
|
58
56
|
* 1. `--hub <origin>` flag,
|
|
59
57
|
* 2. `OWENLOOP_HUB` env,
|
|
60
|
-
* 3.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
58
|
+
* 3. `~/.owenloop/config.json` (written by `owenloop login`; see
|
|
59
|
+
* `src/global-config.ts`'s header for why this is a separate file from
|
|
60
|
+
* the execution plane's `settings.json`),
|
|
61
|
+
* 4. if the FILE credential backend holds exactly ONE hub with a valid
|
|
62
|
+
* `human` slot, use it (back-compat for a login that predates rung 3),
|
|
63
|
+
* 5. else `DEFAULT_HUB` (`src/hub.ts`) — the production hub.
|
|
63
64
|
*
|
|
64
65
|
* Rungs 1–2 normalize the origin (a malformed value throws a `CliError` → the
|
|
65
|
-
* command's exit-1 path via `mainAsync`'s catch, matching every other
|
|
66
|
-
* Rung 3
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* command's exit-1 path via `mainAsync`'s catch, matching every other
|
|
67
|
+
* command). Rung 3 reads `home` from `io.env.HOME`/`io.env.USERPROFILE` (the
|
|
68
|
+
* first non-blank of the two, mirroring `src/cli.ts`'s `workflowHome`) — but
|
|
69
|
+
* unlike `workflowHome`, an absent home does NOT throw here: it just means
|
|
70
|
+
* this rung has nothing to offer, same as a missing or malformed config file
|
|
71
|
+
* (`readGlobalConfig` never throws; see its doc comment in
|
|
72
|
+
* `src/global-config.ts`). Rung 4 is file-backend-only because only the file
|
|
73
|
+
* backend can enumerate (`listStoredHubOrigins`); `null` (cannot enumerate —
|
|
74
|
+
* keychain/external), `[]` (nothing stored), and length>1 (ambiguous) are ALL
|
|
75
|
+
* just "this rung has nothing to offer" and fall through to rung 5 — none of
|
|
76
|
+
* them is an error here.
|
|
69
77
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
78
|
+
* This function used to stop at what is now rung 4 and exit 2 instead of
|
|
79
|
+
* falling through, with a comment reading: "DELIBERATELY there is NO silent
|
|
80
|
+
* production fallback (the CLI's `resolveHub` `DEFAULT_HUB` rung): a
|
|
81
|
+
* control-plane server must never bind to a hub the operator did not name."
|
|
82
|
+
* Two things were wrong with that rule:
|
|
83
|
+
* 1. `resolveHub` (`src/cli.ts:2667-2674`) — used by `login` (`:2869`),
|
|
84
|
+
* `logout` (`:3173`), and `connect` (`:3193`) — ALREADY falls back to
|
|
85
|
+
* `DEFAULT_HUB`. `capability` and `crew` use `resolveAgentHub` instead;
|
|
86
|
+
* that resolver has no `DEFAULT_HUB` rung and still exits 2. The `login`
|
|
87
|
+
* command that CREATES credentials defaults to production while MCP's
|
|
88
|
+
* startup origin resolution exited 2 before it could reach any read or
|
|
89
|
+
* write tool. That asymmetry was the real inconsistency.
|
|
90
|
+
* 2. The no-fallback rule bought no safety. With no credential for the
|
|
91
|
+
* resolved origin, the server fails at the FIRST TOOL CALL with
|
|
92
|
+
* `loginHint` (below): "not logged in to <origin> — run `owenloop login
|
|
93
|
+
* --hub <origin>` in a terminal, then retry". That is a strictly better
|
|
94
|
+
* failure than dying before `initialize` — the host shows an actionable
|
|
95
|
+
* tool error instead of a dead server.
|
|
73
96
|
*/
|
|
74
|
-
export declare function resolveMcpOrigin(io: McpIo, hubFlag: string | undefined):
|
|
97
|
+
export declare function resolveMcpOrigin(io: McpIo, hubFlag: string | undefined): string;
|
|
75
98
|
/**
|
|
76
99
|
* Run the `owenloop mcp` command: resolve the origin, decide the enrollment
|
|
77
100
|
* gate, build the tool list, construct the JSON-RPC server, and pump stdin until
|
|
78
|
-
* EOF. Returns the process exit code:
|
|
79
|
-
*
|
|
80
|
-
*
|
|
101
|
+
* EOF. Returns the process exit code: always 0 on stdin EOF — origin
|
|
102
|
+
* resolution has no exit-2 path of its own anymore (see `resolveMcpOrigin`;
|
|
103
|
+
* it always resolves to some origin, falling back as far as `DEFAULT_HUB`).
|
|
104
|
+
* A malformed `--hub`/`OWENLOOP_HUB` still throws a `CliError` (exit-1 path,
|
|
105
|
+
* via `mainAsync`'s catch).
|
|
81
106
|
*/
|
|
82
107
|
export declare function runMcpCommand(io: McpIo, opts: {
|
|
83
108
|
hubFlag?: string;
|
|
84
109
|
}): Promise<number>;
|
|
85
|
-
export {};
|
package/dist/src/mcp/serve.js
CHANGED
|
@@ -33,64 +33,81 @@
|
|
|
33
33
|
* client, the tool registrations, the enrollment capability gate, and the
|
|
34
34
|
* command body — lives here.
|
|
35
35
|
*/
|
|
36
|
+
import { packageVersion } from "../package-version.js";
|
|
36
37
|
import { CliError } from "../util.js";
|
|
38
|
+
import { DSSE_SSH_NAMESPACE, PrincipalKeyManager, buildSubmissionRecord, createSshSigner, signSubmission, } from "../crypto/index.js";
|
|
37
39
|
import { authHeader, ensureFreshOAuth, hubFetch, refreshOAuth, storeCredential, } from "../credentials.js";
|
|
38
|
-
import {
|
|
40
|
+
import { DEFAULT_HUB, listStoredHubOrigins, normalizeOrigin, readStoredCredential, resolveEndpoint, } from "../hub.js";
|
|
41
|
+
import { globalConfigPath, readGlobalConfig } from "../global-config.js";
|
|
39
42
|
import { createMcpServer, pumpStdin, textResult } from "./server.js";
|
|
40
43
|
/** The human control plane authenticates as the human slot, always. */
|
|
41
44
|
const HUMAN = { principal: 'human' };
|
|
42
45
|
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
46
|
+
// ---- origin resolution ------------------------------------------------------
|
|
43
47
|
/**
|
|
44
48
|
* Resolve the hub origin this server binds to, precedence:
|
|
45
49
|
* 1. `--hub <origin>` flag,
|
|
46
50
|
* 2. `OWENLOOP_HUB` env,
|
|
47
|
-
* 3.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
51
|
+
* 3. `~/.owenloop/config.json` (written by `owenloop login`; see
|
|
52
|
+
* `src/global-config.ts`'s header for why this is a separate file from
|
|
53
|
+
* the execution plane's `settings.json`),
|
|
54
|
+
* 4. if the FILE credential backend holds exactly ONE hub with a valid
|
|
55
|
+
* `human` slot, use it (back-compat for a login that predates rung 3),
|
|
56
|
+
* 5. else `DEFAULT_HUB` (`src/hub.ts`) — the production hub.
|
|
50
57
|
*
|
|
51
58
|
* Rungs 1–2 normalize the origin (a malformed value throws a `CliError` → the
|
|
52
|
-
* command's exit-1 path via `mainAsync`'s catch, matching every other
|
|
53
|
-
* Rung 3
|
|
54
|
-
*
|
|
55
|
-
*
|
|
59
|
+
* command's exit-1 path via `mainAsync`'s catch, matching every other
|
|
60
|
+
* command). Rung 3 reads `home` from `io.env.HOME`/`io.env.USERPROFILE` (the
|
|
61
|
+
* first non-blank of the two, mirroring `src/cli.ts`'s `workflowHome`) — but
|
|
62
|
+
* unlike `workflowHome`, an absent home does NOT throw here: it just means
|
|
63
|
+
* this rung has nothing to offer, same as a missing or malformed config file
|
|
64
|
+
* (`readGlobalConfig` never throws; see its doc comment in
|
|
65
|
+
* `src/global-config.ts`). Rung 4 is file-backend-only because only the file
|
|
66
|
+
* backend can enumerate (`listStoredHubOrigins`); `null` (cannot enumerate —
|
|
67
|
+
* keychain/external), `[]` (nothing stored), and length>1 (ambiguous) are ALL
|
|
68
|
+
* just "this rung has nothing to offer" and fall through to rung 5 — none of
|
|
69
|
+
* them is an error here.
|
|
56
70
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
71
|
+
* This function used to stop at what is now rung 4 and exit 2 instead of
|
|
72
|
+
* falling through, with a comment reading: "DELIBERATELY there is NO silent
|
|
73
|
+
* production fallback (the CLI's `resolveHub` `DEFAULT_HUB` rung): a
|
|
74
|
+
* control-plane server must never bind to a hub the operator did not name."
|
|
75
|
+
* Two things were wrong with that rule:
|
|
76
|
+
* 1. `resolveHub` (`src/cli.ts:2667-2674`) — used by `login` (`:2869`),
|
|
77
|
+
* `logout` (`:3173`), and `connect` (`:3193`) — ALREADY falls back to
|
|
78
|
+
* `DEFAULT_HUB`. `capability` and `crew` use `resolveAgentHub` instead;
|
|
79
|
+
* that resolver has no `DEFAULT_HUB` rung and still exits 2. The `login`
|
|
80
|
+
* command that CREATES credentials defaults to production while MCP's
|
|
81
|
+
* startup origin resolution exited 2 before it could reach any read or
|
|
82
|
+
* write tool. That asymmetry was the real inconsistency.
|
|
83
|
+
* 2. The no-fallback rule bought no safety. With no credential for the
|
|
84
|
+
* resolved origin, the server fails at the FIRST TOOL CALL with
|
|
85
|
+
* `loginHint` (below): "not logged in to <origin> — run `owenloop login
|
|
86
|
+
* --hub <origin>` in a terminal, then retry". That is a strictly better
|
|
87
|
+
* failure than dying before `initialize` — the host shows an actionable
|
|
88
|
+
* tool error instead of a dead server.
|
|
60
89
|
*/
|
|
61
90
|
export function resolveMcpOrigin(io, hubFlag) {
|
|
62
91
|
const explicit = hubFlag ?? io.env.OWENLOOP_HUB;
|
|
63
92
|
if (explicit !== undefined && explicit.trim() !== '') {
|
|
64
93
|
try {
|
|
65
|
-
return
|
|
94
|
+
return normalizeOrigin(explicit);
|
|
66
95
|
}
|
|
67
96
|
catch (e) {
|
|
68
97
|
throw new CliError(e.message);
|
|
69
98
|
}
|
|
70
99
|
}
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
exitCode: 2,
|
|
77
|
-
message: `cannot list stored hubs from the ${which} credential store — ` +
|
|
78
|
-
'pass --hub <origin> (or set OWENLOOP_HUB)',
|
|
79
|
-
};
|
|
100
|
+
const home = [io.env.HOME, io.env.USERPROFILE].find((value) => value !== undefined && value.trim() !== '');
|
|
101
|
+
if (home !== undefined) {
|
|
102
|
+
const config = readGlobalConfig(globalConfigPath(home));
|
|
103
|
+
if (config !== null)
|
|
104
|
+
return config.hub;
|
|
80
105
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
message: 'no hub credentials stored — run `owenloop login --hub <origin>` first, or pass --hub <origin>',
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (origins.length > 1) {
|
|
88
|
-
return {
|
|
89
|
-
exitCode: 2,
|
|
90
|
-
message: `multiple hubs in the credential store (${origins.join(', ')}) — pass --hub <origin>`,
|
|
91
|
-
};
|
|
106
|
+
const origins = listStoredHubOrigins(io.env, io.keychain);
|
|
107
|
+
if (origins !== null && origins.length === 1) {
|
|
108
|
+
return origins[0];
|
|
92
109
|
}
|
|
93
|
-
return
|
|
110
|
+
return DEFAULT_HUB;
|
|
94
111
|
}
|
|
95
112
|
// ---- the authenticated hub client -------------------------------------------
|
|
96
113
|
/** The non-interactive "you are not authenticated" instruction (Decision 8). */
|
|
@@ -205,6 +222,105 @@ function passthrough(deps, build) {
|
|
|
205
222
|
return toolResultFromRest(r);
|
|
206
223
|
};
|
|
207
224
|
}
|
|
225
|
+
let warnedMcpUnsigned = false;
|
|
226
|
+
/** Sign the baseline MCP submit when a claimed order can be resolved locally. */
|
|
227
|
+
async function signMcpSubmit(deps, args) {
|
|
228
|
+
const workflow = args['workflow'];
|
|
229
|
+
const run = args['run'];
|
|
230
|
+
const path = args['path'];
|
|
231
|
+
if (typeof workflow !== 'string' || typeof run !== 'string' || typeof path !== 'string' || !('value' in args)) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
let keys;
|
|
235
|
+
try {
|
|
236
|
+
keys = deps.io.principalKeys ?? new PrincipalKeyManager({ env: deps.io.env });
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
warnMcpUnsigned(deps, `machine signing is unavailable (${e.message}); submitting without a proof`);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const ref = keys.resolveRef(deps.origin, 'machine');
|
|
243
|
+
if (ref === null) {
|
|
244
|
+
warnMcpUnsigned(deps, `no machine signing key for ${deps.origin}; submitting without a proof`);
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
const inspected = await keys.inspect(ref);
|
|
248
|
+
if (!inspected.exists || inspected.publicKey === undefined) {
|
|
249
|
+
warnMcpUnsigned(deps, `machine signing key for ${deps.origin} is unavailable; submitting without a proof`);
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const orderResponse = await callHub(deps, {
|
|
253
|
+
method: 'POST',
|
|
254
|
+
path: '/api/get_order',
|
|
255
|
+
body: { workflow, run },
|
|
256
|
+
});
|
|
257
|
+
if (!isOk(orderResponse.status) || !isObject(orderResponse.json) || !isObject(orderResponse.json['order'])) {
|
|
258
|
+
warnMcpUnsigned(deps, `order metadata for ${workflow}/${run} was unavailable; submitting without a proof`);
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
const order = orderResponse.json['order'];
|
|
262
|
+
const version = outputVersion(order, path);
|
|
263
|
+
if (version === undefined) {
|
|
264
|
+
warnMcpUnsigned(deps, `order ${workflow}/${run} omitted authoritative version metadata for output '${path}'; submitting without a proof`);
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const consumedFingerprint = submissionFingerprint(order, deps);
|
|
268
|
+
if (consumedFingerprint === undefined)
|
|
269
|
+
return undefined;
|
|
270
|
+
const record = buildSubmissionRecord({
|
|
271
|
+
run: order.run,
|
|
272
|
+
workflow: order.workflow,
|
|
273
|
+
defDigest: order.defDigest,
|
|
274
|
+
step: order.step,
|
|
275
|
+
key: order.key,
|
|
276
|
+
...(order.index !== undefined ? { index: order.index } : {}),
|
|
277
|
+
produced: [{ artifact: path, version, value: args['value'] }],
|
|
278
|
+
consumedFingerprint,
|
|
279
|
+
producerKeyId: inspected.publicKey.keyid,
|
|
280
|
+
timestamp: Date.now(),
|
|
281
|
+
});
|
|
282
|
+
return keys.withSigningKey(ref, async (keyPath) => {
|
|
283
|
+
const signer = createSshSigner({
|
|
284
|
+
namespace: DSSE_SSH_NAMESPACE,
|
|
285
|
+
signKeyPath: keyPath,
|
|
286
|
+
...(deps.io.sshProcess !== undefined ? { process: deps.io.sshProcess } : {}),
|
|
287
|
+
});
|
|
288
|
+
return signSubmission(record, signer);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function submissionFingerprint(order, deps) {
|
|
292
|
+
if (order.consumedFingerprint !== undefined)
|
|
293
|
+
return order.consumedFingerprint;
|
|
294
|
+
if (order.inputs.length > 0 || Object.keys(order.consumes).length > 0) {
|
|
295
|
+
warnMcpUnsigned(deps, `order ${order.workflow}/${order.run} omitted its consumed fingerprint; submitting without a proof`);
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
return {};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Resolve a signed submit version from authoritative immutable metadata only.
|
|
302
|
+
* Judge claims name the already-submitted version in their fingerprint; the
|
|
303
|
+
* judge-approve commit does not increment it. Producer claims name
|
|
304
|
+
* `owes[].version`, the target the engine issued for this owed output inside
|
|
305
|
+
* the claim transaction — the version the next successful commit lands, and
|
|
306
|
+
* the version the consumer checks the proof against. See
|
|
307
|
+
* `outputVersionForSubmission` in packages/work/src/submit-proof.ts for the
|
|
308
|
+
* retry-safety argument; this is the same rule on the local MCP path.
|
|
309
|
+
*/
|
|
310
|
+
function outputVersion(order, path) {
|
|
311
|
+
if (order.judge === path)
|
|
312
|
+
return order.consumedFingerprint?.[path];
|
|
313
|
+
const target = order.owes.find((owed) => owed.path === path)?.version;
|
|
314
|
+
// Only a positive integer is a target this protocol issued; see
|
|
315
|
+
// outputVersionForSubmission for why 0 submits unsigned instead.
|
|
316
|
+
return typeof target === 'number' && Number.isInteger(target) && target > 0 ? target : undefined;
|
|
317
|
+
}
|
|
318
|
+
function warnMcpUnsigned(deps, reason) {
|
|
319
|
+
if (warnedMcpUnsigned)
|
|
320
|
+
return;
|
|
321
|
+
warnedMcpUnsigned = true;
|
|
322
|
+
deps.io.err(`owenloop mcp: ${reason}`);
|
|
323
|
+
}
|
|
208
324
|
/**
|
|
209
325
|
* The 17 baseline tools — names, descriptions, and schemas mirror the hub's own
|
|
210
326
|
* HTTP-MCP toolset (owenloop-service `apps/hub-edge/src/mcp/tools.ts`); each maps
|
|
@@ -244,7 +360,23 @@ function buildBaselineTools(deps) {
|
|
|
244
360
|
required: ['workflow', 'run', 'path', 'value'],
|
|
245
361
|
additionalProperties: false,
|
|
246
362
|
},
|
|
247
|
-
handler:
|
|
363
|
+
handler: async (args) => {
|
|
364
|
+
let proof;
|
|
365
|
+
try {
|
|
366
|
+
proof = await signMcpSubmit(deps, args);
|
|
367
|
+
}
|
|
368
|
+
catch (e) {
|
|
369
|
+
// A configured signer/tool failure is a submit error, not an
|
|
370
|
+
// unsigned fallback. The missing-key cases are handled inside the
|
|
371
|
+
// helper and remain compatible with pre-WP-D2 clients.
|
|
372
|
+
return errorText(e.message);
|
|
373
|
+
}
|
|
374
|
+
const body = proof === undefined ? args : { ...args, proof };
|
|
375
|
+
const r = await callHub(deps, { method: 'POST', path: '/api/submit', body });
|
|
376
|
+
if (r.authFailed)
|
|
377
|
+
return errorText(r.authMessage ?? loginHint(deps.origin));
|
|
378
|
+
return toolResultFromRest(r);
|
|
379
|
+
},
|
|
248
380
|
},
|
|
249
381
|
{
|
|
250
382
|
name: 'reject_artifact',
|
|
@@ -674,23 +806,21 @@ async function shouldRegisterEnrollment(deps) {
|
|
|
674
806
|
/**
|
|
675
807
|
* Run the `owenloop mcp` command: resolve the origin, decide the enrollment
|
|
676
808
|
* gate, build the tool list, construct the JSON-RPC server, and pump stdin until
|
|
677
|
-
* EOF. Returns the process exit code:
|
|
678
|
-
*
|
|
679
|
-
*
|
|
809
|
+
* EOF. Returns the process exit code: always 0 on stdin EOF — origin
|
|
810
|
+
* resolution has no exit-2 path of its own anymore (see `resolveMcpOrigin`;
|
|
811
|
+
* it always resolves to some origin, falling back as far as `DEFAULT_HUB`).
|
|
812
|
+
* A malformed `--hub`/`OWENLOOP_HUB` still throws a `CliError` (exit-1 path,
|
|
813
|
+
* via `mainAsync`'s catch).
|
|
680
814
|
*/
|
|
681
815
|
export async function runMcpCommand(io, opts) {
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
io.err(resolved.message);
|
|
685
|
-
return resolved.exitCode;
|
|
686
|
-
}
|
|
687
|
-
const deps = { io, origin: resolved.origin };
|
|
816
|
+
const origin = resolveMcpOrigin(io, opts.hubFlag);
|
|
817
|
+
const deps = { io, origin };
|
|
688
818
|
const tools = [...buildBaselineTools(deps), createAgentTool(deps), ...buildCrewTools(deps)];
|
|
689
819
|
if (await shouldRegisterEnrollment(deps))
|
|
690
820
|
tools.push(stageEnrollmentTool(deps));
|
|
691
821
|
const server = createMcpServer({
|
|
692
822
|
name: 'owenloop-cli-mcp',
|
|
693
|
-
version:
|
|
823
|
+
version: packageVersion(),
|
|
694
824
|
tools,
|
|
695
825
|
write: (msg) => io.out(JSON.stringify(msg)),
|
|
696
826
|
err: (line) => io.err(line),
|
package/dist/src/mcp/server.js
CHANGED
|
@@ -44,7 +44,7 @@ const RECOGNIZED_PROTOCOL_VERSIONS = new Set([
|
|
|
44
44
|
'2024-11-05',
|
|
45
45
|
'2025-03-26',
|
|
46
46
|
'2025-06-18',
|
|
47
|
-
'2025-11-
|
|
47
|
+
'2025-11-25',
|
|
48
48
|
]);
|
|
49
49
|
/** The version we answer with when the client's is missing or unrecognized. */
|
|
50
50
|
const OUR_PROTOCOL_VERSION = '2025-06-18';
|
|
@@ -60,6 +60,12 @@ export function textResult(value, isError = false) {
|
|
|
60
60
|
}
|
|
61
61
|
export function createMcpServer(opts) {
|
|
62
62
|
const err = opts.err ?? (() => { });
|
|
63
|
+
// A plugin supplies its manifest version through the MCP environment. An
|
|
64
|
+
// absent expectation leaves hand-run and headless MCP servers unchanged;
|
|
65
|
+
// only a supplied value can describe a plugin/CLI drift. The comparison is
|
|
66
|
+
// deferred to tools/call instead of rejecting startup, because startup
|
|
67
|
+
// rejection surfaces as the opaque "server transport closed unexpectedly".
|
|
68
|
+
const expectedPluginVersion = process.env['OWENLOOP_PLUGIN_VERSION'];
|
|
63
69
|
const tools = new Map();
|
|
64
70
|
for (const t of opts.tools)
|
|
65
71
|
tools.set(t.name, t);
|
|
@@ -127,6 +133,11 @@ export function createMcpServer(opts) {
|
|
|
127
133
|
},
|
|
128
134
|
};
|
|
129
135
|
try {
|
|
136
|
+
// Keep the check at the transport choke point so every registered tool is
|
|
137
|
+
// covered, but leave unknown tools on the normal -32601 path above.
|
|
138
|
+
if (expectedPluginVersion !== undefined && expectedPluginVersion !== opts.version) {
|
|
139
|
+
throw new Error(`owenloop plugin ${expectedPluginVersion} does not match owenloop CLI ${opts.version}. Run: owenloop setup`);
|
|
140
|
+
}
|
|
130
141
|
const result = await reg.handler(args, ctx);
|
|
131
142
|
// A CLIENT-cancelled call sends NO response frame (the JSON-RPC/MCP
|
|
132
143
|
// cancel contract). A close-cancelled call still replies — see InFlight.
|
package/dist/src/model.d.ts
CHANGED
|
@@ -134,6 +134,42 @@ export declare function isSchemaStalled(a: ArtifactData | undefined, cap: number
|
|
|
134
134
|
* entry, which clears the held condition automatically.
|
|
135
135
|
*/
|
|
136
136
|
export declare function isHeld(a: ArtifactData | undefined): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* §7 escalation trigger: has this artifact been judgment-rejected at least
|
|
139
|
+
* `after` times in the CURRENT rejection episode?
|
|
140
|
+
*
|
|
141
|
+
* Reads `judgmentRejects`, the same counter `isStalled` reads and the same one
|
|
142
|
+
* `retry` zeroes — so "current episode" needs no separate bookkeeping: a human
|
|
143
|
+
* `retry` resets the counter and the trigger goes false again by itself.
|
|
144
|
+
*
|
|
145
|
+
* The state this tests is derived, never stored. Every offer of the step
|
|
146
|
+
* re-evaluates it, so the transition cannot half-apply, cannot be lost, and
|
|
147
|
+
* cannot be applied twice to one offer. It is deliberately independent of
|
|
148
|
+
* `acceptance`: unlike `isStalled` (which describes a FROZEN artifact and must
|
|
149
|
+
* only be true while it is sitting rejected), this describes the routing of the
|
|
150
|
+
* NEXT offer, and by the time that offer is built the artifact has been re-armed
|
|
151
|
+
* to `owed`.
|
|
152
|
+
*
|
|
153
|
+
* `after` comes from the step's authored `escalation.after`. Install validation
|
|
154
|
+
* (`defs.ts` R2) guarantees `after < effectiveMaxAttempts`, so there is always a
|
|
155
|
+
* window between "escalate" and "freeze" in which the escalated attempt runs.
|
|
156
|
+
*/
|
|
157
|
+
export declare function isEscalated(a: ArtifactData | undefined, after: number): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Which rejection episode this artifact is in: 0 before any human `retry`, 1
|
|
160
|
+
* after the first, and so on.
|
|
161
|
+
*
|
|
162
|
+
* `retry` is the only lever that ends an episode (it zeroes `judgmentRejects`),
|
|
163
|
+
* and it appends a `'retry'` entry to the append-only reason thread — so
|
|
164
|
+
* counting those entries yields a monotonic episode ordinal with no new column
|
|
165
|
+
* and no new state to keep consistent.
|
|
166
|
+
*
|
|
167
|
+
* Used to key an escalation's ONE history record per episode. It is not used to
|
|
168
|
+
* decide anything: the trigger above reads the counter, which is authoritative.
|
|
169
|
+
* If the thread and the counter ever disagreed, the ordinal would only mislabel
|
|
170
|
+
* a history row, never change routing.
|
|
171
|
+
*/
|
|
172
|
+
export declare function rejectionEpisode(a: ArtifactData | undefined): number;
|
|
137
173
|
/** Bare elements (no further suffix) of a collection stem, in index order. */
|
|
138
174
|
export declare function members(arts: ArtifactMap, stem: string): ArtifactData[];
|
|
139
175
|
/**
|
|
@@ -431,3 +467,18 @@ export declare function applyOutcome(def: WorkflowDef, arts: Map<string, Artifac
|
|
|
431
467
|
* Pure — no store, no engine, no IO.
|
|
432
468
|
*/
|
|
433
469
|
export declare function modelCheck(def: WorkflowDef, opts?: CheckOptions): CheckReport;
|
|
470
|
+
/**
|
|
471
|
+
* The single "definite defect" predicate over a modelCheck `report`, shared by
|
|
472
|
+
* every acceptance gate that accepts or rejects a def (`check`, `add`'s GitHub
|
|
473
|
+
* route, `add`'s workflow-bundle route, `push`). A pure function of the report
|
|
474
|
+
* object — it does NOT read or change how any caller seeded its modelCheck
|
|
475
|
+
* (install/push seed `assumeProvided: true`; check seeds
|
|
476
|
+
* `assumeProvided: !strictInputs`).
|
|
477
|
+
*
|
|
478
|
+
* invariant violations and structurally-dead steps are ALWAYS definite (sound
|
|
479
|
+
* regardless of bounds); a true deadlock counts ONLY when the search was
|
|
480
|
+
* exhaustive (`!bounded`) because a tight maxCollectionSize cap can manufacture
|
|
481
|
+
* a spurious one. `unreachedSteps` is deliberately EXCLUDED — it is a bounds
|
|
482
|
+
* artifact ("raise --max-states/--max-depth"), never a definite defect.
|
|
483
|
+
*/
|
|
484
|
+
export declare function hasDefiniteCheckDefect(report: CheckReport): boolean;
|