@gakr-gakr/codex 0.1.0 → 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/dist/client-DNN2uyJW.js +642 -0
- package/dist/client-factory-Bu9OClHJ.js +9 -0
- package/dist/command-formatters-BpPOTePl.js +520 -0
- package/dist/command-handlers-BBs7Vws9.js +1533 -0
- package/dist/compact-CDboBy7o.js +329 -0
- package/dist/computer-use-DCZB46Sw.js +367 -0
- package/dist/config-CLMSw0p2.js +510 -0
- package/dist/doctor-contract-api.js +53 -0
- package/dist/harness.js +51 -0
- package/dist/index.js +1171 -0
- package/dist/media-understanding-provider.js +335 -0
- package/dist/models-jLA2SIvd.js +110 -0
- package/dist/node-cli-sessions-BLRDs_US.js +1216 -0
- package/dist/plugin-activation-CEy_oYpx.js +452 -0
- package/dist/prompt-overlay.js +12 -0
- package/dist/protocol-C9UWI98H.js +9 -0
- package/dist/protocol-validators-BGBspNmF.js +5988 -0
- package/dist/provider-catalog.js +84 -0
- package/dist/provider-discovery.js +33 -0
- package/dist/provider.js +150 -0
- package/dist/rate-limit-cache-9LxQdE0K.js +24 -0
- package/dist/request-DbSPeTcV.js +89 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/run-attempt-BoEwzQCv.js +5463 -0
- package/dist/session-binding-e2GFp9VH.js +222 -0
- package/dist/shared-client-D7Vy0glq.js +631 -0
- package/dist/side-question-BDLuEzFP.js +668 -0
- package/dist/test-api.js +49 -0
- package/dist/thread-lifecycle-Clo0EHMk.js +1565 -0
- package/dist/vision-tools-Cofrv35p.js +1379 -0
- package/package.json +16 -1
- package/doctor-contract-api.ts +0 -68
- package/harness.ts +0 -72
- package/index.ts +0 -124
- package/media-understanding-provider.ts +0 -521
- package/prompt-overlay.ts +0 -21
- package/provider-catalog.ts +0 -83
- package/provider-discovery.ts +0 -45
- package/provider.ts +0 -243
- package/src/app-server/app-inventory-cache.ts +0 -324
- package/src/app-server/approval-bridge.ts +0 -1211
- package/src/app-server/auth-bridge.ts +0 -614
- package/src/app-server/capabilities.ts +0 -27
- package/src/app-server/client-factory.ts +0 -24
- package/src/app-server/client.ts +0 -715
- package/src/app-server/compact.ts +0 -512
- package/src/app-server/computer-use.ts +0 -683
- package/src/app-server/config.ts +0 -1038
- package/src/app-server/context-engine-projection.ts +0 -403
- package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
- package/src/app-server/dynamic-tool-profile.ts +0 -70
- package/src/app-server/dynamic-tools.ts +0 -623
- package/src/app-server/elicitation-bridge.ts +0 -783
- package/src/app-server/event-projector.ts +0 -2065
- package/src/app-server/image-payload-sanitizer.ts +0 -167
- package/src/app-server/local-runtime-attribution.ts +0 -39
- package/src/app-server/managed-binary.ts +0 -193
- package/src/app-server/models.ts +0 -172
- package/src/app-server/native-hook-relay.ts +0 -150
- package/src/app-server/native-subagent-task-mirror.ts +0 -497
- package/src/app-server/plugin-activation.ts +0 -283
- package/src/app-server/plugin-app-cache-key.ts +0 -74
- package/src/app-server/plugin-approval-roundtrip.ts +0 -122
- package/src/app-server/plugin-inventory.ts +0 -357
- package/src/app-server/plugin-thread-config.ts +0 -455
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
- package/src/app-server/protocol-validators.ts +0 -203
- package/src/app-server/protocol.ts +0 -520
- package/src/app-server/rate-limit-cache.ts +0 -48
- package/src/app-server/rate-limits.ts +0 -583
- package/src/app-server/request.ts +0 -73
- package/src/app-server/run-attempt.ts +0 -4862
- package/src/app-server/session-binding.ts +0 -398
- package/src/app-server/session-history.ts +0 -44
- package/src/app-server/shared-client.ts +0 -289
- package/src/app-server/side-question.ts +0 -1009
- package/src/app-server/test-support.ts +0 -48
- package/src/app-server/thread-lifecycle.ts +0 -959
- package/src/app-server/timeout.ts +0 -9
- package/src/app-server/tool-progress-normalization.ts +0 -77
- package/src/app-server/trajectory.ts +0 -368
- package/src/app-server/transcript-mirror.ts +0 -208
- package/src/app-server/transport-stdio.ts +0 -107
- package/src/app-server/transport-websocket.ts +0 -90
- package/src/app-server/transport.ts +0 -117
- package/src/app-server/user-input-bridge.ts +0 -316
- package/src/app-server/version.ts +0 -4
- package/src/app-server/vision-tools.ts +0 -12
- package/src/command-account.ts +0 -544
- package/src/command-formatters.ts +0 -426
- package/src/command-handlers.ts +0 -2021
- package/src/command-plugins-management.ts +0 -137
- package/src/command-rpc.ts +0 -142
- package/src/commands.ts +0 -65
- package/src/conversation-binding-data.ts +0 -124
- package/src/conversation-binding.ts +0 -561
- package/src/conversation-control.ts +0 -303
- package/src/conversation-turn-collector.ts +0 -186
- package/src/conversation-turn-input.ts +0 -106
- package/src/migration/apply.ts +0 -501
- package/src/migration/helpers.ts +0 -55
- package/src/migration/plan.ts +0 -461
- package/src/migration/provider.ts +0 -41
- package/src/migration/source.ts +0 -643
- package/src/migration/targets.ts +0 -25
- package/src/node-cli-sessions.ts +0 -711
- package/test-api.ts +0 -95
- package/tsconfig.json +0 -16
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import type { PluginCommandContext, PluginCommandResult } from "autobot/plugin-sdk/plugin-entry";
|
|
2
|
-
import { formatCodexDisplayText } from "./command-formatters.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Lightweight read/write surface over the Autobot config file. Plugged in by
|
|
6
|
-
* the command registration site so this module stays decoupled from the
|
|
7
|
-
* concrete `mutateConfigFile` import in tests.
|
|
8
|
-
*/
|
|
9
|
-
export type CodexPluginsManagementIO = {
|
|
10
|
-
readConfig: () => Promise<{
|
|
11
|
-
enabled?: boolean;
|
|
12
|
-
plugins?: Record<string, CodexPluginConfigEntry>;
|
|
13
|
-
}>;
|
|
14
|
-
mutate: (update: (block: CodexPluginsConfigBlock) => void) => Promise<void>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type CodexPluginConfigEntry = {
|
|
18
|
-
enabled?: boolean;
|
|
19
|
-
marketplaceName?: string;
|
|
20
|
-
pluginName?: string;
|
|
21
|
-
allow_destructive_actions?: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type CodexPluginsConfigBlock = {
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
plugins?: Record<string, CodexPluginConfigEntry>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Plugin lifecycle changes (enable/disable) write to autobot.json
|
|
30
|
-
// synchronously. The Codex app-server picks up the new policy when the next
|
|
31
|
-
// thread starts; in-flight conversations keep the old policy until /new or
|
|
32
|
-
// /reset. A full gateway restart is NOT needed.
|
|
33
|
-
const POLICY_REFRESH_HINT =
|
|
34
|
-
"New Codex conversations pick this up automatically. Use /new or /reset to refresh the current one.";
|
|
35
|
-
|
|
36
|
-
export async function handleCodexPluginsSubcommand(
|
|
37
|
-
ctx: PluginCommandContext,
|
|
38
|
-
rest: string[],
|
|
39
|
-
io: CodexPluginsManagementIO,
|
|
40
|
-
): Promise<PluginCommandResult> {
|
|
41
|
-
const [verb = "list", ...args] = rest;
|
|
42
|
-
const normalized = verb.toLowerCase();
|
|
43
|
-
|
|
44
|
-
if (normalized === "list") {
|
|
45
|
-
if (args.length > 0) {
|
|
46
|
-
return { text: "Usage: /codex plugins list" };
|
|
47
|
-
}
|
|
48
|
-
const current = await io.readConfig();
|
|
49
|
-
return {
|
|
50
|
-
text: formatPluginList(current.plugins ?? {}, { globalEnabled: current.enabled === true }),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const target = args[0];
|
|
55
|
-
if (normalized === "enable" || normalized === "disable") {
|
|
56
|
-
if (!target || args.length > 1) {
|
|
57
|
-
return { text: `Usage: /codex plugins ${normalized} <name>` };
|
|
58
|
-
}
|
|
59
|
-
if (!canMutateCodexPlugins(ctx)) {
|
|
60
|
-
return {
|
|
61
|
-
text: `Only an owner or operator.admin gateway client can run /codex plugins ${normalized}.`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const wantEnabled = normalized === "enable";
|
|
65
|
-
const current = (await io.readConfig()).plugins ?? {};
|
|
66
|
-
if (!current[target]) {
|
|
67
|
-
return {
|
|
68
|
-
text: `Codex sub-plugin '${formatCodexDisplayText(target)}' is not configured. Run '/codex plugins list' to see configured plugins.`,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
await io.mutate((block) => {
|
|
72
|
-
if (wantEnabled) {
|
|
73
|
-
block.enabled = true;
|
|
74
|
-
}
|
|
75
|
-
block.plugins ??= {};
|
|
76
|
-
block.plugins[target] = { ...block.plugins[target], enabled: wantEnabled };
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
text: `${formatCodexDisplayText(target)}: ${wantEnabled ? "enabled" : "disabled"} in autobot.json. ${POLICY_REFRESH_HINT}`,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
text: `Unknown /codex plugins subcommand: ${formatCodexDisplayText(verb)}\n\n${buildPluginsHelp()}`,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function canMutateCodexPlugins(ctx: PluginCommandContext): boolean {
|
|
89
|
-
if (ctx.senderIsOwner === true) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
return ctx.gatewayClientScopes?.includes("operator.admin") === true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function buildPluginsHelp(): string {
|
|
96
|
-
return [
|
|
97
|
-
"Codex sub-plugin management (writes only to ~/.autobot/autobot.json, never to ~/.codex/config.toml):",
|
|
98
|
-
"- /codex plugins (alias for list)",
|
|
99
|
-
"- /codex plugins list show all configured Codex sub-plugins",
|
|
100
|
-
"- /codex plugins enable <name> enable a configured sub-plugin",
|
|
101
|
-
"- /codex plugins disable <name> disable a configured sub-plugin",
|
|
102
|
-
].join("\n");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function formatPluginList(
|
|
106
|
-
plugins: Record<string, CodexPluginConfigEntry>,
|
|
107
|
-
options: { globalEnabled?: boolean } = {},
|
|
108
|
-
): string {
|
|
109
|
-
const globalEnabled = options.globalEnabled === true;
|
|
110
|
-
const keys = Object.keys(plugins).toSorted();
|
|
111
|
-
if (keys.length === 0) {
|
|
112
|
-
return "No Codex sub-plugins configured under plugins.entries.codex.config.codexPlugins.plugins";
|
|
113
|
-
}
|
|
114
|
-
const rows = keys.map((key) => {
|
|
115
|
-
const entry = plugins[key] ?? {};
|
|
116
|
-
const state = globalEnabled && entry.enabled !== false ? "ON " : "OFF";
|
|
117
|
-
const displayKey = formatCodexDisplayText(key);
|
|
118
|
-
const pluginName = formatCodexDisplayText(entry.pluginName ?? key);
|
|
119
|
-
const marketplace = formatCodexDisplayText(entry.marketplaceName ?? "?");
|
|
120
|
-
return { displayKey, state, pluginName, marketplace };
|
|
121
|
-
});
|
|
122
|
-
const keyW = Math.max(...rows.map((r) => r.displayKey.length));
|
|
123
|
-
const pluginW = Math.max(...rows.map((r) => r.pluginName.length));
|
|
124
|
-
return [
|
|
125
|
-
"Codex sub-plugins in Autobot config (~/.autobot/autobot.json):",
|
|
126
|
-
"",
|
|
127
|
-
...rows.map(
|
|
128
|
-
(r) =>
|
|
129
|
-
` ${r.state} ${r.displayKey.padEnd(keyW)} ${r.pluginName.padEnd(pluginW)} [${r.marketplace}]`,
|
|
130
|
-
),
|
|
131
|
-
"",
|
|
132
|
-
...(globalEnabled
|
|
133
|
-
? []
|
|
134
|
-
: ["Global codexPlugins.enabled is off; configured sub-plugins are inactive.", ""]),
|
|
135
|
-
"New Codex conversations pick up policy changes automatically; /new or /reset to refresh the current one.",
|
|
136
|
-
].join("\n");
|
|
137
|
-
}
|
package/src/command-rpc.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { resolveCodexAppServerAuthProfileIdForAgent } from "./app-server/auth-bridge.js";
|
|
2
|
-
import {
|
|
3
|
-
CODEX_CONTROL_METHODS,
|
|
4
|
-
describeControlFailure,
|
|
5
|
-
type CodexControlMethod,
|
|
6
|
-
} from "./app-server/capabilities.js";
|
|
7
|
-
import { resolveCodexAppServerRuntimeOptions } from "./app-server/config.js";
|
|
8
|
-
import { listCodexAppServerModels } from "./app-server/models.js";
|
|
9
|
-
import type {
|
|
10
|
-
CodexAppServerRequestMethod,
|
|
11
|
-
CodexAppServerRequestParams,
|
|
12
|
-
CodexAppServerRequestResult,
|
|
13
|
-
JsonValue,
|
|
14
|
-
} from "./app-server/protocol.js";
|
|
15
|
-
import { requestCodexAppServerJson } from "./app-server/request.js";
|
|
16
|
-
|
|
17
|
-
export type SafeValue<T> = { ok: true; value: T } | { ok: false; error: string };
|
|
18
|
-
|
|
19
|
-
type AuthProfileOrderConfig = Parameters<
|
|
20
|
-
typeof resolveCodexAppServerAuthProfileIdForAgent
|
|
21
|
-
>[0]["config"];
|
|
22
|
-
|
|
23
|
-
export type CodexControlRequestOptions = {
|
|
24
|
-
config?: AuthProfileOrderConfig;
|
|
25
|
-
authProfileId?: string;
|
|
26
|
-
agentDir?: string;
|
|
27
|
-
isolated?: boolean;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export function requestOptions(
|
|
31
|
-
pluginConfig: unknown,
|
|
32
|
-
limit: number,
|
|
33
|
-
config?: AuthProfileOrderConfig,
|
|
34
|
-
) {
|
|
35
|
-
const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig });
|
|
36
|
-
return {
|
|
37
|
-
limit,
|
|
38
|
-
timeoutMs: runtime.requestTimeoutMs,
|
|
39
|
-
startOptions: runtime.start,
|
|
40
|
-
config,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type CodexControlRequestMethod = CodexControlMethod & CodexAppServerRequestMethod;
|
|
45
|
-
|
|
46
|
-
export function codexControlRequest<M extends CodexControlRequestMethod>(
|
|
47
|
-
pluginConfig: unknown,
|
|
48
|
-
method: M,
|
|
49
|
-
requestParams: CodexAppServerRequestParams<M>,
|
|
50
|
-
options?: CodexControlRequestOptions,
|
|
51
|
-
): Promise<CodexAppServerRequestResult<M>>;
|
|
52
|
-
export function codexControlRequest(
|
|
53
|
-
pluginConfig: unknown,
|
|
54
|
-
method: CodexControlMethod,
|
|
55
|
-
requestParams?: JsonValue,
|
|
56
|
-
options?: CodexControlRequestOptions,
|
|
57
|
-
): Promise<JsonValue | undefined>;
|
|
58
|
-
export async function codexControlRequest(
|
|
59
|
-
pluginConfig: unknown,
|
|
60
|
-
method: CodexControlMethod,
|
|
61
|
-
requestParams?: unknown,
|
|
62
|
-
options: CodexControlRequestOptions = {},
|
|
63
|
-
) {
|
|
64
|
-
const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig });
|
|
65
|
-
return await requestCodexAppServerJson({
|
|
66
|
-
method,
|
|
67
|
-
requestParams,
|
|
68
|
-
timeoutMs: runtime.requestTimeoutMs,
|
|
69
|
-
startOptions: runtime.start,
|
|
70
|
-
config: options.config,
|
|
71
|
-
authProfileId: options.authProfileId,
|
|
72
|
-
agentDir: options.agentDir,
|
|
73
|
-
isolated: options.isolated,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function safeCodexControlRequest<M extends CodexControlRequestMethod>(
|
|
78
|
-
pluginConfig: unknown,
|
|
79
|
-
method: M,
|
|
80
|
-
requestParams: CodexAppServerRequestParams<M>,
|
|
81
|
-
options?: CodexControlRequestOptions,
|
|
82
|
-
): Promise<SafeValue<CodexAppServerRequestResult<M>>>;
|
|
83
|
-
export function safeCodexControlRequest(
|
|
84
|
-
pluginConfig: unknown,
|
|
85
|
-
method: CodexControlMethod,
|
|
86
|
-
requestParams?: JsonValue,
|
|
87
|
-
options?: CodexControlRequestOptions,
|
|
88
|
-
): Promise<SafeValue<JsonValue | undefined>>;
|
|
89
|
-
export async function safeCodexControlRequest(
|
|
90
|
-
pluginConfig: unknown,
|
|
91
|
-
method: CodexControlMethod,
|
|
92
|
-
requestParams?: unknown,
|
|
93
|
-
options: CodexControlRequestOptions = {},
|
|
94
|
-
) {
|
|
95
|
-
return await safeValue(
|
|
96
|
-
async () =>
|
|
97
|
-
await codexControlRequest(pluginConfig, method, requestParams as JsonValue, options),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async function safeCodexModelList(
|
|
102
|
-
pluginConfig: unknown,
|
|
103
|
-
limit: number,
|
|
104
|
-
config?: AuthProfileOrderConfig,
|
|
105
|
-
) {
|
|
106
|
-
return await safeValue(
|
|
107
|
-
async () => await listCodexAppServerModels(requestOptions(pluginConfig, limit, config)),
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export async function readCodexStatusProbes(
|
|
112
|
-
pluginConfig: unknown,
|
|
113
|
-
config?: AuthProfileOrderConfig,
|
|
114
|
-
) {
|
|
115
|
-
const [models, account, limits, mcps, skills] = await Promise.all([
|
|
116
|
-
safeCodexModelList(pluginConfig, 20, config),
|
|
117
|
-
safeCodexControlRequest(
|
|
118
|
-
pluginConfig,
|
|
119
|
-
CODEX_CONTROL_METHODS.account,
|
|
120
|
-
{ refreshToken: false },
|
|
121
|
-
{ config },
|
|
122
|
-
),
|
|
123
|
-
safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.rateLimits, undefined, { config }),
|
|
124
|
-
safeCodexControlRequest(
|
|
125
|
-
pluginConfig,
|
|
126
|
-
CODEX_CONTROL_METHODS.listMcpServers,
|
|
127
|
-
{ limit: 100 },
|
|
128
|
-
{ config },
|
|
129
|
-
),
|
|
130
|
-
safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.listSkills, {}, { config }),
|
|
131
|
-
]);
|
|
132
|
-
|
|
133
|
-
return { models, account, limits, mcps, skills };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export async function safeValue<T>(read: () => Promise<T>): Promise<SafeValue<T>> {
|
|
137
|
-
try {
|
|
138
|
-
return { ok: true, value: await read() };
|
|
139
|
-
} catch (error) {
|
|
140
|
-
return { ok: false, error: describeControlFailure(error) };
|
|
141
|
-
}
|
|
142
|
-
}
|
package/src/commands.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AutoBotPluginCommandDefinition,
|
|
3
|
-
PluginCommandContext,
|
|
4
|
-
PluginCommandResult,
|
|
5
|
-
} from "autobot/plugin-sdk/plugin-entry";
|
|
6
|
-
import { describeControlFailure } from "./app-server/capabilities.js";
|
|
7
|
-
import { formatCodexDisplayText } from "./command-formatters.js";
|
|
8
|
-
import type { CodexCommandDeps } from "./command-handlers.js";
|
|
9
|
-
|
|
10
|
-
type CodexCommandOptions = {
|
|
11
|
-
pluginConfig?: unknown;
|
|
12
|
-
deps?: Partial<CodexCommandDeps>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type CodexSubcommandHandler = (
|
|
16
|
-
ctx: PluginCommandContext,
|
|
17
|
-
options: CodexCommandOptions,
|
|
18
|
-
) => Promise<PluginCommandResult>;
|
|
19
|
-
|
|
20
|
-
type CodexCommandInternalOptions = CodexCommandOptions & {
|
|
21
|
-
loadSubcommandHandler?: () => Promise<CodexSubcommandHandler>;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function createCodexCommand(options: CodexCommandOptions): AutoBotPluginCommandDefinition {
|
|
25
|
-
return {
|
|
26
|
-
name: "codex",
|
|
27
|
-
description: "Inspect and control the Codex app-server harness",
|
|
28
|
-
ownership: "reserved",
|
|
29
|
-
agentPromptGuidance: [
|
|
30
|
-
{
|
|
31
|
-
text: "Native Codex app-server plugin is available (`/codex ...`). For Codex bind/control/thread/resume/steer/stop requests, prefer `/codex bind`, `/codex threads`, `/codex resume`, `/codex steer`, and `/codex stop` over ACP.",
|
|
32
|
-
surfaces: ["pi_main"],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
text: "Use ACP for Codex only when the user explicitly asks for ACP/acpx or wants to test the ACP path.",
|
|
36
|
-
surfaces: ["pi_main"],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
acceptsArgs: true,
|
|
40
|
-
requireAuth: true,
|
|
41
|
-
handler: (ctx) => handleCodexCommand(ctx, options),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export async function handleCodexCommand(
|
|
46
|
-
ctx: PluginCommandContext,
|
|
47
|
-
options: CodexCommandInternalOptions = {},
|
|
48
|
-
): Promise<PluginCommandResult> {
|
|
49
|
-
const { loadSubcommandHandler, ...subcommandOptions } = options;
|
|
50
|
-
try {
|
|
51
|
-
const handleCodexSubcommand = loadSubcommandHandler
|
|
52
|
-
? await loadSubcommandHandler()
|
|
53
|
-
: await loadDefaultCodexSubcommandHandler();
|
|
54
|
-
return await handleCodexSubcommand(ctx, subcommandOptions);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return {
|
|
57
|
-
text: `Codex command failed: ${formatCodexDisplayText(describeControlFailure(error))}`,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function loadDefaultCodexSubcommandHandler(): Promise<CodexSubcommandHandler> {
|
|
63
|
-
const { handleCodexSubcommand } = await import("./command-handlers.js");
|
|
64
|
-
return handleCodexSubcommand;
|
|
65
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import type { PluginConversationBinding } from "autobot/plugin-sdk/plugin-entry";
|
|
3
|
-
|
|
4
|
-
const BINDING_DATA_VERSION = 1;
|
|
5
|
-
|
|
6
|
-
export type CodexAppServerConversationBindingData = {
|
|
7
|
-
kind: "codex-app-server-session";
|
|
8
|
-
version: 1;
|
|
9
|
-
sessionFile: string;
|
|
10
|
-
workspaceDir: string;
|
|
11
|
-
agentDir?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type CodexCliNodeConversationBindingData = {
|
|
15
|
-
kind: "codex-cli-node-session";
|
|
16
|
-
version: 1;
|
|
17
|
-
nodeId: string;
|
|
18
|
-
sessionId: string;
|
|
19
|
-
cwd?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type CodexConversationBindingData =
|
|
23
|
-
| CodexAppServerConversationBindingData
|
|
24
|
-
| CodexCliNodeConversationBindingData;
|
|
25
|
-
|
|
26
|
-
export function createCodexConversationBindingData(params: {
|
|
27
|
-
sessionFile: string;
|
|
28
|
-
workspaceDir: string;
|
|
29
|
-
agentDir?: string;
|
|
30
|
-
}): CodexAppServerConversationBindingData {
|
|
31
|
-
const agentDir = params.agentDir?.trim();
|
|
32
|
-
return {
|
|
33
|
-
kind: "codex-app-server-session",
|
|
34
|
-
version: BINDING_DATA_VERSION,
|
|
35
|
-
sessionFile: params.sessionFile,
|
|
36
|
-
workspaceDir: params.workspaceDir,
|
|
37
|
-
...(agentDir ? { agentDir } : {}),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function createCodexCliNodeConversationBindingData(params: {
|
|
42
|
-
nodeId: string;
|
|
43
|
-
sessionId: string;
|
|
44
|
-
cwd?: string;
|
|
45
|
-
}): CodexCliNodeConversationBindingData {
|
|
46
|
-
const cwd = params.cwd?.trim();
|
|
47
|
-
return {
|
|
48
|
-
kind: "codex-cli-node-session",
|
|
49
|
-
version: BINDING_DATA_VERSION,
|
|
50
|
-
nodeId: params.nodeId,
|
|
51
|
-
sessionId: params.sessionId,
|
|
52
|
-
...(cwd ? { cwd } : {}),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function readCodexConversationBindingData(
|
|
57
|
-
binding: PluginConversationBinding | null | undefined,
|
|
58
|
-
): CodexConversationBindingData | undefined {
|
|
59
|
-
const data = binding?.data;
|
|
60
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
return readCodexConversationBindingDataRecord(data);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function readCodexConversationBindingDataRecord(
|
|
67
|
-
data: Record<string, unknown>,
|
|
68
|
-
): CodexConversationBindingData | undefined {
|
|
69
|
-
if (data.kind === "codex-cli-node-session") {
|
|
70
|
-
if (
|
|
71
|
-
data.version !== BINDING_DATA_VERSION ||
|
|
72
|
-
typeof data.nodeId !== "string" ||
|
|
73
|
-
!data.nodeId.trim() ||
|
|
74
|
-
typeof data.sessionId !== "string" ||
|
|
75
|
-
!data.sessionId.trim()
|
|
76
|
-
) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
kind: "codex-cli-node-session",
|
|
81
|
-
version: BINDING_DATA_VERSION,
|
|
82
|
-
nodeId: data.nodeId.trim(),
|
|
83
|
-
sessionId: data.sessionId.trim(),
|
|
84
|
-
cwd: typeof data.cwd === "string" && data.cwd.trim() ? data.cwd.trim() : undefined,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (data.kind !== "codex-app-server-session") {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
if (
|
|
91
|
-
data.version !== BINDING_DATA_VERSION ||
|
|
92
|
-
typeof data.sessionFile !== "string" ||
|
|
93
|
-
!data.sessionFile.trim()
|
|
94
|
-
) {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
kind: "codex-app-server-session",
|
|
99
|
-
version: BINDING_DATA_VERSION,
|
|
100
|
-
sessionFile: data.sessionFile,
|
|
101
|
-
workspaceDir:
|
|
102
|
-
typeof data.workspaceDir === "string" && data.workspaceDir.trim()
|
|
103
|
-
? data.workspaceDir
|
|
104
|
-
: process.cwd(),
|
|
105
|
-
agentDir: typeof data.agentDir === "string" && data.agentDir.trim() ? data.agentDir : undefined,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function resolveCodexDefaultWorkspaceDir(pluginConfig: unknown): string {
|
|
110
|
-
const appServer = readRecord(readRecord(pluginConfig)?.appServer);
|
|
111
|
-
const configured = readString(appServer, "defaultWorkspaceDir");
|
|
112
|
-
return configured ?? process.cwd();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function readRecord(value: unknown): Record<string, unknown> | undefined {
|
|
116
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
117
|
-
? (value as Record<string, unknown>)
|
|
118
|
-
: undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function readString(record: Record<string, unknown> | undefined, key: string) {
|
|
122
|
-
const value = record?.[key];
|
|
123
|
-
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
124
|
-
}
|