claude-use 11.89.1 → 12.0.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 +2566 -1315
- package/dist/index.cjs +1811 -1047
- package/dist/index.mjs +1763 -1007
- package/dist/types/index.d.ts +684 -224
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5341,46 +5341,46 @@ function acceptsNull(path55) {
|
|
|
5341
5341
|
return StatuslineSchema.safeParse(layer).success;
|
|
5342
5342
|
}
|
|
5343
5343
|
function keyOf(path55, declared) {
|
|
5344
|
-
const optional = declared instanceof
|
|
5344
|
+
const optional = declared instanceof import_zod11.z.ZodOptional;
|
|
5345
5345
|
const leaf = optional ? declared.unwrap() : declared;
|
|
5346
5346
|
const common = { path: path55.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path55), optional, unsettable: acceptsNull(path55) };
|
|
5347
|
-
if (leaf instanceof
|
|
5347
|
+
if (leaf instanceof import_zod11.z.ZodNumber) {
|
|
5348
5348
|
return { ...common, kind: "integer", choices: [] };
|
|
5349
5349
|
}
|
|
5350
|
-
if (leaf instanceof
|
|
5350
|
+
if (leaf instanceof import_zod11.z.ZodBoolean) {
|
|
5351
5351
|
return { ...common, kind: "boolean", choices: [] };
|
|
5352
5352
|
}
|
|
5353
|
-
if (leaf instanceof
|
|
5353
|
+
if (leaf instanceof import_zod11.z.ZodString) {
|
|
5354
5354
|
return { ...common, kind: "text", choices: [] };
|
|
5355
5355
|
}
|
|
5356
|
-
if (leaf instanceof
|
|
5356
|
+
if (leaf instanceof import_zod11.z.ZodUnion) {
|
|
5357
5357
|
return { ...common, kind: "colour", choices: [...STATUSLINE_COLOUR_NAMES] };
|
|
5358
5358
|
}
|
|
5359
|
-
if (leaf instanceof
|
|
5359
|
+
if (leaf instanceof import_zod11.z.ZodEnum) {
|
|
5360
5360
|
return { ...common, kind: "choice", choices: Object.values(leaf.enum).map(String) };
|
|
5361
5361
|
}
|
|
5362
|
-
if (leaf instanceof
|
|
5362
|
+
if (leaf instanceof import_zod11.z.ZodArray && leaf.element instanceof import_zod11.z.ZodEnum) {
|
|
5363
5363
|
return { ...common, kind: "list", choices: Object.values(leaf.element.enum).map(String) };
|
|
5364
5364
|
}
|
|
5365
|
-
if (leaf instanceof
|
|
5365
|
+
if (leaf instanceof import_zod11.z.ZodArray && leaf.element instanceof import_zod11.z.ZodArray && leaf.element.element instanceof import_zod11.z.ZodEnum) {
|
|
5366
5366
|
return { ...common, kind: "groups", choices: Object.values(leaf.element.element.enum).map(String) };
|
|
5367
5367
|
}
|
|
5368
|
-
if (leaf instanceof
|
|
5368
|
+
if (leaf instanceof import_zod11.z.ZodArray && leaf.element instanceof import_zod11.z.ZodString) {
|
|
5369
5369
|
return { ...common, kind: "textList", choices: [] };
|
|
5370
5370
|
}
|
|
5371
5371
|
throw new TypeError(`statusline setting ${path55.join(".")} has a kind the key listing does not describe`);
|
|
5372
5372
|
}
|
|
5373
5373
|
function walk(shape, prefix) {
|
|
5374
|
-
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof
|
|
5374
|
+
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod11.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
5375
5375
|
}
|
|
5376
5376
|
function statuslineKeys() {
|
|
5377
5377
|
return walk(ResolvedStatuslineSchema.shape, []);
|
|
5378
5378
|
}
|
|
5379
|
-
var
|
|
5379
|
+
var import_zod11;
|
|
5380
5380
|
var init_keys = __esm({
|
|
5381
5381
|
"src/statusline/keys.ts"() {
|
|
5382
5382
|
"use strict";
|
|
5383
|
-
|
|
5383
|
+
import_zod11 = require("zod");
|
|
5384
5384
|
init_statusline();
|
|
5385
5385
|
}
|
|
5386
5386
|
});
|
|
@@ -5788,164 +5788,164 @@ var init_poolStore = __esm({
|
|
|
5788
5788
|
});
|
|
5789
5789
|
|
|
5790
5790
|
// src/usage/schema.ts
|
|
5791
|
-
var
|
|
5791
|
+
var import_zod12, USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, CLIENT_SESSION_ID_PATTERN, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderAccountSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
|
|
5792
5792
|
var init_schema2 = __esm({
|
|
5793
5793
|
"src/usage/schema.ts"() {
|
|
5794
5794
|
"use strict";
|
|
5795
|
-
|
|
5795
|
+
import_zod12 = require("zod");
|
|
5796
5796
|
USAGE_SCHEMA_VERSION = 1;
|
|
5797
|
-
VersionSchema =
|
|
5798
|
-
InstantSchema =
|
|
5797
|
+
VersionSchema = import_zod12.z.literal(USAGE_SCHEMA_VERSION);
|
|
5798
|
+
InstantSchema = import_zod12.z.iso.datetime();
|
|
5799
5799
|
CLIENT_SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
5800
|
-
TokenCountSchema =
|
|
5801
|
-
TokenUsageSchema =
|
|
5800
|
+
TokenCountSchema = import_zod12.z.number().int().nonnegative();
|
|
5801
|
+
TokenUsageSchema = import_zod12.z.strictObject({
|
|
5802
5802
|
inputTokens: TokenCountSchema.optional(),
|
|
5803
5803
|
outputTokens: TokenCountSchema.optional(),
|
|
5804
5804
|
cacheCreationInputTokens: TokenCountSchema.optional(),
|
|
5805
5805
|
cacheReadInputTokens: TokenCountSchema.optional()
|
|
5806
5806
|
});
|
|
5807
5807
|
LIMIT_KINDS = ["rate-limited", "quota-exhausted"];
|
|
5808
|
-
LimitClassificationSchema =
|
|
5809
|
-
kind:
|
|
5808
|
+
LimitClassificationSchema = import_zod12.z.strictObject({
|
|
5809
|
+
kind: import_zod12.z.enum(LIMIT_KINDS),
|
|
5810
5810
|
/** Seconds to wait before retrying, from the response's `retry-after`. */
|
|
5811
|
-
retryAfterSeconds:
|
|
5811
|
+
retryAfterSeconds: import_zod12.z.number().nonnegative().optional(),
|
|
5812
5812
|
/** When the limiting window resets, from the upstream's own reset header. */
|
|
5813
5813
|
resetAt: InstantSchema.optional(),
|
|
5814
5814
|
/** The window the upstream named as the binding one (`anthropic-ratelimit-unified-representative-claim`), such as `five_hour` or `seven_day`. */
|
|
5815
|
-
window:
|
|
5815
|
+
window: import_zod12.z.string().optional(),
|
|
5816
5816
|
/** 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. */
|
|
5817
|
-
evidence:
|
|
5817
|
+
evidence: import_zod12.z.array(import_zod12.z.string())
|
|
5818
5818
|
});
|
|
5819
|
-
UsageRecordSchema =
|
|
5819
|
+
UsageRecordSchema = import_zod12.z.strictObject({
|
|
5820
5820
|
schemaVersion: VersionSchema,
|
|
5821
5821
|
/** When the front door received the request. */
|
|
5822
5822
|
at: InstantSchema,
|
|
5823
5823
|
/** The id of the launching identity (the directory it is stored in, which a rename of its name keeps), when the launch resolved one: what the session's identity header carries. */
|
|
5824
|
-
identity:
|
|
5824
|
+
identity: import_zod12.z.string().optional(),
|
|
5825
5825
|
/** `anthropic` for an OAuth session's request to Claude Code's own API, otherwise the provider's name. */
|
|
5826
|
-
provider:
|
|
5826
|
+
provider: import_zod12.z.string(),
|
|
5827
5827
|
/** The launch's session id, generated per launch. */
|
|
5828
|
-
sessionId:
|
|
5828
|
+
sessionId: import_zod12.z.string().optional(),
|
|
5829
5829
|
/** The client's own id for the conversation, from the request's `x-claude-code-session-id` header: it changes when the conversation is cleared inside one launch, which `sessionId` does not, so it is what ties a request to the client's per-conversation figures. Absent when the client sent none. */
|
|
5830
|
-
clientSessionId:
|
|
5830
|
+
clientSessionId: import_zod12.z.string().regex(CLIENT_SESSION_ID_PATTERN).optional(),
|
|
5831
5831
|
/** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
|
|
5832
|
-
project:
|
|
5832
|
+
project: import_zod12.z.string().optional(),
|
|
5833
5833
|
/** Whether the request crossed headroom on its way upstream. Absent on a record written before the door recorded it, and false when the request went direct. */
|
|
5834
|
-
viaHeadroom:
|
|
5834
|
+
viaHeadroom: import_zod12.z.boolean().optional(),
|
|
5835
5835
|
/** The front-door route that served the request. */
|
|
5836
|
-
route:
|
|
5837
|
-
method:
|
|
5836
|
+
route: import_zod12.z.string(),
|
|
5837
|
+
method: import_zod12.z.string(),
|
|
5838
5838
|
/** The API path as the upstream sees it (`/v1/messages`), without the provider prefix or a query string. */
|
|
5839
|
-
endpoint:
|
|
5839
|
+
endpoint: import_zod12.z.string(),
|
|
5840
5840
|
/** The model the response named. */
|
|
5841
|
-
model:
|
|
5841
|
+
model: import_zod12.z.string().optional(),
|
|
5842
5842
|
/** The model the session requested when a routing layer chose a different model, or when no response model was available to compare it with. Absent when the response confirms that the requested name was served unchanged. */
|
|
5843
|
-
requestedModel:
|
|
5843
|
+
requestedModel: import_zod12.z.string().optional(),
|
|
5844
5844
|
/** The distinct providers the choice could have landed on, present only when there was more than one, so a reader can tell a choice that crossed providers from one that stayed inside a single provider's lineup. */
|
|
5845
|
-
candidateProviders:
|
|
5846
|
-
status:
|
|
5845
|
+
candidateProviders: import_zod12.z.array(import_zod12.z.string()).optional(),
|
|
5846
|
+
status: import_zod12.z.number().int(),
|
|
5847
5847
|
/** Milliseconds from the request's arrival to its response head. */
|
|
5848
|
-
latencyMs:
|
|
5848
|
+
latencyMs: import_zod12.z.number().int().nonnegative(),
|
|
5849
5849
|
/** Milliseconds from the request's arrival to the end of its response body. */
|
|
5850
|
-
durationMs:
|
|
5850
|
+
durationMs: import_zod12.z.number().int().nonnegative(),
|
|
5851
5851
|
/** Whether the client received the whole body. */
|
|
5852
|
-
outcome:
|
|
5852
|
+
outcome: import_zod12.z.enum(["completed", "aborted"]),
|
|
5853
5853
|
usage: TokenUsageSchema.optional(),
|
|
5854
5854
|
/** The response's quota and rate-limit headers, by name (see `isRateLimitHeader`). */
|
|
5855
|
-
rateLimitHeaders:
|
|
5855
|
+
rateLimitHeaders: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.string()).optional(),
|
|
5856
5856
|
limit: LimitClassificationSchema.optional(),
|
|
5857
5857
|
/** The upstream's request id (`request-id`), for matching a record to the provider's own logs. */
|
|
5858
|
-
requestId:
|
|
5858
|
+
requestId: import_zod12.z.string().optional()
|
|
5859
5859
|
});
|
|
5860
|
-
QuotaWindowSchema =
|
|
5860
|
+
QuotaWindowSchema = import_zod12.z.strictObject({
|
|
5861
5861
|
/** The fraction of the window used, as the upstream reports it (0 to 1). */
|
|
5862
|
-
utilization:
|
|
5862
|
+
utilization: import_zod12.z.number().nonnegative().optional(),
|
|
5863
5863
|
resetsAt: InstantSchema.optional(),
|
|
5864
5864
|
/** The window's own status (`allowed`, `allowed_warning`, `rejected`). */
|
|
5865
|
-
status:
|
|
5865
|
+
status: import_zod12.z.string().optional(),
|
|
5866
5866
|
/** 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. */
|
|
5867
|
-
graceUtilization:
|
|
5867
|
+
graceUtilization: import_zod12.z.number().nonnegative().optional()
|
|
5868
5868
|
});
|
|
5869
|
-
ExtraUsageSpendSchema =
|
|
5869
|
+
ExtraUsageSpendSchema = import_zod12.z.strictObject({
|
|
5870
5870
|
/** Spent so far in the allowance's period, in the currency's minor units (pence, cents). */
|
|
5871
|
-
usedMinor:
|
|
5871
|
+
usedMinor: import_zod12.z.number().nonnegative(),
|
|
5872
5872
|
/** The allowance's cap in the same units, when it has one. */
|
|
5873
|
-
limitMinor:
|
|
5873
|
+
limitMinor: import_zod12.z.number().nonnegative().optional(),
|
|
5874
5874
|
/** The ISO 4217 currency code. */
|
|
5875
|
-
currency:
|
|
5875
|
+
currency: import_zod12.z.string()
|
|
5876
5876
|
});
|
|
5877
|
-
UnifiedRateLimitSchema =
|
|
5877
|
+
UnifiedRateLimitSchema = import_zod12.z.strictObject({
|
|
5878
5878
|
/** The overall status: `allowed`, `allowed_warning` or `rejected`. */
|
|
5879
|
-
status:
|
|
5879
|
+
status: import_zod12.z.string().optional(),
|
|
5880
5880
|
fiveHour: QuotaWindowSchema.optional(),
|
|
5881
5881
|
sevenDay: QuotaWindowSchema.optional(),
|
|
5882
5882
|
/** 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. */
|
|
5883
5883
|
sevenDayOverageIncluded: QuotaWindowSchema.optional(),
|
|
5884
5884
|
/** The window that currently binds. */
|
|
5885
|
-
representativeClaim:
|
|
5885
|
+
representativeClaim: import_zod12.z.string().optional(),
|
|
5886
5886
|
/** When the binding window resets. */
|
|
5887
5887
|
resetAt: InstantSchema.optional(),
|
|
5888
5888
|
/** Whether usage beyond the plan (extra usage) is available: `allowed` or `rejected`. */
|
|
5889
|
-
overageStatus:
|
|
5889
|
+
overageStatus: import_zod12.z.string().optional(),
|
|
5890
5890
|
/** 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. */
|
|
5891
|
-
overageUtilization:
|
|
5891
|
+
overageUtilization: import_zod12.z.number().nonnegative().optional(),
|
|
5892
5892
|
/** When the extra-usage allowance resets. */
|
|
5893
5893
|
overageResetsAt: InstantSchema.optional(),
|
|
5894
5894
|
/** Why extra usage is unavailable, as the upstream names it (`out_of_credits`, for one). */
|
|
5895
|
-
overageDisabledReason:
|
|
5895
|
+
overageDisabledReason: import_zod12.z.string().optional(),
|
|
5896
5896
|
/** Whether the response was served on extra usage, as the upstream states it. */
|
|
5897
|
-
overageInUse:
|
|
5897
|
+
overageInUse: import_zod12.z.boolean().optional(),
|
|
5898
5898
|
/** The allowance in money, from the usage endpoint (the response headers state only the fraction). */
|
|
5899
5899
|
extraUsageSpend: ExtraUsageSpendSchema.optional(),
|
|
5900
5900
|
/** True when the upstream offers a fallback while a window is rejected: some requests, by model, are still served, though the rest are refused. */
|
|
5901
|
-
fallbackAvailable:
|
|
5901
|
+
fallbackAvailable: import_zod12.z.boolean().optional()
|
|
5902
5902
|
});
|
|
5903
|
-
RateLimitStateSchema =
|
|
5903
|
+
RateLimitStateSchema = import_zod12.z.strictObject({
|
|
5904
5904
|
observedAt: InstantSchema,
|
|
5905
5905
|
/** Every quota and rate-limit header on that response, by name. */
|
|
5906
|
-
headers:
|
|
5906
|
+
headers: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.string()),
|
|
5907
5907
|
unified: UnifiedRateLimitSchema.optional(),
|
|
5908
5908
|
/** 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. */
|
|
5909
5909
|
planWindowsUnavailableAt: InstantSchema.optional()
|
|
5910
5910
|
});
|
|
5911
5911
|
LimitEventSchema = LimitClassificationSchema.extend({
|
|
5912
5912
|
observedAt: InstantSchema,
|
|
5913
|
-
status:
|
|
5913
|
+
status: import_zod12.z.number().int()
|
|
5914
5914
|
});
|
|
5915
|
-
ProviderQuotaWindowSchema =
|
|
5915
|
+
ProviderQuotaWindowSchema = import_zod12.z.strictObject({
|
|
5916
5916
|
/** What the window measures, in the provider's terms (`tokens`, `tool-calls`). */
|
|
5917
|
-
measures:
|
|
5917
|
+
measures: import_zod12.z.string(),
|
|
5918
5918
|
/** 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. */
|
|
5919
|
-
periodMs:
|
|
5919
|
+
periodMs: import_zod12.z.number().int().positive().optional(),
|
|
5920
5920
|
/** The provider's own description of the period when `periodMs` could not be derived, such as `unit 4 x 1`. */
|
|
5921
|
-
period:
|
|
5921
|
+
period: import_zod12.z.string().optional(),
|
|
5922
5922
|
/** The fraction of the window used (0 to 1). */
|
|
5923
|
-
utilization:
|
|
5923
|
+
utilization: import_zod12.z.number().nonnegative(),
|
|
5924
5924
|
resetsAt: InstantSchema.optional(),
|
|
5925
5925
|
/** Absolute counts, when the provider reports them for this window. */
|
|
5926
|
-
limit:
|
|
5927
|
-
used:
|
|
5928
|
-
remaining:
|
|
5926
|
+
limit: import_zod12.z.number().nonnegative().optional(),
|
|
5927
|
+
used: import_zod12.z.number().nonnegative().optional(),
|
|
5928
|
+
remaining: import_zod12.z.number().nonnegative().optional()
|
|
5929
5929
|
});
|
|
5930
|
-
ProviderAccountSchema =
|
|
5931
|
-
email:
|
|
5932
|
-
accountId:
|
|
5930
|
+
ProviderAccountSchema = import_zod12.z.strictObject({
|
|
5931
|
+
email: import_zod12.z.string().optional(),
|
|
5932
|
+
accountId: import_zod12.z.string().optional()
|
|
5933
5933
|
});
|
|
5934
|
-
ProviderQuotaSchema =
|
|
5934
|
+
ProviderQuotaSchema = import_zod12.z.strictObject({
|
|
5935
5935
|
observedAt: InstantSchema,
|
|
5936
5936
|
/** Which usage endpoint produced it (`z.ai`). */
|
|
5937
|
-
source:
|
|
5937
|
+
source: import_zod12.z.string(),
|
|
5938
5938
|
/** The subscription level the endpoint reports, when it does. */
|
|
5939
|
-
level:
|
|
5939
|
+
level: import_zod12.z.string().optional(),
|
|
5940
5940
|
/** The account the provider's credential belongs to, when its endpoint reports it. */
|
|
5941
5941
|
account: ProviderAccountSchema.optional(),
|
|
5942
|
-
windows:
|
|
5942
|
+
windows: import_zod12.z.array(ProviderQuotaWindowSchema)
|
|
5943
5943
|
});
|
|
5944
|
-
ProviderUsageStateSchema =
|
|
5944
|
+
ProviderUsageStateSchema = import_zod12.z.strictObject({
|
|
5945
5945
|
/** 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. */
|
|
5946
5946
|
lastRequestAt: InstantSchema.optional(),
|
|
5947
|
-
lastStatus:
|
|
5948
|
-
lastModel:
|
|
5947
|
+
lastStatus: import_zod12.z.number().int().optional(),
|
|
5948
|
+
lastModel: import_zod12.z.string().optional(),
|
|
5949
5949
|
/** The latest rate-limit state, from the last response that carried any rate-limit header. */
|
|
5950
5950
|
rateLimit: RateLimitStateSchema.optional(),
|
|
5951
5951
|
/** The latest classified refusal. It stays after later successes, so a reader compares its `resetAt` (or `observedAt` plus `retryAfterSeconds`) with the current time. */
|
|
@@ -5953,31 +5953,31 @@ var init_schema2 = __esm({
|
|
|
5953
5953
|
/** The latest quota the provider's usage endpoint reported, for providers whose quota is not visible in response headers. */
|
|
5954
5954
|
quota: ProviderQuotaSchema.optional()
|
|
5955
5955
|
});
|
|
5956
|
-
AccountMetadataSchema =
|
|
5957
|
-
accountUuid:
|
|
5958
|
-
emailAddress:
|
|
5959
|
-
displayName:
|
|
5960
|
-
organizationUuid:
|
|
5961
|
-
organizationName:
|
|
5962
|
-
organizationType:
|
|
5963
|
-
organizationRole:
|
|
5964
|
-
workspaceRole:
|
|
5965
|
-
billingType:
|
|
5966
|
-
seatTier:
|
|
5967
|
-
organizationRateLimitTier:
|
|
5968
|
-
userRateLimitTier:
|
|
5969
|
-
hasExtraUsageEnabled:
|
|
5970
|
-
subscriptionCreatedAt:
|
|
5971
|
-
accountCreatedAt:
|
|
5956
|
+
AccountMetadataSchema = import_zod12.z.strictObject({
|
|
5957
|
+
accountUuid: import_zod12.z.string().optional(),
|
|
5958
|
+
emailAddress: import_zod12.z.string().optional(),
|
|
5959
|
+
displayName: import_zod12.z.string().optional(),
|
|
5960
|
+
organizationUuid: import_zod12.z.string().optional(),
|
|
5961
|
+
organizationName: import_zod12.z.string().optional(),
|
|
5962
|
+
organizationType: import_zod12.z.string().optional(),
|
|
5963
|
+
organizationRole: import_zod12.z.string().optional(),
|
|
5964
|
+
workspaceRole: import_zod12.z.string().optional(),
|
|
5965
|
+
billingType: import_zod12.z.string().optional(),
|
|
5966
|
+
seatTier: import_zod12.z.string().optional(),
|
|
5967
|
+
organizationRateLimitTier: import_zod12.z.string().optional(),
|
|
5968
|
+
userRateLimitTier: import_zod12.z.string().optional(),
|
|
5969
|
+
hasExtraUsageEnabled: import_zod12.z.boolean().optional(),
|
|
5970
|
+
subscriptionCreatedAt: import_zod12.z.string().optional(),
|
|
5971
|
+
accountCreatedAt: import_zod12.z.string().optional()
|
|
5972
5972
|
});
|
|
5973
|
-
UsageSnapshotSchema =
|
|
5973
|
+
UsageSnapshotSchema = import_zod12.z.strictObject({
|
|
5974
5974
|
schemaVersion: VersionSchema,
|
|
5975
|
-
identity:
|
|
5975
|
+
identity: import_zod12.z.string(),
|
|
5976
5976
|
updatedAt: InstantSchema,
|
|
5977
5977
|
/** The identity's account metadata as of `updatedAt`. */
|
|
5978
5978
|
account: AccountMetadataSchema.optional(),
|
|
5979
5979
|
/** Latest state per provider, keyed by provider name (`anthropic` for OAuth sessions). */
|
|
5980
|
-
providers:
|
|
5980
|
+
providers: import_zod12.z.record(import_zod12.z.string(), ProviderUsageStateSchema)
|
|
5981
5981
|
});
|
|
5982
5982
|
}
|
|
5983
5983
|
});
|
|
@@ -6412,19 +6412,19 @@ function formatCachedCredentialState(state) {
|
|
|
6412
6412
|
}
|
|
6413
6413
|
return state.status === "fresh" ? `${age}, expires in ${formatAge(state.expiresInMs)}` : `${age}, expired ${formatAge(-state.expiresInMs)} ago`;
|
|
6414
6414
|
}
|
|
6415
|
-
var
|
|
6415
|
+
var import_zod13, MS_PER_UNIT, CachedCredentialSchema, KEYCHAIN_CACHE_SERVICE, KEYCHAIN_ITEM_NOT_FOUND_STATUS;
|
|
6416
6416
|
var init_credentialCache = __esm({
|
|
6417
6417
|
"src/credentialCache.ts"() {
|
|
6418
6418
|
"use strict";
|
|
6419
|
-
|
|
6419
|
+
import_zod13 = require("zod");
|
|
6420
6420
|
init_schema();
|
|
6421
6421
|
init_preflight();
|
|
6422
6422
|
MS_PER_UNIT = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
|
|
6423
|
-
CachedCredentialSchema =
|
|
6424
|
-
token:
|
|
6425
|
-
fetchedAt:
|
|
6423
|
+
CachedCredentialSchema = import_zod13.z.strictObject({
|
|
6424
|
+
token: import_zod13.z.string().min(1),
|
|
6425
|
+
fetchedAt: import_zod13.z.number().int().nonnegative(),
|
|
6426
6426
|
source: CredentialSourceSchema,
|
|
6427
|
-
owner:
|
|
6427
|
+
owner: import_zod13.z.string().min(1).optional()
|
|
6428
6428
|
});
|
|
6429
6429
|
KEYCHAIN_CACHE_SERVICE = "agent-shim-credential-cache";
|
|
6430
6430
|
KEYCHAIN_ITEM_NOT_FOUND_STATUS = 44;
|
|
@@ -6511,7 +6511,7 @@ function describeCredential(credential) {
|
|
|
6511
6511
|
function cacheKeyOf(params) {
|
|
6512
6512
|
return params.cacheKey ?? params.subject;
|
|
6513
6513
|
}
|
|
6514
|
-
function
|
|
6514
|
+
function isRecord6(value) {
|
|
6515
6515
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6516
6516
|
}
|
|
6517
6517
|
function unpackKeyringToken(raw) {
|
|
@@ -6523,7 +6523,7 @@ function unpackKeyringToken(raw) {
|
|
|
6523
6523
|
const base64Str = trimmed.slice(GO_KEYRING_BASE64_PREFIX.length);
|
|
6524
6524
|
const decoded = Buffer.from(base64Str, "base64").toString("utf8");
|
|
6525
6525
|
const parsed = JSON.parse(decoded);
|
|
6526
|
-
if (
|
|
6526
|
+
if (isRecord6(parsed) && isRecord6(parsed.token)) {
|
|
6527
6527
|
const accessToken = parsed.token.access_token;
|
|
6528
6528
|
if (typeof accessToken === "string" && accessToken.trim() !== "") {
|
|
6529
6529
|
return accessToken.trim();
|
|
@@ -6691,7 +6691,7 @@ var init_blockingSpawn = __esm({
|
|
|
6691
6691
|
|
|
6692
6692
|
// src/usage/signIn.ts
|
|
6693
6693
|
function claudeCodeKeychainService(configDir) {
|
|
6694
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${(0,
|
|
6694
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${(0, import_node_crypto7.createHash)("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
6695
6695
|
}
|
|
6696
6696
|
function keychainHasItem(run, configDir) {
|
|
6697
6697
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -6724,11 +6724,11 @@ function identitySignIn(fs17, probe, identity) {
|
|
|
6724
6724
|
platform: probe.platform
|
|
6725
6725
|
});
|
|
6726
6726
|
}
|
|
6727
|
-
var
|
|
6727
|
+
var import_node_crypto7, import_node_path19, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS;
|
|
6728
6728
|
var init_signIn = __esm({
|
|
6729
6729
|
"src/usage/signIn.ts"() {
|
|
6730
6730
|
"use strict";
|
|
6731
|
-
|
|
6731
|
+
import_node_crypto7 = require("node:crypto");
|
|
6732
6732
|
import_node_path19 = __toESM(require("node:path"), 1);
|
|
6733
6733
|
CREDENTIALS_FILE = ".credentials.json";
|
|
6734
6734
|
KEYCHAIN_SERVICE_PREFIX = "Claude Code-credentials";
|
|
@@ -6863,7 +6863,7 @@ function serialisedFor(entry, owner) {
|
|
|
6863
6863
|
return JSON.stringify({ owner, ...withoutOwner(entry) });
|
|
6864
6864
|
}
|
|
6865
6865
|
function tempPathFor(target) {
|
|
6866
|
-
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0,
|
|
6866
|
+
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto8.randomUUID)()}`);
|
|
6867
6867
|
}
|
|
6868
6868
|
function processRuns(pid) {
|
|
6869
6869
|
try {
|
|
@@ -6982,11 +6982,11 @@ function createRealCredentialCache(root, keychain = { run: security, platform: p
|
|
|
6982
6982
|
function realCredentialCacheEnv(paths) {
|
|
6983
6983
|
return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
6984
6984
|
}
|
|
6985
|
-
var
|
|
6985
|
+
var import_node_crypto8, import_node_fs5, import_node_path20, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
|
|
6986
6986
|
var init_realCredentialCache = __esm({
|
|
6987
6987
|
"src/realCredentialCache.ts"() {
|
|
6988
6988
|
"use strict";
|
|
6989
|
-
|
|
6989
|
+
import_node_crypto8 = require("node:crypto");
|
|
6990
6990
|
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
6991
6991
|
import_node_path20 = __toESM(require("node:path"), 1);
|
|
6992
6992
|
init_blockingSpawn();
|
|
@@ -7143,7 +7143,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
7143
7143
|
fs17.removeRecursive(files.legacyStateFile);
|
|
7144
7144
|
}
|
|
7145
7145
|
function hashAllowlist(allowlist) {
|
|
7146
|
-
return (0,
|
|
7146
|
+
return (0, import_node_crypto9.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
|
|
7147
7147
|
}
|
|
7148
7148
|
function formatAllowlistFile(allowlist) {
|
|
7149
7149
|
return allowlist.map((entry) => `${entry}
|
|
@@ -7248,40 +7248,40 @@ function readStartLock(fs17, lockFile) {
|
|
|
7248
7248
|
return void 0;
|
|
7249
7249
|
}
|
|
7250
7250
|
}
|
|
7251
|
-
var
|
|
7251
|
+
var import_node_crypto9, import_node_path21, import_zod14, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema, HEADROOM_ALLOWLIST_FILE_FLAG, ALLOWLIST_LINE_BREAKS, ALLOWLIST_WHITESPACE, ALLOWLIST_FILE_SEPARATORS, ALLOWLIST_FILE_COMMENT, ALLOWLIST_ENTRY_WHITESPACE, ALLOWLIST_SURROUNDING_WHITESPACE, ALLOWLIST_SAFE_SCHEMES;
|
|
7252
7252
|
var init_state2 = __esm({
|
|
7253
7253
|
"src/headroom/state.ts"() {
|
|
7254
7254
|
"use strict";
|
|
7255
|
-
|
|
7255
|
+
import_node_crypto9 = require("node:crypto");
|
|
7256
7256
|
import_node_path21 = __toESM(require("node:path"), 1);
|
|
7257
|
-
|
|
7257
|
+
import_zod14 = require("zod");
|
|
7258
7258
|
init_schema();
|
|
7259
|
-
HeadroomStateSchema =
|
|
7259
|
+
HeadroomStateSchema = import_zod14.z.strictObject({
|
|
7260
7260
|
/** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
|
|
7261
|
-
supervisorPid:
|
|
7261
|
+
supervisorPid: import_zod14.z.number().int().positive().optional(),
|
|
7262
7262
|
/** The headroom proxy process itself, recorded as soon as it is spawned (before it is ready, which `socketPath` signals) so a successor can find a daemon whose supervisor died during its start. Absent while the supervisor is between restarts. */
|
|
7263
|
-
headroomPid:
|
|
7263
|
+
headroomPid: import_zod14.z.number().int().positive().optional(),
|
|
7264
7264
|
/**
|
|
7265
7265
|
* 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.
|
|
7266
7266
|
*/
|
|
7267
|
-
socketPath:
|
|
7267
|
+
socketPath: import_zod14.z.string().min(1).optional(),
|
|
7268
7268
|
/** The `headroom --version` output of the running install. */
|
|
7269
|
-
version:
|
|
7269
|
+
version: import_zod14.z.string().optional(),
|
|
7270
7270
|
/**
|
|
7271
7271
|
* Hash of the allowlist the running proxy serves. The supervisor records it in the same tick it writes that allowlist to `LayoutPaths.headroomAllowlistFile`, which the proxy re-reads on its next request, so a provider launch, whose requests come back through its front door's direct origin, waits until this names an allowlist holding that origin. A supervisor from an earlier release records here the hash of the allowlist its daemon was started with instead (see `earlierRelease.ts`).
|
|
7272
7272
|
*/
|
|
7273
|
-
allowlistHash:
|
|
7273
|
+
allowlistHash: import_zod14.z.string().optional(),
|
|
7274
7274
|
/** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
|
|
7275
|
-
settingsHash:
|
|
7275
|
+
settingsHash: import_zod14.z.string().optional(),
|
|
7276
7276
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
7277
|
-
installedSource:
|
|
7277
|
+
installedSource: import_zod14.z.string().optional(),
|
|
7278
7278
|
/** The install spec the supervisor is installing right now, present only while `uv tool install` runs, so a launcher that finds a live supervisor with no daemon yet keeps waiting for the install instead of counting it against its start bound. Cleared by the write that follows the install, whatever its outcome. */
|
|
7279
|
-
installing:
|
|
7279
|
+
installing: import_zod14.z.string().optional(),
|
|
7280
7280
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
7281
|
-
lastError:
|
|
7281
|
+
lastError: import_zod14.z.string().optional()
|
|
7282
7282
|
});
|
|
7283
|
-
HeadroomSessionSchema =
|
|
7284
|
-
HeadroomLockSchema =
|
|
7283
|
+
HeadroomSessionSchema = import_zod14.z.strictObject({ pid: import_zod14.z.number().int().positive(), startedAt: import_zod14.z.number(), supervisorPid: import_zod14.z.number().int().positive() });
|
|
7284
|
+
HeadroomLockSchema = import_zod14.z.strictObject({ pid: import_zod14.z.number().int().positive(), at: import_zod14.z.number() });
|
|
7285
7285
|
HEADROOM_ALLOWLIST_FILE_FLAG = "--allowed-base-urls-file";
|
|
7286
7286
|
ALLOWLIST_LINE_BREAKS = "\\n\\r\\u000b\\u000c\\u001c\\u001d\\u001e\\u0085\\u2028\\u2029";
|
|
7287
7287
|
ALLOWLIST_WHITESPACE = "\\t\\n\\u000b\\u000c\\r\\u001c-\\u001f \\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
@@ -7294,30 +7294,30 @@ var init_state2 = __esm({
|
|
|
7294
7294
|
});
|
|
7295
7295
|
|
|
7296
7296
|
// src/headroom/earlierRelease.ts
|
|
7297
|
-
function withoutOurSocket(
|
|
7297
|
+
function withoutOurSocket(commandLine2, socketPath) {
|
|
7298
7298
|
for (const argument of [`--uds ${socketPath}`, `--uds=${socketPath}`]) {
|
|
7299
7299
|
let from = 0;
|
|
7300
7300
|
for (; ; ) {
|
|
7301
|
-
const index =
|
|
7301
|
+
const index = commandLine2.indexOf(argument, from);
|
|
7302
7302
|
if (index === -1) {
|
|
7303
7303
|
break;
|
|
7304
7304
|
}
|
|
7305
7305
|
const end = index + argument.length;
|
|
7306
|
-
const startsArgument = index === 0 || /\s/.test(
|
|
7307
|
-
const endsArgument = end ===
|
|
7306
|
+
const startsArgument = index === 0 || /\s/.test(commandLine2.charAt(index - 1));
|
|
7307
|
+
const endsArgument = end === commandLine2.length || /\s/.test(commandLine2.charAt(end));
|
|
7308
7308
|
if (startsArgument && endsArgument) {
|
|
7309
|
-
return `${
|
|
7309
|
+
return `${commandLine2.slice(0, index)} ${commandLine2.slice(end)}`;
|
|
7310
7310
|
}
|
|
7311
7311
|
from = index + 1;
|
|
7312
7312
|
}
|
|
7313
7313
|
}
|
|
7314
7314
|
return void 0;
|
|
7315
7315
|
}
|
|
7316
|
-
function daemonIdentity(
|
|
7317
|
-
if (
|
|
7316
|
+
function daemonIdentity(commandLine2, socketPath) {
|
|
7317
|
+
if (commandLine2 === void 0) {
|
|
7318
7318
|
return "unreadable";
|
|
7319
7319
|
}
|
|
7320
|
-
const rest = withoutOurSocket(
|
|
7320
|
+
const rest = withoutOurSocket(commandLine2, socketPath);
|
|
7321
7321
|
const argumentsList = rest === void 0 ? [] : rest.trim().split(/\s+/);
|
|
7322
7322
|
if (rest === void 0 || !argumentsList.includes("proxy")) {
|
|
7323
7323
|
return "not-headroom";
|
|
@@ -7416,8 +7416,8 @@ function ensureHeadroom(params) {
|
|
|
7416
7416
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
7417
7417
|
return { socketPath: state.socketPath };
|
|
7418
7418
|
}
|
|
7419
|
-
const
|
|
7420
|
-
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7419
|
+
const commandLine2 = commandLineOf(state.headroomPid);
|
|
7420
|
+
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine: commandLine2, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7421
7421
|
if (earlierRelease !== void 0) {
|
|
7422
7422
|
if (earlierRelease.admitsServingDoor) {
|
|
7423
7423
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
@@ -7427,7 +7427,7 @@ function ensureHeadroom(params) {
|
|
|
7427
7427
|
`the running headroom daemon (pid ${String(state.headroomPid)}) was ${EARLIER_RELEASE_ALLOWLIST}, and its allowlist cannot be shown to admit the serving front door; launch with --no-headroom until then. Supervisor and daemon log: ${paths.headroomLogPath}`
|
|
7428
7428
|
);
|
|
7429
7429
|
}
|
|
7430
|
-
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(
|
|
7430
|
+
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine2, state.socketPath) };
|
|
7431
7431
|
}
|
|
7432
7432
|
if (state.lastError !== void 0) {
|
|
7433
7433
|
throw new HeadroomStartError(
|
|
@@ -7495,13 +7495,13 @@ function settingsEnv(settings) {
|
|
|
7495
7495
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
7496
7496
|
}
|
|
7497
7497
|
function hashSettings(settings) {
|
|
7498
|
-
return (0,
|
|
7498
|
+
return (0, import_node_crypto10.createHash)("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
7499
7499
|
}
|
|
7500
|
-
var
|
|
7500
|
+
var import_node_crypto10;
|
|
7501
7501
|
var init_settings = __esm({
|
|
7502
7502
|
"src/headroom/settings.ts"() {
|
|
7503
7503
|
"use strict";
|
|
7504
|
-
|
|
7504
|
+
import_node_crypto10 = require("node:crypto");
|
|
7505
7505
|
}
|
|
7506
7506
|
});
|
|
7507
7507
|
|
|
@@ -7701,14 +7701,14 @@ function pinnedGitCommit(spec) {
|
|
|
7701
7701
|
const ref = GIT_SPEC_RE.exec(spec)?.[1];
|
|
7702
7702
|
return ref !== void 0 && COMMIT_SHA_RE.test(ref) ? ref.toLowerCase() : void 0;
|
|
7703
7703
|
}
|
|
7704
|
-
var
|
|
7704
|
+
var import_zod15, GIT_SPEC_RE, COMMIT_SHA_RE, DirectUrlSchema;
|
|
7705
7705
|
var init_source = __esm({
|
|
7706
7706
|
"src/headroom/source.ts"() {
|
|
7707
7707
|
"use strict";
|
|
7708
|
-
|
|
7708
|
+
import_zod15 = require("zod");
|
|
7709
7709
|
GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
7710
7710
|
COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
|
|
7711
|
-
DirectUrlSchema =
|
|
7711
|
+
DirectUrlSchema = import_zod15.z.object({ vcs_info: import_zod15.z.object({ commit_id: import_zod15.z.string() }) });
|
|
7712
7712
|
}
|
|
7713
7713
|
});
|
|
7714
7714
|
|
|
@@ -8422,14 +8422,14 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
8422
8422
|
function realInstalledClaudeVersions() {
|
|
8423
8423
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
8424
8424
|
}
|
|
8425
|
-
var import_node_child_process2,
|
|
8425
|
+
var import_node_child_process2, import_node_crypto11, import_node_fs6, import_node_os2, import_node_path24, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS2, DIRECTORY_FLUSH_UNSUPPORTED_CODES, realFarmFs, INT32_BYTE_LENGTH, KEY_POLL_MS, CTRL_C_BYTE, realHoldPort, PS_TIMEOUT_MS, RUN_OUTPUT_LIMIT_MIB, BYTES_PER_MIB2, RUN_OUTPUT_LIMIT_BYTES, realRunPort, ASYNC_RUN_TIMEOUT_MS, realRunAsync, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
|
|
8426
8426
|
var init_realPorts = __esm({
|
|
8427
8427
|
"src/realPorts.ts"() {
|
|
8428
8428
|
"use strict";
|
|
8429
8429
|
init_blockingSpawn();
|
|
8430
8430
|
init_processRole();
|
|
8431
8431
|
import_node_child_process2 = require("node:child_process");
|
|
8432
|
-
|
|
8432
|
+
import_node_crypto11 = require("node:crypto");
|
|
8433
8433
|
import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
8434
8434
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
8435
8435
|
import_node_path24 = __toESM(require("node:path"), 1);
|
|
@@ -8580,7 +8580,7 @@ var init_realPorts = __esm({
|
|
|
8580
8580
|
},
|
|
8581
8581
|
hashFile(filePath) {
|
|
8582
8582
|
try {
|
|
8583
|
-
return (0,
|
|
8583
|
+
return (0, import_node_crypto11.createHash)("sha256").update(import_node_fs6.default.readFileSync(filePath)).digest("hex");
|
|
8584
8584
|
} catch (error) {
|
|
8585
8585
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
8586
8586
|
return void 0;
|
|
@@ -9041,24 +9041,24 @@ function planOf(account) {
|
|
|
9041
9041
|
}
|
|
9042
9042
|
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
9043
9043
|
}
|
|
9044
|
-
var
|
|
9044
|
+
var import_zod16, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
9045
9045
|
var init_plan2 = __esm({
|
|
9046
9046
|
"src/usage/plan.ts"() {
|
|
9047
9047
|
"use strict";
|
|
9048
|
-
|
|
9049
|
-
PlanClassSchema =
|
|
9050
|
-
|
|
9051
|
-
kind:
|
|
9048
|
+
import_zod16 = require("zod");
|
|
9049
|
+
PlanClassSchema = import_zod16.z.union([
|
|
9050
|
+
import_zod16.z.strictObject({
|
|
9051
|
+
kind: import_zod16.z.literal("subscription"),
|
|
9052
9052
|
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
9053
|
-
capacity:
|
|
9053
|
+
capacity: import_zod16.z.number().positive(),
|
|
9054
9054
|
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
9055
|
-
recognised:
|
|
9055
|
+
recognised: import_zod16.z.boolean(),
|
|
9056
9056
|
/** The tier string the classification rests on, when the account had one. */
|
|
9057
|
-
tier:
|
|
9057
|
+
tier: import_zod16.z.string().optional()
|
|
9058
9058
|
}),
|
|
9059
|
-
|
|
9060
|
-
kind:
|
|
9061
|
-
tier:
|
|
9059
|
+
import_zod16.z.strictObject({
|
|
9060
|
+
kind: import_zod16.z.literal("pay-per-use"),
|
|
9061
|
+
tier: import_zod16.z.string().optional()
|
|
9062
9062
|
})
|
|
9063
9063
|
]);
|
|
9064
9064
|
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
@@ -9068,21 +9068,21 @@ var init_plan2 = __esm({
|
|
|
9068
9068
|
});
|
|
9069
9069
|
|
|
9070
9070
|
// src/usage/scan.ts
|
|
9071
|
-
var
|
|
9071
|
+
var import_zod17, AnthropicUsageSchema, ErrorObjectSchema;
|
|
9072
9072
|
var init_scan = __esm({
|
|
9073
9073
|
"src/usage/scan.ts"() {
|
|
9074
9074
|
"use strict";
|
|
9075
|
-
|
|
9076
|
-
AnthropicUsageSchema =
|
|
9077
|
-
input_tokens:
|
|
9078
|
-
output_tokens:
|
|
9079
|
-
cache_creation_input_tokens:
|
|
9080
|
-
cache_read_input_tokens:
|
|
9075
|
+
import_zod17 = require("zod");
|
|
9076
|
+
AnthropicUsageSchema = import_zod17.z.looseObject({
|
|
9077
|
+
input_tokens: import_zod17.z.number().int().nonnegative().nullish(),
|
|
9078
|
+
output_tokens: import_zod17.z.number().int().nonnegative().nullish(),
|
|
9079
|
+
cache_creation_input_tokens: import_zod17.z.number().int().nonnegative().nullish(),
|
|
9080
|
+
cache_read_input_tokens: import_zod17.z.number().int().nonnegative().nullish()
|
|
9081
9081
|
});
|
|
9082
|
-
ErrorObjectSchema =
|
|
9083
|
-
type:
|
|
9084
|
-
code:
|
|
9085
|
-
message:
|
|
9082
|
+
ErrorObjectSchema = import_zod17.z.looseObject({
|
|
9083
|
+
type: import_zod17.z.string().optional(),
|
|
9084
|
+
code: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).optional(),
|
|
9085
|
+
message: import_zod17.z.string().optional()
|
|
9086
9086
|
});
|
|
9087
9087
|
}
|
|
9088
9088
|
});
|
|
@@ -9732,12 +9732,12 @@ function recordStickyPick(fs17, picksFile, directory, identity, nowMs) {
|
|
|
9732
9732
|
fs17.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
|
|
9733
9733
|
`);
|
|
9734
9734
|
}
|
|
9735
|
-
var import_node_path26,
|
|
9735
|
+
var import_node_path26, import_zod18, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
|
|
9736
9736
|
var init_poolPick = __esm({
|
|
9737
9737
|
"src/usage/poolPick.ts"() {
|
|
9738
9738
|
"use strict";
|
|
9739
9739
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
9740
|
-
|
|
9740
|
+
import_zod18 = require("zod");
|
|
9741
9741
|
init_cliError();
|
|
9742
9742
|
init_identity();
|
|
9743
9743
|
init_schema();
|
|
@@ -9754,17 +9754,17 @@ var init_poolPick = __esm({
|
|
|
9754
9754
|
}
|
|
9755
9755
|
};
|
|
9756
9756
|
SCHEMA_VERSION = 1;
|
|
9757
|
-
PickEntrySchema =
|
|
9758
|
-
PicksFileSchema =
|
|
9759
|
-
schemaVersion:
|
|
9760
|
-
picks:
|
|
9757
|
+
PickEntrySchema = import_zod18.z.strictObject({ identity: import_zod18.z.string().min(1), at: import_zod18.z.iso.datetime() });
|
|
9758
|
+
PicksFileSchema = import_zod18.z.strictObject({
|
|
9759
|
+
schemaVersion: import_zod18.z.literal(SCHEMA_VERSION),
|
|
9760
|
+
picks: import_zod18.z.record(import_zod18.z.string().min(1), PickEntrySchema)
|
|
9761
9761
|
});
|
|
9762
9762
|
}
|
|
9763
9763
|
});
|
|
9764
9764
|
|
|
9765
9765
|
// src/identityRenameJournal.ts
|
|
9766
9766
|
function renamePairFileName(from, to, suffix) {
|
|
9767
|
-
return `${(0,
|
|
9767
|
+
return `${(0, import_node_crypto12.createHash)("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
9768
9768
|
}
|
|
9769
9769
|
function readRenameJournal(fs17, file) {
|
|
9770
9770
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -9835,28 +9835,28 @@ function requireNameFreeOfUnfinishedRename(fs17, directory, name, action, sameNa
|
|
|
9835
9835
|
throw new NameHeldByUnfinishedRenameError(action, name, held, finishabilityOf(held, exists));
|
|
9836
9836
|
}
|
|
9837
9837
|
}
|
|
9838
|
-
var
|
|
9838
|
+
var import_node_crypto12, import_node_path27, import_zod19, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
|
|
9839
9839
|
var init_identityRenameJournal = __esm({
|
|
9840
9840
|
"src/identityRenameJournal.ts"() {
|
|
9841
9841
|
"use strict";
|
|
9842
|
-
|
|
9842
|
+
import_node_crypto12 = require("node:crypto");
|
|
9843
9843
|
import_node_path27 = __toESM(require("node:path"), 1);
|
|
9844
|
-
|
|
9844
|
+
import_zod19 = require("zod");
|
|
9845
9845
|
init_cliError();
|
|
9846
|
-
RenameJournalSchema =
|
|
9847
|
-
version:
|
|
9848
|
-
from:
|
|
9849
|
-
to:
|
|
9850
|
-
startedAt:
|
|
9846
|
+
RenameJournalSchema = import_zod19.z.strictObject({
|
|
9847
|
+
version: import_zod19.z.literal(1),
|
|
9848
|
+
from: import_zod19.z.string().min(1),
|
|
9849
|
+
to: import_zod19.z.string().min(1),
|
|
9850
|
+
startedAt: import_zod19.z.iso.datetime(),
|
|
9851
9851
|
/** The process that began the rename, for a person reading the file. Whether it is still running is told by the locks, not by this. */
|
|
9852
|
-
pid:
|
|
9853
|
-
steps:
|
|
9854
|
-
|
|
9855
|
-
description:
|
|
9852
|
+
pid: import_zod19.z.number().int().positive(),
|
|
9853
|
+
steps: import_zod19.z.array(
|
|
9854
|
+
import_zod19.z.strictObject({
|
|
9855
|
+
description: import_zod19.z.string().min(1),
|
|
9856
9856
|
/** Whether the step has been applied and marked so. */
|
|
9857
|
-
done:
|
|
9857
|
+
done: import_zod19.z.boolean(),
|
|
9858
9858
|
/** Whether the step was begun: written ahead of the step, before it runs, so a process that dies after the step took effect and before `done` was written still leaves a record that it may have. */
|
|
9859
|
-
started:
|
|
9859
|
+
started: import_zod19.z.boolean()
|
|
9860
9860
|
})
|
|
9861
9861
|
)
|
|
9862
9862
|
});
|
|
@@ -9961,13 +9961,13 @@ function requireNoInterruptedNameRename(paths, name, action, except) {
|
|
|
9961
9961
|
throw new InterruptedNameRenameError(action, describeInterruptedNameRename(paths, held));
|
|
9962
9962
|
}
|
|
9963
9963
|
}
|
|
9964
|
-
var import_node_fs7, import_node_path28,
|
|
9964
|
+
var import_node_fs7, import_node_path28, import_zod20, NameRenameRecordSchema, RECORD_SUFFIX, InterruptedNameRenameError;
|
|
9965
9965
|
var init_identityNameRenameRecord = __esm({
|
|
9966
9966
|
"src/identityNameRenameRecord.ts"() {
|
|
9967
9967
|
"use strict";
|
|
9968
9968
|
import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
9969
9969
|
import_node_path28 = __toESM(require("node:path"), 1);
|
|
9970
|
-
|
|
9970
|
+
import_zod20 = require("zod");
|
|
9971
9971
|
init_cliError();
|
|
9972
9972
|
init_configProfilesStore();
|
|
9973
9973
|
init_directoryRulesStore();
|
|
@@ -9977,12 +9977,12 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9977
9977
|
init_poolPick();
|
|
9978
9978
|
init_identityRecords();
|
|
9979
9979
|
init_identityRenameJournal();
|
|
9980
|
-
NameRenameRecordSchema =
|
|
9981
|
-
version:
|
|
9982
|
-
id:
|
|
9983
|
-
from:
|
|
9984
|
-
to:
|
|
9985
|
-
startedAt:
|
|
9980
|
+
NameRenameRecordSchema = import_zod20.z.strictObject({
|
|
9981
|
+
version: import_zod20.z.literal(1),
|
|
9982
|
+
id: import_zod20.z.string().min(1),
|
|
9983
|
+
from: import_zod20.z.string().min(1),
|
|
9984
|
+
to: import_zod20.z.string().min(1),
|
|
9985
|
+
startedAt: import_zod20.z.iso.datetime()
|
|
9986
9986
|
});
|
|
9987
9987
|
RECORD_SUFFIX = ".json";
|
|
9988
9988
|
InterruptedNameRenameError = class extends CliError {
|
|
@@ -9996,7 +9996,7 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9996
9996
|
|
|
9997
9997
|
// src/launcher/launchRecords.ts
|
|
9998
9998
|
function recordFile(directory, pid) {
|
|
9999
|
-
return import_node_path29.default.join(directory, `${String(pid)}.${(0,
|
|
9999
|
+
return import_node_path29.default.join(directory, `${String(pid)}.${(0, import_node_crypto13.randomUUID)()}${RECORD_SUFFIX2}`);
|
|
10000
10000
|
}
|
|
10001
10001
|
function readRecord(fs17, directory, name) {
|
|
10002
10002
|
if (!name.endsWith(RECORD_SUFFIX2)) {
|
|
@@ -10037,18 +10037,18 @@ function liveLaunchesOn(fs17, directory, identity, isRunning) {
|
|
|
10037
10037
|
return record?.identity === identity && isRunning(record.pid) ? [record.pid] : [];
|
|
10038
10038
|
}).sort((left, right) => left - right);
|
|
10039
10039
|
}
|
|
10040
|
-
var import_node_path29,
|
|
10040
|
+
var import_node_path29, import_node_crypto13, import_zod21, LaunchRecordSchema, RECORD_SUFFIX2;
|
|
10041
10041
|
var init_launchRecords = __esm({
|
|
10042
10042
|
"src/launcher/launchRecords.ts"() {
|
|
10043
10043
|
"use strict";
|
|
10044
10044
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
LaunchRecordSchema =
|
|
10045
|
+
import_node_crypto13 = require("node:crypto");
|
|
10046
|
+
import_zod21 = require("zod");
|
|
10047
|
+
LaunchRecordSchema = import_zod21.z.strictObject({
|
|
10048
10048
|
/** The launcher's process id, which is what tells a launch in progress from a record a crashed launcher left behind. */
|
|
10049
|
-
pid:
|
|
10050
|
-
identity:
|
|
10051
|
-
startedAt:
|
|
10049
|
+
pid: import_zod21.z.number().int().positive(),
|
|
10050
|
+
identity: import_zod21.z.string().min(1),
|
|
10051
|
+
startedAt: import_zod21.z.iso.datetime()
|
|
10052
10052
|
});
|
|
10053
10053
|
RECORD_SUFFIX2 = ".json";
|
|
10054
10054
|
}
|
|
@@ -10519,7 +10519,7 @@ var init_package = __esm({
|
|
|
10519
10519
|
"package.json"() {
|
|
10520
10520
|
package_default = {
|
|
10521
10521
|
name: "claude-use",
|
|
10522
|
-
version: "
|
|
10522
|
+
version: "12.0.0",
|
|
10523
10523
|
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.",
|
|
10524
10524
|
license: "MIT",
|
|
10525
10525
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10898,15 +10898,15 @@ function aliasFindings(aliases, providerNames) {
|
|
|
10898
10898
|
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
10899
10899
|
});
|
|
10900
10900
|
}
|
|
10901
|
-
var
|
|
10901
|
+
var import_zod25, ProviderAliasesSchema;
|
|
10902
10902
|
var init_providerAliases = __esm({
|
|
10903
10903
|
"src/providerAliases.ts"() {
|
|
10904
10904
|
"use strict";
|
|
10905
|
-
|
|
10905
|
+
import_zod25 = require("zod");
|
|
10906
10906
|
init_cliError();
|
|
10907
10907
|
init_load();
|
|
10908
10908
|
init_store();
|
|
10909
|
-
ProviderAliasesSchema =
|
|
10909
|
+
ProviderAliasesSchema = import_zod25.z.record(import_zod25.z.string().min(1), import_zod25.z.string().min(1));
|
|
10910
10910
|
}
|
|
10911
10911
|
});
|
|
10912
10912
|
|
|
@@ -11130,14 +11130,14 @@ function requireProviderExists(paths, name) {
|
|
|
11130
11130
|
throw new ProviderNotFoundError(name);
|
|
11131
11131
|
}
|
|
11132
11132
|
}
|
|
11133
|
-
function
|
|
11133
|
+
function isRecord9(value) {
|
|
11134
11134
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11135
11135
|
}
|
|
11136
11136
|
function legacyProviderConversion(raw) {
|
|
11137
|
-
if (!
|
|
11137
|
+
if (!isRecord9(raw) || "credential" in raw) {
|
|
11138
11138
|
return void 0;
|
|
11139
11139
|
}
|
|
11140
|
-
const env =
|
|
11140
|
+
const env = isRecord9(raw.env) ? raw.env : void 0;
|
|
11141
11141
|
const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
|
|
11142
11142
|
const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
|
|
11143
11143
|
if (fields.length === 0) {
|
|
@@ -11624,7 +11624,7 @@ function listKey(list) {
|
|
|
11624
11624
|
return `${list},appended`;
|
|
11625
11625
|
}
|
|
11626
11626
|
function digest2(value) {
|
|
11627
|
-
return (0,
|
|
11627
|
+
return (0, import_node_crypto14.createHash)("sha256").update(value).digest("hex");
|
|
11628
11628
|
}
|
|
11629
11629
|
function recordedDigests(env) {
|
|
11630
11630
|
const raw = env[INJECTED_ENV];
|
|
@@ -11704,17 +11704,17 @@ function withoutInjected(env) {
|
|
|
11704
11704
|
});
|
|
11705
11705
|
return Object.fromEntries(entries);
|
|
11706
11706
|
}
|
|
11707
|
-
var
|
|
11707
|
+
var import_node_crypto14, import_zod26, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
11708
11708
|
var init_injected = __esm({
|
|
11709
11709
|
"src/launcher/injected.ts"() {
|
|
11710
11710
|
"use strict";
|
|
11711
|
-
|
|
11712
|
-
|
|
11711
|
+
import_node_crypto14 = require("node:crypto");
|
|
11712
|
+
import_zod26 = require("zod");
|
|
11713
11713
|
init_headers();
|
|
11714
11714
|
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
11715
11715
|
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
11716
11716
|
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
11717
|
-
InjectedSchema =
|
|
11717
|
+
InjectedSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.string());
|
|
11718
11718
|
}
|
|
11719
11719
|
});
|
|
11720
11720
|
|
|
@@ -11889,46 +11889,46 @@ function findPathShadow(params) {
|
|
|
11889
11889
|
}
|
|
11890
11890
|
return params.pathDirs.some((dir) => import_node_path38.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
11891
11891
|
}
|
|
11892
|
-
var import_node_fs11, import_node_path38,
|
|
11892
|
+
var import_node_fs11, import_node_path38, import_zod31, ClaudeShimStateSchema, nodeLinkFs;
|
|
11893
11893
|
var init_claudeShim = __esm({
|
|
11894
11894
|
"src/claudeShim.ts"() {
|
|
11895
11895
|
"use strict";
|
|
11896
11896
|
import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
11897
11897
|
import_node_path38 = __toESM(require("node:path"), 1);
|
|
11898
|
-
|
|
11898
|
+
import_zod31 = require("zod");
|
|
11899
11899
|
init_commandDeps();
|
|
11900
11900
|
init_store();
|
|
11901
11901
|
init_realPorts();
|
|
11902
11902
|
init_cliError();
|
|
11903
|
-
ClaudeShimStateSchema =
|
|
11904
|
-
targetPath:
|
|
11905
|
-
method:
|
|
11906
|
-
installedAtMs:
|
|
11903
|
+
ClaudeShimStateSchema = import_zod31.z.strictObject({
|
|
11904
|
+
targetPath: import_zod31.z.string().min(1),
|
|
11905
|
+
method: import_zod31.z.enum(["hardlink", "copy"]),
|
|
11906
|
+
installedAtMs: import_zod31.z.number()
|
|
11907
11907
|
});
|
|
11908
11908
|
nodeLinkFs = { link: import_node_fs11.default.linkSync, copyFile: import_node_fs11.default.copyFileSync, chmod: import_node_fs11.default.chmodSync };
|
|
11909
11909
|
}
|
|
11910
11910
|
});
|
|
11911
11911
|
|
|
11912
11912
|
// src/codex/auth.ts
|
|
11913
|
-
var
|
|
11913
|
+
var import_zod32, AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
11914
11914
|
var init_auth = __esm({
|
|
11915
11915
|
"src/codex/auth.ts"() {
|
|
11916
11916
|
"use strict";
|
|
11917
|
-
|
|
11918
|
-
AuthFileSchema =
|
|
11919
|
-
tokens:
|
|
11920
|
-
access_token:
|
|
11921
|
-
refresh_token:
|
|
11922
|
-
id_token:
|
|
11923
|
-
account_id:
|
|
11917
|
+
import_zod32 = require("zod");
|
|
11918
|
+
AuthFileSchema = import_zod32.z.looseObject({
|
|
11919
|
+
tokens: import_zod32.z.looseObject({
|
|
11920
|
+
access_token: import_zod32.z.string().optional(),
|
|
11921
|
+
refresh_token: import_zod32.z.string().optional(),
|
|
11922
|
+
id_token: import_zod32.z.string().optional(),
|
|
11923
|
+
account_id: import_zod32.z.string().optional()
|
|
11924
11924
|
}).nullish(),
|
|
11925
|
-
last_refresh:
|
|
11925
|
+
last_refresh: import_zod32.z.string().optional()
|
|
11926
11926
|
});
|
|
11927
|
-
TokenGrantSchema =
|
|
11928
|
-
access_token:
|
|
11929
|
-
refresh_token:
|
|
11930
|
-
id_token:
|
|
11931
|
-
account_id:
|
|
11927
|
+
TokenGrantSchema = import_zod32.z.looseObject({
|
|
11928
|
+
access_token: import_zod32.z.string().min(1).optional(),
|
|
11929
|
+
refresh_token: import_zod32.z.string().min(1).optional(),
|
|
11930
|
+
id_token: import_zod32.z.string().min(1).optional(),
|
|
11931
|
+
account_id: import_zod32.z.string().min(1).optional()
|
|
11932
11932
|
});
|
|
11933
11933
|
CodexAuthError = class extends Error {
|
|
11934
11934
|
constructor(message) {
|
|
@@ -11940,31 +11940,31 @@ var init_auth = __esm({
|
|
|
11940
11940
|
});
|
|
11941
11941
|
|
|
11942
11942
|
// src/codex/siwc.ts
|
|
11943
|
-
var
|
|
11943
|
+
var import_zod33, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
11944
11944
|
var init_siwc = __esm({
|
|
11945
11945
|
"src/codex/siwc.ts"() {
|
|
11946
11946
|
"use strict";
|
|
11947
|
-
|
|
11947
|
+
import_zod33 = require("zod");
|
|
11948
11948
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
11949
11949
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
11950
11950
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
11951
|
-
TokenResponseSchema =
|
|
11952
|
-
access_token:
|
|
11953
|
-
refresh_token:
|
|
11954
|
-
id_token:
|
|
11955
|
-
expires_in:
|
|
11956
|
-
scope:
|
|
11951
|
+
TokenResponseSchema = import_zod33.z.looseObject({
|
|
11952
|
+
access_token: import_zod33.z.string().min(1),
|
|
11953
|
+
refresh_token: import_zod33.z.string().min(1).optional(),
|
|
11954
|
+
id_token: import_zod33.z.string().min(1).optional(),
|
|
11955
|
+
expires_in: import_zod33.z.number().positive(),
|
|
11956
|
+
scope: import_zod33.z.string().optional()
|
|
11957
11957
|
});
|
|
11958
|
-
JwtHeaderSchema =
|
|
11959
|
-
IdTokenClaimsSchema =
|
|
11960
|
-
iss:
|
|
11961
|
-
sub:
|
|
11962
|
-
aud:
|
|
11963
|
-
exp:
|
|
11964
|
-
nonce:
|
|
11965
|
-
email:
|
|
11958
|
+
JwtHeaderSchema = import_zod33.z.looseObject({ alg: import_zod33.z.string(), kid: import_zod33.z.string().optional() });
|
|
11959
|
+
IdTokenClaimsSchema = import_zod33.z.looseObject({
|
|
11960
|
+
iss: import_zod33.z.string(),
|
|
11961
|
+
sub: import_zod33.z.string().min(1),
|
|
11962
|
+
aud: import_zod33.z.union([import_zod33.z.string(), import_zod33.z.array(import_zod33.z.string())]),
|
|
11963
|
+
exp: import_zod33.z.number(),
|
|
11964
|
+
nonce: import_zod33.z.string().optional(),
|
|
11965
|
+
email: import_zod33.z.string().optional()
|
|
11966
11966
|
});
|
|
11967
|
-
JwksSchema =
|
|
11967
|
+
JwksSchema = import_zod33.z.object({ keys: import_zod33.z.array(import_zod33.z.looseObject({ kid: import_zod33.z.string().optional(), kty: import_zod33.z.string() })) });
|
|
11968
11968
|
}
|
|
11969
11969
|
});
|
|
11970
11970
|
|
|
@@ -11982,25 +11982,25 @@ function parseSiwcFile(raw, filePath) {
|
|
|
11982
11982
|
}
|
|
11983
11983
|
return parsed.data;
|
|
11984
11984
|
}
|
|
11985
|
-
var
|
|
11985
|
+
var import_zod34, SiwcGrantSchema, SiwcFileSchema;
|
|
11986
11986
|
var init_siwcStore = __esm({
|
|
11987
11987
|
"src/codex/siwcStore.ts"() {
|
|
11988
11988
|
"use strict";
|
|
11989
|
-
|
|
11989
|
+
import_zod34 = require("zod");
|
|
11990
11990
|
init_auth();
|
|
11991
11991
|
init_siwc();
|
|
11992
|
-
SiwcGrantSchema =
|
|
11993
|
-
clientId:
|
|
11994
|
-
sub:
|
|
11995
|
-
email:
|
|
11996
|
-
idToken:
|
|
11997
|
-
accessToken:
|
|
11998
|
-
refreshToken:
|
|
11999
|
-
scopes:
|
|
11992
|
+
SiwcGrantSchema = import_zod34.z.strictObject({
|
|
11993
|
+
clientId: import_zod34.z.string().min(1),
|
|
11994
|
+
sub: import_zod34.z.string().min(1),
|
|
11995
|
+
email: import_zod34.z.string().optional(),
|
|
11996
|
+
idToken: import_zod34.z.string().min(1),
|
|
11997
|
+
accessToken: import_zod34.z.string().min(1),
|
|
11998
|
+
refreshToken: import_zod34.z.string().min(1),
|
|
11999
|
+
scopes: import_zod34.z.array(import_zod34.z.string()).readonly(),
|
|
12000
12000
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
12001
|
-
expiresAt:
|
|
12001
|
+
expiresAt: import_zod34.z.number()
|
|
12002
12002
|
});
|
|
12003
|
-
SiwcFileSchema =
|
|
12003
|
+
SiwcFileSchema = import_zod34.z.strictObject({ registeredClientId: import_zod34.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
12004
12004
|
}
|
|
12005
12005
|
});
|
|
12006
12006
|
|
|
@@ -12068,7 +12068,7 @@ function parseCatalogueBinding(raw) {
|
|
|
12068
12068
|
}
|
|
12069
12069
|
}
|
|
12070
12070
|
function catalogueCredentialFingerprint(cli, token, accountId) {
|
|
12071
|
-
return (0,
|
|
12071
|
+
return (0, import_node_crypto15.createHash)("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
|
|
12072
12072
|
}
|
|
12073
12073
|
function cliCatalogueFingerprint(raw) {
|
|
12074
12074
|
if (raw === void 0) return void 0;
|
|
@@ -12093,15 +12093,15 @@ function savedCatalogueFingerprint(provider, paths, env, home, read) {
|
|
|
12093
12093
|
const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path41.default.join(home, ".codex") : configuredHome;
|
|
12094
12094
|
return cliCatalogueFingerprint(read(import_node_path41.default.join(codexHome, "auth.json")));
|
|
12095
12095
|
}
|
|
12096
|
-
var
|
|
12096
|
+
var import_node_crypto15, import_node_path41, import_zod35, CatalogueBindingSchema;
|
|
12097
12097
|
var init_catalogueCredential = __esm({
|
|
12098
12098
|
"src/codex/catalogueCredential.ts"() {
|
|
12099
12099
|
"use strict";
|
|
12100
|
-
|
|
12100
|
+
import_node_crypto15 = require("node:crypto");
|
|
12101
12101
|
import_node_path41 = __toESM(require("node:path"), 1);
|
|
12102
|
-
|
|
12102
|
+
import_zod35 = require("zod");
|
|
12103
12103
|
init_siwcStore();
|
|
12104
|
-
CatalogueBindingSchema =
|
|
12104
|
+
CatalogueBindingSchema = import_zod35.z.strictObject({ fingerprint: import_zod35.z.string().min(1), source: import_zod35.z.string().min(1), revision: import_zod35.z.string().min(1) });
|
|
12105
12105
|
}
|
|
12106
12106
|
});
|
|
12107
12107
|
|
|
@@ -12152,64 +12152,64 @@ var init_signatures = __esm({
|
|
|
12152
12152
|
});
|
|
12153
12153
|
|
|
12154
12154
|
// src/codex/anthropic.ts
|
|
12155
|
-
var
|
|
12155
|
+
var import_zod36, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
12156
12156
|
var init_anthropic = __esm({
|
|
12157
12157
|
"src/codex/anthropic.ts"() {
|
|
12158
12158
|
"use strict";
|
|
12159
|
-
|
|
12160
|
-
TextBlockSchema =
|
|
12161
|
-
Base64ImageSourceSchema =
|
|
12162
|
-
UrlImageSourceSchema =
|
|
12163
|
-
ImageBlockSchema =
|
|
12164
|
-
type:
|
|
12165
|
-
source:
|
|
12159
|
+
import_zod36 = require("zod");
|
|
12160
|
+
TextBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("text"), text: import_zod36.z.string() });
|
|
12161
|
+
Base64ImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("base64"), media_type: import_zod36.z.string().min(1), data: import_zod36.z.string() });
|
|
12162
|
+
UrlImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("url"), url: import_zod36.z.string().min(1) });
|
|
12163
|
+
ImageBlockSchema = import_zod36.z.looseObject({
|
|
12164
|
+
type: import_zod36.z.literal("image"),
|
|
12165
|
+
source: import_zod36.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
12166
12166
|
});
|
|
12167
|
-
ToolUseBlockSchema =
|
|
12168
|
-
type:
|
|
12169
|
-
id:
|
|
12170
|
-
name:
|
|
12171
|
-
input:
|
|
12167
|
+
ToolUseBlockSchema = import_zod36.z.looseObject({
|
|
12168
|
+
type: import_zod36.z.literal("tool_use"),
|
|
12169
|
+
id: import_zod36.z.string().min(1),
|
|
12170
|
+
name: import_zod36.z.string().min(1),
|
|
12171
|
+
input: import_zod36.z.unknown()
|
|
12172
12172
|
});
|
|
12173
|
-
ToolResultContentBlockSchema =
|
|
12174
|
-
ToolResultBlockSchema =
|
|
12175
|
-
type:
|
|
12176
|
-
tool_use_id:
|
|
12177
|
-
content:
|
|
12173
|
+
ToolResultContentBlockSchema = import_zod36.z.union([TextBlockSchema, import_zod36.z.looseObject({ type: import_zod36.z.string() })]);
|
|
12174
|
+
ToolResultBlockSchema = import_zod36.z.looseObject({
|
|
12175
|
+
type: import_zod36.z.literal("tool_result"),
|
|
12176
|
+
tool_use_id: import_zod36.z.string().min(1),
|
|
12177
|
+
content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ToolResultContentBlockSchema)]).optional()
|
|
12178
12178
|
});
|
|
12179
|
-
OtherBlockSchema =
|
|
12180
|
-
ContentBlockSchema =
|
|
12181
|
-
MessageSchema =
|
|
12182
|
-
role:
|
|
12183
|
-
content:
|
|
12179
|
+
OtherBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.string() });
|
|
12180
|
+
ContentBlockSchema = import_zod36.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
12181
|
+
MessageSchema = import_zod36.z.looseObject({
|
|
12182
|
+
role: import_zod36.z.enum(["user", "assistant", "system"]),
|
|
12183
|
+
content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ContentBlockSchema)])
|
|
12184
12184
|
});
|
|
12185
|
-
ToolSchema =
|
|
12186
|
-
name:
|
|
12187
|
-
description:
|
|
12188
|
-
input_schema:
|
|
12189
|
-
allowed_domains:
|
|
12190
|
-
blocked_domains:
|
|
12185
|
+
ToolSchema = import_zod36.z.looseObject({
|
|
12186
|
+
name: import_zod36.z.string().min(1),
|
|
12187
|
+
description: import_zod36.z.string().optional(),
|
|
12188
|
+
input_schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()).optional(),
|
|
12189
|
+
allowed_domains: import_zod36.z.array(import_zod36.z.string()).optional(),
|
|
12190
|
+
blocked_domains: import_zod36.z.array(import_zod36.z.string()).optional()
|
|
12191
12191
|
});
|
|
12192
|
-
ToolChoiceSchema =
|
|
12193
|
-
|
|
12194
|
-
|
|
12192
|
+
ToolChoiceSchema = import_zod36.z.union([
|
|
12193
|
+
import_zod36.z.looseObject({ type: import_zod36.z.enum(["auto", "none", "any"]) }),
|
|
12194
|
+
import_zod36.z.looseObject({ type: import_zod36.z.literal("tool"), name: import_zod36.z.string().min(1) })
|
|
12195
12195
|
]);
|
|
12196
|
-
SystemSchema =
|
|
12197
|
-
MessagesRequestSchema =
|
|
12198
|
-
model:
|
|
12196
|
+
SystemSchema = import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(import_zod36.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
12197
|
+
MessagesRequestSchema = import_zod36.z.looseObject({
|
|
12198
|
+
model: import_zod36.z.string().optional(),
|
|
12199
12199
|
system: SystemSchema.optional(),
|
|
12200
|
-
messages:
|
|
12201
|
-
tools:
|
|
12200
|
+
messages: import_zod36.z.array(MessageSchema),
|
|
12201
|
+
tools: import_zod36.z.array(ToolSchema).optional(),
|
|
12202
12202
|
tool_choice: ToolChoiceSchema.optional(),
|
|
12203
|
-
stream:
|
|
12203
|
+
stream: import_zod36.z.boolean().optional(),
|
|
12204
12204
|
/** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
|
|
12205
|
-
metadata:
|
|
12205
|
+
metadata: import_zod36.z.looseObject({ user_id: import_zod36.z.string().optional() }).optional(),
|
|
12206
12206
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
12207
|
-
output_config:
|
|
12207
|
+
output_config: import_zod36.z.looseObject({ effort: import_zod36.z.string().optional(), format: import_zod36.z.object({ type: import_zod36.z.literal("json_schema"), schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()) }).optional() }).optional()
|
|
12208
12208
|
});
|
|
12209
|
-
CountTokensRequestSchema =
|
|
12210
|
-
system:
|
|
12211
|
-
messages:
|
|
12212
|
-
tools:
|
|
12209
|
+
CountTokensRequestSchema = import_zod36.z.looseObject({
|
|
12210
|
+
system: import_zod36.z.unknown().optional(),
|
|
12211
|
+
messages: import_zod36.z.unknown().optional(),
|
|
12212
|
+
tools: import_zod36.z.unknown().optional()
|
|
12213
12213
|
});
|
|
12214
12214
|
}
|
|
12215
12215
|
});
|
|
@@ -12818,7 +12818,7 @@ function ensureFrontDoor(params) {
|
|
|
12818
12818
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
12819
12819
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
12820
12820
|
if (supervisorPid === params.launcherPid && params.replace === void 0 && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
12821
|
-
const token = (0,
|
|
12821
|
+
const token = (0, import_node_crypto16.randomUUID)();
|
|
12822
12822
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
12823
12823
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
12824
12824
|
}
|
|
@@ -12839,7 +12839,7 @@ function ensureFrontDoor(params) {
|
|
|
12839
12839
|
continue;
|
|
12840
12840
|
}
|
|
12841
12841
|
if (verdict.ok) {
|
|
12842
|
-
const token = (0,
|
|
12842
|
+
const token = (0, import_node_crypto16.randomUUID)();
|
|
12843
12843
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
12844
12844
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
12845
12845
|
}
|
|
@@ -12892,11 +12892,11 @@ function ensureFrontDoor(params) {
|
|
|
12892
12892
|
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
12893
12893
|
}
|
|
12894
12894
|
}
|
|
12895
|
-
var
|
|
12895
|
+
var import_node_crypto16, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
|
|
12896
12896
|
var init_ensure2 = __esm({
|
|
12897
12897
|
"src/frontdoor/ensure.ts"() {
|
|
12898
12898
|
"use strict";
|
|
12899
|
-
|
|
12899
|
+
import_node_crypto16 = require("node:crypto");
|
|
12900
12900
|
init_cliError();
|
|
12901
12901
|
init_state2();
|
|
12902
12902
|
init_replacement();
|
|
@@ -13565,7 +13565,7 @@ function withLauncherSettings(passthrough, settings) {
|
|
|
13565
13565
|
}
|
|
13566
13566
|
return [...kept, "--settings", settings, ...tail];
|
|
13567
13567
|
}
|
|
13568
|
-
function
|
|
13568
|
+
function isRecord17(value) {
|
|
13569
13569
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13570
13570
|
}
|
|
13571
13571
|
function mergeSettings(parts) {
|
|
@@ -13576,7 +13576,7 @@ function mergeSettings(parts) {
|
|
|
13576
13576
|
continue;
|
|
13577
13577
|
}
|
|
13578
13578
|
const parsed = JSON.parse(part);
|
|
13579
|
-
if (!
|
|
13579
|
+
if (!isRecord17(parsed)) {
|
|
13580
13580
|
throw new Error("a launch's settings part is not a JSON object");
|
|
13581
13581
|
}
|
|
13582
13582
|
for (const [key, value] of Object.entries(parsed)) {
|
|
@@ -14526,7 +14526,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
14526
14526
|
log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
|
|
14527
14527
|
proc.exit(1);
|
|
14528
14528
|
}
|
|
14529
|
-
const sessionId = params.supervised?.sessionId ?? (0,
|
|
14529
|
+
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto17.randomUUID)();
|
|
14530
14530
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
14531
14531
|
const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
14532
14532
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -14634,11 +14634,11 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
14634
14634
|
function runLauncher(params) {
|
|
14635
14635
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
14636
14636
|
}
|
|
14637
|
-
var
|
|
14637
|
+
var import_node_crypto17, import_node_os8, import_node_util2, import_node_path51;
|
|
14638
14638
|
var init_launcher = __esm({
|
|
14639
14639
|
"src/launcher.ts"() {
|
|
14640
14640
|
"use strict";
|
|
14641
|
-
|
|
14641
|
+
import_node_crypto17 = require("node:crypto");
|
|
14642
14642
|
import_node_os8 = __toESM(require("node:os"), 1);
|
|
14643
14643
|
init_catalogueCredential();
|
|
14644
14644
|
import_node_util2 = require("node:util");
|
|
@@ -14770,18 +14770,18 @@ function resolveTrustBundle(params) {
|
|
|
14770
14770
|
}
|
|
14771
14771
|
const combined = `${inheritedPem.trimEnd()}
|
|
14772
14772
|
${caPem}`;
|
|
14773
|
-
const bundle = import_node_path53.default.join(bundlesDir, `${(0,
|
|
14773
|
+
const bundle = import_node_path53.default.join(bundlesDir, `${(0, import_node_crypto18.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
14774
14774
|
if (!fs17.exists(bundle)) {
|
|
14775
14775
|
fs17.mkdirp(bundlesDir);
|
|
14776
14776
|
fs17.writeFileAtomic(bundle, combined);
|
|
14777
14777
|
}
|
|
14778
14778
|
return { path: bundle };
|
|
14779
14779
|
}
|
|
14780
|
-
var
|
|
14780
|
+
var import_node_crypto18, import_node_path53, BUNDLE_NAME_HEX_DIGITS;
|
|
14781
14781
|
var init_trust = __esm({
|
|
14782
14782
|
"src/frontdoor/trust.ts"() {
|
|
14783
14783
|
"use strict";
|
|
14784
|
-
|
|
14784
|
+
import_node_crypto18 = require("node:crypto");
|
|
14785
14785
|
import_node_path53 = __toESM(require("node:path"), 1);
|
|
14786
14786
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
14787
14787
|
}
|
|
@@ -14941,7 +14941,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
14941
14941
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
14942
14942
|
}).input,
|
|
14943
14943
|
now: () => Date.now(),
|
|
14944
|
-
uniqueSuffix: `${String(process.pid)}.${(0,
|
|
14944
|
+
uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto19.randomUUID)()}`,
|
|
14945
14945
|
// Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
|
|
14946
14946
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
14947
14947
|
},
|
|
@@ -15029,13 +15029,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
15029
15029
|
};
|
|
15030
15030
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
15031
15031
|
}
|
|
15032
|
-
var import_node_os10, import_node_path54,
|
|
15032
|
+
var import_node_os10, import_node_path54, import_node_crypto19, LaunchRefusedError;
|
|
15033
15033
|
var init_launchWiring = __esm({
|
|
15034
15034
|
"src/launchWiring.ts"() {
|
|
15035
15035
|
"use strict";
|
|
15036
15036
|
import_node_os10 = __toESM(require("node:os"), 1);
|
|
15037
15037
|
import_node_path54 = __toESM(require("node:path"), 1);
|
|
15038
|
-
|
|
15038
|
+
import_node_crypto19 = require("node:crypto");
|
|
15039
15039
|
init_cliError();
|
|
15040
15040
|
init_claudeShim();
|
|
15041
15041
|
init_classify();
|
|
@@ -15260,11 +15260,11 @@ var init_identityClaude = __esm({
|
|
|
15260
15260
|
});
|
|
15261
15261
|
|
|
15262
15262
|
// src/usage/providerQuota.ts
|
|
15263
|
-
var
|
|
15263
|
+
var import_zod45, MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, 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_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
15264
15264
|
var init_providerQuota = __esm({
|
|
15265
15265
|
"src/usage/providerQuota.ts"() {
|
|
15266
15266
|
"use strict";
|
|
15267
|
-
|
|
15267
|
+
import_zod45 = require("zod");
|
|
15268
15268
|
init_cloudUpstream();
|
|
15269
15269
|
init_schema2();
|
|
15270
15270
|
MS_PER_SECOND9 = 1e3;
|
|
@@ -15279,35 +15279,35 @@ var init_providerQuota = __esm({
|
|
|
15279
15279
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
15280
15280
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
15281
15281
|
]);
|
|
15282
|
-
ZaiLimitSchema =
|
|
15283
|
-
type:
|
|
15284
|
-
unit:
|
|
15285
|
-
number:
|
|
15286
|
-
percentage:
|
|
15287
|
-
nextResetTime:
|
|
15288
|
-
usage:
|
|
15289
|
-
currentValue:
|
|
15290
|
-
remaining:
|
|
15282
|
+
ZaiLimitSchema = import_zod45.z.object({
|
|
15283
|
+
type: import_zod45.z.string(),
|
|
15284
|
+
unit: import_zod45.z.number().int(),
|
|
15285
|
+
number: import_zod45.z.number().int().positive(),
|
|
15286
|
+
percentage: import_zod45.z.number().nonnegative(),
|
|
15287
|
+
nextResetTime: import_zod45.z.number().positive().optional(),
|
|
15288
|
+
usage: import_zod45.z.number().nonnegative().optional(),
|
|
15289
|
+
currentValue: import_zod45.z.number().nonnegative().optional(),
|
|
15290
|
+
remaining: import_zod45.z.number().nonnegative().optional()
|
|
15291
15291
|
});
|
|
15292
|
-
ZaiResponseSchema =
|
|
15293
|
-
success:
|
|
15294
|
-
msg:
|
|
15295
|
-
data:
|
|
15292
|
+
ZaiResponseSchema = import_zod45.z.object({
|
|
15293
|
+
success: import_zod45.z.boolean(),
|
|
15294
|
+
msg: import_zod45.z.string().optional(),
|
|
15295
|
+
data: import_zod45.z.object({ level: import_zod45.z.string().optional(), limits: import_zod45.z.array(ZaiLimitSchema) })
|
|
15296
15296
|
});
|
|
15297
15297
|
OPENROUTER_HOST = "openrouter.ai";
|
|
15298
15298
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
15299
15299
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
15300
15300
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15301
|
-
OpenRouterKeySchema =
|
|
15302
|
-
data:
|
|
15303
|
-
limit:
|
|
15304
|
-
limit_remaining:
|
|
15305
|
-
limit_reset:
|
|
15306
|
-
is_free_tier:
|
|
15307
|
-
free_model_daily_requests:
|
|
15301
|
+
OpenRouterKeySchema = import_zod45.z.object({
|
|
15302
|
+
data: import_zod45.z.object({
|
|
15303
|
+
limit: import_zod45.z.number().nonnegative().nullable(),
|
|
15304
|
+
limit_remaining: import_zod45.z.number().nullable(),
|
|
15305
|
+
limit_reset: import_zod45.z.string().nullable(),
|
|
15306
|
+
is_free_tier: import_zod45.z.boolean().optional(),
|
|
15307
|
+
free_model_daily_requests: import_zod45.z.object({ used: import_zod45.z.number().nonnegative(), limit: import_zod45.z.number().nonnegative(), remaining: import_zod45.z.number() }).optional()
|
|
15308
15308
|
})
|
|
15309
15309
|
});
|
|
15310
|
-
OpenRouterCreditsSchema =
|
|
15310
|
+
OpenRouterCreditsSchema = import_zod45.z.object({ data: import_zod45.z.object({ total_credits: import_zod45.z.number().nonnegative(), total_usage: import_zod45.z.number().nonnegative() }) });
|
|
15311
15311
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
15312
15312
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
15313
15313
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -15315,21 +15315,21 @@ var init_providerQuota = __esm({
|
|
|
15315
15315
|
DAYS_PER_WEEK2 = 7;
|
|
15316
15316
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15317
15317
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15318
|
-
AntigravityBucketSchema =
|
|
15319
|
-
bucketId:
|
|
15320
|
-
remainingFraction:
|
|
15321
|
-
resetTime:
|
|
15318
|
+
AntigravityBucketSchema = import_zod45.z.object({
|
|
15319
|
+
bucketId: import_zod45.z.string(),
|
|
15320
|
+
remainingFraction: import_zod45.z.number().optional(),
|
|
15321
|
+
resetTime: import_zod45.z.string().optional()
|
|
15322
15322
|
});
|
|
15323
|
-
AntigravitySummarySchema =
|
|
15324
|
-
GoogleTokenInfoSchema =
|
|
15325
|
-
email:
|
|
15326
|
-
sub:
|
|
15323
|
+
AntigravitySummarySchema = import_zod45.z.object({ groups: import_zod45.z.array(import_zod45.z.object({ buckets: import_zod45.z.array(AntigravityBucketSchema) })) });
|
|
15324
|
+
GoogleTokenInfoSchema = import_zod45.z.object({
|
|
15325
|
+
email: import_zod45.z.string().optional(),
|
|
15326
|
+
sub: import_zod45.z.string().optional()
|
|
15327
15327
|
});
|
|
15328
|
-
AntigravityUserSchema =
|
|
15328
|
+
AntigravityUserSchema = import_zod45.z.object({
|
|
15329
15329
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
15330
|
-
currentTier:
|
|
15330
|
+
currentTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional(),
|
|
15331
15331
|
/** The account's paid subscription; absent when the account has none. */
|
|
15332
|
-
paidTier:
|
|
15332
|
+
paidTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional()
|
|
15333
15333
|
});
|
|
15334
15334
|
}
|
|
15335
15335
|
});
|
|
@@ -15549,9 +15549,10 @@ __export(index_exports, {
|
|
|
15549
15549
|
QUOTA_EXPIRING_EVENT_SOURCE: () => QUOTA_EXPIRING_EVENT_SOURCE,
|
|
15550
15550
|
QuotaExpiringEventSchema: () => QuotaExpiringEventSchema,
|
|
15551
15551
|
RC_CONTEXT_USAGE_DETAILS: () => RC_CONTEXT_USAGE_DETAILS,
|
|
15552
|
+
RC_GOAL_CLEAR_WORDS: () => RC_GOAL_CLEAR_WORDS,
|
|
15553
|
+
RC_GOAL_CONDITION_MAX_CHARS: () => RC_GOAL_CONDITION_MAX_CHARS,
|
|
15552
15554
|
RC_IDLE_EXPIRY_MS: () => RC_IDLE_EXPIRY_MS,
|
|
15553
15555
|
RC_ORPC_PATH_PREFIX: () => RC_ORPC_PATH_PREFIX,
|
|
15554
|
-
RC_PENDING_DEADLINE_MS: () => RC_PENDING_DEADLINE_MS,
|
|
15555
15556
|
RC_PENDING_RETIRE_REASONS: () => RC_PENDING_RETIRE_REASONS,
|
|
15556
15557
|
RC_PERMISSION_MODES: () => RC_PERMISSION_MODES,
|
|
15557
15558
|
RC_READ_FILE_ENCODINGS: () => RC_READ_FILE_ENCODINGS,
|
|
@@ -15564,6 +15565,8 @@ __export(index_exports, {
|
|
|
15564
15565
|
RC_SELF_HOST_SCOPE_LIST: () => RC_SELF_HOST_SCOPE_LIST,
|
|
15565
15566
|
RC_SELF_HOST_WORKER_JWT_TTL_SECONDS: () => RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
|
|
15566
15567
|
RC_SESSIONS_PATH_PREFIX: () => RC_SESSIONS_PATH_PREFIX,
|
|
15568
|
+
RC_SESSION_COMMAND_MAX_WAIT_MS: () => RC_SESSION_COMMAND_MAX_WAIT_MS,
|
|
15569
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS: () => RC_SESSION_COMMAND_VERIFIED_VERSIONS,
|
|
15567
15570
|
RC_SESSION_END_REASONS: () => RC_SESSION_END_REASONS,
|
|
15568
15571
|
RC_SESSION_EVENT_LOG_CAPACITY: () => RC_SESSION_EVENT_LOG_CAPACITY,
|
|
15569
15572
|
RC_STREAM_BACKOFF_MS: () => RC_STREAM_BACKOFF_MS,
|
|
@@ -15659,11 +15662,13 @@ __export(index_exports, {
|
|
|
15659
15662
|
createQuotaExpiringPublisher: () => createQuotaExpiringPublisher,
|
|
15660
15663
|
createRcApiNodeHandler: () => createRcApiNodeHandler,
|
|
15661
15664
|
createRcApiRouter: () => createRcApiRouter,
|
|
15665
|
+
createRcClaudeCodeVersions: () => createRcClaudeCodeVersions,
|
|
15662
15666
|
createRcControlHandler: () => createRcControlHandler,
|
|
15663
15667
|
createRcCredentialStore: () => createRcCredentialStore,
|
|
15664
15668
|
createRcEventFanout: () => createRcEventFanout,
|
|
15665
15669
|
createRcLiveUsage: () => createRcLiveUsage,
|
|
15666
15670
|
createRcSelfHostSurface: () => createRcSelfHostSurface,
|
|
15671
|
+
createRcSessionCommands: () => createRcSessionCommands,
|
|
15667
15672
|
createRcSessionEventLog: () => createRcSessionEventLog,
|
|
15668
15673
|
createRcSessionEventsApiRouter: () => createRcSessionEventsApiRouter,
|
|
15669
15674
|
createRcSessionRegistryReader: () => createRcSessionRegistryReader,
|
|
@@ -15726,6 +15731,7 @@ __export(index_exports, {
|
|
|
15726
15731
|
mintRcSelfHostCredential: () => mintRcSelfHostCredential,
|
|
15727
15732
|
observingRoutedRoute: () => observingRoutedRoute,
|
|
15728
15733
|
parseConnectTarget: () => parseConnectTarget,
|
|
15734
|
+
parseRcGoalOutput: () => parseRcGoalOutput,
|
|
15729
15735
|
parseRcStreamEnvelope: () => parseRcStreamEnvelope,
|
|
15730
15736
|
planOf: () => planOf,
|
|
15731
15737
|
poolIdentities: () => poolIdentities,
|
|
@@ -15737,6 +15743,8 @@ __export(index_exports, {
|
|
|
15737
15743
|
rankPool: () => rankPool,
|
|
15738
15744
|
rcEventWriteResultFromAnswer: () => rcEventWriteResultFromAnswer,
|
|
15739
15745
|
rcFanoutOnDoorHub: () => rcFanoutOnDoorHub,
|
|
15746
|
+
rcLocalCommandAnswerOf: () => rcLocalCommandAnswerOf,
|
|
15747
|
+
rcManualCompactBoundaryOf: () => rcManualCompactBoundaryOf,
|
|
15740
15748
|
rcObserverAsPassthrough: () => rcObserverAsPassthrough,
|
|
15741
15749
|
rcRateLimitInfoOf: () => rcRateLimitInfoOf,
|
|
15742
15750
|
rcSelfHostFromEnv: () => rcSelfHostFromEnv,
|
|
@@ -15855,6 +15863,9 @@ var HTTP_STATUS = {
|
|
|
15855
15863
|
// src/frontdoor/connectEffects.ts
|
|
15856
15864
|
init_connect();
|
|
15857
15865
|
|
|
15866
|
+
// src/frontdoor/rcSessions.ts
|
|
15867
|
+
var import_node_crypto6 = require("node:crypto");
|
|
15868
|
+
|
|
15858
15869
|
// src/agents/liveTasks.ts
|
|
15859
15870
|
var import_zod9 = require("zod");
|
|
15860
15871
|
|
|
@@ -16113,6 +16124,125 @@ function mergeLiveTasks(tree, live) {
|
|
|
16113
16124
|
return { ...tree, agents, remoteSessions, liveOnly };
|
|
16114
16125
|
}
|
|
16115
16126
|
|
|
16127
|
+
// src/frontdoor/rcQuestions.ts
|
|
16128
|
+
var RC_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
16129
|
+
var RC_QUESTIONS_MAX = 16;
|
|
16130
|
+
var RC_QUESTION_OPTIONS_MAX = 16;
|
|
16131
|
+
var RC_QUESTION_FIELD_MAX_CHARS = 1024;
|
|
16132
|
+
var MULTI_SELECT_SEPARATOR = ", ";
|
|
16133
|
+
function isRecord4(value) {
|
|
16134
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16135
|
+
}
|
|
16136
|
+
function fits(value) {
|
|
16137
|
+
return value === void 0 || value.length <= RC_QUESTION_FIELD_MAX_CHARS;
|
|
16138
|
+
}
|
|
16139
|
+
function optionOf(value) {
|
|
16140
|
+
if (!isRecord4(value) || typeof value.label !== "string" || value.label === "") {
|
|
16141
|
+
return "an option names no label";
|
|
16142
|
+
}
|
|
16143
|
+
const description = typeof value.description === "string" && value.description !== "" ? value.description : void 0;
|
|
16144
|
+
if (!fits(value.label) || !fits(description)) {
|
|
16145
|
+
return `an option is past ${String(RC_QUESTION_FIELD_MAX_CHARS)} characters`;
|
|
16146
|
+
}
|
|
16147
|
+
return description === void 0 ? { label: value.label } : { label: value.label, description };
|
|
16148
|
+
}
|
|
16149
|
+
function questionOf(value) {
|
|
16150
|
+
if (!isRecord4(value) || typeof value.question !== "string" || value.question === "" || !Array.isArray(value.options) || value.options.length === 0) {
|
|
16151
|
+
return "a question has no text or no options";
|
|
16152
|
+
}
|
|
16153
|
+
if (value.options.length > RC_QUESTION_OPTIONS_MAX) {
|
|
16154
|
+
return `a question has more than ${String(RC_QUESTION_OPTIONS_MAX)} options`;
|
|
16155
|
+
}
|
|
16156
|
+
const options = [];
|
|
16157
|
+
for (const candidate of value.options) {
|
|
16158
|
+
const option = optionOf(candidate);
|
|
16159
|
+
if (typeof option === "string") {
|
|
16160
|
+
return option;
|
|
16161
|
+
}
|
|
16162
|
+
if (options.some((existing) => existing.label === option.label)) {
|
|
16163
|
+
return `a question lists the option ${JSON.stringify(option.label)} twice`;
|
|
16164
|
+
}
|
|
16165
|
+
options.push(option);
|
|
16166
|
+
}
|
|
16167
|
+
const header = typeof value.header === "string" && value.header !== "" ? value.header : void 0;
|
|
16168
|
+
if (!fits(value.question) || !fits(header)) {
|
|
16169
|
+
return `a question is past ${String(RC_QUESTION_FIELD_MAX_CHARS)} characters`;
|
|
16170
|
+
}
|
|
16171
|
+
return { question: value.question, ...header === void 0 ? {} : { header }, multiSelect: value.multiSelect === true, options };
|
|
16172
|
+
}
|
|
16173
|
+
function rcQuestionsOfToolRequest(toolName, input) {
|
|
16174
|
+
if (toolName !== RC_QUESTION_TOOL_NAME) {
|
|
16175
|
+
return void 0;
|
|
16176
|
+
}
|
|
16177
|
+
if (!isRecord4(input) || !Array.isArray(input.questions) || input.questions.length === 0) {
|
|
16178
|
+
return { unanswerable: "the request names no questions" };
|
|
16179
|
+
}
|
|
16180
|
+
if (input.questions.length > RC_QUESTIONS_MAX) {
|
|
16181
|
+
return { unanswerable: `the request asks more than ${String(RC_QUESTIONS_MAX)} questions` };
|
|
16182
|
+
}
|
|
16183
|
+
const questions = [];
|
|
16184
|
+
for (const candidate of input.questions) {
|
|
16185
|
+
const question = questionOf(candidate);
|
|
16186
|
+
if (typeof question === "string") {
|
|
16187
|
+
return { unanswerable: question };
|
|
16188
|
+
}
|
|
16189
|
+
if (questions.some((existing) => existing.question === question.question)) {
|
|
16190
|
+
return { unanswerable: `the request asks ${JSON.stringify(question.question)} twice` };
|
|
16191
|
+
}
|
|
16192
|
+
questions.push(question);
|
|
16193
|
+
}
|
|
16194
|
+
return { questions };
|
|
16195
|
+
}
|
|
16196
|
+
function resolveSelection(question, questionNumber, selection) {
|
|
16197
|
+
if (typeof selection === "number") {
|
|
16198
|
+
const option = Number.isInteger(selection) ? question.options[selection - 1] : void 0;
|
|
16199
|
+
return option === void 0 ? { error: `question ${String(questionNumber)} has no option ${String(selection)}: its options are numbered 1 to ${String(question.options.length)}` } : { text: option.label };
|
|
16200
|
+
}
|
|
16201
|
+
if (typeof selection === "object") {
|
|
16202
|
+
const text = selection.text.trim();
|
|
16203
|
+
return text === "" ? { error: `question ${String(questionNumber)}'s free-text answer is empty` } : { text };
|
|
16204
|
+
}
|
|
16205
|
+
const exact = question.options.find((option) => option.label === selection);
|
|
16206
|
+
if (exact !== void 0) {
|
|
16207
|
+
return { text: exact.label };
|
|
16208
|
+
}
|
|
16209
|
+
const folded = question.options.filter((option) => option.label.toLowerCase() === selection.toLowerCase());
|
|
16210
|
+
const [only] = folded;
|
|
16211
|
+
if (only !== void 0 && folded.length === 1) {
|
|
16212
|
+
return { text: only.label };
|
|
16213
|
+
}
|
|
16214
|
+
return { error: `question ${String(questionNumber)} has no option labelled ${JSON.stringify(selection)}: its options are ${question.options.map((option) => JSON.stringify(option.label)).join(", ")}` };
|
|
16215
|
+
}
|
|
16216
|
+
function resolveRcQuestionAnswers(questions, choices) {
|
|
16217
|
+
if (choices.length !== questions.length) {
|
|
16218
|
+
return { error: `the request asks ${String(questions.length)} question(s), so the answer must choose for each of them in order, but it chose for ${String(choices.length)}` };
|
|
16219
|
+
}
|
|
16220
|
+
const answers = {};
|
|
16221
|
+
for (const [index, question] of questions.entries()) {
|
|
16222
|
+
const questionNumber = index + 1;
|
|
16223
|
+
const selections = choices[index] ?? [];
|
|
16224
|
+
if (selections.length === 0) {
|
|
16225
|
+
return { error: `question ${String(questionNumber)} has no selection` };
|
|
16226
|
+
}
|
|
16227
|
+
if (!question.multiSelect && selections.length > 1) {
|
|
16228
|
+
return { error: `question ${String(questionNumber)} takes one option, but ${String(selections.length)} were chosen` };
|
|
16229
|
+
}
|
|
16230
|
+
const texts = [];
|
|
16231
|
+
for (const selection of selections) {
|
|
16232
|
+
const resolved = resolveSelection(question, questionNumber, selection);
|
|
16233
|
+
if ("error" in resolved) {
|
|
16234
|
+
return resolved;
|
|
16235
|
+
}
|
|
16236
|
+
if (texts.includes(resolved.text)) {
|
|
16237
|
+
return { error: `question ${String(questionNumber)} chose ${JSON.stringify(resolved.text)} twice` };
|
|
16238
|
+
}
|
|
16239
|
+
texts.push(resolved.text);
|
|
16240
|
+
}
|
|
16241
|
+
answers[question.question] = texts.join(MULTI_SELECT_SEPARATOR);
|
|
16242
|
+
}
|
|
16243
|
+
return { answers };
|
|
16244
|
+
}
|
|
16245
|
+
|
|
16116
16246
|
// src/frontdoor/rcSessions.ts
|
|
16117
16247
|
var RC_SESSIONS_PATH_PREFIX = "/v1/code/sessions";
|
|
16118
16248
|
function pathnameOf(url) {
|
|
@@ -16127,7 +16257,12 @@ var RC_IDLE_EXPIRY_MS = 45e3;
|
|
|
16127
16257
|
var RC_CREATE_RESPONSE_CAP_BYTES = 8192;
|
|
16128
16258
|
var CONFLICT_REASON_HEADER = "x-ccr-conflict-reason";
|
|
16129
16259
|
var RC_STREAM_WORKER_SOURCE = "worker";
|
|
16130
|
-
var
|
|
16260
|
+
var HIGH_SURROGATE_FIRST = 55296;
|
|
16261
|
+
var HIGH_SURROGATE_LAST = 56319;
|
|
16262
|
+
var RC_WORKER_IDLE = "idle";
|
|
16263
|
+
var RC_PENDING_PER_SESSION_MAX = 64;
|
|
16264
|
+
var RC_REQUEST_ID_MAX_CHARS = 128;
|
|
16265
|
+
var RC_RETIRED_TOMBSTONES_MAX = 2 * RC_PENDING_PER_SESSION_MAX;
|
|
16131
16266
|
var RC_REQUEST_PARSE_CAP_BYTES = 262144;
|
|
16132
16267
|
var RC_PENDING_SUMMARY_EXCERPT_CHARS = 300;
|
|
16133
16268
|
var SUCCESS_STATUS_MAX_EXCLUSIVE = 300;
|
|
@@ -16160,7 +16295,7 @@ function sessionCreateId(body) {
|
|
|
16160
16295
|
const id = session.id;
|
|
16161
16296
|
return typeof id === "string" && id.startsWith(RC_SESSION_ID_PREFIX) ? id : void 0;
|
|
16162
16297
|
}
|
|
16163
|
-
function
|
|
16298
|
+
function isRecord5(value) {
|
|
16164
16299
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16165
16300
|
}
|
|
16166
16301
|
function parseJsonObject(body) {
|
|
@@ -16170,7 +16305,7 @@ function parseJsonObject(body) {
|
|
|
16170
16305
|
} catch {
|
|
16171
16306
|
return void 0;
|
|
16172
16307
|
}
|
|
16173
|
-
return
|
|
16308
|
+
return isRecord5(parsed) ? parsed : void 0;
|
|
16174
16309
|
}
|
|
16175
16310
|
function nonEmptyString(record, field) {
|
|
16176
16311
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -16180,8 +16315,16 @@ function finiteNumber(record, field) {
|
|
|
16180
16315
|
const value = record === void 0 ? void 0 : record[field];
|
|
16181
16316
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
16182
16317
|
}
|
|
16183
|
-
function
|
|
16184
|
-
|
|
16318
|
+
function rcExcerpt(text) {
|
|
16319
|
+
if (text.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS) {
|
|
16320
|
+
return text;
|
|
16321
|
+
}
|
|
16322
|
+
const cut = text.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS);
|
|
16323
|
+
const last = cut.charCodeAt(cut.length - 1);
|
|
16324
|
+
return `${isHighSurrogate(last) ? cut.slice(0, -1) : cut}...`;
|
|
16325
|
+
}
|
|
16326
|
+
function isHighSurrogate(unit) {
|
|
16327
|
+
return unit >= HIGH_SURROGATE_FIRST && unit <= HIGH_SURROGATE_LAST;
|
|
16185
16328
|
}
|
|
16186
16329
|
function payloadEventsOf(body) {
|
|
16187
16330
|
const parsed = parseJsonObject(body);
|
|
@@ -16191,11 +16334,11 @@ function payloadEventsOf(body) {
|
|
|
16191
16334
|
}
|
|
16192
16335
|
const payloads = [];
|
|
16193
16336
|
for (const event of events) {
|
|
16194
|
-
if (!
|
|
16337
|
+
if (!isRecord5(event)) {
|
|
16195
16338
|
continue;
|
|
16196
16339
|
}
|
|
16197
16340
|
const payload = event.payload;
|
|
16198
|
-
if (!
|
|
16341
|
+
if (!isRecord5(payload)) {
|
|
16199
16342
|
continue;
|
|
16200
16343
|
}
|
|
16201
16344
|
payloads.push(payload);
|
|
@@ -16203,6 +16346,14 @@ function payloadEventsOf(body) {
|
|
|
16203
16346
|
return payloads;
|
|
16204
16347
|
}
|
|
16205
16348
|
function pendingOfControlRequestPayload(payload) {
|
|
16349
|
+
const parsed = fullPendingOfControlRequestPayload(payload);
|
|
16350
|
+
const isQuestion = parsed !== void 0 && (parsed.questions !== void 0 || parsed.unanswerable !== void 0);
|
|
16351
|
+
if (parsed === void 0 || !isQuestion || Buffer.byteLength(JSON.stringify(payload), "utf8") <= RC_REQUEST_PARSE_CAP_BYTES) {
|
|
16352
|
+
return parsed;
|
|
16353
|
+
}
|
|
16354
|
+
return { ...parsed, questions: void 0, toolInput: void 0, oversized: true, unanswerable: parsed.unanswerable ?? `the request is past the door's parse cap of ${String(RC_REQUEST_PARSE_CAP_BYTES)} bytes` };
|
|
16355
|
+
}
|
|
16356
|
+
function fullPendingOfControlRequestPayload(payload) {
|
|
16206
16357
|
if (payload.type !== "control_request") {
|
|
16207
16358
|
return void 0;
|
|
16208
16359
|
}
|
|
@@ -16210,24 +16361,41 @@ function pendingOfControlRequestPayload(payload) {
|
|
|
16210
16361
|
if (requestId === void 0) {
|
|
16211
16362
|
return void 0;
|
|
16212
16363
|
}
|
|
16213
|
-
const request4 =
|
|
16364
|
+
const request4 = isRecord5(payload.request) ? payload.request : void 0;
|
|
16214
16365
|
const subtype = nonEmptyString(request4, "subtype");
|
|
16215
16366
|
const type = subtype ?? "control_request";
|
|
16216
16367
|
let summary = "";
|
|
16368
|
+
let questions;
|
|
16369
|
+
let unanswerable;
|
|
16370
|
+
let toolInput;
|
|
16217
16371
|
if (subtype === "can_use_tool") {
|
|
16218
|
-
const toolName = nonEmptyString(request4, "tool_name")
|
|
16372
|
+
const toolName = nonEmptyString(request4, "tool_name");
|
|
16219
16373
|
const input = request4 === void 0 ? void 0 : request4.input;
|
|
16220
|
-
summary = input === void 0 ? toolName : `${toolName} ${
|
|
16374
|
+
summary = input === void 0 ? toolName ?? "unknown tool" : `${toolName ?? "unknown tool"} ${rcExcerpt(JSON.stringify(input))}`;
|
|
16375
|
+
const parsedQuestions = rcQuestionsOfToolRequest(toolName, input);
|
|
16376
|
+
if (parsedQuestions !== void 0 && "questions" in parsedQuestions) {
|
|
16377
|
+
questions = parsedQuestions.questions;
|
|
16378
|
+
toolInput = isRecord5(input) ? input : void 0;
|
|
16379
|
+
} else if (parsedQuestions !== void 0) {
|
|
16380
|
+
unanswerable = parsedQuestions.unanswerable;
|
|
16381
|
+
}
|
|
16221
16382
|
} else if (request4 !== void 0) {
|
|
16222
|
-
summary =
|
|
16383
|
+
summary = rcExcerpt(JSON.stringify(request4));
|
|
16223
16384
|
}
|
|
16224
|
-
return { requestId, type, summary };
|
|
16385
|
+
return { requestId, type, summary, questions, unanswerable, toolInput, oversized: false };
|
|
16386
|
+
}
|
|
16387
|
+
function withdrawnRequestIdsOfControlCancelPayload(payload) {
|
|
16388
|
+
if (payload.type !== "control_cancel_request") {
|
|
16389
|
+
return [];
|
|
16390
|
+
}
|
|
16391
|
+
const id = nonEmptyString(payload, "request_id");
|
|
16392
|
+
return id === void 0 ? [] : [id];
|
|
16225
16393
|
}
|
|
16226
16394
|
function answeredRequestIdsOfControlResponsePayload(payload) {
|
|
16227
16395
|
if (payload.type !== "control_response") {
|
|
16228
16396
|
return [];
|
|
16229
16397
|
}
|
|
16230
|
-
const response =
|
|
16398
|
+
const response = isRecord5(payload.response) ? payload.response : void 0;
|
|
16231
16399
|
const id = nonEmptyString(response, "request_id") ?? nonEmptyString(payload, "request_id") ?? nonEmptyString(payload, "uuid");
|
|
16232
16400
|
return id === void 0 ? [] : [id];
|
|
16233
16401
|
}
|
|
@@ -16239,44 +16407,74 @@ function initFactsOfPayload(payload) {
|
|
|
16239
16407
|
}
|
|
16240
16408
|
function parseRcRequestBody(kind, body) {
|
|
16241
16409
|
if (kind === "heartbeat") {
|
|
16242
|
-
return { controlRequests: [], answeredRequestIds: [], idleSeconds: finiteNumber(parseJsonObject(body), "idle_seconds"), workerStatus: void 0, payloads: [] };
|
|
16410
|
+
return { controlRequests: [], answeredRequestIds: [], withdrawnRequestIds: [], idleSeconds: finiteNumber(parseJsonObject(body), "idle_seconds"), workerStatus: void 0, workerEpoch: void 0, payloads: [] };
|
|
16243
16411
|
}
|
|
16244
16412
|
if (kind === "worker-registration") {
|
|
16245
16413
|
const registration = parseJsonObject(body);
|
|
16246
|
-
const metadata = registration === void 0 || !
|
|
16414
|
+
const metadata = registration === void 0 || !isRecord5(registration.external_metadata) ? void 0 : registration.external_metadata;
|
|
16247
16415
|
const model = nonEmptyString(metadata, "model");
|
|
16248
|
-
return { controlRequests: [], answeredRequestIds: [], idleSeconds: void 0, workerStatus: nonEmptyString(registration, "worker_status"), payloads: [], ...model === void 0 ? {} : { model } };
|
|
16416
|
+
return { controlRequests: [], answeredRequestIds: [], withdrawnRequestIds: [], idleSeconds: void 0, workerStatus: nonEmptyString(registration, "worker_status"), workerEpoch: finiteNumber(registration, "worker_epoch"), payloads: [], ...model === void 0 ? {} : { model } };
|
|
16249
16417
|
}
|
|
16250
16418
|
const controlRequests = [];
|
|
16251
16419
|
const answeredRequestIds = [];
|
|
16420
|
+
const withdrawnRequestIds = [];
|
|
16252
16421
|
const payloads = payloadEventsOf(body);
|
|
16253
16422
|
for (const payload of payloads) {
|
|
16254
16423
|
const pending = pendingOfControlRequestPayload(payload);
|
|
16255
16424
|
if (pending !== void 0) {
|
|
16256
|
-
controlRequests.push(
|
|
16425
|
+
controlRequests.push(pending);
|
|
16257
16426
|
continue;
|
|
16258
16427
|
}
|
|
16259
16428
|
answeredRequestIds.push(...answeredRequestIdsOfControlResponsePayload(payload));
|
|
16429
|
+
if (kind === "worker-events") {
|
|
16430
|
+
withdrawnRequestIds.push(...withdrawnRequestIdsOfControlCancelPayload(payload));
|
|
16431
|
+
}
|
|
16432
|
+
}
|
|
16433
|
+
return { controlRequests, answeredRequestIds, withdrawnRequestIds, idleSeconds: void 0, workerStatus: void 0, workerEpoch: void 0, payloads };
|
|
16434
|
+
}
|
|
16435
|
+
function rememberBounded(record, key) {
|
|
16436
|
+
record.delete(key);
|
|
16437
|
+
record.add(key);
|
|
16438
|
+
if (record.size > RC_RETIRED_TOMBSTONES_MAX) {
|
|
16439
|
+
const [oldest] = record;
|
|
16440
|
+
if (oldest !== void 0) {
|
|
16441
|
+
record.delete(oldest);
|
|
16442
|
+
}
|
|
16260
16443
|
}
|
|
16261
|
-
|
|
16444
|
+
}
|
|
16445
|
+
function droppedKeyOf(requestId) {
|
|
16446
|
+
return requestId.length <= RC_REQUEST_ID_MAX_CHARS ? requestId : (0, import_node_crypto6.createHash)("sha256").update(requestId).digest("hex");
|
|
16262
16447
|
}
|
|
16263
16448
|
function createRcSessionTracker(deps) {
|
|
16264
16449
|
const entries = /* @__PURE__ */ new Map();
|
|
16450
|
+
let observationSequence = 0;
|
|
16451
|
+
const rememberRetired = (entry, requestId) => {
|
|
16452
|
+
rememberBounded(entry.retired, requestId);
|
|
16453
|
+
};
|
|
16265
16454
|
const retirePending = (entry, requestId, reason) => {
|
|
16266
16455
|
if (entry.pending.delete(requestId)) {
|
|
16267
|
-
entry
|
|
16456
|
+
rememberRetired(entry, requestId);
|
|
16268
16457
|
deps.onTransition?.({ kind: "pending-retired", session: entry.id, requestId, reason, at: deps.now() });
|
|
16269
16458
|
}
|
|
16270
16459
|
};
|
|
16271
|
-
const addPending = (entry,
|
|
16272
|
-
|
|
16460
|
+
const addPending = (entry, request4, now) => {
|
|
16461
|
+
const droppedKey = droppedKeyOf(request4.requestId);
|
|
16462
|
+
if (entry.retired.has(request4.requestId) || entry.dropped.has(droppedKey)) {
|
|
16273
16463
|
return;
|
|
16274
16464
|
}
|
|
16275
|
-
const
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16465
|
+
const already = entry.pending.get(request4.requestId);
|
|
16466
|
+
if (already !== void 0) {
|
|
16467
|
+
entry.pending.set(request4.requestId, { ...already, ...request4, observedAt: already.observedAt });
|
|
16468
|
+
return;
|
|
16469
|
+
}
|
|
16470
|
+
if (request4.requestId.length > RC_REQUEST_ID_MAX_CHARS || entry.pending.size >= RC_PENDING_PER_SESSION_MAX) {
|
|
16471
|
+
entry.droppedPending += 1;
|
|
16472
|
+
rememberBounded(entry.dropped, droppedKey);
|
|
16473
|
+
return;
|
|
16279
16474
|
}
|
|
16475
|
+
observationSequence += 1;
|
|
16476
|
+
entry.pending.set(request4.requestId, { sessionId: entry.id, ...request4, observedAt: now, observedSequence: observationSequence });
|
|
16477
|
+
deps.onTransition?.({ kind: "pending-born", session: entry.id, requestId: request4.requestId, type: request4.type, summary: request4.summary, at: now });
|
|
16280
16478
|
};
|
|
16281
16479
|
const expire = (id, reason) => {
|
|
16282
16480
|
const entry = entries.get(id);
|
|
@@ -16289,31 +16487,17 @@ function createRcSessionTracker(deps) {
|
|
|
16289
16487
|
entries.delete(id);
|
|
16290
16488
|
deps.onTransition?.({ kind: "session-ended", session: id, reason, at: deps.now() });
|
|
16291
16489
|
};
|
|
16292
|
-
const expirePendings = (entry, now) => {
|
|
16293
|
-
for (const [requestId, pending] of entry.pending) {
|
|
16294
|
-
if (now - pending.observedAt >= RC_PENDING_DEADLINE_MS) {
|
|
16295
|
-
retirePending(entry, requestId, "expired");
|
|
16296
|
-
}
|
|
16297
|
-
}
|
|
16298
|
-
for (const [requestId, retiredAt] of entry.retired) {
|
|
16299
|
-
if (now - retiredAt >= RC_PENDING_DEADLINE_MS) {
|
|
16300
|
-
entry.retired.delete(requestId);
|
|
16301
|
-
}
|
|
16302
|
-
}
|
|
16303
|
-
};
|
|
16304
16490
|
const sweep = () => {
|
|
16305
16491
|
for (const [id, entry] of entries) {
|
|
16306
16492
|
if (deps.now() - entry.lastSeenAt >= deps.idleMs) {
|
|
16307
16493
|
expire(id, "expired");
|
|
16308
|
-
continue;
|
|
16309
16494
|
}
|
|
16310
|
-
expirePendings(entry, deps.now());
|
|
16311
16495
|
}
|
|
16312
16496
|
};
|
|
16313
|
-
const timer = setInterval(sweep,
|
|
16497
|
+
const timer = setInterval(sweep, deps.idleMs);
|
|
16314
16498
|
timer.unref();
|
|
16315
16499
|
const birth = (id, facts) => {
|
|
16316
|
-
const record = { id, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), retired: /* @__PURE__ */ new
|
|
16500
|
+
const record = { id, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), retired: /* @__PURE__ */ new Set(), dropped: /* @__PURE__ */ new Set(), workerState: void 0, workerIdleSeconds: void 0, model: void 0, cwd: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map(), workerEpoch: void 0, droppedPending: 0, answering: /* @__PURE__ */ new Set() };
|
|
16317
16501
|
entries.set(id, record);
|
|
16318
16502
|
deps.onTransition?.({ kind: "session-appeared", session: id, at: record.createdAt });
|
|
16319
16503
|
return record;
|
|
@@ -16344,6 +16528,7 @@ function createRcSessionTracker(deps) {
|
|
|
16344
16528
|
return void 0;
|
|
16345
16529
|
}
|
|
16346
16530
|
const tail = pathnameOf(request4.url).slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
16531
|
+
const startedAtSequence = observationSequence;
|
|
16347
16532
|
const facts = {
|
|
16348
16533
|
oauthAuthorization: oauthAuthorizationOf(request4.headers),
|
|
16349
16534
|
anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
|
|
@@ -16391,9 +16576,11 @@ function createRcSessionTracker(deps) {
|
|
|
16391
16576
|
if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
|
|
16392
16577
|
return void 0;
|
|
16393
16578
|
}
|
|
16579
|
+
const isClientWrite = method === "POST" && (rest === `${id}/events` || rest === `${id}/teleport-events`);
|
|
16580
|
+
const sessionFacts = isClientWrite ? { ...facts, anthropicClientPlatform: void 0 } : facts;
|
|
16394
16581
|
const tracked = entries.get(id);
|
|
16395
16582
|
if (tracked !== void 0) {
|
|
16396
|
-
refresh(tracked,
|
|
16583
|
+
refresh(tracked, sessionFacts);
|
|
16397
16584
|
}
|
|
16398
16585
|
const bodyKind = method === "POST" && rest === `${id}/worker/events` ? "worker-events" : method === "POST" && rest === `${id}/events` ? "client-events" : method === "POST" && rest === `${id}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id}/worker` ? "worker-registration" : void 0;
|
|
16399
16586
|
let chunks = [];
|
|
@@ -16415,11 +16602,14 @@ function createRcSessionTracker(deps) {
|
|
|
16415
16602
|
}
|
|
16416
16603
|
const now = deps.now();
|
|
16417
16604
|
for (const controlRequest of factsOfBody.controlRequests) {
|
|
16418
|
-
addPending(entryNow,
|
|
16605
|
+
addPending(entryNow, controlRequest, now);
|
|
16419
16606
|
}
|
|
16420
16607
|
for (const requestId of factsOfBody.answeredRequestIds) {
|
|
16421
16608
|
retirePending(entryNow, requestId, "answered");
|
|
16422
16609
|
}
|
|
16610
|
+
for (const requestId of factsOfBody.withdrawnRequestIds) {
|
|
16611
|
+
retirePending(entryNow, requestId, "withdrawn");
|
|
16612
|
+
}
|
|
16423
16613
|
for (const payload of factsOfBody.payloads) {
|
|
16424
16614
|
entryNow.liveTasks = applyAgentTaskEvent(entryNow.liveTasks, id, payload, now);
|
|
16425
16615
|
noteInit(entryNow, payload);
|
|
@@ -16435,6 +16625,17 @@ function createRcSessionTracker(deps) {
|
|
|
16435
16625
|
deps.onTransition?.({ kind: "worker-state", session: id, state: factsOfBody.workerStatus, ...previous === void 0 ? {} : { previous }, at: now });
|
|
16436
16626
|
}
|
|
16437
16627
|
}
|
|
16628
|
+
const epochChanged = factsOfBody.workerEpoch !== void 0 && entryNow.workerEpoch !== void 0 && factsOfBody.workerEpoch !== entryNow.workerEpoch;
|
|
16629
|
+
if (factsOfBody.workerEpoch !== void 0) {
|
|
16630
|
+
entryNow.workerEpoch = factsOfBody.workerEpoch;
|
|
16631
|
+
}
|
|
16632
|
+
if (epochChanged || factsOfBody.workerStatus === RC_WORKER_IDLE) {
|
|
16633
|
+
for (const [requestId, pending] of entryNow.pending) {
|
|
16634
|
+
if (pending.observedSequence <= startedAtSequence) {
|
|
16635
|
+
retirePending(entryNow, requestId, "worker-stopped");
|
|
16636
|
+
}
|
|
16637
|
+
}
|
|
16638
|
+
}
|
|
16438
16639
|
};
|
|
16439
16640
|
const archiving = method === "POST" && rest === `${id}/archive`;
|
|
16440
16641
|
return {
|
|
@@ -16463,7 +16664,7 @@ function createRcSessionTracker(deps) {
|
|
|
16463
16664
|
}
|
|
16464
16665
|
accepted = isSuccessful(status);
|
|
16465
16666
|
if (accepted && !entries.has(id)) {
|
|
16466
|
-
persistCredential(birth(id,
|
|
16667
|
+
persistCredential(birth(id, sessionFacts));
|
|
16467
16668
|
}
|
|
16468
16669
|
file();
|
|
16469
16670
|
},
|
|
@@ -16474,7 +16675,7 @@ function createRcSessionTracker(deps) {
|
|
|
16474
16675
|
};
|
|
16475
16676
|
};
|
|
16476
16677
|
const summaryOf2 = ({ id, createdAt, lastSeenAt }) => ({ id, createdAt, lastSeenAt });
|
|
16477
|
-
const pendingSummaryOf = ({ sessionId, requestId, type, summary, observedAt: observedAt2 }) => ({ sessionId, requestId, type, summary, observedAt: observedAt2 });
|
|
16678
|
+
const pendingSummaryOf = ({ sessionId, requestId, type, summary, questions, unanswerable, oversized, observedAt: observedAt2 }) => ({ sessionId, requestId, type, summary, ...questions === void 0 ? {} : { questions }, ...oversized ? { oversized: true } : {}, ...unanswerable === void 0 ? {} : { unanswerable }, observedAt: observedAt2 });
|
|
16478
16679
|
const sortedEntries = () => [...entries.values()].sort((left, right) => left.createdAt - right.createdAt || (left.id < right.id ? -1 : 1));
|
|
16479
16680
|
const pendingSorted = (entry) => [...entry.pending.values()].sort((left, right) => left.observedAt - right.observedAt || (left.requestId < right.requestId ? -1 : 1)).map(pendingSummaryOf);
|
|
16480
16681
|
return {
|
|
@@ -16492,7 +16693,8 @@ function createRcSessionTracker(deps) {
|
|
|
16492
16693
|
pending: pendingSorted(entry),
|
|
16493
16694
|
...entry.identity === void 0 ? {} : { identity: entry.identity },
|
|
16494
16695
|
...entry.model === void 0 ? {} : { model: entry.model },
|
|
16495
|
-
...entry.cwd === void 0 ? {} : { cwd: entry.cwd }
|
|
16696
|
+
...entry.cwd === void 0 ? {} : { cwd: entry.cwd },
|
|
16697
|
+
...entry.droppedPending === 0 ? {} : { pendingDropped: entry.droppedPending }
|
|
16496
16698
|
}));
|
|
16497
16699
|
},
|
|
16498
16700
|
pendingOf: (sessionId) => {
|
|
@@ -16530,7 +16732,7 @@ function createRcSessionTracker(deps) {
|
|
|
16530
16732
|
return;
|
|
16531
16733
|
}
|
|
16532
16734
|
entry.sequenceNum = entry.sequenceNum === void 0 || event.sequence_num > entry.sequenceNum ? event.sequence_num : entry.sequenceNum;
|
|
16533
|
-
if (!
|
|
16735
|
+
if (!isRecord5(event.payload)) {
|
|
16534
16736
|
return;
|
|
16535
16737
|
}
|
|
16536
16738
|
entry.liveTasks = applyAgentTaskEvent(entry.liveTasks, sessionId, event.payload, deps.now());
|
|
@@ -16538,13 +16740,18 @@ function createRcSessionTracker(deps) {
|
|
|
16538
16740
|
const pending = pendingOfControlRequestPayload(event.payload);
|
|
16539
16741
|
if (pending !== void 0) {
|
|
16540
16742
|
if (event.source === RC_STREAM_WORKER_SOURCE) {
|
|
16541
|
-
addPending(entry,
|
|
16743
|
+
addPending(entry, pending, deps.now());
|
|
16542
16744
|
}
|
|
16543
16745
|
return;
|
|
16544
16746
|
}
|
|
16545
16747
|
for (const requestId of answeredRequestIdsOfControlResponsePayload(event.payload)) {
|
|
16546
16748
|
retirePending(entry, requestId, "answered");
|
|
16547
16749
|
}
|
|
16750
|
+
if (event.source === RC_STREAM_WORKER_SOURCE) {
|
|
16751
|
+
for (const requestId of withdrawnRequestIdsOfControlCancelPayload(event.payload)) {
|
|
16752
|
+
retirePending(entry, requestId, "withdrawn");
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16548
16755
|
},
|
|
16549
16756
|
liveTasksOf: (sessionId) => {
|
|
16550
16757
|
sweep();
|
|
@@ -16556,6 +16763,17 @@ function createRcSessionTracker(deps) {
|
|
|
16556
16763
|
retirePending(entry, requestId, "answered");
|
|
16557
16764
|
}
|
|
16558
16765
|
},
|
|
16766
|
+
claimPending: (sessionId, requestId) => {
|
|
16767
|
+
const entry = entries.get(sessionId);
|
|
16768
|
+
if (entry === void 0 || !entry.pending.has(requestId) || entry.answering.has(requestId)) {
|
|
16769
|
+
return void 0;
|
|
16770
|
+
}
|
|
16771
|
+
entry.answering.add(requestId);
|
|
16772
|
+
return () => {
|
|
16773
|
+
entry.answering.delete(requestId);
|
|
16774
|
+
};
|
|
16775
|
+
},
|
|
16776
|
+
pendingToolInputOf: (sessionId, requestId) => entries.get(sessionId)?.pending.get(requestId)?.toolInput,
|
|
16559
16777
|
close: () => {
|
|
16560
16778
|
clearInterval(timer);
|
|
16561
16779
|
deps.onClose?.();
|
|
@@ -16722,8 +16940,8 @@ async function injectRcUserMessage(deps, sessionId, text) {
|
|
|
16722
16940
|
}
|
|
16723
16941
|
return result;
|
|
16724
16942
|
}
|
|
16725
|
-
function buildRcControlResponsePayload(requestId, decision) {
|
|
16726
|
-
const result = decision.approve ? { behavior: "allow" } : { behavior: "deny", message: decision.message ?? "" };
|
|
16943
|
+
function buildRcControlResponsePayload(requestId, decision, updatedInput) {
|
|
16944
|
+
const result = decision.approve ? { behavior: "allow", ...updatedInput === void 0 ? {} : { updatedInput } } : { behavior: "deny", message: decision.message ?? "" };
|
|
16727
16945
|
return { type: "control_response", response: { subtype: "success", request_id: requestId, response: result } };
|
|
16728
16946
|
}
|
|
16729
16947
|
var RC_PERMISSION_MODES = ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"];
|
|
@@ -16780,6 +16998,27 @@ function buildRcMcpOAuthCallbackUrlPayload(requestId, serverName, callbackUrl) {
|
|
|
16780
16998
|
function buildRcKeepAlivePayload() {
|
|
16781
16999
|
return { type: "keep_alive" };
|
|
16782
17000
|
}
|
|
17001
|
+
function questionAnswerInput(deps, sessionId, pending, decision) {
|
|
17002
|
+
const { questions, unanswerable } = pending;
|
|
17003
|
+
if (questions === void 0 && unanswerable === void 0) {
|
|
17004
|
+
return decision.choices === void 0 ? void 0 : { error: `control request ${pending.requestId} is not a question (it is ${pending.type}${pending.summary === "" ? "" : `: ${pending.summary}`}), so it has no options to choose; approve or deny it instead` };
|
|
17005
|
+
}
|
|
17006
|
+
if (!decision.approve) {
|
|
17007
|
+
return decision.choices === void 0 ? void 0 : { error: "a denial dismisses the question and carries no choices; choose options to answer it, or deny it without them" };
|
|
17008
|
+
}
|
|
17009
|
+
if (questions === void 0) {
|
|
17010
|
+
return { error: `control request ${pending.requestId} is a question the door cannot answer (${String(unanswerable)}), so it cannot write an answer the worker would read correctly; answer it in the session itself, or deny it to dismiss it` };
|
|
17011
|
+
}
|
|
17012
|
+
if (decision.choices === void 0) {
|
|
17013
|
+
return { error: `control request ${pending.requestId} is a question, so answering it means choosing an option for each of its ${String(questions.length)} question(s); deny it to dismiss it` };
|
|
17014
|
+
}
|
|
17015
|
+
const input = deps.pendingToolInputOf(sessionId, pending.requestId);
|
|
17016
|
+
if (input === void 0) {
|
|
17017
|
+
return { error: `the front door holds no input for question ${pending.requestId} on session ${sessionId}, so it cannot write the answer the worker expects` };
|
|
17018
|
+
}
|
|
17019
|
+
const resolved = resolveRcQuestionAnswers(questions, decision.choices);
|
|
17020
|
+
return "error" in resolved ? resolved : { input: { ...input, answers: resolved.answers } };
|
|
17021
|
+
}
|
|
16783
17022
|
async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
16784
17023
|
const credential = deps.credentialOf(sessionId);
|
|
16785
17024
|
if (credential === void 0) {
|
|
@@ -16788,15 +17027,26 @@ async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
|
16788
17027
|
if (credential.authorization === void 0) {
|
|
16789
17028
|
return noOAuthCredentialResult(sessionId);
|
|
16790
17029
|
}
|
|
16791
|
-
|
|
16792
|
-
|
|
17030
|
+
const pending = deps.pendingOf(sessionId).find((candidate) => candidate.requestId === requestId);
|
|
17031
|
+
if (pending === void 0) {
|
|
17032
|
+
return { ok: false, message: `the front door has not observed control request ${requestId} pending on session ${sessionId}: it was answered already (by this door, by an attached client or in the session's own terminal), the worker withdrew it, or it never passed through this door` };
|
|
17033
|
+
}
|
|
17034
|
+
const updatedInput = questionAnswerInput(deps, sessionId, pending, decision);
|
|
17035
|
+
if (updatedInput !== void 0 && "error" in updatedInput) {
|
|
17036
|
+
return { ok: false, message: updatedInput.error };
|
|
16793
17037
|
}
|
|
16794
|
-
const
|
|
17038
|
+
const release = deps.claimPending(sessionId, requestId);
|
|
17039
|
+
if (release === void 0) {
|
|
17040
|
+
return { ok: false, message: `another answer to control request ${requestId} on session ${sessionId} is being written right now; the worker takes only one, so this one was not sent` };
|
|
17041
|
+
}
|
|
17042
|
+
const body = JSON.stringify(buildRcEventWriteBody(buildRcControlResponsePayload(requestId, decision, updatedInput?.input)));
|
|
16795
17043
|
let answer;
|
|
16796
17044
|
try {
|
|
16797
17045
|
answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders(credential), body);
|
|
16798
17046
|
} catch (error) {
|
|
16799
17047
|
return { ok: false, message: `the door could not reach the API host to answer on session ${sessionId}: ${error instanceof Error ? error.message : String(error)}` };
|
|
17048
|
+
} finally {
|
|
17049
|
+
release();
|
|
16800
17050
|
}
|
|
16801
17051
|
const result = rcEventWriteResultFromAnswer(answer);
|
|
16802
17052
|
if (result.ok) {
|
|
@@ -16926,6 +17176,198 @@ init_legacy();
|
|
|
16926
17176
|
// src/frontdoor/rcControl.ts
|
|
16927
17177
|
var https = __toESM(require("node:https"), 1);
|
|
16928
17178
|
init_capability();
|
|
17179
|
+
|
|
17180
|
+
// src/frontdoor/rcSchemas.ts
|
|
17181
|
+
var import_zod10 = require("zod");
|
|
17182
|
+
var RcPermissionModeSchema = import_zod10.z.enum(RC_PERMISSION_MODES);
|
|
17183
|
+
var RcSessionSummarySchema = import_zod10.z.strictObject({
|
|
17184
|
+
id: import_zod10.z.string(),
|
|
17185
|
+
createdAt: import_zod10.z.number(),
|
|
17186
|
+
lastSeenAt: import_zod10.z.number()
|
|
17187
|
+
});
|
|
17188
|
+
function workerFactSchema(value) {
|
|
17189
|
+
return import_zod10.z.strictObject({ value, observedAt: import_zod10.z.number() });
|
|
17190
|
+
}
|
|
17191
|
+
var RcQuestionOptionSchema = import_zod10.z.strictObject({
|
|
17192
|
+
label: import_zod10.z.string(),
|
|
17193
|
+
description: import_zod10.z.string().optional()
|
|
17194
|
+
});
|
|
17195
|
+
var RcPendingQuestionSchema = import_zod10.z.strictObject({
|
|
17196
|
+
question: import_zod10.z.string(),
|
|
17197
|
+
header: import_zod10.z.string().optional(),
|
|
17198
|
+
multiSelect: import_zod10.z.boolean(),
|
|
17199
|
+
options: import_zod10.z.readonly(import_zod10.z.array(RcQuestionOptionSchema))
|
|
17200
|
+
});
|
|
17201
|
+
var RcPendingRequestSummarySchema = import_zod10.z.strictObject({
|
|
17202
|
+
sessionId: import_zod10.z.string(),
|
|
17203
|
+
requestId: import_zod10.z.string(),
|
|
17204
|
+
type: import_zod10.z.string(),
|
|
17205
|
+
summary: import_zod10.z.string(),
|
|
17206
|
+
questions: import_zod10.z.readonly(import_zod10.z.array(RcPendingQuestionSchema)).optional(),
|
|
17207
|
+
oversized: import_zod10.z.literal(true).optional(),
|
|
17208
|
+
unanswerable: import_zod10.z.string().optional(),
|
|
17209
|
+
observedAt: import_zod10.z.number()
|
|
17210
|
+
});
|
|
17211
|
+
var RcSessionStatusSchema = import_zod10.z.strictObject({
|
|
17212
|
+
...RcSessionSummarySchema.shape,
|
|
17213
|
+
workerState: workerFactSchema(import_zod10.z.string()).optional(),
|
|
17214
|
+
workerIdleSeconds: workerFactSchema(import_zod10.z.number()).optional(),
|
|
17215
|
+
pending: import_zod10.z.readonly(import_zod10.z.array(RcPendingRequestSummarySchema)),
|
|
17216
|
+
/** The identity the session runs as, when known; absent otherwise. */
|
|
17217
|
+
identity: import_zod10.z.string().optional(),
|
|
17218
|
+
/** The model the session last stated, when the door saw one. */
|
|
17219
|
+
model: import_zod10.z.string().optional(),
|
|
17220
|
+
/** The session's name from the Claude Code session registry, when the registry holds it. */
|
|
17221
|
+
name: import_zod10.z.string().optional(),
|
|
17222
|
+
/** The session process's id from the registry. */
|
|
17223
|
+
pid: import_zod10.z.number().optional(),
|
|
17224
|
+
/** The session's working directory, from its init event or the registry. */
|
|
17225
|
+
cwd: import_zod10.z.string().optional(),
|
|
17226
|
+
pendingDropped: import_zod10.z.int().positive().optional()
|
|
17227
|
+
});
|
|
17228
|
+
var RcStreamEnvelopeSchema = import_zod10.z.looseObject({
|
|
17229
|
+
/** The envelope's own event id, when the host sent one. */
|
|
17230
|
+
event_id: import_zod10.z.string().optional(),
|
|
17231
|
+
/** The envelope's event type, the discriminator a consumer switches on (`control_request`, `user`, and kin). */
|
|
17232
|
+
event_type: import_zod10.z.string(),
|
|
17233
|
+
/** The sequence number the host assigned, the value a resume continues after. */
|
|
17234
|
+
sequence_num: import_zod10.z.int(),
|
|
17235
|
+
/** Who emitted the event (`worker` for the CLI's half, a client id for a client's). */
|
|
17236
|
+
source: import_zod10.z.string(),
|
|
17237
|
+
/** The event's payload, carried verbatim: its shape is the payload family's, narrowed by whichever consumer needs it. Optional in the schema's own type because the door forwards the host's envelope as it arrived, asserting only the fields it relies on itself. */
|
|
17238
|
+
payload: import_zod10.z.unknown().optional(),
|
|
17239
|
+
/** When the host created the event; the protocol's own type for this field is not established here, so it is forwarded rather than asserted. */
|
|
17240
|
+
created_at: import_zod10.z.unknown().optional()
|
|
17241
|
+
});
|
|
17242
|
+
var RcStreamEventSchema = import_zod10.z.strictObject({
|
|
17243
|
+
session: import_zod10.z.string(),
|
|
17244
|
+
envelope: RcStreamEnvelopeSchema
|
|
17245
|
+
});
|
|
17246
|
+
var RcRateLimitWindowSchema = import_zod10.z.looseObject({
|
|
17247
|
+
/** The fraction of the window used, usually between 0 and 1, above 1 when usage legitimately runs past the window's cap (the CLI's own field description states both). */
|
|
17248
|
+
utilization: import_zod10.z.number().optional(),
|
|
17249
|
+
/** When the window resets, in unix epoch seconds: the unit is the CLI's own field description, stated in the 2.1.289 bundle's schema. */
|
|
17250
|
+
resetsAt: import_zod10.z.number().optional()
|
|
17251
|
+
});
|
|
17252
|
+
var RcRateLimitInfoSchema = import_zod10.z.looseObject({
|
|
17253
|
+
/** The limiting window's own status (`allowed`, `allowed_warning`, `rejected`), asserted only as a string because the vocabulary grows with the CLI. */
|
|
17254
|
+
status: import_zod10.z.string(),
|
|
17255
|
+
/** When the limiting window resets, in unix epoch seconds. */
|
|
17256
|
+
resetsAt: import_zod10.z.number().optional(),
|
|
17257
|
+
/** Which window the top-level fields describe (`five_hour`, `seven_day`, and kin), the payload's own name for it. */
|
|
17258
|
+
rateLimitType: import_zod10.z.string().optional(),
|
|
17259
|
+
/** The fraction of the limiting window used, on the same scale the per-window utilizations carry. */
|
|
17260
|
+
utilization: import_zod10.z.number().optional(),
|
|
17261
|
+
/** Whether usage beyond the plan (extra usage) is currently covering the overflow, the payload's own flag for it. */
|
|
17262
|
+
isUsingOverage: import_zod10.z.boolean().optional(),
|
|
17263
|
+
/** The overage's own status, the same vocabulary the limiting window's `status` carries. */
|
|
17264
|
+
overageStatus: import_zod10.z.string().optional(),
|
|
17265
|
+
/** When the overage window resets, in unix epoch seconds. */
|
|
17266
|
+
overageResetsAt: import_zod10.z.number().optional(),
|
|
17267
|
+
/** Each subscription window the account's response headers carried: the session (five-hour), weekly (seven-day), and overage-included weekly windows, each present only when the account's responses carry it. */
|
|
17268
|
+
unifiedWindows: import_zod10.z.looseObject({ five_hour: RcRateLimitWindowSchema.optional(), seven_day: RcRateLimitWindowSchema.optional(), seven_day_overage_included: RcRateLimitWindowSchema.optional() }).optional()
|
|
17269
|
+
});
|
|
17270
|
+
var RcLiveRateLimitSchema = import_zod10.z.strictObject({
|
|
17271
|
+
session: import_zod10.z.string(),
|
|
17272
|
+
observedAt: import_zod10.z.number(),
|
|
17273
|
+
rateLimit: RcRateLimitInfoSchema
|
|
17274
|
+
});
|
|
17275
|
+
var RcSessionQuerySchema = import_zod10.z.strictObject({
|
|
17276
|
+
session: import_zod10.z.string().min(1).optional()
|
|
17277
|
+
});
|
|
17278
|
+
var RcSendInputSchema = import_zod10.z.strictObject({
|
|
17279
|
+
session: import_zod10.z.string().min(1),
|
|
17280
|
+
text: import_zod10.z.string().min(1)
|
|
17281
|
+
});
|
|
17282
|
+
var RcQuestionSelectionSchema = import_zod10.z.union([import_zod10.z.string().min(1), import_zod10.z.int().positive(), import_zod10.z.strictObject({ text: import_zod10.z.string().refine((text) => text.trim() !== "", { message: "free text must not be blank" }) })]);
|
|
17283
|
+
var RcQuestionChoicesSchema = import_zod10.z.array(import_zod10.z.array(RcQuestionSelectionSchema).min(1)).min(1);
|
|
17284
|
+
var RcAnswerInputSchema = import_zod10.z.strictObject({
|
|
17285
|
+
session: import_zod10.z.string().min(1),
|
|
17286
|
+
request: import_zod10.z.string().min(1),
|
|
17287
|
+
approve: import_zod10.z.boolean(),
|
|
17288
|
+
text: import_zod10.z.string().optional(),
|
|
17289
|
+
choices: RcQuestionChoicesSchema.optional()
|
|
17290
|
+
}).refine((input) => !input.approve || input.text === void 0 || input.text === "", { message: "an approval carries no text (the protocol's allow result has no message field); text is the denial message" }).refine((input) => input.approve || input.choices === void 0, { message: "choices answer a question, so they come with approve: true; a denial dismisses the question" });
|
|
17291
|
+
var RcInterruptInputSchema = import_zod10.z.strictObject({
|
|
17292
|
+
session: import_zod10.z.string().min(1)
|
|
17293
|
+
});
|
|
17294
|
+
var RcSetModelInputSchema = import_zod10.z.strictObject({
|
|
17295
|
+
session: import_zod10.z.string().min(1),
|
|
17296
|
+
model: import_zod10.z.string().min(1)
|
|
17297
|
+
});
|
|
17298
|
+
var RcSetPermissionModeInputSchema = import_zod10.z.strictObject({
|
|
17299
|
+
session: import_zod10.z.string().min(1),
|
|
17300
|
+
mode: RcPermissionModeSchema
|
|
17301
|
+
});
|
|
17302
|
+
var RcEndSessionInputSchema = import_zod10.z.strictObject({
|
|
17303
|
+
session: import_zod10.z.string().min(1),
|
|
17304
|
+
reason: import_zod10.z.string().min(1).optional()
|
|
17305
|
+
});
|
|
17306
|
+
var RcGetUsageInputSchema = import_zod10.z.strictObject({
|
|
17307
|
+
session: import_zod10.z.string().min(1),
|
|
17308
|
+
skipBehaviors: import_zod10.z.boolean().optional()
|
|
17309
|
+
});
|
|
17310
|
+
var RcGetContextUsageInputSchema = import_zod10.z.strictObject({
|
|
17311
|
+
session: import_zod10.z.string().min(1),
|
|
17312
|
+
detail: import_zod10.z.enum(RC_CONTEXT_USAGE_DETAILS).optional()
|
|
17313
|
+
});
|
|
17314
|
+
var RcReadFileInputSchema = import_zod10.z.strictObject({
|
|
17315
|
+
session: import_zod10.z.string().min(1),
|
|
17316
|
+
path: import_zod10.z.string().min(1),
|
|
17317
|
+
maxBytes: import_zod10.z.number().int().positive().optional(),
|
|
17318
|
+
encoding: import_zod10.z.enum(RC_READ_FILE_ENCODINGS).optional()
|
|
17319
|
+
});
|
|
17320
|
+
var RcFileSuggestionsInputSchema = import_zod10.z.strictObject({
|
|
17321
|
+
session: import_zod10.z.string().min(1),
|
|
17322
|
+
query: import_zod10.z.string()
|
|
17323
|
+
});
|
|
17324
|
+
var RcKeepAliveInputSchema = import_zod10.z.strictObject({
|
|
17325
|
+
session: import_zod10.z.string().min(1)
|
|
17326
|
+
});
|
|
17327
|
+
var RcMcpStatusInputSchema = import_zod10.z.strictObject({
|
|
17328
|
+
session: import_zod10.z.string().min(1)
|
|
17329
|
+
});
|
|
17330
|
+
var RcMcpReconnectInputSchema = import_zod10.z.strictObject({
|
|
17331
|
+
session: import_zod10.z.string().min(1),
|
|
17332
|
+
serverName: import_zod10.z.string().min(1)
|
|
17333
|
+
});
|
|
17334
|
+
var RcMcpAuthenticateInputSchema = import_zod10.z.strictObject({
|
|
17335
|
+
session: import_zod10.z.string().min(1),
|
|
17336
|
+
serverName: import_zod10.z.string().min(1),
|
|
17337
|
+
redirectUri: import_zod10.z.string().min(1)
|
|
17338
|
+
});
|
|
17339
|
+
var RcMcpOAuthCallbackUrlInputSchema = import_zod10.z.strictObject({
|
|
17340
|
+
session: import_zod10.z.string().min(1),
|
|
17341
|
+
serverName: import_zod10.z.string().min(1),
|
|
17342
|
+
callbackUrl: import_zod10.z.string().min(1)
|
|
17343
|
+
});
|
|
17344
|
+
var RcTeleportInputSchema = import_zod10.z.strictObject({
|
|
17345
|
+
session: import_zod10.z.string().min(1),
|
|
17346
|
+
marker: import_zod10.z.string().min(1)
|
|
17347
|
+
});
|
|
17348
|
+
var RcListOutputSchema = import_zod10.z.strictObject({ sessions: import_zod10.z.readonly(import_zod10.z.array(RcSessionSummarySchema)) });
|
|
17349
|
+
var RcStatusOutputSchema = import_zod10.z.strictObject({ statuses: import_zod10.z.readonly(import_zod10.z.array(RcSessionStatusSchema)) });
|
|
17350
|
+
var RcPendingOutputSchema = import_zod10.z.strictObject({
|
|
17351
|
+
pending: import_zod10.z.readonly(import_zod10.z.array(RcPendingRequestSummarySchema)),
|
|
17352
|
+
/** The sessions that had requests the door did not list (past the per-session cap, or with an id the protocol does not mint), each with how many: a question the caller expects may be among them. Absent when none did. */
|
|
17353
|
+
dropped: import_zod10.z.readonly(import_zod10.z.array(import_zod10.z.strictObject({ sessionId: import_zod10.z.string(), count: import_zod10.z.int().positive() }))).optional()
|
|
17354
|
+
});
|
|
17355
|
+
var RcWriteOutputSchema = import_zod10.z.strictObject({
|
|
17356
|
+
session: import_zod10.z.string(),
|
|
17357
|
+
sequenceNums: import_zod10.z.readonly(import_zod10.z.array(import_zod10.z.number()))
|
|
17358
|
+
});
|
|
17359
|
+
var RcControlWriteOutputSchema = import_zod10.z.strictObject({
|
|
17360
|
+
session: import_zod10.z.string(),
|
|
17361
|
+
request: import_zod10.z.string(),
|
|
17362
|
+
sequenceNums: import_zod10.z.readonly(import_zod10.z.array(import_zod10.z.number()))
|
|
17363
|
+
});
|
|
17364
|
+
var RcAnswerOutputSchema = import_zod10.z.strictObject({
|
|
17365
|
+
session: import_zod10.z.string(),
|
|
17366
|
+
request: import_zod10.z.string(),
|
|
17367
|
+
sequenceNums: import_zod10.z.readonly(import_zod10.z.array(import_zod10.z.number()))
|
|
17368
|
+
});
|
|
17369
|
+
|
|
17370
|
+
// src/frontdoor/rcControl.ts
|
|
16929
17371
|
var RC_PERMISSION_MODE_LIST = RC_PERMISSION_MODES.join(", ");
|
|
16930
17372
|
var CONTROL_PATH_PREFIX = "/__agent-shim/rc";
|
|
16931
17373
|
var CONTROL_BODY_CAP_BYTES = 10485760;
|
|
@@ -17182,11 +17624,20 @@ function createRcControlHandler(deps) {
|
|
|
17182
17624
|
return;
|
|
17183
17625
|
}
|
|
17184
17626
|
const text = "text" in parsed && typeof parsed.text === "string" ? parsed.text : void 0;
|
|
17627
|
+
const choices = "choices" in parsed ? RcQuestionChoicesSchema.safeParse(parsed.choices) : void 0;
|
|
17628
|
+
if (choices !== void 0 && !choices.success) {
|
|
17629
|
+
answerJson(response, HTTP_STATUS.badRequest, { error: 'choices must be one non-empty list per question of selections, each an option label, a one-based option number or {"text": ...}' });
|
|
17630
|
+
return;
|
|
17631
|
+
}
|
|
17632
|
+
if (choices !== void 0 && !parsed.approve) {
|
|
17633
|
+
answerJson(response, HTTP_STATUS.badRequest, { error: "choices answer a question, so they come with approve: true; a denial dismisses the question" });
|
|
17634
|
+
return;
|
|
17635
|
+
}
|
|
17185
17636
|
if (parsed.approve && text !== void 0 && text !== "") {
|
|
17186
17637
|
answerJson(response, HTTP_STATUS.badRequest, { error: "an approval carries no text (the protocol's allow result has no message field); text is the denial message" });
|
|
17187
17638
|
return;
|
|
17188
17639
|
}
|
|
17189
|
-
const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 : text });
|
|
17640
|
+
const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 : text, ...choices === void 0 ? {} : { choices: choices.data } });
|
|
17190
17641
|
if (result.ok) {
|
|
17191
17642
|
answerJson(response, HTTP_STATUS.ok, { session: parsed.session, request: parsed.request, sequenceNums: result.sequenceNums });
|
|
17192
17643
|
return;
|
|
@@ -17308,6 +17759,9 @@ function isRcSessionStatus(value) {
|
|
|
17308
17759
|
if ("workerState" in value && value.workerState !== void 0 && !isRcWorkerFact(value.workerState, (candidate) => typeof candidate === "string")) {
|
|
17309
17760
|
return false;
|
|
17310
17761
|
}
|
|
17762
|
+
if ("pendingDropped" in value && value.pendingDropped !== void 0 && typeof value.pendingDropped !== "number") {
|
|
17763
|
+
return false;
|
|
17764
|
+
}
|
|
17311
17765
|
if ("workerIdleSeconds" in value && value.workerIdleSeconds !== void 0 && !isRcWorkerFact(value.workerIdleSeconds, (candidate) => typeof candidate === "number")) {
|
|
17312
17766
|
return false;
|
|
17313
17767
|
}
|
|
@@ -17317,13 +17771,7 @@ function isRcSessionStatus(value) {
|
|
|
17317
17771
|
return value.pending.every((candidate) => isRcPendingRequestSummary(candidate));
|
|
17318
17772
|
}
|
|
17319
17773
|
function isRcPendingRequestSummary(value) {
|
|
17320
|
-
|
|
17321
|
-
return false;
|
|
17322
|
-
}
|
|
17323
|
-
if (!("sessionId" in value) || !("requestId" in value) || !("type" in value) || !("summary" in value) || !("observedAt" in value)) {
|
|
17324
|
-
return false;
|
|
17325
|
-
}
|
|
17326
|
-
return typeof value.sessionId === "string" && typeof value.requestId === "string" && typeof value.type === "string" && typeof value.summary === "string" && typeof value.observedAt === "number";
|
|
17774
|
+
return RcPendingRequestSummarySchema.safeParse(value).success;
|
|
17327
17775
|
}
|
|
17328
17776
|
function sequenceNumsOfBody(body) {
|
|
17329
17777
|
let parsed;
|
|
@@ -17459,7 +17907,7 @@ function frontDoorRcControl(transport, token) {
|
|
|
17459
17907
|
sendPrompt: async (sessionId, text) => await writeOf(`${CONTROL_PATH_PREFIX}/inject`, JSON.stringify({ session: sessionId, text }), (status, message) => `injecting into ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
17460
17908
|
answerRequest: async (sessionId, requestId, decision) => await writeOf(
|
|
17461
17909
|
`${CONTROL_PATH_PREFIX}/answer`,
|
|
17462
|
-
JSON.stringify({ session: sessionId, request: requestId, approve: decision.approve, ...decision.approve || decision.message === void 0 ? {} : { text: decision.message } }),
|
|
17910
|
+
JSON.stringify({ session: sessionId, request: requestId, approve: decision.approve, ...decision.approve || decision.message === void 0 ? {} : { text: decision.message }, ...decision.choices === void 0 ? {} : { choices: decision.choices } }),
|
|
17463
17911
|
(status, message) => `answering control request ${requestId} on ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
17464
17912
|
),
|
|
17465
17913
|
interruptSession: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/interrupt`, JSON.stringify({ session: sessionId }), (status, message) => `interrupting ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -17976,20 +18424,20 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
17976
18424
|
|
|
17977
18425
|
// src/frontdoor/rcSessionRegistry.ts
|
|
17978
18426
|
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
17979
|
-
var
|
|
18427
|
+
var import_zod22 = require("zod");
|
|
17980
18428
|
init_identityStore();
|
|
17981
18429
|
var REGISTRY_BRIDGE_PREFIX = "session_";
|
|
17982
18430
|
var DOOR_SESSION_PREFIX = "cse_";
|
|
17983
18431
|
var REGISTRY_DIR = "sessions";
|
|
17984
18432
|
var ENTRY_SUFFIX = ".json";
|
|
17985
18433
|
var RC_REGISTRY_ENTRY_MAX_BYTES = 8192;
|
|
17986
|
-
var RegistryEntrySchema =
|
|
17987
|
-
sessionId:
|
|
17988
|
-
pid:
|
|
17989
|
-
bridgeSessionId:
|
|
17990
|
-
cwd:
|
|
17991
|
-
name:
|
|
17992
|
-
updatedAt:
|
|
18434
|
+
var RegistryEntrySchema = import_zod22.z.looseObject({
|
|
18435
|
+
sessionId: import_zod22.z.string().min(1),
|
|
18436
|
+
pid: import_zod22.z.int().positive(),
|
|
18437
|
+
bridgeSessionId: import_zod22.z.union([import_zod22.z.string().startsWith(REGISTRY_BRIDGE_PREFIX), import_zod22.z.string().startsWith(DOOR_SESSION_PREFIX)]),
|
|
18438
|
+
cwd: import_zod22.z.string().optional(),
|
|
18439
|
+
name: import_zod22.z.string().optional(),
|
|
18440
|
+
updatedAt: import_zod22.z.number().optional()
|
|
17993
18441
|
});
|
|
17994
18442
|
function supersedes(candidate, kept) {
|
|
17995
18443
|
return candidate.updatedAt > kept.updatedAt || candidate.updatedAt === kept.updatedAt && candidate.session.pid > kept.session.pid;
|
|
@@ -18103,11 +18551,11 @@ var import_node_path32 = __toESM(require("node:path"), 1);
|
|
|
18103
18551
|
function isSafeSessionId(sessionId) {
|
|
18104
18552
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
18105
18553
|
}
|
|
18106
|
-
function
|
|
18554
|
+
function isRecord7(value) {
|
|
18107
18555
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18108
18556
|
}
|
|
18109
18557
|
function credentialOfJson(parsed) {
|
|
18110
|
-
if (!
|
|
18558
|
+
if (!isRecord7(parsed)) {
|
|
18111
18559
|
return void 0;
|
|
18112
18560
|
}
|
|
18113
18561
|
const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
|
|
@@ -18137,7 +18585,7 @@ function createRcCredentialStore(fs17, dir) {
|
|
|
18137
18585
|
} catch {
|
|
18138
18586
|
return void 0;
|
|
18139
18587
|
}
|
|
18140
|
-
return
|
|
18588
|
+
return isRecord7(parsed) ? parsed : void 0;
|
|
18141
18589
|
};
|
|
18142
18590
|
return {
|
|
18143
18591
|
read: (sessionId) => {
|
|
@@ -18188,175 +18636,443 @@ var import_server2 = require("@orpc/server");
|
|
|
18188
18636
|
var import_node2 = require("@orpc/server/node");
|
|
18189
18637
|
var import_undici = require("undici");
|
|
18190
18638
|
init_package();
|
|
18639
|
+
|
|
18640
|
+
// src/supervise/compactTimeout.ts
|
|
18641
|
+
var COMPACT_TIMEOUT_MS = 9e5;
|
|
18642
|
+
|
|
18643
|
+
// src/frontdoor/rcApi.ts
|
|
18191
18644
|
init_capability();
|
|
18192
18645
|
|
|
18193
|
-
// src/frontdoor/
|
|
18194
|
-
var
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
18202
|
-
|
|
18646
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18647
|
+
var import_zod23 = require("zod");
|
|
18648
|
+
|
|
18649
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
18650
|
+
var import_promises = require("node:timers/promises");
|
|
18651
|
+
|
|
18652
|
+
// src/supervise/sessionControl.ts
|
|
18653
|
+
var RESULT_POLL_MS = 250;
|
|
18654
|
+
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
18655
|
+
|
|
18656
|
+
// src/frontdoor/rcSelfHostCommands.ts
|
|
18657
|
+
var RC_PERSON_CLIENT_PLATFORM = "web_claude_ai";
|
|
18658
|
+
async function writeRcPersonMessage(deps, sessionId, text) {
|
|
18659
|
+
const credential = deps.credentialOf(sessionId);
|
|
18660
|
+
if (credential === void 0) {
|
|
18661
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
18662
|
+
}
|
|
18663
|
+
if (credential.authorization === void 0) {
|
|
18664
|
+
return noOAuthCredentialResult(sessionId);
|
|
18665
|
+
}
|
|
18666
|
+
const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text)));
|
|
18667
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
18668
|
+
if (bytes > CONTROL_BODY_CAP_BYTES) {
|
|
18669
|
+
return { ok: false, message: `the command for session ${sessionId} makes an event write of ${String(bytes)} bytes, over the ${String(CONTROL_BODY_CAP_BYTES)} bytes the door's self-hosted surface reads; shorten its arguments` };
|
|
18670
|
+
}
|
|
18671
|
+
let answer;
|
|
18672
|
+
try {
|
|
18673
|
+
answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders({ ...credential, anthropicClientPlatform: RC_PERSON_CLIENT_PLATFORM }), body);
|
|
18674
|
+
} catch (error) {
|
|
18675
|
+
return { ok: false, message: `the door could not write to its own self-hosted surface for session ${sessionId}: ${error instanceof Error ? error.message : String(error)}` };
|
|
18676
|
+
}
|
|
18677
|
+
const result = rcEventWriteResultFromAnswer(answer);
|
|
18678
|
+
if (result.ok) {
|
|
18679
|
+
deps.noteSequenceNums(sessionId, result.sequenceNums);
|
|
18680
|
+
}
|
|
18681
|
+
return result;
|
|
18203
18682
|
}
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
payload
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
}
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18250
|
-
}
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
}
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
}
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
}
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
}
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
}
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
});
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
}
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
}
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
}
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18683
|
+
function isRecord8(value) {
|
|
18684
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18685
|
+
}
|
|
18686
|
+
function rcLocalCommandAnswerOf(event, command, args) {
|
|
18687
|
+
const payload = event.envelope.payload;
|
|
18688
|
+
if (!isRecord8(payload) || payload.type !== "assistant" || !isRecord8(payload.local_command_run) || payload.local_command_run.command !== command || payload.local_command_run.args !== args) {
|
|
18689
|
+
return void 0;
|
|
18690
|
+
}
|
|
18691
|
+
const message = payload.message;
|
|
18692
|
+
if (!isRecord8(message) || !Array.isArray(message.content)) {
|
|
18693
|
+
return void 0;
|
|
18694
|
+
}
|
|
18695
|
+
const blocks = message.content;
|
|
18696
|
+
const text = blocks.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
18697
|
+
const outcome = isRecord8(payload.local_command_outcome) && typeof payload.local_command_outcome.kind === "string" ? payload.local_command_outcome.kind : void 0;
|
|
18698
|
+
return { text, outcome };
|
|
18699
|
+
}
|
|
18700
|
+
function rcManualCompactBoundaryOf(event) {
|
|
18701
|
+
const payload = event.envelope.payload;
|
|
18702
|
+
if (!isRecord8(payload) || payload.type !== "system" || payload.subtype !== "compact_boundary" || !isRecord8(payload.compact_metadata)) {
|
|
18703
|
+
return void 0;
|
|
18704
|
+
}
|
|
18705
|
+
const metadata = payload.compact_metadata;
|
|
18706
|
+
if (metadata.trigger !== "manual" || typeof metadata.pre_tokens !== "number" || typeof metadata.post_tokens !== "number") {
|
|
18707
|
+
return void 0;
|
|
18708
|
+
}
|
|
18709
|
+
return { trigger: metadata.trigger, preTokens: metadata.pre_tokens, postTokens: metadata.post_tokens };
|
|
18710
|
+
}
|
|
18711
|
+
function isPeerDelivery(event, text) {
|
|
18712
|
+
const payload = event.envelope.payload;
|
|
18713
|
+
if (!isRecord8(payload) || payload.type !== "user" || !isRecord8(payload.origin) || payload.origin.kind !== "peer" || !isRecord8(payload.message)) {
|
|
18714
|
+
return false;
|
|
18715
|
+
}
|
|
18716
|
+
return typeof payload.message.content === "string" && payload.message.content.includes(text);
|
|
18717
|
+
}
|
|
18718
|
+
var NO_GOAL_PREFIX = "No goal set";
|
|
18719
|
+
var ACTIVE_GOAL_PATTERN = /^Goal active: (?<condition>[\s\S]*?) \((?:not yet evaluated|(?<iterations>\d+) turns?)\)(?:\nLast check: (?<lastCheck>[\s\S]*))?$/u;
|
|
18720
|
+
function parseRcGoalOutput(output) {
|
|
18721
|
+
if (output.startsWith(NO_GOAL_PREFIX)) {
|
|
18722
|
+
return { goal: null };
|
|
18723
|
+
}
|
|
18724
|
+
const groups = ACTIVE_GOAL_PATTERN.exec(output)?.groups;
|
|
18725
|
+
const condition = groups?.condition;
|
|
18726
|
+
if (condition === void 0) {
|
|
18727
|
+
return void 0;
|
|
18728
|
+
}
|
|
18729
|
+
return { goal: { condition, iterations: groups?.iterations === void 0 ? 0 : Number(groups.iterations), ...groups?.lastCheck === void 0 ? {} : { lastCheck: groups.lastCheck } } };
|
|
18730
|
+
}
|
|
18731
|
+
var GOAL_CLEARED_PREFIX = "Goal cleared: ";
|
|
18732
|
+
var GOAL_SET_PREFIX = "Goal set: ";
|
|
18733
|
+
function commandLine(command) {
|
|
18734
|
+
if (command.kind === "goal-set") {
|
|
18735
|
+
return { name: "goal", args: command.condition };
|
|
18736
|
+
}
|
|
18737
|
+
if (command.kind === "compact") {
|
|
18738
|
+
return { name: "compact", args: command.instructions ?? "" };
|
|
18739
|
+
}
|
|
18740
|
+
return { name: "goal", args: command.kind === "goal-clear" ? "clear" : "" };
|
|
18741
|
+
}
|
|
18742
|
+
function recognise(command, event, name, args) {
|
|
18743
|
+
if (command.kind === "compact") {
|
|
18744
|
+
const boundary = rcManualCompactBoundaryOf(event);
|
|
18745
|
+
if (boundary !== void 0) {
|
|
18746
|
+
return { ok: true, report: boundary };
|
|
18747
|
+
}
|
|
18748
|
+
}
|
|
18749
|
+
const answer = rcLocalCommandAnswerOf(event, name, args);
|
|
18750
|
+
if (answer === void 0) {
|
|
18751
|
+
return void 0;
|
|
18752
|
+
}
|
|
18753
|
+
if (answer.outcome === "failed") {
|
|
18754
|
+
return { ok: false, message: `the worker reported /${name} failed: ${answer.text}` };
|
|
18755
|
+
}
|
|
18756
|
+
if (command.kind === "goal-get") {
|
|
18757
|
+
const report = parseRcGoalOutput(answer.text);
|
|
18758
|
+
return report === void 0 ? { ok: false, message: `the worker answered /goal with text the verified versions never produce: ${answer.text}` } : { ok: true, report };
|
|
18759
|
+
}
|
|
18760
|
+
if (command.kind === "goal-set") {
|
|
18761
|
+
return answer.text.startsWith(GOAL_SET_PREFIX) ? { ok: true, report: { condition: answer.text.slice(GOAL_SET_PREFIX.length) } } : { ok: false, message: `the worker did not set the goal: ${answer.text}` };
|
|
18762
|
+
}
|
|
18763
|
+
if (command.kind === "goal-clear") {
|
|
18764
|
+
if (answer.text.startsWith(GOAL_CLEARED_PREFIX)) {
|
|
18765
|
+
return { ok: true, report: { cleared: answer.text.slice(GOAL_CLEARED_PREFIX.length) } };
|
|
18766
|
+
}
|
|
18767
|
+
return answer.text === NO_GOAL_PREFIX ? { ok: true, report: { cleared: null } } : { ok: false, message: `the worker answered /goal clear with text the verified versions never produce: ${answer.text}` };
|
|
18768
|
+
}
|
|
18769
|
+
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
18770
|
+
}
|
|
18771
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
18772
|
+
const { name, args } = commandLine(command);
|
|
18773
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
18774
|
+
const early = [];
|
|
18775
|
+
let after;
|
|
18776
|
+
let settle;
|
|
18777
|
+
const judge = (event) => {
|
|
18778
|
+
if (after === void 0) {
|
|
18779
|
+
early.push(event);
|
|
18780
|
+
return;
|
|
18781
|
+
}
|
|
18782
|
+
if (event.envelope.sequence_num <= after || event.envelope.source !== "worker") {
|
|
18783
|
+
return;
|
|
18784
|
+
}
|
|
18785
|
+
if (isPeerDelivery(event, text)) {
|
|
18786
|
+
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message instead of running it, so it did not read the write as a person's` });
|
|
18787
|
+
return;
|
|
18788
|
+
}
|
|
18789
|
+
const outcome = recognise(command, event, name, args);
|
|
18790
|
+
if (outcome !== void 0) {
|
|
18791
|
+
settle?.(outcome);
|
|
18792
|
+
}
|
|
18793
|
+
};
|
|
18794
|
+
const detach = deps.fanout.subscribe(sessionId, judge);
|
|
18795
|
+
let cancelTimer;
|
|
18796
|
+
const onAbort = () => {
|
|
18797
|
+
settle?.({ ok: false, message: `the request for ${text} on session ${sessionId} was aborted before the worker answered` });
|
|
18798
|
+
};
|
|
18799
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
18800
|
+
try {
|
|
18801
|
+
const answered = new Promise((resolve) => {
|
|
18802
|
+
settle = resolve;
|
|
18803
|
+
});
|
|
18804
|
+
const written = await writeRcPersonMessage(deps.personWrite, sessionId, text);
|
|
18805
|
+
if (!written.ok) {
|
|
18806
|
+
return written;
|
|
18807
|
+
}
|
|
18808
|
+
if (signal.aborted) {
|
|
18809
|
+
return { ok: false, message: `the request for ${text} on session ${sessionId} was aborted after it was written (sequence_num ${written.sequenceNums.join(", ")})` };
|
|
18810
|
+
}
|
|
18811
|
+
after = Math.max(...written.sequenceNums);
|
|
18812
|
+
const bound = waitMs ?? deps.defaultWaitMs;
|
|
18813
|
+
cancelTimer = deps.setTimer(() => {
|
|
18814
|
+
settle?.({ ok: false, message: `${text} was delivered to session ${sessionId} (sequence_num ${written.sequenceNums.join(", ")}) but the worker reported no outcome within ${String(bound)} ms; it may still be queued behind a running turn, so read the session's stream before sending it again` });
|
|
18815
|
+
}, bound);
|
|
18816
|
+
for (const event of early.splice(0)) {
|
|
18817
|
+
judge(event);
|
|
18818
|
+
}
|
|
18819
|
+
return await answered;
|
|
18820
|
+
} finally {
|
|
18821
|
+
signal.removeEventListener("abort", onAbort);
|
|
18822
|
+
cancelTimer?.();
|
|
18823
|
+
detach();
|
|
18824
|
+
}
|
|
18825
|
+
}
|
|
18826
|
+
function createRcClaudeCodeVersions(fanout) {
|
|
18827
|
+
const versions = /* @__PURE__ */ new Map();
|
|
18828
|
+
fanout.subscribe(void 0, (event) => {
|
|
18829
|
+
const payload = event.envelope.payload;
|
|
18830
|
+
if (event.envelope.source === "worker" && isRecord8(payload) && payload.type === "system" && payload.subtype === "init" && typeof payload.claude_code_version === "string") {
|
|
18831
|
+
versions.set(event.session, payload.claude_code_version);
|
|
18832
|
+
}
|
|
18833
|
+
});
|
|
18834
|
+
return {
|
|
18835
|
+
versionOf: (sessionId) => versions.get(sessionId),
|
|
18836
|
+
sweep: (isTracked) => {
|
|
18837
|
+
for (const sessionId of [...versions.keys()]) {
|
|
18838
|
+
if (!isTracked(sessionId)) {
|
|
18839
|
+
versions.delete(sessionId);
|
|
18840
|
+
}
|
|
18841
|
+
}
|
|
18842
|
+
}
|
|
18843
|
+
};
|
|
18844
|
+
}
|
|
18845
|
+
|
|
18846
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
18847
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
18848
|
+
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
18849
|
+
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
18850
|
+
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
18851
|
+
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
18852
|
+
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
18853
|
+
function unverifiedVersionMessage(sessionId, version, source) {
|
|
18854
|
+
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
18855
|
+
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and compaction control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal and compaction control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
|
|
18856
|
+
}
|
|
18857
|
+
function unsupportedMessage(sessionId) {
|
|
18858
|
+
return `session ${sessionId} was not launched under an agent-shim supervisor, so the door has no in-process channel into it, and it is not on the door's own self-hosted surface. Over the real Remote Control service, Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} runs a slash command only when a person's app wrote it and treats any other writer as a peer, whose message the model reads as text, and the door does not claim to be a person's app on a service it does not run. Launch the session under a pool with resumeOnLimit (which supervises it), or run it against the door's self-hosted surface.`;
|
|
18859
|
+
}
|
|
18860
|
+
function createRcSessionCommands(deps) {
|
|
18861
|
+
const queues = /* @__PURE__ */ new Map();
|
|
18862
|
+
const serialised = async (sessionId, work) => {
|
|
18863
|
+
const before = queues.get(sessionId) ?? Promise.resolve();
|
|
18864
|
+
const run = before.then(work, work);
|
|
18865
|
+
const settled = run.then(() => void 0, () => void 0);
|
|
18866
|
+
queues.set(sessionId, settled);
|
|
18867
|
+
try {
|
|
18868
|
+
return await run;
|
|
18869
|
+
} finally {
|
|
18870
|
+
if (queues.get(sessionId) === settled) {
|
|
18871
|
+
queues.delete(sessionId);
|
|
18872
|
+
}
|
|
18873
|
+
}
|
|
18874
|
+
};
|
|
18875
|
+
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
18876
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
18877
|
+
if (signal.aborted) {
|
|
18878
|
+
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
18879
|
+
}
|
|
18880
|
+
const target = await deps.supervisedOf(sessionId);
|
|
18881
|
+
if (target !== void 0 && "refused" in target) {
|
|
18882
|
+
return { ok: false, message: target.refused };
|
|
18883
|
+
}
|
|
18884
|
+
if (target !== void 0) {
|
|
18885
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
18886
|
+
return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
|
|
18887
|
+
}
|
|
18888
|
+
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
18889
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18890
|
+
const bounded3 = AbortSignal.any([signal, timeout]);
|
|
18891
|
+
try {
|
|
18892
|
+
return await actions.supervised(target, bounded3, waitMs);
|
|
18893
|
+
} catch (error) {
|
|
18894
|
+
if (timeout.aborted) {
|
|
18895
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs)} ms. A request the plugin had not started is withdrawn; one it had started runs once the session is idle (a turn waiting on a permission prompt holds it), so read the session's goal or transcript before asking again` };
|
|
18896
|
+
}
|
|
18897
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
18898
|
+
}
|
|
18899
|
+
}
|
|
18900
|
+
if (!deps.isObserved(sessionId)) {
|
|
18901
|
+
return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
18902
|
+
}
|
|
18903
|
+
if (deps.selfHost !== void 0) {
|
|
18904
|
+
const unavailable = deps.selfHost.unavailable();
|
|
18905
|
+
if (unavailable !== void 0) {
|
|
18906
|
+
return { ok: false, message: `session ${sessionId} was not launched under an agent-shim supervisor, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
18907
|
+
}
|
|
18908
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
18909
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
18910
|
+
return { ok: false, message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
18911
|
+
}
|
|
18912
|
+
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
18913
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18914
|
+
const result = await actions.selfHosted(deps.selfHost, AbortSignal.any([signal, timeout]));
|
|
18915
|
+
if (!result.ok && timeout.aborted) {
|
|
18916
|
+
return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
|
|
18917
|
+
}
|
|
18918
|
+
return result;
|
|
18919
|
+
}
|
|
18920
|
+
return { ok: false, message: unsupportedMessage(sessionId) };
|
|
18921
|
+
});
|
|
18922
|
+
const transcriptGoal = async (sessionId, target) => {
|
|
18923
|
+
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
18924
|
+
if (goal === void 0) {
|
|
18925
|
+
return { ok: false, message: `session ${sessionId}'s supervisor has not recorded its transcript yet, which is where its goal is read from; retry once it has finished a turn` };
|
|
18926
|
+
}
|
|
18927
|
+
return { ok: true, report: goal };
|
|
18928
|
+
};
|
|
18929
|
+
const settledGoal = async (sessionId, target, signal, holds) => {
|
|
18930
|
+
for (; ; ) {
|
|
18931
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18932
|
+
if (!read.ok || holds(read.report) || signal.aborted) {
|
|
18933
|
+
return read;
|
|
18934
|
+
}
|
|
18935
|
+
await (0, import_promises.setTimeout)(RESULT_POLL_MS);
|
|
18936
|
+
}
|
|
18937
|
+
};
|
|
18938
|
+
const waitOf = (options) => options.waitMs;
|
|
18939
|
+
return {
|
|
18940
|
+
/** Reads the session's goal: from the transcript for a supervised session, with no effect on it; by running `/goal` on the self-hosted surface otherwise. */
|
|
18941
|
+
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18942
|
+
supervised: async (target) => {
|
|
18943
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18944
|
+
return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
|
|
18945
|
+
},
|
|
18946
|
+
selfHosted: async (selfHost, signal) => {
|
|
18947
|
+
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18948
|
+
return read.ok ? { ok: true, report: { route: "self-hosted", goal: read.report.goal } } : read;
|
|
18949
|
+
}
|
|
18950
|
+
}),
|
|
18951
|
+
/**
|
|
18952
|
+
* Sets the session's goal: the goal check then keeps the session working until the condition holds, and the condition reaches its model as a directive (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: an empty condition, one `/goal` reads as a clear, and one longer than it accepts. The answer names the goal it replaced.
|
|
18953
|
+
*/
|
|
18954
|
+
goalSet: async (sessionId, condition, options = {}) => {
|
|
18955
|
+
const trimmed = condition.trim();
|
|
18956
|
+
if (trimmed === "") {
|
|
18957
|
+
return { ok: false, message: "a goal set needs a non-empty condition" };
|
|
18958
|
+
}
|
|
18959
|
+
if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
|
|
18960
|
+
return { ok: false, message: `"${trimmed}" cannot be set as a goal condition: /goal reads ${RC_GOAL_CLEAR_WORDS.join(", ")} as a request to clear the goal, so use the clear verb for that` };
|
|
18961
|
+
}
|
|
18962
|
+
if (/[\r\n]/u.test(trimmed)) {
|
|
18963
|
+
return { ok: false, message: "a goal condition is one line: /goal reads its condition from the line it is typed on, and both routes confirm the goal by the exact condition, so a condition spanning lines is refused rather than set as something else" };
|
|
18964
|
+
}
|
|
18965
|
+
if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
|
|
18966
|
+
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
18967
|
+
}
|
|
18968
|
+
return await onRoute(sessionId, options, {
|
|
18969
|
+
supervised: async (target, signal, waitMs) => {
|
|
18970
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18971
|
+
if (!before.ok) {
|
|
18972
|
+
return before;
|
|
18973
|
+
}
|
|
18974
|
+
await target.runGoal(trimmed, signal, waitMs);
|
|
18975
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal?.condition === trimmed);
|
|
18976
|
+
if (!after.ok) {
|
|
18977
|
+
return after;
|
|
18978
|
+
}
|
|
18979
|
+
return after.report?.condition === trimmed ? { ok: true, report: { route: "supervised", condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
|
|
18980
|
+
},
|
|
18981
|
+
selfHosted: async (selfHost, signal) => {
|
|
18982
|
+
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18983
|
+
if (!before.ok) {
|
|
18984
|
+
return before;
|
|
18985
|
+
}
|
|
18986
|
+
const set = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-set", condition: trimmed }, waitOf(options), signal);
|
|
18987
|
+
return set.ok ? { ok: true, report: { route: "self-hosted", condition: set.report.condition, superseded: before.report.goal?.condition ?? null } } : set;
|
|
18988
|
+
}
|
|
18989
|
+
});
|
|
18990
|
+
},
|
|
18991
|
+
/** Clears the session's goal and names the condition it cleared, or `null` when there was none, which is not a failure (clearing is idempotent). */
|
|
18992
|
+
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18993
|
+
supervised: async (target, signal, waitMs) => {
|
|
18994
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18995
|
+
if (!before.ok) {
|
|
18996
|
+
return before;
|
|
18997
|
+
}
|
|
18998
|
+
if (before.report === null) {
|
|
18999
|
+
return { ok: true, report: { route: "supervised", cleared: null } };
|
|
19000
|
+
}
|
|
19001
|
+
await target.runGoal("clear", signal, waitMs);
|
|
19002
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
19003
|
+
if (!after.ok) {
|
|
19004
|
+
return after;
|
|
19005
|
+
}
|
|
19006
|
+
return after.report === null ? { ok: true, report: { route: "supervised", cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
|
|
19007
|
+
},
|
|
19008
|
+
selfHosted: async (selfHost, signal) => {
|
|
19009
|
+
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
19010
|
+
return cleared.ok ? { ok: true, report: { route: "self-hosted", cleared: cleared.report.cleared } } : cleared;
|
|
19011
|
+
}
|
|
19012
|
+
}),
|
|
19013
|
+
/** Compacts the session's conversation, with custom summary instructions when given, and resolves with the outcome: the trigger and token counts, or the session's reason for not compacting. */
|
|
19014
|
+
compact: async (sessionId, options = {}) => {
|
|
19015
|
+
const instructions = options.instructions?.trim();
|
|
19016
|
+
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
19017
|
+
return await onRoute(sessionId, options, {
|
|
19018
|
+
supervised: async (target, signal, waitMs) => {
|
|
19019
|
+
const result = await target.compact(signal, given, waitMs);
|
|
19020
|
+
if (result.kind === "unchanged") {
|
|
19021
|
+
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
19022
|
+
}
|
|
19023
|
+
return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
19024
|
+
},
|
|
19025
|
+
selfHosted: async (selfHost, signal) => {
|
|
19026
|
+
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
19027
|
+
return compacted.ok ? { ok: true, report: { route: "self-hosted", ...compacted.report } } : compacted;
|
|
19028
|
+
}
|
|
19029
|
+
});
|
|
19030
|
+
}
|
|
19031
|
+
};
|
|
19032
|
+
}
|
|
19033
|
+
|
|
19034
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19035
|
+
var WaitMsSchema = import_zod23.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
19036
|
+
var RcGoalSessionInputSchema = import_zod23.z.strictObject({
|
|
19037
|
+
session: import_zod23.z.string().min(1),
|
|
19038
|
+
waitMs: WaitMsSchema
|
|
18325
19039
|
});
|
|
18326
|
-
var
|
|
18327
|
-
session:
|
|
18328
|
-
|
|
19040
|
+
var RcGoalSetInputSchema = import_zod23.z.strictObject({
|
|
19041
|
+
session: import_zod23.z.string().min(1),
|
|
19042
|
+
condition: import_zod23.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
19043
|
+
waitMs: WaitMsSchema
|
|
18329
19044
|
});
|
|
18330
|
-
var
|
|
18331
|
-
session:
|
|
18332
|
-
|
|
18333
|
-
redirectUri: import_zod22.z.string().min(1)
|
|
19045
|
+
var RcCompactInputSchema = import_zod23.z.strictObject({
|
|
19046
|
+
session: import_zod23.z.string().min(1),
|
|
19047
|
+
waitMs: WaitMsSchema
|
|
18334
19048
|
});
|
|
18335
|
-
var
|
|
18336
|
-
session:
|
|
18337
|
-
|
|
18338
|
-
|
|
19049
|
+
var RcCompactWithInstructionsInputSchema = import_zod23.z.strictObject({
|
|
19050
|
+
session: import_zod23.z.string().min(1),
|
|
19051
|
+
instructions: import_zod23.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
19052
|
+
waitMs: WaitMsSchema
|
|
18339
19053
|
});
|
|
18340
|
-
var
|
|
18341
|
-
session:
|
|
18342
|
-
|
|
19054
|
+
var commandAnswerShape = {
|
|
19055
|
+
session: import_zod23.z.string(),
|
|
19056
|
+
route: import_zod23.z.enum(["supervised", "self-hosted"])
|
|
19057
|
+
};
|
|
19058
|
+
var RcGoalGetOutputSchema = import_zod23.z.strictObject({
|
|
19059
|
+
...commandAnswerShape,
|
|
19060
|
+
goal: import_zod23.z.strictObject({ condition: import_zod23.z.string(), iterations: import_zod23.z.int().nonnegative(), lastCheck: import_zod23.z.string().optional() }).nullable()
|
|
18343
19061
|
});
|
|
18344
|
-
var
|
|
18345
|
-
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
session: import_zod22.z.string(),
|
|
18349
|
-
sequenceNums: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.number()))
|
|
19062
|
+
var RcGoalSetOutputSchema = import_zod23.z.strictObject({
|
|
19063
|
+
...commandAnswerShape,
|
|
19064
|
+
condition: import_zod23.z.string(),
|
|
19065
|
+
superseded: import_zod23.z.string().nullable()
|
|
18350
19066
|
});
|
|
18351
|
-
var
|
|
18352
|
-
|
|
18353
|
-
|
|
18354
|
-
sequenceNums: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.number()))
|
|
19067
|
+
var RcGoalClearOutputSchema = import_zod23.z.strictObject({
|
|
19068
|
+
...commandAnswerShape,
|
|
19069
|
+
cleared: import_zod23.z.string().nullable()
|
|
18355
19070
|
});
|
|
18356
|
-
var
|
|
18357
|
-
|
|
18358
|
-
|
|
18359
|
-
|
|
19071
|
+
var RcCompactOutputSchema = import_zod23.z.strictObject({
|
|
19072
|
+
...commandAnswerShape,
|
|
19073
|
+
trigger: import_zod23.z.string(),
|
|
19074
|
+
preTokens: import_zod23.z.number().optional(),
|
|
19075
|
+
postTokens: import_zod23.z.number().optional()
|
|
18360
19076
|
});
|
|
18361
19077
|
|
|
18362
19078
|
// src/frontdoor/rcApi.ts
|
|
@@ -18380,6 +19096,7 @@ function doorApiAuth(expectedToken) {
|
|
|
18380
19096
|
});
|
|
18381
19097
|
}
|
|
18382
19098
|
var RC_API_TAG = "remote-control";
|
|
19099
|
+
var RC_DIRECTIVE_TAG = "remote-control-directives";
|
|
18383
19100
|
function createRcApiRouter(deps) {
|
|
18384
19101
|
const authed = doorApiAuth(deps.expectedToken);
|
|
18385
19102
|
const delivered = (sessionId, result) => {
|
|
@@ -18397,6 +19114,13 @@ function createRcApiRouter(deps) {
|
|
|
18397
19114
|
}
|
|
18398
19115
|
return { request: result.requestId, sequenceNums: result.sequenceNums };
|
|
18399
19116
|
};
|
|
19117
|
+
const commanded = (sessionId, result) => {
|
|
19118
|
+
if (!result.ok) {
|
|
19119
|
+
throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
|
|
19120
|
+
}
|
|
19121
|
+
return { session: sessionId, ...result.report };
|
|
19122
|
+
};
|
|
19123
|
+
const optionsOf = (waitMs, signal) => ({ ...waitMs === void 0 ? {} : { waitMs }, ...signal === void 0 ? {} : { signal } });
|
|
18400
19124
|
return {
|
|
18401
19125
|
rc: {
|
|
18402
19126
|
list: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
@@ -18409,14 +19133,16 @@ function createRcApiRouter(deps) {
|
|
|
18409
19133
|
}),
|
|
18410
19134
|
pending: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/pending", summary: "Read the control requests awaiting an answer", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input }) => {
|
|
18411
19135
|
const pending = deps.pendingOf(input.session);
|
|
18412
|
-
|
|
19136
|
+
const statuses = deps.statusOf(input.session);
|
|
19137
|
+
if (input.session !== void 0 && statuses.length === 0) {
|
|
18413
19138
|
throw new import_client.ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
|
|
18414
19139
|
}
|
|
18415
|
-
|
|
19140
|
+
const dropped = statuses.flatMap((status) => status.pendingDropped === void 0 ? [] : [{ sessionId: status.id, count: status.pendingDropped }]);
|
|
19141
|
+
return { pending, ...dropped.length === 0 ? {} : { dropped } };
|
|
18416
19142
|
}),
|
|
18417
19143
|
send: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
|
|
18418
|
-
answer: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request", tags: [RC_API_TAG] })).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input }) => {
|
|
18419
|
-
const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text };
|
|
19144
|
+
answer: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request: approve or deny it, or choose the options of a pending question", tags: [RC_API_TAG] })).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input }) => {
|
|
19145
|
+
const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text, ...input.choices === void 0 ? {} : { choices: input.choices } };
|
|
18420
19146
|
return { session: input.session, request: input.request, sequenceNums: delivered(input.session, await deps.answer(input.session, input.request, decision)) };
|
|
18421
19147
|
}),
|
|
18422
19148
|
interrupt: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/interrupt", summary: "Interrupt a session's running turn", tags: [RC_API_TAG] })).input(RcInterruptInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.interrupt(input.session)) })),
|
|
@@ -18433,6 +19159,11 @@ function createRcApiRouter(deps) {
|
|
|
18433
19159
|
mcpAuthenticate: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/mcp-authenticate", summary: "Start OAuth for one MCP server on a session", tags: [RC_API_TAG] })).input(RcMcpAuthenticateInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpAuthenticate(input.session, input.serverName, input.redirectUri)) })),
|
|
18434
19160
|
mcpOAuthCallbackUrl: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/mcp-oauth-callback-url", summary: "Hand a completed MCP OAuth callback to a session", tags: [RC_API_TAG] })).input(RcMcpOAuthCallbackUrlInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpOAuthCallbackUrl(input.session, input.serverName, input.callbackUrl)) })),
|
|
18435
19161
|
teleport: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/teleport", summary: "Teleport a session to a conversation marker", tags: [RC_API_TAG] })).input(RcTeleportInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.teleport(input.session, input.marker)) })),
|
|
19162
|
+
goalGet: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/get", summary: "Read a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalGetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalGet(input.session, optionsOf(input.waitMs, signal)))),
|
|
19163
|
+
goalSet: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/set", summary: "Set a session's goal, a directive its model then works to", tags: [RC_DIRECTIVE_TAG] })).input(RcGoalSetInputSchema).output(RcGoalSetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalSet(input.session, input.condition, optionsOf(input.waitMs, signal)))),
|
|
19164
|
+
goalClear: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/clear", summary: "Clear a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalClearOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalClear(input.session, optionsOf(input.waitMs, signal)))),
|
|
19165
|
+
compact: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/compact", summary: "Compact a session's conversation", tags: [RC_API_TAG] })).input(RcCompactInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, optionsOf(input.waitMs, signal)))),
|
|
19166
|
+
compactWithInstructions: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/compact-with-instructions", summary: "Compact a session's conversation under summary instructions, a directive to its model", tags: [RC_DIRECTIVE_TAG] })).input(RcCompactWithInstructionsInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, { ...optionsOf(input.waitMs, signal), instructions: input.instructions }))),
|
|
18436
19167
|
subscribe: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output((0, import_server2.eventIterator)(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
18437
19168
|
const queue = [];
|
|
18438
19169
|
let wake;
|
|
@@ -18513,8 +19244,27 @@ function doorApiNodeHandlerOf(router, expectedToken) {
|
|
|
18513
19244
|
function createRcApiNodeHandler(deps) {
|
|
18514
19245
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
18515
19246
|
}
|
|
19247
|
+
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
19248
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
19249
|
+
function headersTimeoutOf(url, body) {
|
|
19250
|
+
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
19251
|
+
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
19252
|
+
}
|
|
19253
|
+
const parsed = body === void 0 ? void 0 : JSON.parse(body.toString("utf8"));
|
|
19254
|
+
const waitMs = typeof parsed === "object" && parsed !== null && "json" in parsed && typeof parsed.json === "object" && parsed.json !== null && "waitMs" in parsed.json && typeof parsed.json.waitMs === "number" ? parsed.json.waitMs : COMPACT_TIMEOUT_MS;
|
|
19255
|
+
return Math.min(waitMs + DEFAULT_HEADERS_TIMEOUT_MS, RC_SESSION_COMMAND_MAX_WAIT_MS);
|
|
19256
|
+
}
|
|
18516
19257
|
function frontDoorApiLink(port, ca, token) {
|
|
18517
|
-
const
|
|
19258
|
+
const dispatchers = /* @__PURE__ */ new Map();
|
|
19259
|
+
const dispatcherFor = (headersTimeout) => {
|
|
19260
|
+
const existing = dispatchers.get(headersTimeout);
|
|
19261
|
+
if (existing !== void 0) {
|
|
19262
|
+
return existing;
|
|
19263
|
+
}
|
|
19264
|
+
const created = new import_undici.Agent({ connect: { ca }, headersTimeout });
|
|
19265
|
+
dispatchers.set(headersTimeout, created);
|
|
19266
|
+
return created;
|
|
19267
|
+
};
|
|
18518
19268
|
return new import_fetch.RPCLink({
|
|
18519
19269
|
origin: `https://127.0.0.1:${String(port)}`,
|
|
18520
19270
|
url: RC_ORPC_PATH_PREFIX,
|
|
@@ -18527,7 +19277,7 @@ function frontDoorApiLink(port, ca, token) {
|
|
|
18527
19277
|
method: request4.method,
|
|
18528
19278
|
headers: [...request4.headers],
|
|
18529
19279
|
...body === void 0 ? {} : { body },
|
|
18530
|
-
dispatcher,
|
|
19280
|
+
dispatcher: dispatcherFor(headersTimeoutOf(request4.url, body)),
|
|
18531
19281
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
18532
19282
|
});
|
|
18533
19283
|
return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
|
|
@@ -18543,48 +19293,48 @@ init_cliError();
|
|
|
18543
19293
|
init_package();
|
|
18544
19294
|
|
|
18545
19295
|
// src/codex/appServerSchemas.ts
|
|
18546
|
-
var
|
|
19296
|
+
var import_zod24 = require("zod");
|
|
18547
19297
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
18548
|
-
var RateLimitWindowSchema =
|
|
18549
|
-
usedPercent:
|
|
18550
|
-
resetsAt:
|
|
18551
|
-
windowDurationMins:
|
|
18552
|
-
});
|
|
18553
|
-
var RateLimitSnapshotSchema =
|
|
18554
|
-
limitId:
|
|
18555
|
-
limitName:
|
|
18556
|
-
planType:
|
|
19298
|
+
var RateLimitWindowSchema = import_zod24.z.object({
|
|
19299
|
+
usedPercent: import_zod24.z.number(),
|
|
19300
|
+
resetsAt: import_zod24.z.number().nullish(),
|
|
19301
|
+
windowDurationMins: import_zod24.z.number().nullish()
|
|
19302
|
+
});
|
|
19303
|
+
var RateLimitSnapshotSchema = import_zod24.z.object({
|
|
19304
|
+
limitId: import_zod24.z.string().nullish(),
|
|
19305
|
+
limitName: import_zod24.z.string().nullish(),
|
|
19306
|
+
planType: import_zod24.z.string().nullish(),
|
|
18557
19307
|
primary: RateLimitWindowSchema.nullish(),
|
|
18558
19308
|
secondary: RateLimitWindowSchema.nullish(),
|
|
18559
|
-
rateLimitReachedType:
|
|
18560
|
-
spendControlReached:
|
|
18561
|
-
});
|
|
18562
|
-
var RateLimitResetCreditSchema =
|
|
18563
|
-
id:
|
|
18564
|
-
grantedAt:
|
|
18565
|
-
expiresAt:
|
|
18566
|
-
resetType:
|
|
18567
|
-
status:
|
|
18568
|
-
title:
|
|
18569
|
-
description:
|
|
18570
|
-
});
|
|
18571
|
-
var CodexAccountSchema =
|
|
18572
|
-
|
|
18573
|
-
|
|
18574
|
-
|
|
19309
|
+
rateLimitReachedType: import_zod24.z.string().nullish(),
|
|
19310
|
+
spendControlReached: import_zod24.z.boolean().nullish()
|
|
19311
|
+
});
|
|
19312
|
+
var RateLimitResetCreditSchema = import_zod24.z.object({
|
|
19313
|
+
id: import_zod24.z.string(),
|
|
19314
|
+
grantedAt: import_zod24.z.number(),
|
|
19315
|
+
expiresAt: import_zod24.z.number().nullish(),
|
|
19316
|
+
resetType: import_zod24.z.string(),
|
|
19317
|
+
status: import_zod24.z.string(),
|
|
19318
|
+
title: import_zod24.z.string().nullish(),
|
|
19319
|
+
description: import_zod24.z.string().nullish()
|
|
19320
|
+
});
|
|
19321
|
+
var CodexAccountSchema = import_zod24.z.discriminatedUnion("type", [
|
|
19322
|
+
import_zod24.z.object({ type: import_zod24.z.literal("apiKey") }),
|
|
19323
|
+
import_zod24.z.object({ type: import_zod24.z.literal("chatgpt"), email: import_zod24.z.string().nullable(), planType: import_zod24.z.string() }),
|
|
19324
|
+
import_zod24.z.object({ type: import_zod24.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod24.z.boolean().default(false) })
|
|
18575
19325
|
]);
|
|
18576
|
-
var CodexAccountReadSchema =
|
|
19326
|
+
var CodexAccountReadSchema = import_zod24.z.object({
|
|
18577
19327
|
account: CodexAccountSchema.nullable(),
|
|
18578
|
-
requiresOpenaiAuth:
|
|
19328
|
+
requiresOpenaiAuth: import_zod24.z.boolean()
|
|
18579
19329
|
});
|
|
18580
|
-
var CodexRateLimitsReadSchema =
|
|
19330
|
+
var CodexRateLimitsReadSchema = import_zod24.z.object({
|
|
18581
19331
|
rateLimits: RateLimitSnapshotSchema,
|
|
18582
|
-
rateLimitsByLimitId:
|
|
18583
|
-
rateLimitResetCredits:
|
|
18584
|
-
accountId:
|
|
18585
|
-
ordinaryUsageAllowed:
|
|
19332
|
+
rateLimitsByLimitId: import_zod24.z.record(import_zod24.z.string(), RateLimitSnapshotSchema).nullish(),
|
|
19333
|
+
rateLimitResetCredits: import_zod24.z.object({ availableCount: import_zod24.z.number(), credits: import_zod24.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
19334
|
+
accountId: import_zod24.z.string().nullish(),
|
|
19335
|
+
ordinaryUsageAllowed: import_zod24.z.boolean().nullish()
|
|
18586
19336
|
});
|
|
18587
|
-
var CodexInitializeResultSchema =
|
|
19337
|
+
var CodexInitializeResultSchema = import_zod24.z.object({ userAgent: import_zod24.z.string() });
|
|
18588
19338
|
|
|
18589
19339
|
// src/codex/appServer.ts
|
|
18590
19340
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -18911,7 +19661,7 @@ init_providersStore();
|
|
|
18911
19661
|
init_signIn();
|
|
18912
19662
|
init_realPorts();
|
|
18913
19663
|
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
18914
|
-
var
|
|
19664
|
+
var import_zod27 = require("zod");
|
|
18915
19665
|
init_envBool();
|
|
18916
19666
|
init_load();
|
|
18917
19667
|
init_schema();
|
|
@@ -18993,9 +19743,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
18993
19743
|
}
|
|
18994
19744
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
18995
19745
|
}
|
|
18996
|
-
var SettingsSecretsShapeSchema =
|
|
18997
|
-
env:
|
|
18998
|
-
hooks:
|
|
19746
|
+
var SettingsSecretsShapeSchema = import_zod27.z.looseObject({
|
|
19747
|
+
env: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.unknown()).optional(),
|
|
19748
|
+
hooks: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.array(import_zod27.z.unknown())).optional()
|
|
18999
19749
|
});
|
|
19000
19750
|
function hookCommandCountOf(group) {
|
|
19001
19751
|
if (typeof group !== "object" || group === null) {
|
|
@@ -19296,7 +20046,7 @@ function collectCheckReport(params) {
|
|
|
19296
20046
|
}
|
|
19297
20047
|
|
|
19298
20048
|
// src/checkReportSchema.ts
|
|
19299
|
-
var
|
|
20049
|
+
var import_zod29 = require("zod");
|
|
19300
20050
|
init_schema();
|
|
19301
20051
|
init_claudeVersion();
|
|
19302
20052
|
init_identity();
|
|
@@ -19360,124 +20110,124 @@ var DIAGNOSTIC_CODES = [
|
|
|
19360
20110
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
19361
20111
|
|
|
19362
20112
|
// src/usage/pickReportSchema.ts
|
|
19363
|
-
var
|
|
20113
|
+
var import_zod28 = require("zod");
|
|
19364
20114
|
init_plan2();
|
|
19365
|
-
var PoolPickCandidateViewSchema =
|
|
19366
|
-
identity:
|
|
20115
|
+
var PoolPickCandidateViewSchema = import_zod28.z.strictObject({
|
|
20116
|
+
identity: import_zod28.z.string(),
|
|
19367
20117
|
/** In pick order: `scored` has usable quota data, `unknown` has none and no plan known to bill by use, `pay-per-use` bills by use whether or not usage is recorded, `ineligible` is refused right now. */
|
|
19368
|
-
class:
|
|
20118
|
+
class: import_zod28.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
19369
20119
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
19370
|
-
score:
|
|
20120
|
+
score: import_zod28.z.number().optional(),
|
|
19371
20121
|
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
|
|
19372
|
-
scoreWindow:
|
|
20122
|
+
scoreWindow: import_zod28.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
19373
20123
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
19374
|
-
feasible:
|
|
20124
|
+
feasible: import_zod28.z.boolean(),
|
|
19375
20125
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
19376
|
-
blockedUntil:
|
|
20126
|
+
blockedUntil: import_zod28.z.iso.datetime().optional(),
|
|
19377
20127
|
plan: PlanClassSchema,
|
|
19378
20128
|
/** The facts behind the class and score, in the order they matter. */
|
|
19379
|
-
reasons:
|
|
20129
|
+
reasons: import_zod28.z.array(import_zod28.z.string())
|
|
19380
20130
|
});
|
|
19381
|
-
var PoolPickReportSchema =
|
|
19382
|
-
pool:
|
|
19383
|
-
directory:
|
|
20131
|
+
var PoolPickReportSchema = import_zod28.z.strictObject({
|
|
20132
|
+
pool: import_zod28.z.string(),
|
|
20133
|
+
directory: import_zod28.z.string(),
|
|
19384
20134
|
/** The member a launch would run as, absent when every member is refused. */
|
|
19385
|
-
pick:
|
|
19386
|
-
candidates:
|
|
20135
|
+
pick: import_zod28.z.string().optional(),
|
|
20136
|
+
candidates: import_zod28.z.array(PoolPickCandidateViewSchema),
|
|
19387
20137
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
19388
|
-
missing:
|
|
20138
|
+
missing: import_zod28.z.array(import_zod28.z.string()),
|
|
19389
20139
|
/** When nothing can be picked, the soonest any member returns. */
|
|
19390
|
-
earliestReturn:
|
|
20140
|
+
earliestReturn: import_zod28.z.strictObject({ identity: import_zod28.z.string(), at: import_zod28.z.iso.datetime() }).optional(),
|
|
19391
20141
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
19392
|
-
movedOff:
|
|
20142
|
+
movedOff: import_zod28.z.strictObject({ identity: import_zod28.z.string(), reason: import_zod28.z.string() }).optional(),
|
|
19393
20143
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
19394
|
-
stickyProblem:
|
|
20144
|
+
stickyProblem: import_zod28.z.string().optional()
|
|
19395
20145
|
});
|
|
19396
20146
|
|
|
19397
20147
|
// src/checkReportSchema.ts
|
|
19398
20148
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
19399
|
-
var CheckLayerViewSchema =
|
|
19400
|
-
id:
|
|
19401
|
-
kind:
|
|
19402
|
-
source:
|
|
19403
|
-
});
|
|
19404
|
-
var CheckEntryViewSchema =
|
|
19405
|
-
path:
|
|
19406
|
-
shared:
|
|
19407
|
-
via:
|
|
20149
|
+
var CheckLayerViewSchema = import_zod29.z.strictObject({
|
|
20150
|
+
id: import_zod29.z.int(),
|
|
20151
|
+
kind: import_zod29.z.enum(LAYER_KINDS),
|
|
20152
|
+
source: import_zod29.z.string()
|
|
20153
|
+
});
|
|
20154
|
+
var CheckEntryViewSchema = import_zod29.z.strictObject({
|
|
20155
|
+
path: import_zod29.z.string(),
|
|
20156
|
+
shared: import_zod29.z.boolean(),
|
|
20157
|
+
via: import_zod29.z.enum(DECISION_VIAS),
|
|
19408
20158
|
/** The entry's real category, or null when nothing classifies it. */
|
|
19409
|
-
category:
|
|
19410
|
-
rule:
|
|
20159
|
+
category: import_zod29.z.enum(CATEGORY_NAMES).nullable(),
|
|
20160
|
+
rule: import_zod29.z.strictObject({ key: import_zod29.z.string(), layer: import_zod29.z.int() }).optional(),
|
|
19411
20161
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
19412
|
-
eliminated:
|
|
19413
|
-
});
|
|
19414
|
-
var CheckDiagnosticSchema =
|
|
19415
|
-
code:
|
|
19416
|
-
severity:
|
|
19417
|
-
message:
|
|
19418
|
-
subject:
|
|
19419
|
-
layer:
|
|
19420
|
-
});
|
|
19421
|
-
var CheckAmbientCredentialSchema =
|
|
19422
|
-
var CheckKeychainSchema =
|
|
19423
|
-
checked:
|
|
19424
|
-
found:
|
|
19425
|
-
serviceName:
|
|
19426
|
-
note:
|
|
19427
|
-
});
|
|
19428
|
-
var CheckSettingsExposureSchema =
|
|
19429
|
-
file:
|
|
19430
|
-
envKeyNames:
|
|
19431
|
-
hookEventNames:
|
|
19432
|
-
hookCommandCount:
|
|
19433
|
-
});
|
|
19434
|
-
var CredentialSourceSummarySchema =
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
20162
|
+
eliminated: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.strictObject({ key: import_zod29.z.string(), failed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())) }))).optional()
|
|
20163
|
+
});
|
|
20164
|
+
var CheckDiagnosticSchema = import_zod29.z.strictObject({
|
|
20165
|
+
code: import_zod29.z.enum(DIAGNOSTIC_CODES),
|
|
20166
|
+
severity: import_zod29.z.enum(DIAGNOSTIC_SEVERITIES),
|
|
20167
|
+
message: import_zod29.z.string(),
|
|
20168
|
+
subject: import_zod29.z.string().optional(),
|
|
20169
|
+
layer: import_zod29.z.int().optional()
|
|
20170
|
+
});
|
|
20171
|
+
var CheckAmbientCredentialSchema = import_zod29.z.union([import_zod29.z.strictObject({ ok: import_zod29.z.literal(true) }), import_zod29.z.strictObject({ ok: import_zod29.z.literal(false), variable: import_zod29.z.string(), message: import_zod29.z.string() })]);
|
|
20172
|
+
var CheckKeychainSchema = import_zod29.z.strictObject({
|
|
20173
|
+
checked: import_zod29.z.literal(true),
|
|
20174
|
+
found: import_zod29.z.boolean(),
|
|
20175
|
+
serviceName: import_zod29.z.string().optional(),
|
|
20176
|
+
note: import_zod29.z.string()
|
|
20177
|
+
});
|
|
20178
|
+
var CheckSettingsExposureSchema = import_zod29.z.strictObject({
|
|
20179
|
+
file: import_zod29.z.string(),
|
|
20180
|
+
envKeyNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
|
|
20181
|
+
hookEventNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
|
|
20182
|
+
hookCommandCount: import_zod29.z.int().nonnegative()
|
|
20183
|
+
});
|
|
20184
|
+
var CredentialSourceSummarySchema = import_zod29.z.union([
|
|
20185
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("env"), variable: import_zod29.z.string() }),
|
|
20186
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("file"), path: import_zod29.z.string() }),
|
|
20187
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("command"), program: import_zod29.z.string() }),
|
|
20188
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("op"), reference: import_zod29.z.string() }),
|
|
20189
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("keychain"), service: import_zod29.z.string(), account: import_zod29.z.string().optional() }),
|
|
20190
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("literal") })
|
|
19441
20191
|
]);
|
|
19442
|
-
var CredentialSummarySchema =
|
|
19443
|
-
target:
|
|
19444
|
-
sources:
|
|
20192
|
+
var CredentialSummarySchema = import_zod29.z.strictObject({
|
|
20193
|
+
target: import_zod29.z.enum(CREDENTIAL_TARGETS),
|
|
20194
|
+
sources: import_zod29.z.readonly(import_zod29.z.array(CredentialSourceSummarySchema)),
|
|
19445
20195
|
cache: CredentialCacheSchema.optional()
|
|
19446
20196
|
});
|
|
19447
|
-
var CachedCredentialStateSchema =
|
|
19448
|
-
|
|
19449
|
-
|
|
19450
|
-
|
|
20197
|
+
var CachedCredentialStateSchema = import_zod29.z.union([
|
|
20198
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("empty") }),
|
|
20199
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("unreadable"), reason: import_zod29.z.string() }),
|
|
20200
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.enum(["fresh", "expired"]), ageMs: import_zod29.z.number(), expiresInMs: import_zod29.z.number().optional() })
|
|
19451
20201
|
]);
|
|
19452
|
-
var CheckCredentialProviderSchema =
|
|
19453
|
-
|
|
19454
|
-
|
|
20202
|
+
var CheckCredentialProviderSchema = import_zod29.z.union([
|
|
20203
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
20204
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), problem: import_zod29.z.string() })
|
|
19455
20205
|
]);
|
|
19456
|
-
var CheckCredentialSchema =
|
|
19457
|
-
applies:
|
|
20206
|
+
var CheckCredentialSchema = import_zod29.z.strictObject({
|
|
20207
|
+
applies: import_zod29.z.enum(CHECK_CREDENTIAL_APPLIES),
|
|
19458
20208
|
provider: CheckCredentialProviderSchema.optional(),
|
|
19459
20209
|
identity: CredentialSummarySchema.optional(),
|
|
19460
20210
|
identityCached: CachedCredentialStateSchema.optional()
|
|
19461
20211
|
});
|
|
19462
|
-
var CheckClaudeVersionSchema =
|
|
19463
|
-
pinned:
|
|
19464
|
-
highestInstalled:
|
|
19465
|
-
installed:
|
|
20212
|
+
var CheckClaudeVersionSchema = import_zod29.z.strictObject({
|
|
20213
|
+
pinned: import_zod29.z.strictObject({ version: import_zod29.z.string(), source: import_zod29.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod29.z.boolean() }).optional(),
|
|
20214
|
+
highestInstalled: import_zod29.z.string().optional(),
|
|
20215
|
+
installed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string()))
|
|
19466
20216
|
});
|
|
19467
|
-
var CheckReportJsonSchema =
|
|
19468
|
-
identity:
|
|
20217
|
+
var CheckReportJsonSchema = import_zod29.z.strictObject({
|
|
20218
|
+
identity: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(IDENTITY_DECISION_SOURCES) }),
|
|
19469
20219
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
19470
20220
|
pool: PoolPickReportSchema.optional(),
|
|
19471
|
-
configProfile:
|
|
19472
|
-
layers:
|
|
19473
|
-
entries:
|
|
19474
|
-
projectEncodingAmbiguities:
|
|
19475
|
-
|
|
20221
|
+
configProfile: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
20222
|
+
layers: import_zod29.z.readonly(import_zod29.z.array(CheckLayerViewSchema)),
|
|
20223
|
+
entries: import_zod29.z.readonly(import_zod29.z.array(CheckEntryViewSchema)),
|
|
20224
|
+
projectEncodingAmbiguities: import_zod29.z.readonly(
|
|
20225
|
+
import_zod29.z.array(import_zod29.z.strictObject({ fragment: import_zod29.z.string(), encoded: import_zod29.z.string(), reason: import_zod29.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod29.z.string() }))
|
|
19476
20226
|
),
|
|
19477
|
-
diagnostics:
|
|
20227
|
+
diagnostics: import_zod29.z.readonly(import_zod29.z.array(CheckDiagnosticSchema)),
|
|
19478
20228
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
19479
20229
|
keychain: CheckKeychainSchema.optional(),
|
|
19480
|
-
settingsExposure:
|
|
20230
|
+
settingsExposure: import_zod29.z.readonly(import_zod29.z.array(CheckSettingsExposureSchema)),
|
|
19481
20231
|
credential: CheckCredentialSchema,
|
|
19482
20232
|
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
19483
20233
|
});
|
|
@@ -19488,28 +20238,28 @@ init_preflight();
|
|
|
19488
20238
|
init_resets();
|
|
19489
20239
|
|
|
19490
20240
|
// src/usage/resetsSchema.ts
|
|
19491
|
-
var
|
|
19492
|
-
var ResetRowSchema =
|
|
19493
|
-
identity:
|
|
19494
|
-
provider:
|
|
20241
|
+
var import_zod30 = require("zod");
|
|
20242
|
+
var ResetRowSchema = import_zod30.z.strictObject({
|
|
20243
|
+
identity: import_zod30.z.string(),
|
|
20244
|
+
provider: import_zod30.z.string(),
|
|
19495
20245
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
19496
|
-
window:
|
|
20246
|
+
window: import_zod30.z.string(),
|
|
19497
20247
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
19498
|
-
observedAt:
|
|
20248
|
+
observedAt: import_zod30.z.iso.datetime(),
|
|
19499
20249
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
19500
|
-
resetsAt:
|
|
20250
|
+
resetsAt: import_zod30.z.iso.datetime().optional(),
|
|
19501
20251
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
19502
|
-
reset:
|
|
20252
|
+
reset: import_zod30.z.boolean(),
|
|
19503
20253
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
19504
|
-
utilization:
|
|
20254
|
+
utilization: import_zod30.z.number().optional(),
|
|
19505
20255
|
/** The window's own status, for a window that has not reset yet. */
|
|
19506
|
-
status:
|
|
20256
|
+
status: import_zod30.z.string().optional()
|
|
19507
20257
|
});
|
|
19508
|
-
var ResetScheduleSchema =
|
|
20258
|
+
var ResetScheduleSchema = import_zod30.z.strictObject({ resets: import_zod30.z.readonly(import_zod30.z.array(ResetRowSchema)) });
|
|
19509
20259
|
|
|
19510
20260
|
// src/frontdoor/controlSchemas.ts
|
|
19511
20261
|
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
19512
|
-
var
|
|
20262
|
+
var import_zod37 = require("zod");
|
|
19513
20263
|
|
|
19514
20264
|
// src/codex/doctor.ts
|
|
19515
20265
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20736,92 +21486,92 @@ function collectDoctorReport(params) {
|
|
|
20736
21486
|
// src/frontdoor/controlSchemas.ts
|
|
20737
21487
|
init_schema2();
|
|
20738
21488
|
init_state();
|
|
20739
|
-
var UsageListOutputSchema =
|
|
20740
|
-
var UsageWindowsInputSchema =
|
|
20741
|
-
identity:
|
|
20742
|
-
provider:
|
|
21489
|
+
var UsageListOutputSchema = import_zod37.z.strictObject({ snapshots: import_zod37.z.readonly(import_zod37.z.array(UsageSnapshotSchema)) });
|
|
21490
|
+
var UsageWindowsInputSchema = import_zod37.z.strictObject({
|
|
21491
|
+
identity: import_zod37.z.string().min(1),
|
|
21492
|
+
provider: import_zod37.z.string().min(1).optional()
|
|
20743
21493
|
});
|
|
20744
|
-
var EffectiveWindowSchema =
|
|
21494
|
+
var EffectiveWindowSchema = import_zod37.z.strictObject({
|
|
20745
21495
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
20746
|
-
reset:
|
|
21496
|
+
reset: import_zod37.z.boolean(),
|
|
20747
21497
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
20748
|
-
utilization:
|
|
21498
|
+
utilization: import_zod37.z.number().optional(),
|
|
20749
21499
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
20750
|
-
resetsAtMs:
|
|
21500
|
+
resetsAtMs: import_zod37.z.number().optional(),
|
|
20751
21501
|
/** The window's own status, for a window that has not reset yet. */
|
|
20752
|
-
status:
|
|
21502
|
+
status: import_zod37.z.string().optional()
|
|
20753
21503
|
});
|
|
20754
|
-
var UsageWindowsOutputSchema =
|
|
20755
|
-
identity:
|
|
20756
|
-
provider:
|
|
21504
|
+
var UsageWindowsOutputSchema = import_zod37.z.strictObject({
|
|
21505
|
+
identity: import_zod37.z.string(),
|
|
21506
|
+
provider: import_zod37.z.string(),
|
|
20757
21507
|
/** When the rate-limit state the windows come from was observed. */
|
|
20758
|
-
observedAt:
|
|
21508
|
+
observedAt: import_zod37.z.iso.datetime().optional(),
|
|
20759
21509
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
20760
21510
|
sevenDay: EffectiveWindowSchema.optional()
|
|
20761
21511
|
});
|
|
20762
|
-
var UsageLiveOutputSchema =
|
|
21512
|
+
var UsageLiveOutputSchema = import_zod37.z.strictObject({
|
|
20763
21513
|
/** 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. */
|
|
20764
21514
|
latest: RcLiveRateLimitSchema.optional(),
|
|
20765
21515
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
20766
|
-
sessions:
|
|
21516
|
+
sessions: import_zod37.z.readonly(import_zod37.z.array(RcLiveRateLimitSchema))
|
|
20767
21517
|
});
|
|
20768
|
-
var FrontDoorSessionStatusSchema =
|
|
20769
|
-
pid:
|
|
20770
|
-
startedAt:
|
|
20771
|
-
alive:
|
|
21518
|
+
var FrontDoorSessionStatusSchema = import_zod37.z.strictObject({
|
|
21519
|
+
pid: import_zod37.z.int().positive(),
|
|
21520
|
+
startedAt: import_zod37.z.number(),
|
|
21521
|
+
alive: import_zod37.z.boolean()
|
|
20772
21522
|
});
|
|
20773
|
-
var HeadroomSocketTargetSchema =
|
|
20774
|
-
var FrontDoorStatusOutputSchema =
|
|
21523
|
+
var HeadroomSocketTargetSchema = import_zod37.z.union([import_zod37.z.strictObject({ socketPath: import_zod37.z.string() }), import_zod37.z.strictObject({ refused: import_zod37.z.string() })]);
|
|
21524
|
+
var FrontDoorStatusOutputSchema = import_zod37.z.strictObject({
|
|
20775
21525
|
state: FrontDoorStateSchema,
|
|
20776
|
-
supervisorAlive:
|
|
21526
|
+
supervisorAlive: import_zod37.z.boolean(),
|
|
20777
21527
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
20778
|
-
draining:
|
|
20779
|
-
sessions:
|
|
21528
|
+
draining: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.number().int().positive())),
|
|
21529
|
+
sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)),
|
|
20780
21530
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
20781
|
-
logPath:
|
|
20782
|
-
logExists:
|
|
21531
|
+
logPath: import_zod37.z.string(),
|
|
21532
|
+
logExists: import_zod37.z.boolean()
|
|
20783
21533
|
});
|
|
20784
|
-
var FrontDoorSessionsOutputSchema =
|
|
20785
|
-
var CheckRunInputSchema =
|
|
20786
|
-
path:
|
|
20787
|
-
identity:
|
|
21534
|
+
var FrontDoorSessionsOutputSchema = import_zod37.z.strictObject({ sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)) });
|
|
21535
|
+
var CheckRunInputSchema = import_zod37.z.strictObject({
|
|
21536
|
+
path: import_zod37.z.string().min(1),
|
|
21537
|
+
identity: import_zod37.z.string().min(1).optional()
|
|
20788
21538
|
}).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20789
|
-
var PoolPickInputSchema =
|
|
20790
|
-
pool:
|
|
20791
|
-
path:
|
|
21539
|
+
var PoolPickInputSchema = import_zod37.z.strictObject({
|
|
21540
|
+
pool: import_zod37.z.string().min(1),
|
|
21541
|
+
path: import_zod37.z.string().min(1)
|
|
20792
21542
|
}).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20793
|
-
var DoctorFindingSchema =
|
|
20794
|
-
section:
|
|
20795
|
-
subject:
|
|
20796
|
-
severity:
|
|
20797
|
-
message:
|
|
21543
|
+
var DoctorFindingSchema = import_zod37.z.strictObject({
|
|
21544
|
+
section: import_zod37.z.enum(DOCTOR_SECTIONS),
|
|
21545
|
+
subject: import_zod37.z.string().optional(),
|
|
21546
|
+
severity: import_zod37.z.enum(DOCTOR_SEVERITIES),
|
|
21547
|
+
message: import_zod37.z.string()
|
|
20798
21548
|
});
|
|
20799
|
-
var DoctorRunOutputSchema =
|
|
21549
|
+
var DoctorRunOutputSchema = import_zod37.z.strictObject({
|
|
20800
21550
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
20801
|
-
ok:
|
|
20802
|
-
findings:
|
|
20803
|
-
});
|
|
20804
|
-
var FrontDoorRestartOutputSchema =
|
|
20805
|
-
action:
|
|
20806
|
-
previousPid:
|
|
20807
|
-
});
|
|
20808
|
-
var UpdateCheckOutputSchema =
|
|
20809
|
-
current:
|
|
20810
|
-
latest:
|
|
20811
|
-
action:
|
|
20812
|
-
});
|
|
20813
|
-
var CodexSignInSchema =
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
21551
|
+
ok: import_zod37.z.boolean(),
|
|
21552
|
+
findings: import_zod37.z.readonly(import_zod37.z.array(DoctorFindingSchema))
|
|
21553
|
+
});
|
|
21554
|
+
var FrontDoorRestartOutputSchema = import_zod37.z.strictObject({
|
|
21555
|
+
action: import_zod37.z.literal("restarting"),
|
|
21556
|
+
previousPid: import_zod37.z.int().positive()
|
|
21557
|
+
});
|
|
21558
|
+
var UpdateCheckOutputSchema = import_zod37.z.strictObject({
|
|
21559
|
+
current: import_zod37.z.string(),
|
|
21560
|
+
latest: import_zod37.z.string(),
|
|
21561
|
+
action: import_zod37.z.enum(["current", "available", "updated"])
|
|
21562
|
+
});
|
|
21563
|
+
var CodexSignInSchema = import_zod37.z.discriminatedUnion("state", [
|
|
21564
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("none") }),
|
|
21565
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("signed-in"), email: import_zod37.z.string().optional(), planScope: import_zod37.z.boolean(), accessTokenExpiresAt: import_zod37.z.number() }),
|
|
21566
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("unreadable"), message: import_zod37.z.string() })
|
|
20817
21567
|
]);
|
|
20818
|
-
var CodexStatusOutputSchema =
|
|
21568
|
+
var CodexStatusOutputSchema = import_zod37.z.strictObject({
|
|
20819
21569
|
signIn: CodexSignInSchema,
|
|
20820
|
-
codexProviders:
|
|
21570
|
+
codexProviders: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.string()))
|
|
20821
21571
|
});
|
|
20822
|
-
var CodexLogoutOutputSchema =
|
|
20823
|
-
hadGrant:
|
|
20824
|
-
revoked:
|
|
21572
|
+
var CodexLogoutOutputSchema = import_zod37.z.strictObject({
|
|
21573
|
+
hadGrant: import_zod37.z.boolean(),
|
|
21574
|
+
revoked: import_zod37.z.boolean()
|
|
20825
21575
|
});
|
|
20826
21576
|
|
|
20827
21577
|
// src/frontdoor/codexApi.ts
|
|
@@ -20885,71 +21635,71 @@ init_poolStore();
|
|
|
20885
21635
|
init_providersStore();
|
|
20886
21636
|
|
|
20887
21637
|
// src/frontdoor/configSchemas.ts
|
|
20888
|
-
var
|
|
21638
|
+
var import_zod38 = require("zod");
|
|
20889
21639
|
init_schema();
|
|
20890
21640
|
init_names();
|
|
20891
21641
|
init_keychainLogin();
|
|
20892
21642
|
init_statusline();
|
|
20893
|
-
var RemovalConfirmationSchema =
|
|
20894
|
-
var CredentialWriteSchema = (targets) =>
|
|
20895
|
-
sources:
|
|
20896
|
-
target:
|
|
20897
|
-
cache:
|
|
20898
|
-
});
|
|
20899
|
-
var CredentialSummarySchema2 =
|
|
20900
|
-
target:
|
|
20901
|
-
sources:
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
20908
|
-
|
|
21643
|
+
var RemovalConfirmationSchema = import_zod38.z.boolean();
|
|
21644
|
+
var CredentialWriteSchema = (targets) => import_zod38.z.strictObject({
|
|
21645
|
+
sources: import_zod38.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
21646
|
+
target: import_zod38.z.enum(targets).optional(),
|
|
21647
|
+
cache: import_zod38.z.union([import_zod38.z.literal(false), CredentialCacheSchema]).optional()
|
|
21648
|
+
});
|
|
21649
|
+
var CredentialSummarySchema2 = import_zod38.z.strictObject({
|
|
21650
|
+
target: import_zod38.z.enum(CREDENTIAL_TARGETS),
|
|
21651
|
+
sources: import_zod38.z.readonly(import_zod38.z.array(
|
|
21652
|
+
import_zod38.z.discriminatedUnion("kind", [
|
|
21653
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("env"), variable: import_zod38.z.string() }),
|
|
21654
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("file"), path: import_zod38.z.string() }),
|
|
21655
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("command"), program: import_zod38.z.string() }),
|
|
21656
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("op"), reference: import_zod38.z.string() }),
|
|
21657
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("keychain"), service: import_zod38.z.string(), account: import_zod38.z.string().optional() }),
|
|
21658
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("literal") })
|
|
20909
21659
|
])
|
|
20910
21660
|
)),
|
|
20911
21661
|
cache: CredentialCacheSchema.optional()
|
|
20912
21662
|
});
|
|
20913
|
-
var mutationOutput = (kind, action) =>
|
|
20914
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
20915
|
-
var IdentityValueSchema =
|
|
20916
|
-
name:
|
|
20917
|
-
label:
|
|
20918
|
-
defaultConfigProfile:
|
|
20919
|
-
provider:
|
|
20920
|
-
allowAmbientCredential:
|
|
21663
|
+
var mutationOutput = (kind, action) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string() });
|
|
21664
|
+
var storedMutationOutput = (kind, action, value) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string(), value });
|
|
21665
|
+
var IdentityValueSchema = import_zod38.z.strictObject({
|
|
21666
|
+
name: import_zod38.z.string(),
|
|
21667
|
+
label: import_zod38.z.string().optional(),
|
|
21668
|
+
defaultConfigProfile: import_zod38.z.string().optional(),
|
|
21669
|
+
provider: import_zod38.z.string().optional(),
|
|
21670
|
+
allowAmbientCredential: import_zod38.z.boolean(),
|
|
20921
21671
|
credential: CredentialSummarySchema2.optional(),
|
|
20922
|
-
anchors:
|
|
21672
|
+
anchors: import_zod38.z.array(AnchorSchema).optional()
|
|
20923
21673
|
});
|
|
20924
21674
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
20925
|
-
var ProviderValueSchema =
|
|
20926
|
-
name:
|
|
20927
|
-
kind:
|
|
20928
|
-
displayName:
|
|
20929
|
-
baseUrl:
|
|
21675
|
+
var ProviderValueSchema = import_zod38.z.strictObject({
|
|
21676
|
+
name: import_zod38.z.string(),
|
|
21677
|
+
kind: import_zod38.z.enum(PROVIDER_KINDS),
|
|
21678
|
+
displayName: import_zod38.z.string(),
|
|
21679
|
+
baseUrl: import_zod38.z.string().optional(),
|
|
20930
21680
|
codex: CodexProviderConfigSchema.optional(),
|
|
20931
21681
|
credential: CredentialSummarySchema2.optional(),
|
|
20932
|
-
env:
|
|
21682
|
+
env: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.string()).optional()
|
|
20933
21683
|
});
|
|
20934
|
-
var ConfigNameInputSchema =
|
|
20935
|
-
var ConfigIdentityAddInputSchema =
|
|
21684
|
+
var ConfigNameInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1) });
|
|
21685
|
+
var ConfigIdentityAddInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), keepKeychainLogin: import_zod38.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
20936
21686
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
20937
|
-
var ConfigIdentitySetInputSchema =
|
|
20938
|
-
name:
|
|
21687
|
+
var ConfigIdentitySetInputSchema = import_zod38.z.strictObject({
|
|
21688
|
+
name: import_zod38.z.string().min(1),
|
|
20939
21689
|
/** The identity's display label; `false` clears it. */
|
|
20940
|
-
label:
|
|
20941
|
-
defaultConfigProfile:
|
|
21690
|
+
label: import_zod38.z.union([IdentityLabelSchema, import_zod38.z.literal(false)]).optional(),
|
|
21691
|
+
defaultConfigProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
20942
21692
|
/** The provider the identity exists for; `false` clears it. */
|
|
20943
|
-
provider:
|
|
20944
|
-
allowAmbientCredential:
|
|
20945
|
-
credential:
|
|
21693
|
+
provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21694
|
+
allowAmbientCredential: import_zod38.z.boolean().optional(),
|
|
21695
|
+
credential: import_zod38.z.union([import_zod38.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
20946
21696
|
/** `false` removes the anchors; a list replaces them. */
|
|
20947
|
-
anchors:
|
|
21697
|
+
anchors: import_zod38.z.union([import_zod38.z.literal(false), import_zod38.z.array(AnchorSchema).min(1)]).optional()
|
|
20948
21698
|
});
|
|
20949
21699
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
20950
|
-
var ConfigIdentityRemoveInputSchema =
|
|
21700
|
+
var ConfigIdentityRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20951
21701
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
20952
|
-
var ConfigStatuslineSetSchema =
|
|
21702
|
+
var ConfigStatuslineSetSchema = import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()).superRefine((settings, context) => {
|
|
20953
21703
|
for (const key of Object.keys(settings)) {
|
|
20954
21704
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
20955
21705
|
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
@@ -20957,93 +21707,93 @@ var ConfigStatuslineSetSchema = import_zod37.z.record(import_zod37.z.string(), i
|
|
|
20957
21707
|
}
|
|
20958
21708
|
});
|
|
20959
21709
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
20960
|
-
var ConfigProfileAddInputSchema =
|
|
20961
|
-
name:
|
|
20962
|
-
extends:
|
|
20963
|
-
description:
|
|
21710
|
+
var ConfigProfileAddInputSchema = import_zod38.z.strictObject({
|
|
21711
|
+
name: import_zod38.z.string().min(1),
|
|
21712
|
+
extends: import_zod38.z.array(import_zod38.z.string().min(1)).optional(),
|
|
21713
|
+
description: import_zod38.z.string().optional()
|
|
20964
21714
|
});
|
|
20965
21715
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
20966
|
-
var ConfigProfileSetInputSchema =
|
|
20967
|
-
name:
|
|
20968
|
-
category:
|
|
20969
|
-
entry:
|
|
20970
|
-
extends:
|
|
20971
|
-
description:
|
|
20972
|
-
launch:
|
|
20973
|
-
skipPermissions:
|
|
20974
|
-
remoteControl:
|
|
20975
|
-
headroom:
|
|
20976
|
-
trackUsage:
|
|
20977
|
-
provider:
|
|
20978
|
-
claudeVersion:
|
|
20979
|
-
delay:
|
|
20980
|
-
pause:
|
|
20981
|
-
explain:
|
|
20982
|
-
proxyBypass:
|
|
20983
|
-
statusline:
|
|
21716
|
+
var ConfigProfileSetInputSchema = import_zod38.z.strictObject({
|
|
21717
|
+
name: import_zod38.z.string().min(1),
|
|
21718
|
+
category: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
|
|
21719
|
+
entry: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
|
|
21720
|
+
extends: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
|
|
21721
|
+
description: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.literal(false)]).optional(),
|
|
21722
|
+
launch: import_zod38.z.strictObject({
|
|
21723
|
+
skipPermissions: import_zod38.z.boolean().optional(),
|
|
21724
|
+
remoteControl: import_zod38.z.boolean().optional(),
|
|
21725
|
+
headroom: import_zod38.z.boolean().optional(),
|
|
21726
|
+
trackUsage: import_zod38.z.boolean().optional(),
|
|
21727
|
+
provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21728
|
+
claudeVersion: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21729
|
+
delay: import_zod38.z.union([import_zod38.z.string().regex(DURATION_RE), import_zod38.z.literal(false)]).optional(),
|
|
21730
|
+
pause: import_zod38.z.boolean().optional(),
|
|
21731
|
+
explain: import_zod38.z.boolean().optional(),
|
|
21732
|
+
proxyBypass: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
|
|
21733
|
+
statusline: import_zod38.z.strictObject({
|
|
20984
21734
|
set: ConfigStatuslineSetSchema.optional(),
|
|
20985
|
-
unset:
|
|
21735
|
+
unset: import_zod38.z.array(import_zod38.z.string()).optional()
|
|
20986
21736
|
}).optional()
|
|
20987
21737
|
}).optional()
|
|
20988
21738
|
});
|
|
20989
21739
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
20990
|
-
var ConfigProfileRemoveInputSchema =
|
|
21740
|
+
var ConfigProfileRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20991
21741
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
20992
21742
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
20993
|
-
var PoolMembersInputSchema =
|
|
20994
|
-
var ConfigPoolAddInputSchema =
|
|
20995
|
-
name:
|
|
21743
|
+
var PoolMembersInputSchema = import_zod38.z.array(import_zod38.z.string().min(1)).min(1);
|
|
21744
|
+
var ConfigPoolAddInputSchema = import_zod38.z.strictObject({
|
|
21745
|
+
name: import_zod38.z.string().min(1),
|
|
20996
21746
|
identities: PoolMembersInputSchema,
|
|
20997
|
-
preference:
|
|
20998
|
-
resumeOnLimit:
|
|
20999
|
-
compactBeforeLimit:
|
|
21747
|
+
preference: import_zod38.z.enum(POOL_PREFERENCES).optional(),
|
|
21748
|
+
resumeOnLimit: import_zod38.z.boolean().optional(),
|
|
21749
|
+
compactBeforeLimit: import_zod38.z.boolean().optional(),
|
|
21000
21750
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
21001
21751
|
});
|
|
21002
21752
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
21003
|
-
var ConfigPoolSetInputSchema =
|
|
21004
|
-
name:
|
|
21753
|
+
var ConfigPoolSetInputSchema = import_zod38.z.strictObject({
|
|
21754
|
+
name: import_zod38.z.string().min(1),
|
|
21005
21755
|
identities: PoolMembersInputSchema.optional(),
|
|
21006
|
-
preference:
|
|
21007
|
-
resumeOnLimit:
|
|
21008
|
-
compactBeforeLimit:
|
|
21009
|
-
compactAtUtilisation:
|
|
21756
|
+
preference: import_zod38.z.union([import_zod38.z.enum(POOL_PREFERENCES), import_zod38.z.literal(false)]).optional(),
|
|
21757
|
+
resumeOnLimit: import_zod38.z.boolean().optional(),
|
|
21758
|
+
compactBeforeLimit: import_zod38.z.boolean().optional(),
|
|
21759
|
+
compactAtUtilisation: import_zod38.z.union([CompactAtUtilisationSchema, import_zod38.z.literal(false)]).optional()
|
|
21010
21760
|
});
|
|
21011
21761
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
21012
|
-
var ConfigPoolRemoveInputSchema =
|
|
21762
|
+
var ConfigPoolRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21013
21763
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
21014
21764
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
21015
|
-
var ConfigProviderAddInputSchema =
|
|
21016
|
-
name:
|
|
21017
|
-
kind:
|
|
21018
|
-
displayName:
|
|
21019
|
-
baseUrl:
|
|
21765
|
+
var ConfigProviderAddInputSchema = import_zod38.z.strictObject({
|
|
21766
|
+
name: import_zod38.z.string().min(1),
|
|
21767
|
+
kind: import_zod38.z.enum(PROVIDER_KINDS).optional(),
|
|
21768
|
+
displayName: import_zod38.z.string().min(1),
|
|
21769
|
+
baseUrl: import_zod38.z.string().min(1).optional(),
|
|
21020
21770
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
21021
21771
|
codex: CodexProviderConfigSchema.optional()
|
|
21022
21772
|
});
|
|
21023
21773
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
21024
|
-
var ConfigProviderSetInputSchema =
|
|
21025
|
-
name:
|
|
21026
|
-
displayName:
|
|
21027
|
-
baseUrl:
|
|
21774
|
+
var ConfigProviderSetInputSchema = import_zod38.z.strictObject({
|
|
21775
|
+
name: import_zod38.z.string().min(1),
|
|
21776
|
+
displayName: import_zod38.z.string().min(1).optional(),
|
|
21777
|
+
baseUrl: import_zod38.z.string().min(1).optional(),
|
|
21028
21778
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
21029
21779
|
codex: CodexProviderConfigSchema.optional()
|
|
21030
21780
|
});
|
|
21031
21781
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
21032
|
-
var ConfigProviderRemoveInputSchema =
|
|
21782
|
+
var ConfigProviderRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21033
21783
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
21034
|
-
var ConfigRuleAddInputSchema =
|
|
21035
|
-
path:
|
|
21036
|
-
configProfile:
|
|
21037
|
-
identity:
|
|
21784
|
+
var ConfigRuleAddInputSchema = import_zod38.z.strictObject({
|
|
21785
|
+
path: import_zod38.z.string().min(1),
|
|
21786
|
+
configProfile: import_zod38.z.string().min(1).optional(),
|
|
21787
|
+
identity: import_zod38.z.string().min(1).optional()
|
|
21038
21788
|
});
|
|
21039
21789
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
21040
|
-
var ConfigRuleSetInputSchema =
|
|
21041
|
-
path:
|
|
21042
|
-
configProfile:
|
|
21043
|
-
identity:
|
|
21790
|
+
var ConfigRuleSetInputSchema = import_zod38.z.strictObject({
|
|
21791
|
+
path: import_zod38.z.string().min(1),
|
|
21792
|
+
configProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21793
|
+
identity: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional()
|
|
21044
21794
|
});
|
|
21045
21795
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
21046
|
-
var ConfigRuleRemoveInputSchema =
|
|
21796
|
+
var ConfigRuleRemoveInputSchema = import_zod38.z.strictObject({ path: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21047
21797
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
21048
21798
|
|
|
21049
21799
|
// src/frontdoor/configApi.ts
|
|
@@ -21395,51 +22145,51 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
21395
22145
|
var import_server3 = require("@orpc/server");
|
|
21396
22146
|
|
|
21397
22147
|
// src/frontdoor/eventSchemas.ts
|
|
21398
|
-
var
|
|
22148
|
+
var import_zod39 = require("zod");
|
|
21399
22149
|
init_schema2();
|
|
21400
22150
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
21401
22151
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
21402
22152
|
var USAGE_EVENT_SOURCE = "usage";
|
|
21403
22153
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
21404
22154
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
21405
|
-
var DoorEventSchema =
|
|
21406
|
-
source:
|
|
22155
|
+
var DoorEventSchema = import_zod39.z.strictObject({
|
|
22156
|
+
source: import_zod39.z.string().min(1),
|
|
21407
22157
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
21408
|
-
sequence:
|
|
21409
|
-
payload:
|
|
21410
|
-
});
|
|
21411
|
-
var DoorEventSourceQuerySchema =
|
|
21412
|
-
sources:
|
|
21413
|
-
});
|
|
21414
|
-
var LaunchLifecycleEventSchema =
|
|
21415
|
-
kind:
|
|
21416
|
-
pid:
|
|
21417
|
-
startedAt:
|
|
21418
|
-
observedAt:
|
|
21419
|
-
});
|
|
21420
|
-
var DoorHealthEventSchema =
|
|
21421
|
-
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
|
|
21426
|
-
|
|
22158
|
+
sequence: import_zod39.z.number().int().positive(),
|
|
22159
|
+
payload: import_zod39.z.unknown()
|
|
22160
|
+
});
|
|
22161
|
+
var DoorEventSourceQuerySchema = import_zod39.z.strictObject({
|
|
22162
|
+
sources: import_zod39.z.array(import_zod39.z.string().min(1)).min(1).optional()
|
|
22163
|
+
});
|
|
22164
|
+
var LaunchLifecycleEventSchema = import_zod39.z.strictObject({
|
|
22165
|
+
kind: import_zod39.z.enum(["registered", "pruned", "ended"]),
|
|
22166
|
+
pid: import_zod39.z.number().int().positive(),
|
|
22167
|
+
startedAt: import_zod39.z.number(),
|
|
22168
|
+
observedAt: import_zod39.z.number()
|
|
22169
|
+
});
|
|
22170
|
+
var DoorHealthEventSchema = import_zod39.z.discriminatedUnion("kind", [
|
|
22171
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("generation"), pid: import_zod39.z.number().int().positive(), providerPort: import_zod39.z.number().int().positive(), connectPort: import_zod39.z.number().int().positive(), directPort: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
22172
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("listenerFailed"), pid: import_zod39.z.number().int().positive(), listener: import_zod39.z.enum(["provider", "connect", "direct"]), message: import_zod39.z.string(), observedAt: import_zod39.z.number() }),
|
|
22173
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("binaryTurnover"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
22174
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("idleShutdown"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
22175
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("superseded"), pid: import_zod39.z.number().int().positive(), ownerPid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
22176
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("drained"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() })
|
|
21427
22177
|
]);
|
|
21428
|
-
var QuotaExpiringEventSchema =
|
|
22178
|
+
var QuotaExpiringEventSchema = import_zod39.z.strictObject({
|
|
21429
22179
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
21430
|
-
id:
|
|
22180
|
+
id: import_zod39.z.string().min(1),
|
|
21431
22181
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
21432
|
-
name:
|
|
21433
|
-
provider:
|
|
21434
|
-
window:
|
|
22182
|
+
name: import_zod39.z.string().min(1).optional(),
|
|
22183
|
+
provider: import_zod39.z.string().min(1),
|
|
22184
|
+
window: import_zod39.z.enum(["fiveHour", "sevenDay"]),
|
|
21435
22185
|
/** 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. */
|
|
21436
|
-
utilization:
|
|
21437
|
-
resetsAt:
|
|
21438
|
-
observedAt:
|
|
22186
|
+
utilization: import_zod39.z.number().min(0).max(1),
|
|
22187
|
+
resetsAt: import_zod39.z.iso.datetime(),
|
|
22188
|
+
observedAt: import_zod39.z.number()
|
|
21439
22189
|
});
|
|
21440
22190
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
21441
|
-
id:
|
|
21442
|
-
name:
|
|
22191
|
+
id: import_zod39.z.string().min(1),
|
|
22192
|
+
name: import_zod39.z.string().min(1).optional()
|
|
21443
22193
|
});
|
|
21444
22194
|
|
|
21445
22195
|
// src/frontdoor/eventsApi.ts
|
|
@@ -21483,7 +22233,7 @@ function createEventsApiRouter(deps) {
|
|
|
21483
22233
|
// src/frontdoor/lifecycleApi.ts
|
|
21484
22234
|
var import_client4 = require("@orpc/client");
|
|
21485
22235
|
var import_openapi5 = require("@orpc/openapi");
|
|
21486
|
-
var
|
|
22236
|
+
var import_zod40 = require("zod");
|
|
21487
22237
|
init_update();
|
|
21488
22238
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
21489
22239
|
var UPDATE_API_TAG = "update";
|
|
@@ -21491,7 +22241,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
21491
22241
|
const authed = doorApiAuth(deps.expectedToken);
|
|
21492
22242
|
return {
|
|
21493
22243
|
frontdoor: {
|
|
21494
|
-
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
22244
|
+
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod40.z.strictObject({ requested: import_zod40.z.literal(true) })).handler(() => {
|
|
21495
22245
|
deps.refreshCatalogues();
|
|
21496
22246
|
return { requested: true };
|
|
21497
22247
|
}),
|
|
@@ -21528,62 +22278,62 @@ init_cliError();
|
|
|
21528
22278
|
|
|
21529
22279
|
// src/frontdoor/launchSchemas.ts
|
|
21530
22280
|
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
21531
|
-
var
|
|
22281
|
+
var import_zod41 = require("zod");
|
|
21532
22282
|
init_statusline();
|
|
21533
22283
|
init_claudeVersion();
|
|
21534
22284
|
init_identity();
|
|
21535
|
-
var LaunchResolveInputSchema =
|
|
21536
|
-
path:
|
|
22285
|
+
var LaunchResolveInputSchema = import_zod41.z.strictObject({
|
|
22286
|
+
path: import_zod41.z.string().min(1),
|
|
21537
22287
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
21538
|
-
argv:
|
|
22288
|
+
argv: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())).optional(),
|
|
21539
22289
|
/** 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. */
|
|
21540
|
-
env:
|
|
22290
|
+
env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
|
|
21541
22291
|
}).refine((input) => import_node_path44.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
21542
|
-
var LaunchPoolDecisionSchema =
|
|
21543
|
-
name:
|
|
21544
|
-
reasons:
|
|
21545
|
-
movedOff:
|
|
21546
|
-
});
|
|
21547
|
-
var LaunchDecisionSchema =
|
|
21548
|
-
identity:
|
|
21549
|
-
identityId:
|
|
21550
|
-
identitySource:
|
|
22292
|
+
var LaunchPoolDecisionSchema = import_zod41.z.strictObject({
|
|
22293
|
+
name: import_zod41.z.string(),
|
|
22294
|
+
reasons: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
22295
|
+
movedOff: import_zod41.z.strictObject({ identity: import_zod41.z.string(), reason: import_zod41.z.string() }).optional()
|
|
22296
|
+
});
|
|
22297
|
+
var LaunchDecisionSchema = import_zod41.z.strictObject({
|
|
22298
|
+
identity: import_zod41.z.string().optional(),
|
|
22299
|
+
identityId: import_zod41.z.string().optional(),
|
|
22300
|
+
identitySource: import_zod41.z.enum(IDENTITY_DECISION_SOURCES),
|
|
21551
22301
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
21552
22302
|
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
21553
|
-
configDirEscapeHatch:
|
|
21554
|
-
configDir:
|
|
21555
|
-
configProfile:
|
|
21556
|
-
configProfileSource:
|
|
21557
|
-
provider:
|
|
21558
|
-
});
|
|
21559
|
-
var LaunchFlagsSchema =
|
|
21560
|
-
skipPermissions:
|
|
21561
|
-
remoteControl:
|
|
21562
|
-
headroom:
|
|
21563
|
-
trackUsage:
|
|
21564
|
-
pause:
|
|
21565
|
-
explain:
|
|
22303
|
+
configDirEscapeHatch: import_zod41.z.boolean(),
|
|
22304
|
+
configDir: import_zod41.z.string().optional(),
|
|
22305
|
+
configProfile: import_zod41.z.string().optional(),
|
|
22306
|
+
configProfileSource: import_zod41.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
22307
|
+
provider: import_zod41.z.string().optional()
|
|
22308
|
+
});
|
|
22309
|
+
var LaunchFlagsSchema = import_zod41.z.strictObject({
|
|
22310
|
+
skipPermissions: import_zod41.z.boolean(),
|
|
22311
|
+
remoteControl: import_zod41.z.boolean(),
|
|
22312
|
+
headroom: import_zod41.z.boolean(),
|
|
22313
|
+
trackUsage: import_zod41.z.boolean(),
|
|
22314
|
+
pause: import_zod41.z.boolean(),
|
|
22315
|
+
explain: import_zod41.z.boolean(),
|
|
21566
22316
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
21567
|
-
delayMs:
|
|
22317
|
+
delayMs: import_zod41.z.number(),
|
|
21568
22318
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
21569
|
-
proxyBypass:
|
|
22319
|
+
proxyBypass: import_zod41.z.array(import_zod41.z.string()).readonly(),
|
|
21570
22320
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
21571
22321
|
statusline: StatuslineSchema.optional()
|
|
21572
22322
|
});
|
|
21573
|
-
var LaunchResolveOutputSchema =
|
|
22323
|
+
var LaunchResolveOutputSchema = import_zod41.z.strictObject({
|
|
21574
22324
|
decision: LaunchDecisionSchema,
|
|
21575
22325
|
flags: LaunchFlagsSchema,
|
|
21576
|
-
claudeVersion:
|
|
22326
|
+
claudeVersion: import_zod41.z.strictObject({ version: import_zod41.z.string(), source: import_zod41.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
21577
22327
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
21578
|
-
bin:
|
|
22328
|
+
bin: import_zod41.z.string(),
|
|
21579
22329
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
21580
|
-
args:
|
|
22330
|
+
args: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
21581
22331
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
21582
|
-
credential:
|
|
21583
|
-
routing:
|
|
22332
|
+
credential: import_zod41.z.strictObject({ subject: import_zod41.z.enum(["provider", "identity"]), name: import_zod41.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
22333
|
+
routing: import_zod41.z.strictObject({ frontDoor: import_zod41.z.boolean(), headroom: import_zod41.z.boolean() }),
|
|
21584
22334
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
21585
|
-
environment:
|
|
21586
|
-
warnings:
|
|
22335
|
+
environment: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
22336
|
+
warnings: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string()))
|
|
21587
22337
|
});
|
|
21588
22338
|
|
|
21589
22339
|
// src/frontdoor/launchApi.ts
|
|
@@ -21619,22 +22369,22 @@ function createLaunchApiRouter(deps) {
|
|
|
21619
22369
|
// src/frontdoor/agentTreesApi.ts
|
|
21620
22370
|
var import_client6 = require("@orpc/client");
|
|
21621
22371
|
var import_openapi7 = require("@orpc/openapi");
|
|
21622
|
-
var
|
|
22372
|
+
var import_zod42 = require("zod");
|
|
21623
22373
|
init_cliError();
|
|
21624
|
-
var AgentTreesListInputSchema =
|
|
22374
|
+
var AgentTreesListInputSchema = import_zod42.z.strictObject({
|
|
21625
22375
|
/** Only this identity's sessions. */
|
|
21626
|
-
identity:
|
|
22376
|
+
identity: import_zod42.z.string().optional(),
|
|
21627
22377
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
21628
|
-
all:
|
|
22378
|
+
all: import_zod42.z.boolean().optional()
|
|
21629
22379
|
});
|
|
21630
|
-
var AgentTreesListOutputSchema =
|
|
21631
|
-
var AgentTreesShowInputSchema =
|
|
22380
|
+
var AgentTreesListOutputSchema = import_zod42.z.array(SessionSummarySchema);
|
|
22381
|
+
var AgentTreesShowInputSchema = import_zod42.z.strictObject({
|
|
21632
22382
|
/** A session id, or an unambiguous prefix of one. */
|
|
21633
|
-
session:
|
|
22383
|
+
session: import_zod42.z.string().min(1),
|
|
21634
22384
|
/** Look only in this identity. */
|
|
21635
|
-
identity:
|
|
22385
|
+
identity: import_zod42.z.string().optional()
|
|
21636
22386
|
});
|
|
21637
|
-
var AgentTreesShowOutputSchema =
|
|
22387
|
+
var AgentTreesShowOutputSchema = import_zod42.z.strictObject({ identities: import_zod42.z.array(import_zod42.z.string()), ...MergedAgentTreeSchema.shape });
|
|
21638
22388
|
function asBadRequest(error) {
|
|
21639
22389
|
if (error instanceof CliError) {
|
|
21640
22390
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -21687,7 +22437,7 @@ var import_openapi8 = require("@orpc/openapi");
|
|
|
21687
22437
|
var import_server4 = require("@orpc/server");
|
|
21688
22438
|
|
|
21689
22439
|
// src/frontdoor/rcEventLog.ts
|
|
21690
|
-
var
|
|
22440
|
+
var import_zod43 = require("zod");
|
|
21691
22441
|
|
|
21692
22442
|
// src/frontdoor/eventHub.ts
|
|
21693
22443
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -21797,8 +22547,8 @@ function rcFanoutOnDoorHub(fanout, hub) {
|
|
|
21797
22547
|
|
|
21798
22548
|
// src/frontdoor/rcEventLog.ts
|
|
21799
22549
|
var RC_SESSION_EVENT_TOKEN_MAX_CHARS = 255;
|
|
21800
|
-
var
|
|
21801
|
-
var
|
|
22550
|
+
var HIGH_SURROGATE_FIRST2 = 55296;
|
|
22551
|
+
var HIGH_SURROGATE_LAST2 = 56319;
|
|
21802
22552
|
var LOW_SURROGATE_FIRST = 56320;
|
|
21803
22553
|
var LOW_SURROGATE_LAST = 57343;
|
|
21804
22554
|
var CUT_MARKER = "...";
|
|
@@ -21809,47 +22559,47 @@ var NUMBER_BYTES = Float64Array.BYTES_PER_ELEMENT;
|
|
|
21809
22559
|
var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
21810
22560
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
21811
22561
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
21812
|
-
var RC_PENDING_RETIRE_REASONS = ["answered", "
|
|
21813
|
-
var transitionBase = { session:
|
|
21814
|
-
var cursorFields = { cursor:
|
|
21815
|
-
var sessionAppearedShape = { kind:
|
|
21816
|
-
var sessionEndedShape = { kind:
|
|
21817
|
-
var workerStateShape = { kind:
|
|
21818
|
-
var pendingBornShape = { kind:
|
|
21819
|
-
var pendingRetiredShape = { kind:
|
|
21820
|
-
var RcSessionTransitionSchema =
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
22562
|
+
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
22563
|
+
var transitionBase = { session: import_zod43.z.string(), at: import_zod43.z.number() };
|
|
22564
|
+
var cursorFields = { cursor: import_zod43.z.string(), sequence: import_zod43.z.int().positive() };
|
|
22565
|
+
var sessionAppearedShape = { kind: import_zod43.z.literal("session-appeared"), ...transitionBase };
|
|
22566
|
+
var sessionEndedShape = { kind: import_zod43.z.literal("session-ended"), reason: import_zod43.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
22567
|
+
var workerStateShape = { kind: import_zod43.z.literal("worker-state"), state: import_zod43.z.string(), previous: import_zod43.z.string().optional(), ...transitionBase };
|
|
22568
|
+
var pendingBornShape = { kind: import_zod43.z.literal("pending-born"), requestId: import_zod43.z.string(), type: import_zod43.z.string(), summary: import_zod43.z.string(), ...transitionBase };
|
|
22569
|
+
var pendingRetiredShape = { kind: import_zod43.z.literal("pending-retired"), requestId: import_zod43.z.string(), reason: import_zod43.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
22570
|
+
var RcSessionTransitionSchema = import_zod43.z.discriminatedUnion("kind", [
|
|
22571
|
+
import_zod43.z.strictObject(sessionAppearedShape),
|
|
22572
|
+
import_zod43.z.strictObject(sessionEndedShape),
|
|
22573
|
+
import_zod43.z.strictObject(workerStateShape),
|
|
22574
|
+
import_zod43.z.strictObject(pendingBornShape),
|
|
22575
|
+
import_zod43.z.strictObject(pendingRetiredShape)
|
|
21826
22576
|
]);
|
|
21827
22577
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
21828
22578
|
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
21829
22579
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
21830
|
-
var RcSessionEventSchema =
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
22580
|
+
var RcSessionEventSchema = import_zod43.z.discriminatedUnion("kind", [
|
|
22581
|
+
import_zod43.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
22582
|
+
import_zod43.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
22583
|
+
import_zod43.z.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
22584
|
+
import_zod43.z.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
22585
|
+
import_zod43.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
21836
22586
|
]);
|
|
21837
|
-
var RcSessionEventsReadInputSchema =
|
|
22587
|
+
var RcSessionEventsReadInputSchema = import_zod43.z.strictObject({
|
|
21838
22588
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
21839
|
-
since:
|
|
22589
|
+
since: import_zod43.z.string().min(1).optional(),
|
|
21840
22590
|
/** One `cse_` session id; every session when omitted. */
|
|
21841
|
-
session:
|
|
22591
|
+
session: import_zod43.z.string().min(1).optional(),
|
|
21842
22592
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
21843
|
-
limit:
|
|
22593
|
+
limit: import_zod43.z.int().positive().optional()
|
|
21844
22594
|
});
|
|
21845
22595
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
21846
22596
|
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
21847
|
-
limit:
|
|
22597
|
+
limit: import_zod43.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
21848
22598
|
});
|
|
21849
22599
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
21850
|
-
var RcSessionEventsReadOutputSchema =
|
|
21851
|
-
|
|
21852
|
-
|
|
22600
|
+
var RcSessionEventsReadOutputSchema = import_zod43.z.discriminatedUnion("status", [
|
|
22601
|
+
import_zod43.z.strictObject({ status: import_zod43.z.literal("ok"), events: import_zod43.z.readonly(import_zod43.z.array(RcSessionEventSchema)), cursor: import_zod43.z.string(), more: import_zod43.z.boolean(), head: import_zod43.z.string() }),
|
|
22602
|
+
import_zod43.z.strictObject({ status: import_zod43.z.literal("expired"), message: import_zod43.z.string(), head: import_zod43.z.string() })
|
|
21853
22603
|
]);
|
|
21854
22604
|
var CURSOR_SEPARATOR = ".";
|
|
21855
22605
|
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
@@ -21870,7 +22620,7 @@ function parseCursor(cursor) {
|
|
|
21870
22620
|
function codePointBoundary(text, at) {
|
|
21871
22621
|
const before = text.charCodeAt(at - 1);
|
|
21872
22622
|
const after = text.charCodeAt(at);
|
|
21873
|
-
const isHigh = before >=
|
|
22623
|
+
const isHigh = before >= HIGH_SURROGATE_FIRST2 && before <= HIGH_SURROGATE_LAST2;
|
|
21874
22624
|
const isLow = after >= LOW_SURROGATE_FIRST && after <= LOW_SURROGATE_LAST;
|
|
21875
22625
|
return isHigh && isLow ? at - 1 : at;
|
|
21876
22626
|
}
|
|
@@ -22348,15 +23098,15 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
22348
23098
|
|
|
22349
23099
|
// src/frontdoor/rcLiveUsage.ts
|
|
22350
23100
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
22351
|
-
function
|
|
23101
|
+
function isRecord10(value) {
|
|
22352
23102
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22353
23103
|
}
|
|
22354
23104
|
function rcRateLimitInfoOf(event) {
|
|
22355
23105
|
const payload = event.envelope.payload;
|
|
22356
|
-
if (!
|
|
23106
|
+
if (!isRecord10(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
22357
23107
|
return void 0;
|
|
22358
23108
|
}
|
|
22359
|
-
if (!
|
|
23109
|
+
if (!isRecord10(payload.rate_limit_info)) {
|
|
22360
23110
|
return void 0;
|
|
22361
23111
|
}
|
|
22362
23112
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -22444,7 +23194,7 @@ function createSseParser() {
|
|
|
22444
23194
|
}
|
|
22445
23195
|
};
|
|
22446
23196
|
}
|
|
22447
|
-
function
|
|
23197
|
+
function isRecord11(value) {
|
|
22448
23198
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22449
23199
|
}
|
|
22450
23200
|
function sequenceNumOf(value) {
|
|
@@ -22466,7 +23216,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
22466
23216
|
} catch {
|
|
22467
23217
|
return void 0;
|
|
22468
23218
|
}
|
|
22469
|
-
if (!
|
|
23219
|
+
if (!isRecord11(data)) {
|
|
22470
23220
|
return void 0;
|
|
22471
23221
|
}
|
|
22472
23222
|
const eventType = data.event_type;
|
|
@@ -22713,7 +23463,13 @@ init_capability();
|
|
|
22713
23463
|
// src/frontdoor/rcSelfHostEndpoints.ts
|
|
22714
23464
|
var RC_SOURCE_WORKER = "worker";
|
|
22715
23465
|
var RC_SOURCE_CLIENT = "client";
|
|
22716
|
-
|
|
23466
|
+
var CLIENT_PLATFORM_HEADER = "anthropic-client-platform";
|
|
23467
|
+
function withClientPlatform(payload, headers) {
|
|
23468
|
+
const rest = Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "client_platform"));
|
|
23469
|
+
const platform = headers[CLIENT_PLATFORM_HEADER];
|
|
23470
|
+
return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
|
|
23471
|
+
}
|
|
23472
|
+
function isRecord12(value) {
|
|
22717
23473
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22718
23474
|
}
|
|
22719
23475
|
function parseJsonObject2(body) {
|
|
@@ -22723,7 +23479,7 @@ function parseJsonObject2(body) {
|
|
|
22723
23479
|
} catch {
|
|
22724
23480
|
return void 0;
|
|
22725
23481
|
}
|
|
22726
|
-
return
|
|
23482
|
+
return isRecord12(parsed) ? parsed : void 0;
|
|
22727
23483
|
}
|
|
22728
23484
|
function nonEmptyString2(record, field) {
|
|
22729
23485
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22797,11 +23553,11 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
22797
23553
|
}
|
|
22798
23554
|
const results = [];
|
|
22799
23555
|
for (const event of events) {
|
|
22800
|
-
if (!
|
|
23556
|
+
if (!isRecord12(event) || !isRecord12(event.payload)) {
|
|
22801
23557
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a teleport write is an object carrying one payload object" } });
|
|
22802
23558
|
return true;
|
|
22803
23559
|
}
|
|
22804
|
-
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, event.payload);
|
|
23560
|
+
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22805
23561
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22806
23562
|
}
|
|
22807
23563
|
ctx.sweep();
|
|
@@ -22897,7 +23653,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
22897
23653
|
// src/frontdoor/rcSelfHostConversations.ts
|
|
22898
23654
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
22899
23655
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
22900
|
-
function
|
|
23656
|
+
function isRecord13(value) {
|
|
22901
23657
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22902
23658
|
}
|
|
22903
23659
|
function parseJsonObject3(body) {
|
|
@@ -22907,7 +23663,7 @@ function parseJsonObject3(body) {
|
|
|
22907
23663
|
} catch {
|
|
22908
23664
|
return void 0;
|
|
22909
23665
|
}
|
|
22910
|
-
return
|
|
23666
|
+
return isRecord13(parsed) ? parsed : void 0;
|
|
22911
23667
|
}
|
|
22912
23668
|
function nonEmptyString3(record, field) {
|
|
22913
23669
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22961,11 +23717,11 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
22961
23717
|
}
|
|
22962
23718
|
const results = [];
|
|
22963
23719
|
for (const event of events) {
|
|
22964
|
-
if (!
|
|
23720
|
+
if (!isRecord13(event) || !isRecord13(event.payload)) {
|
|
22965
23721
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
|
|
22966
23722
|
return;
|
|
22967
23723
|
}
|
|
22968
|
-
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
23724
|
+
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22969
23725
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22970
23726
|
}
|
|
22971
23727
|
ctx.sweep();
|
|
@@ -22993,7 +23749,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
|
|
|
22993
23749
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
22994
23750
|
var MS_PER_SECOND6 = 1e3;
|
|
22995
23751
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
22996
|
-
function
|
|
23752
|
+
function isRecord14(value) {
|
|
22997
23753
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22998
23754
|
}
|
|
22999
23755
|
function parseJsonObject4(body) {
|
|
@@ -23003,7 +23759,7 @@ function parseJsonObject4(body) {
|
|
|
23003
23759
|
} catch {
|
|
23004
23760
|
return void 0;
|
|
23005
23761
|
}
|
|
23006
|
-
return
|
|
23762
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
23007
23763
|
}
|
|
23008
23764
|
function growthBookFeatures() {
|
|
23009
23765
|
return {
|
|
@@ -23357,7 +24113,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
23357
24113
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
23358
24114
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
23359
24115
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
23360
|
-
function
|
|
24116
|
+
function isRecord15(value) {
|
|
23361
24117
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23362
24118
|
}
|
|
23363
24119
|
function isWebSearchRefusal(value) {
|
|
@@ -23441,7 +24197,7 @@ function parseJsonObject5(body) {
|
|
|
23441
24197
|
} catch {
|
|
23442
24198
|
return void 0;
|
|
23443
24199
|
}
|
|
23444
|
-
return
|
|
24200
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
23445
24201
|
}
|
|
23446
24202
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
23447
24203
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -23701,7 +24457,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23701
24457
|
if (status !== void 0) {
|
|
23702
24458
|
session.workerStatus = status;
|
|
23703
24459
|
}
|
|
23704
|
-
if (
|
|
24460
|
+
if (isRecord15(body?.external_metadata)) {
|
|
23705
24461
|
session.externalMetadata = body.external_metadata;
|
|
23706
24462
|
}
|
|
23707
24463
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -23731,7 +24487,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23731
24487
|
}
|
|
23732
24488
|
const results = [];
|
|
23733
24489
|
for (const event of events) {
|
|
23734
|
-
if (!
|
|
24490
|
+
if (!isRecord15(event) || !isRecord15(event.payload)) {
|
|
23735
24491
|
await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a batch is an object carrying one payload object" } });
|
|
23736
24492
|
return;
|
|
23737
24493
|
}
|
|
@@ -23764,7 +24520,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23764
24520
|
return;
|
|
23765
24521
|
}
|
|
23766
24522
|
for (const event of events) {
|
|
23767
|
-
if (
|
|
24523
|
+
if (isRecord15(event)) {
|
|
23768
24524
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
23769
24525
|
}
|
|
23770
24526
|
}
|
|
@@ -23860,11 +24616,11 @@ data: ${JSON.stringify(envelope)}
|
|
|
23860
24616
|
}
|
|
23861
24617
|
const results = [];
|
|
23862
24618
|
for (const event of events) {
|
|
23863
|
-
if (!
|
|
24619
|
+
if (!isRecord15(event) || !isRecord15(event.payload)) {
|
|
23864
24620
|
await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
|
|
23865
24621
|
return;
|
|
23866
24622
|
}
|
|
23867
|
-
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
24623
|
+
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
23868
24624
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
23869
24625
|
}
|
|
23870
24626
|
sweep();
|
|
@@ -23998,7 +24754,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
|
23998
24754
|
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
23999
24755
|
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
24000
24756
|
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
24001
|
-
function
|
|
24757
|
+
function isRecord16(value) {
|
|
24002
24758
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24003
24759
|
}
|
|
24004
24760
|
function readJsonObject(fs17, file) {
|
|
@@ -24012,7 +24768,7 @@ function readJsonObject(fs17, file) {
|
|
|
24012
24768
|
} catch {
|
|
24013
24769
|
return void 0;
|
|
24014
24770
|
}
|
|
24015
|
-
return
|
|
24771
|
+
return isRecord16(parsed) ? parsed : void 0;
|
|
24016
24772
|
}
|
|
24017
24773
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
24018
24774
|
const parsed = readJsonObject(fs17, import_node_path45.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
@@ -24040,7 +24796,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
24040
24796
|
const recordFile2 = import_node_path45.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
24041
24797
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
24042
24798
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
24043
|
-
const existingOauth =
|
|
24799
|
+
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
24044
24800
|
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
24045
24801
|
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
24046
24802
|
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
@@ -24057,7 +24813,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
24057
24813
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
24058
24814
|
`);
|
|
24059
24815
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
24060
|
-
const existingBlock = (value) =>
|
|
24816
|
+
const existingBlock = (value) => isRecord16(value) ? value : {};
|
|
24061
24817
|
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
24062
24818
|
...claudeJson,
|
|
24063
24819
|
oauthAccount: {
|
|
@@ -24180,7 +24936,7 @@ init_poolPick();
|
|
|
24180
24936
|
|
|
24181
24937
|
// src/agents/read.ts
|
|
24182
24938
|
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
24183
|
-
var
|
|
24939
|
+
var import_zod44 = require("zod");
|
|
24184
24940
|
var PROJECTS_DIR = "projects";
|
|
24185
24941
|
var TASKS_DIR = "tasks";
|
|
24186
24942
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -24299,14 +25055,14 @@ function parseJson2(text) {
|
|
|
24299
25055
|
return void 0;
|
|
24300
25056
|
}
|
|
24301
25057
|
}
|
|
24302
|
-
var TaskFileSchema =
|
|
24303
|
-
var WorkflowRunFileSchema =
|
|
24304
|
-
runId:
|
|
24305
|
-
workflowName:
|
|
24306
|
-
status:
|
|
24307
|
-
startTime:
|
|
24308
|
-
phases:
|
|
24309
|
-
summary:
|
|
25058
|
+
var TaskFileSchema = import_zod44.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod44.z.array(import_zod44.z.string()).default([]), blockedBy: import_zod44.z.array(import_zod44.z.string()).default([]) });
|
|
25059
|
+
var WorkflowRunFileSchema = import_zod44.z.object({
|
|
25060
|
+
runId: import_zod44.z.string(),
|
|
25061
|
+
workflowName: import_zod44.z.string().optional(),
|
|
25062
|
+
status: import_zod44.z.string().optional(),
|
|
25063
|
+
startTime: import_zod44.z.number().optional(),
|
|
25064
|
+
phases: import_zod44.z.array(import_zod44.z.object({ title: import_zod44.z.string() })).default([]),
|
|
25065
|
+
summary: import_zod44.z.string().optional()
|
|
24310
25066
|
});
|
|
24311
25067
|
function summariseSession(fs17, configDir, ref) {
|
|
24312
25068
|
const sessionRelative = import_node_path47.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
@@ -24811,9 +25567,10 @@ init_ownCli();
|
|
|
24811
25567
|
QUOTA_EXPIRING_EVENT_SOURCE,
|
|
24812
25568
|
QuotaExpiringEventSchema,
|
|
24813
25569
|
RC_CONTEXT_USAGE_DETAILS,
|
|
25570
|
+
RC_GOAL_CLEAR_WORDS,
|
|
25571
|
+
RC_GOAL_CONDITION_MAX_CHARS,
|
|
24814
25572
|
RC_IDLE_EXPIRY_MS,
|
|
24815
25573
|
RC_ORPC_PATH_PREFIX,
|
|
24816
|
-
RC_PENDING_DEADLINE_MS,
|
|
24817
25574
|
RC_PENDING_RETIRE_REASONS,
|
|
24818
25575
|
RC_PERMISSION_MODES,
|
|
24819
25576
|
RC_READ_FILE_ENCODINGS,
|
|
@@ -24826,6 +25583,8 @@ init_ownCli();
|
|
|
24826
25583
|
RC_SELF_HOST_SCOPE_LIST,
|
|
24827
25584
|
RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
|
|
24828
25585
|
RC_SESSIONS_PATH_PREFIX,
|
|
25586
|
+
RC_SESSION_COMMAND_MAX_WAIT_MS,
|
|
25587
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS,
|
|
24829
25588
|
RC_SESSION_END_REASONS,
|
|
24830
25589
|
RC_SESSION_EVENT_LOG_CAPACITY,
|
|
24831
25590
|
RC_STREAM_BACKOFF_MS,
|
|
@@ -24921,11 +25680,13 @@ init_ownCli();
|
|
|
24921
25680
|
createQuotaExpiringPublisher,
|
|
24922
25681
|
createRcApiNodeHandler,
|
|
24923
25682
|
createRcApiRouter,
|
|
25683
|
+
createRcClaudeCodeVersions,
|
|
24924
25684
|
createRcControlHandler,
|
|
24925
25685
|
createRcCredentialStore,
|
|
24926
25686
|
createRcEventFanout,
|
|
24927
25687
|
createRcLiveUsage,
|
|
24928
25688
|
createRcSelfHostSurface,
|
|
25689
|
+
createRcSessionCommands,
|
|
24929
25690
|
createRcSessionEventLog,
|
|
24930
25691
|
createRcSessionEventsApiRouter,
|
|
24931
25692
|
createRcSessionRegistryReader,
|
|
@@ -24988,6 +25749,7 @@ init_ownCli();
|
|
|
24988
25749
|
mintRcSelfHostCredential,
|
|
24989
25750
|
observingRoutedRoute,
|
|
24990
25751
|
parseConnectTarget,
|
|
25752
|
+
parseRcGoalOutput,
|
|
24991
25753
|
parseRcStreamEnvelope,
|
|
24992
25754
|
planOf,
|
|
24993
25755
|
poolIdentities,
|
|
@@ -24999,6 +25761,8 @@ init_ownCli();
|
|
|
24999
25761
|
rankPool,
|
|
25000
25762
|
rcEventWriteResultFromAnswer,
|
|
25001
25763
|
rcFanoutOnDoorHub,
|
|
25764
|
+
rcLocalCommandAnswerOf,
|
|
25765
|
+
rcManualCompactBoundaryOf,
|
|
25002
25766
|
rcObserverAsPassthrough,
|
|
25003
25767
|
rcRateLimitInfoOf,
|
|
25004
25768
|
rcSelfHostFromEnv,
|