claude-use 9.8.0 → 9.10.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/README.md +2 -0
- package/dist/cli.cjs +608 -536
- package/dist/index.cjs +782 -525
- package/dist/index.mjs +769 -522
- package/dist/types/index.d.ts +174 -37
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -626,9 +626,9 @@ function applyPatch(filePath, schema, patch, options = {}) {
|
|
|
626
626
|
if (!result.success) {
|
|
627
627
|
throw new ConfigValidationError(filePath, result.error.issues);
|
|
628
628
|
}
|
|
629
|
-
const
|
|
630
|
-
writeJsonAtomic(filePath,
|
|
631
|
-
return
|
|
629
|
+
const validated3 = result.data;
|
|
630
|
+
writeJsonAtomic(filePath, validated3, storeFs);
|
|
631
|
+
return validated3;
|
|
632
632
|
}
|
|
633
633
|
var import_node_fs, import_node_path3, import_node_crypto, nodeStoreFs;
|
|
634
634
|
var init_store = __esm({
|
|
@@ -2663,7 +2663,7 @@ var init_package = __esm({
|
|
|
2663
2663
|
"package.json"() {
|
|
2664
2664
|
package_default = {
|
|
2665
2665
|
name: "claude-use",
|
|
2666
|
-
version: "9.
|
|
2666
|
+
version: "9.10.0",
|
|
2667
2667
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
2668
2668
|
license: "MIT",
|
|
2669
2669
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -2891,37 +2891,37 @@ function readStartLock(fs12, lockFile) {
|
|
|
2891
2891
|
return void 0;
|
|
2892
2892
|
}
|
|
2893
2893
|
}
|
|
2894
|
-
var import_node_crypto6, import_node_path11,
|
|
2894
|
+
var import_node_crypto6, import_node_path11, import_zod6, HEADROOM_ANTHROPIC_UPSTREAM, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema;
|
|
2895
2895
|
var init_state2 = __esm({
|
|
2896
2896
|
"src/headroom/state.ts"() {
|
|
2897
2897
|
"use strict";
|
|
2898
2898
|
import_node_crypto6 = require("node:crypto");
|
|
2899
2899
|
import_node_path11 = __toESM(require("node:path"), 1);
|
|
2900
|
-
|
|
2900
|
+
import_zod6 = require("zod");
|
|
2901
2901
|
init_schema();
|
|
2902
2902
|
HEADROOM_ANTHROPIC_UPSTREAM = "https://api.anthropic.com";
|
|
2903
|
-
HeadroomStateSchema =
|
|
2903
|
+
HeadroomStateSchema = import_zod6.z.strictObject({
|
|
2904
2904
|
/** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
|
|
2905
|
-
supervisorPid:
|
|
2905
|
+
supervisorPid: import_zod6.z.number().int().positive().optional(),
|
|
2906
2906
|
/** The headroom proxy process itself. Absent while the supervisor is between restarts. */
|
|
2907
|
-
headroomPid:
|
|
2907
|
+
headroomPid: import_zod6.z.number().int().positive().optional(),
|
|
2908
2908
|
/**
|
|
2909
2909
|
* The unix socket the proxy serves on, inside the owner-only socket directory. Absent until the proxy has passed its readiness check, so "socketPath is set" is itself the ready signal a launcher polls for. The front door reads it on every hop, so a restart (which keeps the generation's path) is followed without anything being relaunched.
|
|
2910
2910
|
*/
|
|
2911
|
-
socketPath:
|
|
2911
|
+
socketPath: import_zod6.z.string().min(1).optional(),
|
|
2912
2912
|
/** The `headroom --version` output of the running install. */
|
|
2913
|
-
version:
|
|
2913
|
+
version: import_zod6.z.string().optional(),
|
|
2914
2914
|
/** Hash of the allowlist the running proxy was started with, so a provider-file change is detected as drift. */
|
|
2915
|
-
allowlistHash:
|
|
2915
|
+
allowlistHash: import_zod6.z.string().optional(),
|
|
2916
2916
|
/** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
|
|
2917
|
-
settingsHash:
|
|
2917
|
+
settingsHash: import_zod6.z.string().optional(),
|
|
2918
2918
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
2919
|
-
installedSource:
|
|
2919
|
+
installedSource: import_zod6.z.string().optional(),
|
|
2920
2920
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
2921
|
-
lastError:
|
|
2921
|
+
lastError: import_zod6.z.string().optional()
|
|
2922
2922
|
});
|
|
2923
|
-
HeadroomSessionSchema =
|
|
2924
|
-
HeadroomLockSchema =
|
|
2923
|
+
HeadroomSessionSchema = import_zod6.z.strictObject({ pid: import_zod6.z.number().int().positive(), startedAt: import_zod6.z.number(), supervisorPid: import_zod6.z.number().int().positive() });
|
|
2924
|
+
HeadroomLockSchema = import_zod6.z.strictObject({ pid: import_zod6.z.number().int().positive(), at: import_zod6.z.number() });
|
|
2925
2925
|
}
|
|
2926
2926
|
});
|
|
2927
2927
|
|
|
@@ -3128,14 +3128,14 @@ function pinnedGitCommit(spec) {
|
|
|
3128
3128
|
const ref = GIT_SPEC_RE.exec(spec)?.[1];
|
|
3129
3129
|
return ref !== void 0 && COMMIT_SHA_RE.test(ref) ? ref.toLowerCase() : void 0;
|
|
3130
3130
|
}
|
|
3131
|
-
var
|
|
3131
|
+
var import_zod7, GIT_SPEC_RE, COMMIT_SHA_RE, DirectUrlSchema;
|
|
3132
3132
|
var init_source = __esm({
|
|
3133
3133
|
"src/headroom/source.ts"() {
|
|
3134
3134
|
"use strict";
|
|
3135
|
-
|
|
3135
|
+
import_zod7 = require("zod");
|
|
3136
3136
|
GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
3137
3137
|
COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
|
|
3138
|
-
DirectUrlSchema =
|
|
3138
|
+
DirectUrlSchema = import_zod7.z.object({ vcs_info: import_zod7.z.object({ commit_id: import_zod7.z.string() }) });
|
|
3139
3139
|
}
|
|
3140
3140
|
});
|
|
3141
3141
|
|
|
@@ -3421,7 +3421,7 @@ function realIsProcessAlive(pid) {
|
|
|
3421
3421
|
}
|
|
3422
3422
|
}
|
|
3423
3423
|
function realIsProcessZombie(pid) {
|
|
3424
|
-
const result = (0,
|
|
3424
|
+
const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8" });
|
|
3425
3425
|
return result.status === 0 && result.stdout.trim().startsWith("Z");
|
|
3426
3426
|
}
|
|
3427
3427
|
function realIsProcessRunning(pid) {
|
|
@@ -3432,7 +3432,7 @@ function expandHome2(filePath) {
|
|
|
3432
3432
|
}
|
|
3433
3433
|
function hasDesktopSession() {
|
|
3434
3434
|
if (process.platform === "darwin") {
|
|
3435
|
-
const result = (0,
|
|
3435
|
+
const result = (0, import_node_child_process2.spawnSync)("launchctl", ["managername"], { encoding: "utf8" });
|
|
3436
3436
|
return result.status === 0 && result.stdout.trim() === MACOS_GUI_SESSION_MANAGER;
|
|
3437
3437
|
}
|
|
3438
3438
|
if (process.platform === "win32") {
|
|
@@ -3475,7 +3475,7 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
|
3475
3475
|
import_node_fs2.default.mkdirSync(import_node_path13.default.dirname(logPath), { recursive: true });
|
|
3476
3476
|
const logFd = import_node_fs2.default.openSync(logPath, "a");
|
|
3477
3477
|
try {
|
|
3478
|
-
const child = (0,
|
|
3478
|
+
const child = (0, import_node_child_process2.spawn)(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
|
|
3479
3479
|
child.unref();
|
|
3480
3480
|
if (child.pid === void 0) {
|
|
3481
3481
|
throw new Error(`spawning ${subcommand} returned no pid`);
|
|
@@ -3624,11 +3624,11 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
3624
3624
|
function realInstalledClaudeVersions() {
|
|
3625
3625
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
3626
3626
|
}
|
|
3627
|
-
var
|
|
3627
|
+
var import_node_child_process2, import_node_crypto8, import_node_fs2, import_node_os2, import_node_path13, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
|
|
3628
3628
|
var init_realPorts = __esm({
|
|
3629
3629
|
"src/realPorts.ts"() {
|
|
3630
3630
|
"use strict";
|
|
3631
|
-
|
|
3631
|
+
import_node_child_process2 = require("node:child_process");
|
|
3632
3632
|
import_node_crypto8 = require("node:crypto");
|
|
3633
3633
|
import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
3634
3634
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
@@ -3767,7 +3767,7 @@ var init_realPorts = __esm({
|
|
|
3767
3767
|
INT32_BYTE_LENGTH = 4;
|
|
3768
3768
|
realRunPort = {
|
|
3769
3769
|
run(command, args) {
|
|
3770
|
-
const result = (0,
|
|
3770
|
+
const result = (0, import_node_child_process2.spawnSync)(command, [...args], { encoding: "utf8" });
|
|
3771
3771
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr };
|
|
3772
3772
|
}
|
|
3773
3773
|
};
|
|
@@ -3790,7 +3790,7 @@ var init_realPorts = __esm({
|
|
|
3790
3790
|
},
|
|
3791
3791
|
runCommand(argv, options) {
|
|
3792
3792
|
const [command, ...args] = argv;
|
|
3793
|
-
const result = (0,
|
|
3793
|
+
const result = (0, import_node_child_process2.spawnSync)(command, args, {
|
|
3794
3794
|
encoding: "utf8",
|
|
3795
3795
|
timeout: options.timeoutMs,
|
|
3796
3796
|
stdio: options.interactive ? ["inherit", "pipe", "inherit"] : ["ignore", "pipe", "pipe"]
|
|
@@ -3828,7 +3828,7 @@ var init_realPorts = __esm({
|
|
|
3828
3828
|
};
|
|
3829
3829
|
realSpawnPort = {
|
|
3830
3830
|
spawnSync(command, args, options) {
|
|
3831
|
-
const result = (0,
|
|
3831
|
+
const result = (0, import_node_child_process2.spawnSync)(command, args, options);
|
|
3832
3832
|
return { status: result.status, signal: result.signal, ...result.error === void 0 ? {} : { error: result.error } };
|
|
3833
3833
|
}
|
|
3834
3834
|
};
|
|
@@ -4040,149 +4040,149 @@ var init_identity = __esm({
|
|
|
4040
4040
|
});
|
|
4041
4041
|
|
|
4042
4042
|
// src/usage/schema.ts
|
|
4043
|
-
var
|
|
4043
|
+
var import_zod8, USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
4044
4044
|
var init_schema2 = __esm({
|
|
4045
4045
|
"src/usage/schema.ts"() {
|
|
4046
4046
|
"use strict";
|
|
4047
|
-
|
|
4047
|
+
import_zod8 = require("zod");
|
|
4048
4048
|
USAGE_SCHEMA_VERSION = 1;
|
|
4049
|
-
VersionSchema =
|
|
4050
|
-
InstantSchema =
|
|
4051
|
-
TokenCountSchema =
|
|
4052
|
-
TokenUsageSchema =
|
|
4049
|
+
VersionSchema = import_zod8.z.literal(USAGE_SCHEMA_VERSION);
|
|
4050
|
+
InstantSchema = import_zod8.z.iso.datetime();
|
|
4051
|
+
TokenCountSchema = import_zod8.z.number().int().nonnegative();
|
|
4052
|
+
TokenUsageSchema = import_zod8.z.strictObject({
|
|
4053
4053
|
inputTokens: TokenCountSchema.optional(),
|
|
4054
4054
|
outputTokens: TokenCountSchema.optional(),
|
|
4055
4055
|
cacheCreationInputTokens: TokenCountSchema.optional(),
|
|
4056
4056
|
cacheReadInputTokens: TokenCountSchema.optional()
|
|
4057
4057
|
});
|
|
4058
4058
|
LIMIT_KINDS = ["rate-limited", "quota-exhausted"];
|
|
4059
|
-
LimitClassificationSchema =
|
|
4060
|
-
kind:
|
|
4059
|
+
LimitClassificationSchema = import_zod8.z.strictObject({
|
|
4060
|
+
kind: import_zod8.z.enum(LIMIT_KINDS),
|
|
4061
4061
|
/** Seconds to wait before retrying, from the response's `retry-after`. */
|
|
4062
|
-
retryAfterSeconds:
|
|
4062
|
+
retryAfterSeconds: import_zod8.z.number().nonnegative().optional(),
|
|
4063
4063
|
/** When the limiting window resets, from the upstream's own reset header. */
|
|
4064
4064
|
resetAt: InstantSchema.optional(),
|
|
4065
4065
|
/** The window the upstream named as the binding one (`anthropic-ratelimit-unified-representative-claim`), such as `five_hour` or `seven_day`. */
|
|
4066
|
-
window:
|
|
4066
|
+
window: import_zod8.z.string().optional(),
|
|
4067
4067
|
/** The signals the classification rests on, each `<name>=<value>` from a response header or the error body's `type` or `code`. Never the error message. */
|
|
4068
|
-
evidence:
|
|
4068
|
+
evidence: import_zod8.z.array(import_zod8.z.string())
|
|
4069
4069
|
});
|
|
4070
|
-
UsageRecordSchema =
|
|
4070
|
+
UsageRecordSchema = import_zod8.z.strictObject({
|
|
4071
4071
|
schemaVersion: VersionSchema,
|
|
4072
4072
|
/** When the front door received the request. */
|
|
4073
4073
|
at: InstantSchema,
|
|
4074
4074
|
/** The launching identity, when the launch resolved one. */
|
|
4075
|
-
identity:
|
|
4075
|
+
identity: import_zod8.z.string().optional(),
|
|
4076
4076
|
/** `anthropic` for an OAuth session's request to Claude Code's own API, otherwise the provider's name. */
|
|
4077
|
-
provider:
|
|
4077
|
+
provider: import_zod8.z.string(),
|
|
4078
4078
|
/** The launch's session id, generated per launch. */
|
|
4079
|
-
sessionId:
|
|
4079
|
+
sessionId: import_zod8.z.string().optional(),
|
|
4080
4080
|
/** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
|
|
4081
|
-
project:
|
|
4081
|
+
project: import_zod8.z.string().optional(),
|
|
4082
4082
|
/** The front-door route that served the request. */
|
|
4083
|
-
route:
|
|
4084
|
-
method:
|
|
4083
|
+
route: import_zod8.z.string(),
|
|
4084
|
+
method: import_zod8.z.string(),
|
|
4085
4085
|
/** The API path as the upstream sees it (`/v1/messages`), without the provider prefix or a query string. */
|
|
4086
|
-
endpoint:
|
|
4086
|
+
endpoint: import_zod8.z.string(),
|
|
4087
4087
|
/** The model the response named. */
|
|
4088
|
-
model:
|
|
4089
|
-
status:
|
|
4088
|
+
model: import_zod8.z.string().optional(),
|
|
4089
|
+
status: import_zod8.z.number().int(),
|
|
4090
4090
|
/** Milliseconds from the request's arrival to its response head. */
|
|
4091
|
-
latencyMs:
|
|
4091
|
+
latencyMs: import_zod8.z.number().int().nonnegative(),
|
|
4092
4092
|
/** Milliseconds from the request's arrival to the end of its response body. */
|
|
4093
|
-
durationMs:
|
|
4093
|
+
durationMs: import_zod8.z.number().int().nonnegative(),
|
|
4094
4094
|
/** Whether the client received the whole body. */
|
|
4095
|
-
outcome:
|
|
4095
|
+
outcome: import_zod8.z.enum(["completed", "aborted"]),
|
|
4096
4096
|
usage: TokenUsageSchema.optional(),
|
|
4097
4097
|
/** The response's quota and rate-limit headers, by name (see `isRateLimitHeader`). */
|
|
4098
|
-
rateLimitHeaders:
|
|
4098
|
+
rateLimitHeaders: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()).optional(),
|
|
4099
4099
|
limit: LimitClassificationSchema.optional(),
|
|
4100
4100
|
/** The upstream's request id (`request-id`), for matching a record to the provider's own logs. */
|
|
4101
|
-
requestId:
|
|
4101
|
+
requestId: import_zod8.z.string().optional()
|
|
4102
4102
|
});
|
|
4103
|
-
QuotaWindowSchema =
|
|
4103
|
+
QuotaWindowSchema = import_zod8.z.strictObject({
|
|
4104
4104
|
/** The fraction of the window used, as the upstream reports it (0 to 1). */
|
|
4105
|
-
utilization:
|
|
4105
|
+
utilization: import_zod8.z.number().nonnegative().optional(),
|
|
4106
4106
|
resetsAt: InstantSchema.optional(),
|
|
4107
4107
|
/** The window's own status (`allowed`, `allowed_warning`, `rejected`). */
|
|
4108
|
-
status:
|
|
4108
|
+
status: import_zod8.z.string().optional(),
|
|
4109
4109
|
/** The fraction of the window's grace allowance used, while the upstream reports the window in grace (the five-hour window only). Requests are served beyond the window's own full mark while it grows, but refusals have been seen at a small value, so nothing ranks on it. */
|
|
4110
|
-
graceUtilization:
|
|
4110
|
+
graceUtilization: import_zod8.z.number().nonnegative().optional()
|
|
4111
4111
|
});
|
|
4112
|
-
ExtraUsageSpendSchema =
|
|
4112
|
+
ExtraUsageSpendSchema = import_zod8.z.strictObject({
|
|
4113
4113
|
/** Spent so far in the allowance's period, in the currency's minor units (pence, cents). */
|
|
4114
|
-
usedMinor:
|
|
4114
|
+
usedMinor: import_zod8.z.number().nonnegative(),
|
|
4115
4115
|
/** The allowance's cap in the same units, when it has one. */
|
|
4116
|
-
limitMinor:
|
|
4116
|
+
limitMinor: import_zod8.z.number().nonnegative().optional(),
|
|
4117
4117
|
/** The ISO 4217 currency code. */
|
|
4118
|
-
currency:
|
|
4118
|
+
currency: import_zod8.z.string()
|
|
4119
4119
|
});
|
|
4120
|
-
UnifiedRateLimitSchema =
|
|
4120
|
+
UnifiedRateLimitSchema = import_zod8.z.strictObject({
|
|
4121
4121
|
/** The overall status: `allowed`, `allowed_warning` or `rejected`. */
|
|
4122
|
-
status:
|
|
4122
|
+
status: import_zod8.z.string().optional(),
|
|
4123
4123
|
fiveHour: QuotaWindowSchema.optional(),
|
|
4124
4124
|
sevenDay: QuotaWindowSchema.optional(),
|
|
4125
4125
|
/** The weekly window of the models whose usage may continue as extra usage (`7d_oi`), reported by some plans beside the all-models weekly window. */
|
|
4126
4126
|
sevenDayOverageIncluded: QuotaWindowSchema.optional(),
|
|
4127
4127
|
/** The window that currently binds. */
|
|
4128
|
-
representativeClaim:
|
|
4128
|
+
representativeClaim: import_zod8.z.string().optional(),
|
|
4129
4129
|
/** When the binding window resets. */
|
|
4130
4130
|
resetAt: InstantSchema.optional(),
|
|
4131
4131
|
/** Whether usage beyond the plan (extra usage) is available: `allowed` or `rejected`. */
|
|
4132
|
-
overageStatus:
|
|
4132
|
+
overageStatus: import_zod8.z.string().optional(),
|
|
4133
4133
|
/** The fraction of the extra-usage allowance used, as the upstream reports it (0 to 1). An account with no plan windows, such as an Enterprise one, is metered by this alone. */
|
|
4134
|
-
overageUtilization:
|
|
4134
|
+
overageUtilization: import_zod8.z.number().nonnegative().optional(),
|
|
4135
4135
|
/** When the extra-usage allowance resets. */
|
|
4136
4136
|
overageResetsAt: InstantSchema.optional(),
|
|
4137
4137
|
/** Why extra usage is unavailable, as the upstream names it (`out_of_credits`, for one). */
|
|
4138
|
-
overageDisabledReason:
|
|
4138
|
+
overageDisabledReason: import_zod8.z.string().optional(),
|
|
4139
4139
|
/** Whether the response was served on extra usage, as the upstream states it. */
|
|
4140
|
-
overageInUse:
|
|
4140
|
+
overageInUse: import_zod8.z.boolean().optional(),
|
|
4141
4141
|
/** The allowance in money, from the usage endpoint (the response headers state only the fraction). */
|
|
4142
4142
|
extraUsageSpend: ExtraUsageSpendSchema.optional(),
|
|
4143
4143
|
/** True when the upstream offers a fallback while a window is rejected: some requests, by model, are still served, though the rest are refused. */
|
|
4144
|
-
fallbackAvailable:
|
|
4144
|
+
fallbackAvailable: import_zod8.z.boolean().optional()
|
|
4145
4145
|
});
|
|
4146
|
-
RateLimitStateSchema =
|
|
4146
|
+
RateLimitStateSchema = import_zod8.z.strictObject({
|
|
4147
4147
|
observedAt: InstantSchema,
|
|
4148
4148
|
/** Every quota and rate-limit header on that response, by name. */
|
|
4149
|
-
headers:
|
|
4149
|
+
headers: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()),
|
|
4150
4150
|
unified: UnifiedRateLimitSchema.optional(),
|
|
4151
4151
|
/** When the usage endpoint last answered that it has no plan windows for the account, which a later response replaces. Its answer leaves the recorded `unified` state alone (a response's headers may be the only source of it), so this alone says the question was asked. */
|
|
4152
4152
|
planWindowsUnavailableAt: InstantSchema.optional()
|
|
4153
4153
|
});
|
|
4154
4154
|
LimitEventSchema = LimitClassificationSchema.extend({
|
|
4155
4155
|
observedAt: InstantSchema,
|
|
4156
|
-
status:
|
|
4156
|
+
status: import_zod8.z.number().int()
|
|
4157
4157
|
});
|
|
4158
|
-
ProviderQuotaWindowSchema =
|
|
4158
|
+
ProviderQuotaWindowSchema = import_zod8.z.strictObject({
|
|
4159
4159
|
/** What the window measures, in the provider's terms (`tokens`, `tool-calls`). */
|
|
4160
|
-
measures:
|
|
4160
|
+
measures: import_zod8.z.string(),
|
|
4161
4161
|
/** The window's length in milliseconds, when the provider's unit is one this project knows; absent for an unrecognised unit, with `period` carrying the raw code. */
|
|
4162
|
-
periodMs:
|
|
4162
|
+
periodMs: import_zod8.z.number().int().positive().optional(),
|
|
4163
4163
|
/** The provider's own description of the period when `periodMs` could not be derived, such as `unit 4 x 1`. */
|
|
4164
|
-
period:
|
|
4164
|
+
period: import_zod8.z.string().optional(),
|
|
4165
4165
|
/** The fraction of the window used (0 to 1). */
|
|
4166
|
-
utilization:
|
|
4166
|
+
utilization: import_zod8.z.number().nonnegative(),
|
|
4167
4167
|
resetsAt: InstantSchema.optional(),
|
|
4168
4168
|
/** Absolute counts, when the provider reports them for this window. */
|
|
4169
|
-
limit:
|
|
4170
|
-
used:
|
|
4171
|
-
remaining:
|
|
4169
|
+
limit: import_zod8.z.number().nonnegative().optional(),
|
|
4170
|
+
used: import_zod8.z.number().nonnegative().optional(),
|
|
4171
|
+
remaining: import_zod8.z.number().nonnegative().optional()
|
|
4172
4172
|
});
|
|
4173
|
-
ProviderQuotaSchema =
|
|
4173
|
+
ProviderQuotaSchema = import_zod8.z.strictObject({
|
|
4174
4174
|
observedAt: InstantSchema,
|
|
4175
4175
|
/** Which usage endpoint produced it (`z.ai`). */
|
|
4176
|
-
source:
|
|
4176
|
+
source: import_zod8.z.string(),
|
|
4177
4177
|
/** The subscription level the endpoint reports, when it does. */
|
|
4178
|
-
level:
|
|
4179
|
-
windows:
|
|
4178
|
+
level: import_zod8.z.string().optional(),
|
|
4179
|
+
windows: import_zod8.z.array(ProviderQuotaWindowSchema)
|
|
4180
4180
|
});
|
|
4181
|
-
ProviderUsageStateSchema =
|
|
4181
|
+
ProviderUsageStateSchema = import_zod8.z.strictObject({
|
|
4182
4182
|
/** When the provider last served a request for the identity through the front door. Absent while the state holds only a rate-limit state fetched from the provider's usage endpoint, for an identity that has made no request. */
|
|
4183
4183
|
lastRequestAt: InstantSchema.optional(),
|
|
4184
|
-
lastStatus:
|
|
4185
|
-
lastModel:
|
|
4184
|
+
lastStatus: import_zod8.z.number().int().optional(),
|
|
4185
|
+
lastModel: import_zod8.z.string().optional(),
|
|
4186
4186
|
/** The latest rate-limit state, from the last response that carried any rate-limit header. */
|
|
4187
4187
|
rateLimit: RateLimitStateSchema.optional(),
|
|
4188
4188
|
/** The latest classified refusal. It stays after later successes, so a reader compares its `resetAt` (or `observedAt` plus `retryAfterSeconds`) with the current time. */
|
|
@@ -4190,31 +4190,31 @@ var init_schema2 = __esm({
|
|
|
4190
4190
|
/** The latest quota the provider's usage endpoint reported, for providers whose quota is not visible in response headers. */
|
|
4191
4191
|
quota: ProviderQuotaSchema.optional()
|
|
4192
4192
|
});
|
|
4193
|
-
AccountMetadataSchema =
|
|
4194
|
-
accountUuid:
|
|
4195
|
-
emailAddress:
|
|
4196
|
-
displayName:
|
|
4197
|
-
organizationUuid:
|
|
4198
|
-
organizationName:
|
|
4199
|
-
organizationType:
|
|
4200
|
-
organizationRole:
|
|
4201
|
-
workspaceRole:
|
|
4202
|
-
billingType:
|
|
4203
|
-
seatTier:
|
|
4204
|
-
organizationRateLimitTier:
|
|
4205
|
-
userRateLimitTier:
|
|
4206
|
-
hasExtraUsageEnabled:
|
|
4207
|
-
subscriptionCreatedAt:
|
|
4208
|
-
accountCreatedAt:
|
|
4193
|
+
AccountMetadataSchema = import_zod8.z.strictObject({
|
|
4194
|
+
accountUuid: import_zod8.z.string().optional(),
|
|
4195
|
+
emailAddress: import_zod8.z.string().optional(),
|
|
4196
|
+
displayName: import_zod8.z.string().optional(),
|
|
4197
|
+
organizationUuid: import_zod8.z.string().optional(),
|
|
4198
|
+
organizationName: import_zod8.z.string().optional(),
|
|
4199
|
+
organizationType: import_zod8.z.string().optional(),
|
|
4200
|
+
organizationRole: import_zod8.z.string().optional(),
|
|
4201
|
+
workspaceRole: import_zod8.z.string().optional(),
|
|
4202
|
+
billingType: import_zod8.z.string().optional(),
|
|
4203
|
+
seatTier: import_zod8.z.string().optional(),
|
|
4204
|
+
organizationRateLimitTier: import_zod8.z.string().optional(),
|
|
4205
|
+
userRateLimitTier: import_zod8.z.string().optional(),
|
|
4206
|
+
hasExtraUsageEnabled: import_zod8.z.boolean().optional(),
|
|
4207
|
+
subscriptionCreatedAt: import_zod8.z.string().optional(),
|
|
4208
|
+
accountCreatedAt: import_zod8.z.string().optional()
|
|
4209
4209
|
});
|
|
4210
|
-
UsageSnapshotSchema =
|
|
4210
|
+
UsageSnapshotSchema = import_zod8.z.strictObject({
|
|
4211
4211
|
schemaVersion: VersionSchema,
|
|
4212
|
-
identity:
|
|
4212
|
+
identity: import_zod8.z.string(),
|
|
4213
4213
|
updatedAt: InstantSchema,
|
|
4214
4214
|
/** The identity's account metadata as of `updatedAt`. */
|
|
4215
4215
|
account: AccountMetadataSchema.optional(),
|
|
4216
4216
|
/** Latest state per provider, keyed by provider name (`anthropic` for OAuth sessions). */
|
|
4217
|
-
providers:
|
|
4217
|
+
providers: import_zod8.z.record(import_zod8.z.string(), ProviderUsageStateSchema)
|
|
4218
4218
|
});
|
|
4219
4219
|
}
|
|
4220
4220
|
});
|
|
@@ -4321,24 +4321,24 @@ function planOf(account) {
|
|
|
4321
4321
|
}
|
|
4322
4322
|
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
4323
4323
|
}
|
|
4324
|
-
var
|
|
4324
|
+
var import_zod9, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
4325
4325
|
var init_plan2 = __esm({
|
|
4326
4326
|
"src/usage/plan.ts"() {
|
|
4327
4327
|
"use strict";
|
|
4328
|
-
|
|
4329
|
-
PlanClassSchema =
|
|
4330
|
-
|
|
4331
|
-
kind:
|
|
4328
|
+
import_zod9 = require("zod");
|
|
4329
|
+
PlanClassSchema = import_zod9.z.union([
|
|
4330
|
+
import_zod9.z.strictObject({
|
|
4331
|
+
kind: import_zod9.z.literal("subscription"),
|
|
4332
4332
|
/** The plan's size as a multiple of the smallest subscription tier (Max 5x is 5, Max 20x is 20). */
|
|
4333
|
-
capacity:
|
|
4333
|
+
capacity: import_zod9.z.number().positive(),
|
|
4334
4334
|
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
4335
|
-
recognised:
|
|
4335
|
+
recognised: import_zod9.z.boolean(),
|
|
4336
4336
|
/** The tier string the classification rests on, when the account had one. */
|
|
4337
|
-
tier:
|
|
4337
|
+
tier: import_zod9.z.string().optional()
|
|
4338
4338
|
}),
|
|
4339
|
-
|
|
4340
|
-
kind:
|
|
4341
|
-
tier:
|
|
4339
|
+
import_zod9.z.strictObject({
|
|
4340
|
+
kind: import_zod9.z.literal("pay-per-use"),
|
|
4341
|
+
tier: import_zod9.z.string().optional()
|
|
4342
4342
|
})
|
|
4343
4343
|
]);
|
|
4344
4344
|
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
@@ -4439,21 +4439,21 @@ var init_rateLimit = __esm({
|
|
|
4439
4439
|
});
|
|
4440
4440
|
|
|
4441
4441
|
// src/usage/scan.ts
|
|
4442
|
-
var
|
|
4442
|
+
var import_zod10, AnthropicUsageSchema, ErrorObjectSchema;
|
|
4443
4443
|
var init_scan = __esm({
|
|
4444
4444
|
"src/usage/scan.ts"() {
|
|
4445
4445
|
"use strict";
|
|
4446
|
-
|
|
4447
|
-
AnthropicUsageSchema =
|
|
4448
|
-
input_tokens:
|
|
4449
|
-
output_tokens:
|
|
4450
|
-
cache_creation_input_tokens:
|
|
4451
|
-
cache_read_input_tokens:
|
|
4446
|
+
import_zod10 = require("zod");
|
|
4447
|
+
AnthropicUsageSchema = import_zod10.z.looseObject({
|
|
4448
|
+
input_tokens: import_zod10.z.number().int().nonnegative().nullish(),
|
|
4449
|
+
output_tokens: import_zod10.z.number().int().nonnegative().nullish(),
|
|
4450
|
+
cache_creation_input_tokens: import_zod10.z.number().int().nonnegative().nullish(),
|
|
4451
|
+
cache_read_input_tokens: import_zod10.z.number().int().nonnegative().nullish()
|
|
4452
4452
|
});
|
|
4453
|
-
ErrorObjectSchema =
|
|
4454
|
-
type:
|
|
4455
|
-
code:
|
|
4456
|
-
message:
|
|
4453
|
+
ErrorObjectSchema = import_zod10.z.looseObject({
|
|
4454
|
+
type: import_zod10.z.string().optional(),
|
|
4455
|
+
code: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]).optional(),
|
|
4456
|
+
message: import_zod10.z.string().optional()
|
|
4457
4457
|
});
|
|
4458
4458
|
}
|
|
4459
4459
|
});
|
|
@@ -5156,12 +5156,12 @@ function recordStickyPick(fs12, picksFile, directory, identity, nowMs) {
|
|
|
5156
5156
|
fs12.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
|
|
5157
5157
|
`);
|
|
5158
5158
|
}
|
|
5159
|
-
var import_node_path20,
|
|
5159
|
+
var import_node_path20, import_zod11, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
|
|
5160
5160
|
var init_poolPick = __esm({
|
|
5161
5161
|
"src/usage/poolPick.ts"() {
|
|
5162
5162
|
"use strict";
|
|
5163
5163
|
import_node_path20 = __toESM(require("node:path"), 1);
|
|
5164
|
-
|
|
5164
|
+
import_zod11 = require("zod");
|
|
5165
5165
|
init_cliError();
|
|
5166
5166
|
init_identity();
|
|
5167
5167
|
init_schema();
|
|
@@ -5177,10 +5177,10 @@ var init_poolPick = __esm({
|
|
|
5177
5177
|
}
|
|
5178
5178
|
};
|
|
5179
5179
|
SCHEMA_VERSION = 1;
|
|
5180
|
-
PickEntrySchema =
|
|
5181
|
-
PicksFileSchema =
|
|
5182
|
-
schemaVersion:
|
|
5183
|
-
picks:
|
|
5180
|
+
PickEntrySchema = import_zod11.z.strictObject({ identity: import_zod11.z.string().min(1), at: import_zod11.z.iso.datetime() });
|
|
5181
|
+
PicksFileSchema = import_zod11.z.strictObject({
|
|
5182
|
+
schemaVersion: import_zod11.z.literal(SCHEMA_VERSION),
|
|
5183
|
+
picks: import_zod11.z.record(import_zod11.z.string().min(1), PickEntrySchema)
|
|
5184
5184
|
});
|
|
5185
5185
|
}
|
|
5186
5186
|
});
|
|
@@ -5239,7 +5239,8 @@ function buildLayoutPaths(root) {
|
|
|
5239
5239
|
usageDir: import_node_path22.default.join(root, "usage"),
|
|
5240
5240
|
usageLogDir: import_node_path22.default.join(root, "usage", "log"),
|
|
5241
5241
|
usageSnapshotsDir: import_node_path22.default.join(root, "usage", "snapshots"),
|
|
5242
|
-
usagePicksFile: import_node_path22.default.join(root, "usage", "picks.json")
|
|
5242
|
+
usagePicksFile: import_node_path22.default.join(root, "usage", "picks.json"),
|
|
5243
|
+
mcpPermissionsFile: import_node_path22.default.join(root, "mcp", "permissions.json")
|
|
5243
5244
|
};
|
|
5244
5245
|
}
|
|
5245
5246
|
function resolveLayoutPaths() {
|
|
@@ -5316,17 +5317,17 @@ function formatCachedCredentialState(state) {
|
|
|
5316
5317
|
}
|
|
5317
5318
|
return state.status === "fresh" ? `${age}, expires in ${formatAge(state.expiresInMs)}` : `${age}, expired ${formatAge(-state.expiresInMs)} ago`;
|
|
5318
5319
|
}
|
|
5319
|
-
var
|
|
5320
|
+
var import_zod12, MS_PER_UNIT, CachedCredentialSchema;
|
|
5320
5321
|
var init_credentialCache = __esm({
|
|
5321
5322
|
"src/credentialCache.ts"() {
|
|
5322
5323
|
"use strict";
|
|
5323
|
-
|
|
5324
|
+
import_zod12 = require("zod");
|
|
5324
5325
|
init_schema();
|
|
5325
5326
|
init_preflight();
|
|
5326
5327
|
MS_PER_UNIT = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
|
|
5327
|
-
CachedCredentialSchema =
|
|
5328
|
-
token:
|
|
5329
|
-
fetchedAt:
|
|
5328
|
+
CachedCredentialSchema = import_zod12.z.strictObject({
|
|
5329
|
+
token: import_zod12.z.string().min(1),
|
|
5330
|
+
fetchedAt: import_zod12.z.number().int().nonnegative(),
|
|
5330
5331
|
source: CredentialSourceSchema
|
|
5331
5332
|
});
|
|
5332
5333
|
}
|
|
@@ -5352,7 +5353,7 @@ function requireKeychain() {
|
|
|
5352
5353
|
}
|
|
5353
5354
|
}
|
|
5354
5355
|
function security(args, stdin) {
|
|
5355
|
-
const result = (0,
|
|
5356
|
+
const result = (0, import_node_child_process3.spawnSync)("security", args, { encoding: "utf8", ...stdin === void 0 ? {} : { input: stdin }, stdio: ["pipe", "pipe", "ignore"] });
|
|
5356
5357
|
return { status: result.status, stdout: result.stdout };
|
|
5357
5358
|
}
|
|
5358
5359
|
function createRealCredentialCache(root) {
|
|
@@ -5403,11 +5404,11 @@ function createRealCredentialCache(root) {
|
|
|
5403
5404
|
function realCredentialCacheEnv(paths) {
|
|
5404
5405
|
return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
5405
5406
|
}
|
|
5406
|
-
var
|
|
5407
|
+
var import_node_child_process3, import_node_fs5, import_node_path23, KEYCHAIN_CACHE_SERVICE, CACHE_DIR_MODE, CACHE_FILE_MODE;
|
|
5407
5408
|
var init_realCredentialCache = __esm({
|
|
5408
5409
|
"src/realCredentialCache.ts"() {
|
|
5409
5410
|
"use strict";
|
|
5410
|
-
|
|
5411
|
+
import_node_child_process3 = require("node:child_process");
|
|
5411
5412
|
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
5412
5413
|
import_node_path23 = __toESM(require("node:path"), 1);
|
|
5413
5414
|
init_credentialCache();
|
|
@@ -5928,7 +5929,7 @@ var init_envBool = __esm({
|
|
|
5928
5929
|
});
|
|
5929
5930
|
|
|
5930
5931
|
// src/launcher/claudeVersion.ts
|
|
5931
|
-
function
|
|
5932
|
+
function validated2(value, origin) {
|
|
5932
5933
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
5933
5934
|
throw new InvalidClaudeVersionError(value, origin);
|
|
5934
5935
|
}
|
|
@@ -5936,11 +5937,11 @@ function validated(value, origin) {
|
|
|
5936
5937
|
}
|
|
5937
5938
|
function resolveClaudeVersion(params) {
|
|
5938
5939
|
if (params.flag !== void 0) {
|
|
5939
|
-
return { version:
|
|
5940
|
+
return { version: validated2(params.flag, "--claude-version"), source: "flag" };
|
|
5940
5941
|
}
|
|
5941
5942
|
const fromEnv = params.env.AGENT_SHIM_CLAUDE_VERSION;
|
|
5942
5943
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
5943
|
-
return { version:
|
|
5944
|
+
return { version: validated2(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
|
|
5944
5945
|
}
|
|
5945
5946
|
return params.cascade === void 0 ? void 0 : { version: params.cascade, source: "cascade" };
|
|
5946
5947
|
}
|
|
@@ -6067,21 +6068,21 @@ function findPathShadow(params) {
|
|
|
6067
6068
|
}
|
|
6068
6069
|
return params.pathDirs.some((dir) => import_node_path26.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
6069
6070
|
}
|
|
6070
|
-
var import_node_fs7, import_node_path26,
|
|
6071
|
+
var import_node_fs7, import_node_path26, import_zod16, ClaudeShimStateSchema, nodeLinkFs;
|
|
6071
6072
|
var init_claudeShim = __esm({
|
|
6072
6073
|
"src/claudeShim.ts"() {
|
|
6073
6074
|
"use strict";
|
|
6074
6075
|
import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
6075
6076
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
6076
|
-
|
|
6077
|
+
import_zod16 = require("zod");
|
|
6077
6078
|
init_commandDeps();
|
|
6078
6079
|
init_store();
|
|
6079
6080
|
init_realPorts();
|
|
6080
6081
|
init_cliError();
|
|
6081
|
-
ClaudeShimStateSchema =
|
|
6082
|
-
targetPath:
|
|
6083
|
-
method:
|
|
6084
|
-
installedAtMs:
|
|
6082
|
+
ClaudeShimStateSchema = import_zod16.z.strictObject({
|
|
6083
|
+
targetPath: import_zod16.z.string().min(1),
|
|
6084
|
+
method: import_zod16.z.enum(["hardlink", "copy"]),
|
|
6085
|
+
installedAtMs: import_zod16.z.number()
|
|
6085
6086
|
});
|
|
6086
6087
|
nodeLinkFs = { link: import_node_fs7.default.linkSync, copyFile: import_node_fs7.default.copyFileSync, chmod: import_node_fs7.default.chmodSync };
|
|
6087
6088
|
}
|
|
@@ -7207,10 +7208,10 @@ function resolveLaunch(params) {
|
|
|
7207
7208
|
environment
|
|
7208
7209
|
};
|
|
7209
7210
|
}
|
|
7210
|
-
function runLaunchPlan(plan,
|
|
7211
|
+
function runLaunchPlan(plan, spawn3) {
|
|
7211
7212
|
try {
|
|
7212
7213
|
plan.markChildStarted();
|
|
7213
|
-
const result =
|
|
7214
|
+
const result = spawn3.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
|
|
7214
7215
|
if (result.error !== void 0) {
|
|
7215
7216
|
throw result.error;
|
|
7216
7217
|
}
|
|
@@ -7717,11 +7718,11 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
7717
7718
|
});
|
|
7718
7719
|
|
|
7719
7720
|
// src/usage/providerQuota.ts
|
|
7720
|
-
var
|
|
7721
|
+
var import_zod24, MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY3, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema;
|
|
7721
7722
|
var init_providerQuota = __esm({
|
|
7722
7723
|
"src/usage/providerQuota.ts"() {
|
|
7723
7724
|
"use strict";
|
|
7724
|
-
|
|
7725
|
+
import_zod24 = require("zod");
|
|
7725
7726
|
init_schema2();
|
|
7726
7727
|
MS_PER_SECOND7 = 1e3;
|
|
7727
7728
|
SECONDS_PER_HOUR = 3600;
|
|
@@ -7735,35 +7736,35 @@ var init_providerQuota = __esm({
|
|
|
7735
7736
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
|
|
7736
7737
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7]
|
|
7737
7738
|
]);
|
|
7738
|
-
ZaiLimitSchema =
|
|
7739
|
-
type:
|
|
7740
|
-
unit:
|
|
7741
|
-
number:
|
|
7742
|
-
percentage:
|
|
7743
|
-
nextResetTime:
|
|
7744
|
-
usage:
|
|
7745
|
-
currentValue:
|
|
7746
|
-
remaining:
|
|
7739
|
+
ZaiLimitSchema = import_zod24.z.object({
|
|
7740
|
+
type: import_zod24.z.string(),
|
|
7741
|
+
unit: import_zod24.z.number().int(),
|
|
7742
|
+
number: import_zod24.z.number().int().positive(),
|
|
7743
|
+
percentage: import_zod24.z.number().nonnegative(),
|
|
7744
|
+
nextResetTime: import_zod24.z.number().positive().optional(),
|
|
7745
|
+
usage: import_zod24.z.number().nonnegative().optional(),
|
|
7746
|
+
currentValue: import_zod24.z.number().nonnegative().optional(),
|
|
7747
|
+
remaining: import_zod24.z.number().nonnegative().optional()
|
|
7747
7748
|
});
|
|
7748
|
-
ZaiResponseSchema =
|
|
7749
|
-
success:
|
|
7750
|
-
msg:
|
|
7751
|
-
data:
|
|
7749
|
+
ZaiResponseSchema = import_zod24.z.object({
|
|
7750
|
+
success: import_zod24.z.boolean(),
|
|
7751
|
+
msg: import_zod24.z.string().optional(),
|
|
7752
|
+
data: import_zod24.z.object({ level: import_zod24.z.string().optional(), limits: import_zod24.z.array(ZaiLimitSchema) })
|
|
7752
7753
|
});
|
|
7753
7754
|
OPENROUTER_HOST = "openrouter.ai";
|
|
7754
7755
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
7755
7756
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
7756
7757
|
MS_PER_DAY3 = HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7;
|
|
7757
|
-
OpenRouterKeySchema =
|
|
7758
|
-
data:
|
|
7759
|
-
limit:
|
|
7760
|
-
limit_remaining:
|
|
7761
|
-
limit_reset:
|
|
7762
|
-
is_free_tier:
|
|
7763
|
-
free_model_daily_requests:
|
|
7758
|
+
OpenRouterKeySchema = import_zod24.z.object({
|
|
7759
|
+
data: import_zod24.z.object({
|
|
7760
|
+
limit: import_zod24.z.number().nonnegative().nullable(),
|
|
7761
|
+
limit_remaining: import_zod24.z.number().nullable(),
|
|
7762
|
+
limit_reset: import_zod24.z.string().nullable(),
|
|
7763
|
+
is_free_tier: import_zod24.z.boolean().optional(),
|
|
7764
|
+
free_model_daily_requests: import_zod24.z.object({ used: import_zod24.z.number().nonnegative(), limit: import_zod24.z.number().nonnegative(), remaining: import_zod24.z.number() }).optional()
|
|
7764
7765
|
})
|
|
7765
7766
|
});
|
|
7766
|
-
OpenRouterCreditsSchema =
|
|
7767
|
+
OpenRouterCreditsSchema = import_zod24.z.object({ data: import_zod24.z.object({ total_credits: import_zod24.z.number().nonnegative(), total_usage: import_zod24.z.number().nonnegative() }) });
|
|
7767
7768
|
}
|
|
7768
7769
|
});
|
|
7769
7770
|
|
|
@@ -7885,6 +7886,8 @@ var index_exports = {};
|
|
|
7885
7886
|
__export(index_exports, {
|
|
7886
7887
|
AMBIENT_CREDENTIAL_VARS: () => AMBIENT_CREDENTIAL_VARS,
|
|
7887
7888
|
CHECK_CREDENTIAL_APPLIES: () => CHECK_CREDENTIAL_APPLIES,
|
|
7889
|
+
CODEX_APP_SERVER_GENERATED_AGAINST: () => CODEX_APP_SERVER_GENERATED_AGAINST,
|
|
7890
|
+
CODEX_APP_SERVER_TIMEOUT_MS: () => CODEX_APP_SERVER_TIMEOUT_MS,
|
|
7888
7891
|
CONNECT_INTERCEPT_HOST: () => CONNECT_INTERCEPT_HOST,
|
|
7889
7892
|
CONNECT_INTERCEPT_HOSTS: () => CONNECT_INTERCEPT_HOSTS,
|
|
7890
7893
|
CONNECT_LIMITS: () => CONNECT_LIMITS,
|
|
@@ -7895,7 +7898,12 @@ __export(index_exports, {
|
|
|
7895
7898
|
CheckReportJsonSchema: () => CheckReportJsonSchema,
|
|
7896
7899
|
CheckRunInputSchema: () => CheckRunInputSchema,
|
|
7897
7900
|
CliError: () => CliError,
|
|
7901
|
+
CodexAccountReadSchema: () => CodexAccountReadSchema,
|
|
7902
|
+
CodexAppServerProtocolError: () => CodexAppServerProtocolError,
|
|
7903
|
+
CodexAppServerRequestError: () => CodexAppServerRequestError,
|
|
7904
|
+
CodexAppServerUnavailableError: () => CodexAppServerUnavailableError,
|
|
7898
7905
|
CodexLogoutOutputSchema: () => CodexLogoutOutputSchema,
|
|
7906
|
+
CodexRateLimitsReadSchema: () => CodexRateLimitsReadSchema,
|
|
7899
7907
|
CodexSignInSchema: () => CodexSignInSchema,
|
|
7900
7908
|
CodexStatusOutputSchema: () => CodexStatusOutputSchema,
|
|
7901
7909
|
ConfigIdentityAddOutputSchema: () => ConfigIdentityAddOutputSchema,
|
|
@@ -8153,6 +8161,8 @@ __export(index_exports, {
|
|
|
8153
8161
|
rcSelfHostFromEnv: () => rcSelfHostFromEnv,
|
|
8154
8162
|
rcWebFetchAllowsPrivateFromEnv: () => rcWebFetchAllowsPrivateFromEnv,
|
|
8155
8163
|
readActiveIdentity: () => readActiveIdentity2,
|
|
8164
|
+
readCodexAccount: () => readCodexAccount,
|
|
8165
|
+
readCodexRateLimits: () => readCodexRateLimits,
|
|
8156
8166
|
readDirectoryRules: () => readDirectoryRules,
|
|
8157
8167
|
readFarmManifest: () => readFarmManifest,
|
|
8158
8168
|
readFrontDoorControlMaterial: () => readFrontDoorControlMaterial,
|
|
@@ -8164,6 +8174,7 @@ __export(index_exports, {
|
|
|
8164
8174
|
readRcSelfHostRecord: () => readRcSelfHostRecord,
|
|
8165
8175
|
readRcSessionFile: () => readRcSessionFile,
|
|
8166
8176
|
readUsageSnapshot: () => readUsageSnapshot,
|
|
8177
|
+
realCodexAppServerPort: () => realCodexAppServerPort,
|
|
8167
8178
|
realConnectCertStore: () => realConnectCertStore,
|
|
8168
8179
|
realConnectEffects: () => realConnectEffects,
|
|
8169
8180
|
realRcControlTransport: () => realRcControlTransport,
|
|
@@ -11268,6 +11279,242 @@ function frontDoorRcApiClient(port, ca, token) {
|
|
|
11268
11279
|
return (0, import_client.createORPCClient)(frontDoorApiLink(port, ca, token));
|
|
11269
11280
|
}
|
|
11270
11281
|
|
|
11282
|
+
// src/codex/appServer.ts
|
|
11283
|
+
init_cliError();
|
|
11284
|
+
init_package();
|
|
11285
|
+
|
|
11286
|
+
// src/codex/appServerSchemas.ts
|
|
11287
|
+
var import_zod5 = require("zod");
|
|
11288
|
+
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
11289
|
+
var RateLimitWindowSchema = import_zod5.z.object({
|
|
11290
|
+
usedPercent: import_zod5.z.number(),
|
|
11291
|
+
resetsAt: import_zod5.z.number().nullish(),
|
|
11292
|
+
windowDurationMins: import_zod5.z.number().nullish()
|
|
11293
|
+
});
|
|
11294
|
+
var RateLimitSnapshotSchema = import_zod5.z.object({
|
|
11295
|
+
limitId: import_zod5.z.string().nullish(),
|
|
11296
|
+
limitName: import_zod5.z.string().nullish(),
|
|
11297
|
+
planType: import_zod5.z.string().nullish(),
|
|
11298
|
+
primary: RateLimitWindowSchema.nullish(),
|
|
11299
|
+
secondary: RateLimitWindowSchema.nullish(),
|
|
11300
|
+
rateLimitReachedType: import_zod5.z.string().nullish(),
|
|
11301
|
+
spendControlReached: import_zod5.z.boolean().nullish()
|
|
11302
|
+
});
|
|
11303
|
+
var RateLimitResetCreditSchema = import_zod5.z.object({
|
|
11304
|
+
id: import_zod5.z.string(),
|
|
11305
|
+
grantedAt: import_zod5.z.number(),
|
|
11306
|
+
expiresAt: import_zod5.z.number().nullish(),
|
|
11307
|
+
resetType: import_zod5.z.string(),
|
|
11308
|
+
status: import_zod5.z.string(),
|
|
11309
|
+
title: import_zod5.z.string().nullish(),
|
|
11310
|
+
description: import_zod5.z.string().nullish()
|
|
11311
|
+
});
|
|
11312
|
+
var CodexAccountSchema = import_zod5.z.discriminatedUnion("type", [
|
|
11313
|
+
import_zod5.z.object({ type: import_zod5.z.literal("apiKey") }),
|
|
11314
|
+
import_zod5.z.object({ type: import_zod5.z.literal("chatgpt"), email: import_zod5.z.string().nullable(), planType: import_zod5.z.string() }),
|
|
11315
|
+
import_zod5.z.object({ type: import_zod5.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod5.z.boolean().default(false) })
|
|
11316
|
+
]);
|
|
11317
|
+
var CodexAccountReadSchema = import_zod5.z.object({
|
|
11318
|
+
account: CodexAccountSchema.nullable(),
|
|
11319
|
+
requiresOpenaiAuth: import_zod5.z.boolean()
|
|
11320
|
+
});
|
|
11321
|
+
var CodexRateLimitsReadSchema = import_zod5.z.object({
|
|
11322
|
+
rateLimits: RateLimitSnapshotSchema,
|
|
11323
|
+
rateLimitsByLimitId: import_zod5.z.record(import_zod5.z.string(), RateLimitSnapshotSchema).nullish(),
|
|
11324
|
+
rateLimitResetCredits: import_zod5.z.object({ availableCount: import_zod5.z.number(), credits: import_zod5.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
11325
|
+
accountId: import_zod5.z.string().nullish(),
|
|
11326
|
+
ordinaryUsageAllowed: import_zod5.z.boolean().nullish()
|
|
11327
|
+
});
|
|
11328
|
+
var CodexInitializeResultSchema = import_zod5.z.object({ userAgent: import_zod5.z.string() });
|
|
11329
|
+
|
|
11330
|
+
// src/codex/appServer.ts
|
|
11331
|
+
var CodexAppServerUnavailableError = class extends CliError {
|
|
11332
|
+
constructor(detail) {
|
|
11333
|
+
super(`The Codex app-server is not available: ${detail}.`);
|
|
11334
|
+
this.name = "CodexAppServerUnavailableError";
|
|
11335
|
+
}
|
|
11336
|
+
};
|
|
11337
|
+
var CodexAppServerRequestError = class extends CliError {
|
|
11338
|
+
constructor(method, rpcCode, detail) {
|
|
11339
|
+
super(`Codex app-server ${method} failed (${String(rpcCode)}): ${detail}`);
|
|
11340
|
+
this.method = method;
|
|
11341
|
+
this.rpcCode = rpcCode;
|
|
11342
|
+
this.name = "CodexAppServerRequestError";
|
|
11343
|
+
}
|
|
11344
|
+
method;
|
|
11345
|
+
rpcCode;
|
|
11346
|
+
};
|
|
11347
|
+
var CodexAppServerProtocolError = class extends CliError {
|
|
11348
|
+
constructor(method, installedVersion, detail) {
|
|
11349
|
+
super(
|
|
11350
|
+
`Codex app-server ${method} answered in a shape this reader does not know (installed Codex ${installedVersion ?? "of unknown version"}, shapes generated against ${CODEX_APP_SERVER_GENERATED_AGAINST}): ${detail}`
|
|
11351
|
+
);
|
|
11352
|
+
this.method = method;
|
|
11353
|
+
this.installedVersion = installedVersion;
|
|
11354
|
+
this.name = "CodexAppServerProtocolError";
|
|
11355
|
+
}
|
|
11356
|
+
method;
|
|
11357
|
+
installedVersion;
|
|
11358
|
+
};
|
|
11359
|
+
var CODEX_APP_SERVER_TIMEOUT_MS = 3e4;
|
|
11360
|
+
var CLIENT_NAME = "agent-shim";
|
|
11361
|
+
function installedVersionOf(userAgent) {
|
|
11362
|
+
return /^[^/\s]+\/(\S+)/.exec(userAgent)?.[1];
|
|
11363
|
+
}
|
|
11364
|
+
function responseTo(message, id) {
|
|
11365
|
+
if (typeof message !== "object" || message === null || !("id" in message) || message.id !== id) {
|
|
11366
|
+
return void 0;
|
|
11367
|
+
}
|
|
11368
|
+
if ("error" in message && typeof message.error === "object" && message.error !== null) {
|
|
11369
|
+
const { error } = message;
|
|
11370
|
+
const code = "code" in error && typeof error.code === "number" ? error.code : 0;
|
|
11371
|
+
const detail = "message" in error && typeof error.message === "string" ? error.message : "no message";
|
|
11372
|
+
return { error: { code, message: detail } };
|
|
11373
|
+
}
|
|
11374
|
+
return "result" in message ? { result: message.result } : void 0;
|
|
11375
|
+
}
|
|
11376
|
+
async function withAppServer(port, options, ask) {
|
|
11377
|
+
const connection = await port.open({ bin: options.bin ?? "codex", codexHome: options.codexHome });
|
|
11378
|
+
let nextId = 0;
|
|
11379
|
+
const timeoutMs = options.timeoutMs ?? CODEX_APP_SERVER_TIMEOUT_MS;
|
|
11380
|
+
const stopper = AbortSignal.any([...options.signal === void 0 ? [] : [options.signal], AbortSignal.timeout(timeoutMs)]);
|
|
11381
|
+
const stopReason = () => {
|
|
11382
|
+
if (options.signal?.aborted !== true) {
|
|
11383
|
+
return new CodexAppServerUnavailableError(`it did not answer within ${String(timeoutMs)} ms`);
|
|
11384
|
+
}
|
|
11385
|
+
const reason = options.signal.reason;
|
|
11386
|
+
return reason instanceof Error ? reason : new Error(`the Codex app-server read was aborted: ${String(reason)}`);
|
|
11387
|
+
};
|
|
11388
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
11389
|
+
if (stopper.aborted) {
|
|
11390
|
+
reject(stopReason());
|
|
11391
|
+
return;
|
|
11392
|
+
}
|
|
11393
|
+
stopper.addEventListener(
|
|
11394
|
+
"abort",
|
|
11395
|
+
() => {
|
|
11396
|
+
reject(stopReason());
|
|
11397
|
+
},
|
|
11398
|
+
{ once: true }
|
|
11399
|
+
);
|
|
11400
|
+
});
|
|
11401
|
+
aborted.catch(() => void 0);
|
|
11402
|
+
const request4 = async (method, params) => {
|
|
11403
|
+
nextId += 1;
|
|
11404
|
+
const id = nextId;
|
|
11405
|
+
connection.send({ jsonrpc: "2.0", id, method, params });
|
|
11406
|
+
for (; ; ) {
|
|
11407
|
+
const message = await Promise.race([connection.receive(), aborted]);
|
|
11408
|
+
if (message === void 0) {
|
|
11409
|
+
throw new CodexAppServerUnavailableError(`it ended before answering ${method}`);
|
|
11410
|
+
}
|
|
11411
|
+
const response = responseTo(message, id);
|
|
11412
|
+
if (response === void 0) {
|
|
11413
|
+
continue;
|
|
11414
|
+
}
|
|
11415
|
+
if ("error" in response) {
|
|
11416
|
+
throw new CodexAppServerRequestError(method, response.error.code, response.error.message);
|
|
11417
|
+
}
|
|
11418
|
+
return response.result;
|
|
11419
|
+
}
|
|
11420
|
+
};
|
|
11421
|
+
try {
|
|
11422
|
+
const initialised = CodexInitializeResultSchema.safeParse(await request4("initialize", { clientInfo: { name: CLIENT_NAME, title: null, version: package_default.version } }));
|
|
11423
|
+
if (!initialised.success) {
|
|
11424
|
+
throw new CodexAppServerProtocolError("initialize", void 0, initialised.error.message);
|
|
11425
|
+
}
|
|
11426
|
+
connection.send({ jsonrpc: "2.0", method: "initialized" });
|
|
11427
|
+
return await ask(request4, installedVersionOf(initialised.data.userAgent));
|
|
11428
|
+
} finally {
|
|
11429
|
+
await connection.close();
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
function validated(method, installedVersion, schema, value) {
|
|
11433
|
+
const parsed = schema.safeParse(value);
|
|
11434
|
+
if (!parsed.success) {
|
|
11435
|
+
throw new CodexAppServerProtocolError(method, installedVersion, parsed.error.message);
|
|
11436
|
+
}
|
|
11437
|
+
return parsed.data;
|
|
11438
|
+
}
|
|
11439
|
+
async function readCodexAccount(port, options) {
|
|
11440
|
+
return await withAppServer(port, options, async (request4, version) => validated("account/read", version, CodexAccountReadSchema, await request4("account/read", { refreshToken: false })));
|
|
11441
|
+
}
|
|
11442
|
+
async function readCodexRateLimits(port, options) {
|
|
11443
|
+
return await withAppServer(port, options, async (request4, version) => validated("account/rateLimits/read", version, CodexRateLimitsReadSchema, await request4("account/rateLimits/read", void 0)));
|
|
11444
|
+
}
|
|
11445
|
+
|
|
11446
|
+
// src/codex/realAppServer.ts
|
|
11447
|
+
var import_node_child_process = require("node:child_process");
|
|
11448
|
+
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
11449
|
+
var SHUTDOWN_GRACE_MS = 5e3;
|
|
11450
|
+
var realCodexAppServerPort = {
|
|
11451
|
+
open: async ({ bin, codexHome }) => {
|
|
11452
|
+
const child = (0, import_node_child_process.spawn)(bin, ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
|
|
11453
|
+
await new Promise((resolve, reject) => {
|
|
11454
|
+
child.once("spawn", resolve);
|
|
11455
|
+
child.once("error", (error) => {
|
|
11456
|
+
reject(new CodexAppServerUnavailableError(`${bin} could not be started (${error.message})`));
|
|
11457
|
+
});
|
|
11458
|
+
});
|
|
11459
|
+
const exited = new Promise((resolve) => {
|
|
11460
|
+
child.once("exit", () => {
|
|
11461
|
+
resolve();
|
|
11462
|
+
});
|
|
11463
|
+
});
|
|
11464
|
+
const pending = [];
|
|
11465
|
+
const waiting = [];
|
|
11466
|
+
let ended = false;
|
|
11467
|
+
const deliver = (message) => {
|
|
11468
|
+
const waiter = waiting.shift();
|
|
11469
|
+
if (waiter === void 0) {
|
|
11470
|
+
pending.push(message);
|
|
11471
|
+
} else {
|
|
11472
|
+
waiter(message);
|
|
11473
|
+
}
|
|
11474
|
+
};
|
|
11475
|
+
const lines = import_node_readline.default.createInterface({ input: child.stdout });
|
|
11476
|
+
lines.on("line", (line) => {
|
|
11477
|
+
try {
|
|
11478
|
+
deliver(JSON.parse(line));
|
|
11479
|
+
} catch {
|
|
11480
|
+
}
|
|
11481
|
+
});
|
|
11482
|
+
lines.on("close", () => {
|
|
11483
|
+
ended = true;
|
|
11484
|
+
for (const waiter of waiting.splice(0)) {
|
|
11485
|
+
waiter(void 0);
|
|
11486
|
+
}
|
|
11487
|
+
});
|
|
11488
|
+
const connection = {
|
|
11489
|
+
send: (message) => {
|
|
11490
|
+
child.stdin.write(`${JSON.stringify(message)}
|
|
11491
|
+
`);
|
|
11492
|
+
},
|
|
11493
|
+
receive: async () => {
|
|
11494
|
+
if (pending.length > 0) {
|
|
11495
|
+
return pending.shift();
|
|
11496
|
+
}
|
|
11497
|
+
if (ended) {
|
|
11498
|
+
return void 0;
|
|
11499
|
+
}
|
|
11500
|
+
return await new Promise((resolve) => {
|
|
11501
|
+
waiting.push(resolve);
|
|
11502
|
+
});
|
|
11503
|
+
},
|
|
11504
|
+
close: async () => {
|
|
11505
|
+
child.stdin.end();
|
|
11506
|
+
const timer = setTimeout(() => {
|
|
11507
|
+
child.kill("SIGKILL");
|
|
11508
|
+
}, SHUTDOWN_GRACE_MS);
|
|
11509
|
+
await exited;
|
|
11510
|
+
clearTimeout(timer);
|
|
11511
|
+
lines.close();
|
|
11512
|
+
}
|
|
11513
|
+
};
|
|
11514
|
+
return connection;
|
|
11515
|
+
}
|
|
11516
|
+
};
|
|
11517
|
+
|
|
11271
11518
|
// src/frontdoor/doorClient.ts
|
|
11272
11519
|
init_cliError();
|
|
11273
11520
|
init_realPorts();
|
|
@@ -11655,7 +11902,7 @@ init_realCredentialCache();
|
|
|
11655
11902
|
init_providersStore();
|
|
11656
11903
|
init_realPorts();
|
|
11657
11904
|
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
11658
|
-
var
|
|
11905
|
+
var import_zod13 = require("zod");
|
|
11659
11906
|
init_envBool();
|
|
11660
11907
|
init_load();
|
|
11661
11908
|
init_schema();
|
|
@@ -11743,9 +11990,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
11743
11990
|
note: serviceName === void 0 ? `A Keychain entry was found for account "${farmRoot}" but its service name could not be parsed from security's output.` : `Keychain service name for this identity: "${serviceName}".`
|
|
11744
11991
|
};
|
|
11745
11992
|
}
|
|
11746
|
-
var SettingsSecretsShapeSchema =
|
|
11747
|
-
env:
|
|
11748
|
-
hooks:
|
|
11993
|
+
var SettingsSecretsShapeSchema = import_zod13.z.looseObject({
|
|
11994
|
+
env: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional(),
|
|
11995
|
+
hooks: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.array(import_zod13.z.unknown())).optional()
|
|
11749
11996
|
});
|
|
11750
11997
|
function hookCommandCountOf(group) {
|
|
11751
11998
|
if (typeof group !== "object" || group === null) {
|
|
@@ -12037,7 +12284,7 @@ function collectCheckReport(params) {
|
|
|
12037
12284
|
}
|
|
12038
12285
|
|
|
12039
12286
|
// src/checkReportSchema.ts
|
|
12040
|
-
var
|
|
12287
|
+
var import_zod15 = require("zod");
|
|
12041
12288
|
init_schema();
|
|
12042
12289
|
init_claudeVersion();
|
|
12043
12290
|
init_identity();
|
|
@@ -12101,124 +12348,124 @@ var DIAGNOSTIC_CODES = [
|
|
|
12101
12348
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
12102
12349
|
|
|
12103
12350
|
// src/usage/pickReportSchema.ts
|
|
12104
|
-
var
|
|
12351
|
+
var import_zod14 = require("zod");
|
|
12105
12352
|
init_plan2();
|
|
12106
|
-
var PoolPickCandidateViewSchema =
|
|
12107
|
-
identity:
|
|
12353
|
+
var PoolPickCandidateViewSchema = import_zod14.z.strictObject({
|
|
12354
|
+
identity: import_zod14.z.string(),
|
|
12108
12355
|
/** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
|
|
12109
|
-
class:
|
|
12356
|
+
class: import_zod14.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
12110
12357
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
12111
|
-
score:
|
|
12358
|
+
score: import_zod14.z.number().optional(),
|
|
12112
12359
|
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation; present with `score`. */
|
|
12113
|
-
scoreWindow:
|
|
12360
|
+
scoreWindow: import_zod14.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
12114
12361
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
12115
|
-
feasible:
|
|
12362
|
+
feasible: import_zod14.z.boolean(),
|
|
12116
12363
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
12117
|
-
blockedUntil:
|
|
12364
|
+
blockedUntil: import_zod14.z.iso.datetime().optional(),
|
|
12118
12365
|
plan: PlanClassSchema,
|
|
12119
12366
|
/** The facts behind the class and score, in the order they matter. */
|
|
12120
|
-
reasons:
|
|
12367
|
+
reasons: import_zod14.z.array(import_zod14.z.string())
|
|
12121
12368
|
});
|
|
12122
|
-
var PoolPickReportSchema =
|
|
12123
|
-
pool:
|
|
12124
|
-
directory:
|
|
12369
|
+
var PoolPickReportSchema = import_zod14.z.strictObject({
|
|
12370
|
+
pool: import_zod14.z.string(),
|
|
12371
|
+
directory: import_zod14.z.string(),
|
|
12125
12372
|
/** The member a launch would run as, absent when every member is refused. */
|
|
12126
|
-
pick:
|
|
12127
|
-
candidates:
|
|
12373
|
+
pick: import_zod14.z.string().optional(),
|
|
12374
|
+
candidates: import_zod14.z.array(PoolPickCandidateViewSchema),
|
|
12128
12375
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
12129
|
-
missing:
|
|
12376
|
+
missing: import_zod14.z.array(import_zod14.z.string()),
|
|
12130
12377
|
/** When nothing can be picked, the soonest any member returns. */
|
|
12131
|
-
earliestReturn:
|
|
12378
|
+
earliestReturn: import_zod14.z.strictObject({ identity: import_zod14.z.string(), at: import_zod14.z.iso.datetime() }).optional(),
|
|
12132
12379
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
12133
|
-
movedOff:
|
|
12380
|
+
movedOff: import_zod14.z.strictObject({ identity: import_zod14.z.string(), reason: import_zod14.z.string() }).optional(),
|
|
12134
12381
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
12135
|
-
stickyProblem:
|
|
12382
|
+
stickyProblem: import_zod14.z.string().optional()
|
|
12136
12383
|
});
|
|
12137
12384
|
|
|
12138
12385
|
// src/checkReportSchema.ts
|
|
12139
12386
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
12140
|
-
var CheckLayerViewSchema =
|
|
12141
|
-
id:
|
|
12142
|
-
kind:
|
|
12143
|
-
source:
|
|
12387
|
+
var CheckLayerViewSchema = import_zod15.z.strictObject({
|
|
12388
|
+
id: import_zod15.z.int(),
|
|
12389
|
+
kind: import_zod15.z.enum(LAYER_KINDS),
|
|
12390
|
+
source: import_zod15.z.string()
|
|
12144
12391
|
});
|
|
12145
|
-
var CheckEntryViewSchema =
|
|
12146
|
-
path:
|
|
12147
|
-
shared:
|
|
12148
|
-
via:
|
|
12392
|
+
var CheckEntryViewSchema = import_zod15.z.strictObject({
|
|
12393
|
+
path: import_zod15.z.string(),
|
|
12394
|
+
shared: import_zod15.z.boolean(),
|
|
12395
|
+
via: import_zod15.z.enum(DECISION_VIAS),
|
|
12149
12396
|
/** The entry's real category, or null when nothing classifies it. */
|
|
12150
|
-
category:
|
|
12151
|
-
rule:
|
|
12397
|
+
category: import_zod15.z.enum(CATEGORY_NAMES).nullable(),
|
|
12398
|
+
rule: import_zod15.z.strictObject({ key: import_zod15.z.string(), layer: import_zod15.z.int() }).optional(),
|
|
12152
12399
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
12153
|
-
eliminated:
|
|
12400
|
+
eliminated: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.strictObject({ key: import_zod15.z.string(), failed: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())) }))).optional()
|
|
12154
12401
|
});
|
|
12155
|
-
var CheckDiagnosticSchema =
|
|
12156
|
-
code:
|
|
12157
|
-
severity:
|
|
12158
|
-
message:
|
|
12159
|
-
subject:
|
|
12160
|
-
layer:
|
|
12402
|
+
var CheckDiagnosticSchema = import_zod15.z.strictObject({
|
|
12403
|
+
code: import_zod15.z.enum(DIAGNOSTIC_CODES),
|
|
12404
|
+
severity: import_zod15.z.enum(DIAGNOSTIC_SEVERITIES),
|
|
12405
|
+
message: import_zod15.z.string(),
|
|
12406
|
+
subject: import_zod15.z.string().optional(),
|
|
12407
|
+
layer: import_zod15.z.int().optional()
|
|
12161
12408
|
});
|
|
12162
|
-
var CheckAmbientCredentialSchema =
|
|
12163
|
-
var CheckKeychainSchema =
|
|
12164
|
-
checked:
|
|
12165
|
-
found:
|
|
12166
|
-
serviceName:
|
|
12167
|
-
note:
|
|
12409
|
+
var CheckAmbientCredentialSchema = import_zod15.z.union([import_zod15.z.strictObject({ ok: import_zod15.z.literal(true) }), import_zod15.z.strictObject({ ok: import_zod15.z.literal(false), variable: import_zod15.z.string(), message: import_zod15.z.string() })]);
|
|
12410
|
+
var CheckKeychainSchema = import_zod15.z.strictObject({
|
|
12411
|
+
checked: import_zod15.z.literal(true),
|
|
12412
|
+
found: import_zod15.z.boolean(),
|
|
12413
|
+
serviceName: import_zod15.z.string().optional(),
|
|
12414
|
+
note: import_zod15.z.string()
|
|
12168
12415
|
});
|
|
12169
|
-
var CheckSettingsExposureSchema =
|
|
12170
|
-
file:
|
|
12171
|
-
envKeyNames:
|
|
12172
|
-
hookEventNames:
|
|
12173
|
-
hookCommandCount:
|
|
12416
|
+
var CheckSettingsExposureSchema = import_zod15.z.strictObject({
|
|
12417
|
+
file: import_zod15.z.string(),
|
|
12418
|
+
envKeyNames: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())),
|
|
12419
|
+
hookEventNames: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())),
|
|
12420
|
+
hookCommandCount: import_zod15.z.int().nonnegative()
|
|
12174
12421
|
});
|
|
12175
|
-
var CredentialSourceSummarySchema =
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12422
|
+
var CredentialSourceSummarySchema = import_zod15.z.union([
|
|
12423
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("env"), variable: import_zod15.z.string() }),
|
|
12424
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("file"), path: import_zod15.z.string() }),
|
|
12425
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("command"), program: import_zod15.z.string() }),
|
|
12426
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("op"), reference: import_zod15.z.string() }),
|
|
12427
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("keychain"), service: import_zod15.z.string(), account: import_zod15.z.string().optional() }),
|
|
12428
|
+
import_zod15.z.strictObject({ kind: import_zod15.z.literal("literal") })
|
|
12182
12429
|
]);
|
|
12183
|
-
var CredentialSummarySchema =
|
|
12184
|
-
target:
|
|
12185
|
-
sources:
|
|
12430
|
+
var CredentialSummarySchema = import_zod15.z.strictObject({
|
|
12431
|
+
target: import_zod15.z.enum(CREDENTIAL_TARGETS),
|
|
12432
|
+
sources: import_zod15.z.readonly(import_zod15.z.array(CredentialSourceSummarySchema)),
|
|
12186
12433
|
cache: CredentialCacheSchema.optional()
|
|
12187
12434
|
});
|
|
12188
|
-
var CachedCredentialStateSchema =
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12435
|
+
var CachedCredentialStateSchema = import_zod15.z.union([
|
|
12436
|
+
import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.literal("empty") }),
|
|
12437
|
+
import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.literal("unreadable"), reason: import_zod15.z.string() }),
|
|
12438
|
+
import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.enum(["fresh", "expired"]), ageMs: import_zod15.z.number(), expiresInMs: import_zod15.z.number().optional() })
|
|
12192
12439
|
]);
|
|
12193
|
-
var CheckCredentialProviderSchema =
|
|
12194
|
-
|
|
12195
|
-
|
|
12440
|
+
var CheckCredentialProviderSchema = import_zod15.z.union([
|
|
12441
|
+
import_zod15.z.strictObject({ name: import_zod15.z.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
|
|
12442
|
+
import_zod15.z.strictObject({ name: import_zod15.z.string(), problem: import_zod15.z.string() })
|
|
12196
12443
|
]);
|
|
12197
|
-
var CheckCredentialSchema =
|
|
12198
|
-
applies:
|
|
12444
|
+
var CheckCredentialSchema = import_zod15.z.strictObject({
|
|
12445
|
+
applies: import_zod15.z.enum(CHECK_CREDENTIAL_APPLIES),
|
|
12199
12446
|
provider: CheckCredentialProviderSchema.optional(),
|
|
12200
12447
|
identity: CredentialSummarySchema.optional(),
|
|
12201
12448
|
identityCached: CachedCredentialStateSchema.optional()
|
|
12202
12449
|
});
|
|
12203
|
-
var CheckClaudeVersionSchema =
|
|
12204
|
-
pinned:
|
|
12205
|
-
highestInstalled:
|
|
12206
|
-
installed:
|
|
12450
|
+
var CheckClaudeVersionSchema = import_zod15.z.strictObject({
|
|
12451
|
+
pinned: import_zod15.z.strictObject({ version: import_zod15.z.string(), source: import_zod15.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod15.z.boolean() }).optional(),
|
|
12452
|
+
highestInstalled: import_zod15.z.string().optional(),
|
|
12453
|
+
installed: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string()))
|
|
12207
12454
|
});
|
|
12208
|
-
var CheckReportJsonSchema =
|
|
12209
|
-
identity:
|
|
12455
|
+
var CheckReportJsonSchema = import_zod15.z.strictObject({
|
|
12456
|
+
identity: import_zod15.z.strictObject({ name: import_zod15.z.string().nullable(), source: import_zod15.z.enum(IDENTITY_DECISION_SOURCES) }),
|
|
12210
12457
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
12211
12458
|
pool: PoolPickReportSchema.optional(),
|
|
12212
|
-
configProfile:
|
|
12213
|
-
layers:
|
|
12214
|
-
entries:
|
|
12215
|
-
projectEncodingAmbiguities:
|
|
12216
|
-
|
|
12459
|
+
configProfile: import_zod15.z.strictObject({ name: import_zod15.z.string().nullable(), source: import_zod15.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
12460
|
+
layers: import_zod15.z.readonly(import_zod15.z.array(CheckLayerViewSchema)),
|
|
12461
|
+
entries: import_zod15.z.readonly(import_zod15.z.array(CheckEntryViewSchema)),
|
|
12462
|
+
projectEncodingAmbiguities: import_zod15.z.readonly(
|
|
12463
|
+
import_zod15.z.array(import_zod15.z.strictObject({ fragment: import_zod15.z.string(), encoded: import_zod15.z.string(), reason: import_zod15.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod15.z.string() }))
|
|
12217
12464
|
),
|
|
12218
|
-
diagnostics:
|
|
12465
|
+
diagnostics: import_zod15.z.readonly(import_zod15.z.array(CheckDiagnosticSchema)),
|
|
12219
12466
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
12220
12467
|
keychain: CheckKeychainSchema.optional(),
|
|
12221
|
-
settingsExposure:
|
|
12468
|
+
settingsExposure: import_zod15.z.readonly(import_zod15.z.array(CheckSettingsExposureSchema)),
|
|
12222
12469
|
credential: CheckCredentialSchema,
|
|
12223
12470
|
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
12224
12471
|
});
|
|
@@ -12229,7 +12476,7 @@ init_preflight();
|
|
|
12229
12476
|
|
|
12230
12477
|
// src/frontdoor/controlSchemas.ts
|
|
12231
12478
|
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
12232
|
-
var
|
|
12479
|
+
var import_zod20 = require("zod");
|
|
12233
12480
|
|
|
12234
12481
|
// src/doctorReport.ts
|
|
12235
12482
|
init_claudeShim();
|
|
@@ -12424,24 +12671,24 @@ function credentialsFilePath(farmRoot) {
|
|
|
12424
12671
|
}
|
|
12425
12672
|
|
|
12426
12673
|
// src/codex/siwcStore.ts
|
|
12427
|
-
var
|
|
12674
|
+
var import_zod19 = require("zod");
|
|
12428
12675
|
|
|
12429
12676
|
// src/codex/auth.ts
|
|
12430
|
-
var
|
|
12431
|
-
var AuthFileSchema =
|
|
12432
|
-
tokens:
|
|
12433
|
-
access_token:
|
|
12434
|
-
refresh_token:
|
|
12435
|
-
id_token:
|
|
12436
|
-
account_id:
|
|
12677
|
+
var import_zod17 = require("zod");
|
|
12678
|
+
var AuthFileSchema = import_zod17.z.looseObject({
|
|
12679
|
+
tokens: import_zod17.z.looseObject({
|
|
12680
|
+
access_token: import_zod17.z.string().optional(),
|
|
12681
|
+
refresh_token: import_zod17.z.string().optional(),
|
|
12682
|
+
id_token: import_zod17.z.string().optional(),
|
|
12683
|
+
account_id: import_zod17.z.string().optional()
|
|
12437
12684
|
}).nullish(),
|
|
12438
|
-
last_refresh:
|
|
12685
|
+
last_refresh: import_zod17.z.string().optional()
|
|
12439
12686
|
});
|
|
12440
|
-
var TokenGrantSchema =
|
|
12441
|
-
access_token:
|
|
12442
|
-
refresh_token:
|
|
12443
|
-
id_token:
|
|
12444
|
-
account_id:
|
|
12687
|
+
var TokenGrantSchema = import_zod17.z.looseObject({
|
|
12688
|
+
access_token: import_zod17.z.string().min(1).optional(),
|
|
12689
|
+
refresh_token: import_zod17.z.string().min(1).optional(),
|
|
12690
|
+
id_token: import_zod17.z.string().min(1).optional(),
|
|
12691
|
+
account_id: import_zod17.z.string().min(1).optional()
|
|
12445
12692
|
});
|
|
12446
12693
|
var CodexAuthError = class extends Error {
|
|
12447
12694
|
constructor(message) {
|
|
@@ -12451,41 +12698,41 @@ var CodexAuthError = class extends Error {
|
|
|
12451
12698
|
};
|
|
12452
12699
|
|
|
12453
12700
|
// src/codex/siwc.ts
|
|
12454
|
-
var
|
|
12701
|
+
var import_zod18 = require("zod");
|
|
12455
12702
|
var SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
12456
12703
|
var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
12457
12704
|
var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
12458
|
-
var TokenResponseSchema =
|
|
12459
|
-
access_token:
|
|
12460
|
-
refresh_token:
|
|
12461
|
-
id_token:
|
|
12462
|
-
expires_in:
|
|
12463
|
-
scope:
|
|
12705
|
+
var TokenResponseSchema = import_zod18.z.looseObject({
|
|
12706
|
+
access_token: import_zod18.z.string().min(1),
|
|
12707
|
+
refresh_token: import_zod18.z.string().min(1).optional(),
|
|
12708
|
+
id_token: import_zod18.z.string().min(1).optional(),
|
|
12709
|
+
expires_in: import_zod18.z.number().positive(),
|
|
12710
|
+
scope: import_zod18.z.string().optional()
|
|
12464
12711
|
});
|
|
12465
|
-
var JwtHeaderSchema =
|
|
12466
|
-
var IdTokenClaimsSchema =
|
|
12467
|
-
iss:
|
|
12468
|
-
sub:
|
|
12469
|
-
aud:
|
|
12470
|
-
exp:
|
|
12471
|
-
nonce:
|
|
12472
|
-
email:
|
|
12712
|
+
var JwtHeaderSchema = import_zod18.z.looseObject({ alg: import_zod18.z.string(), kid: import_zod18.z.string().optional() });
|
|
12713
|
+
var IdTokenClaimsSchema = import_zod18.z.looseObject({
|
|
12714
|
+
iss: import_zod18.z.string(),
|
|
12715
|
+
sub: import_zod18.z.string().min(1),
|
|
12716
|
+
aud: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.array(import_zod18.z.string())]),
|
|
12717
|
+
exp: import_zod18.z.number(),
|
|
12718
|
+
nonce: import_zod18.z.string().optional(),
|
|
12719
|
+
email: import_zod18.z.string().optional()
|
|
12473
12720
|
});
|
|
12474
|
-
var JwksSchema =
|
|
12721
|
+
var JwksSchema = import_zod18.z.object({ keys: import_zod18.z.array(import_zod18.z.looseObject({ kid: import_zod18.z.string().optional(), kty: import_zod18.z.string() })) });
|
|
12475
12722
|
|
|
12476
12723
|
// src/codex/siwcStore.ts
|
|
12477
|
-
var SiwcGrantSchema =
|
|
12478
|
-
clientId:
|
|
12479
|
-
sub:
|
|
12480
|
-
email:
|
|
12481
|
-
idToken:
|
|
12482
|
-
accessToken:
|
|
12483
|
-
refreshToken:
|
|
12484
|
-
scopes:
|
|
12724
|
+
var SiwcGrantSchema = import_zod19.z.strictObject({
|
|
12725
|
+
clientId: import_zod19.z.string().min(1),
|
|
12726
|
+
sub: import_zod19.z.string().min(1),
|
|
12727
|
+
email: import_zod19.z.string().optional(),
|
|
12728
|
+
idToken: import_zod19.z.string().min(1),
|
|
12729
|
+
accessToken: import_zod19.z.string().min(1),
|
|
12730
|
+
refreshToken: import_zod19.z.string().min(1),
|
|
12731
|
+
scopes: import_zod19.z.array(import_zod19.z.string()).readonly(),
|
|
12485
12732
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
12486
|
-
expiresAt:
|
|
12733
|
+
expiresAt: import_zod19.z.number()
|
|
12487
12734
|
});
|
|
12488
|
-
var SiwcFileSchema =
|
|
12735
|
+
var SiwcFileSchema = import_zod19.z.strictObject({ registeredClientId: import_zod19.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
12489
12736
|
function parseSiwcFile(raw, filePath) {
|
|
12490
12737
|
let json;
|
|
12491
12738
|
try {
|
|
@@ -12645,17 +12892,17 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
12645
12892
|
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
12646
12893
|
return;
|
|
12647
12894
|
}
|
|
12648
|
-
const
|
|
12649
|
-
if (!
|
|
12650
|
-
push("provider", "fail", new ConfigValidationError(entry.path,
|
|
12895
|
+
const validated3 = ProviderSchema.safeParse(parsed);
|
|
12896
|
+
if (!validated3.success) {
|
|
12897
|
+
push("provider", "fail", new ConfigValidationError(entry.path, validated3.error.issues).message, entry.name);
|
|
12651
12898
|
return;
|
|
12652
12899
|
}
|
|
12653
|
-
const cache = cacheClause(cacheEnv, `provider ${entry.name}`,
|
|
12654
|
-
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(
|
|
12655
|
-
if (
|
|
12900
|
+
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated3.data.credential);
|
|
12901
|
+
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated3.data)}, credential ${describeCredential(validated3.data.credential)})${cache.text}.`, entry.name);
|
|
12902
|
+
if (validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
12656
12903
|
push("provider", "warn", `${entry.name} does not set ENABLE_TOOL_SEARCH: a session on this provider keeps Claude Code's own API as its base URL, so it defers MCP tool loading and sends tool_reference payloads the upstream backend must understand. Set ENABLE_TOOL_SEARCH=false in the provider's env block to load tools upfront instead, when the backend does not support them.`, entry.name);
|
|
12657
12904
|
}
|
|
12658
|
-
if (signIn !== void 0 && isCodexProvider(
|
|
12905
|
+
if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
|
|
12659
12906
|
const problem = signInProblem(signIn);
|
|
12660
12907
|
if (problem !== void 0) {
|
|
12661
12908
|
push("provider", "warn", `${entry.name} uses the Sign in with ChatGPT login, but ${problem}`, entry.name);
|
|
@@ -12723,13 +12970,13 @@ function runDoctor(params) {
|
|
|
12723
12970
|
pushLegacyName(push, params);
|
|
12724
12971
|
const profileSources = /* @__PURE__ */ new Map();
|
|
12725
12972
|
for (const entry of params.configProfiles) {
|
|
12726
|
-
const
|
|
12727
|
-
if (!
|
|
12728
|
-
push("config-profile", "fail",
|
|
12973
|
+
const validated3 = validateJson(ConfigProfileSchema, entry);
|
|
12974
|
+
if (!validated3.ok) {
|
|
12975
|
+
push("config-profile", "fail", validated3.message, entry.name);
|
|
12729
12976
|
continue;
|
|
12730
12977
|
}
|
|
12731
|
-
profileSources.set(entry.name, { name: entry.name, profile:
|
|
12732
|
-
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`,
|
|
12978
|
+
profileSources.set(entry.name, { name: entry.name, profile: validated3.data });
|
|
12979
|
+
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated3.data.launch?.claudeVersion);
|
|
12733
12980
|
}
|
|
12734
12981
|
const loadProfile = (name) => profileSources.get(name);
|
|
12735
12982
|
for (const name of profileSources.keys()) {
|
|
@@ -12745,13 +12992,13 @@ function runDoctor(params) {
|
|
|
12745
12992
|
const validProfileNames = new Set(profileSources.keys());
|
|
12746
12993
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
12747
12994
|
for (const entry of params.identities) {
|
|
12748
|
-
const
|
|
12749
|
-
if (!
|
|
12750
|
-
push("identity", "fail",
|
|
12995
|
+
const validated3 = validateJson(IdentitySchema, entry);
|
|
12996
|
+
if (!validated3.ok) {
|
|
12997
|
+
push("identity", "fail", validated3.message, entry.name);
|
|
12751
12998
|
continue;
|
|
12752
12999
|
}
|
|
12753
13000
|
validIdentityNames.add(entry.name);
|
|
12754
|
-
const defaultProfile =
|
|
13001
|
+
const defaultProfile = validated3.data.defaultConfigProfile;
|
|
12755
13002
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
12756
13003
|
push(
|
|
12757
13004
|
"identity",
|
|
@@ -12760,7 +13007,7 @@ function runDoctor(params) {
|
|
|
12760
13007
|
entry.name
|
|
12761
13008
|
);
|
|
12762
13009
|
} else {
|
|
12763
|
-
const credential =
|
|
13010
|
+
const credential = validated3.data.credential;
|
|
12764
13011
|
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
12765
13012
|
push(
|
|
12766
13013
|
"identity",
|
|
@@ -12831,12 +13078,12 @@ function runDoctor(params) {
|
|
|
12831
13078
|
if (params.directoryRules.raw === void 0) {
|
|
12832
13079
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
12833
13080
|
} else {
|
|
12834
|
-
const
|
|
12835
|
-
if (!
|
|
12836
|
-
push("directory-rules", "fail",
|
|
13081
|
+
const validated3 = validateJson(DirectoryRulesSchema, params.directoryRules);
|
|
13082
|
+
if (!validated3.ok) {
|
|
13083
|
+
push("directory-rules", "fail", validated3.message);
|
|
12837
13084
|
} else {
|
|
12838
13085
|
push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
|
|
12839
|
-
for (const rule of
|
|
13086
|
+
for (const rule of validated3.data.rules) {
|
|
12840
13087
|
const badRefs = [];
|
|
12841
13088
|
if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
|
|
12842
13089
|
badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
|
|
@@ -12856,11 +13103,11 @@ function runDoctor(params) {
|
|
|
12856
13103
|
if (params.globalConfig.raw === void 0) {
|
|
12857
13104
|
push("global-config", "pass", "No config.json configured.");
|
|
12858
13105
|
} else {
|
|
12859
|
-
const
|
|
12860
|
-
if (!
|
|
12861
|
-
push("global-config", "fail",
|
|
13106
|
+
const validated3 = validateJson(GlobalConfigSchema, params.globalConfig);
|
|
13107
|
+
if (!validated3.ok) {
|
|
13108
|
+
push("global-config", "fail", validated3.message);
|
|
12862
13109
|
} else {
|
|
12863
|
-
const defaultProfile =
|
|
13110
|
+
const defaultProfile = validated3.data.defaultConfigProfile;
|
|
12864
13111
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
12865
13112
|
push(
|
|
12866
13113
|
"global-config",
|
|
@@ -12869,18 +13116,18 @@ function runDoctor(params) {
|
|
|
12869
13116
|
);
|
|
12870
13117
|
} else {
|
|
12871
13118
|
push("global-config", "pass", `${params.globalConfig.path} is valid.`);
|
|
12872
|
-
checkPin("global-config", void 0, "config.json",
|
|
13119
|
+
checkPin("global-config", void 0, "config.json", validated3.data.launch?.claudeVersion);
|
|
12873
13120
|
}
|
|
12874
13121
|
}
|
|
12875
13122
|
}
|
|
12876
13123
|
if (params.categoriesLocal.raw === void 0) {
|
|
12877
13124
|
push("categories-local", "pass", "No categories.local.json configured.");
|
|
12878
13125
|
} else {
|
|
12879
|
-
const
|
|
13126
|
+
const validated3 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
|
|
12880
13127
|
push(
|
|
12881
13128
|
"categories-local",
|
|
12882
|
-
|
|
12883
|
-
|
|
13129
|
+
validated3.ok ? "pass" : "fail",
|
|
13130
|
+
validated3.ok ? `${params.categoriesLocal.path} is valid.` : validated3.message
|
|
12884
13131
|
);
|
|
12885
13132
|
}
|
|
12886
13133
|
if (params.headroom.state.raw === void 0) {
|
|
@@ -12888,11 +13135,11 @@ function runDoctor(params) {
|
|
|
12888
13135
|
} else if (tcpPortEraRecord(params.headroom.state.raw)) {
|
|
12889
13136
|
push("headroom", "pass", `${params.headroom.state.path} holds a previous release's TCP-port state record; the next launch through headroom claims over it.`);
|
|
12890
13137
|
} else {
|
|
12891
|
-
const
|
|
12892
|
-
if (!
|
|
12893
|
-
push("headroom", "fail",
|
|
13138
|
+
const validated3 = validateJson(HeadroomStateSchema, params.headroom.state);
|
|
13139
|
+
if (!validated3.ok) {
|
|
13140
|
+
push("headroom", "fail", validated3.message);
|
|
12894
13141
|
} else {
|
|
12895
|
-
const state =
|
|
13142
|
+
const state = validated3.data;
|
|
12896
13143
|
const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
|
|
12897
13144
|
const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
|
|
12898
13145
|
if (state.supervisorPid === void 0) {
|
|
@@ -13108,90 +13355,90 @@ function collectDoctorReport(params) {
|
|
|
13108
13355
|
// src/frontdoor/controlSchemas.ts
|
|
13109
13356
|
init_schema2();
|
|
13110
13357
|
init_state();
|
|
13111
|
-
var UsageListOutputSchema =
|
|
13112
|
-
var UsageWindowsInputSchema =
|
|
13113
|
-
identity:
|
|
13114
|
-
provider:
|
|
13358
|
+
var UsageListOutputSchema = import_zod20.z.strictObject({ snapshots: import_zod20.z.readonly(import_zod20.z.array(UsageSnapshotSchema)) });
|
|
13359
|
+
var UsageWindowsInputSchema = import_zod20.z.strictObject({
|
|
13360
|
+
identity: import_zod20.z.string().min(1),
|
|
13361
|
+
provider: import_zod20.z.string().min(1).optional()
|
|
13115
13362
|
});
|
|
13116
|
-
var EffectiveWindowSchema =
|
|
13363
|
+
var EffectiveWindowSchema = import_zod20.z.strictObject({
|
|
13117
13364
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
13118
|
-
reset:
|
|
13365
|
+
reset: import_zod20.z.boolean(),
|
|
13119
13366
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
13120
|
-
utilization:
|
|
13367
|
+
utilization: import_zod20.z.number().optional(),
|
|
13121
13368
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
13122
|
-
resetsAtMs:
|
|
13369
|
+
resetsAtMs: import_zod20.z.number().optional(),
|
|
13123
13370
|
/** The window's own status, for a window that has not reset yet. */
|
|
13124
|
-
status:
|
|
13371
|
+
status: import_zod20.z.string().optional()
|
|
13125
13372
|
});
|
|
13126
|
-
var UsageWindowsOutputSchema =
|
|
13127
|
-
identity:
|
|
13128
|
-
provider:
|
|
13373
|
+
var UsageWindowsOutputSchema = import_zod20.z.strictObject({
|
|
13374
|
+
identity: import_zod20.z.string(),
|
|
13375
|
+
provider: import_zod20.z.string(),
|
|
13129
13376
|
/** When the rate-limit state the windows come from was observed. */
|
|
13130
|
-
observedAt:
|
|
13377
|
+
observedAt: import_zod20.z.iso.datetime().optional(),
|
|
13131
13378
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
13132
13379
|
sevenDay: EffectiveWindowSchema.optional()
|
|
13133
13380
|
});
|
|
13134
|
-
var UsageLiveOutputSchema =
|
|
13381
|
+
var UsageLiveOutputSchema = import_zod20.z.strictObject({
|
|
13135
13382
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
13136
13383
|
latest: RcLiveRateLimitSchema.optional(),
|
|
13137
13384
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
13138
|
-
sessions:
|
|
13385
|
+
sessions: import_zod20.z.readonly(import_zod20.z.array(RcLiveRateLimitSchema))
|
|
13139
13386
|
});
|
|
13140
|
-
var FrontDoorSessionStatusSchema =
|
|
13141
|
-
pid:
|
|
13142
|
-
startedAt:
|
|
13143
|
-
alive:
|
|
13387
|
+
var FrontDoorSessionStatusSchema = import_zod20.z.strictObject({
|
|
13388
|
+
pid: import_zod20.z.int().positive(),
|
|
13389
|
+
startedAt: import_zod20.z.number(),
|
|
13390
|
+
alive: import_zod20.z.boolean()
|
|
13144
13391
|
});
|
|
13145
|
-
var HeadroomSocketTargetSchema =
|
|
13146
|
-
var FrontDoorStatusOutputSchema =
|
|
13392
|
+
var HeadroomSocketTargetSchema = import_zod20.z.union([import_zod20.z.strictObject({ socketPath: import_zod20.z.string() }), import_zod20.z.strictObject({ refused: import_zod20.z.string() })]);
|
|
13393
|
+
var FrontDoorStatusOutputSchema = import_zod20.z.strictObject({
|
|
13147
13394
|
state: FrontDoorStateSchema,
|
|
13148
|
-
supervisorAlive:
|
|
13149
|
-
sessions:
|
|
13395
|
+
supervisorAlive: import_zod20.z.boolean(),
|
|
13396
|
+
sessions: import_zod20.z.readonly(import_zod20.z.array(FrontDoorSessionStatusSchema)),
|
|
13150
13397
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
13151
|
-
logPath:
|
|
13152
|
-
logExists:
|
|
13398
|
+
logPath: import_zod20.z.string(),
|
|
13399
|
+
logExists: import_zod20.z.boolean()
|
|
13153
13400
|
});
|
|
13154
|
-
var FrontDoorSessionsOutputSchema =
|
|
13155
|
-
var CheckRunInputSchema =
|
|
13156
|
-
path:
|
|
13157
|
-
identity:
|
|
13401
|
+
var FrontDoorSessionsOutputSchema = import_zod20.z.strictObject({ sessions: import_zod20.z.readonly(import_zod20.z.array(FrontDoorSessionStatusSchema)) });
|
|
13402
|
+
var CheckRunInputSchema = import_zod20.z.strictObject({
|
|
13403
|
+
path: import_zod20.z.string().min(1),
|
|
13404
|
+
identity: import_zod20.z.string().min(1).optional()
|
|
13158
13405
|
}).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13159
|
-
var PoolPickInputSchema =
|
|
13160
|
-
pool:
|
|
13161
|
-
path:
|
|
13406
|
+
var PoolPickInputSchema = import_zod20.z.strictObject({
|
|
13407
|
+
pool: import_zod20.z.string().min(1),
|
|
13408
|
+
path: import_zod20.z.string().min(1)
|
|
13162
13409
|
}).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13163
|
-
var DoctorFindingSchema =
|
|
13164
|
-
section:
|
|
13165
|
-
subject:
|
|
13166
|
-
severity:
|
|
13167
|
-
message:
|
|
13410
|
+
var DoctorFindingSchema = import_zod20.z.strictObject({
|
|
13411
|
+
section: import_zod20.z.enum(DOCTOR_SECTIONS),
|
|
13412
|
+
subject: import_zod20.z.string().optional(),
|
|
13413
|
+
severity: import_zod20.z.enum(DOCTOR_SEVERITIES),
|
|
13414
|
+
message: import_zod20.z.string()
|
|
13168
13415
|
});
|
|
13169
|
-
var DoctorRunOutputSchema =
|
|
13416
|
+
var DoctorRunOutputSchema = import_zod20.z.strictObject({
|
|
13170
13417
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
13171
|
-
ok:
|
|
13172
|
-
findings:
|
|
13418
|
+
ok: import_zod20.z.boolean(),
|
|
13419
|
+
findings: import_zod20.z.readonly(import_zod20.z.array(DoctorFindingSchema))
|
|
13173
13420
|
});
|
|
13174
|
-
var FrontDoorRestartOutputSchema =
|
|
13175
|
-
action:
|
|
13176
|
-
previousPid:
|
|
13421
|
+
var FrontDoorRestartOutputSchema = import_zod20.z.strictObject({
|
|
13422
|
+
action: import_zod20.z.literal("restarting"),
|
|
13423
|
+
previousPid: import_zod20.z.int().positive()
|
|
13177
13424
|
});
|
|
13178
|
-
var UpdateCheckOutputSchema =
|
|
13179
|
-
current:
|
|
13180
|
-
latest:
|
|
13181
|
-
action:
|
|
13425
|
+
var UpdateCheckOutputSchema = import_zod20.z.strictObject({
|
|
13426
|
+
current: import_zod20.z.string(),
|
|
13427
|
+
latest: import_zod20.z.string(),
|
|
13428
|
+
action: import_zod20.z.enum(["current", "available", "updated"])
|
|
13182
13429
|
});
|
|
13183
|
-
var CodexSignInSchema =
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13430
|
+
var CodexSignInSchema = import_zod20.z.discriminatedUnion("state", [
|
|
13431
|
+
import_zod20.z.strictObject({ state: import_zod20.z.literal("none") }),
|
|
13432
|
+
import_zod20.z.strictObject({ state: import_zod20.z.literal("signed-in"), email: import_zod20.z.string().optional(), planScope: import_zod20.z.boolean(), accessTokenExpiresAt: import_zod20.z.number() }),
|
|
13433
|
+
import_zod20.z.strictObject({ state: import_zod20.z.literal("unreadable"), message: import_zod20.z.string() })
|
|
13187
13434
|
]);
|
|
13188
|
-
var CodexStatusOutputSchema =
|
|
13435
|
+
var CodexStatusOutputSchema = import_zod20.z.strictObject({
|
|
13189
13436
|
signIn: CodexSignInSchema,
|
|
13190
|
-
codexProviders:
|
|
13437
|
+
codexProviders: import_zod20.z.readonly(import_zod20.z.array(import_zod20.z.string()))
|
|
13191
13438
|
});
|
|
13192
|
-
var CodexLogoutOutputSchema =
|
|
13193
|
-
hadGrant:
|
|
13194
|
-
revoked:
|
|
13439
|
+
var CodexLogoutOutputSchema = import_zod20.z.strictObject({
|
|
13440
|
+
hadGrant: import_zod20.z.boolean(),
|
|
13441
|
+
revoked: import_zod20.z.boolean()
|
|
13195
13442
|
});
|
|
13196
13443
|
|
|
13197
13444
|
// src/frontdoor/codexApi.ts
|
|
@@ -13347,131 +13594,131 @@ init_identity();
|
|
|
13347
13594
|
init_providersStore();
|
|
13348
13595
|
|
|
13349
13596
|
// src/frontdoor/configSchemas.ts
|
|
13350
|
-
var
|
|
13597
|
+
var import_zod21 = require("zod");
|
|
13351
13598
|
init_schema();
|
|
13352
|
-
var RemovalConfirmationSchema =
|
|
13353
|
-
var CredentialWriteSchema = (targets) =>
|
|
13354
|
-
sources:
|
|
13355
|
-
target:
|
|
13356
|
-
cache:
|
|
13599
|
+
var RemovalConfirmationSchema = import_zod21.z.boolean();
|
|
13600
|
+
var CredentialWriteSchema = (targets) => import_zod21.z.strictObject({
|
|
13601
|
+
sources: import_zod21.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
13602
|
+
target: import_zod21.z.enum(targets).optional(),
|
|
13603
|
+
cache: import_zod21.z.union([import_zod21.z.literal(false), CredentialCacheSchema]).optional()
|
|
13357
13604
|
});
|
|
13358
|
-
var CredentialSummarySchema2 =
|
|
13359
|
-
target:
|
|
13360
|
-
sources:
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13605
|
+
var CredentialSummarySchema2 = import_zod21.z.strictObject({
|
|
13606
|
+
target: import_zod21.z.enum(CREDENTIAL_TARGETS),
|
|
13607
|
+
sources: import_zod21.z.readonly(import_zod21.z.array(
|
|
13608
|
+
import_zod21.z.discriminatedUnion("kind", [
|
|
13609
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("env"), variable: import_zod21.z.string() }),
|
|
13610
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("file"), path: import_zod21.z.string() }),
|
|
13611
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("command"), program: import_zod21.z.string() }),
|
|
13612
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("op"), reference: import_zod21.z.string() }),
|
|
13613
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("keychain"), service: import_zod21.z.string(), account: import_zod21.z.string().optional() }),
|
|
13614
|
+
import_zod21.z.strictObject({ kind: import_zod21.z.literal("literal") })
|
|
13368
13615
|
])
|
|
13369
13616
|
)),
|
|
13370
13617
|
cache: CredentialCacheSchema.optional()
|
|
13371
13618
|
});
|
|
13372
|
-
var mutationOutput = (kind, action) =>
|
|
13373
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
13374
|
-
var IdentityValueSchema =
|
|
13375
|
-
name:
|
|
13376
|
-
defaultConfigProfile:
|
|
13377
|
-
allowAmbientCredential:
|
|
13619
|
+
var mutationOutput = (kind, action) => import_zod21.z.strictObject({ action: import_zod21.z.literal(action), kind: import_zod21.z.literal(kind), name: import_zod21.z.string() });
|
|
13620
|
+
var storedMutationOutput = (kind, action, value) => import_zod21.z.strictObject({ action: import_zod21.z.literal(action), kind: import_zod21.z.literal(kind), name: import_zod21.z.string(), value });
|
|
13621
|
+
var IdentityValueSchema = import_zod21.z.strictObject({
|
|
13622
|
+
name: import_zod21.z.string(),
|
|
13623
|
+
defaultConfigProfile: import_zod21.z.string().optional(),
|
|
13624
|
+
allowAmbientCredential: import_zod21.z.boolean(),
|
|
13378
13625
|
credential: CredentialSummarySchema2.optional()
|
|
13379
13626
|
});
|
|
13380
13627
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
13381
|
-
var ProviderValueSchema =
|
|
13382
|
-
name:
|
|
13383
|
-
kind:
|
|
13384
|
-
displayName:
|
|
13385
|
-
baseUrl:
|
|
13628
|
+
var ProviderValueSchema = import_zod21.z.strictObject({
|
|
13629
|
+
name: import_zod21.z.string(),
|
|
13630
|
+
kind: import_zod21.z.enum(PROVIDER_KINDS),
|
|
13631
|
+
displayName: import_zod21.z.string(),
|
|
13632
|
+
baseUrl: import_zod21.z.string().optional(),
|
|
13386
13633
|
codex: CodexProviderConfigSchema.optional(),
|
|
13387
13634
|
credential: CredentialSummarySchema2,
|
|
13388
|
-
env:
|
|
13635
|
+
env: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.string()).optional()
|
|
13389
13636
|
});
|
|
13390
|
-
var ConfigNameInputSchema =
|
|
13637
|
+
var ConfigNameInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1) });
|
|
13391
13638
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
13392
|
-
var ConfigIdentitySetInputSchema =
|
|
13393
|
-
name:
|
|
13394
|
-
defaultConfigProfile:
|
|
13395
|
-
allowAmbientCredential:
|
|
13396
|
-
credential:
|
|
13639
|
+
var ConfigIdentitySetInputSchema = import_zod21.z.strictObject({
|
|
13640
|
+
name: import_zod21.z.string().min(1),
|
|
13641
|
+
defaultConfigProfile: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
|
|
13642
|
+
allowAmbientCredential: import_zod21.z.boolean().optional(),
|
|
13643
|
+
credential: import_zod21.z.union([import_zod21.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
|
|
13397
13644
|
});
|
|
13398
13645
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
13399
|
-
var ConfigIdentityRemoveInputSchema =
|
|
13646
|
+
var ConfigIdentityRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13400
13647
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
13401
13648
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
13402
|
-
var ConfigProfileAddInputSchema =
|
|
13403
|
-
name:
|
|
13404
|
-
extends:
|
|
13405
|
-
description:
|
|
13649
|
+
var ConfigProfileAddInputSchema = import_zod21.z.strictObject({
|
|
13650
|
+
name: import_zod21.z.string().min(1),
|
|
13651
|
+
extends: import_zod21.z.array(import_zod21.z.string().min(1)).optional(),
|
|
13652
|
+
description: import_zod21.z.string().optional()
|
|
13406
13653
|
});
|
|
13407
13654
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
13408
|
-
var ConfigProfileSetInputSchema =
|
|
13409
|
-
name:
|
|
13410
|
-
category:
|
|
13411
|
-
entry:
|
|
13412
|
-
extends:
|
|
13413
|
-
description:
|
|
13414
|
-
launch:
|
|
13415
|
-
skipPermissions:
|
|
13416
|
-
remoteControl:
|
|
13417
|
-
headroom:
|
|
13418
|
-
trackUsage:
|
|
13419
|
-
provider:
|
|
13420
|
-
claudeVersion:
|
|
13655
|
+
var ConfigProfileSetInputSchema = import_zod21.z.strictObject({
|
|
13656
|
+
name: import_zod21.z.string().min(1),
|
|
13657
|
+
category: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.boolean()).optional(),
|
|
13658
|
+
entry: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.boolean()).optional(),
|
|
13659
|
+
extends: import_zod21.z.union([import_zod21.z.array(import_zod21.z.string().min(1)), import_zod21.z.literal(false)]).optional(),
|
|
13660
|
+
description: import_zod21.z.union([import_zod21.z.string(), import_zod21.z.literal(false)]).optional(),
|
|
13661
|
+
launch: import_zod21.z.strictObject({
|
|
13662
|
+
skipPermissions: import_zod21.z.boolean().optional(),
|
|
13663
|
+
remoteControl: import_zod21.z.boolean().optional(),
|
|
13664
|
+
headroom: import_zod21.z.boolean().optional(),
|
|
13665
|
+
trackUsage: import_zod21.z.boolean().optional(),
|
|
13666
|
+
provider: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
|
|
13667
|
+
claudeVersion: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional()
|
|
13421
13668
|
}).optional()
|
|
13422
13669
|
});
|
|
13423
13670
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
13424
|
-
var ConfigProfileRemoveInputSchema =
|
|
13671
|
+
var ConfigProfileRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13425
13672
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
13426
13673
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
13427
|
-
var PoolMembersInputSchema =
|
|
13428
|
-
var ConfigPoolAddInputSchema =
|
|
13429
|
-
name:
|
|
13674
|
+
var PoolMembersInputSchema = import_zod21.z.array(import_zod21.z.string().min(1)).min(1);
|
|
13675
|
+
var ConfigPoolAddInputSchema = import_zod21.z.strictObject({
|
|
13676
|
+
name: import_zod21.z.string().min(1),
|
|
13430
13677
|
identities: PoolMembersInputSchema,
|
|
13431
|
-
preference:
|
|
13678
|
+
preference: import_zod21.z.enum(POOL_PREFERENCES).optional()
|
|
13432
13679
|
});
|
|
13433
13680
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
13434
|
-
var ConfigPoolSetInputSchema =
|
|
13435
|
-
name:
|
|
13681
|
+
var ConfigPoolSetInputSchema = import_zod21.z.strictObject({
|
|
13682
|
+
name: import_zod21.z.string().min(1),
|
|
13436
13683
|
identities: PoolMembersInputSchema.optional(),
|
|
13437
|
-
preference:
|
|
13684
|
+
preference: import_zod21.z.union([import_zod21.z.enum(POOL_PREFERENCES), import_zod21.z.literal(false)]).optional()
|
|
13438
13685
|
});
|
|
13439
13686
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
13440
|
-
var ConfigPoolRemoveInputSchema =
|
|
13687
|
+
var ConfigPoolRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13441
13688
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
13442
13689
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
13443
|
-
var ConfigProviderAddInputSchema =
|
|
13444
|
-
name:
|
|
13445
|
-
kind:
|
|
13446
|
-
displayName:
|
|
13447
|
-
baseUrl:
|
|
13690
|
+
var ConfigProviderAddInputSchema = import_zod21.z.strictObject({
|
|
13691
|
+
name: import_zod21.z.string().min(1),
|
|
13692
|
+
kind: import_zod21.z.enum(PROVIDER_KINDS).optional(),
|
|
13693
|
+
displayName: import_zod21.z.string().min(1),
|
|
13694
|
+
baseUrl: import_zod21.z.string().min(1).optional(),
|
|
13448
13695
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
13449
13696
|
codex: CodexProviderConfigSchema.optional()
|
|
13450
13697
|
});
|
|
13451
13698
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
13452
|
-
var ConfigProviderSetInputSchema =
|
|
13453
|
-
name:
|
|
13454
|
-
displayName:
|
|
13455
|
-
baseUrl:
|
|
13699
|
+
var ConfigProviderSetInputSchema = import_zod21.z.strictObject({
|
|
13700
|
+
name: import_zod21.z.string().min(1),
|
|
13701
|
+
displayName: import_zod21.z.string().min(1).optional(),
|
|
13702
|
+
baseUrl: import_zod21.z.string().min(1).optional(),
|
|
13456
13703
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
13457
13704
|
codex: CodexProviderConfigSchema.optional()
|
|
13458
13705
|
});
|
|
13459
13706
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
13460
|
-
var ConfigProviderRemoveInputSchema =
|
|
13707
|
+
var ConfigProviderRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13461
13708
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
13462
|
-
var ConfigRuleAddInputSchema =
|
|
13463
|
-
path:
|
|
13464
|
-
configProfile:
|
|
13465
|
-
identity:
|
|
13709
|
+
var ConfigRuleAddInputSchema = import_zod21.z.strictObject({
|
|
13710
|
+
path: import_zod21.z.string().min(1),
|
|
13711
|
+
configProfile: import_zod21.z.string().min(1).optional(),
|
|
13712
|
+
identity: import_zod21.z.string().min(1).optional()
|
|
13466
13713
|
});
|
|
13467
13714
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
13468
|
-
var ConfigRuleSetInputSchema =
|
|
13469
|
-
path:
|
|
13470
|
-
configProfile:
|
|
13471
|
-
identity:
|
|
13715
|
+
var ConfigRuleSetInputSchema = import_zod21.z.strictObject({
|
|
13716
|
+
path: import_zod21.z.string().min(1),
|
|
13717
|
+
configProfile: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
|
|
13718
|
+
identity: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional()
|
|
13472
13719
|
});
|
|
13473
13720
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
13474
|
-
var ConfigRuleRemoveInputSchema =
|
|
13721
|
+
var ConfigRuleRemoveInputSchema = import_zod21.z.strictObject({ path: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13475
13722
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
13476
13723
|
|
|
13477
13724
|
// src/frontdoor/configApi.ts
|
|
@@ -13777,41 +14024,41 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
13777
14024
|
var import_server3 = require("@orpc/server");
|
|
13778
14025
|
|
|
13779
14026
|
// src/frontdoor/eventSchemas.ts
|
|
13780
|
-
var
|
|
14027
|
+
var import_zod22 = require("zod");
|
|
13781
14028
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
13782
14029
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
13783
14030
|
var USAGE_EVENT_SOURCE = "usage";
|
|
13784
14031
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
13785
14032
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
13786
|
-
var DoorEventSchema =
|
|
13787
|
-
source:
|
|
14033
|
+
var DoorEventSchema = import_zod22.z.strictObject({
|
|
14034
|
+
source: import_zod22.z.string().min(1),
|
|
13788
14035
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
13789
|
-
sequence:
|
|
13790
|
-
payload:
|
|
14036
|
+
sequence: import_zod22.z.number().int().positive(),
|
|
14037
|
+
payload: import_zod22.z.unknown()
|
|
13791
14038
|
});
|
|
13792
|
-
var DoorEventSourceQuerySchema =
|
|
13793
|
-
sources:
|
|
14039
|
+
var DoorEventSourceQuerySchema = import_zod22.z.strictObject({
|
|
14040
|
+
sources: import_zod22.z.array(import_zod22.z.string().min(1)).min(1).optional()
|
|
13794
14041
|
});
|
|
13795
|
-
var LaunchLifecycleEventSchema =
|
|
13796
|
-
kind:
|
|
13797
|
-
pid:
|
|
13798
|
-
startedAt:
|
|
13799
|
-
observedAt:
|
|
14042
|
+
var LaunchLifecycleEventSchema = import_zod22.z.strictObject({
|
|
14043
|
+
kind: import_zod22.z.enum(["registered", "pruned", "ended"]),
|
|
14044
|
+
pid: import_zod22.z.number().int().positive(),
|
|
14045
|
+
startedAt: import_zod22.z.number(),
|
|
14046
|
+
observedAt: import_zod22.z.number()
|
|
13800
14047
|
});
|
|
13801
|
-
var DoorHealthEventSchema =
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
14048
|
+
var DoorHealthEventSchema = import_zod22.z.discriminatedUnion("kind", [
|
|
14049
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("generation"), pid: import_zod22.z.number().int().positive(), providerPort: import_zod22.z.number().int().positive(), connectPort: import_zod22.z.number().int().positive(), directPort: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() }),
|
|
14050
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("listenerFailed"), pid: import_zod22.z.number().int().positive(), listener: import_zod22.z.enum(["provider", "connect", "direct"]), message: import_zod22.z.string(), observedAt: import_zod22.z.number() }),
|
|
14051
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("binaryTurnover"), pid: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() }),
|
|
14052
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("idleShutdown"), pid: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() })
|
|
13806
14053
|
]);
|
|
13807
|
-
var QuotaExpiringEventSchema =
|
|
13808
|
-
identity:
|
|
13809
|
-
provider:
|
|
13810
|
-
window:
|
|
14054
|
+
var QuotaExpiringEventSchema = import_zod22.z.strictObject({
|
|
14055
|
+
identity: import_zod22.z.string().min(1),
|
|
14056
|
+
provider: import_zod22.z.string().min(1),
|
|
14057
|
+
window: import_zod22.z.enum(["fiveHour", "sevenDay"]),
|
|
13811
14058
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
13812
|
-
utilization:
|
|
13813
|
-
resetsAt:
|
|
13814
|
-
observedAt:
|
|
14059
|
+
utilization: import_zod22.z.number().min(0).max(1),
|
|
14060
|
+
resetsAt: import_zod22.z.iso.datetime(),
|
|
14061
|
+
observedAt: import_zod22.z.number()
|
|
13815
14062
|
});
|
|
13816
14063
|
|
|
13817
14064
|
// src/frontdoor/eventsApi.ts
|
|
@@ -13895,51 +14142,51 @@ init_cliError();
|
|
|
13895
14142
|
|
|
13896
14143
|
// src/frontdoor/launchSchemas.ts
|
|
13897
14144
|
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
13898
|
-
var
|
|
14145
|
+
var import_zod23 = require("zod");
|
|
13899
14146
|
init_claudeVersion();
|
|
13900
14147
|
init_identity();
|
|
13901
|
-
var LaunchResolveInputSchema =
|
|
13902
|
-
path:
|
|
14148
|
+
var LaunchResolveInputSchema = import_zod23.z.strictObject({
|
|
14149
|
+
path: import_zod23.z.string().min(1),
|
|
13903
14150
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
13904
|
-
argv:
|
|
14151
|
+
argv: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())).optional(),
|
|
13905
14152
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
13906
|
-
env:
|
|
14153
|
+
env: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.string()).optional()
|
|
13907
14154
|
}).refine((input) => import_node_path31.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13908
|
-
var LaunchPoolDecisionSchema =
|
|
13909
|
-
name:
|
|
13910
|
-
reasons:
|
|
13911
|
-
movedOff:
|
|
14155
|
+
var LaunchPoolDecisionSchema = import_zod23.z.strictObject({
|
|
14156
|
+
name: import_zod23.z.string(),
|
|
14157
|
+
reasons: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
|
|
14158
|
+
movedOff: import_zod23.z.strictObject({ identity: import_zod23.z.string(), reason: import_zod23.z.string() }).optional()
|
|
13912
14159
|
});
|
|
13913
|
-
var LaunchDecisionSchema =
|
|
13914
|
-
identity:
|
|
13915
|
-
identitySource:
|
|
14160
|
+
var LaunchDecisionSchema = import_zod23.z.strictObject({
|
|
14161
|
+
identity: import_zod23.z.string().optional(),
|
|
14162
|
+
identitySource: import_zod23.z.enum(IDENTITY_DECISION_SOURCES),
|
|
13916
14163
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
13917
|
-
configDirEscapeHatch:
|
|
13918
|
-
configDir:
|
|
13919
|
-
configProfile:
|
|
13920
|
-
configProfileSource:
|
|
13921
|
-
provider:
|
|
14164
|
+
configDirEscapeHatch: import_zod23.z.boolean(),
|
|
14165
|
+
configDir: import_zod23.z.string().optional(),
|
|
14166
|
+
configProfile: import_zod23.z.string().optional(),
|
|
14167
|
+
configProfileSource: import_zod23.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
14168
|
+
provider: import_zod23.z.string().optional()
|
|
13922
14169
|
});
|
|
13923
|
-
var LaunchFlagsSchema =
|
|
13924
|
-
skipPermissions:
|
|
13925
|
-
remoteControl:
|
|
13926
|
-
headroom:
|
|
13927
|
-
trackUsage:
|
|
14170
|
+
var LaunchFlagsSchema = import_zod23.z.strictObject({
|
|
14171
|
+
skipPermissions: import_zod23.z.boolean(),
|
|
14172
|
+
remoteControl: import_zod23.z.boolean(),
|
|
14173
|
+
headroom: import_zod23.z.boolean(),
|
|
14174
|
+
trackUsage: import_zod23.z.boolean()
|
|
13928
14175
|
});
|
|
13929
|
-
var LaunchResolveOutputSchema =
|
|
14176
|
+
var LaunchResolveOutputSchema = import_zod23.z.strictObject({
|
|
13930
14177
|
decision: LaunchDecisionSchema,
|
|
13931
14178
|
flags: LaunchFlagsSchema,
|
|
13932
|
-
claudeVersion:
|
|
14179
|
+
claudeVersion: import_zod23.z.strictObject({ version: import_zod23.z.string(), source: import_zod23.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
13933
14180
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
13934
|
-
bin:
|
|
14181
|
+
bin: import_zod23.z.string(),
|
|
13935
14182
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
13936
|
-
args:
|
|
14183
|
+
args: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
|
|
13937
14184
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
13938
|
-
credential:
|
|
13939
|
-
routing:
|
|
14185
|
+
credential: import_zod23.z.strictObject({ subject: import_zod23.z.enum(["provider", "identity"]), name: import_zod23.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
14186
|
+
routing: import_zod23.z.strictObject({ frontDoor: import_zod23.z.boolean(), headroom: import_zod23.z.boolean() }),
|
|
13940
14187
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
13941
|
-
environment:
|
|
13942
|
-
warnings:
|
|
14188
|
+
environment: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
|
|
14189
|
+
warnings: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string()))
|
|
13943
14190
|
});
|
|
13944
14191
|
|
|
13945
14192
|
// src/frontdoor/launchApi.ts
|
|
@@ -16207,6 +16454,8 @@ init_ownCli();
|
|
|
16207
16454
|
0 && (module.exports = {
|
|
16208
16455
|
AMBIENT_CREDENTIAL_VARS,
|
|
16209
16456
|
CHECK_CREDENTIAL_APPLIES,
|
|
16457
|
+
CODEX_APP_SERVER_GENERATED_AGAINST,
|
|
16458
|
+
CODEX_APP_SERVER_TIMEOUT_MS,
|
|
16210
16459
|
CONNECT_INTERCEPT_HOST,
|
|
16211
16460
|
CONNECT_INTERCEPT_HOSTS,
|
|
16212
16461
|
CONNECT_LIMITS,
|
|
@@ -16217,7 +16466,12 @@ init_ownCli();
|
|
|
16217
16466
|
CheckReportJsonSchema,
|
|
16218
16467
|
CheckRunInputSchema,
|
|
16219
16468
|
CliError,
|
|
16469
|
+
CodexAccountReadSchema,
|
|
16470
|
+
CodexAppServerProtocolError,
|
|
16471
|
+
CodexAppServerRequestError,
|
|
16472
|
+
CodexAppServerUnavailableError,
|
|
16220
16473
|
CodexLogoutOutputSchema,
|
|
16474
|
+
CodexRateLimitsReadSchema,
|
|
16221
16475
|
CodexSignInSchema,
|
|
16222
16476
|
CodexStatusOutputSchema,
|
|
16223
16477
|
ConfigIdentityAddOutputSchema,
|
|
@@ -16475,6 +16729,8 @@ init_ownCli();
|
|
|
16475
16729
|
rcSelfHostFromEnv,
|
|
16476
16730
|
rcWebFetchAllowsPrivateFromEnv,
|
|
16477
16731
|
readActiveIdentity,
|
|
16732
|
+
readCodexAccount,
|
|
16733
|
+
readCodexRateLimits,
|
|
16478
16734
|
readDirectoryRules,
|
|
16479
16735
|
readFarmManifest,
|
|
16480
16736
|
readFrontDoorControlMaterial,
|
|
@@ -16486,6 +16742,7 @@ init_ownCli();
|
|
|
16486
16742
|
readRcSelfHostRecord,
|
|
16487
16743
|
readRcSessionFile,
|
|
16488
16744
|
readUsageSnapshot,
|
|
16745
|
+
realCodexAppServerPort,
|
|
16489
16746
|
realConnectCertStore,
|
|
16490
16747
|
realConnectEffects,
|
|
16491
16748
|
realRcControlTransport,
|