codex-multi-auth 2.3.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +10 -10
- package/README.md +423 -421
- package/dist/lib/runtime/rotation-proxy-state.d.ts +7 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +9 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +10 -0
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +38 -1
- 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 +196 -196
- package/scripts/codex.js +189 -8
- 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
|
@@ -29,6 +29,13 @@ export interface RotationProxyStateInit {
|
|
|
29
29
|
quotaRemainingPercentThreshold: number;
|
|
30
30
|
sessionAffinityStore: SessionAffinityStore | null;
|
|
31
31
|
lastObservedAffinityGeneration: number;
|
|
32
|
+
/**
|
|
33
|
+
* Ephemeral per-invocation account pin (0-based) or null. When a number,
|
|
34
|
+
* the request handler treats it exactly like a manual `switch` pin — a
|
|
35
|
+
* deterministic, fail-hard selection — but it is never written to disk, so
|
|
36
|
+
* concurrent invocations with different pins never interfere (issue #623).
|
|
37
|
+
*/
|
|
38
|
+
forcedAccountIndex: number | null;
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
34
41
|
* Mutable rotation-loop state shared by every request of one proxy instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation-proxy-state.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-proxy-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACtC,oBAAoB,EAAE,cAAc,CAAC;IACrC,gBAAgB,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,kBAAkB,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC5C,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2BAA2B,EAAE,MAAM,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8BAA8B,EAAE,MAAM,CAAC;IACvC,oBA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BAAoB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACzD,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,yBAAyB,EAAE,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,wBAAwB,EAAE,MAAM,CAAC;CACjC;AAID,gBAAgB;AAChB,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,sBAAsB,GAC1B,kBAAkB,CAuBpB;AAED,gBAAgB;AAChB,wBAAsB,wBAAwB,CAC7C,KAAK,EAAE,kBAAkB,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAkDhC"}
|
|
@@ -32,6 +32,15 @@ export interface RuntimeRotationProxyOptions {
|
|
|
32
32
|
maxRequestBodyBytes?: number;
|
|
33
33
|
fetchTimeoutMs?: number;
|
|
34
34
|
streamStallTimeoutMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Ephemeral, per-instance account pin (0-based) for a single invocation
|
|
37
|
+
* (issue #623: `codex-multi-auth-codex --account`). When set, this proxy
|
|
38
|
+
* routes every request to exactly this account and never rotates, without
|
|
39
|
+
* touching the persisted `switch` pin on disk. Falls back to
|
|
40
|
+
* `CODEX_MULTI_AUTH_FORCE_ACCOUNT_INDEX` in the environment when omitted so
|
|
41
|
+
* the value survives the launcher -> detached app-helper process boundary.
|
|
42
|
+
*/
|
|
43
|
+
forcedAccountIndex?: number | null;
|
|
35
44
|
}
|
|
36
45
|
export interface RequestContext {
|
|
37
46
|
body: Buffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation-server-types.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-server-types.ts"],"names":[],"mappings":"AAA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AAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,gBAAgB,GACzB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,cAAc,GACd,QAAQ,GACR,aAAa,GACb,YAAY,CAAC;AAChB,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -5,5 +5,15 @@ export type { PinnedUnavailableErrorBody } from "./request/rate-limit-decision.j
|
|
|
5
5
|
export { chooseAccount } from "./runtime/rotation-account-selection.js";
|
|
6
6
|
export { maybeInvalidateAffinityFromDisk, readPinnedAccountIndexFromDisk, readStorageMetaFromDisk, resetPinCacheForTesting, } from "./runtime/rotation-storage-meta.js";
|
|
7
7
|
export type { StorageMeta } from "./runtime/rotation-storage-meta.js";
|
|
8
|
+
/**
|
|
9
|
+
* Coerce a forced-account pin from an option (number) or the launcher's env
|
|
10
|
+
* string into a normalized 0-based index, or null when absent/invalid. Invalid
|
|
11
|
+
* or negative values collapse to null so an out-of-range env value can never
|
|
12
|
+
* throw at proxy startup; chooseAccount reports the deterministic
|
|
13
|
+
* pinned-account failure per-request instead. Exported for unit tests.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeForcedAccountIndex(value: number | string | null | undefined): number | null;
|
|
8
18
|
export declare function startRuntimeRotationProxy(options: RuntimeRotationProxyOptions): Promise<RuntimeRotationProxyServer>;
|
|
9
19
|
//# sourceMappingURL=runtime-rotation-proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAwEA,OAAO,KAAK,EAKX,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,oCAAoC,CAAC;AAe5C,YAAY,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EACN,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA6etE,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAwEA,OAAO,KAAK,EAKX,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,oCAAoC,CAAC;AAe5C,YAAY,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EACN,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA6etE;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,MAAM,GAAG,IAAI,CAUf;AAED,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,CA6JrC"}
|
|
@@ -420,6 +420,25 @@ function writePoolExhausted(params) {
|
|
|
420
420
|
},
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Coerce a forced-account pin from an option (number) or the launcher's env
|
|
425
|
+
* string into a normalized 0-based index, or null when absent/invalid. Invalid
|
|
426
|
+
* or negative values collapse to null so an out-of-range env value can never
|
|
427
|
+
* throw at proxy startup; chooseAccount reports the deterministic
|
|
428
|
+
* pinned-account failure per-request instead. Exported for unit tests.
|
|
429
|
+
*
|
|
430
|
+
* @internal
|
|
431
|
+
*/
|
|
432
|
+
export function normalizeForcedAccountIndex(value) {
|
|
433
|
+
if (value === null || value === undefined) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
const parsed = typeof value === "number" ? value : Number.parseInt(value.trim(), 10);
|
|
437
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
return parsed;
|
|
441
|
+
}
|
|
423
442
|
export async function startRuntimeRotationProxy(options) {
|
|
424
443
|
const pluginConfig = loadPluginConfig();
|
|
425
444
|
const activeAccountManager = options.accountManager ?? (await AccountManager.loadFromDisk());
|
|
@@ -455,6 +474,17 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
455
474
|
throw new CodexValidationError("Runtime rotation proxy requires a clientApiKey.", { field: "clientApiKey", expected: "a non-empty string" });
|
|
456
475
|
}
|
|
457
476
|
const now = options.now ?? Date.now;
|
|
477
|
+
// Ephemeral per-invocation pin (issue #623). Prefer an explicit option (used by
|
|
478
|
+
// tests and the in-process inline proxy); otherwise fall back to the numeric env
|
|
479
|
+
// the launcher publishes, which is how the value reaches a detached app-helper
|
|
480
|
+
// process. `??` means both `undefined` and an explicit `null` option defer to the
|
|
481
|
+
// env, so "no option" and "no pin" behave identically. Invalid/negative values
|
|
482
|
+
// are ignored (treated as "no forced pin") rather than throwing — the launcher
|
|
483
|
+
// already validated the selector, and an out-of-range index is surfaced
|
|
484
|
+
// per-request as a deterministic pinned-account failure by chooseAccount rather
|
|
485
|
+
// than crashing proxy startup.
|
|
486
|
+
const forcedAccountIndex = normalizeForcedAccountIndex(options.forcedAccountIndex ??
|
|
487
|
+
process.env.CODEX_MULTI_AUTH_FORCE_ACCOUNT_INDEX);
|
|
458
488
|
const tokenRefreshSkewMs = getTokenRefreshSkewMs(pluginConfig);
|
|
459
489
|
const networkErrorCooldownMs = getNetworkErrorCooldownMs(pluginConfig);
|
|
460
490
|
const serverErrorCooldownMs = getServerErrorCooldownMs(pluginConfig);
|
|
@@ -500,6 +530,7 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
500
530
|
quotaRemainingPercentThreshold,
|
|
501
531
|
sessionAffinityStore,
|
|
502
532
|
lastObservedAffinityGeneration,
|
|
533
|
+
forcedAccountIndex,
|
|
503
534
|
});
|
|
504
535
|
const server = createServer((req, res) => {
|
|
505
536
|
void handleRequest(state, req, res);
|
|
@@ -669,7 +700,13 @@ async function handleRequestInner(state, req, res, traceId) {
|
|
|
669
700
|
// account. The proxy itself never bumps the generation, so its own
|
|
670
701
|
// debounced disk writes do not clear affinity. See issue #474.
|
|
671
702
|
const storageMeta = readStorageMetaFromDisk();
|
|
672
|
-
|
|
703
|
+
// The ephemeral --account pin (issue #623) takes precedence over the
|
|
704
|
+
// persisted `switch` pin for this invocation, without ever mutating disk
|
|
705
|
+
// state. Use `??` (not `||`) so a forced index of 0 is honored. When set,
|
|
706
|
+
// everything downstream — deterministic pick, no cursor advance, no
|
|
707
|
+
// stale-state recovery, the `codex_pinned_account_unavailable` failure —
|
|
708
|
+
// applies unchanged because it all keys off `pinnedIndex` / `isPinned`.
|
|
709
|
+
const pinnedIndex = state.forcedAccountIndex ?? storageMeta.pinnedAccountIndex;
|
|
673
710
|
const isPinned = typeof pinnedIndex === "number";
|
|
674
711
|
if (storageMeta.affinityGeneration > state.lastObservedAffinityGeneration) {
|
|
675
712
|
state.sessionAffinityStore?.clearAll();
|
|
@@ -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
|
+
}
|