@parcha/agentrun-harness-codex 0.0.0-bootstrap.0 → 0.1.0-beta.100
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 +349 -0
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +81 -0
- package/dist/adapter.d.ts +93 -0
- package/dist/adapter.js +375 -0
- package/dist/app-server.d.ts +53 -0
- package/dist/app-server.js +105 -0
- package/dist/binary.d.ts +31 -0
- package/dist/binary.js +74 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +104 -0
- package/dist/code-mode.d.ts +171 -0
- package/dist/code-mode.js +514 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +214 -0
- package/dist/facts.d.ts +2 -0
- package/dist/facts.js +40 -0
- package/dist/harness.d.ts +210 -0
- package/dist/harness.js +1112 -0
- package/dist/host/kernel.d.ts +20 -0
- package/dist/host/kernel.js +3 -0
- package/dist/host/machine.d.ts +81 -0
- package/dist/host/machine.js +355 -0
- package/dist/host/policy.d.ts +113 -0
- package/dist/host/policy.js +683 -0
- package/dist/host/process.d.ts +151 -0
- package/dist/host/process.js +50 -0
- package/dist/host/sandbox.d.ts +36 -0
- package/dist/host/sandbox.js +35 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/rollout.d.ts +96 -0
- package/dist/rollout.js +170 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.js +178 -0
- package/dist/scripts.d.ts +218 -0
- package/dist/scripts.js +409 -0
- package/dist/tool-images.d.ts +7 -0
- package/dist/tool-images.js +18 -0
- package/dist/transcript.d.ts +20 -0
- package/dist/transcript.js +73 -0
- package/dist/verify.d.ts +62 -0
- package/dist/verify.js +155 -0
- package/dist/versions.d.ts +43 -0
- package/dist/versions.js +72 -0
- package/package.json +74 -1
- package/vendor/durable-harness/UPSTREAM.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
AgentRun
|
|
2
|
+
Copyright 2026 Parcha Labs, Inc.
|
|
3
|
+
|
|
4
|
+
The boxd computer provider (packages/computer/src/boxd.ts) was contributed by Michiel Voortman.
|
|
5
|
+
|
|
6
|
+
This product includes software from vercel-labs/durable-harness (https://github.com/vercel-labs/durable-harness), Copyright 2026 Vercel Inc., licensed under the Apache License 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @parcha/agentrun-harness-codex
|
|
2
|
+
|
|
3
|
+
Codex as an AgentRun harness: a DSL `agent` node runs on Codex through `@parcha/agentrun-kernel`, durable in AgentRun's
|
|
4
|
+
own store, with the host's tools as its only tools.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { createHarnessRunner } from "@parcha/agentrun-kernel";
|
|
8
|
+
import { codexAdapter } from "@parcha/agentrun-harness-codex";
|
|
9
|
+
|
|
10
|
+
const runNode = createHarnessRunner(
|
|
11
|
+
codexAdapter({
|
|
12
|
+
model: "gpt-6-luna",
|
|
13
|
+
provider: { origin: "https://api.openai.com", credential: () => process.env.OPENAI_API_KEY! },
|
|
14
|
+
sessionsDir: "/var/lib/my-host/codex-sessions",
|
|
15
|
+
}),
|
|
16
|
+
{ store, tools },
|
|
17
|
+
);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **The host's tools only.** Codex's app-server runs with its built-in tools off: no shell, no file edits, no web, no
|
|
21
|
+
images, no sub-agents. Codex's sandbox stays read-only for those built-ins, and its message describing that sandbox
|
|
22
|
+
is not sent, so the model is never told its files are read-only while the host's tools write them
|
|
23
|
+
(`test/developer-messages.test.mjs`). A classic model is offered exactly the host's tools (and the runner's
|
|
24
|
+
`submit`); a code-mode model is offered code mode's `exec` and `wait`, whose runtime has no Node modules, no process and no network, and
|
|
25
|
+
reaches the host's tools by their own names, as nested calls of the script it writes. A nested call of a computer tool
|
|
26
|
+
answers the tool's value as JSON text, its images' data in it, for the script to `JSON.parse`; any other tool answers
|
|
27
|
+
its words and a line saying how many images it returned were not sent, since in code mode an image reaches a script only
|
|
28
|
+
as text (`test/code-mode-images-taken.test.mjs`). Codex's runtime takes no
|
|
29
|
+
binding of ours, so a computer run offers `computer_op` (`{op, args}`: apps, shell, files, processes, raw input)
|
|
30
|
+
beside the computer's tools, and a script calls it as a nested call like any other, held to the run's gate. The proxy passes `exec` and
|
|
31
|
+
`wait` and drops the sub-agent and user-input tools Codex lists beside them; it keeps parallel tool calls off for a
|
|
32
|
+
code-mode request, and offers no `exec` while a script that yielded still runs, so one script is live at a time. A
|
|
33
|
+
nested call has an id of Codex's own (`exec-<uuid>`) that no line of the rollout carries and that names no `exec`, so
|
|
34
|
+
the session ties it to the one live script: the `exec` the proxy's latest answer carried (read before Codex has that
|
|
35
|
+
part of the answer) or that the rollout shows unfinished. A `never` tool's call waits for that `exec`'s line to be in
|
|
36
|
+
the log, and is declined, never run, while two scripts are live. `test/tool-off.test.mjs` runs the pinned binary
|
|
37
|
+
against a scripted model that calls every built-in, and checks that nothing runs, writes or spawns;
|
|
38
|
+
`test/code-mode-never.test.mjs` runs a `never` tool from code mode, from a script that yielded, and from a second
|
|
39
|
+
script a model wrote while the first ran. After a crash the harness's note about the interrupted turn reaches the model
|
|
40
|
+
once, as a developer message injected on the recovery resume (Codex ignores new developer instructions on resume, and every
|
|
41
|
+
turn opens with `thread/resume`), and the resumed turn's user input is the user's own words or `Continue.`.
|
|
42
|
+
- **The model behind a proxy.** Codex talks to a model proxy on the loopback interface with a key of its session's own;
|
|
43
|
+
it never holds the provider key. The proxy forwards `POST /v1/responses` only, fixes the model, stores nothing at the
|
|
44
|
+
provider, drops any tool that is not the session's, and asks the runner before every paid request, so the turn cap and
|
|
45
|
+
the host's budget hold. Each response's usage comes back to the runner.
|
|
46
|
+
- **Web search, when asked.** The one exception to the above: `webSearch: "live"` sets `web_search = "live"` in Codex's
|
|
47
|
+
config; the proxy then passes exactly the hosted tool Codex sends for it (`{ type: "web_search", external_web_access:
|
|
48
|
+
true }`, recorded in `test/fixtures/responses-request-web-search-live.json`) and refuses any other web search tool.
|
|
49
|
+
Each search a response ran (`tool_usage.web_search.num_requests`) is added to its price at OpenAI's $0.01 a call; a
|
|
50
|
+
model with no known search price books an unknown cost. A request that offers web search has no input bound, so a cap
|
|
51
|
+
treats its input as unknown.
|
|
52
|
+
- **Remote MCP tools are host tools.** Codex refuses a dynamic tool named `mcp` or `mcp__*` at `thread/start`, so a
|
|
53
|
+
host tool named `mcp__<server>__<tool>` reaches Codex as `mcp_<server>__<tool>`; the session maps the name back for
|
|
54
|
+
the host's gate and its events. Two tools that would reach Codex by one name are refused when the session is checked.
|
|
55
|
+
- **A private machine.** A session runs in its own directories. Its working directory is the host's workspace when the
|
|
56
|
+
host names one (`io.cwd`, where the host's file tools write, an untrusted project to Codex), and otherwise an empty
|
|
57
|
+
directory of the session's. Codex keeps nothing there, and takes no instructions from an `AGENTS.md` in it
|
|
58
|
+
(`test/developer-messages.test.mjs`). Codex's environment is an allowlist (`PATH`, `LANG`, `TZ`, its own homes and the proxy key); nothing else of the host's
|
|
59
|
+
reaches it, and its process group ends with the session.
|
|
60
|
+
- **The host's skills, and no others.** `codexAdapter({ skills: [{ name, files }] })`: Codex lists each skill to the model
|
|
61
|
+
by its name and description, and the model reads its `SKILL.md` and the files it names with `read_skill_file` (it has
|
|
62
|
+
no shell). The skills are written into the session's `CODEX_HOME` at the start of every drive, where Codex lists a
|
|
63
|
+
user's skills even in a turn with its built-ins off (it lists none from a working directory's `.agents/skills` there).
|
|
64
|
+
Codex's bundled skills (imagegen, openai-docs, skill-creator, skill-installer, ...) are off in every session, with
|
|
65
|
+
skills or without. The skills are checked when the adapter is made, by `skillProblems` of `@parcha/agentrun-kernel`,
|
|
66
|
+
the Claude adapter's check: a lowercase name, a `SKILL.md` whose front matter names it and describes it, plain
|
|
67
|
+
relative paths, 1 MiB in all. Codex itself skips a skill with no front matter or no description and lists one under
|
|
68
|
+
its front matter's name, so each of those is refused here instead.
|
|
69
|
+
- **Durable.** A session's records are in the store the host lends (Codex's rollout mirrored line by line, every tool
|
|
70
|
+
call an effect recorded before it runs). A session a process died inside resumes from its records: a `safe` tool runs
|
|
71
|
+
again, a `never` tool's cut-off call is reported to the model as interrupted and never repeated.
|
|
72
|
+
|
|
73
|
+
**Tool schemas.** Codex sanitizes the schema its model is given (measured on the pinned binary, recorded in `test/fixtures/schema-column.json`). The adapter refuses, when a session is checked, the shapes Codex drops or retypes (a tuple `items`, `prefixItems`, `patternProperties`, `if`/`then`/`else`, `not`, a non-scalar or untyped non-string `enum`/`const`, `contains`, `dependentRequired`, `propertyNames`, a boolean `items`, constraints inside `allOf`), naming the tool, the JSON pointer and the keyword. The keywords Codex only strips (bounds, patterns, formats, titles, defaults, examples) are listed in the tool's description, so the model still reads them; the host checks every call against the original schema. A schema object reused in two places is described at its first path.
|
|
74
|
+
|
|
75
|
+
The adapter is pinned to Codex 0.164.0. `@openai/codex` is the host's: an exact optional peer dependency, never shipped
|
|
76
|
+
here (`npm install --save-exact @openai/codex@0.164.0`). `codexAdapter()` checks the binary against the pins when it is
|
|
77
|
+
made and throws `CodexNotInstalled` or `CodexPinMismatch` before any run starts. `CODEX_BIN` names another path to the
|
|
78
|
+
same build.
|
|
79
|
+
|
|
80
|
+
Code this package copies from another project is listed in `vendor/durable-harness/UPSTREAM.json` and credited in
|
|
81
|
+
`NOTICE`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type HostSkill } from "@parcha/agentrun-kernel";
|
|
2
|
+
import type { AgentAdapter } from "@parcha/agentrun-kernel";
|
|
3
|
+
import { NativeJournal } from "@parcha/agentrun-kernel/process";
|
|
4
|
+
import { type ConfineChild } from "./host/machine.js";
|
|
5
|
+
import { type ModelProxyOptions } from "@parcha/agentrun-kernel/host";
|
|
6
|
+
/**
|
|
7
|
+
* The name Codex is given a host tool by. App-server reserves `mcp__` names for its own MCP client's tools and refuses a
|
|
8
|
+
* dynamic tool so named at the thread's start (`dynamic tool name is reserved`, 0.164.0, #1586), so a run's MCP tool
|
|
9
|
+
* (`mcp__<server>__<tool>`), a host tool like any other, is offered as `mcp_<server>__<tool>`. Every other name is
|
|
10
|
+
* as given. Inside the session only: the host's gate and the session's events name the call by the host's name.
|
|
11
|
+
*/
|
|
12
|
+
export declare const codexToolName: (name: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Codex's `tool_output_token_limit`: the host's result bound (HOST_RESULT_MAX_CHARS), as Codex counts it. Codex keeps a
|
|
15
|
+
* tool's output in the model's history within its truncation policy (10,000 tokens for each model its catalog holds, less
|
|
16
|
+
* for one it does not) and cuts the middle of a longer one; this sets the policy. Codex counts a token as four bytes of
|
|
17
|
+
* UTF-8, and a character (a UTF-16 unit) takes at most three, so a result within the bound in any script takes at most
|
|
18
|
+
* three quarters of a token a character: not a quarter, which holds for ASCII alone.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CODEX_TOOL_OUTPUT_TOKENS: number;
|
|
21
|
+
/** How long Codex waits on a silent stream from a model on the host's own machine (an Ollama model the route
|
|
22
|
+
* translates), which says nothing while it loads or reads a long prompt: 30 minutes, as claude-agent's CLI waits
|
|
23
|
+
* (its LOCAL_STREAM_IDLE_MS). Any other route keeps Codex's own five minutes. */
|
|
24
|
+
export declare const LOCAL_STREAM_IDLE_MS: number;
|
|
25
|
+
export interface CodexProvider {
|
|
26
|
+
/** The provider's origin (`https://api.openai.com`): the proxy forwards to its `/v1/responses` only. */
|
|
27
|
+
origin: string;
|
|
28
|
+
/** The provider key, read per request in this process. It never reaches Codex's process. */
|
|
29
|
+
credential: () => Promise<string> | string;
|
|
30
|
+
/** A person's ChatGPT plan (`credential` its access token), whose rules the proxy keeps (codexPolicy's `plan`). */
|
|
31
|
+
plan?: boolean;
|
|
32
|
+
/** Told the credential a request was sent with when the provider answered 401 to it (ModelProxyOptions.credentialRefused). */
|
|
33
|
+
refused?: (credential: string) => void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** Codex's own web search, as a session may turn it on: `live` (it searches the web as it runs). */
|
|
36
|
+
export type CodexWebSearch = "live";
|
|
37
|
+
export interface CodexAdapterOptions {
|
|
38
|
+
/** The provider's model id, or one per tier (`default` when a node names none). */
|
|
39
|
+
model: string | {
|
|
40
|
+
default: string;
|
|
41
|
+
fast?: string;
|
|
42
|
+
strong?: string;
|
|
43
|
+
};
|
|
44
|
+
provider: CodexProvider;
|
|
45
|
+
/** Start Codex under the host's confinement (its own `confine()`, a `setpriv --no-new-privs` prefix, say). It may only
|
|
46
|
+
* add in front of the pinned binary and its arguments, and never touches its environment. */
|
|
47
|
+
confine?: ConfineChild;
|
|
48
|
+
/** The price of a response; null (or no function) records its cost as unknown. */
|
|
49
|
+
price?: ModelProxyOptions["price"];
|
|
50
|
+
/** Codex's own web search, on the provider (OpenAI's hosted `web_search` tool): `"live"` sets `web_search = "live"` in
|
|
51
|
+
* Codex's config, the model proxy admits exactly the tool Codex then sends, and each search a response ran is added to
|
|
52
|
+
* its price at the model's per-call price (unknown for a model with no known search price). Default off. */
|
|
53
|
+
webSearch?: CodexWebSearch;
|
|
54
|
+
/** The most output tokens one request may ask for. Default 32 000. */
|
|
55
|
+
maxOutputTokens?: number;
|
|
56
|
+
/** The model's context window, in tokens: Codex is told it (`model_context_window`), and the host's bound on one tool
|
|
57
|
+
* result is its share of it (the kernel's resultMaxChars). A session's own (SessionSpec.contextWindow) wins. With
|
|
58
|
+
* neither, Codex is told 272 000 and the host's bound alone holds a result. */
|
|
59
|
+
contextWindow?: number;
|
|
60
|
+
/** How long Codex waits on a streamed answer that sends nothing. A host sets LOCAL_STREAM_IDLE_MS for a model on its
|
|
61
|
+
* own machine; absent, Codex's own limit (five minutes), so a hung paid stream holds the run's slot and cap no longer. */
|
|
62
|
+
streamIdleMs?: number;
|
|
63
|
+
/** Where sessions keep their private directories when the host lends none (`io.dir`): one per session key. */
|
|
64
|
+
sessionsDir?: string;
|
|
65
|
+
/** The host's skills, which Codex lists to the model by name and description and the model reads with
|
|
66
|
+
* `read_skill_file`, and no others: never Codex's bundled ones. Checked when the adapter is made (`skillProblems`, the
|
|
67
|
+
* check the Claude adapter runs). Written into each session's private directory. Default none. */
|
|
68
|
+
skills?: readonly HostSkill[];
|
|
69
|
+
/** Diagnostics. */
|
|
70
|
+
log?: (message: string, fields?: Record<string, unknown>) => void;
|
|
71
|
+
/** For tests: a command that speaks app-server's protocol instead of Codex (needs AGENTRUN_CODEX_STANDIN=1 under a test runner). */
|
|
72
|
+
standIn?: {
|
|
73
|
+
command: string;
|
|
74
|
+
args?: string[];
|
|
75
|
+
env?: Record<string, string>;
|
|
76
|
+
};
|
|
77
|
+
/** The Codex binary to run, as the host installed it (its path, and its platform package's version): checked against
|
|
78
|
+
* the pins as one found here is. Default: found beside this package (findCodex). */
|
|
79
|
+
binary?: {
|
|
80
|
+
path: string;
|
|
81
|
+
packageVersion?: string;
|
|
82
|
+
};
|
|
83
|
+
/** For tests: the fetch the model proxy forwards with. */
|
|
84
|
+
fetch?: typeof fetch;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The mirrored rollout the next drive resumes Codex from, by the harness's own rule (harness.ts, `resume`: the last
|
|
88
|
+
* thread, its first line `session_meta`, its path the one the harness derives); none when it would start a new thread.
|
|
89
|
+
* The settle reads only this, so it and the next Codex agree on what Codex has. The copied harness keeps its own copy
|
|
90
|
+
* of the rule: its own patch budget has no room for a call here.
|
|
91
|
+
*/
|
|
92
|
+
export declare function resumedRollout(journal: NativeJournal): Promise<string[]>;
|
|
93
|
+
export declare function codexAdapter(options: CodexAdapterOptions): AgentAdapter;
|