codex-multi-auth 2.22.0 → 2.24.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.
Files changed (117) hide show
  1. package/.codex-plugin/plugin.json +9 -9
  2. package/LICENSE +21 -21
  3. package/README.md +159 -150
  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 +1021 -1021
  8. package/config/codex-modern.json +347 -347
  9. package/config/minimal-codex.json +15 -15
  10. package/config/schema/config.schema.json +8 -0
  11. package/dist/index.js +33 -10
  12. package/dist/lib/account-policy.d.ts +2 -0
  13. package/dist/lib/account-policy.js +3 -1
  14. package/dist/lib/accounts/rate-limits.d.ts +6 -0
  15. package/dist/lib/accounts/rate-limits.js +14 -1
  16. package/dist/lib/accounts.d.ts +6 -1
  17. package/dist/lib/accounts.js +33 -8
  18. package/dist/lib/api-route-store.d.ts +1 -0
  19. package/dist/lib/api-route-store.js +2 -1
  20. package/dist/lib/auth/account-access.js +2 -1
  21. package/dist/lib/auth/auth.js +3 -2
  22. package/dist/lib/auth/device-auth.js +2 -1
  23. package/dist/lib/auth/http.d.ts +1 -0
  24. package/dist/lib/auth/http.js +1 -0
  25. package/dist/lib/auth/token-utils.d.ts +5 -0
  26. package/dist/lib/auth/token-utils.js +10 -0
  27. package/dist/lib/codex-manager/account-manager-commands.js +1 -0
  28. package/dist/lib/codex-manager/commands/account.js +15 -0
  29. package/dist/lib/codex-manager/commands/locale.d.ts +12 -0
  30. package/dist/lib/codex-manager/commands/locale.js +25 -0
  31. package/dist/lib/codex-manager/commands/resets.js +18 -5
  32. package/dist/lib/codex-manager/commands/status.d.ts +4 -0
  33. package/dist/lib/codex-manager/commands/status.js +476 -5
  34. package/dist/lib/codex-manager/commands/workspace.d.ts +4 -2
  35. package/dist/lib/codex-manager/commands/workspace.js +33 -2
  36. package/dist/lib/codex-manager/help.js +5 -3
  37. package/dist/lib/codex-manager.js +112 -30
  38. package/dist/lib/config.js +3 -0
  39. package/dist/lib/constants.d.ts +2 -0
  40. package/dist/lib/constants.js +2 -0
  41. package/dist/lib/context-budget-response.js +8 -8
  42. package/dist/lib/context-overflow.js +10 -10
  43. package/dist/lib/locale.d.ts +7 -0
  44. package/dist/lib/locale.js +35 -0
  45. package/dist/lib/oauth-success.html +125 -125
  46. package/dist/lib/policy/runtime-policy-cache.js +1 -1
  47. package/dist/lib/policy/runtime-policy.d.ts +1 -0
  48. package/dist/lib/policy/runtime-policy.js +4 -0
  49. package/dist/lib/preemptive-quota-scheduler.js +12 -3
  50. package/dist/lib/prompts/codex-host-bridge.js +138 -138
  51. package/dist/lib/prompts/codex.js +79 -79
  52. package/dist/lib/quota-cache.d.ts +4 -0
  53. package/dist/lib/quota-probe.js +2 -1
  54. package/dist/lib/quota-readiness.d.ts +1 -1
  55. package/dist/lib/quota-readiness.js +9 -2
  56. package/dist/lib/request/proxy-fetch.d.ts +5 -0
  57. package/dist/lib/request/proxy-fetch.js +37 -0
  58. package/dist/lib/request/rate-limit-decision.js +1 -1
  59. package/dist/lib/request/url-rewriting.js +17 -0
  60. package/dist/lib/runtime/account-model-catalog.d.ts +2 -0
  61. package/dist/lib/runtime/account-model-catalog.js +7 -2
  62. package/dist/lib/runtime/account-reset-credits.d.ts +11 -2
  63. package/dist/lib/runtime/account-reset-credits.js +35 -12
  64. package/dist/lib/runtime/app-bind.d.ts +4 -1
  65. package/dist/lib/runtime/app-bind.js +63 -3
  66. package/dist/lib/runtime/automatic-account-checks.js +6 -5
  67. package/dist/lib/runtime/automatic-subscription-checks.js +4 -3
  68. package/dist/lib/runtime/model-discovery-status.js +2 -2
  69. package/dist/lib/runtime/reset-credit-routing.d.ts +11 -3
  70. package/dist/lib/runtime/reset-credit-routing.js +66 -21
  71. package/dist/lib/runtime/reset-credits.d.ts +31 -7
  72. package/dist/lib/runtime/reset-credits.js +135 -28
  73. package/dist/lib/runtime/responses-websocket.d.ts +30 -0
  74. package/dist/lib/runtime/responses-websocket.js +243 -29
  75. package/dist/lib/runtime/rotation-account-selection.d.ts +5 -4
  76. package/dist/lib/runtime/rotation-proxy-state.d.ts +3 -0
  77. package/dist/lib/runtime/rotation-server-types.d.ts +4 -1
  78. package/dist/lib/runtime/subscription-quota-order.d.ts +1 -0
  79. package/dist/lib/runtime/subscription-quota-order.js +7 -3
  80. package/dist/lib/runtime/workspace-model-scopes.d.ts +2 -0
  81. package/dist/lib/runtime/workspace-model-scopes.js +14 -4
  82. package/dist/lib/runtime-rotation-proxy.js +138 -38
  83. package/dist/lib/schemas.d.ts +5 -0
  84. package/dist/lib/schemas.js +1 -0
  85. package/dist/lib/storage/snapshot-merge.js +15 -4
  86. package/dist/lib/web-dashboard-html.d.ts +1 -0
  87. package/dist/lib/web-dashboard-html.js +66 -0
  88. package/dist/lib/web-dashboard.d.ts +36 -0
  89. package/dist/lib/web-dashboard.js +322 -0
  90. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
  91. package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
  92. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
  93. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
  94. package/node_modules/@codex-ai/plugin/package.json +9 -9
  95. package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
  96. package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
  97. package/node_modules/@codex-ai/sdk/package.json +8 -8
  98. package/package.json +209 -207
  99. package/scripts/codex-app-launcher.js +653 -653
  100. package/scripts/codex-app-router.js +446 -402
  101. package/scripts/codex-bin-resolver.js +332 -332
  102. package/scripts/codex-multi-auth.js +65 -65
  103. package/scripts/codex-routing.js +63 -62
  104. package/scripts/codex.js +7143 -7006
  105. package/scripts/install-codex-auth-utils.js +213 -213
  106. package/scripts/mcodex.js +367 -367
  107. package/scripts/postinstall.js +114 -114
  108. package/scripts/preuninstall.js +265 -265
  109. package/skills/codex-auth-setup/SKILL.md +73 -73
  110. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
  111. package/vendor/codex-ai-plugin/dist/index.js +2 -2
  112. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
  113. package/vendor/codex-ai-plugin/dist/tool.js +29 -29
  114. package/vendor/codex-ai-plugin/package.json +9 -9
  115. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
  116. package/vendor/codex-ai-sdk/dist/index.js +2 -2
  117. package/vendor/codex-ai-sdk/package.json +8 -8
@@ -0,0 +1,322 @@
1
+ import { createServer } from "node:http";
2
+ import { spawn } from "node:child_process";
3
+ import { renderDashboardHtml } from "./web-dashboard-html.js";
4
+ import { localized, resolveOutputLocale } from "./locale.js";
5
+ function isLoopbackHost(host) {
6
+ const normalized = host.trim().toLowerCase();
7
+ return normalized === "127.0.0.1" || normalized === "localhost" || normalized === "::1" || normalized === "[::1]";
8
+ }
9
+ function parsePort(value) {
10
+ const port = value === undefined ? 4317 : Number(value);
11
+ if (!Number.isInteger(port) || port < 0 || port > 65535) {
12
+ throw new Error("Web port must be an integer between 0 and 65535.");
13
+ }
14
+ return port;
15
+ }
16
+ function unauthorized(response) {
17
+ response.writeHead(401, {
18
+ "content-type": "application/json; charset=utf-8",
19
+ "cache-control": "no-store",
20
+ "www-authenticate": "Bearer",
21
+ });
22
+ response.end(JSON.stringify({ error: "Unauthorized" }));
23
+ }
24
+ function authorized(request, token, url) {
25
+ if (!token)
26
+ return true;
27
+ const header = request.headers.authorization;
28
+ const bearer = typeof header === "string" && header.startsWith("Bearer ")
29
+ ? header.slice("Bearer ".length).trim()
30
+ : "";
31
+ return bearer === token || url.searchParams.get("token") === token;
32
+ }
33
+ /**
34
+ * Reject requests addressed to a foreign Host. A loopback listener without a
35
+ * token is otherwise reachable via DNS rebinding: a hostile page resolving its
36
+ * own domain to 127.0.0.1 would read the pool status as same-origin. Token-gated
37
+ * binds skip the check — the bearer token is already the guard there.
38
+ */
39
+ function requestHostAllowed(request, host, token) {
40
+ if (token)
41
+ return true;
42
+ const bound = host.trim().toLowerCase().replace(/^\[|\]$/g, "");
43
+ if (!isLoopbackHost(bound))
44
+ return true;
45
+ const hostHeader = request.headers.host;
46
+ if (typeof hostHeader !== "string" || !hostHeader.trim())
47
+ return true;
48
+ let hostname = hostHeader.trim();
49
+ const bracketed = hostname.match(/^\[(.*)\](?::\d+)?$/);
50
+ hostname = (bracketed ? bracketed[1] ?? "" : hostname.replace(/:\d+$/, "")).toLowerCase();
51
+ return isLoopbackHost(hostname);
52
+ }
53
+ function sendJson(response, value, status = 200) {
54
+ response.writeHead(status, {
55
+ "content-type": "application/json; charset=utf-8",
56
+ "cache-control": "no-store",
57
+ "x-content-type-options": "nosniff",
58
+ });
59
+ response.end(JSON.stringify(value));
60
+ }
61
+ function openBrowserDefault(url) {
62
+ const command = process.platform === "darwin"
63
+ ? { file: "open", args: [url] }
64
+ : process.platform === "win32"
65
+ ? { file: "cmd", args: ["/c", "start", "", url] }
66
+ : { file: "xdg-open", args: [url] };
67
+ try {
68
+ const child = spawn(command.file, command.args, {
69
+ detached: true,
70
+ stdio: "ignore",
71
+ });
72
+ // A missing opener (e.g. no xdg-open on a headless box) fails
73
+ // asynchronously: without a listener the process-level default would
74
+ // tear down the already-running dashboard.
75
+ child.on("error", () => undefined);
76
+ child.unref();
77
+ }
78
+ catch {
79
+ // The server remains usable when no graphical opener is installed.
80
+ }
81
+ }
82
+ function parseArgs(args) {
83
+ let host = "127.0.0.1";
84
+ let port = 4317;
85
+ let token = (process.env.CODEX_MULTI_AUTH_WEB_TOKEN ?? "").trim() || null;
86
+ let refreshMs = 5000;
87
+ let noOpen = false;
88
+ for (let i = 0; i < args.length; i += 1) {
89
+ const arg = args[i] ?? "";
90
+ const next = () => {
91
+ const value = args[i + 1];
92
+ i += 1;
93
+ return value;
94
+ };
95
+ if (arg === "--host")
96
+ host = (next() ?? "").trim();
97
+ else if (arg.startsWith("--host="))
98
+ host = arg.slice("--host=".length).trim();
99
+ else if (arg === "--port")
100
+ port = parsePort(next());
101
+ else if (arg.startsWith("--port="))
102
+ port = parsePort(arg.slice("--port=".length));
103
+ else if (arg === "--token")
104
+ token = (next() ?? "").trim() || null;
105
+ else if (arg.startsWith("--token="))
106
+ token = arg.slice("--token=".length).trim() || null;
107
+ else if (arg === "--interval")
108
+ refreshMs = Math.max(1000, Number(next() ?? 5000));
109
+ else if (arg.startsWith("--interval="))
110
+ refreshMs = Math.max(1000, Number(arg.slice("--interval=".length)));
111
+ else if (arg === "--no-open")
112
+ noOpen = true;
113
+ else if (arg === "--help" || arg === "-h") {
114
+ throw new Error("Usage: codex-multi-auth web [--host 127.0.0.1] [--port 4317] [--token <token>] [--interval <ms>] [--no-open]");
115
+ }
116
+ else {
117
+ throw new Error("Unknown web option: " + arg);
118
+ }
119
+ }
120
+ if (!host)
121
+ throw new Error("Web host cannot be empty.");
122
+ if (!Number.isFinite(refreshMs) || refreshMs < 1000)
123
+ throw new Error("Web refresh interval must be at least 1000 ms.");
124
+ if (!isLoopbackHost(host) && !token) {
125
+ throw new Error("Binding the web dashboard beyond loopback requires --token or CODEX_MULTI_AUTH_WEB_TOKEN.");
126
+ }
127
+ return { host, port, token, refreshMs: Math.round(refreshMs), noOpen };
128
+ }
129
+ export async function startWebServer(options) {
130
+ const host = options.host?.trim() || "127.0.0.1";
131
+ const port = options.port ?? 4317;
132
+ const refreshMs = Math.max(1000, options.refreshMs ?? 5000);
133
+ const token = options.token?.trim() || null;
134
+ if (!isLoopbackHost(host) && !token) {
135
+ throw new Error("Binding the web dashboard beyond loopback requires a token.");
136
+ }
137
+ let latest = null;
138
+ let refreshPromise = null;
139
+ const clients = new Set();
140
+ const refresh = async () => {
141
+ if (!refreshPromise) {
142
+ refreshPromise = options.getStatus().finally(() => {
143
+ refreshPromise = null;
144
+ });
145
+ }
146
+ latest = await refreshPromise;
147
+ return latest;
148
+ };
149
+ const broadcast = (snapshot) => {
150
+ const message = "data: " + JSON.stringify(snapshot) + "\n\n";
151
+ for (const client of clients) {
152
+ try {
153
+ if (client.write(message))
154
+ continue;
155
+ // A client that stopped reading would otherwise accumulate one full
156
+ // snapshot per refresh forever. end() would stall behind its own
157
+ // unsent queue, so hard-close the connection instead.
158
+ clients.delete(client);
159
+ client.destroy();
160
+ client.socket?.destroy();
161
+ options.onSseClientDrop?.(client);
162
+ }
163
+ catch {
164
+ clients.delete(client);
165
+ }
166
+ }
167
+ };
168
+ // The request handler intentionally awaits the status read before answering;
169
+ // this keeps one response atomic while the server continues accepting SSE
170
+ // connections. Node's callback type is void-returning, so mark the promise
171
+ // boundary explicitly for the linter.
172
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
173
+ const server = createServer(async (request, response) => {
174
+ try {
175
+ if (!requestHostAllowed(request, host, token)) {
176
+ sendJson(response, { error: "Host header not allowed" }, 403);
177
+ return;
178
+ }
179
+ let requestUrl;
180
+ try {
181
+ requestUrl = new URL(request.url ?? "/", "http://" + (request.headers.host ?? host));
182
+ }
183
+ catch {
184
+ sendJson(response, { error: "Malformed request" }, 400);
185
+ return;
186
+ }
187
+ if (!authorized(request, token, requestUrl)) {
188
+ unauthorized(response);
189
+ return;
190
+ }
191
+ if (requestUrl.pathname === "/" || requestUrl.pathname === "/index.html") {
192
+ response.writeHead(200, {
193
+ "content-type": "text/html; charset=utf-8",
194
+ "cache-control": "no-store",
195
+ "x-content-type-options": "nosniff",
196
+ "content-security-policy": "default-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'",
197
+ });
198
+ response.end(renderDashboardHtml(token, options.locale));
199
+ return;
200
+ }
201
+ if (requestUrl.pathname === "/api/health") {
202
+ sendJson(response, { ok: true, service: "codex-multi-auth-web" });
203
+ return;
204
+ }
205
+ if (requestUrl.pathname === "/api/status") {
206
+ try {
207
+ sendJson(response, await refresh());
208
+ }
209
+ catch (error) {
210
+ sendJson(response, { error: error instanceof Error ? error.message : String(error) }, 503);
211
+ }
212
+ return;
213
+ }
214
+ if (requestUrl.pathname === "/events") {
215
+ // Cleanup must register before the awaited refresh: a disconnect
216
+ // during that read would otherwise leave the response registered
217
+ // until server shutdown.
218
+ response.on("close", () => clients.delete(response));
219
+ response.writeHead(200, {
220
+ "content-type": "text/event-stream; charset=utf-8",
221
+ "cache-control": "no-cache, no-store",
222
+ connection: "keep-alive",
223
+ "x-accel-buffering": "no",
224
+ });
225
+ response.write("retry: " + refreshMs + "\n\n");
226
+ clients.add(response);
227
+ try {
228
+ response.write("data: " + JSON.stringify(await refresh()) + "\n\n");
229
+ }
230
+ catch {
231
+ response.end();
232
+ }
233
+ return;
234
+ }
235
+ sendJson(response, { error: "Not found" }, 404);
236
+ }
237
+ catch {
238
+ try {
239
+ sendJson(response, { error: "Internal error" }, 500);
240
+ }
241
+ catch {
242
+ response.destroy();
243
+ }
244
+ }
245
+ });
246
+ await new Promise((resolve, reject) => {
247
+ const onError = (error) => { server.off("listening", onListening); reject(error); };
248
+ const onListening = () => { server.off("error", onError); resolve(); };
249
+ server.once("error", onError);
250
+ server.once("listening", onListening);
251
+ server.listen(port, host);
252
+ });
253
+ const address = server.address();
254
+ const actualPort = typeof address === "object" && address ? address.port : port;
255
+ const hostForUrl = host.includes(":") && !host.startsWith("[") ? "[" + host + "]" : host;
256
+ const baseUrl = "http://" + hostForUrl + ":" + actualPort + "/";
257
+ const url = token ? baseUrl + "?token=" + encodeURIComponent(token) : baseUrl;
258
+ const interval = setInterval(() => { void refresh().then(broadcast).catch(() => undefined); }, refreshMs);
259
+ interval.unref();
260
+ return {
261
+ server,
262
+ url,
263
+ token,
264
+ close: async () => {
265
+ clearInterval(interval);
266
+ for (const client of clients)
267
+ client.end();
268
+ clients.clear();
269
+ await new Promise((resolve) => server.close(() => resolve()));
270
+ },
271
+ };
272
+ }
273
+ export async function runWebCommand(args, deps) {
274
+ if (args.includes("--help") || args.includes("-h")) {
275
+ (deps.logInfo ?? ((message) => process.stdout.write(message + "\n")))("Usage: codex-multi-auth web [--host 127.0.0.1] [--port 4317] [--token <token>] [--interval <ms>] [--no-open]");
276
+ return 0;
277
+ }
278
+ let parsed;
279
+ try {
280
+ parsed = parseArgs(args);
281
+ }
282
+ catch (error) {
283
+ (deps.logInfo ?? ((message) => process.stderr.write(message + "\n")))(error instanceof Error ? error.message : String(error));
284
+ return 1;
285
+ }
286
+ const logInfo = deps.logInfo ?? ((message) => process.stdout.write(message + "\n"));
287
+ const locale = deps.locale ?? resolveOutputLocale();
288
+ let handle;
289
+ try {
290
+ handle = await startWebServer({
291
+ ...parsed,
292
+ getStatus: deps.getStatus,
293
+ openBrowser: deps.openBrowser,
294
+ locale,
295
+ });
296
+ }
297
+ catch (error) {
298
+ (deps.logInfo ?? ((message) => process.stderr.write(message + "\n")))(error instanceof Error ? error.message : String(error));
299
+ return 1;
300
+ }
301
+ logInfo("Codex Multi-Auth web dashboard: " + handle.url);
302
+ logInfo(localized(locale, `Live refresh every ${parsed.refreshMs} ms; press Ctrl-C to stop.`, `实时刷新间隔:${parsed.refreshMs} ms;按 Ctrl-C 停止。`));
303
+ if (!parsed.noOpen)
304
+ (deps.openBrowser ?? openBrowserDefault)(handle.url);
305
+ return await new Promise((resolve) => {
306
+ let stopped = false;
307
+ const stop = () => {
308
+ if (stopped)
309
+ return;
310
+ stopped = true;
311
+ process.removeListener("SIGINT", stop);
312
+ process.removeListener("SIGTERM", stop);
313
+ void handle.close().finally(() => resolve(0));
314
+ };
315
+ process.once("SIGINT", stop);
316
+ process.once("SIGTERM", stop);
317
+ });
318
+ }
319
+ export function parseWebCommandArgs(args) {
320
+ const parsed = parseArgs(args);
321
+ return { ...parsed, openBrowser: !parsed.noOpen };
322
+ }
@@ -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
+ }