@makaio/adapter-codex-app-server 1.0.0-dev-1779051654000
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 +21 -0
- package/README.md +311 -0
- package/descriptor.json +27 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/index.d.mts +5565 -0
- package/dist/index.mjs +3787 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Makaio GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# @makaio/adapter-codex-app-server
|
|
2
|
+
|
|
3
|
+
OpenAI Codex App-Server adapter for the Makaio AI framework.
|
|
4
|
+
|
|
5
|
+
Communicates with `codex app-server` via stdio subprocess using JSON-RPC 2.0 over JSONL.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {
|
|
11
|
+
CodexAppServerAdapter,
|
|
12
|
+
createCodexAppServerAdapter,
|
|
13
|
+
} from '@makaio/adapter-codex-app-server';
|
|
14
|
+
import { MakaioBus } from '@makaio/bus-core';
|
|
15
|
+
import { AdapterSubjects } from '@makaio/contracts';
|
|
16
|
+
|
|
17
|
+
// Using the factory function (recommended)
|
|
18
|
+
const adapter = await createCodexAppServerAdapter();
|
|
19
|
+
|
|
20
|
+
const result = await MakaioBus.request(AdapterSubjects.startAgent, {
|
|
21
|
+
adapterId: adapter.adapterId,
|
|
22
|
+
role: 'lead',
|
|
23
|
+
cwd: process.cwd(),
|
|
24
|
+
initialMessage: 'Inspect this repository',
|
|
25
|
+
model: 'gpt-5.1-codex-mini',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Or using the class directly
|
|
29
|
+
const directAdapter = new CodexAppServerAdapter();
|
|
30
|
+
await directAdapter.init();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Architecture
|
|
34
|
+
|
|
35
|
+
This adapter follows the three-layer architecture pattern:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
CodexAppServerAdapter extends AIAdapter
|
|
39
|
+
-> creates via agentFactory()
|
|
40
|
+
CodexAppServerAgent extends AIAgent
|
|
41
|
+
-> receives connector via connectorFactory()
|
|
42
|
+
CodexAppServerConnector extends AIAgentConnector
|
|
43
|
+
-> JsonRpcClient
|
|
44
|
+
-> StdioTransport
|
|
45
|
+
-> [codex app-server subprocess]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Layers:**
|
|
49
|
+
|
|
50
|
+
| Layer | Class | Responsibility |
|
|
51
|
+
|-------|-------|----------------|
|
|
52
|
+
| Adapter | `CodexAppServerAdapter` | Factory for agents, handles `adapter.startAgent` RPC |
|
|
53
|
+
| Agent | `CodexAppServerAgent` | Wires events to global bus, manages lifecycle |
|
|
54
|
+
| Connector | `CodexAppServerConnector` | JSON-RPC bridge to codex app-server subprocess |
|
|
55
|
+
|
|
56
|
+
**Thread/Turn Management:**
|
|
57
|
+
|
|
58
|
+
| Class | Purpose |
|
|
59
|
+
|-------|---------|
|
|
60
|
+
| `CodexAppServerThread` | Thread lifecycle management |
|
|
61
|
+
| `CodexAppServerTurn` | Individual turn handling |
|
|
62
|
+
| `UserMessageQueue` | Internal connector queue from adapter core |
|
|
63
|
+
|
|
64
|
+
## Capabilities
|
|
65
|
+
|
|
66
|
+
- `tools` - Tool/function calling support (bash, patch)
|
|
67
|
+
- `streaming` - Streaming responses
|
|
68
|
+
- `systemPrompt:override` - Replace/set the system prompt
|
|
69
|
+
- `systemPrompt:append` - Append to the adapter's default system prompt
|
|
70
|
+
- Tool approval workflow via agent wiring to `AgentSubjects.toolApprove`
|
|
71
|
+
- File change approval workflow
|
|
72
|
+
- Replace and interrupt delivery modes
|
|
73
|
+
- Reasoning support with configurable effort levels
|
|
74
|
+
|
|
75
|
+
## Exports
|
|
76
|
+
|
|
77
|
+
### Adapter
|
|
78
|
+
|
|
79
|
+
| Export | Description |
|
|
80
|
+
|--------|-------------|
|
|
81
|
+
| `CodexAppServerAdapter` | Main adapter class |
|
|
82
|
+
| `createCodexAppServerAdapter` | Factory function (creates and initializes) |
|
|
83
|
+
| `CodexAppServerAdapterName` | Adapter identifier constant |
|
|
84
|
+
|
|
85
|
+
### Agent & Connector
|
|
86
|
+
|
|
87
|
+
| Export | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| `CodexAppServerAgent` | Agent class (middle layer) |
|
|
90
|
+
| `CodexAppServerConnector` | Connector class (JSON-RPC bridge) |
|
|
91
|
+
|
|
92
|
+
### Thread Management
|
|
93
|
+
|
|
94
|
+
| Export | Description |
|
|
95
|
+
|--------|-------------|
|
|
96
|
+
| `CodexAppServerThread` | Thread abstraction |
|
|
97
|
+
| `CodexAppServerTurn` | Turn abstraction |
|
|
98
|
+
|
|
99
|
+
### Namespaces & Types
|
|
100
|
+
|
|
101
|
+
| Export | Description |
|
|
102
|
+
|--------|-------------|
|
|
103
|
+
| `CodexAppServerNamespace` | Bus namespace for connector events |
|
|
104
|
+
| `CodexAppServerSubjects` | Subject constants for bus messaging |
|
|
105
|
+
| `CodexAppServerBus` | Typed bus type |
|
|
106
|
+
|
|
107
|
+
### Tool Handling
|
|
108
|
+
|
|
109
|
+
| Export | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `registerToolApprovalHandler` | Register handler for tool approval requests |
|
|
112
|
+
| `toGlobalToolApproval` | Convert to global tool approval format |
|
|
113
|
+
| `toGlobalFileApproval` | Convert to global file approval format |
|
|
114
|
+
| `fromGlobalToolApproval` | Convert from global approval format |
|
|
115
|
+
| `ToolApprovalContext` | Tool approval context type |
|
|
116
|
+
| `CodexToolApprovalDecision` | Approval decision type |
|
|
117
|
+
|
|
118
|
+
### Configuration & Schemas
|
|
119
|
+
|
|
120
|
+
| Export | Description |
|
|
121
|
+
|--------|-------------|
|
|
122
|
+
| `CodexAppServerProviderConfigSchema` | Zod schema for provider config |
|
|
123
|
+
| `CodexAppServerProviderConfig` | Provider config type |
|
|
124
|
+
| `CodexAppServerConfig` | Config factory |
|
|
125
|
+
|
|
126
|
+
### Runtime Contribution
|
|
127
|
+
|
|
128
|
+
Runtime registration is contributed by `@makaio/adapter-codex-app-server/server`.
|
|
129
|
+
That entrypoint default-exports the `codexAppServerPackage` `MakaioExtension`
|
|
130
|
+
descriptor, whose `adapters[]` entry wraps the internal definition from
|
|
131
|
+
`src/definition.ts`.
|
|
132
|
+
|
|
133
|
+
### Utilities
|
|
134
|
+
|
|
135
|
+
| Export | Description |
|
|
136
|
+
|--------|-------------|
|
|
137
|
+
| `createStdioTransport` | Create stdio transport for subprocess |
|
|
138
|
+
| `createJsonRpcClient` | Create JSON-RPC client |
|
|
139
|
+
|
|
140
|
+
### Protocol Types
|
|
141
|
+
|
|
142
|
+
| Export | Description |
|
|
143
|
+
|--------|-------------|
|
|
144
|
+
| `ThreadStartedNotification` | Thread started event |
|
|
145
|
+
| `TurnStartedNotification` | Turn started event |
|
|
146
|
+
| `TurnCompletedNotification` | Turn completed event |
|
|
147
|
+
| `AgentMessageDeltaNotification` | Agent message delta event |
|
|
148
|
+
| `CommandExecutionOutputDeltaNotification` | Command output event |
|
|
149
|
+
| `ReasoningTextDeltaNotification` | Reasoning delta event |
|
|
150
|
+
| `FileChangeOutputDeltaNotification` | File change delta event |
|
|
151
|
+
| `ThreadTokenUsageUpdatedNotification` | Token usage event |
|
|
152
|
+
|
|
153
|
+
## Configuration Options
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
interface CodexAppServerProviderConfig {
|
|
157
|
+
/**
|
|
158
|
+
* Reasoning effort level.
|
|
159
|
+
* Maps to ReasoningEffort in app-server protocol.
|
|
160
|
+
*/
|
|
161
|
+
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Approval policy for tool execution.
|
|
165
|
+
* Maps to AskForApproval in app-server protocol.
|
|
166
|
+
*/
|
|
167
|
+
approvalPolicy?: 'untrusted' | 'on-failure' | 'on-request' | 'never';
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Sandbox mode for command execution.
|
|
171
|
+
*/
|
|
172
|
+
sandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`cwd`, `model`, and `env` are runtime/adapter options supplied on
|
|
177
|
+
`adapter.startAgent`, not provider config fields. Hosts should resolve the selected
|
|
178
|
+
provider/model before calling `startAgent` and pass that model explicitly. The current
|
|
179
|
+
adapter fallback is `gpt-5.1-codex-mini` for low-level tests and direct construction paths.
|
|
180
|
+
|
|
181
|
+
## Prerequisites
|
|
182
|
+
|
|
183
|
+
This adapter requires a Codex CLI build with `app-server` support.
|
|
184
|
+
|
|
185
|
+
### Installation
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Install Codex by the distribution method supported by your host.
|
|
189
|
+
# The adapter supports:
|
|
190
|
+
# - a host-managed absolute binary path
|
|
191
|
+
# - PATH lookup for `codex`
|
|
192
|
+
# - test/fetcher paths that spawn `codex app-server` directly
|
|
193
|
+
|
|
194
|
+
# Verify installation
|
|
195
|
+
codex --version
|
|
196
|
+
codex app-server --help
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Configuration
|
|
200
|
+
|
|
201
|
+
The adapter will spawn `codex app-server` as a subprocess via stdio. Ensure:
|
|
202
|
+
- The `codex` binary is host-resolved or available in PATH
|
|
203
|
+
- You have appropriate permissions for the working directory
|
|
204
|
+
|
|
205
|
+
## Protocol Methods
|
|
206
|
+
|
|
207
|
+
The adapter communicates with `codex app-server` using JSON-RPC 2.0 over JSONL:
|
|
208
|
+
|
|
209
|
+
The package exports generated protocol types from `src/protocol/generated/index.ts`. Prefer the
|
|
210
|
+
`v2` namespace for app-server protocol types when importing generated definitions.
|
|
211
|
+
|
|
212
|
+
### Client Requests
|
|
213
|
+
|
|
214
|
+
- `initialize` - Initialize connection handshake
|
|
215
|
+
- `thread/start` - Start new conversation thread (v2)
|
|
216
|
+
- `turn/start` - Send user message to agent (v2)
|
|
217
|
+
- `turn/interrupt` - Cancel current turn (v2)
|
|
218
|
+
- `model/list` - Fetch available Codex models
|
|
219
|
+
|
|
220
|
+
### Client Notifications
|
|
221
|
+
|
|
222
|
+
- `initialized` - Acknowledge successful initialization
|
|
223
|
+
|
|
224
|
+
### Server Notifications (Events)
|
|
225
|
+
|
|
226
|
+
- `thread/started` - Thread created
|
|
227
|
+
- `turn/started` - Agent begins processing turn
|
|
228
|
+
- `turn/completed` - Agent finished turn
|
|
229
|
+
- `item/started` - Item (message/tool/reasoning) started
|
|
230
|
+
- `item/completed` - Item completed
|
|
231
|
+
- `item/agentMessage/delta` - Streaming message content
|
|
232
|
+
- `item/commandExecution/outputDelta` - Streaming command output
|
|
233
|
+
- `item/reasoning/textDelta` - Streaming reasoning content
|
|
234
|
+
- `item/fileChange/outputDelta` - Streaming file change output
|
|
235
|
+
- `thread/tokenUsage/updated` - Token usage metrics
|
|
236
|
+
|
|
237
|
+
### Server Requests
|
|
238
|
+
|
|
239
|
+
- `item/commandExecution/requestApproval` - Request approval for command execution
|
|
240
|
+
- `item/fileChange/requestApproval` - Request approval for file changes
|
|
241
|
+
|
|
242
|
+
## Troubleshooting
|
|
243
|
+
|
|
244
|
+
### Subprocess fails to start
|
|
245
|
+
|
|
246
|
+
**Error:** `codex app-server exited with code 1`
|
|
247
|
+
|
|
248
|
+
**Solution:**
|
|
249
|
+
- Verify `codex` CLI is installed: `codex --version`
|
|
250
|
+
- Check the working directory is accessible
|
|
251
|
+
- Review stderr logs for subprocess errors
|
|
252
|
+
|
|
253
|
+
### JSONL parsing errors
|
|
254
|
+
|
|
255
|
+
**Error:** `Failed to parse JSONL`
|
|
256
|
+
|
|
257
|
+
**Solution:**
|
|
258
|
+
- This may indicate a protocol mismatch
|
|
259
|
+
- Ensure you're using the correct version of `codex`
|
|
260
|
+
- Check the subprocess logs for protocol errors
|
|
261
|
+
|
|
262
|
+
### Approval handling issues
|
|
263
|
+
|
|
264
|
+
**Error:** Tool approval timeout
|
|
265
|
+
|
|
266
|
+
**Solution:**
|
|
267
|
+
- Increase timeout in config
|
|
268
|
+
- Ensure the host has an `AgentSubjects.toolApprove` handler registered
|
|
269
|
+
- Check that the agent is initialized so its scoped approval wiring is active
|
|
270
|
+
|
|
271
|
+
### Connection issues
|
|
272
|
+
|
|
273
|
+
**Error:** `Failed to initialize connection`
|
|
274
|
+
|
|
275
|
+
**Solution:**
|
|
276
|
+
- Verify stdio transport is working
|
|
277
|
+
- Check that `codex app-server` is responding
|
|
278
|
+
- Ensure JSON-RPC handshake completes
|
|
279
|
+
|
|
280
|
+
## File Structure
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
src/
|
|
284
|
+
├── index.ts # Package exports
|
|
285
|
+
├── adapter.ts # CodexAppServerAdapter class
|
|
286
|
+
├── agent.ts # CodexAppServerAgent class
|
|
287
|
+
├── connector.ts # CodexAppServerConnector class
|
|
288
|
+
├── thread.ts # Thread management
|
|
289
|
+
├── turn.ts # Turn management
|
|
290
|
+
├── config.ts # Configuration utilities
|
|
291
|
+
├── constants.ts # Adapter constants
|
|
292
|
+
├── definition.ts # Internal adapter definition
|
|
293
|
+
├── package.ts # MakaioExtension package descriptor
|
|
294
|
+
├── server.ts # Server entrypoint exporting the package descriptor
|
|
295
|
+
├── provider.ts # Provider registration
|
|
296
|
+
├── provider.fetcher.ts # Codex model/list fetcher
|
|
297
|
+
├── schemas.ts # Zod schemas
|
|
298
|
+
├── tool-handling.ts # Tool approval utilities
|
|
299
|
+
├── dynamic-tool-handling.ts # Registry tool declaration and routing
|
|
300
|
+
├── event-normalizers.ts # Event normalization
|
|
301
|
+
├── connector/ # JSON-RPC connection, lifecycle, and approval handlers
|
|
302
|
+
├── namespaces/ # Bus namespace definitions
|
|
303
|
+
│ ├── index.ts # Namespace export
|
|
304
|
+
│ └── schemas/ # Message schemas
|
|
305
|
+
├── protocol/generated/ # Generated protocol types
|
|
306
|
+
│ ├── index.ts # Protocol exports
|
|
307
|
+
│ └── v2/ # V2 protocol definitions
|
|
308
|
+
└── utils/ # Utility functions
|
|
309
|
+
├── createStdioTransport.ts
|
|
310
|
+
└── jsonRpcClient.ts
|
|
311
|
+
```
|
package/descriptor.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-app-server",
|
|
3
|
+
"displayName": "Codex App-Server",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"makaio": {
|
|
6
|
+
"framework": ">=0.1.0"
|
|
7
|
+
},
|
|
8
|
+
"entrypoints": {
|
|
9
|
+
"server": true
|
|
10
|
+
},
|
|
11
|
+
"contributions": {
|
|
12
|
+
"adapters": [
|
|
13
|
+
{
|
|
14
|
+
"name": "codex-app-server",
|
|
15
|
+
"displayName": "Codex App-Server",
|
|
16
|
+
"description": "Direct integration with codex app-server via stdio subprocess using JSON-RPC 2.0 over JSONL",
|
|
17
|
+
"clients": [
|
|
18
|
+
{
|
|
19
|
+
"id": "codex",
|
|
20
|
+
"version": "^0.1.0"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"protocols": ["openai"]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|