@roamcode.ai/server 1.0.0 → 1.0.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/dist/index.d.ts +2406 -82
- package/dist/index.js +8314 -44
- package/dist/managed-update-helper.js +621 -26
- package/dist/mcp-send.js +76 -90
- package/dist/start.d.ts +591 -9
- package/dist/start.js +7629 -353
- package/package.json +3 -3
- package/dist/auth.d.ts +0 -63
- package/dist/auth.js +0 -133
- package/dist/claude-auth-service.d.ts +0 -76
- package/dist/claude-auth-service.js +0 -217
- package/dist/claude-latest-service.d.ts +0 -34
- package/dist/claude-latest-service.js +0 -61
- package/dist/config.d.ts +0 -78
- package/dist/config.js +0 -59
- package/dist/data-dir.d.ts +0 -42
- package/dist/data-dir.js +0 -70
- package/dist/diag.d.ts +0 -43
- package/dist/diag.js +0 -83
- package/dist/fs-service.d.ts +0 -90
- package/dist/fs-service.js +0 -290
- package/dist/managed-runtime.d.ts +0 -51
- package/dist/managed-runtime.js +0 -411
- package/dist/managed-update-helper.d.ts +0 -2
- package/dist/mcp-send.d.ts +0 -33
- package/dist/origin-check.d.ts +0 -37
- package/dist/origin-check.js +0 -101
- package/dist/pane-status.d.ts +0 -61
- package/dist/pane-status.js +0 -145
- package/dist/providers/claude-metadata-service.d.ts +0 -58
- package/dist/providers/claude-metadata-service.js +0 -352
- package/dist/providers/claude-provider.d.ts +0 -11
- package/dist/providers/claude-provider.js +0 -166
- package/dist/providers/codex-activity.d.ts +0 -21
- package/dist/providers/codex-activity.js +0 -122
- package/dist/providers/codex-app-server-client.d.ts +0 -90
- package/dist/providers/codex-app-server-client.js +0 -485
- package/dist/providers/codex-latest-service.d.ts +0 -50
- package/dist/providers/codex-latest-service.js +0 -174
- package/dist/providers/codex-metadata-service.d.ts +0 -161
- package/dist/providers/codex-metadata-service.js +0 -686
- package/dist/providers/codex-profile-client.d.ts +0 -16
- package/dist/providers/codex-profile-client.js +0 -52
- package/dist/providers/codex-profile-security.d.ts +0 -23
- package/dist/providers/codex-profile-security.js +0 -161
- package/dist/providers/codex-provider.d.ts +0 -15
- package/dist/providers/codex-provider.js +0 -174
- package/dist/providers/codex-thread-coordinator.d.ts +0 -18
- package/dist/providers/codex-thread-coordinator.js +0 -93
- package/dist/providers/codex-thread-persistence.d.ts +0 -9
- package/dist/providers/codex-thread-persistence.js +0 -45
- package/dist/providers/codex-thread-resolver.d.ts +0 -59
- package/dist/providers/codex-thread-resolver.js +0 -322
- package/dist/providers/options.d.ts +0 -7
- package/dist/providers/options.js +0 -155
- package/dist/providers/provider-artifacts.d.ts +0 -3
- package/dist/providers/provider-artifacts.js +0 -30
- package/dist/providers/registry.d.ts +0 -7
- package/dist/providers/registry.js +0 -23
- package/dist/providers/types.d.ts +0 -95
- package/dist/providers/types.js +0 -8
- package/dist/push-dispatch.d.ts +0 -81
- package/dist/push-dispatch.js +0 -100
- package/dist/push-store.d.ts +0 -25
- package/dist/push-store.js +0 -79
- package/dist/rate-limit.d.ts +0 -52
- package/dist/rate-limit.js +0 -72
- package/dist/server-config.d.ts +0 -60
- package/dist/server-config.js +0 -77
- package/dist/service-install.d.ts +0 -60
- package/dist/service-install.js +0 -221
- package/dist/session-defaults.d.ts +0 -26
- package/dist/session-defaults.js +0 -60
- package/dist/session-store.d.ts +0 -81
- package/dist/session-store.js +0 -654
- package/dist/static-routes.d.ts +0 -101
- package/dist/static-routes.js +0 -188
- package/dist/terminal-capability.d.ts +0 -5
- package/dist/terminal-capability.js +0 -27
- package/dist/terminal-manager.d.ts +0 -224
- package/dist/terminal-manager.js +0 -917
- package/dist/terminal-process.d.ts +0 -85
- package/dist/terminal-process.js +0 -238
- package/dist/terminal-shared.d.ts +0 -36
- package/dist/terminal-shared.js +0 -43
- package/dist/tmux-list.d.ts +0 -11
- package/dist/tmux-list.js +0 -39
- package/dist/transport.d.ts +0 -123
- package/dist/transport.js +0 -1559
- package/dist/updater.d.ts +0 -161
- package/dist/updater.js +0 -451
- package/dist/usage-service.d.ts +0 -118
- package/dist/usage-service.js +0 -173
- package/dist/vapid.d.ts +0 -17
- package/dist/vapid.js +0 -31
- package/dist/web-push-send.d.ts +0 -20
- package/dist/web-push-send.js +0 -21
- package/dist/ws-ticket.d.ts +0 -47
- package/dist/ws-ticket.js +0 -62
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { buildHooksSettingsDocument, buildMcpConfigDocument, hookAuthFileContent, hookAuthPathFor, hooksSettingsPathFor, mcpConfigPathFor, } from "../config.js";
|
|
2
|
-
import { classifyPaneStatus } from "../pane-status.js";
|
|
3
|
-
import { cleanupProviderArtifacts, writeProviderArtifact0600 } from "./provider-artifacts.js";
|
|
4
|
-
import { ProviderError } from "./types.js";
|
|
5
|
-
const OWNED_VALUE_FLAGS = new Map([
|
|
6
|
-
["--resume", "optional"],
|
|
7
|
-
["--session-id", "one"],
|
|
8
|
-
["--model", "one"],
|
|
9
|
-
["--effort", "one"],
|
|
10
|
-
["--permission-mode", "one"],
|
|
11
|
-
["--add-dir", "variadic"],
|
|
12
|
-
["--mcp-config", "variadic"],
|
|
13
|
-
["--settings", "one"],
|
|
14
|
-
]);
|
|
15
|
-
const OWNED_BOOLEAN_FLAGS = ["--continue", "--dangerously-skip-permissions"];
|
|
16
|
-
function invalidLegacyArg(message) {
|
|
17
|
-
return new ProviderError("INVALID_PROVIDER_OPTIONS", `Invalid provider options: ${message}`);
|
|
18
|
-
}
|
|
19
|
-
function requireLegacyValue(args, index, flag) {
|
|
20
|
-
const value = args[index + 1];
|
|
21
|
-
if (value === undefined || value.startsWith("-"))
|
|
22
|
-
throw invalidLegacyArg(`${flag} requires a value`);
|
|
23
|
-
return index + 1;
|
|
24
|
-
}
|
|
25
|
-
function sanitizeLegacyArgs(legacyArgs) {
|
|
26
|
-
const preserved = [];
|
|
27
|
-
for (let index = 0; index < legacyArgs.length; index += 1) {
|
|
28
|
-
const arg = legacyArgs[index];
|
|
29
|
-
if (arg === "--") {
|
|
30
|
-
preserved.push(...legacyArgs.slice(index));
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
if (arg === "-c")
|
|
34
|
-
continue;
|
|
35
|
-
if (arg.startsWith("-c")) {
|
|
36
|
-
throw invalidLegacyArg("-c has an ambiguous attached value");
|
|
37
|
-
}
|
|
38
|
-
if (arg === "-r") {
|
|
39
|
-
const value = legacyArgs[index + 1];
|
|
40
|
-
if (value !== undefined && !value.startsWith("-"))
|
|
41
|
-
index += 1;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (arg.startsWith("-r")) {
|
|
45
|
-
if (arg === "-r=" || arg.length === 2)
|
|
46
|
-
throw invalidLegacyArg("-r has an ambiguous empty value");
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
let handled = false;
|
|
50
|
-
for (const flag of OWNED_BOOLEAN_FLAGS) {
|
|
51
|
-
if (arg === flag) {
|
|
52
|
-
handled = true;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
if (arg.startsWith(`${flag}=`)) {
|
|
56
|
-
if (arg.length === flag.length + 1)
|
|
57
|
-
throw invalidLegacyArg(`${flag} has an ambiguous empty value`);
|
|
58
|
-
handled = true;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (handled)
|
|
63
|
-
continue;
|
|
64
|
-
for (const [flag, arity] of OWNED_VALUE_FLAGS) {
|
|
65
|
-
if (arg.startsWith(`${flag}=`)) {
|
|
66
|
-
if (arg.length === flag.length + 1) {
|
|
67
|
-
const detail = arity === "optional" ? "has an ambiguous empty value" : "requires a value";
|
|
68
|
-
throw invalidLegacyArg(`${flag} ${detail}`);
|
|
69
|
-
}
|
|
70
|
-
handled = true;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
if (arg !== flag)
|
|
74
|
-
continue;
|
|
75
|
-
handled = true;
|
|
76
|
-
if (arity === "optional") {
|
|
77
|
-
const value = legacyArgs[index + 1];
|
|
78
|
-
if (value !== undefined && !value.startsWith("-"))
|
|
79
|
-
index += 1;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
index = requireLegacyValue(legacyArgs, index, flag);
|
|
83
|
-
if (arity === "variadic") {
|
|
84
|
-
while (legacyArgs[index + 1] !== undefined && !legacyArgs[index + 1].startsWith("-"))
|
|
85
|
-
index += 1;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (!handled)
|
|
91
|
-
preserved.push(arg);
|
|
92
|
-
}
|
|
93
|
-
return preserved;
|
|
94
|
-
}
|
|
95
|
-
function insertBeforeSeparator(args, ownedArgs) {
|
|
96
|
-
const separatorIndex = args.indexOf("--");
|
|
97
|
-
args.splice(separatorIndex === -1 ? args.length : separatorIndex, 0, ...ownedArgs);
|
|
98
|
-
}
|
|
99
|
-
function claudeArgs(options) {
|
|
100
|
-
const args = [];
|
|
101
|
-
if (options.model)
|
|
102
|
-
args.push("--model", options.model);
|
|
103
|
-
if (options.effort)
|
|
104
|
-
args.push("--effort", options.effort);
|
|
105
|
-
if (options.dangerouslySkip)
|
|
106
|
-
args.push("--dangerously-skip-permissions");
|
|
107
|
-
else if (options.permissionMode)
|
|
108
|
-
args.push("--permission-mode", options.permissionMode);
|
|
109
|
-
for (const dir of options.addDirs ?? [])
|
|
110
|
-
args.push("--add-dir", dir);
|
|
111
|
-
// Legacy arguments exist only for rollback-readable Claude rows. Provider-owned model, safety, session,
|
|
112
|
-
// and attachment flags are rebuilt from typed options so historical argv cannot override adapter policy.
|
|
113
|
-
args.push(...sanitizeLegacyArgs(options.legacyArgs ?? []));
|
|
114
|
-
return args;
|
|
115
|
-
}
|
|
116
|
-
export function createClaudeProvider(options) {
|
|
117
|
-
return {
|
|
118
|
-
id: "claude",
|
|
119
|
-
displayName: "Claude Code",
|
|
120
|
-
resumeIdentity: "optional",
|
|
121
|
-
probe: options.probe ?? (() => Promise.resolve({ terminalAvailable: true, metadataAvailable: true })),
|
|
122
|
-
buildProcess: async (context) => {
|
|
123
|
-
if (context.options.provider !== "claude") {
|
|
124
|
-
throw new ProviderError("INVALID_PROVIDER_OPTIONS", "Claude provider received non-Claude options");
|
|
125
|
-
}
|
|
126
|
-
const args = claudeArgs(context.options);
|
|
127
|
-
const ownedPaths = [];
|
|
128
|
-
const attach = context.attach ?? options.getAttach?.() ?? options.attach;
|
|
129
|
-
if (attach) {
|
|
130
|
-
try {
|
|
131
|
-
const mcpPath = mcpConfigPathFor(attach.dataDir, context.roamSessionId);
|
|
132
|
-
if (writeProviderArtifact0600(mcpPath, JSON.stringify(buildMcpConfigDocument(context.roamSessionId, attach)), context, ownedPaths)) {
|
|
133
|
-
insertBeforeSeparator(args, ["--mcp-config", mcpPath]);
|
|
134
|
-
}
|
|
135
|
-
const authPath = hookAuthPathFor(attach.dataDir, context.roamSessionId);
|
|
136
|
-
const settingsPath = hooksSettingsPathFor(attach.dataDir, context.roamSessionId);
|
|
137
|
-
if (writeProviderArtifact0600(authPath, hookAuthFileContent(attach.token), context, ownedPaths)) {
|
|
138
|
-
if (writeProviderArtifact0600(settingsPath, JSON.stringify(buildHooksSettingsDocument(context.roamSessionId, attach, authPath)), context, ownedPaths)) {
|
|
139
|
-
insertBeforeSeparator(args, ["--settings", settingsPath]);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
cleanupProviderArtifacts([authPath]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
cleanupProviderArtifacts(ownedPaths);
|
|
148
|
-
throw error;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (context.intent === "resume")
|
|
152
|
-
insertBeforeSeparator(args, ["--continue"]);
|
|
153
|
-
const env = { ...(options.env ?? process.env) };
|
|
154
|
-
delete env.ANTHROPIC_API_KEY;
|
|
155
|
-
return {
|
|
156
|
-
executable: options.claudeBin,
|
|
157
|
-
args,
|
|
158
|
-
env,
|
|
159
|
-
cleanupPaths: ownedPaths,
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
runtimeSignals: () => [],
|
|
163
|
-
classifyPane: classifyPaneStatus,
|
|
164
|
-
cleanup: cleanupProviderArtifacts,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type PaneStatus } from "../pane-status.js";
|
|
2
|
-
import type { ProviderRuntimeMetadata, ProviderRuntimeSignal, ProviderRuntimeSignalParser } from "./types.js";
|
|
3
|
-
export declare const CODEX_OSC_MAX_CARRY: number;
|
|
4
|
-
export declare const CODEX_CLASSIFIER_TESTED_UP_TO = "0.144";
|
|
5
|
-
export interface CodexOscParser extends ProviderRuntimeSignalParser {
|
|
6
|
-
readonly bufferedLength: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function createCodexOscParser(): CodexOscParser;
|
|
9
|
-
export declare function parseCodexOscNotifications(input: string): ProviderRuntimeSignal[];
|
|
10
|
-
export declare function classifyCodexPane(pane: string): PaneStatus;
|
|
11
|
-
/**
|
|
12
|
-
* Read Codex's LIVE model + reasoning level from the pinned bottom status row. Unlike launch options, this
|
|
13
|
-
* changes immediately when the user switches reasoning inside the TUI. Only the final non-empty row is
|
|
14
|
-
* considered, so conversation text that happens to mention a model/effort pair cannot rewrite metadata.
|
|
15
|
-
*
|
|
16
|
-
* Supported real Codex layouts:
|
|
17
|
-
* gpt-5.6-sol xhigh · ~/Developer/remote-coder
|
|
18
|
-
* gpt-5.6 · high · 91% left
|
|
19
|
-
*/
|
|
20
|
-
export declare function parseCodexRuntimeMetadata(pane: string): ProviderRuntimeMetadata | undefined;
|
|
21
|
-
export declare function codexClassifierVersionWarning(codexVersion: string | undefined): string | undefined;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { isNewerMajorMinor } from "../pane-status.js";
|
|
2
|
-
export const CODEX_OSC_MAX_CARRY = 8 * 1024;
|
|
3
|
-
export const CODEX_CLASSIFIER_TESTED_UP_TO = "0.144";
|
|
4
|
-
const OSC_START = "\u001b]";
|
|
5
|
-
const OSC_9_START = "\u001b]9;";
|
|
6
|
-
const ST = "\u001b\\";
|
|
7
|
-
function signalForPayload(payload) {
|
|
8
|
-
if (payload.startsWith("Approval requested: ") ||
|
|
9
|
-
payload.startsWith("Codex wants to edit ") ||
|
|
10
|
-
payload.startsWith("Approval requested by ") ||
|
|
11
|
-
payload.startsWith("Plan mode prompt: ")) {
|
|
12
|
-
return { type: "blocked" };
|
|
13
|
-
}
|
|
14
|
-
return payload.length > 0 ? { type: "idle" } : undefined;
|
|
15
|
-
}
|
|
16
|
-
function terminatorAt(input, from) {
|
|
17
|
-
const bel = input.indexOf("\u0007", from);
|
|
18
|
-
const st = input.indexOf(ST, from);
|
|
19
|
-
if (bel === -1 && st === -1)
|
|
20
|
-
return undefined;
|
|
21
|
-
if (bel !== -1 && (st === -1 || bel < st))
|
|
22
|
-
return { index: bel, width: 1 };
|
|
23
|
-
return { index: st, width: 2 };
|
|
24
|
-
}
|
|
25
|
-
export function createCodexOscParser() {
|
|
26
|
-
let carry = "";
|
|
27
|
-
return {
|
|
28
|
-
get bufferedLength() {
|
|
29
|
-
return carry.length;
|
|
30
|
-
},
|
|
31
|
-
push(chunk) {
|
|
32
|
-
const input = carry + chunk;
|
|
33
|
-
carry = "";
|
|
34
|
-
const signals = [];
|
|
35
|
-
let cursor = 0;
|
|
36
|
-
while (cursor < input.length) {
|
|
37
|
-
const start = input.indexOf("\u001b", cursor);
|
|
38
|
-
if (start === -1)
|
|
39
|
-
break;
|
|
40
|
-
if (start === input.length - 1) {
|
|
41
|
-
carry = "\u001b";
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
if (!input.startsWith(OSC_START, start)) {
|
|
45
|
-
cursor = start + 1;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (input.length < start + OSC_9_START.length) {
|
|
49
|
-
carry = input.slice(start);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
if (!input.startsWith(OSC_9_START, start)) {
|
|
53
|
-
cursor = start + OSC_START.length;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const payloadStart = start + OSC_9_START.length;
|
|
57
|
-
const terminator = terminatorAt(input, payloadStart);
|
|
58
|
-
if (!terminator) {
|
|
59
|
-
const pending = input.slice(start);
|
|
60
|
-
carry = pending.length <= CODEX_OSC_MAX_CARRY ? pending : "";
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
const frameLength = terminator.index + terminator.width - start;
|
|
64
|
-
if (frameLength <= CODEX_OSC_MAX_CARRY) {
|
|
65
|
-
const signal = signalForPayload(input.slice(payloadStart, terminator.index));
|
|
66
|
-
if (signal)
|
|
67
|
-
signals.push(signal);
|
|
68
|
-
}
|
|
69
|
-
cursor = terminator.index + terminator.width;
|
|
70
|
-
}
|
|
71
|
-
return signals;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export function parseCodexOscNotifications(input) {
|
|
76
|
-
return createCodexOscParser().push(input);
|
|
77
|
-
}
|
|
78
|
-
export function classifyCodexPane(pane) {
|
|
79
|
-
const tail = pane.split("\n").slice(-24).join("\n");
|
|
80
|
-
if (/\bWould you like to run the following command\b/i.test(tail))
|
|
81
|
-
return "blocked";
|
|
82
|
-
if (/\bDo you want to allow\b/i.test(tail))
|
|
83
|
-
return "blocked";
|
|
84
|
-
if (/\bPress enter to confirm or esc to cancel\b/i.test(tail))
|
|
85
|
-
return "blocked";
|
|
86
|
-
if (/\besc to interrupt\b/i.test(tail))
|
|
87
|
-
return "working";
|
|
88
|
-
if (/[•●]\s*(?:Working|Thinking|Running)\s*\(\s*\d+\s*[ms]\b/i.test(tail))
|
|
89
|
-
return "working";
|
|
90
|
-
return "idle";
|
|
91
|
-
}
|
|
92
|
-
const RUNTIME_TOKEN = "[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}";
|
|
93
|
-
const EFFORT_TOKEN = "[A-Za-z0-9][A-Za-z0-9._-]{0,127}";
|
|
94
|
-
/**
|
|
95
|
-
* Read Codex's LIVE model + reasoning level from the pinned bottom status row. Unlike launch options, this
|
|
96
|
-
* changes immediately when the user switches reasoning inside the TUI. Only the final non-empty row is
|
|
97
|
-
* considered, so conversation text that happens to mention a model/effort pair cannot rewrite metadata.
|
|
98
|
-
*
|
|
99
|
-
* Supported real Codex layouts:
|
|
100
|
-
* gpt-5.6-sol xhigh · ~/Developer/remote-coder
|
|
101
|
-
* gpt-5.6 · high · 91% left
|
|
102
|
-
*/
|
|
103
|
-
export function parseCodexRuntimeMetadata(pane) {
|
|
104
|
-
const line = pane
|
|
105
|
-
.split(/\r?\n/)
|
|
106
|
-
.map((value) => value.trim())
|
|
107
|
-
.filter(Boolean)
|
|
108
|
-
.at(-1);
|
|
109
|
-
if (!line)
|
|
110
|
-
return undefined;
|
|
111
|
-
const current = new RegExp(`^(${RUNTIME_TOKEN})\\s+(${EFFORT_TOKEN})\\s+·\\s+(?:~/|/).+$`).exec(line);
|
|
112
|
-
if (current)
|
|
113
|
-
return { model: current[1], effort: current[2] };
|
|
114
|
-
const legacy = new RegExp(`^(${RUNTIME_TOKEN})\\s+·\\s+(${EFFORT_TOKEN})\\s+·\\s+.+$`).exec(line);
|
|
115
|
-
return legacy ? { model: legacy[1], effort: legacy[2] } : undefined;
|
|
116
|
-
}
|
|
117
|
-
export function codexClassifierVersionWarning(codexVersion) {
|
|
118
|
-
if (!codexVersion || !isNewerMajorMinor(codexVersion, CODEX_CLASSIFIER_TESTED_UP_TO))
|
|
119
|
-
return undefined;
|
|
120
|
-
return (`Codex pane-status markers were verified against Codex <=${CODEX_CLASSIFIER_TESTED_UP_TO}; ` +
|
|
121
|
-
`current is ${codexVersion} — verify rail statuses after this upgrade`);
|
|
122
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { type ZodType } from "zod";
|
|
3
|
-
export declare const CODEX_METADATA_ERROR_CODE: "CODEX_METADATA_UNAVAILABLE";
|
|
4
|
-
export declare const DEFAULT_CODEX_APP_SERVER_TIMEOUT_MS = 15000;
|
|
5
|
-
export declare const DEFAULT_CODEX_APP_SERVER_MAX_STDOUT_LINE_BYTES: number;
|
|
6
|
-
export declare const DEFAULT_CODEX_APP_SERVER_MAX_STDOUT_BUFFER_BYTES: number;
|
|
7
|
-
export declare const DEFAULT_CODEX_APP_SERVER_MAX_STDERR_BYTES: number;
|
|
8
|
-
type DiagnosticIssue = "exit" | "malformed_json" | "notification_listener" | "spawn" | "stderr_limit" | "stdout_limit" | "transport_error" | "unknown_message" | "write_error";
|
|
9
|
-
export interface CodexMetadataDiagnostics {
|
|
10
|
-
readonly lastIssue?: DiagnosticIssue;
|
|
11
|
-
readonly stderrBytes: number;
|
|
12
|
-
readonly stderrTruncated: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface CodexAppServerNotification {
|
|
15
|
-
readonly method: string;
|
|
16
|
-
readonly params?: unknown;
|
|
17
|
-
}
|
|
18
|
-
interface WritableTransport extends EventEmitter {
|
|
19
|
-
write(value: string | Uint8Array, callback?: (error?: Error | null) => void): boolean;
|
|
20
|
-
end(): void;
|
|
21
|
-
}
|
|
22
|
-
type ReadableTransport = EventEmitter;
|
|
23
|
-
/** The intentionally small child-process surface used by the protocol client and its fake tests. */
|
|
24
|
-
export interface CodexAppServerTransport extends EventEmitter {
|
|
25
|
-
readonly stdin: WritableTransport;
|
|
26
|
-
readonly stdout: ReadableTransport;
|
|
27
|
-
readonly stderr: ReadableTransport;
|
|
28
|
-
kill(signal?: NodeJS.Signals): boolean | void;
|
|
29
|
-
}
|
|
30
|
-
export type SpawnCodexAppServerTransport = (command: string, args: readonly string[], options?: {
|
|
31
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
32
|
-
}) => CodexAppServerTransport;
|
|
33
|
-
export interface CodexAppServerClientOptions {
|
|
34
|
-
readonly codexBin?: string;
|
|
35
|
-
/** Selects one validated `$CODEX_HOME/<name>.config.toml` layer before app-server starts. */
|
|
36
|
-
readonly profile?: string;
|
|
37
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
38
|
-
readonly spawnTransport?: SpawnCodexAppServerTransport;
|
|
39
|
-
readonly timeoutMs?: number;
|
|
40
|
-
readonly maxStdoutLineBytes?: number;
|
|
41
|
-
readonly maxStdoutBufferBytes?: number;
|
|
42
|
-
readonly maxStderrBytes?: number;
|
|
43
|
-
}
|
|
44
|
-
export declare class CodexMetadataUnavailableError extends Error {
|
|
45
|
-
readonly code: "CODEX_METADATA_UNAVAILABLE";
|
|
46
|
-
constructor();
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Bounded JSON-lines client for the auxiliary Codex app-server metadata channel.
|
|
50
|
-
* It never participates in terminal streaming and deliberately knows no method-specific result schemas.
|
|
51
|
-
*/
|
|
52
|
-
export declare class CodexAppServerClient {
|
|
53
|
-
readonly limits: {
|
|
54
|
-
readonly timeoutMs: number;
|
|
55
|
-
readonly maxStdoutLineBytes: number;
|
|
56
|
-
readonly maxStdoutBufferBytes: number;
|
|
57
|
-
readonly maxStderrBytes: number;
|
|
58
|
-
};
|
|
59
|
-
private readonly codexBin;
|
|
60
|
-
private readonly profile?;
|
|
61
|
-
private readonly env?;
|
|
62
|
-
private readonly spawnTransport;
|
|
63
|
-
private readonly notificationListeners;
|
|
64
|
-
private active?;
|
|
65
|
-
private startPromise?;
|
|
66
|
-
private stopPromise?;
|
|
67
|
-
private nextRequestId;
|
|
68
|
-
private nextGeneration;
|
|
69
|
-
private lastDiagnostics;
|
|
70
|
-
constructor(options?: CodexAppServerClientOptions);
|
|
71
|
-
get diagnostics(): CodexMetadataDiagnostics;
|
|
72
|
-
start(): Promise<void>;
|
|
73
|
-
request<T>(method: string, params: unknown, schema: ZodType<T>): Promise<T>;
|
|
74
|
-
onNotification(listener: (notification: CodexAppServerNotification) => void): () => void;
|
|
75
|
-
stop(): Promise<void>;
|
|
76
|
-
private createGeneration;
|
|
77
|
-
private installListeners;
|
|
78
|
-
private sendRequest;
|
|
79
|
-
private writeFrame;
|
|
80
|
-
private flushWrites;
|
|
81
|
-
private onStdout;
|
|
82
|
-
private onMessage;
|
|
83
|
-
private resolveResponse;
|
|
84
|
-
private rejectResponse;
|
|
85
|
-
private onStderr;
|
|
86
|
-
private failGeneration;
|
|
87
|
-
private removeListeners;
|
|
88
|
-
private recordIssue;
|
|
89
|
-
}
|
|
90
|
-
export {};
|