@karowanorg/orc-ops 0.1.0

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Registry assembly — zero-config by default: built-ins (claude, codex) are
3
+ * registered unconditionally and probed natively at capability time. There is
4
+ * deliberately NO ambient plugin scanning; custom harnesses and extensions
5
+ * come only from an explicit orc.config.(js|json).
6
+ */
7
+ import { callerAffinity, loadConfig } from "@karowanorg/orc-core";
8
+ import { executorFor } from "@karowanorg/orc-executors";
9
+ import { claudeHarness } from "@karowanorg/orc-harness-claude";
10
+ import { codexHarness, createCodexHarness } from "@karowanorg/orc-harness-codex";
11
+ import { makeExecHarness } from "./exec-harness.js";
12
+ export async function buildRegistry(opts = {}) {
13
+ const config = await loadConfig(opts.cwd ?? process.cwd());
14
+ const harnesses = new Map();
15
+ harnesses.set(claudeHarness.name, claudeHarness);
16
+ // Codex needs a cost-rate table (it reports tokens, not dollars); pass config
17
+ // overrides through, else the built-in default is used.
18
+ const codex = config.costRates ? createCodexHarness({ costRates: config.costRates }) : codexHarness;
19
+ harnesses.set(codex.name, codex);
20
+ for (const entry of config.harnesses ?? []) {
21
+ if ("exec" in entry) {
22
+ const h = makeExecHarness(entry.exec, entry.name);
23
+ harnesses.set(h.name, h);
24
+ }
25
+ else {
26
+ harnesses.set(entry.name, entry);
27
+ }
28
+ }
29
+ const extensions = new Map((config.extensions ?? []).map((e) => [e.name, e]));
30
+ const defaultHarness = opts.defaultHarness ??
31
+ config.defaultHarness ??
32
+ callerAffinity(opts.mcpClientName) ??
33
+ "codex";
34
+ return { harnesses, extensions, defaultHarness, executorFor };
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { runSupervisorChild } from "./supervisor-run.js";
2
+ const runId = process.argv[2];
3
+ if (!runId) {
4
+ process.stderr.write("orc supervisor: run id is required\n");
5
+ process.exitCode = 1;
6
+ }
7
+ else {
8
+ try {
9
+ await runSupervisorChild(runId);
10
+ }
11
+ catch (err) {
12
+ process.stderr.write(`orc supervisor: ${String(err instanceof Error ? err.stack ?? err.message : err)}\n`);
13
+ process.exitCode = 1;
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ /** Package-owned detached-supervisor body, shared by the CLI and SDK child entry. */
2
+ export declare function runSupervisorChild(runId: string, registryCwd?: string | undefined): Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { readManifest, superviseRun } from "@karowanorg/orc-core";
2
+ import { writeReport } from "@karowanorg/orc-ui";
3
+ import { buildRegistry } from "./registry.js";
4
+ async function signalStartup(type, message) {
5
+ if (typeof process.send !== "function")
6
+ return;
7
+ await new Promise((resolve) => {
8
+ try {
9
+ process.send({ type, message }, () => {
10
+ if (process.connected)
11
+ process.disconnect();
12
+ resolve();
13
+ });
14
+ }
15
+ catch {
16
+ resolve();
17
+ }
18
+ });
19
+ }
20
+ /** Package-owned detached-supervisor body, shared by the CLI and SDK child entry. */
21
+ export async function runSupervisorChild(runId, registryCwd = process.env.ORC_SUPERVISOR_REGISTRY_CWD) {
22
+ let lastReportAt = 0;
23
+ let settled = false;
24
+ let startupQueued = false;
25
+ let startupSignaled = false;
26
+ const onUpdate = (id) => {
27
+ if (!startupQueued) {
28
+ startupQueued = true;
29
+ // superviseRun also calls onUpdate from its finally block. Deferring one
30
+ // turn lets a preflight rejection win and report an error instead.
31
+ setImmediate(() => {
32
+ if (settled || startupSignaled)
33
+ return;
34
+ startupSignaled = true;
35
+ void signalStartup("orc-supervisor-ready");
36
+ });
37
+ }
38
+ if (Date.now() - lastReportAt <= 1_000)
39
+ return;
40
+ lastReportAt = Date.now();
41
+ try {
42
+ writeReport(id);
43
+ }
44
+ catch {
45
+ /* best-effort */
46
+ }
47
+ };
48
+ try {
49
+ const registry = await buildRegistry({ cwd: registryCwd });
50
+ readManifest(runId);
51
+ await superviseRun(runId, registry, { onUpdate });
52
+ settled = true;
53
+ if (!startupSignaled) {
54
+ startupSignaled = true;
55
+ await signalStartup("orc-supervisor-ready");
56
+ }
57
+ writeReport(runId);
58
+ }
59
+ catch (err) {
60
+ settled = true;
61
+ if (!startupSignaled) {
62
+ startupSignaled = true;
63
+ await signalStartup("orc-supervisor-error", String(err instanceof Error ? err.message : err));
64
+ }
65
+ throw err;
66
+ }
67
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@karowanorg/orc-ops",
3
+ "version": "0.1.0",
4
+ "license": "0BSD",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "dependencies": {
8
+ "@karowanorg/orc-core": "^0.1.0",
9
+ "@karowanorg/orc-executors": "^0.1.0",
10
+ "@karowanorg/orc-harness-claude": "^0.1.0",
11
+ "@karowanorg/orc-harness-codex": "^0.1.0",
12
+ "@karowanorg/orc-ui": "^0.1.0",
13
+ "zod": "^4.1.0"
14
+ },
15
+ "description": "The zod-first operation registry orc's CLI, MCP server, and SDK all interpret.",
16
+ "types": "dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "engines": {
30
+ "node": ">=20"
31
+ }
32
+ }