@harapter/adapter-codex 0.1.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/LICENSE +201 -0
- package/README.md +250 -0
- package/dist/adapter.d.ts +28 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +1033 -0
- package/dist/adapter.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +77 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +631 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Harapter contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# `@harapter/adapter-codex`
|
|
2
|
+
|
|
3
|
+
`@harapter/adapter-codex` exposes the official Codex harness through the stable
|
|
4
|
+
[Codex App Server](https://developers.openai.com/codex/app-server) interface and
|
|
5
|
+
maps it to the portable Harapter lifecycle. The harness and App Server source
|
|
6
|
+
live in the open-source
|
|
7
|
+
[OpenAI Codex repository](https://github.com/openai/codex).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @harapter/core@next @harapter/adapter-codex@next
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Runtime prerequisites and compatibility
|
|
16
|
+
|
|
17
|
+
The host installs and authenticates Codex. This package does not include the
|
|
18
|
+
Codex binary, read credentials, resolve `SecretRef` values, or change a host
|
|
19
|
+
security policy. The configured process is launched without a shell, and its
|
|
20
|
+
stderr is not captured or exposed.
|
|
21
|
+
|
|
22
|
+
The Adapter targets the current stable App Server interface with
|
|
23
|
+
`experimentalApi: false`. `connect()` completes the required `initialize` /
|
|
24
|
+
`initialized` handshake, validates the required response structure, and keeps
|
|
25
|
+
the returned runtime version only as non-sensitive diagnostic identity. The
|
|
26
|
+
leading user-agent product name may reflect `clientInfo.name` or a process-level
|
|
27
|
+
originator, so it is not treated as Provider identity. There is no CLI version
|
|
28
|
+
allowlist. Malformed required structures fail with `provider_api_incompatible`,
|
|
29
|
+
while unknown events remain observable through the bounded raw channel.
|
|
30
|
+
|
|
31
|
+
The upstream runtime and generated Schema are Apache-2.0 licensed. Harapter does
|
|
32
|
+
not redistribute either one; see the
|
|
33
|
+
[license record](../../licenses/openai-codex.md).
|
|
34
|
+
|
|
35
|
+
## Public entrypoints
|
|
36
|
+
|
|
37
|
+
- `CODEX_PROVIDER_ID` is `openai.codex`.
|
|
38
|
+
- `createCodexProviderFactory()` returns a dynamically registrable Provider
|
|
39
|
+
factory.
|
|
40
|
+
- `CODEX_USER_INPUT_PART` names the explicit `openai.codex.userInput` native
|
|
41
|
+
input escape hatch.
|
|
42
|
+
- `CodexNativeClient` exposes initialized native requests, notifications, the
|
|
43
|
+
non-sensitive runtime identity, and bounded redacted unknown-event
|
|
44
|
+
observation.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
48
|
+
import {
|
|
49
|
+
CODEX_PROVIDER_ID,
|
|
50
|
+
createCodexProviderFactory,
|
|
51
|
+
} from '@harapter/adapter-codex';
|
|
52
|
+
|
|
53
|
+
const registry = new HarnessRegistry();
|
|
54
|
+
registry.register(createCodexProviderFactory());
|
|
55
|
+
|
|
56
|
+
const client = await registry.connect({
|
|
57
|
+
profileId: profileId('codex-local'),
|
|
58
|
+
providerId: CODEX_PROVIDER_ID,
|
|
59
|
+
displayName: 'Local Codex',
|
|
60
|
+
connection: {
|
|
61
|
+
kind: 'process',
|
|
62
|
+
command: 'codex',
|
|
63
|
+
args: ['app-server', '--stdio'],
|
|
64
|
+
ownership: 'adapter',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const session = await client.createSession();
|
|
69
|
+
const run = await session.start({
|
|
70
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
for await (const event of run.events()) {
|
|
74
|
+
// Render or persist according to the host's data policy.
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const result = await run.result();
|
|
78
|
+
await session.close();
|
|
79
|
+
await client.close();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Profile and process ownership
|
|
83
|
+
|
|
84
|
+
The Adapter currently accepts only `process` connections with
|
|
85
|
+
`ownership: "adapter"`. The Profile supplies the complete command, arguments,
|
|
86
|
+
and optional process working directory. Harapter never appends installation or
|
|
87
|
+
authentication commands and never invokes a shell. This package has no host
|
|
88
|
+
Secret Store resolver. `envRefs` are rejected. The child otherwise inherits the
|
|
89
|
+
environment selected by the host process.
|
|
90
|
+
|
|
91
|
+
`HarnessProfile.providerOptions` accepts these positive integer limits:
|
|
92
|
+
|
|
93
|
+
- `maxMessageBytes`, `maxBufferedMessages`, `maxPendingRequests`,
|
|
94
|
+
`maxPendingInboundRequests`, and `maxPendingWrites` configure the shared JSONL
|
|
95
|
+
RPC transport;
|
|
96
|
+
- `requestTimeoutMs` bounds each App Server request wait;
|
|
97
|
+
- `cancelSettlementTimeoutMs` bounds the wait for native `turn/started`, the
|
|
98
|
+
`turn/interrupt` request, and its authoritative terminal notification;
|
|
99
|
+
- `maxRunEvents` bounds unread portable events and must be at least two so a
|
|
100
|
+
terminal event always has reserved space.
|
|
101
|
+
|
|
102
|
+
An unread Run that exhausts its event bound closes the connection and settles as
|
|
103
|
+
`connection_aborted`; it does not silently drop events or claim native
|
|
104
|
+
cancellation.
|
|
105
|
+
|
|
106
|
+
## Session, Run, and input mapping
|
|
107
|
+
|
|
108
|
+
Codex Thread is a Harapter Session, and Codex Turn is a Harapter Run. A
|
|
109
|
+
`SessionRef` stores the native Thread id and remains bound to the creating
|
|
110
|
+
Provider, Profile, stable App Server interface, and Provider-owned state. Resume
|
|
111
|
+
checks those fields before sending `thread/resume`, and it rejects a response
|
|
112
|
+
that identifies another Thread. Ephemeral Threads declare Session resume as
|
|
113
|
+
unsupported and are rejected before Provider traffic.
|
|
114
|
+
|
|
115
|
+
`CreateSessionInput` maps workspace file URIs, system context, and model id to
|
|
116
|
+
stable `thread/start` fields. Its `providerOptions` accepts `approvalPolicy`,
|
|
117
|
+
`sandbox`, `modelProvider`, `serviceTier`, `personality`, `config`, and
|
|
118
|
+
`ephemeral`. Omitting these fields preserves the active Codex configuration; the
|
|
119
|
+
Adapter does not choose a weaker approval or sandbox policy.
|
|
120
|
+
|
|
121
|
+
Runs accept text and image references. Arbitrary file references are
|
|
122
|
+
unsupported. `RunOptions.providerOptions` accepts the stable turn overrides
|
|
123
|
+
`approvalPolicy`, `effort`, `model`, `outputSchema`, `personality`,
|
|
124
|
+
`sandboxPolicy`, `serviceTier`, and `summary`. Unknown options fail instead of
|
|
125
|
+
being silently ignored. A positive `timeoutMs` requests native `turn/interrupt`;
|
|
126
|
+
an authoritative `interrupted` terminal result is returned as `cancelled` with a
|
|
127
|
+
timeout reason.
|
|
128
|
+
|
|
129
|
+
The Adapter enforces one active Turn per Thread and rejects any Turn identifier
|
|
130
|
+
reused during the connection lifetime. Reuse aborts the connection so late
|
|
131
|
+
traffic cannot be reassigned to a later Run. `turn/completed` is the only
|
|
132
|
+
authoritative Run terminal notification:
|
|
133
|
+
|
|
134
|
+
- `completed` → `run.completed`;
|
|
135
|
+
- `interrupted` → `run.cancelled`;
|
|
136
|
+
- `failed` → `run.failed` with only a safe Provider error code;
|
|
137
|
+
- an unknown status in a structurally complete terminal → a redacted `provider`
|
|
138
|
+
event and `run.failed`, never success;
|
|
139
|
+
- a malformed terminal → a redacted `provider` event while the Run remains
|
|
140
|
+
active.
|
|
141
|
+
|
|
142
|
+
Closing the Client or losing the process settles active Runs as
|
|
143
|
+
`connection_aborted`. Only a successful `turn/interrupt` followed by the
|
|
144
|
+
authoritative `interrupted` terminal status reports native cancellation. The
|
|
145
|
+
Adapter waits for the matching native `turn/started` notification before
|
|
146
|
+
requesting interruption. A missing start notification or an acknowledged
|
|
147
|
+
interrupt without a terminal notification closes the owning connection after
|
|
148
|
+
`cancelSettlementTimeoutMs` and reports `connection_aborted`.
|
|
149
|
+
|
|
150
|
+
## Events and interactions
|
|
151
|
+
|
|
152
|
+
Agent message, reasoning, Tool lifecycle, Tool update, usage, interaction, and
|
|
153
|
+
terminal notifications map to the portable event vocabulary. Completed agent
|
|
154
|
+
message items are authoritative for `finalMessage`. Known message, reasoning,
|
|
155
|
+
Tool, and interaction content remains application data and must follow the
|
|
156
|
+
host's normal privacy and persistence policy.
|
|
157
|
+
|
|
158
|
+
Unknown notifications during a Run remain observable as `provider` events. Their
|
|
159
|
+
`raw` value is a bounded structural summary: string values and unsafe keys are
|
|
160
|
+
redacted, numeric scalar values are redacted, nesting and collections are
|
|
161
|
+
capped, and the method name is length-limited.
|
|
162
|
+
`CodexNativeClient.onUnknownEvent()` observes the same safe summary even when no
|
|
163
|
+
portable Run can own it. Unknown values are never reinterpreted as terminal
|
|
164
|
+
success.
|
|
165
|
+
|
|
166
|
+
Stable command and file-change requests map to portable approvals. App Server
|
|
167
|
+
user-input requests belong to the experimental API and remain explicit
|
|
168
|
+
`provider` interactions; the portable `interaction.user_input` capability is
|
|
169
|
+
unsupported. A host that needs a native Codex decision such as
|
|
170
|
+
`acceptForSession`, permission subsets, MCP elicitation, or another
|
|
171
|
+
Provider-specific response uses `InteractionResponse.kind: "provider"`
|
|
172
|
+
explicitly. Server requests that cannot be associated with an active Run are
|
|
173
|
+
denied instead of changing state invisibly.
|
|
174
|
+
|
|
175
|
+
## Capabilities and native access
|
|
176
|
+
|
|
177
|
+
The current stable Schema declares native Session creation and resume,
|
|
178
|
+
streaming, Turn interrupt, text and image input, approvals, generic Provider
|
|
179
|
+
interactions, and native client access. Session close, connection abort, and
|
|
180
|
+
bounded raw observation are Adapter-controlled. Session fork, portable file
|
|
181
|
+
input, and portable user input are explicitly unsupported.
|
|
182
|
+
|
|
183
|
+
Capability values are selected only after the stable App Server handshake is
|
|
184
|
+
validated. They are not inferred from `openai.codex` identity.
|
|
185
|
+
|
|
186
|
+
`CodexNativeClient` is an explicit escape hatch and can issue methods outside
|
|
187
|
+
the portable lifecycle. Callers own the resulting Provider semantics and must
|
|
188
|
+
not use it to bypass host authorization, Session ownership, or data policy.
|
|
189
|
+
|
|
190
|
+
## Errors, evidence, and limitations
|
|
191
|
+
|
|
192
|
+
Errors contain fixed Harapter messages, stable categories, safe numeric or
|
|
193
|
+
transport codes, Schema-declared Codex error categories, and no Provider message
|
|
194
|
+
bodies, prompts, file contents, credentials, environment values, or local paths.
|
|
195
|
+
Runtime absence is `runtime_not_found`; handshake and method incompatibility is
|
|
196
|
+
`provider_api_incompatible`; request wait expiry is `timeout`; unexpected stream
|
|
197
|
+
or process termination is `connection_aborted` after connect; and an
|
|
198
|
+
operation-local transport rejection on an open connection is `provider_error`.
|
|
199
|
+
|
|
200
|
+
Evidence for the supported interface includes:
|
|
201
|
+
|
|
202
|
+
- the generated stable Schema fingerprint and synthetic JSONL traces in
|
|
203
|
+
[`fixtures/codex/app-server-stable`](../../fixtures/codex/app-server-stable/manifest.json);
|
|
204
|
+
- a synthetic initialize response with the client-selected originator used by
|
|
205
|
+
the official App Server;
|
|
206
|
+
- mapping, malformed-input, redaction, interaction, timeout, cancellation,
|
|
207
|
+
process-exit, ownership, and cleanup tests;
|
|
208
|
+
- the shared portable Provider conformance suite;
|
|
209
|
+
- a local live test against the current Codex release using a read-only,
|
|
210
|
+
resumable Thread that performs no Tool calls, verifies one completed Turn and
|
|
211
|
+
one natively interrupted Turn, and logs no Provider traffic.
|
|
212
|
+
|
|
213
|
+
The live test is opt-in and requires an authenticated Codex installation:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
HARAPTER_CODEX_LIVE=1 \
|
|
217
|
+
HARAPTER_CODEX_COMMAND="$(command -v codex)" \
|
|
218
|
+
pnpm vitest run providers/codex/test/live.test.ts
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The last repository-recorded
|
|
222
|
+
[trusted live canary](https://github.com/yunfeizhu/harapter/actions/runs/33745075649)
|
|
223
|
+
passed on 2026-09-03 with `@openai/codex@0.153.0`. It proved the stable
|
|
224
|
+
handshake, an exact completed text response with `run.completed`,
|
|
225
|
+
same-connection resume of the native non-ephemeral Thread, immediate native
|
|
226
|
+
cancellation with `run.cancelled`, and orderly Session and Client cleanup. The
|
|
227
|
+
canary submitted two synthetic Prompts with no Tool or interaction Event.
|
|
228
|
+
|
|
229
|
+
A production host may pin the recorded release for a reproducible deployment.
|
|
230
|
+
Harapter continues to admit newer stable releases and validates the observed
|
|
231
|
+
handshake, response, Event, and terminal structures instead of using the
|
|
232
|
+
recorded version as an executable allowlist. The run does not establish
|
|
233
|
+
cross-process Thread resume, experimental App Server APIs, image input, approval
|
|
234
|
+
interactions, or Tool execution.
|
|
235
|
+
|
|
236
|
+
The trusted scheduled live-canary workflow can install the current stable Codex
|
|
237
|
+
release on an ephemeral runner and execute the same lifecycle with an isolated
|
|
238
|
+
configuration. It is enabled independently from pull request CI, records the
|
|
239
|
+
installed package version, and requires a configured model service that supports
|
|
240
|
+
the Responses interface used by Codex. Before the job receives the real model
|
|
241
|
+
credential, the current Codex feature inventory must match the reviewed
|
|
242
|
+
tool-disabled surface. The lifecycle requires one exact completed response,
|
|
243
|
+
closes and resumes the same non-ephemeral Thread on the App Server connection,
|
|
244
|
+
then requires native interruption and an authoritative cancelled terminal for a
|
|
245
|
+
second Turn. It fails if a tool or interaction event is observed and stores only
|
|
246
|
+
Event type strings in the test.
|
|
247
|
+
|
|
248
|
+
Experimental App Server APIs, Session fork, paginated history, direct account or
|
|
249
|
+
authentication management, and host-owned process streams are not supported by
|
|
250
|
+
this release.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ProviderAdapterFactory } from '@harapter/core';
|
|
2
|
+
import { type CodexRawEvent } from './protocol.js';
|
|
3
|
+
/** Connection-level limits accepted in a Codex Profile's providerOptions. */
|
|
4
|
+
export interface CodexProfileOptions {
|
|
5
|
+
readonly cancelSettlementTimeoutMs?: number;
|
|
6
|
+
readonly maxBufferedMessages?: number;
|
|
7
|
+
readonly maxMessageBytes?: number;
|
|
8
|
+
readonly maxPendingInboundRequests?: number;
|
|
9
|
+
readonly maxPendingRequests?: number;
|
|
10
|
+
readonly maxPendingWrites?: number;
|
|
11
|
+
readonly maxRunEvents?: number;
|
|
12
|
+
readonly requestTimeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Request options for explicit Provider-native App Server calls. */
|
|
15
|
+
export interface CodexNativeRequestOptions {
|
|
16
|
+
readonly signal?: AbortSignal;
|
|
17
|
+
readonly timeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Explicit Provider-native escape hatch for initialized App Server traffic. */
|
|
20
|
+
export interface CodexNativeClient {
|
|
21
|
+
readonly runtimeIdentity: string;
|
|
22
|
+
request<TResult = unknown>(method: string, params?: unknown, options?: CodexNativeRequestOptions): Promise<TResult>;
|
|
23
|
+
notify(method: string, params?: unknown): Promise<void>;
|
|
24
|
+
onUnknownEvent(listener: (event: CodexRawEvent) => void): () => void;
|
|
25
|
+
}
|
|
26
|
+
/** Create a fresh Codex App Server Adapter factory. */
|
|
27
|
+
export declare function createCodexProviderFactory(): ProviderAdapterFactory;
|
|
28
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAmBL,KAAK,sBAAsB,EAQ5B,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAcL,KAAK,aAAa,EAGnB,MAAM,eAAe,CAAC;AAcvB,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,qEAAqE;AACrE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,OAAO,CAAC,OAAO,GAAG,OAAO,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACtE;AAyBD,uDAAuD;AACvD,wBAAgB,0BAA0B,IAAI,sBAAsB,CAQnE"}
|