owenloop 0.4.0 → 0.5.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +98 -25
  3. package/bin/owenloop.mjs +2 -2
  4. package/dist/packages/work/src/agent/brief.d.ts +172 -0
  5. package/dist/packages/work/src/agent/brief.js +193 -0
  6. package/dist/packages/work/src/agent/loop.d.ts +135 -0
  7. package/dist/packages/work/src/agent/loop.js +542 -0
  8. package/dist/packages/work/src/agent/workdir.d.ts +210 -0
  9. package/dist/packages/work/src/agent/workdir.js +319 -0
  10. package/dist/packages/work/src/bundle/cache.d.ts +90 -0
  11. package/dist/packages/work/src/bundle/cache.js +324 -0
  12. package/dist/packages/work/src/bundle/fetch.d.ts +85 -0
  13. package/dist/packages/work/src/bundle/fetch.js +325 -0
  14. package/dist/packages/work/src/bundle/types.d.ts +160 -0
  15. package/dist/packages/work/src/bundle/types.js +1 -0
  16. package/dist/packages/work/src/credentials/owenloop.d.ts +11 -0
  17. package/dist/packages/work/src/credentials/owenloop.js +28 -0
  18. package/dist/packages/work/src/credentials/reader.d.ts +36 -0
  19. package/dist/packages/work/src/credentials/reader.js +32 -0
  20. package/dist/packages/work/src/credentials/resolve.d.ts +19 -0
  21. package/dist/packages/work/src/credentials/resolve.js +56 -0
  22. package/dist/packages/work/src/exec/loop.d.ts +29 -0
  23. package/dist/packages/work/src/exec/loop.js +215 -0
  24. package/dist/packages/work/src/exec/receipt.d.ts +38 -0
  25. package/dist/packages/work/src/exec/receipt.js +21 -0
  26. package/dist/packages/work/src/exec/runner.d.ts +65 -0
  27. package/dist/packages/work/src/exec/runner.js +185 -0
  28. package/dist/packages/work/src/harness/child-env.d.ts +100 -0
  29. package/dist/packages/work/src/harness/child-env.js +127 -0
  30. package/dist/packages/work/src/harness/claude.d.ts +128 -0
  31. package/dist/packages/work/src/harness/claude.js +635 -0
  32. package/dist/packages/work/src/harness/codex.d.ts +110 -0
  33. package/dist/packages/work/src/harness/codex.js +896 -0
  34. package/dist/packages/work/src/harness/contract.d.ts +283 -0
  35. package/dist/packages/work/src/harness/contract.js +32 -0
  36. package/dist/packages/work/src/harness/fake.d.ts +59 -0
  37. package/dist/packages/work/src/harness/fake.js +90 -0
  38. package/dist/packages/work/src/harness/jsonrpc-stdio.d.ts +108 -0
  39. package/dist/packages/work/src/harness/jsonrpc-stdio.js +344 -0
  40. package/dist/packages/work/src/harness/permissions.d.ts +62 -0
  41. package/dist/packages/work/src/harness/permissions.js +93 -0
  42. package/dist/packages/work/src/harness/registry.d.ts +47 -0
  43. package/dist/packages/work/src/harness/registry.js +45 -0
  44. package/dist/packages/work/src/harness/session-store.d.ts +163 -0
  45. package/dist/packages/work/src/harness/session-store.js +319 -0
  46. package/dist/packages/work/src/harness/types.d.ts +29 -0
  47. package/dist/packages/work/src/harness/types.js +14 -0
  48. package/dist/packages/work/src/harnesses.d.ts +38 -0
  49. package/dist/packages/work/src/harnesses.js +38 -0
  50. package/dist/packages/work/src/hold/loop.d.ts +36 -0
  51. package/dist/packages/work/src/hold/loop.js +23 -0
  52. package/dist/packages/work/src/hold/mcp.d.ts +55 -0
  53. package/dist/packages/work/src/hold/mcp.js +149 -0
  54. package/dist/packages/work/src/hub/client.d.ts +22 -0
  55. package/dist/packages/work/src/hub/client.js +78 -0
  56. package/dist/packages/work/src/hub/types.d.ts +290 -0
  57. package/dist/packages/work/src/hub/types.js +28 -0
  58. package/dist/packages/work/src/lease/loop.d.ts +94 -0
  59. package/dist/packages/work/src/lease/loop.js +277 -0
  60. package/dist/packages/work/src/main.d.ts +1 -0
  61. package/dist/packages/work/src/main.js +48 -0
  62. package/dist/packages/work/src/mcp/server.d.ts +125 -0
  63. package/dist/packages/work/src/mcp/server.js +320 -0
  64. package/dist/packages/work/src/roles/agent-run.d.ts +118 -0
  65. package/dist/packages/work/src/roles/agent-run.js +447 -0
  66. package/dist/packages/work/src/roles/exec.d.ts +40 -0
  67. package/dist/packages/work/src/roles/exec.js +203 -0
  68. package/dist/packages/work/src/roles/hold.d.ts +68 -0
  69. package/dist/packages/work/src/roles/hold.js +324 -0
  70. package/dist/packages/work/src/roles/join.d.ts +18 -0
  71. package/dist/packages/work/src/roles/join.js +204 -0
  72. package/dist/packages/work/src/roles/lint.d.ts +59 -0
  73. package/dist/packages/work/src/roles/lint.js +200 -0
  74. package/dist/packages/work/src/roles/prepare.d.ts +1 -0
  75. package/dist/packages/work/src/roles/prepare.js +249 -0
  76. package/dist/packages/work/src/roles/release.d.ts +48 -0
  77. package/dist/packages/work/src/roles/release.js +137 -0
  78. package/dist/packages/work/src/roles/sessions.d.ts +61 -0
  79. package/dist/packages/work/src/roles/sessions.js +180 -0
  80. package/dist/packages/work/src/roles/settings.d.ts +6 -0
  81. package/dist/packages/work/src/roles/settings.js +66 -0
  82. package/dist/packages/work/src/roles/shift.d.ts +12 -0
  83. package/dist/packages/work/src/roles/shift.js +228 -0
  84. package/dist/packages/work/src/roles/signals.d.ts +55 -0
  85. package/dist/packages/work/src/roles/signals.js +62 -0
  86. package/dist/packages/work/src/settings/provision.d.ts +21 -0
  87. package/dist/packages/work/src/settings/provision.js +47 -0
  88. package/dist/packages/work/src/settings/settings.d.ts +120 -0
  89. package/dist/packages/work/src/settings/settings.js +116 -0
  90. package/dist/packages/work/src/shift/client.d.ts +24 -0
  91. package/dist/packages/work/src/shift/client.js +124 -0
  92. package/dist/packages/work/src/shift/loop.d.ts +120 -0
  93. package/dist/packages/work/src/shift/loop.js +468 -0
  94. package/dist/packages/work/src/shift/protocol.d.ts +91 -0
  95. package/dist/packages/work/src/shift/protocol.js +24 -0
  96. package/dist/packages/work/src/shift/routing.d.ts +35 -0
  97. package/dist/packages/work/src/shift/routing.js +50 -0
  98. package/dist/packages/work/src/shift/runtime.d.ts +43 -0
  99. package/dist/packages/work/src/shift/runtime.js +274 -0
  100. package/dist/packages/work/src/shift/server.d.ts +23 -0
  101. package/dist/packages/work/src/shift/server.js +716 -0
  102. package/dist/packages/work/src/shift/spawn.d.ts +86 -0
  103. package/dist/packages/work/src/shift/spawn.js +100 -0
  104. package/dist/packages/work/src/shift/state.d.ts +77 -0
  105. package/dist/packages/work/src/shift/state.js +162 -0
  106. package/dist/packages/work/src/usage.d.ts +6 -0
  107. package/dist/packages/work/src/usage.js +175 -0
  108. package/dist/{add.d.ts → src/add.d.ts} +12 -40
  109. package/dist/{add.js → src/add.js} +11 -176
  110. package/dist/src/cli.d.ts +147 -0
  111. package/dist/{cli.js → src/cli.js} +1643 -353
  112. package/dist/src/credentials.d.ts +280 -0
  113. package/dist/src/credentials.js +697 -0
  114. package/dist/{defs.js → src/defs.js} +59 -36
  115. package/dist/{engine.d.ts → src/engine.d.ts} +8 -8
  116. package/dist/{engine.js → src/engine.js} +29 -20
  117. package/dist/{hub.d.ts → src/hub.d.ts} +330 -2
  118. package/dist/{hub.js → src/hub.js} +531 -1
  119. package/dist/{index.d.ts → src/index.d.ts} +3 -1
  120. package/dist/{index.js → src/index.js} +2 -1
  121. package/dist/src/lock.d.ts +80 -0
  122. package/dist/src/lock.js +217 -0
  123. package/dist/src/mcp/serve.d.ts +85 -0
  124. package/dist/src/mcp/serve.js +702 -0
  125. package/dist/src/mcp/server.d.ts +132 -0
  126. package/dist/src/mcp/server.js +327 -0
  127. package/dist/{model.d.ts → src/model.d.ts} +59 -4
  128. package/dist/{model.js → src/model.js} +149 -22
  129. package/dist/{types.d.ts → src/types.d.ts} +66 -24
  130. package/dist/{util.d.ts → src/util.d.ts} +25 -0
  131. package/dist/{util.js → src/util.js} +26 -0
  132. package/dist/src/work-settings.d.ts +57 -0
  133. package/dist/src/work-settings.js +84 -0
  134. package/docs/authoring.md +102 -53
  135. package/docs/cli.md +883 -29
  136. package/docs/design.md +119 -45
  137. package/docs/embedding.md +39 -14
  138. package/examples/workflows/{command-worker.yaml → command-executor.yaml} +15 -15
  139. package/examples/workflows/compile-dev-playbook.yaml +338 -0
  140. package/examples/workflows/judges/gate-sharpness.md +39 -0
  141. package/examples/workflows/judges/security.md +34 -0
  142. package/package.json +17 -8
  143. package/dist/cli.d.ts +0 -83
  144. /package/dist/{defs.d.ts → src/defs.d.ts} +0 -0
  145. /package/dist/{factory.d.ts → src/factory.d.ts} +0 -0
  146. /package/dist/{factory.js → src/factory.js} +0 -0
  147. /package/dist/{paths.d.ts → src/paths.d.ts} +0 -0
  148. /package/dist/{paths.js → src/paths.js} +0 -0
  149. /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
  150. /package/dist/{schema.js → src/schema.js} +0 -0
  151. /package/dist/{store.d.ts → src/store.d.ts} +0 -0
  152. /package/dist/{store.js → src/store.js} +0 -0
  153. /package/dist/{types.js → src/types.js} +0 -0
  154. /package/dist/{untar.d.ts → src/untar.d.ts} +0 -0
  155. /package/dist/{untar.js → src/untar.js} +0 -0
@@ -0,0 +1,110 @@
1
+ import type { AgentEvent, DeliverArgs, HarnessAdapter } from './contract.ts';
2
+ /** The adapter id. Matches the `"codex"` key in `harness-versions.json`, so the
3
+ * worker can use one string for both the version pin and the adapter lookup. */
4
+ export declare const HARNESS_ID = "codex";
5
+ /**
6
+ * The resume-failure signature, in ONE place.
7
+ *
8
+ * Observed verbatim on 0.146.0: `no rollout found for thread id <uuid>` with
9
+ * code `-32600`. The `thread not found` alternative is defensive against a
10
+ * wording change.
11
+ *
12
+ * Matching `-32600` ALONE would be actively wrong, and that is measured, not
13
+ * assumed: the same code and no other comes back for an unknown method name
14
+ * (`unknown variant '<method>'`) and for a missing required param
15
+ * (`missing field 'threadId'`). A client that read bare `-32600` as
16
+ * "thread is gone" would answer a typo in a method name by throwing away a live
17
+ * thread and cold-replaying the entire step.
18
+ */
19
+ export declare const RESUME_UNAVAILABLE_MESSAGE_RE: RegExp;
20
+ /** The JSON-RPC code the resume failure rides. Never sufficient on its own. */
21
+ export declare const RESUME_UNAVAILABLE_CODE = -32600;
22
+ /** True only when BOTH the code and the message say "I do not know this thread". */
23
+ export declare function isResumeMiss(err: unknown): boolean;
24
+ /** One entry in `config.mcp_servers`. */
25
+ export interface McpServerSpec {
26
+ command: string;
27
+ args: string[];
28
+ env?: Record<string, string>;
29
+ }
30
+ /**
31
+ * Build the `thread/start` params. PURE — exported for tests.
32
+ *
33
+ * Takes `DeliverArgs`, not `StartArgs`, because it never reads `brief` and Phase
34
+ * 4's `deliver` needs the identical mapping (`StartArgs` is assignable to
35
+ * `DeliverArgs`, so every `start` call site is unaffected).
36
+ *
37
+ * Deliberately unmapped, so a reader sees intent rather than oversight:
38
+ * - `permissions.tools` / `permissions.disallowedTools`: 0.146.0 has no
39
+ * per-thread built-in-tool allow-list; the sandbox and the approval policy
40
+ * are the levers it does have.
41
+ * - `permissions.maxTurns`: no `thread/start` or `turn/start` equivalent.
42
+ * - `permissions.effort`: not a `ThreadStartParams` field — it is a
43
+ * `turn/start` param, so it lands in `buildTurnStartParams`.
44
+ * - every `extensions` key other than `mcpServers`, `codexConfig` and
45
+ * `sandbox`: those are the other harness's frontmatter concepts (`hooks`,
46
+ * `memory`, `skills`, `background`, `isolation`, `color`, `initialPrompt`).
47
+ * Unknown keys are ignored silently; `owenloop work lint` is where an unknown key
48
+ * gets warned about.
49
+ */
50
+ export declare function buildThreadStartParams(args: DeliverArgs, onEvent?: (e: AgentEvent) => void): Record<string, unknown>;
51
+ /**
52
+ * Build the `turn/start` params. PURE — exported for tests.
53
+ *
54
+ * `input` is an ARRAY of `UserInput`; the text variant is `{type:'text', text}`.
55
+ * A bare string is the natural wrong guess and the server rejects it.
56
+ */
57
+ export declare function buildTurnStartParams(threadId: string, text: string, effort?: string): Record<string, unknown>;
58
+ /**
59
+ * Build the `thread/resume` params. PURE — exported for tests.
60
+ *
61
+ * `base` is the resolved `thread/start` params from the session map when this
62
+ * process started the thread. `ThreadResumeParams` accepts `approvalPolicy`,
63
+ * `sandbox`, `model` and `config`, and a resumed thread that does not re-supply
64
+ * them reverts to the server's defaults.
65
+ *
66
+ * PHASE 4 CLOSED CONTRACT OBSERVATION 1. `deliver`'s third argument used to carry
67
+ * only `cwd` and `owenloopMcp`, so a resume in a different process from the start
68
+ * (the normal case for a re-offered step) had nothing to rebuild `approvalPolicy`
69
+ * / `sandbox` / `model` from and silently reverted to server defaults. It now
70
+ * carries the normalized `StepPermissions`, so this function derives the SAME
71
+ * params `buildThreadStartParams` would, and `args` WINS over `base` on every
72
+ * key — `base` only fills in what a `DeliverArgs` cannot express.
73
+ *
74
+ * The owenloop mount is ALWAYS re-supplied. Without it the resumed agent has no
75
+ * `submit` tool — a silent, total failure.
76
+ */
77
+ export declare function buildThreadResumeParams(threadId: string, args: DeliverArgs, base?: Record<string, unknown>, onEvent?: (e: AgentEvent) => void): Record<string, unknown>;
78
+ /** The turn-end shape `mapNotification` reports for a `turn/completed` frame. */
79
+ export interface TurnOutcome {
80
+ status: string;
81
+ turnId: string | undefined;
82
+ error: string | undefined;
83
+ }
84
+ /**
85
+ * Read a `turn/completed` frame's outcome. PURE — exported for tests.
86
+ * Returns `undefined` for anything that is not a `turn/completed`.
87
+ */
88
+ export declare function readTurnCompleted(method: string, params: unknown): TurnOutcome | undefined;
89
+ /**
90
+ * Map one server→client notification to an `AgentEvent`.
91
+ *
92
+ * PURE and TOTAL — this is the function the recorded fixture replays through, so
93
+ * it must never throw on a shape it has not seen. `undefined` means "not worth
94
+ * surfacing"; nothing may depend on any particular progress line existing.
95
+ *
96
+ * `thread/started` maps to nothing on purpose: `start` emits `{kind:'started'}`
97
+ * itself from the `thread/start` RESPONSE, so the token is captured even if the
98
+ * notification ordering changes.
99
+ */
100
+ export declare function mapNotification(method: string, params: unknown): AgentEvent | undefined;
101
+ /**
102
+ * Read an `mcpServer/startupStatus/updated` frame for the owenloop mount's
103
+ * FAILURE only. PURE — exported for tests.
104
+ *
105
+ * Gates on an explicit `'failed'`, never on the absence of a `'ready'`: absence
106
+ * of a notification is not proof of failure, and gating on ever seeing `'ready'`
107
+ * would deadlock the moment the notification is renamed.
108
+ */
109
+ export declare function readOwenloopMountFailure(method: string, params: unknown): string | undefined;
110
+ export declare const codexAdapter: HarnessAdapter;