@codex-app-sdk/backend 0.13.0 → 0.14.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.
- package/dist/chunks/{codex-BT2Vtjs1.js → codex-DzX6RrF2.js} +59 -43
- package/dist/chunks/codex-DzX6RrF2.js.map +1 -0
- package/dist/codex/client.d.ts +7 -0
- package/dist/codex/client.d.ts.map +1 -1
- package/dist/codex/listener-errors.d.ts +10 -0
- package/dist/codex/listener-errors.d.ts.map +1 -0
- package/dist/index.js +1163 -991
- package/dist/index.js.map +1 -1
- package/dist/node/codex-conversation-history.d.ts.map +1 -1
- package/dist/node/codex-executable.d.ts +26 -0
- package/dist/node/codex-executable.d.ts.map +1 -1
- package/dist/node/codex-file-attachment.d.ts +7 -0
- package/dist/node/codex-file-attachment.d.ts.map +1 -0
- package/dist/node/codex-stdio-transport.d.ts +3 -0
- package/dist/node/codex-stdio-transport.d.ts.map +1 -1
- package/dist/node/codex-surface-contracts.d.ts +7 -0
- package/dist/node/codex-surface-contracts.d.ts.map +1 -1
- package/dist/node/codex-surface-conversations-controller.d.ts.map +1 -1
- package/dist/node/codex-surface-data.d.ts +7 -0
- package/dist/node/codex-surface-data.d.ts.map +1 -1
- package/dist/node/codex-surface-items-controller.d.ts.map +1 -1
- package/dist/node/codex-surface-notifications-controller.d.ts +1 -0
- package/dist/node/codex-surface-notifications-controller.d.ts.map +1 -1
- package/dist/node/codex-surface-runtime-controller.d.ts.map +1 -1
- package/dist/node/codex-surface.d.ts +12 -1
- package/dist/node/codex-surface.d.ts.map +1 -1
- package/dist/node/codex-unix-socket-transport.d.ts.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/codex-BT2Vtjs1.js.map +0 -1
|
@@ -1,31 +1,49 @@
|
|
|
1
|
+
//#region src/codex/listener-errors.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (t) {
|
|
4
|
+
try {
|
|
5
|
+
t(e);
|
|
6
|
+
} catch {}
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
process.emitWarning(e instanceof Error ? e : Error(String(e)));
|
|
10
|
+
}
|
|
11
|
+
function t(t, n, r) {
|
|
12
|
+
for (let i of t) try {
|
|
13
|
+
i(n);
|
|
14
|
+
} catch (t) {
|
|
15
|
+
e(t, r);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
1
19
|
//#region src/codex/wire.ts
|
|
2
|
-
var
|
|
20
|
+
var n = class extends Error {
|
|
3
21
|
requestId;
|
|
4
22
|
constructor(e, t) {
|
|
5
23
|
super(e, t), this.name = "RpcTransportProtocolError", this.requestId = t?.requestId;
|
|
6
24
|
}
|
|
7
|
-
},
|
|
25
|
+
}, r = class extends Error {
|
|
8
26
|
code;
|
|
9
27
|
data;
|
|
10
28
|
constructor(e) {
|
|
11
29
|
super(e.message), this.name = "RpcRemoteError", this.code = e.code, this.data = e.data;
|
|
12
30
|
}
|
|
13
31
|
};
|
|
14
|
-
function
|
|
15
|
-
return
|
|
32
|
+
function i(e) {
|
|
33
|
+
return a(e) ? typeof e.code == "number" && typeof e.message == "string" : !1;
|
|
16
34
|
}
|
|
17
|
-
function
|
|
35
|
+
function a(e) {
|
|
18
36
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
19
37
|
}
|
|
20
38
|
//#endregion
|
|
21
39
|
//#region src/codex/client.ts
|
|
22
|
-
var
|
|
23
|
-
"thread/revert":
|
|
24
|
-
"thread/rollback":
|
|
25
|
-
},
|
|
40
|
+
var o = 15e3, s = 12e4, c = {
|
|
41
|
+
"thread/revert": s,
|
|
42
|
+
"thread/rollback": s
|
|
43
|
+
}, l = (e) => ({
|
|
26
44
|
code: -32601,
|
|
27
45
|
message: `Codex app-server request is not implemented: ${e.method}`
|
|
28
|
-
}),
|
|
46
|
+
}), u = class {
|
|
29
47
|
transport;
|
|
30
48
|
options;
|
|
31
49
|
nextId = 1;
|
|
@@ -66,24 +84,24 @@ var i = 15e3, a = 12e4, o = {
|
|
|
66
84
|
id: n,
|
|
67
85
|
method: e,
|
|
68
86
|
params: t
|
|
69
|
-
},
|
|
70
|
-
let
|
|
87
|
+
}, i = new Promise((t, r) => {
|
|
88
|
+
let i = setTimeout(() => {
|
|
71
89
|
this.pending.delete(n), r(/* @__PURE__ */ Error(`Codex app-server request timed out: ${e}`));
|
|
72
|
-
}, this.options.requestTimeoutMs ??
|
|
90
|
+
}, this.options.requestTimeoutMs ?? c[e] ?? o);
|
|
73
91
|
this.pending.set(n, {
|
|
74
92
|
method: e,
|
|
75
93
|
resolve: (e) => t(e),
|
|
76
94
|
reject: r,
|
|
77
|
-
timeout:
|
|
95
|
+
timeout: i
|
|
78
96
|
});
|
|
79
97
|
});
|
|
80
98
|
try {
|
|
81
99
|
this.transport.send(r);
|
|
82
100
|
} catch (e) {
|
|
83
101
|
let t = this.pending.get(n);
|
|
84
|
-
t && (clearTimeout(t.timeout), this.pending.delete(n), t.reject(
|
|
102
|
+
t && (clearTimeout(t.timeout), this.pending.delete(n), t.reject(p(e)));
|
|
85
103
|
}
|
|
86
|
-
return
|
|
104
|
+
return i;
|
|
87
105
|
}
|
|
88
106
|
notify(e, ...[t]) {
|
|
89
107
|
this.assertStarted(), this.transport.send(t === void 0 ? { method: e } : {
|
|
@@ -120,11 +138,11 @@ var i = 15e3, a = 12e4, o = {
|
|
|
120
138
|
this.unsubscribeMessage?.(), this.unsubscribeError?.(), this.unsubscribeMessage = void 0, this.unsubscribeError = void 0;
|
|
121
139
|
}
|
|
122
140
|
handleMessage(e) {
|
|
123
|
-
if (!
|
|
141
|
+
if (!a(e)) {
|
|
124
142
|
this.reportProtocolError(/* @__PURE__ */ Error("Codex app-server sent a non-object message"));
|
|
125
143
|
return;
|
|
126
144
|
}
|
|
127
|
-
let t =
|
|
145
|
+
let t = f(e.id) ? e.id : void 0;
|
|
128
146
|
if (t !== void 0 && ("result" in e || "error" in e) && typeof e.method != "string") {
|
|
129
147
|
this.handleResponse(t, e);
|
|
130
148
|
return;
|
|
@@ -143,19 +161,18 @@ var i = 15e3, a = 12e4, o = {
|
|
|
143
161
|
}
|
|
144
162
|
this.reportProtocolError(/* @__PURE__ */ Error("Codex app-server sent an invalid RPC message"));
|
|
145
163
|
}
|
|
146
|
-
handleResponse(e,
|
|
147
|
-
let
|
|
148
|
-
if (
|
|
149
|
-
if (clearTimeout(
|
|
150
|
-
|
|
164
|
+
handleResponse(e, t) {
|
|
165
|
+
let n = this.pending.get(e);
|
|
166
|
+
if (n) {
|
|
167
|
+
if (clearTimeout(n.timeout), this.pending.delete(e), "error" in t) {
|
|
168
|
+
i(t.error) ? n.reject(new r(t.error)) : n.reject(/* @__PURE__ */ Error(`Codex app-server returned a malformed error for ${n.method}`));
|
|
151
169
|
return;
|
|
152
170
|
}
|
|
153
|
-
|
|
171
|
+
n.resolve(t.result);
|
|
154
172
|
}
|
|
155
173
|
}
|
|
156
174
|
handleNotification(e) {
|
|
157
|
-
|
|
158
|
-
for (let t of this.notificationListenersByMethod.get(e.method) ?? []) t(e);
|
|
175
|
+
t(this.notificationListeners, e, this.options.onListenerError), t(this.notificationListenersByMethod.get(e.method) ?? [], e, this.options.onListenerError);
|
|
159
176
|
}
|
|
160
177
|
async handleServerRequest(e) {
|
|
161
178
|
let t = this.createResponder(e.id), n = [...this.serverRequestHandlers.get(e.method) ?? [], ...this.anyServerRequestHandlers];
|
|
@@ -164,11 +181,11 @@ var i = 15e3, a = 12e4, o = {
|
|
|
164
181
|
} catch (e) {
|
|
165
182
|
t.reject({
|
|
166
183
|
code: -32603,
|
|
167
|
-
message:
|
|
184
|
+
message: p(e).message
|
|
168
185
|
});
|
|
169
186
|
return;
|
|
170
187
|
}
|
|
171
|
-
t.reject((this.options.unhandledServerRequestError ??
|
|
188
|
+
t.reject((this.options.unhandledServerRequestError ?? l)(e));
|
|
172
189
|
}
|
|
173
190
|
createResponder(e) {
|
|
174
191
|
let t = !1;
|
|
@@ -185,7 +202,7 @@ var i = 15e3, a = 12e4, o = {
|
|
|
185
202
|
reject: (n) => {
|
|
186
203
|
t || (t = !0, this.transport.send({
|
|
187
204
|
id: e,
|
|
188
|
-
error:
|
|
205
|
+
error: d(n)
|
|
189
206
|
}));
|
|
190
207
|
}
|
|
191
208
|
};
|
|
@@ -194,22 +211,21 @@ var i = 15e3, a = 12e4, o = {
|
|
|
194
211
|
for (let t of this.pending.values()) clearTimeout(t.timeout), t.reject(e);
|
|
195
212
|
this.pending.clear();
|
|
196
213
|
}
|
|
197
|
-
handleTransportError(
|
|
198
|
-
if (
|
|
199
|
-
if (this.reportProtocolError(
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
} else this.rejectAll(
|
|
214
|
+
handleTransportError(e) {
|
|
215
|
+
if (e instanceof n) {
|
|
216
|
+
if (this.reportProtocolError(e), e.requestId !== void 0) {
|
|
217
|
+
let t = this.pending.get(e.requestId);
|
|
218
|
+
t && (clearTimeout(t.timeout), this.pending.delete(e.requestId), t.reject(e));
|
|
219
|
+
} else this.rejectAll(e);
|
|
203
220
|
return;
|
|
204
221
|
}
|
|
205
|
-
this.started = !1, this.initializePromise = null, this.unsubscribeTransport(), this.rejectAll(t);
|
|
206
|
-
for (let e of this.disconnectListeners) e(t);
|
|
222
|
+
this.started = !1, this.initializePromise = null, this.unsubscribeTransport(), this.rejectAll(e), t(this.disconnectListeners, e, this.options.onListenerError);
|
|
207
223
|
}
|
|
208
224
|
reportProtocolError(e) {
|
|
209
225
|
this.options.onProtocolError?.(e);
|
|
210
226
|
}
|
|
211
227
|
};
|
|
212
|
-
function
|
|
228
|
+
function d(e) {
|
|
213
229
|
return typeof e == "string" ? {
|
|
214
230
|
code: -32603,
|
|
215
231
|
message: e
|
|
@@ -218,16 +234,16 @@ function l(e) {
|
|
|
218
234
|
message: e.message
|
|
219
235
|
} : e;
|
|
220
236
|
}
|
|
221
|
-
function
|
|
237
|
+
function f(e) {
|
|
222
238
|
return typeof e == "number" || typeof e == "string";
|
|
223
239
|
}
|
|
224
|
-
function
|
|
240
|
+
function p(e) {
|
|
225
241
|
return e instanceof Error ? e : Error(String(e));
|
|
226
242
|
}
|
|
227
243
|
//#endregion
|
|
228
244
|
//#region src/codex/schema-version.ts
|
|
229
|
-
var
|
|
245
|
+
var m = "codex-cli 0.154.0";
|
|
230
246
|
//#endregion
|
|
231
|
-
export {
|
|
247
|
+
export { a, n as i, u as n, i as o, r, t as s, m as t };
|
|
232
248
|
|
|
233
|
-
//# sourceMappingURL=codex-
|
|
249
|
+
//# sourceMappingURL=codex-DzX6RrF2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-DzX6RrF2.js","names":[],"sources":["../../src/codex/listener-errors.ts","../../src/codex/wire.ts","../../src/codex/client.ts","../../src/codex/schema-version.ts"],"sourcesContent":["export type ListenerErrorHandler = (error: unknown) => void;\n\n/**\n * Reports an exception thrown by a subscriber without letting it disturb the\n * code that notified it. The host's handler receives it; without one it\n * surfaces as a process warning, so it is neither swallowed nor fatal.\n */\nexport function reportListenerError(error: unknown, handler?: ListenerErrorHandler): void {\n if (handler) {\n try {\n handler(error);\n } catch {\n // A failing error handler must not escape into the notifier either.\n }\n return;\n }\n process.emitWarning(error instanceof Error ? error : new Error(String(error)));\n}\n\n/** Calls every listener, isolating each from the others' failures. */\nexport function notifyListeners<Value>(\n listeners: Iterable<(value: Value) => void>,\n value: Value,\n onError?: ListenerErrorHandler,\n): void {\n for (const listener of listeners) {\n try {\n listener(value);\n } catch (error) {\n reportListenerError(error, onError);\n }\n }\n}\n","export type RpcId = number | string;\n\nexport type RpcError = {\n code: number;\n message: string;\n data?: unknown;\n};\n\nexport type RpcRequest = {\n id: RpcId;\n method: string;\n params?: unknown;\n};\n\nexport type RpcNotification = {\n method: string;\n params?: unknown;\n};\n\nexport type RpcSuccessResponse = {\n id: RpcId;\n result: unknown;\n};\n\nexport type RpcErrorResponse = {\n id: RpcId;\n error: RpcError;\n};\n\nexport type RpcMessage =\n | RpcRequest\n | RpcNotification\n | RpcSuccessResponse\n | RpcErrorResponse;\n\nexport interface RpcTransport {\n start(): Promise<void>;\n send(message: RpcMessage): void;\n close(): Promise<void>;\n onMessage(listener: (message: unknown) => void): () => void;\n onError(listener: (error: Error) => void): () => void;\n}\n\n/** A malformed transport frame that does not imply the connection was lost. */\nexport class RpcTransportProtocolError extends Error {\n readonly requestId?: RpcId;\n\n constructor(message: string, options?: ErrorOptions & { requestId?: RpcId }) {\n super(message, options);\n this.name = 'RpcTransportProtocolError';\n this.requestId = options?.requestId;\n }\n}\n\nexport class RpcRemoteError extends Error {\n readonly code: number;\n readonly data?: unknown;\n\n constructor(error: RpcError) {\n super(error.message);\n this.name = 'RpcRemoteError';\n this.code = error.code;\n this.data = error.data;\n }\n}\n\nexport function isRpcError(value: unknown): value is RpcError {\n if (!isRecord(value)) {\n return false;\n }\n\n return typeof value.code === 'number' && typeof value.message === 'string';\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import type { ClientNotification } from './generated/ClientNotification';\nimport type { InitializeParams } from './generated/InitializeParams';\nimport type { InitializeResponse } from './generated/InitializeResponse';\nimport type { ServerNotification } from './generated/ServerNotification';\nimport type { ServerRequest } from './generated/ServerRequest';\nimport type { CodexAppServerMethodMap } from './method-map';\nimport type { CodexServerRequestMethodMap } from './server-request-map';\nimport { notifyListeners, type ListenerErrorHandler } from './listener-errors';\nimport {\n isRecord,\n isRpcError,\n RpcRemoteError,\n RpcTransportProtocolError,\n type RpcError,\n type RpcId,\n type RpcMessage,\n type RpcTransport,\n} from './wire';\n\ntype MethodName = keyof CodexAppServerMethodMap & string;\ntype MethodParams<Method extends MethodName> = CodexAppServerMethodMap[Method]['params'];\ntype MethodResult<Method extends MethodName> = CodexAppServerMethodMap[Method]['result'];\ntype MethodArguments<Params> = undefined extends Params ? [params?: Params] : [params: Params];\n\ntype ClientNotificationMethod = ClientNotification['method'];\ntype ClientNotificationFor<Method extends ClientNotificationMethod> = Extract<ClientNotification, { method: Method }>;\ntype ClientNotificationParams<Method extends ClientNotificationMethod> = ClientNotificationFor<Method> extends { params: infer Params }\n ? Params\n : undefined;\n\ntype ServerNotificationMethod = ServerNotification['method'];\ntype ServerNotificationFor<Method extends ServerNotificationMethod> = Extract<ServerNotification, { method: Method }>;\n\ntype ServerRequestMethod = keyof CodexServerRequestMethodMap & string;\ntype ServerRequestFor<Method extends ServerRequestMethod> = Extract<ServerRequest, { method: Method }>;\ntype ServerRequestResult<Method extends ServerRequestMethod> = CodexServerRequestMethodMap[Method]['result'];\n\ntype PendingRequest = {\n method: string;\n resolve(result: unknown): void;\n reject(error: Error): void;\n timeout: ReturnType<typeof setTimeout>;\n};\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 15_000;\nconst LONG_MUTATION_REQUEST_TIMEOUT_MS = 120_000;\nconst requestTimeoutByMethod: Partial<Record<MethodName, number>> = {\n 'thread/revert': LONG_MUTATION_REQUEST_TIMEOUT_MS,\n 'thread/rollback': LONG_MUTATION_REQUEST_TIMEOUT_MS,\n};\n\nexport type CodexServerRequestResponder<Method extends ServerRequestMethod> = {\n readonly responded: boolean;\n resolve(result: ServerRequestResult<Method>): void;\n reject(error: Error | RpcError | string): void;\n};\n\nexport type UntypedCodexServerRequestResponder = {\n readonly responded: boolean;\n resolve(result: unknown): void;\n reject(error: Error | RpcError | string): void;\n};\n\nexport type CodexAppServerClientOptions = {\n requestTimeoutMs?: number;\n onProtocolError?: (error: Error) => void;\n /**\n * Receives exceptions thrown by notification and disconnect listeners. Each\n * listener is isolated, so one failing subscriber never disturbs the others\n * or fails in-flight requests. Defaults to a process warning.\n */\n onListenerError?: ListenerErrorHandler;\n unhandledServerRequestError?: (request: { id: RpcId; method: string; params?: unknown }) => RpcError;\n};\n\ntype AnyServerRequestHandler = (\n request: ServerRequest,\n responder: UntypedCodexServerRequestResponder,\n) => boolean | void | Promise<boolean | void>;\n\nconst defaultUnhandledRequestError = (request: { method: string }): RpcError => ({\n code: -32601,\n message: `Codex app-server request is not implemented: ${request.method}`,\n});\n\nexport class CodexAppServerClient {\n private nextId = 1;\n private started = false;\n private initializePromise: Promise<InitializeResponse> | null = null;\n private readonly pending = new Map<RpcId, PendingRequest>();\n private readonly notificationListeners = new Set<(notification: ServerNotification) => void>();\n private readonly notificationListenersByMethod = new Map<string, Set<(notification: ServerNotification) => void>>();\n private readonly serverRequestHandlers = new Map<string, Set<AnyServerRequestHandler>>();\n private readonly anyServerRequestHandlers = new Set<AnyServerRequestHandler>();\n private readonly disconnectListeners = new Set<(error: Error) => void>();\n private unsubscribeMessage?: () => void;\n private unsubscribeError?: () => void;\n\n constructor(\n private readonly transport: RpcTransport,\n private readonly options: CodexAppServerClientOptions = {},\n ) {}\n\n async start(): Promise<void> {\n if (this.started) {\n return;\n }\n\n this.unsubscribeMessage = this.transport.onMessage((message) => this.handleMessage(message));\n this.unsubscribeError = this.transport.onError((error) => this.handleTransportError(error));\n\n try {\n await this.transport.start();\n this.started = true;\n } catch (error) {\n this.unsubscribeTransport();\n throw error;\n }\n }\n\n initialize(params: InitializeParams): Promise<InitializeResponse> {\n if (!this.initializePromise) {\n this.initializePromise = this.request('initialize', params)\n .then((result) => {\n this.notify('initialized');\n return result;\n })\n .catch((error: unknown) => {\n this.initializePromise = null;\n throw error;\n });\n }\n\n return this.initializePromise;\n }\n\n request<Method extends MethodName>(\n method: Method,\n ...[params]: MethodArguments<MethodParams<Method>>\n ): Promise<MethodResult<Method>> {\n this.assertStarted();\n const id = this.nextId++;\n const message: RpcMessage = params === undefined\n ? { id, method }\n : { id, method, params };\n\n const result = new Promise<MethodResult<Method>>((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`Codex app-server request timed out: ${method}`));\n }, this.options.requestTimeoutMs ?? requestTimeoutByMethod[method] ?? DEFAULT_REQUEST_TIMEOUT_MS);\n\n this.pending.set(id, {\n method,\n resolve: (value) => resolve(value as MethodResult<Method>),\n reject,\n timeout,\n });\n });\n\n try {\n this.transport.send(message);\n } catch (error) {\n const pending = this.pending.get(id);\n if (pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(id);\n pending.reject(toError(error));\n }\n }\n\n return result;\n }\n\n notify<Method extends ClientNotificationMethod>(\n method: Method,\n ...[params]: MethodArguments<ClientNotificationParams<Method>>\n ): void {\n this.assertStarted();\n this.transport.send(params === undefined ? { method } : { method, params });\n }\n\n onNotification(listener: (notification: ServerNotification) => void): () => void;\n onNotification<Method extends ServerNotificationMethod>(\n method: Method,\n listener: (notification: ServerNotificationFor<Method>) => void,\n ): () => void;\n onNotification<Method extends ServerNotificationMethod>(\n methodOrListener: Method | ((notification: ServerNotification) => void),\n methodListener?: (notification: ServerNotificationFor<Method>) => void,\n ): () => void {\n if (typeof methodOrListener === 'function') {\n this.notificationListeners.add(methodOrListener);\n return () => this.notificationListeners.delete(methodOrListener);\n }\n\n const listeners = this.notificationListenersByMethod.get(methodOrListener) ?? new Set();\n const listener = methodListener as (notification: ServerNotification) => void;\n listeners.add(listener);\n this.notificationListenersByMethod.set(methodOrListener, listeners);\n return () => {\n listeners.delete(listener);\n if (listeners.size === 0) {\n this.notificationListenersByMethod.delete(methodOrListener);\n }\n };\n }\n\n onServerRequest<Method extends ServerRequestMethod>(\n method: Method,\n handler: (\n request: ServerRequestFor<Method>,\n responder: CodexServerRequestResponder<Method>,\n ) => boolean | void | Promise<boolean | void>,\n ): () => void {\n const handlers = this.serverRequestHandlers.get(method) ?? new Set();\n const untypedHandler = handler as AnyServerRequestHandler;\n handlers.add(untypedHandler);\n this.serverRequestHandlers.set(method, handlers);\n return () => {\n handlers.delete(untypedHandler);\n if (handlers.size === 0) {\n this.serverRequestHandlers.delete(method);\n }\n };\n }\n\n onAnyServerRequest(handler: AnyServerRequestHandler): () => void {\n this.anyServerRequestHandlers.add(handler);\n return () => this.anyServerRequestHandlers.delete(handler);\n }\n\n onDisconnect(listener: (error: Error) => void): () => void {\n this.disconnectListeners.add(listener);\n return () => this.disconnectListeners.delete(listener);\n }\n\n async close(): Promise<void> {\n this.unsubscribeTransport();\n this.started = false;\n this.initializePromise = null;\n this.rejectAll(new Error('Codex app-server connection closed'));\n await this.transport.close();\n }\n\n private assertStarted(): void {\n if (!this.started) {\n throw new Error('Codex app-server client is not started');\n }\n }\n\n private unsubscribeTransport(): void {\n this.unsubscribeMessage?.();\n this.unsubscribeError?.();\n this.unsubscribeMessage = undefined;\n this.unsubscribeError = undefined;\n }\n\n private handleMessage(message: unknown): void {\n if (!isRecord(message)) {\n this.reportProtocolError(new Error('Codex app-server sent a non-object message'));\n return;\n }\n\n const id = isRpcId(message.id) ? message.id : undefined;\n if (id !== undefined && ('result' in message || 'error' in message) && typeof message.method !== 'string') {\n this.handleResponse(id, message);\n return;\n }\n\n if (typeof message.method === 'string' && id !== undefined) {\n void this.handleServerRequest({\n id,\n method: message.method,\n ...('params' in message ? { params: message.params } : {}),\n });\n return;\n }\n\n if (typeof message.method === 'string') {\n this.handleNotification(message as ServerNotification);\n return;\n }\n\n this.reportProtocolError(new Error('Codex app-server sent an invalid RPC message'));\n }\n\n private handleResponse(id: RpcId, message: Record<string, unknown>): void {\n const pending = this.pending.get(id);\n if (!pending) {\n return;\n }\n\n clearTimeout(pending.timeout);\n this.pending.delete(id);\n if ('error' in message) {\n if (isRpcError(message.error)) {\n pending.reject(new RpcRemoteError(message.error));\n } else {\n pending.reject(new Error(`Codex app-server returned a malformed error for ${pending.method}`));\n }\n return;\n }\n\n pending.resolve(message.result);\n }\n\n private handleNotification(notification: ServerNotification): void {\n notifyListeners(this.notificationListeners, notification, this.options.onListenerError);\n notifyListeners(\n this.notificationListenersByMethod.get(notification.method) ?? [],\n notification,\n this.options.onListenerError,\n );\n }\n\n private async handleServerRequest(request: { id: RpcId; method: string; params?: unknown }): Promise<void> {\n const responder = this.createResponder(request.id);\n const handlers = [\n ...(this.serverRequestHandlers.get(request.method) ?? []),\n ...this.anyServerRequestHandlers,\n ];\n\n for (const handler of handlers) {\n try {\n const claimed = await handler(request as ServerRequest, responder);\n if (claimed === true || responder.responded) {\n return;\n }\n } catch (error) {\n responder.reject({\n code: -32603,\n message: toError(error).message,\n });\n return;\n }\n }\n\n responder.reject((this.options.unhandledServerRequestError ?? defaultUnhandledRequestError)(request));\n }\n\n private createResponder(id: RpcId): UntypedCodexServerRequestResponder {\n let responded = false;\n return {\n get responded() {\n return responded;\n },\n resolve: (result) => {\n if (responded) {\n return;\n }\n responded = true;\n this.transport.send({ id, result });\n },\n reject: (error) => {\n if (responded) {\n return;\n }\n responded = true;\n this.transport.send({ id, error: normalizeRpcError(error) });\n },\n };\n }\n\n private rejectAll(error: Error): void {\n for (const pending of this.pending.values()) {\n clearTimeout(pending.timeout);\n pending.reject(error);\n }\n this.pending.clear();\n }\n\n private handleTransportError(error: Error): void {\n if (error instanceof RpcTransportProtocolError) {\n this.reportProtocolError(error);\n if (error.requestId !== undefined) {\n const pending = this.pending.get(error.requestId);\n if (pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(error.requestId);\n pending.reject(error);\n }\n } else {\n this.rejectAll(error);\n }\n return;\n }\n this.started = false;\n this.initializePromise = null;\n this.unsubscribeTransport();\n this.rejectAll(error);\n notifyListeners(this.disconnectListeners, error, this.options.onListenerError);\n }\n\n private reportProtocolError(error: Error): void {\n this.options.onProtocolError?.(error);\n }\n}\n\nfunction normalizeRpcError(error: Error | RpcError | string): RpcError {\n if (typeof error === 'string') {\n return { code: -32603, message: error };\n }\n if (error instanceof Error) {\n return { code: -32603, message: error.message };\n }\n return error;\n}\n\nfunction isRpcId(value: unknown): value is RpcId {\n return typeof value === 'number' || typeof value === 'string';\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n","// Generated by scripts/generate-codex-schema.mjs.\nexport const codexSchemaCliVersion = \"codex-cli 0.154.0\";\n"],"mappings":";AAOA,SAAgB,EAAoB,G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AAM,SAAS,GACnC,EAAQ,OAAO,CAAK;GAExB,OACE,KAAK,UAAU,CAAK;GAEtB;EACF;EAKA,AAJA,KAAK,UAAU,IACf,KAAK,oBAAoB,MACzB,KAAK,qBAAqB,GAC1B,KAAK,UAAU,CAAK,GACpB,EAAgB,KAAK,qBAAqB,GAAO,KAAK,QAAQ,eAAe;CAC/E;CAEA,oBAA4B,GAAoB;EAC9C,KAAK,QAAQ,kBAAkB,CAAK;CACtC;AACF;AAEA,SAAS,EAAkB,GAA4C;CAOrE,OANI,OAAO,KAAU,WACZ;EAAE,MAAM;EAAQ,SAAS;CAAM,IAEpC,aAAiB,QACZ;EAAE,MAAM;EAAQ,SAAS,EAAM;CAAQ,IAEzC;AACT;AAEA,SAAS,EAAQ,GAAgC;CAC/C,OAAO,OAAO,KAAU,YAAY,OAAO,KAAU;AACvD;AAEA,SAAS,EAAQ,GAAuB;CACtC,OAAO,aAAiB,QAAQ,IAAY,MAAM,OAAO,CAAK,CAAC;AACjE;;;AC9ZA,IAAa,IAAwB"}
|
package/dist/codex/client.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { ServerNotification } from './generated/ServerNotification';
|
|
|
5
5
|
import type { ServerRequest } from './generated/ServerRequest';
|
|
6
6
|
import type { CodexAppServerMethodMap } from './method-map';
|
|
7
7
|
import type { CodexServerRequestMethodMap } from './server-request-map';
|
|
8
|
+
import { type ListenerErrorHandler } from './listener-errors';
|
|
8
9
|
import { type RpcError, type RpcId, type RpcTransport } from './wire';
|
|
9
10
|
type MethodName = keyof CodexAppServerMethodMap & string;
|
|
10
11
|
type MethodParams<Method extends MethodName> = CodexAppServerMethodMap[Method]['params'];
|
|
@@ -39,6 +40,12 @@ export type UntypedCodexServerRequestResponder = {
|
|
|
39
40
|
export type CodexAppServerClientOptions = {
|
|
40
41
|
requestTimeoutMs?: number;
|
|
41
42
|
onProtocolError?: (error: Error) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Receives exceptions thrown by notification and disconnect listeners. Each
|
|
45
|
+
* listener is isolated, so one failing subscriber never disturbs the others
|
|
46
|
+
* or fails in-flight requests. Defaults to a process warning.
|
|
47
|
+
*/
|
|
48
|
+
onListenerError?: ListenerErrorHandler;
|
|
42
49
|
unhandledServerRequestError?: (request: {
|
|
43
50
|
id: RpcId;
|
|
44
51
|
method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/codex/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAKL,KAAK,QAAQ,EACb,KAAK,KAAK,EAEV,KAAK,YAAY,EAClB,MAAM,QAAQ,CAAC;AAEhB,KAAK,UAAU,GAAG,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACzD,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzF,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;AACzF,KAAK,eAAe,CAAC,MAAM,IAAI,SAAS,SAAS,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/F,KAAK,wBAAwB,GAAG,kB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AS;IAQjB,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,mBAAmB;CAG5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ListenerErrorHandler = (error: unknown) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Reports an exception thrown by a subscriber without letting it disturb the
|
|
4
|
+
* code that notified it. The host's handler receives it; without one it
|
|
5
|
+
* surfaces as a process warning, so it is neither swallowed nor fatal.
|
|
6
|
+
*/
|
|
7
|
+
export declare function reportListenerError(error: unknown, handler?: ListenerErrorHandler): void;
|
|
8
|
+
/** Calls every listener, isolating each from the others' failures. */
|
|
9
|
+
export declare function notifyListeners<Value>(listeners: Iterable<(value: Value) => void>, value: Value, onError?: ListenerErrorHandler): void;
|
|
10
|
+
//# sourceMappingURL=listener-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listener-errors.d.ts","sourceRoot":"","sources":["../../src/codex/listener-errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAUxF;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,KAAK,EACnC,SAAS,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,EAC3C,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,oBAAoB,GAC7B,IAAI,CAQN"}
|