codex-multi-auth 2.16.0 → 2.17.2
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/.codex-plugin/plugin.json +9 -9
- package/LICENSE +21 -21
- package/README.md +487 -463
- package/assets/codex-multi-auth-icon.svg +39 -39
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +31 -31
- package/config/codex-legacy.json +1221 -1221
- package/config/codex-modern.json +423 -423
- package/config/minimal-codex.json +15 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/lib/account-policy.d.ts +4 -0
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +8 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
- package/dist/lib/accounts/rate-limits.js +2 -0
- package/dist/lib/accounts.d.ts +15 -3
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +231 -30
- package/dist/lib/api-route-store.d.ts +24 -0
- package/dist/lib/api-route-store.d.ts.map +1 -0
- package/dist/lib/api-route-store.js +145 -0
- package/dist/lib/auth/account-access.d.ts +115 -0
- package/dist/lib/auth/account-access.d.ts.map +1 -0
- package/dist/lib/auth/account-access.js +214 -0
- package/dist/lib/auth/token-utils.d.ts +54 -1
- package/dist/lib/auth/token-utils.d.ts.map +1 -1
- package/dist/lib/auth/token-utils.js +92 -7
- package/dist/lib/cli.d.ts +1 -1
- package/dist/lib/cli.d.ts.map +1 -1
- package/dist/lib/cli.js +4 -0
- package/dist/lib/codex-cli/state.d.ts +7 -0
- package/dist/lib/codex-cli/state.d.ts.map +1 -1
- package/dist/lib/codex-cli/state.js +18 -0
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +60 -8
- package/dist/lib/codex-manager/account-manager-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-manager-commands.js +1 -0
- package/dist/lib/codex-manager/account-pool-write.d.ts +3 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-pool-write.js +4 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts +14 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts.map +1 -0
- package/dist/lib/codex-manager/api-login-menu.js +224 -0
- package/dist/lib/codex-manager/commands/account.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/account.js +27 -0
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +6 -2
- package/dist/lib/codex-manager/commands/check.d.ts +7 -1
- package/dist/lib/codex-manager/commands/check.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/check.js +24 -3
- package/dist/lib/codex-manager/commands/forecast.d.ts +1 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +7 -3
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +5 -1
- package/dist/lib/codex-manager/commands/resets.d.ts +2 -0
- package/dist/lib/codex-manager/commands/resets.d.ts.map +1 -0
- package/dist/lib/codex-manager/commands/resets.js +67 -0
- package/dist/lib/codex-manager/commands/rotation.d.ts +2 -2
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +63 -12
- package/dist/lib/codex-manager/commands/status.d.ts +12 -1
- package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/status.js +166 -22
- package/dist/lib/codex-manager/commands/uninstall.js +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.js +3 -2
- package/dist/lib/codex-manager/health-check.d.ts +3 -0
- package/dist/lib/codex-manager/health-check.d.ts.map +1 -1
- package/dist/lib/codex-manager/health-check.js +57 -7
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +4 -2
- package/dist/lib/codex-manager/login-flow.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-flow.js +69 -7
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-menu-data.js +21 -8
- package/dist/lib/codex-manager/login-oauth.d.ts +3 -0
- package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-oauth.js +6 -1
- package/dist/lib/codex-manager/login-workspace-choice.d.ts +11 -0
- package/dist/lib/codex-manager/login-workspace-choice.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-workspace-choice.js +37 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -1
- package/dist/lib/codex-manager/persist-selected-account.js +2 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
- package/dist/lib/codex-manager/repair-commands.d.ts +13 -0
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +144 -9
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +25 -6
- package/dist/lib/concurrency.d.ts +3 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +31 -0
- package/dist/lib/context-budget-response.js +8 -8
- package/dist/lib/context-overflow.js +10 -10
- package/dist/lib/model-route-policy.d.ts +52 -0
- package/dist/lib/model-route-policy.d.ts.map +1 -0
- package/dist/lib/model-route-policy.js +159 -0
- package/dist/lib/oauth-success.html +125 -125
- package/dist/lib/policy/runtime-policy.d.ts +1 -0
- package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
- package/dist/lib/policy/runtime-policy.js +3 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts +2 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -1
- package/dist/lib/preemptive-quota-scheduler.js +4 -0
- package/dist/lib/prompts/codex-host-bridge.js +138 -138
- package/dist/lib/prompts/codex.js +79 -79
- package/dist/lib/quota-cache.d.ts +7 -3
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +91 -59
- package/dist/lib/quota-probe.d.ts +5 -0
- package/dist/lib/quota-probe.d.ts.map +1 -1
- package/dist/lib/quota-probe.js +26 -2
- package/dist/lib/quota-readiness.d.ts +7 -2
- package/dist/lib/quota-readiness.d.ts.map +1 -1
- package/dist/lib/quota-readiness.js +25 -4
- package/dist/lib/request/client-cancellation.d.ts +5 -0
- package/dist/lib/request/client-cancellation.d.ts.map +1 -0
- package/dist/lib/request/client-cancellation.js +7 -0
- package/dist/lib/request/response-outcome.d.ts +25 -0
- package/dist/lib/request/response-outcome.d.ts.map +1 -0
- package/dist/lib/request/response-outcome.js +49 -0
- package/dist/lib/request/stream-failover-runtime.d.ts +2 -1
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.js +29 -10
- package/dist/lib/runtime/account-check.d.ts.map +1 -1
- package/dist/lib/runtime/account-check.js +2 -8
- package/dist/lib/runtime/account-model-catalog.d.ts +64 -0
- package/dist/lib/runtime/account-model-catalog.d.ts.map +1 -0
- package/dist/lib/runtime/account-model-catalog.js +154 -0
- package/dist/lib/runtime/account-pool.d.ts +3 -1
- package/dist/lib/runtime/account-pool.d.ts.map +1 -1
- package/dist/lib/runtime/account-pool.js +4 -0
- package/dist/lib/runtime/account-reset-credits.d.ts +42 -0
- package/dist/lib/runtime/account-reset-credits.d.ts.map +1 -0
- package/dist/lib/runtime/account-reset-credits.js +82 -0
- package/dist/lib/runtime/api-model-capabilities.d.ts +30 -0
- package/dist/lib/runtime/api-model-capabilities.d.ts.map +1 -0
- package/dist/lib/runtime/api-model-capabilities.js +434 -0
- package/dist/lib/runtime/api-model-runtime.d.ts +42 -0
- package/dist/lib/runtime/api-model-runtime.d.ts.map +1 -0
- package/dist/lib/runtime/api-model-runtime.js +358 -0
- package/dist/lib/runtime/app-bind.d.ts +19 -1
- package/dist/lib/runtime/app-bind.d.ts.map +1 -1
- package/dist/lib/runtime/app-bind.js +89 -11
- package/dist/lib/runtime/automatic-account-checks.d.ts +35 -0
- package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -0
- package/dist/lib/runtime/automatic-account-checks.js +140 -0
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +7 -0
- package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -0
- package/dist/lib/runtime/automatic-subscription-checks.js +54 -0
- package/dist/lib/runtime/catalog-capabilities.d.ts +8 -0
- package/dist/lib/runtime/catalog-capabilities.d.ts.map +1 -0
- package/dist/lib/runtime/catalog-capabilities.js +61 -0
- package/dist/lib/runtime/inference-activity.d.ts +15 -0
- package/dist/lib/runtime/inference-activity.d.ts.map +1 -0
- package/dist/lib/runtime/inference-activity.js +95 -0
- package/dist/lib/runtime/model-discovery-status.d.ts +100 -0
- package/dist/lib/runtime/model-discovery-status.d.ts.map +1 -0
- package/dist/lib/runtime/model-discovery-status.js +387 -0
- package/dist/lib/runtime/native-account-storage.d.ts +11 -0
- package/dist/lib/runtime/native-account-storage.d.ts.map +1 -0
- package/dist/lib/runtime/native-account-storage.js +50 -0
- package/dist/lib/runtime/native-account-sync.d.ts +19 -0
- package/dist/lib/runtime/native-account-sync.d.ts.map +1 -0
- package/dist/lib/runtime/native-account-sync.js +62 -0
- package/dist/lib/runtime/native-binding-lock.d.ts +3 -0
- package/dist/lib/runtime/native-binding-lock.d.ts.map +1 -0
- package/dist/lib/runtime/native-binding-lock.js +5 -0
- package/dist/lib/runtime/native-client-auth.d.ts +3 -0
- package/dist/lib/runtime/native-client-auth.d.ts.map +1 -0
- package/dist/lib/runtime/native-client-auth.js +42 -0
- package/dist/lib/runtime/native-provider-config.d.ts +4 -0
- package/dist/lib/runtime/native-provider-config.d.ts.map +1 -0
- package/dist/lib/runtime/native-provider-config.js +52 -0
- package/dist/lib/runtime/native-rate-limits.d.ts +18 -0
- package/dist/lib/runtime/native-rate-limits.d.ts.map +1 -0
- package/dist/lib/runtime/native-rate-limits.js +135 -0
- package/dist/lib/runtime/reset-credit-routing.d.ts +41 -0
- package/dist/lib/runtime/reset-credit-routing.d.ts.map +1 -0
- package/dist/lib/runtime/reset-credit-routing.js +66 -0
- package/dist/lib/runtime/reset-credits.d.ts +101 -0
- package/dist/lib/runtime/reset-credits.d.ts.map +1 -0
- package/dist/lib/runtime/reset-credits.js +162 -0
- package/dist/lib/runtime/response-output-history.d.ts +17 -0
- package/dist/lib/runtime/response-output-history.d.ts.map +1 -0
- package/dist/lib/runtime/response-output-history.js +85 -0
- package/dist/lib/runtime/responses-websocket.d.ts +31 -0
- package/dist/lib/runtime/responses-websocket.d.ts.map +1 -0
- package/dist/lib/runtime/responses-websocket.js +636 -0
- package/dist/lib/runtime/resume-picker.d.ts +41 -0
- package/dist/lib/runtime/resume-picker.d.ts.map +1 -0
- package/dist/lib/runtime/resume-picker.js +169 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts +6 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-account-selection.js +63 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts +33 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +18 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-capability-failures.d.ts +14 -0
- package/dist/lib/runtime/runtime-capability-failures.d.ts.map +1 -0
- package/dist/lib/runtime/runtime-capability-failures.js +76 -0
- package/dist/lib/runtime/runtime-observability.d.ts +7 -0
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +42 -2
- package/dist/lib/runtime/subscription-first-use.d.ts +10 -0
- package/dist/lib/runtime/subscription-first-use.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-first-use.js +64 -0
- package/dist/lib/runtime/subscription-quota-event.d.ts +6 -0
- package/dist/lib/runtime/subscription-quota-event.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-quota-event.js +31 -0
- package/dist/lib/runtime/subscription-quota-order.d.ts +17 -0
- package/dist/lib/runtime/subscription-quota-order.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-quota-order.js +31 -0
- package/dist/lib/runtime/workspace-model-scopes.d.ts +15 -0
- package/dist/lib/runtime/workspace-model-scopes.d.ts.map +1 -0
- package/dist/lib/runtime/workspace-model-scopes.js +34 -0
- package/dist/lib/runtime-constants.d.ts +3 -0
- package/dist/lib/runtime-constants.d.ts.map +1 -1
- package/dist/lib/runtime-constants.js +5 -0
- package/dist/lib/runtime-paths.d.ts.map +1 -1
- package/dist/lib/runtime-paths.js +4 -1
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +852 -42
- package/dist/lib/schemas.d.ts +20 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +3 -0
- package/dist/lib/storage/credential-sidecars.d.ts +13 -0
- package/dist/lib/storage/credential-sidecars.d.ts.map +1 -0
- package/dist/lib/storage/credential-sidecars.js +52 -0
- package/dist/lib/storage/file-lock.d.ts +9 -0
- package/dist/lib/storage/file-lock.d.ts.map +1 -0
- package/dist/lib/storage/file-lock.js +186 -0
- package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage.js +12 -0
- package/dist/lib/storage/path-state.d.ts +2 -0
- package/dist/lib/storage/path-state.d.ts.map +1 -1
- package/dist/lib/storage/path-state.js +9 -0
- package/dist/lib/storage/paths.js +4 -4
- package/dist/lib/storage/pending-auth.d.ts +18 -0
- package/dist/lib/storage/pending-auth.d.ts.map +1 -0
- package/dist/lib/storage/pending-auth.js +155 -0
- package/dist/lib/storage/public-types.d.ts +13 -0
- package/dist/lib/storage/public-types.d.ts.map +1 -1
- package/dist/lib/storage/record-identity.d.ts +16 -0
- package/dist/lib/storage/record-identity.d.ts.map +1 -0
- package/dist/lib/storage/record-identity.js +16 -0
- package/dist/lib/storage/snapshot-merge.d.ts +16 -0
- package/dist/lib/storage/snapshot-merge.d.ts.map +1 -0
- package/dist/lib/storage/snapshot-merge.js +206 -0
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +5 -4
- package/dist/lib/storage.d.ts +6 -0
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +77 -7
- package/dist/lib/ui/auth-menu-builder.d.ts +2 -0
- package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu-builder.js +1 -0
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +1 -0
- package/dist/lib/ui/check-progress.d.ts +8 -0
- package/dist/lib/ui/check-progress.d.ts.map +1 -0
- package/dist/lib/ui/check-progress.js +30 -0
- package/dist/lib/ui/format.d.ts +3 -1
- package/dist/lib/ui/format.d.ts.map +1 -1
- package/dist/lib/ui/format.js +8 -0
- package/dist/lib/ui/ui-copy.d.ts +2 -2
- package/dist/lib/ui/ui-copy.js +2 -2
- package/dist/lib/usage/pricing.js +2 -2
- package/dist/lib/usage/usage-extraction.d.ts +3 -1
- package/dist/lib/usage/usage-extraction.d.ts.map +1 -1
- package/dist/lib/usage/usage-extraction.js +46 -9
- package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
- package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
- package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
- package/node_modules/@codex-ai/plugin/package.json +9 -9
- package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
- package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
- package/node_modules/@codex-ai/sdk/package.json +8 -8
- package/package.json +200 -197
- package/scripts/codex-app-launcher.js +653 -653
- package/scripts/codex-app-router.js +373 -366
- package/scripts/codex-bin-resolver.js +313 -281
- package/scripts/codex-multi-auth.js +59 -59
- package/scripts/codex-routing.js +62 -61
- package/scripts/codex.js +6642 -6564
- package/scripts/install-codex-auth-utils.js +213 -213
- package/scripts/mcodex.js +367 -367
- package/scripts/postinstall.js +114 -114
- package/scripts/preuninstall.js +265 -265
- package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
- package/vendor/codex-ai-plugin/dist/index.js +2 -2
- package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
- package/vendor/codex-ai-plugin/dist/tool.js +29 -29
- package/vendor/codex-ai-plugin/package.json +9 -9
- package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
- package/vendor/codex-ai-sdk/dist/index.js +2 -2
- package/vendor/codex-ai-sdk/package.json +8 -8
package/scripts/preuninstall.js
CHANGED
|
@@ -1,265 +1,265 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @ts-check
|
|
4
|
-
|
|
5
|
-
import { readFile, writeFile, rm } from "node:fs/promises";
|
|
6
|
-
import { resolve } from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import process from "node:process";
|
|
9
|
-
import {
|
|
10
|
-
isCiEnvironment,
|
|
11
|
-
resolveInstallPaths,
|
|
12
|
-
removePluginFromList,
|
|
13
|
-
withFileOperationRetry,
|
|
14
|
-
} from "./install-codex-auth-utils.js";
|
|
15
|
-
|
|
16
|
-
async function loadAppBindModule() {
|
|
17
|
-
try {
|
|
18
|
-
return await import("../dist/lib/runtime/app-bind.js");
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (
|
|
21
|
-
error &&
|
|
22
|
-
typeof error === "object" &&
|
|
23
|
-
"code" in error &&
|
|
24
|
-
error.code === "ERR_MODULE_NOT_FOUND"
|
|
25
|
-
) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function defaultPreuninstallLog(message) {
|
|
33
|
-
console.error(`codex-multi-auth: ${message}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {{
|
|
38
|
-
* unbindCodexApp?: (dryRun: boolean) => Promise<void>,
|
|
39
|
-
* removeLauncher?: (options: { dryRun: boolean, log: (m: string) => void }) => Promise<void>,
|
|
40
|
-
* removePluginFromConfig?: (dryRun: boolean, log: (m: string) => void) => Promise<{ bunLockState: "safe" | "uncertain" }>,
|
|
41
|
-
* clearCache?: (dryRun: boolean, log: (m: string) => void, bunLockSafe: boolean) => Promise<void>,
|
|
42
|
-
* log?: (message: string) => void,
|
|
43
|
-
* env?: NodeJS.ProcessEnv,
|
|
44
|
-
* home?: string,
|
|
45
|
-
* dryRun?: boolean,
|
|
46
|
-
* }} [deps]
|
|
47
|
-
*/
|
|
48
|
-
export async function runPreuninstallCleanup(deps = {}) {
|
|
49
|
-
const log = deps.log ?? defaultPreuninstallLog;
|
|
50
|
-
const env = deps.env ?? process.env;
|
|
51
|
-
const home =
|
|
52
|
-
deps.home ??
|
|
53
|
-
(deps.env
|
|
54
|
-
? env.HOME || env.USERPROFILE || ""
|
|
55
|
-
: undefined);
|
|
56
|
-
const dryRun = deps.dryRun ?? process.argv.includes("--dry-run");
|
|
57
|
-
|
|
58
|
-
if (isCiEnvironment(env)) {
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** @type {"safe" | "uncertain"} */
|
|
63
|
-
let bunLockState = "uncertain";
|
|
64
|
-
|
|
65
|
-
// Unbind Codex app runtime rotation (reverses install-time/first-run bind)
|
|
66
|
-
try {
|
|
67
|
-
if (deps.unbindCodexApp) {
|
|
68
|
-
await deps.unbindCodexApp(dryRun);
|
|
69
|
-
} else {
|
|
70
|
-
const appBindModule = await loadAppBindModule();
|
|
71
|
-
if (
|
|
72
|
-
appBindModule &&
|
|
73
|
-
typeof appBindModule.unbindCodexAppRuntimeRotation === "function"
|
|
74
|
-
) {
|
|
75
|
-
if (dryRun) {
|
|
76
|
-
log("[dry-run] Would unbind Codex app runtime rotation");
|
|
77
|
-
} else {
|
|
78
|
-
await appBindModule.unbindCodexAppRuntimeRotation();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} catch (error) {
|
|
83
|
-
log(
|
|
84
|
-
`app unbind skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Remove OS-level launcher (reverses install-time/first-run launcher install)
|
|
89
|
-
try {
|
|
90
|
-
if (deps.removeLauncher) {
|
|
91
|
-
await deps.removeLauncher({ dryRun, log });
|
|
92
|
-
} else {
|
|
93
|
-
const launcherModule = await import("./codex-app-launcher.js");
|
|
94
|
-
if (typeof launcherModule.installCodexAppLauncher === "function") {
|
|
95
|
-
await launcherModule.installCodexAppLauncher({ remove: true, dryRun, log });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
} catch (error) {
|
|
99
|
-
log(
|
|
100
|
-
`launcher removal skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Remove plugin entry from Codex.json and track whether we're certain that
|
|
105
|
-
// no other plugins remain. bun.lock is shared across all Codex plugins, so
|
|
106
|
-
// it's only safe to delete when:
|
|
107
|
-
// - File ENOENT → safe (nothing to protect)
|
|
108
|
-
// - Parse error / read fail → uncertain (be conservative)
|
|
109
|
-
// - File ok, no plugins[] → uncertain (we don't know what's installed)
|
|
110
|
-
// - File ok, plugins[]=[] → safe
|
|
111
|
-
// - File ok, plugins[]≠[] → uncertain
|
|
112
|
-
try {
|
|
113
|
-
if (deps.removePluginFromConfig) {
|
|
114
|
-
const result = await deps.removePluginFromConfig(dryRun, log);
|
|
115
|
-
if (result && typeof result === "object" && "bunLockState" in result) {
|
|
116
|
-
bunLockState = result.bunLockState === "safe" ? "safe" : "uncertain";
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
const paths = resolveInstallPaths(
|
|
120
|
-
process.platform,
|
|
121
|
-
env,
|
|
122
|
-
home || undefined,
|
|
123
|
-
);
|
|
124
|
-
try {
|
|
125
|
-
const raw = await withFileOperationRetry(() =>
|
|
126
|
-
readFile(paths.configPath, "utf8"),
|
|
127
|
-
);
|
|
128
|
-
const config = JSON.parse(raw);
|
|
129
|
-
if (Array.isArray(config.plugins)) {
|
|
130
|
-
const next = removePluginFromList(config.plugins);
|
|
131
|
-
bunLockState = next.length === 0 ? "safe" : "uncertain";
|
|
132
|
-
if (dryRun) {
|
|
133
|
-
log(
|
|
134
|
-
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
135
|
-
);
|
|
136
|
-
} else {
|
|
137
|
-
config.plugins = next;
|
|
138
|
-
await withFileOperationRetry(() =>
|
|
139
|
-
writeFile(
|
|
140
|
-
paths.configPath,
|
|
141
|
-
JSON.stringify(config, null, "\t") + "\n",
|
|
142
|
-
"utf8",
|
|
143
|
-
),
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
} else if (dryRun) {
|
|
147
|
-
log(
|
|
148
|
-
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
} catch (fileError) {
|
|
152
|
-
const code =
|
|
153
|
-
fileError &&
|
|
154
|
-
typeof fileError === "object" &&
|
|
155
|
-
"code" in fileError
|
|
156
|
-
? fileError.code
|
|
157
|
-
: undefined;
|
|
158
|
-
if (code === "ENOENT") {
|
|
159
|
-
bunLockState = "safe";
|
|
160
|
-
if (dryRun) {
|
|
161
|
-
log(
|
|
162
|
-
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
log(
|
|
167
|
-
`config cleanup skipped: ${fileError instanceof Error ? fileError.message : String(fileError)}`,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} catch (error) {
|
|
173
|
-
log(
|
|
174
|
-
`config cleanup skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const bunLockSafe = bunLockState === "safe";
|
|
179
|
-
|
|
180
|
-
// Clear plugin cache dirs
|
|
181
|
-
try {
|
|
182
|
-
if (deps.clearCache) {
|
|
183
|
-
await deps.clearCache(dryRun, log, bunLockSafe);
|
|
184
|
-
} else {
|
|
185
|
-
const paths = resolveInstallPaths(
|
|
186
|
-
process.platform,
|
|
187
|
-
env,
|
|
188
|
-
home || undefined,
|
|
189
|
-
);
|
|
190
|
-
if (dryRun) {
|
|
191
|
-
log(`[dry-run] Would remove ${paths.cacheNodeModules}`);
|
|
192
|
-
if (paths.cacheLegacyNodeModules) {
|
|
193
|
-
log(`[dry-run] Would remove ${paths.cacheLegacyNodeModules}`);
|
|
194
|
-
}
|
|
195
|
-
if (bunLockSafe) {
|
|
196
|
-
log(`[dry-run] Would remove ${paths.cacheBunLock}`);
|
|
197
|
-
} else {
|
|
198
|
-
log(
|
|
199
|
-
`[dry-run] Would skip ${paths.cacheBunLock} (other plugins still installed)`,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
try {
|
|
204
|
-
await withFileOperationRetry(() =>
|
|
205
|
-
rm(paths.cacheNodeModules, { recursive: true, force: true }),
|
|
206
|
-
);
|
|
207
|
-
if (paths.cacheLegacyNodeModules) {
|
|
208
|
-
await withFileOperationRetry(() =>
|
|
209
|
-
rm(paths.cacheLegacyNodeModules, {
|
|
210
|
-
recursive: true,
|
|
211
|
-
force: true,
|
|
212
|
-
}),
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
if (bunLockSafe) {
|
|
216
|
-
await withFileOperationRetry(() =>
|
|
217
|
-
rm(paths.cacheBunLock, { force: true }),
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
} catch (error) {
|
|
221
|
-
log(
|
|
222
|
-
`cache clear skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
} catch (error) {
|
|
228
|
-
log(
|
|
229
|
-
`cache clear skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return 0;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
async function main() {
|
|
237
|
-
return runPreuninstallCleanup();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function normalizeExitCode(exitCode) {
|
|
241
|
-
return Number.isInteger(exitCode) && exitCode >= 0 && exitCode <= 255
|
|
242
|
-
? exitCode
|
|
243
|
-
: 0;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const isDirectRun = (() => {
|
|
247
|
-
try {
|
|
248
|
-
return resolve(process.argv[1] ?? "") === fileURLToPath(import.meta.url);
|
|
249
|
-
} catch {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
})();
|
|
253
|
-
|
|
254
|
-
if (isDirectRun) {
|
|
255
|
-
main()
|
|
256
|
-
.then((exitCode) => {
|
|
257
|
-
process.exitCode = normalizeExitCode(exitCode);
|
|
258
|
-
})
|
|
259
|
-
.catch((error) => {
|
|
260
|
-
defaultPreuninstallLog(
|
|
261
|
-
`preuninstall cleanup skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
262
|
-
);
|
|
263
|
-
process.exitCode = 0;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @ts-check
|
|
4
|
+
|
|
5
|
+
import { readFile, writeFile, rm } from "node:fs/promises";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import process from "node:process";
|
|
9
|
+
import {
|
|
10
|
+
isCiEnvironment,
|
|
11
|
+
resolveInstallPaths,
|
|
12
|
+
removePluginFromList,
|
|
13
|
+
withFileOperationRetry,
|
|
14
|
+
} from "./install-codex-auth-utils.js";
|
|
15
|
+
|
|
16
|
+
async function loadAppBindModule() {
|
|
17
|
+
try {
|
|
18
|
+
return await import("../dist/lib/runtime/app-bind.js");
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (
|
|
21
|
+
error &&
|
|
22
|
+
typeof error === "object" &&
|
|
23
|
+
"code" in error &&
|
|
24
|
+
error.code === "ERR_MODULE_NOT_FOUND"
|
|
25
|
+
) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function defaultPreuninstallLog(message) {
|
|
33
|
+
console.error(`codex-multi-auth: ${message}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {{
|
|
38
|
+
* unbindCodexApp?: (dryRun: boolean) => Promise<void>,
|
|
39
|
+
* removeLauncher?: (options: { dryRun: boolean, log: (m: string) => void }) => Promise<void>,
|
|
40
|
+
* removePluginFromConfig?: (dryRun: boolean, log: (m: string) => void) => Promise<{ bunLockState: "safe" | "uncertain" }>,
|
|
41
|
+
* clearCache?: (dryRun: boolean, log: (m: string) => void, bunLockSafe: boolean) => Promise<void>,
|
|
42
|
+
* log?: (message: string) => void,
|
|
43
|
+
* env?: NodeJS.ProcessEnv,
|
|
44
|
+
* home?: string,
|
|
45
|
+
* dryRun?: boolean,
|
|
46
|
+
* }} [deps]
|
|
47
|
+
*/
|
|
48
|
+
export async function runPreuninstallCleanup(deps = {}) {
|
|
49
|
+
const log = deps.log ?? defaultPreuninstallLog;
|
|
50
|
+
const env = deps.env ?? process.env;
|
|
51
|
+
const home =
|
|
52
|
+
deps.home ??
|
|
53
|
+
(deps.env
|
|
54
|
+
? env.HOME || env.USERPROFILE || ""
|
|
55
|
+
: undefined);
|
|
56
|
+
const dryRun = deps.dryRun ?? process.argv.includes("--dry-run");
|
|
57
|
+
|
|
58
|
+
if (isCiEnvironment(env)) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @type {"safe" | "uncertain"} */
|
|
63
|
+
let bunLockState = "uncertain";
|
|
64
|
+
|
|
65
|
+
// Unbind Codex app runtime rotation (reverses install-time/first-run bind)
|
|
66
|
+
try {
|
|
67
|
+
if (deps.unbindCodexApp) {
|
|
68
|
+
await deps.unbindCodexApp(dryRun);
|
|
69
|
+
} else {
|
|
70
|
+
const appBindModule = await loadAppBindModule();
|
|
71
|
+
if (
|
|
72
|
+
appBindModule &&
|
|
73
|
+
typeof appBindModule.unbindCodexAppRuntimeRotation === "function"
|
|
74
|
+
) {
|
|
75
|
+
if (dryRun) {
|
|
76
|
+
log("[dry-run] Would unbind Codex app runtime rotation");
|
|
77
|
+
} else {
|
|
78
|
+
await appBindModule.unbindCodexAppRuntimeRotation();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
log(
|
|
84
|
+
`app unbind skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Remove OS-level launcher (reverses install-time/first-run launcher install)
|
|
89
|
+
try {
|
|
90
|
+
if (deps.removeLauncher) {
|
|
91
|
+
await deps.removeLauncher({ dryRun, log });
|
|
92
|
+
} else {
|
|
93
|
+
const launcherModule = await import("./codex-app-launcher.js");
|
|
94
|
+
if (typeof launcherModule.installCodexAppLauncher === "function") {
|
|
95
|
+
await launcherModule.installCodexAppLauncher({ remove: true, dryRun, log });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
log(
|
|
100
|
+
`launcher removal skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Remove plugin entry from Codex.json and track whether we're certain that
|
|
105
|
+
// no other plugins remain. bun.lock is shared across all Codex plugins, so
|
|
106
|
+
// it's only safe to delete when:
|
|
107
|
+
// - File ENOENT → safe (nothing to protect)
|
|
108
|
+
// - Parse error / read fail → uncertain (be conservative)
|
|
109
|
+
// - File ok, no plugins[] → uncertain (we don't know what's installed)
|
|
110
|
+
// - File ok, plugins[]=[] → safe
|
|
111
|
+
// - File ok, plugins[]≠[] → uncertain
|
|
112
|
+
try {
|
|
113
|
+
if (deps.removePluginFromConfig) {
|
|
114
|
+
const result = await deps.removePluginFromConfig(dryRun, log);
|
|
115
|
+
if (result && typeof result === "object" && "bunLockState" in result) {
|
|
116
|
+
bunLockState = result.bunLockState === "safe" ? "safe" : "uncertain";
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
const paths = resolveInstallPaths(
|
|
120
|
+
process.platform,
|
|
121
|
+
env,
|
|
122
|
+
home || undefined,
|
|
123
|
+
);
|
|
124
|
+
try {
|
|
125
|
+
const raw = await withFileOperationRetry(() =>
|
|
126
|
+
readFile(paths.configPath, "utf8"),
|
|
127
|
+
);
|
|
128
|
+
const config = JSON.parse(raw);
|
|
129
|
+
if (Array.isArray(config.plugins)) {
|
|
130
|
+
const next = removePluginFromList(config.plugins);
|
|
131
|
+
bunLockState = next.length === 0 ? "safe" : "uncertain";
|
|
132
|
+
if (dryRun) {
|
|
133
|
+
log(
|
|
134
|
+
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
135
|
+
);
|
|
136
|
+
} else {
|
|
137
|
+
config.plugins = next;
|
|
138
|
+
await withFileOperationRetry(() =>
|
|
139
|
+
writeFile(
|
|
140
|
+
paths.configPath,
|
|
141
|
+
JSON.stringify(config, null, "\t") + "\n",
|
|
142
|
+
"utf8",
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
} else if (dryRun) {
|
|
147
|
+
log(
|
|
148
|
+
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
} catch (fileError) {
|
|
152
|
+
const code =
|
|
153
|
+
fileError &&
|
|
154
|
+
typeof fileError === "object" &&
|
|
155
|
+
"code" in fileError
|
|
156
|
+
? fileError.code
|
|
157
|
+
: undefined;
|
|
158
|
+
if (code === "ENOENT") {
|
|
159
|
+
bunLockState = "safe";
|
|
160
|
+
if (dryRun) {
|
|
161
|
+
log(
|
|
162
|
+
`[dry-run] Would remove codex-multi-auth from ${paths.configPath}`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
log(
|
|
167
|
+
`config cleanup skipped: ${fileError instanceof Error ? fileError.message : String(fileError)}`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
log(
|
|
174
|
+
`config cleanup skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const bunLockSafe = bunLockState === "safe";
|
|
179
|
+
|
|
180
|
+
// Clear plugin cache dirs
|
|
181
|
+
try {
|
|
182
|
+
if (deps.clearCache) {
|
|
183
|
+
await deps.clearCache(dryRun, log, bunLockSafe);
|
|
184
|
+
} else {
|
|
185
|
+
const paths = resolveInstallPaths(
|
|
186
|
+
process.platform,
|
|
187
|
+
env,
|
|
188
|
+
home || undefined,
|
|
189
|
+
);
|
|
190
|
+
if (dryRun) {
|
|
191
|
+
log(`[dry-run] Would remove ${paths.cacheNodeModules}`);
|
|
192
|
+
if (paths.cacheLegacyNodeModules) {
|
|
193
|
+
log(`[dry-run] Would remove ${paths.cacheLegacyNodeModules}`);
|
|
194
|
+
}
|
|
195
|
+
if (bunLockSafe) {
|
|
196
|
+
log(`[dry-run] Would remove ${paths.cacheBunLock}`);
|
|
197
|
+
} else {
|
|
198
|
+
log(
|
|
199
|
+
`[dry-run] Would skip ${paths.cacheBunLock} (other plugins still installed)`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
try {
|
|
204
|
+
await withFileOperationRetry(() =>
|
|
205
|
+
rm(paths.cacheNodeModules, { recursive: true, force: true }),
|
|
206
|
+
);
|
|
207
|
+
if (paths.cacheLegacyNodeModules) {
|
|
208
|
+
await withFileOperationRetry(() =>
|
|
209
|
+
rm(paths.cacheLegacyNodeModules, {
|
|
210
|
+
recursive: true,
|
|
211
|
+
force: true,
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (bunLockSafe) {
|
|
216
|
+
await withFileOperationRetry(() =>
|
|
217
|
+
rm(paths.cacheBunLock, { force: true }),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
} catch (error) {
|
|
221
|
+
log(
|
|
222
|
+
`cache clear skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
log(
|
|
229
|
+
`cache clear skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function main() {
|
|
237
|
+
return runPreuninstallCleanup();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function normalizeExitCode(exitCode) {
|
|
241
|
+
return Number.isInteger(exitCode) && exitCode >= 0 && exitCode <= 255
|
|
242
|
+
? exitCode
|
|
243
|
+
: 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const isDirectRun = (() => {
|
|
247
|
+
try {
|
|
248
|
+
return resolve(process.argv[1] ?? "") === fileURLToPath(import.meta.url);
|
|
249
|
+
} catch {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
})();
|
|
253
|
+
|
|
254
|
+
if (isDirectRun) {
|
|
255
|
+
main()
|
|
256
|
+
.then((exitCode) => {
|
|
257
|
+
process.exitCode = normalizeExitCode(exitCode);
|
|
258
|
+
})
|
|
259
|
+
.catch((error) => {
|
|
260
|
+
defaultPreuninstallLog(
|
|
261
|
+
`preuninstall cleanup skipped: ${error instanceof Error ? error.message : String(error)}`,
|
|
262
|
+
);
|
|
263
|
+
process.exitCode = 0;
|
|
264
|
+
});
|
|
265
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type PluginInput = any;
|
|
2
|
-
export type Plugin = any;
|
|
1
|
+
export type PluginInput = any;
|
|
2
|
+
export type Plugin = any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export interface ToolContext {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
directory: string;
|
|
4
|
-
worktree: string;
|
|
5
|
-
ask: (request: any) => Promise<any> | any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ToolDefinition<TArgs = any, TResult = any> {
|
|
9
|
-
description?: string;
|
|
10
|
-
args?: Record<string, any>;
|
|
11
|
-
parameters?: unknown;
|
|
12
|
-
execute: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SchemaNode {
|
|
17
|
-
optional: () => SchemaNode;
|
|
18
|
-
describe: (_text: string) => SchemaNode;
|
|
19
|
-
min: (_value: number) => SchemaNode;
|
|
20
|
-
max: (_value: number) => SchemaNode;
|
|
21
|
-
default: (_value: unknown) => SchemaNode;
|
|
22
|
-
int: () => SchemaNode;
|
|
23
|
-
array: (_node?: unknown) => SchemaNode;
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ToolFactory {
|
|
28
|
-
<TArgs = any, TResult = any>(definition: ToolDefinition<TArgs, TResult>): ToolDefinition<TArgs, TResult>;
|
|
29
|
-
schema: {
|
|
30
|
-
string: () => SchemaNode;
|
|
31
|
-
number: () => SchemaNode;
|
|
32
|
-
boolean: () => SchemaNode;
|
|
33
|
-
object: (shape: Record<string, unknown>) => SchemaNode;
|
|
34
|
-
enum: (values: readonly unknown[]) => SchemaNode;
|
|
35
|
-
literal: (value: unknown) => SchemaNode;
|
|
36
|
-
array: (node: unknown) => SchemaNode;
|
|
37
|
-
any: () => SchemaNode;
|
|
38
|
-
unknown: () => SchemaNode;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export declare const tool: ToolFactory;
|
|
1
|
+
export interface ToolContext {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
directory: string;
|
|
4
|
+
worktree: string;
|
|
5
|
+
ask: (request: any) => Promise<any> | any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ToolDefinition<TArgs = any, TResult = any> {
|
|
9
|
+
description?: string;
|
|
10
|
+
args?: Record<string, any>;
|
|
11
|
+
parameters?: unknown;
|
|
12
|
+
execute: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SchemaNode {
|
|
17
|
+
optional: () => SchemaNode;
|
|
18
|
+
describe: (_text: string) => SchemaNode;
|
|
19
|
+
min: (_value: number) => SchemaNode;
|
|
20
|
+
max: (_value: number) => SchemaNode;
|
|
21
|
+
default: (_value: unknown) => SchemaNode;
|
|
22
|
+
int: () => SchemaNode;
|
|
23
|
+
array: (_node?: unknown) => SchemaNode;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ToolFactory {
|
|
28
|
+
<TArgs = any, TResult = any>(definition: ToolDefinition<TArgs, TResult>): ToolDefinition<TArgs, TResult>;
|
|
29
|
+
schema: {
|
|
30
|
+
string: () => SchemaNode;
|
|
31
|
+
number: () => SchemaNode;
|
|
32
|
+
boolean: () => SchemaNode;
|
|
33
|
+
object: (shape: Record<string, unknown>) => SchemaNode;
|
|
34
|
+
enum: (values: readonly unknown[]) => SchemaNode;
|
|
35
|
+
literal: (value: unknown) => SchemaNode;
|
|
36
|
+
array: (node: unknown) => SchemaNode;
|
|
37
|
+
any: () => SchemaNode;
|
|
38
|
+
unknown: () => SchemaNode;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare const tool: ToolFactory;
|