codex-multi-auth 2.17.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.
Files changed (75) hide show
  1. package/.codex-plugin/plugin.json +9 -9
  2. package/LICENSE +21 -21
  3. package/README.md +487 -484
  4. package/assets/codex-multi-auth-icon.svg +39 -39
  5. package/assets/readme-hero.svg +31 -31
  6. package/config/README.md +31 -31
  7. package/config/codex-legacy.json +1221 -1221
  8. package/config/codex-modern.json +423 -423
  9. package/config/minimal-codex.json +15 -15
  10. package/dist/lib/accounts.d.ts +1 -7
  11. package/dist/lib/accounts.d.ts.map +1 -1
  12. package/dist/lib/accounts.js +3 -14
  13. package/dist/lib/codex-manager/commands/forecast.d.ts +1 -1
  14. package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
  15. package/dist/lib/codex-manager/commands/forecast.js +2 -2
  16. package/dist/lib/codex-manager/health-check.js +1 -1
  17. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
  18. package/dist/lib/codex-manager/login-menu-data.js +7 -3
  19. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -1
  20. package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
  21. package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
  22. package/dist/lib/codex-manager/repair-commands.js +1 -1
  23. package/dist/lib/context-budget-response.js +8 -8
  24. package/dist/lib/context-overflow.js +10 -10
  25. package/dist/lib/oauth-success.html +125 -125
  26. package/dist/lib/prompts/codex-host-bridge.js +138 -138
  27. package/dist/lib/prompts/codex.js +79 -79
  28. package/dist/lib/quota-cache.d.ts +7 -3
  29. package/dist/lib/quota-cache.d.ts.map +1 -1
  30. package/dist/lib/quota-cache.js +91 -59
  31. package/dist/lib/quota-readiness.d.ts +7 -2
  32. package/dist/lib/quota-readiness.d.ts.map +1 -1
  33. package/dist/lib/quota-readiness.js +25 -4
  34. package/dist/lib/runtime/app-bind.d.ts.map +1 -1
  35. package/dist/lib/runtime/app-bind.js +10 -2
  36. package/dist/lib/runtime/automatic-account-checks.d.ts +5 -1
  37. package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -1
  38. package/dist/lib/runtime/automatic-account-checks.js +29 -2
  39. package/dist/lib/runtime/automatic-subscription-checks.d.ts +1 -1
  40. package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -1
  41. package/dist/lib/runtime/automatic-subscription-checks.js +13 -16
  42. package/dist/lib/runtime-rotation-proxy.js +3 -3
  43. package/dist/lib/storage/pending-auth.d.ts +1 -0
  44. package/dist/lib/storage/pending-auth.d.ts.map +1 -1
  45. package/dist/lib/storage/pending-auth.js +4 -2
  46. package/dist/lib/storage/record-identity.d.ts +16 -0
  47. package/dist/lib/storage/record-identity.d.ts.map +1 -0
  48. package/dist/lib/storage/record-identity.js +16 -0
  49. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
  50. package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
  51. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
  52. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
  53. package/node_modules/@codex-ai/plugin/package.json +9 -9
  54. package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
  55. package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
  56. package/node_modules/@codex-ai/sdk/package.json +8 -8
  57. package/package.json +200 -200
  58. package/scripts/codex-app-launcher.js +653 -653
  59. package/scripts/codex-app-router.js +373 -373
  60. package/scripts/codex-bin-resolver.js +313 -313
  61. package/scripts/codex-multi-auth.js +59 -59
  62. package/scripts/codex-routing.js +62 -62
  63. package/scripts/codex.js +6642 -6642
  64. package/scripts/install-codex-auth-utils.js +213 -213
  65. package/scripts/mcodex.js +367 -367
  66. package/scripts/postinstall.js +114 -114
  67. package/scripts/preuninstall.js +265 -265
  68. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
  69. package/vendor/codex-ai-plugin/dist/index.js +2 -2
  70. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
  71. package/vendor/codex-ai-plugin/dist/tool.js +29 -29
  72. package/vendor/codex-ai-plugin/package.json +9 -9
  73. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
  74. package/vendor/codex-ai-sdk/dist/index.js +2 -2
  75. package/vendor/codex-ai-sdk/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"automatic-subscription-checks.d.ts","sourceRoot":"","sources":["../../../lib/runtime/automatic-subscription-checks.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAUrF,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAClI,mGAAmG;AACnG,wBAAgB,gCAAgC,CAAC,OAAO,CAAC,EAAE,QAAQ,IASvD,QAAQ,WAAW,mBA+B9B"}
1
+ {"version":3,"file":"automatic-subscription-checks.d.ts","sourceRoot":"","sources":["../../../lib/runtime/automatic-subscription-checks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAOrF,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACvJ,mGAAmG;AACnG,wBAAgB,gCAAgC,CAAC,OAAO,CAAC,EAAE,QAAQ,IASvD,QAAQ,WAAW,mBAgC9B"}
@@ -1,35 +1,33 @@
1
1
  import { getStoragePathState, runWithStoragePathState } from "../storage/path-state.js";
2
- import { join } from "node:path";
3
2
  import { AccountManager, resolveAccountRecordId } from "../accounts.js";
4
3
  import { getAccountPolicyKey, loadAccountPolicyStore } from "../account-policy.js";
5
4
  import { getStoragePath } from "../storage.js";
6
5
  import { fetchCodexQuotaSnapshot } from "../quota-probe.js";
7
6
  import { loadQuotaCache, saveQuotaCache } from "../quota-cache.js";
8
- import { updateQuotaCacheForAccount } from "../codex-manager/quota-cache-helpers.js";
9
- import { getCodexMultiAuthDir } from "../runtime-paths.js";
10
- import { withFileTransactionLock } from "../storage/file-lock.js";
7
+ import { updateQuotaCacheForWorkspace } from "../codex-manager/quota-cache-helpers.js";
11
8
  import { createNativeAccountStorageReader } from "./native-account-storage.js";
12
9
  import { ensureFreshAccessToken } from "./rotation-token-refresh.js";
13
- import { workspaceModelScopes } from "./workspace-model-scopes.js";
14
- import { runAutomaticAccountChecks } from "./automatic-account-checks.js";
10
+ import { automaticCheckWorkspaceId, runAutomaticAccountChecks } from "./automatic-account-checks.js";
15
11
  import { logWarn } from "../logger.js";
16
12
  /** Captures this router's pool; reads only verified primary credentials, never API/ZDR entries. */
17
13
  export function createAutomaticSubscriptionCheck(observe) {
18
14
  const path = getStoragePath(), storageState = getStoragePathState();
19
15
  const read = createNativeAccountStorageReader(undefined, path);
20
- const quotaPath = join(getCodexMultiAuthDir(), "quota-cache.json");
21
- const onQuota = observe ?? (async (account, snapshot, accounts) => withFileTransactionLock(quotaPath, async () => {
16
+ const onQuota = observe ?? (async (account, snapshot, accounts, workspaceId) => {
22
17
  const cache = await loadQuotaCache();
23
- updateQuotaCacheForAccount(cache, account, snapshot, accounts);
24
- await saveQuotaCache(cache);
25
- }));
18
+ const baseline = structuredClone(cache);
19
+ updateQuotaCacheForWorkspace(cache, account, workspaceId, snapshot, accounts);
20
+ await saveQuotaCache(cache, baseline);
21
+ });
26
22
  return (signal) => runWithStoragePathState(storageState, () => runAutomaticAccountChecks({
27
23
  path: `${path}.automatic-checks.json`, signal, loadPolicies: loadAccountPolicyStore,
28
24
  loadAccounts: async () => { const snapshot = await read(); return snapshot.verified ? snapshot.storage : null; },
29
25
  check: async (storage, index) => {
30
26
  const manager = new AccountManager(undefined, storage);
31
27
  const account = manager.getAccountByIndex(index);
32
- if (!account || !workspaceModelScopes(account).some(s => s.bound && s.routable) || signal.aborted)
28
+ const stored = storage.accounts[index];
29
+ const targetId = stored && automaticCheckWorkspaceId(stored);
30
+ if (!account || !targetId || signal.aborted)
33
31
  return;
34
32
  const fresh = await ensureFreshAccessToken({ accountManager: manager, account, family: "codex", model: null, now: Date.now(), tokenRefreshSkewMs: 60000, tokenInvalidationCooldownMs: 300000 });
35
33
  try {
@@ -41,13 +39,12 @@ export function createAutomaticSubscriptionCheck(observe) {
41
39
  const policy = current ? (await loadAccountPolicyStore()).accounts[getAccountPolicyKey(current)] : undefined;
42
40
  if (!disk.storage || !current || current.refreshToken !== fresh.account.refreshToken || current.accessToken !== fresh.accessToken || !policy?.autoPrime || policy.paused || policy.drained || current.enabled === false || current.authInvalidatedAt || (current.coolingDownUntil ?? 0) > Date.now())
43
41
  return;
44
- const bound = workspaceModelScopes(fresh.account).find(s => s.bound && s.routable);
45
- if (!bound || (current.accountId && current.accountId !== bound.accountId) || current.workspaces?.some(w => w.id === bound.accountId && w.enabled === false) || signal.aborted)
42
+ if (automaticCheckWorkspaceId(current) !== targetId || signal.aborted)
46
43
  return;
47
- const snapshot = await fetchCodexQuotaSnapshot({ accountId: bound.accountId, accessToken: fresh.accessToken, primeUnusedSubscription: true, signal });
44
+ const snapshot = await fetchCodexQuotaSnapshot({ accountId: targetId, accessToken: fresh.accessToken, primeUnusedSubscription: true, signal });
48
45
  if (snapshot.primingFailure)
49
46
  logWarn("Automatic first-use completion was not confirmed; retry deferred until the next check.");
50
- await onQuota(current, snapshot, disk.storage.accounts);
47
+ await onQuota(current, snapshot, disk.storage.accounts, targetId);
51
48
  }
52
49
  finally {
53
50
  await manager.flushPendingSave();
@@ -1366,8 +1366,8 @@ async function handleRequestInner(state, req, res, traceId) {
1366
1366
  const subscriptionQuotaByAccount = {};
1367
1367
  const resetCreditState = state.nativeOpenai && isResponsesRequest ? await cachedRead(state, "reset-credits", loadResetCreditState).catch(() => null) : null;
1368
1368
  const quotaForScope = (account, scope) => {
1369
- // Cached checks describe only the stored account binding, never its sibling workspaces.
1370
- const cached = scope.bound ? findQuotaCacheEntryForAccount(subscriptionQuotaCache, account, accountManager.getAccountsSnapshot()) : null;
1369
+ // Scoped observations belong to this credential and workspace; legacy entries only describe the binding.
1370
+ const cached = findQuotaCacheEntryForAccount(subscriptionQuotaCache, account, accountManager.getAccountsSnapshot(), undefined, scope.accountId);
1371
1371
  const observed = state.subscriptionQuotaObservations?.get(JSON.stringify([scope.id, context.model]));
1372
1372
  const reset = resetCreditState?.snapshots[scope.id];
1373
1373
  if (reset && reset.updatedAt > Math.max(cached?.updatedAt ?? 0, observed?.updatedAt ?? 0) && reset.updatedAt <= state.now() && state.now() - reset.updatedAt <= 60000)
@@ -1616,7 +1616,7 @@ async function handleRequestInner(state, req, res, traceId) {
1616
1616
  continue;
1617
1617
  for (const scope of scopes)
1618
1618
  applyConfirmedReset({ account, scope, model: context.model, family: context.family, manager: accountManager, snapshot: resetCreditState.snapshots[scope.id], lastRedemptionAt: resetCreditState.lastRedemptionAt,
1619
- previous: state.subscriptionQuotaObservations?.get(JSON.stringify([scope.id, context.model])) ?? (scope.bound ? findQuotaCacheEntryForAccount(subscriptionQuotaCache, account, accountManager.getAccountsSnapshot()) : null),
1619
+ previous: state.subscriptionQuotaObservations?.get(JSON.stringify([scope.id, context.model])) ?? findQuotaCacheEntryForAccount(subscriptionQuotaCache, account, accountManager.getAccountsSnapshot(), undefined, scope.accountId),
1620
1620
  observations: state.subscriptionQuotaObservations ??= new Map(), now: state.now(), clearQuotaScheduler: a => state.preemptiveQuotaScheduler.clear(buildQuotaScheduleKey(a, context.family, context.model)) });
1621
1621
  }
1622
1622
  }
@@ -3,6 +3,7 @@ export declare function getPendingAuthPath(storagePath: string): string;
3
3
  /** Record a rotated credential beside the account pool. */
4
4
  export declare function recordPendingAuth(storagePath: string, auth: {
5
5
  priorRefreshToken: string;
6
+ recordId?: string;
6
7
  refreshToken: string;
7
8
  accessToken: string;
8
9
  expiresAt: number;
@@ -1 +1 @@
1
- {"version":3,"file":"pending-auth.d.ts","sourceRoot":"","sources":["../../../lib/storage/pending-auth.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAyB1D,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAmCD,2DAA2D;AAC3D,wBAAsB,iBAAiB,CACtC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC3G,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED,mFAAmF;AACnF,wBAAsB,gBAAgB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC9B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA4BlC;AAED,mGAAmG;AACnG,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlG;AAED,yFAAyF;AACzF,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
1
+ {"version":3,"file":"pending-auth.d.ts","sourceRoot":"","sources":["../../../lib/storage/pending-auth.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA0B1D,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAmCD,2DAA2D;AAC3D,wBAAsB,iBAAiB,CACtC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC9H,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED,mFAAmF;AACnF,wBAAsB,gBAAgB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC9B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA6BlC;AAED,mGAAmG;AACnG,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlG;AAED,yFAAyF;AACzF,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
@@ -17,6 +17,7 @@ import { getIntentionalResetMarkerPath } from "./backup-paths.js";
17
17
  const entrySchema = z.object({
18
18
  /** sha256 of the spent refresh token: identifies the row without storing it. */
19
19
  prior: z.string().regex(/^[0-9a-f]{64}$/),
20
+ recordId: z.string().trim().min(1).optional(),
20
21
  refreshToken: z.string().min(1),
21
22
  accessToken: z.string().min(1),
22
23
  expiresAt: z.number(),
@@ -82,9 +83,9 @@ export async function recordPendingAuth(storagePath, auth) {
82
83
  // the original spent token, so extend that entry rather than add one that
83
84
  // no disk row can match.
84
85
  const chained = entries.find((entry) => entry.refreshToken === auth.priorRefreshToken);
85
- const current = chained ?? { prior, refreshToken: auth.refreshToken, accessToken: auth.accessToken, expiresAt: auth.expiresAt, at: auth.at };
86
+ const current = chained ?? { prior, recordId: auth.recordId, refreshToken: auth.refreshToken, accessToken: auth.accessToken, expiresAt: auth.expiresAt, at: auth.at };
86
87
  if (chained)
87
- Object.assign(chained, { refreshToken: auth.refreshToken, accessToken: auth.accessToken, expiresAt: auth.expiresAt, at: auth.at });
88
+ Object.assign(chained, { recordId: chained.recordId ?? auth.recordId, refreshToken: auth.refreshToken, accessToken: auth.accessToken, expiresAt: auth.expiresAt, at: auth.at });
88
89
  else
89
90
  entries.push(current);
90
91
  const excess = entries.length - MAX_ENTRIES;
@@ -120,6 +121,7 @@ export async function applyPendingAuth(storagePath, storage) {
120
121
  const entry = account.refreshToken ? entries.find((item) => item.prior === hash(account.refreshToken)) : undefined;
121
122
  if (!entry)
122
123
  continue;
124
+ account.recordId ??= entry.recordId;
123
125
  account.refreshToken = entry.refreshToken;
124
126
  account.accessToken = entry.accessToken;
125
127
  account.expiresAt = entry.expiresAt;
@@ -0,0 +1,16 @@
1
+ /** Derive a legacy record identity before its first persisted token rotation. */
2
+ export declare function deriveAccountRecordId(account: {
3
+ accountId?: string;
4
+ email?: string;
5
+ refreshToken: string;
6
+ addedAt: number;
7
+ }): string;
8
+ /** Resolve the persisted identity, or derive it for a legacy row. */
9
+ export declare function resolveAccountRecordId(account: {
10
+ recordId?: string;
11
+ accountId?: string;
12
+ email?: string;
13
+ refreshToken: string;
14
+ addedAt: number;
15
+ }): string;
16
+ //# sourceMappingURL=record-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-identity.d.ts","sourceRoot":"","sources":["../../../lib/storage/record-identity.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAChB,GACC,MAAM,CAQR;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CACrC,OAAO,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAChB,GACC,MAAM,CAGR"}
@@ -0,0 +1,16 @@
1
+ import { createHash } from "node:crypto";
2
+ /** Derive a legacy record identity before its first persisted token rotation. */
3
+ export function deriveAccountRecordId(account) {
4
+ const seed = [
5
+ account.addedAt,
6
+ account.accountId?.trim() ?? "",
7
+ account.email?.trim().toLowerCase() ?? "",
8
+ account.refreshToken.trim(),
9
+ ].join("\u0000");
10
+ return `record:${createHash("sha256").update(seed).digest("hex")}`;
11
+ }
12
+ /** Resolve the persisted identity, or derive it for a legacy row. */
13
+ export function resolveAccountRecordId(account) {
14
+ const stored = account.recordId?.trim();
15
+ return stored || deriveAccountRecordId(account);
16
+ }
@@ -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;
@@ -1,29 +1,29 @@
1
- const chain = {
2
- optional() { return this; },
3
- describe() { return this; },
4
- min() { return this; },
5
- max() { return this; },
6
- default() { return this; },
7
- int() { return this; },
8
- array() { return this; },
9
- };
10
-
11
- function node() {
12
- return Object.create(chain);
13
- }
14
-
15
- export function tool(definition) {
16
- return definition;
17
- }
18
-
19
- tool.schema = {
20
- string: () => node(),
21
- number: () => node(),
22
- boolean: () => node(),
23
- object: () => node(),
24
- enum: () => node(),
25
- literal: () => node(),
26
- array: () => node(),
27
- any: () => node(),
28
- unknown: () => node(),
29
- };
1
+ const chain = {
2
+ optional() { return this; },
3
+ describe() { return this; },
4
+ min() { return this; },
5
+ max() { return this; },
6
+ default() { return this; },
7
+ int() { return this; },
8
+ array() { return this; },
9
+ };
10
+
11
+ function node() {
12
+ return Object.create(chain);
13
+ }
14
+
15
+ export function tool(definition) {
16
+ return definition;
17
+ }
18
+
19
+ tool.schema = {
20
+ string: () => node(),
21
+ number: () => node(),
22
+ boolean: () => node(),
23
+ object: () => node(),
24
+ enum: () => node(),
25
+ literal: () => node(),
26
+ array: () => node(),
27
+ any: () => node(),
28
+ unknown: () => node(),
29
+ };
@@ -1,9 +1,9 @@
1
- {
2
- "name": "@codex-ai/plugin",
3
- "version": "1.2.10-codex.1",
4
- "type": "module",
5
- "exports": {
6
- ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" },
7
- "./tool": { "import": "./dist/tool.js", "types": "./dist/tool.d.ts" }
8
- }
9
- }
1
+ {
2
+ "name": "@codex-ai/plugin",
3
+ "version": "1.2.10-codex.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" },
7
+ "./tool": { "import": "./dist/tool.js", "types": "./dist/tool.d.ts" }
8
+ }
9
+ }
@@ -1,4 +1,4 @@
1
- export type Auth = any;
2
- export type Provider = any;
3
- export type Model = any;
4
- export type CodexClient = any;
1
+ export type Auth = any;
2
+ export type Provider = any;
3
+ export type Model = any;
4
+ export type CodexClient = any;
@@ -1,2 +1,2 @@
1
- export {};
2
-
1
+ export {};
2
+
@@ -1,8 +1,8 @@
1
- {
2
- "name": "@codex-ai/sdk",
3
- "version": "1.2.10-codex.1",
4
- "type": "module",
5
- "exports": {
6
- ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" }
7
- }
8
- }
1
+ {
2
+ "name": "@codex-ai/sdk",
3
+ "version": "1.2.10-codex.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" }
7
+ }
8
+ }