claude-use 14.5.1 → 14.6.1
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/dist/cli.cjs +1600 -1161
- package/dist/index.cjs +548 -305
- package/dist/index.mjs +548 -305
- package/dist/types/index.d.ts +58 -14
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4438,13 +4438,31 @@ var init_capability = __esm({
|
|
|
4438
4438
|
});
|
|
4439
4439
|
|
|
4440
4440
|
// src/frontdoor/route.ts
|
|
4441
|
-
|
|
4441
|
+
function singleHeaderValue(value) {
|
|
4442
|
+
if (typeof value === "string") {
|
|
4443
|
+
return value;
|
|
4444
|
+
}
|
|
4445
|
+
if (Array.isArray(value)) {
|
|
4446
|
+
return value.join(", ");
|
|
4447
|
+
}
|
|
4448
|
+
return void 0;
|
|
4449
|
+
}
|
|
4450
|
+
function internalHeaderValue(headers, name) {
|
|
4451
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
4452
|
+
if (key.toLowerCase() === name) {
|
|
4453
|
+
return singleHeaderValue(value);
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
return void 0;
|
|
4457
|
+
}
|
|
4458
|
+
var IDENTITY_HEADER, SESSION_HEADER, PROVIDER_HEADER, SELF_HOSTED_HEADER, HEADROOM_FLAG_HEADER, PROJECT_ID_HEADER, AUTH_HEADER;
|
|
4442
4459
|
var init_route = __esm({
|
|
4443
4460
|
"src/frontdoor/route.ts"() {
|
|
4444
4461
|
"use strict";
|
|
4445
4462
|
IDENTITY_HEADER = "x-agent-shim-identity";
|
|
4446
4463
|
SESSION_HEADER = "x-agent-shim-session";
|
|
4447
4464
|
PROVIDER_HEADER = "x-agent-shim-provider";
|
|
4465
|
+
SELF_HOSTED_HEADER = "x-agent-shim-self-hosted";
|
|
4448
4466
|
HEADROOM_FLAG_HEADER = "x-agent-shim-headroom";
|
|
4449
4467
|
PROJECT_ID_HEADER = "x-headroom-project-id";
|
|
4450
4468
|
AUTH_HEADER = "x-agent-shim-auth";
|
|
@@ -5457,7 +5475,7 @@ function pruneDeadFrontDoorDirectRecords(fs17, recordsDir, records, liveness) {
|
|
|
5457
5475
|
}
|
|
5458
5476
|
}
|
|
5459
5477
|
function recordOf(details) {
|
|
5460
|
-
return details === void 0 ? {} : { sessionId: details.sessionId, ...details.identity === void 0 ? {} : { identity: details.identity }, ...details.models === void 0 ? {} : { models: details.models } };
|
|
5478
|
+
return details === void 0 ? {} : { sessionId: details.sessionId, ...details.identity === void 0 ? {} : { identity: details.identity }, ...details.models === void 0 ? {} : { models: details.models }, ...details.configDir === void 0 ? {} : { configDir: details.configDir } };
|
|
5461
5479
|
}
|
|
5462
5480
|
function writeFrontDoorSession(fs17, sessionsDir, session) {
|
|
5463
5481
|
fs17.mkdirPrivate(sessionsDir);
|
|
@@ -5531,9 +5549,9 @@ var init_state = __esm({
|
|
|
5531
5549
|
"use strict";
|
|
5532
5550
|
init_schema();
|
|
5533
5551
|
init_baseUrlDial();
|
|
5534
|
-
FRONT_DOOR_PROTOCOL =
|
|
5552
|
+
FRONT_DOOR_PROTOCOL = 10;
|
|
5535
5553
|
FRONT_DOOR_HANDOVER_PROTOCOL = 6;
|
|
5536
|
-
FrontDoorSessionSchema = z9.strictObject({ pid: z9.number().int().positive(), startedAt: z9.number(), token: z9.string().min(1), supervisorPid: z9.number().int().positive().optional(), sessionId: z9.string().min(1).optional(), identity: z9.string().min(1).optional(), models: ModelsConfigSchema.optional() });
|
|
5554
|
+
FrontDoorSessionSchema = z9.strictObject({ pid: z9.number().int().positive(), startedAt: z9.number(), token: z9.string().min(1), supervisorPid: z9.number().int().positive().optional(), sessionId: z9.string().min(1).optional(), identity: z9.string().min(1).optional(), models: ModelsConfigSchema.optional(), configDir: z9.string().min(1).optional() });
|
|
5537
5555
|
MAX_CONTEXT_TEXT_LENGTH = 256;
|
|
5538
5556
|
ContextText = z9.string().min(1).max(MAX_CONTEXT_TEXT_LENGTH);
|
|
5539
5557
|
LaunchRouteSchema = z9.union([z9.strictObject({ kind: z9.literal("anthropic") }), z9.strictObject({ kind: z9.literal("provider"), provider: z9.string().min(1) })]);
|
|
@@ -5833,6 +5851,24 @@ function parseConnectTarget(authority) {
|
|
|
5833
5851
|
function isInterceptedHost(host, interceptHosts) {
|
|
5834
5852
|
return interceptHosts.includes(host);
|
|
5835
5853
|
}
|
|
5854
|
+
function canonicalRequestTarget(target) {
|
|
5855
|
+
const raw = target ?? "/";
|
|
5856
|
+
const absolute = raw.startsWith("/") ? `${TARGET_BASE}${raw}` : void 0;
|
|
5857
|
+
if (absolute === void 0 ? !URL.canParse(raw, TARGET_BASE) : !URL.canParse(absolute)) {
|
|
5858
|
+
return void 0;
|
|
5859
|
+
}
|
|
5860
|
+
const parsed = absolute === void 0 ? new URL(raw, TARGET_BASE) : new URL(absolute);
|
|
5861
|
+
const canonical = `${parsed.pathname}${parsed.search}`;
|
|
5862
|
+
return new URL(canonical, TARGET_BASE).pathname === parsed.pathname ? canonical : void 0;
|
|
5863
|
+
}
|
|
5864
|
+
function answerAndClose(response, status) {
|
|
5865
|
+
if (response.headersSent) {
|
|
5866
|
+
response.destroy();
|
|
5867
|
+
return;
|
|
5868
|
+
}
|
|
5869
|
+
response.writeHead(status, { "content-length": "0", connection: "close" });
|
|
5870
|
+
response.end();
|
|
5871
|
+
}
|
|
5836
5872
|
function servedByPipeline(path59) {
|
|
5837
5873
|
return path59?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5838
5874
|
}
|
|
@@ -5891,10 +5927,36 @@ function caParses(ca) {
|
|
|
5891
5927
|
}
|
|
5892
5928
|
async function startConnectServer(config, effects, source) {
|
|
5893
5929
|
const tunnelTokens = /* @__PURE__ */ new WeakMap();
|
|
5894
|
-
|
|
5930
|
+
let generation = config.localSurface?.mintGeneration();
|
|
5931
|
+
const redirectedSessions = /* @__PURE__ */ new Set();
|
|
5932
|
+
const ledger = createConnectionLedger(config.limits, config.isLiveCapability, () => {
|
|
5933
|
+
checkGeneration();
|
|
5934
|
+
});
|
|
5935
|
+
function checkGeneration() {
|
|
5936
|
+
const surface = config.localSurface;
|
|
5937
|
+
if (surface === void 0) {
|
|
5938
|
+
return;
|
|
5939
|
+
}
|
|
5940
|
+
const current = surface.mintGeneration();
|
|
5941
|
+
if (current === generation) {
|
|
5942
|
+
return;
|
|
5943
|
+
}
|
|
5944
|
+
config.log?.("connect: the self-hosted mint changed, so every intercepted session and tunnel is ended and decided again on reconnection");
|
|
5945
|
+
generation = current;
|
|
5946
|
+
ledger.endAuthenticated();
|
|
5947
|
+
for (const secure of redirectedSessions) {
|
|
5948
|
+
secure.destroy();
|
|
5949
|
+
}
|
|
5950
|
+
}
|
|
5895
5951
|
const lateSessionDeadlines = /* @__PURE__ */ new WeakMap();
|
|
5952
|
+
const owned = /* @__PURE__ */ new WeakMap();
|
|
5953
|
+
const ownedBySurface = (secure) => owned.get(secure) === true;
|
|
5896
5954
|
const onUpgrade = (host) => (request4, socket, head) => {
|
|
5897
5955
|
config.capture?.upgrade(request4);
|
|
5956
|
+
if (ownedBySurface(request4.socket)) {
|
|
5957
|
+
socket.end(REFUSED_UPGRADE_RESPONSE);
|
|
5958
|
+
return;
|
|
5959
|
+
}
|
|
5898
5960
|
if (head.length > 0) {
|
|
5899
5961
|
socket.pause();
|
|
5900
5962
|
socket.unshift(head);
|
|
@@ -5905,8 +5967,8 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5905
5967
|
`;
|
|
5906
5968
|
pumpTapSession(socket, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn), config.capture?.tapStream?.(host), Buffer.from(headText, "utf8"));
|
|
5907
5969
|
};
|
|
5908
|
-
const
|
|
5909
|
-
if (config.tapHosts.includes(host) && !
|
|
5970
|
+
const sessionsFor = (ownedSet) => config.interceptHosts.map((host) => {
|
|
5971
|
+
if (config.tapHosts.includes(host) && !ownedSet) {
|
|
5910
5972
|
const serveSecure2 = (secure) => {
|
|
5911
5973
|
pumpTapSession(secure, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn), config.capture?.tapStream?.(host));
|
|
5912
5974
|
};
|
|
@@ -5914,13 +5976,24 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5914
5976
|
return { host, serveSecure: serveSecure2, tlsAcceptor: tlsAcceptor2 };
|
|
5915
5977
|
}
|
|
5916
5978
|
const handleHostRequest = async (request4, response) => {
|
|
5979
|
+
checkGeneration();
|
|
5980
|
+
if (request4.socket.destroyed) {
|
|
5981
|
+
return;
|
|
5982
|
+
}
|
|
5983
|
+
const target = canonicalRequestTarget(request4.url);
|
|
5984
|
+
if (target === void 0) {
|
|
5985
|
+
request4.resume();
|
|
5986
|
+
answerAndClose(response, REQUEST_STATUS.badRequest);
|
|
5987
|
+
return;
|
|
5988
|
+
}
|
|
5989
|
+
request4.url = target;
|
|
5917
5990
|
if (ledger.retiring()) {
|
|
5918
5991
|
clearTimeout(lateSessionDeadlines.get(request4.socket));
|
|
5919
5992
|
response.once("close", () => {
|
|
5920
5993
|
request4.socket.end();
|
|
5921
5994
|
});
|
|
5922
5995
|
}
|
|
5923
|
-
if (config.localSurface !== void 0 && await config.localSurface.serve(host, request4, response)) {
|
|
5996
|
+
if (config.localSurface !== void 0 && ownedBySurface(request4.socket) && await config.localSurface.serve(host, request4, response)) {
|
|
5924
5997
|
return;
|
|
5925
5998
|
}
|
|
5926
5999
|
if (host === config.routedHost && servedByPipeline(request4.url)) {
|
|
@@ -5928,17 +6001,28 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5928
6001
|
if (tunnelToken !== void 0 && request4.headers[AUTH_HEADER] === void 0) {
|
|
5929
6002
|
request4.headers[AUTH_HEADER] = tunnelToken;
|
|
5930
6003
|
}
|
|
6004
|
+
request4.headers[SELF_HOSTED_HEADER] = ownedBySurface(request4.socket) ? "1" : void 0;
|
|
5931
6005
|
config.serveRouted(request4, response);
|
|
5932
6006
|
return;
|
|
5933
6007
|
}
|
|
6008
|
+
if (ownedBySurface(request4.socket)) {
|
|
6009
|
+
request4.resume();
|
|
6010
|
+
answerAndClose(response, REQUEST_STATUS.notFound);
|
|
6011
|
+
return;
|
|
6012
|
+
}
|
|
5934
6013
|
effects.forwardHttp(config.upstreamFor(host), request4, response, config.capture?.observePassthrough(request4));
|
|
5935
6014
|
};
|
|
5936
6015
|
const handler = (request4, response) => {
|
|
5937
|
-
|
|
6016
|
+
handleHostRequest(request4, response).catch((error) => {
|
|
6017
|
+
config.log?.(`connect: serving ${request4.method ?? "?"} on ${host} failed: ${error instanceof Error ? `${error.name}: ${error.message}` : String(error)}`);
|
|
6018
|
+
request4.resume();
|
|
6019
|
+
answerAndClose(response, REQUEST_STATUS.internalServerError);
|
|
6020
|
+
});
|
|
5938
6021
|
};
|
|
5939
6022
|
const httpSession = effects.createHttpSession(handler, onUpgrade(host));
|
|
5940
6023
|
const serveSecure = (secure, capability) => {
|
|
5941
6024
|
tunnelTokens.set(secure, capability);
|
|
6025
|
+
owned.set(secure, ownedSet);
|
|
5942
6026
|
if (ledger.retiring()) {
|
|
5943
6027
|
const deadline = setTimeout(() => {
|
|
5944
6028
|
secure.destroy();
|
|
@@ -5951,18 +6035,42 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5951
6035
|
const tlsAcceptor = effects.createTlsAcceptor(config.leafFor(host), serveSecure);
|
|
5952
6036
|
return { host, serveSecure, httpSession, tlsAcceptor };
|
|
5953
6037
|
});
|
|
6038
|
+
const sessions = sessionsFor(false);
|
|
6039
|
+
const ownedSessions = config.localSurface === void 0 ? void 0 : sessionsFor(true);
|
|
5954
6040
|
const listener = await effects.listenLoopback(source, (socket) => {
|
|
5955
|
-
handleConnect(socket, { config, effects, sessions, ledger });
|
|
6041
|
+
handleConnect(socket, { config, effects, sessions, ownedSessions, ledger, checkGeneration });
|
|
5956
6042
|
});
|
|
5957
6043
|
const apiSession = sessions.find((session) => session.host === config.routedHost);
|
|
5958
6044
|
const sessionByHost = new Map(sessions.map((session) => [session.host, session]));
|
|
5959
|
-
const
|
|
5960
|
-
|
|
6045
|
+
const ownedSessionByHost = new Map((ownedSessions ?? []).map((session) => [session.host, session]));
|
|
6046
|
+
const serveRedirected = (secure, host, isOwned) => {
|
|
6047
|
+
redirectedSessions.add(secure);
|
|
6048
|
+
secure.once("close", () => {
|
|
6049
|
+
redirectedSessions.delete(secure);
|
|
6050
|
+
});
|
|
6051
|
+
const session = (isOwned ? ownedSessionByHost : sessionByHost).get(host);
|
|
5961
6052
|
if (session === void 0) {
|
|
5962
6053
|
secure.destroy();
|
|
5963
6054
|
return;
|
|
5964
6055
|
}
|
|
5965
6056
|
session.serveSecure(secure, config.transparentCapability ?? "");
|
|
6057
|
+
};
|
|
6058
|
+
const sniAcceptor = effects.createSniTlsAcceptor(config.interceptHosts, config.leafFor, (secure, host) => {
|
|
6059
|
+
const surface = config.localSurface;
|
|
6060
|
+
if (surface === void 0) {
|
|
6061
|
+
serveRedirected(secure, host, false);
|
|
6062
|
+
return;
|
|
6063
|
+
}
|
|
6064
|
+
checkGeneration();
|
|
6065
|
+
surface.ownsPeer(secure.remotePort ?? 0).then(
|
|
6066
|
+
(isOwned) => {
|
|
6067
|
+
serveRedirected(secure, host, isOwned);
|
|
6068
|
+
},
|
|
6069
|
+
(error) => {
|
|
6070
|
+
config.log?.(`connect: attributing a redirected ${host} connection failed, so it is served as the local surface's: ${error instanceof Error ? error.message : String(error)}`);
|
|
6071
|
+
serveRedirected(secure, host, true);
|
|
6072
|
+
}
|
|
6073
|
+
);
|
|
5966
6074
|
});
|
|
5967
6075
|
const transparent = config.transparentPort === void 0 || apiSession === void 0 ? void 0 : await effects.listenLoopback({ preferredPort: config.transparentPort }, (socket) => {
|
|
5968
6076
|
sniAcceptor.accept(socket);
|
|
@@ -5972,7 +6080,7 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5972
6080
|
await listener.close();
|
|
5973
6081
|
await transparent?.close();
|
|
5974
6082
|
sniAcceptor.close();
|
|
5975
|
-
for (const { httpSession, tlsAcceptor } of sessions) {
|
|
6083
|
+
for (const { httpSession, tlsAcceptor } of [...sessions, ...ownedSessions ?? []]) {
|
|
5976
6084
|
tlsAcceptor.close();
|
|
5977
6085
|
httpSession?.close();
|
|
5978
6086
|
}
|
|
@@ -5991,7 +6099,7 @@ ${request4.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `$
|
|
|
5991
6099
|
close: closeSurface
|
|
5992
6100
|
};
|
|
5993
6101
|
}
|
|
5994
|
-
function createConnectionLedger(limits, isLiveCapability2) {
|
|
6102
|
+
function createConnectionLedger(limits, isLiveCapability2, onRevalidate = () => void 0) {
|
|
5995
6103
|
const pending = /* @__PURE__ */ new Map();
|
|
5996
6104
|
const authenticated = /* @__PURE__ */ new Map();
|
|
5997
6105
|
let tunnels = 0;
|
|
@@ -6007,6 +6115,7 @@ function createConnectionLedger(limits, isLiveCapability2) {
|
|
|
6007
6115
|
}
|
|
6008
6116
|
};
|
|
6009
6117
|
const revalidation = setInterval(() => {
|
|
6118
|
+
onRevalidate();
|
|
6010
6119
|
for (const [capability, sockets] of authenticated) {
|
|
6011
6120
|
if (!isLiveCapability2(capability)) {
|
|
6012
6121
|
for (const socket of sockets) {
|
|
@@ -6017,6 +6126,13 @@ function createConnectionLedger(limits, isLiveCapability2) {
|
|
|
6017
6126
|
}, limits.revalidateMs);
|
|
6018
6127
|
revalidation.unref();
|
|
6019
6128
|
return {
|
|
6129
|
+
endAuthenticated: () => {
|
|
6130
|
+
for (const sockets of authenticated.values()) {
|
|
6131
|
+
for (const socket of sockets) {
|
|
6132
|
+
socket.destroy();
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
},
|
|
6020
6136
|
accept: (socket) => {
|
|
6021
6137
|
const [oldest] = pending.keys();
|
|
6022
6138
|
if (pending.size >= limits.maxPendingHeads && oldest !== void 0) {
|
|
@@ -6087,6 +6203,22 @@ function createConnectionLedger(limits, isLiveCapability2) {
|
|
|
6087
6203
|
}
|
|
6088
6204
|
};
|
|
6089
6205
|
}
|
|
6206
|
+
function refuseWithReason(socket, status, rule, reason) {
|
|
6207
|
+
socket.removeAllListeners("data");
|
|
6208
|
+
socket.pause();
|
|
6209
|
+
if (socket.destroyed || socket.writableEnded) {
|
|
6210
|
+
return;
|
|
6211
|
+
}
|
|
6212
|
+
socket.end(`HTTP/1.1 ${status}\r
|
|
6213
|
+
x-agent-shim-refusal: ${rule}\r
|
|
6214
|
+
content-type: text/plain; charset=utf-8\r
|
|
6215
|
+
content-length: ${String(Buffer.byteLength(reason))}\r
|
|
6216
|
+
connection: close\r
|
|
6217
|
+
\r
|
|
6218
|
+
${reason}`, () => {
|
|
6219
|
+
socket.destroy();
|
|
6220
|
+
});
|
|
6221
|
+
}
|
|
6090
6222
|
function refuse(socket, status, headers = []) {
|
|
6091
6223
|
socket.removeAllListeners("data");
|
|
6092
6224
|
socket.pause();
|
|
@@ -6137,7 +6269,7 @@ function proxyAuthorizationOf(head) {
|
|
|
6137
6269
|
return values.length === 1 ? value : void 0;
|
|
6138
6270
|
}
|
|
6139
6271
|
function routeConnect(socket, head, context) {
|
|
6140
|
-
const { config, effects, sessions, ledger } = context;
|
|
6272
|
+
const { config, effects, sessions, ownedSessions, ledger } = context;
|
|
6141
6273
|
const credential = proxyAuthorizationOf(head);
|
|
6142
6274
|
const capability = credential === void 0 ? void 0 : capabilityFromProxyAuthorization(credential);
|
|
6143
6275
|
if (capability === void 0 || !config.isLiveCapability(capability)) {
|
|
@@ -6152,7 +6284,14 @@ function routeConnect(socket, head, context) {
|
|
|
6152
6284
|
refuse(socket, REFUSAL.badRequest, target === void 0 ? [] : [`${REFUSAL_HEADER}: ${target.refusal}`]);
|
|
6153
6285
|
return;
|
|
6154
6286
|
}
|
|
6155
|
-
|
|
6287
|
+
context.checkGeneration();
|
|
6288
|
+
const isOwned = config.localSurface?.ownsLaunch(capability) === true;
|
|
6289
|
+
const session = (isOwned && ownedSessions !== void 0 ? ownedSessions : sessions).find((entry) => entry.host === target.host);
|
|
6290
|
+
if (session === void 0 && isOwned) {
|
|
6291
|
+
config.capture?.refusedTunnel(target);
|
|
6292
|
+
refuseWithReason(socket, REFUSAL.forbidden, SELF_HOSTED_TUNNEL_REFUSAL, `the front door's self-hosted Remote Control mode does not tunnel to ${target.host}: a self-hosted session reaches no host the door does not serve itself`);
|
|
6293
|
+
return;
|
|
6294
|
+
}
|
|
6156
6295
|
if (!ledger.establish(socket, capability, session === void 0 ? "blind" : "terminated")) {
|
|
6157
6296
|
refuse(socket, REFUSAL.serviceUnavailable);
|
|
6158
6297
|
return;
|
|
@@ -6220,7 +6359,7 @@ function realConnectCertStore(paths) {
|
|
|
6220
6359
|
}
|
|
6221
6360
|
};
|
|
6222
6361
|
}
|
|
6223
|
-
var CONNECT_INTERCEPT_HOST, CONNECT_INTERCEPT_HOSTS, ROUTED_PATH_PREFIX, HTTPS_PORT, HTTP_BAD_GATEWAY, CA_KEY_FILE_MODE, CONNECT_LINE_TOKENS, HEAD_TERMINATOR, MAX_CONNECT_HEAD_BYTES, CONNECT_ESTABLISHED, REFUSAL_HEADER, REFUSAL, CONNECT_LIMITS, CA_VALIDITY_DAYS, LEAF_VALIDITY_DAYS, CA_SUBJECT_COMMON_NAME, MS_PER_DAY, HOP_BY_HOP_HEADERS, TAP_ALPN_PROTOCOLS;
|
|
6362
|
+
var CONNECT_INTERCEPT_HOST, CONNECT_INTERCEPT_HOSTS, ROUTED_PATH_PREFIX, HTTPS_PORT, HTTP_BAD_GATEWAY, CA_KEY_FILE_MODE, CONNECT_LINE_TOKENS, HEAD_TERMINATOR, MAX_CONNECT_HEAD_BYTES, CONNECT_ESTABLISHED, REFUSAL_HEADER, REFUSAL, CONNECT_LIMITS, CA_VALIDITY_DAYS, LEAF_VALIDITY_DAYS, CA_SUBJECT_COMMON_NAME, MS_PER_DAY, TARGET_BASE, HOP_BY_HOP_HEADERS, REQUEST_STATUS, REFUSED_UPGRADE_RESPONSE, TAP_ALPN_PROTOCOLS, SELF_HOSTED_TUNNEL_REFUSAL;
|
|
6224
6363
|
var init_connect = __esm({
|
|
6225
6364
|
"src/frontdoor/connect.ts"() {
|
|
6226
6365
|
"use strict";
|
|
@@ -6243,6 +6382,7 @@ var init_connect = __esm({
|
|
|
6243
6382
|
REFUSAL_HEADER = "x-agent-shim-refusal";
|
|
6244
6383
|
REFUSAL = {
|
|
6245
6384
|
badRequest: "400 Bad Request",
|
|
6385
|
+
forbidden: "403 Forbidden",
|
|
6246
6386
|
proxyAuthenticationRequired: "407 Proxy Authentication Required",
|
|
6247
6387
|
requestTimeout: "408 Request Timeout",
|
|
6248
6388
|
headTooLarge: "431 Request Header Fields Too Large",
|
|
@@ -6258,6 +6398,7 @@ var init_connect = __esm({
|
|
|
6258
6398
|
LEAF_VALIDITY_DAYS = 397;
|
|
6259
6399
|
CA_SUBJECT_COMMON_NAME = "agent-shim front door CA";
|
|
6260
6400
|
MS_PER_DAY = 864e5;
|
|
6401
|
+
TARGET_BASE = "http://127.0.0.1";
|
|
6261
6402
|
HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
6262
6403
|
"connection",
|
|
6263
6404
|
"keep-alive",
|
|
@@ -6269,7 +6410,14 @@ var init_connect = __esm({
|
|
|
6269
6410
|
"transfer-encoding",
|
|
6270
6411
|
"upgrade"
|
|
6271
6412
|
]);
|
|
6413
|
+
REQUEST_STATUS = {
|
|
6414
|
+
badRequest: 400,
|
|
6415
|
+
notFound: 404,
|
|
6416
|
+
internalServerError: 500
|
|
6417
|
+
};
|
|
6418
|
+
REFUSED_UPGRADE_RESPONSE = "HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\nConnection: close\r\n\r\n";
|
|
6272
6419
|
TAP_ALPN_PROTOCOLS = ["h2", "http/1.1"];
|
|
6420
|
+
SELF_HOSTED_TUNNEL_REFUSAL = "self-hosted-remote-control";
|
|
6273
6421
|
}
|
|
6274
6422
|
});
|
|
6275
6423
|
|
|
@@ -7359,7 +7507,7 @@ function rcEventWriteResultFromAnswer(answer) {
|
|
|
7359
7507
|
return { ok: true, sequenceNums };
|
|
7360
7508
|
}
|
|
7361
7509
|
function noOAuthCredentialResult(sessionId) {
|
|
7362
|
-
return { ok: false, message: `no claude.ai OAuth bearer has been observed for session ${sessionId}: only worker calls crossed this door, and the worker JWT they carry is answered 401 on the client half. Reconnect Remote Control through this door and the create's own bearer will be observed
|
|
7510
|
+
return { ok: false, message: `no claude.ai OAuth bearer has been observed for session ${sessionId}: only worker calls crossed this door, and the worker JWT they carry is answered 401 on the client half. Reconnect Remote Control through this door and the create's own bearer will be observed`, refusal: "session-state" };
|
|
7363
7511
|
}
|
|
7364
7512
|
function rcSessionNotObservedMessage(sessionId) {
|
|
7365
7513
|
return `the front door has not observed Remote Control session ${sessionId}: it may never have passed through this door, or it ended or expired (an entry lives only a bounded idle period past its last observed traffic)`;
|
|
@@ -7380,7 +7528,7 @@ function rcWriteHeaders(credential) {
|
|
|
7380
7528
|
async function injectRcUserMessage(deps, sessionId, text) {
|
|
7381
7529
|
const credential = deps.credentialOf(sessionId);
|
|
7382
7530
|
if (credential === void 0) {
|
|
7383
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
7531
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
7384
7532
|
}
|
|
7385
7533
|
if (credential.authorization === void 0) {
|
|
7386
7534
|
return noOAuthCredentialResult(sessionId);
|
|
@@ -7477,22 +7625,22 @@ function questionAnswerInput(deps, sessionId, pending, decision) {
|
|
|
7477
7625
|
async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
7478
7626
|
const credential = deps.credentialOf(sessionId);
|
|
7479
7627
|
if (credential === void 0) {
|
|
7480
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
7628
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
7481
7629
|
}
|
|
7482
7630
|
if (credential.authorization === void 0) {
|
|
7483
7631
|
return noOAuthCredentialResult(sessionId);
|
|
7484
7632
|
}
|
|
7485
7633
|
const pending = deps.pendingOf(sessionId).find((candidate) => candidate.requestId === requestId);
|
|
7486
7634
|
if (pending === void 0) {
|
|
7487
|
-
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
|
|
7635
|
+
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`, refusal: "not-observed" };
|
|
7488
7636
|
}
|
|
7489
7637
|
const updatedInput = questionAnswerInput(deps, sessionId, pending, decision);
|
|
7490
7638
|
if (updatedInput !== void 0 && "error" in updatedInput) {
|
|
7491
|
-
return { ok: false, message: updatedInput.error };
|
|
7639
|
+
return { ok: false, message: updatedInput.error, refusal: "invalid-input" };
|
|
7492
7640
|
}
|
|
7493
7641
|
const release = deps.claimPending(sessionId, requestId);
|
|
7494
7642
|
if (release === void 0) {
|
|
7495
|
-
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
|
|
7643
|
+
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`, refusal: "session-state" };
|
|
7496
7644
|
}
|
|
7497
7645
|
const body = JSON.stringify(buildRcEventWriteBody(buildRcControlResponsePayload(requestId, decision, updatedInput?.input)));
|
|
7498
7646
|
let answer;
|
|
@@ -7513,7 +7661,7 @@ async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
|
7513
7661
|
async function deliverRcClientPayload(deps, sessionId, payload, action, to = "events") {
|
|
7514
7662
|
const credential = deps.credentialOf(sessionId);
|
|
7515
7663
|
if (credential === void 0) {
|
|
7516
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
7664
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
7517
7665
|
}
|
|
7518
7666
|
if (credential.authorization === void 0) {
|
|
7519
7667
|
return noOAuthCredentialResult(sessionId);
|
|
@@ -7538,7 +7686,7 @@ async function interruptRcSession(deps, sessionId) {
|
|
|
7538
7686
|
}
|
|
7539
7687
|
async function setRcSessionModel(deps, sessionId, model) {
|
|
7540
7688
|
if (model === "") {
|
|
7541
|
-
return { ok: false, message: "a set-model write needs a non-empty model id: the SDK's own field treats an omitted or null value as a reset to the session default, which this operation never sends, and an empty string is neither" };
|
|
7689
|
+
return { ok: false, message: "a set-model write needs a non-empty model id: the SDK's own field treats an omitted or null value as a reset to the session default, which this operation never sends, and an empty string is neither", refusal: "invalid-input" };
|
|
7542
7690
|
}
|
|
7543
7691
|
const requestId = deps.newUuid();
|
|
7544
7692
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcSetModelPayload(requestId, model), `set the model on session ${sessionId}`);
|
|
@@ -7551,7 +7699,7 @@ async function setRcSessionPermissionMode(deps, sessionId, mode) {
|
|
|
7551
7699
|
}
|
|
7552
7700
|
async function endRcSession(deps, sessionId, reason) {
|
|
7553
7701
|
if (reason === "") {
|
|
7554
|
-
return { ok: false, message: "an end-session write needs either no reason or a non-empty one: the worker reads an absent reason as its own unspecified form, and an empty string is neither" };
|
|
7702
|
+
return { ok: false, message: "an end-session write needs either no reason or a non-empty one: the worker reads an absent reason as its own unspecified form, and an empty string is neither", refusal: "invalid-input" };
|
|
7555
7703
|
}
|
|
7556
7704
|
const requestId = deps.newUuid();
|
|
7557
7705
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcEndSessionPayload(requestId, reason), `end session ${sessionId}`);
|
|
@@ -7569,10 +7717,10 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7569
7717
|
}
|
|
7570
7718
|
async function readRcSessionFile(deps, sessionId, path59, options) {
|
|
7571
7719
|
if (path59 === "") {
|
|
7572
|
-
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
7720
|
+
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none", refusal: "invalid-input" };
|
|
7573
7721
|
}
|
|
7574
7722
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7575
|
-
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
7723
|
+
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing", refusal: "invalid-input" };
|
|
7576
7724
|
}
|
|
7577
7725
|
const requestId = deps.newUuid();
|
|
7578
7726
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
|
|
@@ -7590,7 +7738,7 @@ async function getRcSessionMcpStatus(deps, sessionId) {
|
|
|
7590
7738
|
}
|
|
7591
7739
|
async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
|
|
7592
7740
|
if (serverName === "") {
|
|
7593
|
-
return { ok: false, message: "an mcp-reconnect write needs a non-empty server name: the SDK's own field names the server as mcp_status reports it, and an empty string names none" };
|
|
7741
|
+
return { ok: false, message: "an mcp-reconnect write needs a non-empty server name: the SDK's own field names the server as mcp_status reports it, and an empty string names none", refusal: "invalid-input" };
|
|
7594
7742
|
}
|
|
7595
7743
|
const requestId = deps.newUuid();
|
|
7596
7744
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpReconnectPayload(requestId, serverName), `reconnect MCP server ${serverName} on session ${sessionId}`);
|
|
@@ -7598,7 +7746,7 @@ async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
|
|
|
7598
7746
|
}
|
|
7599
7747
|
async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redirectUri) {
|
|
7600
7748
|
if (serverName === "" || redirectUri === "") {
|
|
7601
|
-
return { ok: false, message: "an mcp-authenticate write needs a non-empty server name and redirect URI: the CLI's own request names the server and where its OAuth flow redirects back to, and an empty string names neither" };
|
|
7749
|
+
return { ok: false, message: "an mcp-authenticate write needs a non-empty server name and redirect URI: the CLI's own request names the server and where its OAuth flow redirects back to, and an empty string names neither", refusal: "invalid-input" };
|
|
7602
7750
|
}
|
|
7603
7751
|
const requestId = deps.newUuid();
|
|
7604
7752
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpAuthenticatePayload(requestId, serverName, redirectUri), `authenticate MCP server ${serverName} on session ${sessionId}`);
|
|
@@ -7606,7 +7754,7 @@ async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redir
|
|
|
7606
7754
|
}
|
|
7607
7755
|
async function submitRcSessionMcpOAuthCallbackUrl(deps, sessionId, serverName, callbackUrl) {
|
|
7608
7756
|
if (serverName === "" || callbackUrl === "") {
|
|
7609
|
-
return { ok: false, message: "an mcp-oauth-callback-url write needs a non-empty server name and callback URL: the CLI's own request names the server and the URL its OAuth flow landed on, and an empty string names neither" };
|
|
7757
|
+
return { ok: false, message: "an mcp-oauth-callback-url write needs a non-empty server name and callback URL: the CLI's own request names the server and the URL its OAuth flow landed on, and an empty string names neither", refusal: "invalid-input" };
|
|
7610
7758
|
}
|
|
7611
7759
|
const requestId = deps.newUuid();
|
|
7612
7760
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpOAuthCallbackUrlPayload(requestId, serverName, callbackUrl), `hand MCP server ${serverName}'s OAuth callback to session ${sessionId}`);
|
|
@@ -7617,7 +7765,7 @@ async function sendRcKeepAlive(deps, sessionId) {
|
|
|
7617
7765
|
}
|
|
7618
7766
|
async function teleportRcSession(deps, sessionId, marker) {
|
|
7619
7767
|
if (marker === "") {
|
|
7620
|
-
return { ok: false, message: "a teleport write needs a non-empty marker: the teleport relay anchors on a marker line's uuid and string content, and an empty string carries neither" };
|
|
7768
|
+
return { ok: false, message: "a teleport write needs a non-empty marker: the teleport relay anchors on a marker line's uuid and string content, and an empty string carries neither", refusal: "invalid-input" };
|
|
7621
7769
|
}
|
|
7622
7770
|
return await deliverRcClientPayload(deps, sessionId, buildRcUserMessagePayload(deps.newUuid(), sessionId, marker), `teleport a marker into session ${sessionId}`, "teleport-events");
|
|
7623
7771
|
}
|
|
@@ -14129,7 +14277,7 @@ var init_package = __esm({
|
|
|
14129
14277
|
"package.json"() {
|
|
14130
14278
|
package_default = {
|
|
14131
14279
|
name: "claude-use",
|
|
14132
|
-
version: "14.
|
|
14280
|
+
version: "14.6.1",
|
|
14133
14281
|
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.",
|
|
14134
14282
|
license: "MIT",
|
|
14135
14283
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -18598,7 +18746,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18598
18746
|
const sessionId = params.supervised?.sessionId ?? randomUUID7();
|
|
18599
18747
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18600
18748
|
const sessionModels = isDeepStrictEqual(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18601
|
-
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
18749
|
+
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels }, configDir: decision.configDir ?? path55.join(os10.homedir(), ".claude") };
|
|
18602
18750
|
let frontDoor = frontDoorEngaged && frontDoorPort !== void 0 ? frontDoorPort.ensure(env.NODE_EXTRA_CA_CERTS, session) : void 0;
|
|
18603
18751
|
if (frontDoor !== void 0 && frontDoorPort !== void 0) {
|
|
18604
18752
|
let beforePid = frontDoor.supervisorPid;
|
|
@@ -20026,10 +20174,10 @@ function createRcSessionCommands(deps) {
|
|
|
20026
20174
|
return void 0;
|
|
20027
20175
|
}
|
|
20028
20176
|
if ("refused" in target) {
|
|
20029
|
-
return { kind: "refused", message: target.refused };
|
|
20177
|
+
return { kind: "refused", message: target.refused, refusal: "session-state" };
|
|
20030
20178
|
}
|
|
20031
20179
|
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
20032
|
-
return { kind: "refused", message: unverifiedVersionMessage(sessionId, target.version, route === "supervised" ? "its supervisor's control plugin has not loaded" : "its launch's control plugin has not loaded") };
|
|
20180
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, target.version, route === "supervised" ? "its supervisor's control plugin has not loaded" : "its launch's control plugin has not loaded"), refusal: "session-state" };
|
|
20033
20181
|
}
|
|
20034
20182
|
return { kind: route, target };
|
|
20035
20183
|
};
|
|
@@ -20043,18 +20191,18 @@ function createRcSessionCommands(deps) {
|
|
|
20043
20191
|
return launched;
|
|
20044
20192
|
}
|
|
20045
20193
|
if (!deps.isObserved(sessionId)) {
|
|
20046
|
-
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}
|
|
20194
|
+
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}`, refusal: "not-observed" };
|
|
20047
20195
|
}
|
|
20048
20196
|
if (deps.selfHost === void 0) {
|
|
20049
|
-
return { kind: "refused", message: unsupportedMessage(sessionId) };
|
|
20197
|
+
return { kind: "refused", message: unsupportedMessage(sessionId), refusal: "session-state" };
|
|
20050
20198
|
}
|
|
20051
20199
|
const unavailable = deps.selfHost.unavailable();
|
|
20052
20200
|
if (unavailable !== void 0) {
|
|
20053
|
-
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}
|
|
20201
|
+
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}`, refusal: "session-state" };
|
|
20054
20202
|
}
|
|
20055
20203
|
const version = deps.selfHost.versionOf(sessionId);
|
|
20056
20204
|
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
20057
|
-
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
20205
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one"), refusal: "session-state" };
|
|
20058
20206
|
}
|
|
20059
20207
|
return { kind: "self-hosted", selfHost: deps.selfHost };
|
|
20060
20208
|
};
|
|
@@ -20065,7 +20213,7 @@ function createRcSessionCommands(deps) {
|
|
|
20065
20213
|
}
|
|
20066
20214
|
const resolved = await resolveRoute(sessionId);
|
|
20067
20215
|
if (resolved.kind === "refused") {
|
|
20068
|
-
return { ok: false, message: resolved.message };
|
|
20216
|
+
return { ok: false, message: resolved.message, refusal: resolved.refusal };
|
|
20069
20217
|
}
|
|
20070
20218
|
if (resolved.kind !== "self-hosted") {
|
|
20071
20219
|
const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
@@ -20091,7 +20239,7 @@ function createRcSessionCommands(deps) {
|
|
|
20091
20239
|
const transcriptGoal = async (sessionId, target) => {
|
|
20092
20240
|
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
20093
20241
|
if (goal === void 0) {
|
|
20094
|
-
return { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where its goal is read from; retry once it has finished a turn
|
|
20242
|
+
return { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where its goal is read from; retry once it has finished a turn`, refusal: "session-state" };
|
|
20095
20243
|
}
|
|
20096
20244
|
return { ok: true, report: goal };
|
|
20097
20245
|
};
|
|
@@ -20107,7 +20255,7 @@ function createRcSessionCommands(deps) {
|
|
|
20107
20255
|
const waitOf = (options) => options.waitMs;
|
|
20108
20256
|
const transcriptPluginTurns = async (sessionId, target) => {
|
|
20109
20257
|
const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
|
|
20110
|
-
return turns === void 0 ? { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where a turn is confirmed from; retry once it has finished a turn
|
|
20258
|
+
return turns === void 0 ? { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where a turn is confirmed from; retry once it has finished a turn`, refusal: "session-state" } : { ok: true, report: turns };
|
|
20111
20259
|
};
|
|
20112
20260
|
return {
|
|
20113
20261
|
/** Which route the verbs would take for the session now, or the refusal naming why none would; reads only, outside the session's queue, so a verb waiting on the session never delays it. */
|
|
@@ -20120,13 +20268,13 @@ function createRcSessionCommands(deps) {
|
|
|
20120
20268
|
*/
|
|
20121
20269
|
turn: async (sessionId, text, options = {}) => {
|
|
20122
20270
|
if (text.trim() === "") {
|
|
20123
|
-
return { ok: false, message: "a turn needs non-empty text" };
|
|
20271
|
+
return { ok: false, message: "a turn needs non-empty text", refusal: "invalid-input" };
|
|
20124
20272
|
}
|
|
20125
20273
|
if (text.trimStart().startsWith("/")) {
|
|
20126
|
-
return { ok: false, message: "a turn's text starts with /, which the session would read as a slash command rather than a message, and the turn could not be confirmed as one; use the goal or compaction verbs for those commands, or start the text with something else" };
|
|
20274
|
+
return { ok: false, message: "a turn's text starts with /, which the session would read as a slash command rather than a message, and the turn could not be confirmed as one; use the goal or compaction verbs for those commands, or start the text with something else", refusal: "invalid-input" };
|
|
20127
20275
|
}
|
|
20128
20276
|
if (text.length > RC_TURN_TEXT_MAX_CHARS) {
|
|
20129
|
-
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text.length)}
|
|
20277
|
+
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text.length)}`, refusal: "invalid-input" };
|
|
20130
20278
|
}
|
|
20131
20279
|
return await onRoute(sessionId, options, {
|
|
20132
20280
|
plugin: async (target, route, signal, waitMs) => {
|
|
@@ -20175,16 +20323,16 @@ function createRcSessionCommands(deps) {
|
|
|
20175
20323
|
goalSet: async (sessionId, condition, options = {}) => {
|
|
20176
20324
|
const trimmed = condition.trim();
|
|
20177
20325
|
if (trimmed === "") {
|
|
20178
|
-
return { ok: false, message: "a goal set needs a non-empty condition" };
|
|
20326
|
+
return { ok: false, message: "a goal set needs a non-empty condition", refusal: "invalid-input" };
|
|
20179
20327
|
}
|
|
20180
20328
|
if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
|
|
20181
|
-
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
|
|
20329
|
+
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`, refusal: "invalid-input" };
|
|
20182
20330
|
}
|
|
20183
20331
|
if (/[\r\n]/u.test(trimmed)) {
|
|
20184
|
-
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" };
|
|
20332
|
+
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", refusal: "invalid-input" };
|
|
20185
20333
|
}
|
|
20186
20334
|
if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
|
|
20187
|
-
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}
|
|
20335
|
+
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}`, refusal: "invalid-input" };
|
|
20188
20336
|
}
|
|
20189
20337
|
return await onRoute(sessionId, options, {
|
|
20190
20338
|
plugin: async (target, route, signal, waitMs) => {
|
|
@@ -20327,17 +20475,25 @@ function doorApiAuth(expectedToken) {
|
|
|
20327
20475
|
}
|
|
20328
20476
|
var RC_API_TAG = "remote-control";
|
|
20329
20477
|
var RC_DIRECTIVE_TAG = "remote-control-directives";
|
|
20478
|
+
var RC_REFUSAL_CODES = {
|
|
20479
|
+
"invalid-input": "BAD_REQUEST",
|
|
20480
|
+
"not-observed": "NOT_FOUND",
|
|
20481
|
+
"session-state": "CONFLICT"
|
|
20482
|
+
};
|
|
20483
|
+
function refusalOf(failure) {
|
|
20484
|
+
return new ORPCError(failure.refusal === void 0 ? "BAD_GATEWAY" : RC_REFUSAL_CODES[failure.refusal], { message: failure.message });
|
|
20485
|
+
}
|
|
20330
20486
|
function createRcApiRouter(deps) {
|
|
20331
20487
|
const authed = doorApiAuth(deps.expectedToken);
|
|
20332
20488
|
const delivered = (sessionId, result) => {
|
|
20333
20489
|
if (!result.ok) {
|
|
20334
|
-
throw
|
|
20490
|
+
throw refusalOf(result);
|
|
20335
20491
|
}
|
|
20336
20492
|
return result.sequenceNums;
|
|
20337
20493
|
};
|
|
20338
20494
|
const deliveredControl = (sessionId, result) => {
|
|
20339
20495
|
if (!result.ok) {
|
|
20340
|
-
throw
|
|
20496
|
+
throw refusalOf(result);
|
|
20341
20497
|
}
|
|
20342
20498
|
if (result.requestId === void 0) {
|
|
20343
20499
|
throw new ORPCError("INTERNAL_SERVER_ERROR", { message: "the control request was delivered but the door cannot name the request id it minted, so the worker's answer cannot be matched" });
|
|
@@ -20346,7 +20502,7 @@ function createRcApiRouter(deps) {
|
|
|
20346
20502
|
};
|
|
20347
20503
|
const commanded = (sessionId, result) => {
|
|
20348
20504
|
if (!result.ok) {
|
|
20349
|
-
throw
|
|
20505
|
+
throw refusalOf(result);
|
|
20350
20506
|
}
|
|
20351
20507
|
return { session: sessionId, ...result.report };
|
|
20352
20508
|
};
|
|
@@ -20985,7 +21141,7 @@ var ResetRowSchema = z29.strictObject({
|
|
|
20985
21141
|
var ResetScheduleSchema = z29.strictObject({ resets: z29.readonly(z29.array(ResetRowSchema)) });
|
|
20986
21142
|
|
|
20987
21143
|
// src/frontdoor/controlSchemas.ts
|
|
20988
|
-
import
|
|
21144
|
+
import path46 from "node:path";
|
|
20989
21145
|
import { z as z39 } from "zod";
|
|
20990
21146
|
|
|
20991
21147
|
// src/codex/doctor.ts
|
|
@@ -21075,7 +21231,7 @@ init_signIn();
|
|
|
21075
21231
|
init_identityAccounts();
|
|
21076
21232
|
init_read();
|
|
21077
21233
|
init_providerReachability();
|
|
21078
|
-
import
|
|
21234
|
+
import path45 from "node:path";
|
|
21079
21235
|
|
|
21080
21236
|
// src/doctorNameFinding.ts
|
|
21081
21237
|
init_names();
|
|
@@ -21920,6 +22076,284 @@ function pushHeadroomAllowlist(push, allowlist, daemon) {
|
|
|
21920
22076
|
// src/doctorReport.ts
|
|
21921
22077
|
init_state2();
|
|
21922
22078
|
init_supervisor2();
|
|
22079
|
+
|
|
22080
|
+
// src/frontdoor/rcSelfHostMint.ts
|
|
22081
|
+
init_identityRecords();
|
|
22082
|
+
init_account();
|
|
22083
|
+
import path44 from "node:path";
|
|
22084
|
+
|
|
22085
|
+
// src/frontdoor/rcSelfHostLocal.ts
|
|
22086
|
+
init_http();
|
|
22087
|
+
init_rcControl();
|
|
22088
|
+
|
|
22089
|
+
// src/frontdoor/rcSelfHostOffline.ts
|
|
22090
|
+
init_http();
|
|
22091
|
+
var GITHUB_SYNC_PATH = /^\/api\/oauth\/organizations\/[^/]+\/sync\/github\/auth$/;
|
|
22092
|
+
var OFF_STATE_ENTRIES = [
|
|
22093
|
+
{ matches: (pathname) => pathname === "/api/claude_cli/bootstrap", answer: { status: HTTP_STATUS.ok, body: {} } },
|
|
22094
|
+
{ matches: (pathname) => pathname === "/api/claude_code_penguin_mode", answer: { status: HTTP_STATUS.ok, body: { enabled: false, disabled_reason: "preference" } } },
|
|
22095
|
+
{ matches: (pathname) => GITHUB_SYNC_PATH.test(pathname), answer: { status: HTTP_STATUS.ok, body: { is_authenticated: false } } },
|
|
22096
|
+
{ matches: (pathname) => pathname === "/v1/mcp_servers", answer: { status: HTTP_STATUS.ok, body: { data: [], next_page: null } } },
|
|
22097
|
+
{ matches: (pathname) => pathname === "/mcp-registry/v0/servers", answer: { status: HTTP_STATUS.ok, body: { servers: [], metadata: { count: 0 } } } }
|
|
22098
|
+
];
|
|
22099
|
+
function rcSelfHostOfflineAnswer(pathname) {
|
|
22100
|
+
const entry = OFF_STATE_ENTRIES.find((candidate) => candidate.matches(pathname));
|
|
22101
|
+
if (entry !== void 0) {
|
|
22102
|
+
return entry.answer;
|
|
22103
|
+
}
|
|
22104
|
+
return {
|
|
22105
|
+
status: HTTP_STATUS.notFound,
|
|
22106
|
+
body: { type: "error", error: { type: "not_found_error", message: `the front door's self-hosted Remote Control mode serves nothing at ${pathname}: a self-hosted session's calls are answered on this machine and never forwarded to the Anthropic hosts` } }
|
|
22107
|
+
};
|
|
22108
|
+
}
|
|
22109
|
+
function isRcSessionFamilyPath(pathname) {
|
|
22110
|
+
return pathname === "/v1/code/sessions" || pathname.startsWith("/v1/code/sessions/") || pathname === "/v1/sessions" || pathname.startsWith("/v1/sessions/");
|
|
22111
|
+
}
|
|
22112
|
+
|
|
22113
|
+
// src/frontdoor/rcSelfHostLocal.ts
|
|
22114
|
+
init_route();
|
|
22115
|
+
var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
|
|
22116
|
+
var RC_SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
22117
|
+
var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
|
|
22118
|
+
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
22119
|
+
var MS_PER_SECOND6 = 1e3;
|
|
22120
|
+
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
22121
|
+
function isRecord10(value) {
|
|
22122
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22123
|
+
}
|
|
22124
|
+
function parseJsonObject2(body) {
|
|
22125
|
+
let parsed;
|
|
22126
|
+
try {
|
|
22127
|
+
parsed = JSON.parse(body);
|
|
22128
|
+
} catch {
|
|
22129
|
+
return void 0;
|
|
22130
|
+
}
|
|
22131
|
+
return isRecord10(parsed) ? parsed : void 0;
|
|
22132
|
+
}
|
|
22133
|
+
function growthBookFeatures() {
|
|
22134
|
+
return {
|
|
22135
|
+
tengu_ccr_bridge: { defaultValue: true },
|
|
22136
|
+
tengu_bridge_repl_v2: { defaultValue: true },
|
|
22137
|
+
tengu_bridge_repl_v2_cse_shim_enabled: { defaultValue: true },
|
|
22138
|
+
tengu_bridge_min_version: { defaultValue: { minVersion: "0.0.0" } }
|
|
22139
|
+
};
|
|
22140
|
+
}
|
|
22141
|
+
var answerServerJson = (response, status, body) => {
|
|
22142
|
+
const text = JSON.stringify(body);
|
|
22143
|
+
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text, "utf8")) });
|
|
22144
|
+
response.end(text);
|
|
22145
|
+
};
|
|
22146
|
+
function createRcSelfHostLocal(deps) {
|
|
22147
|
+
const answerOffline = (method, pathname, request4, response) => {
|
|
22148
|
+
request4.resume();
|
|
22149
|
+
const offline = rcSelfHostOfflineAnswer(pathname);
|
|
22150
|
+
deps.log?.(`rc selfhost: answered ${method} ${pathname} locally with ${String(offline.status)}; a self-hosted session's calls never leave the door`);
|
|
22151
|
+
answerServerJson(response, offline.status, offline.body);
|
|
22152
|
+
};
|
|
22153
|
+
return {
|
|
22154
|
+
ownsLaunch: deps.ownsLaunch,
|
|
22155
|
+
ownsPeer: deps.ownsPeer,
|
|
22156
|
+
mintGeneration: () => {
|
|
22157
|
+
const minted = deps.credentialRecord();
|
|
22158
|
+
return minted === void 0 ? "none" : minted.identityId === void 0 ? "every" : `identity:${minted.identityId}`;
|
|
22159
|
+
},
|
|
22160
|
+
serve: async (host, request4, response) => {
|
|
22161
|
+
const method = (request4.method ?? "").toUpperCase();
|
|
22162
|
+
const pathname = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
22163
|
+
const minted = deps.credentialRecord();
|
|
22164
|
+
if (minted !== void 0 && minted.identityId === void 0) {
|
|
22165
|
+
request4.resume();
|
|
22166
|
+
deps.log?.(`rc selfhost: refused ${method} ${pathname}: the minted credential names no identity; mint it again`);
|
|
22167
|
+
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { type: "error", error: { type: "api_error", message: "the front door's self-hosted Remote Control credential was minted before the door recorded its identity, so no launch can be told apart from it; run agent-shim frontdoor rc selfhost mint <identity> again" } });
|
|
22168
|
+
return true;
|
|
22169
|
+
}
|
|
22170
|
+
if (host === RC_SELF_HOST_OAUTH_HOST) {
|
|
22171
|
+
if (method === "POST" && pathname === "/v1/oauth/token") {
|
|
22172
|
+
const body = parseJsonObject2(await deps.readBody(request4, CONTROL_BODY_CAP_BYTES));
|
|
22173
|
+
const record = deps.credentialRecord();
|
|
22174
|
+
if (record === void 0) {
|
|
22175
|
+
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
22176
|
+
return true;
|
|
22177
|
+
}
|
|
22178
|
+
if (body?.grant_type !== void 0 && body.grant_type !== "refresh_token") {
|
|
22179
|
+
answerServerJson(response, HTTP_STATUS.badRequest, { error: "unsupported_grant_type" });
|
|
22180
|
+
return true;
|
|
22181
|
+
}
|
|
22182
|
+
answerServerJson(response, HTTP_STATUS.ok, { access_token: record.accessToken, refresh_token: record.refreshToken, expires_in: RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS, scope: RC_SELF_HOST_SCOPE_LIST.join(" ") });
|
|
22183
|
+
return true;
|
|
22184
|
+
}
|
|
22185
|
+
if (method === "GET" && pathname === "/v1/oauth/hello") {
|
|
22186
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22187
|
+
return true;
|
|
22188
|
+
}
|
|
22189
|
+
answerOffline(method, pathname, request4, response);
|
|
22190
|
+
return true;
|
|
22191
|
+
}
|
|
22192
|
+
if (method === "POST" && pathname.startsWith("/api/eval/")) {
|
|
22193
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22194
|
+
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND6) });
|
|
22195
|
+
return true;
|
|
22196
|
+
}
|
|
22197
|
+
if (method === "GET" && pathname === "/api/oauth/profile") {
|
|
22198
|
+
const record = deps.credentialRecord();
|
|
22199
|
+
if (record === void 0) {
|
|
22200
|
+
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
22201
|
+
return true;
|
|
22202
|
+
}
|
|
22203
|
+
answerServerJson(response, HTTP_STATUS.ok, {
|
|
22204
|
+
// The email is required: the client's profile schema rejects an answer without `account.email`, discarding the whole profile.
|
|
22205
|
+
account: { uuid: record.accountUuid, email: RC_SELF_HOST_EMAIL, display_name: "agent-shim self-hosted", created_at: (/* @__PURE__ */ new Date(0)).toISOString() },
|
|
22206
|
+
organization: { uuid: record.organizationUuid, organization_type: "claude_max" }
|
|
22207
|
+
});
|
|
22208
|
+
return true;
|
|
22209
|
+
}
|
|
22210
|
+
if (method === "GET" && pathname === "/api/claude_code/policy_limits") {
|
|
22211
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22212
|
+
return true;
|
|
22213
|
+
}
|
|
22214
|
+
if (method === "POST" && pathname === "/api/oauth/validate") {
|
|
22215
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22216
|
+
const record = deps.credentialRecord();
|
|
22217
|
+
if (record === void 0) {
|
|
22218
|
+
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
22219
|
+
return true;
|
|
22220
|
+
}
|
|
22221
|
+
answerServerJson(response, HTTP_STATUS.ok, { scopes: [...RC_SELF_HOST_SCOPE_LIST], expiresAt: null, subscriptionType: "max", account_uuid: record.accountUuid, organization_uuid: record.organizationUuid });
|
|
22222
|
+
return true;
|
|
22223
|
+
}
|
|
22224
|
+
if (method === "POST" && (pathname === "/api/event_logging/v2/batch" || pathname === "/api/claude_code/metrics" || pathname === "/api/claude_cli_feedback")) {
|
|
22225
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22226
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22227
|
+
return true;
|
|
22228
|
+
}
|
|
22229
|
+
if (method === "GET" && pathname === "/api/hello") {
|
|
22230
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22231
|
+
return true;
|
|
22232
|
+
}
|
|
22233
|
+
if (pathname.startsWith("/v1/") && (isRcSessionFamilyPath(pathname) || internalHeaderValue(request4.headers, PROVIDER_HEADER) !== void 0)) {
|
|
22234
|
+
return false;
|
|
22235
|
+
}
|
|
22236
|
+
answerOffline(method, pathname, request4, response);
|
|
22237
|
+
return true;
|
|
22238
|
+
}
|
|
22239
|
+
};
|
|
22240
|
+
}
|
|
22241
|
+
|
|
22242
|
+
// src/frontdoor/rcSelfHostMint.ts
|
|
22243
|
+
init_capability();
|
|
22244
|
+
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
22245
|
+
var CLAUDE_JSON2 = ".claude.json";
|
|
22246
|
+
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
22247
|
+
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
22248
|
+
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
22249
|
+
function isRecord11(value) {
|
|
22250
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22251
|
+
}
|
|
22252
|
+
function readJsonObject(fs17, file) {
|
|
22253
|
+
const raw = fs17.readFileUtf8(file);
|
|
22254
|
+
if (raw === void 0) {
|
|
22255
|
+
return void 0;
|
|
22256
|
+
}
|
|
22257
|
+
let parsed;
|
|
22258
|
+
try {
|
|
22259
|
+
parsed = JSON.parse(raw);
|
|
22260
|
+
} catch {
|
|
22261
|
+
return void 0;
|
|
22262
|
+
}
|
|
22263
|
+
return isRecord11(parsed) ? parsed : void 0;
|
|
22264
|
+
}
|
|
22265
|
+
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
22266
|
+
const parsed = readJsonObject(fs17, path44.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
22267
|
+
if (parsed === void 0) {
|
|
22268
|
+
return void 0;
|
|
22269
|
+
}
|
|
22270
|
+
const { accessToken, refreshToken, organizationUuid, accountUuid, identityId } = parsed;
|
|
22271
|
+
if (typeof accessToken !== "string" || accessToken === "" || typeof refreshToken !== "string" || refreshToken === "" || typeof organizationUuid !== "string" || organizationUuid === "" || typeof accountUuid !== "string" || accountUuid === "") {
|
|
22272
|
+
return void 0;
|
|
22273
|
+
}
|
|
22274
|
+
return { accessToken, refreshToken, organizationUuid, accountUuid, ...typeof identityId === "string" && identityId !== "" ? { identityId } : {} };
|
|
22275
|
+
}
|
|
22276
|
+
function identitiesHoldingMint(fs17, identitiesDir, record) {
|
|
22277
|
+
return fs17.readdir(identitiesDir).filter((id) => {
|
|
22278
|
+
if (id.startsWith(".")) {
|
|
22279
|
+
return false;
|
|
22280
|
+
}
|
|
22281
|
+
const oauth = readJsonObject(fs17, path44.join(identitiesDir, id, CREDENTIALS_FILE2))?.claudeAiOauth;
|
|
22282
|
+
return isRecord11(oauth) && typeof oauth.accessToken === "string" && isLiveCapability(oauth.accessToken, [record.accessToken]);
|
|
22283
|
+
});
|
|
22284
|
+
}
|
|
22285
|
+
function rcSelfHostMintFacts(fs17, identitiesDir, frontdoorDir) {
|
|
22286
|
+
const record = readRcSelfHostRecord(fs17, frontdoorDir);
|
|
22287
|
+
if (record === void 0) {
|
|
22288
|
+
return {};
|
|
22289
|
+
}
|
|
22290
|
+
if (record.identityId !== void 0) {
|
|
22291
|
+
return { rcSelfHostMint: { attributable: true } };
|
|
22292
|
+
}
|
|
22293
|
+
const holders = identitiesHoldingMint(fs17, identitiesDir, record).length;
|
|
22294
|
+
return { rcSelfHostMint: { attributable: holders === 1, holders } };
|
|
22295
|
+
}
|
|
22296
|
+
function mintRcSelfHostCredential(deps) {
|
|
22297
|
+
if (!isIdentityName(deps.identity)) {
|
|
22298
|
+
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
22299
|
+
}
|
|
22300
|
+
const id = identityIdOver(deps.fs, deps.identitiesDir, deps.identity);
|
|
22301
|
+
if (id === void 0) {
|
|
22302
|
+
throw new Error(`No identity named "${deps.identity}".`);
|
|
22303
|
+
}
|
|
22304
|
+
const identityDir = path44.join(deps.identitiesDir, id);
|
|
22305
|
+
const credentialsFile = path44.join(identityDir, CREDENTIALS_FILE2);
|
|
22306
|
+
const claudeJsonFile = path44.join(identityDir, CLAUDE_JSON2);
|
|
22307
|
+
const recordDir = path44.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
22308
|
+
const recordFile2 = path44.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
22309
|
+
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
22310
|
+
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
22311
|
+
const existingOauth = isRecord11(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
22312
|
+
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
22313
|
+
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
22314
|
+
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
22315
|
+
throw new Error(
|
|
22316
|
+
`identity ${deps.identity} already holds an OAuth credential this door did not mint (a real claude.ai login): pass --force to replace it, or mint into an identity with no login. The self-hosted mode expects no Anthropic credential to be in play.`
|
|
22317
|
+
);
|
|
22318
|
+
}
|
|
22319
|
+
const accessToken = `sk-ant-oat${deps.randomToken()}`;
|
|
22320
|
+
const refreshToken = deps.randomToken();
|
|
22321
|
+
const organizationUuid = deps.newUuid();
|
|
22322
|
+
const accountUuid = deps.newUuid();
|
|
22323
|
+
const mintedAt = new Date(deps.now()).toISOString();
|
|
22324
|
+
deps.fs.mkdirPrivate(path44.dirname(credentialsFile));
|
|
22325
|
+
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)}
|
|
22326
|
+
`);
|
|
22327
|
+
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
22328
|
+
const existingBlock = (value) => isRecord11(value) ? value : {};
|
|
22329
|
+
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
22330
|
+
...claudeJson,
|
|
22331
|
+
oauthAccount: {
|
|
22332
|
+
...existingBlock(claudeJson.oauthAccount),
|
|
22333
|
+
accountUuid,
|
|
22334
|
+
emailAddress: RC_SELF_HOST_EMAIL,
|
|
22335
|
+
organizationUuid,
|
|
22336
|
+
organizationName: "agent-shim self-hosted",
|
|
22337
|
+
// The billing and creation fields exist so the CLI's "populate the account block if it is missing" step finds a complete block and skips its profile fetch; the door answers that fetch locally anyway, so these are the quiet path, not a load-bearing claim.
|
|
22338
|
+
billingType: "stripe_subscription",
|
|
22339
|
+
accountCreatedAt: mintedAt,
|
|
22340
|
+
subscriptionCreatedAt: mintedAt
|
|
22341
|
+
},
|
|
22342
|
+
cachedGrowthBookFeatures: {
|
|
22343
|
+
...existingBlock(claudeJson.cachedGrowthBookFeatures),
|
|
22344
|
+
tengu_ccr_bridge: true,
|
|
22345
|
+
tengu_bridge_repl_v2: true,
|
|
22346
|
+
tengu_bridge_repl_v2_cse_shim_enabled: true
|
|
22347
|
+
}
|
|
22348
|
+
}, null, 2)}
|
|
22349
|
+
`);
|
|
22350
|
+
deps.fs.mkdirPrivate(recordDir);
|
|
22351
|
+
deps.fs.writeFilePrivate(recordFile2, `${JSON.stringify({ accessToken, refreshToken, organizationUuid, accountUuid, identityId: id }, null, 2)}
|
|
22352
|
+
`);
|
|
22353
|
+
return { identity: deps.identity, organizationUuid, credentialsFile, claudeJsonFile, recordFile: recordFile2, replaced: existingIsOwn };
|
|
22354
|
+
}
|
|
22355
|
+
|
|
22356
|
+
// src/doctorReport.ts
|
|
21923
22357
|
init_state();
|
|
21924
22358
|
|
|
21925
22359
|
// src/doctorFrontDoor.ts
|
|
@@ -21981,6 +22415,17 @@ function pushFrontDoorListeners(push, readings) {
|
|
|
21981
22415
|
);
|
|
21982
22416
|
}
|
|
21983
22417
|
}
|
|
22418
|
+
function pushRcSelfHostMint(push, mint) {
|
|
22419
|
+
if (mint !== void 0 && !mint.attributable) {
|
|
22420
|
+
push("frontdoor", "fail", `The self-hosted Remote Control credential was minted before the door recorded its identity, and ${mint.holders === 0 ? "no identity holds it" : "more than one identity holds it"}, so a door with the mode on refuses every launch's calls on the intercepted hosts. Mint it again: agent-shim frontdoor rc selfhost mint <identity>.`);
|
|
22421
|
+
}
|
|
22422
|
+
}
|
|
22423
|
+
function pushFrontDoorReadings(push, readings) {
|
|
22424
|
+
if (readings.listeners !== void 0) {
|
|
22425
|
+
pushFrontDoorListeners(push, readings.listeners);
|
|
22426
|
+
}
|
|
22427
|
+
pushRcSelfHostMint(push, readings.rcSelfHostMint);
|
|
22428
|
+
}
|
|
21984
22429
|
|
|
21985
22430
|
// src/frontdoor/listenerReadings.ts
|
|
21986
22431
|
init_probe();
|
|
@@ -22173,7 +22618,7 @@ function tcpPortEraRecord(raw) {
|
|
|
22173
22618
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
22174
22619
|
}
|
|
22175
22620
|
function pushPathResolution(push, resolution) {
|
|
22176
|
-
const ownDir =
|
|
22621
|
+
const ownDir = path45.dirname(resolution.ownExecutablePath);
|
|
22177
22622
|
switch (resolution.agentShim.status) {
|
|
22178
22623
|
case "ok":
|
|
22179
22624
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -22293,14 +22738,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
22293
22738
|
}
|
|
22294
22739
|
function pushLegacyName(push, params) {
|
|
22295
22740
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
22296
|
-
if (legacyVariables.length === 0 &&
|
|
22741
|
+
if (legacyVariables.length === 0 && path45.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
22297
22742
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
22298
22743
|
return;
|
|
22299
22744
|
}
|
|
22300
22745
|
for (const name of legacyVariables) {
|
|
22301
22746
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
22302
22747
|
}
|
|
22303
|
-
if (
|
|
22748
|
+
if (path45.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
22304
22749
|
push(
|
|
22305
22750
|
"legacy-name",
|
|
22306
22751
|
"warn",
|
|
@@ -22390,7 +22835,7 @@ function runDoctor(params) {
|
|
|
22390
22835
|
push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
|
|
22391
22836
|
}
|
|
22392
22837
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
22393
|
-
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`,
|
|
22838
|
+
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, path45.basename(file));
|
|
22394
22839
|
}
|
|
22395
22840
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22396
22841
|
const signedInAccounts = [];
|
|
@@ -22660,9 +23105,7 @@ function runDoctor(params) {
|
|
|
22660
23105
|
if (params.frontDoor !== void 0) {
|
|
22661
23106
|
const validated3 = params.frontDoor.state.raw === void 0 ? void 0 : validateJson(FrontDoorStateSchema, params.frontDoor.state);
|
|
22662
23107
|
pushFrontDoor(push, params.frontDoor.supervisors, validated3?.ok === true ? validated3.data.supervisorPid : void 0, params.frontDoor.liveSessions, params.frontDoor.draining ?? []);
|
|
22663
|
-
|
|
22664
|
-
pushFrontDoorListeners(push, params.frontDoor.listeners);
|
|
22665
|
-
}
|
|
23108
|
+
pushFrontDoorReadings(push, params.frontDoor);
|
|
22666
23109
|
}
|
|
22667
23110
|
if (params.activeIdentity.raw === void 0) {
|
|
22668
23111
|
push("active-identity", "pass", "No active identity set.");
|
|
@@ -22688,9 +23131,9 @@ function collectDoctorReport(params) {
|
|
|
22688
23131
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22689
23132
|
const records = identityRecords(paths);
|
|
22690
23133
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
22691
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(
|
|
22692
|
-
const farmRoot =
|
|
22693
|
-
const identityPath =
|
|
23134
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(path45.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
23135
|
+
const farmRoot = path45.join(paths.identitiesDir, id);
|
|
23136
|
+
const identityPath = path45.join(farmRoot, "identity.json");
|
|
22694
23137
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs14.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
22695
23138
|
});
|
|
22696
23139
|
const usageSnapshots = {};
|
|
@@ -22708,12 +23151,12 @@ function collectDoctorReport(params) {
|
|
|
22708
23151
|
}
|
|
22709
23152
|
const profileNames = fs14.existsSync(paths.configProfilesDir) ? fs14.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22710
23153
|
const configProfiles = profileNames.map((name) => {
|
|
22711
|
-
const profilePath =
|
|
23154
|
+
const profilePath = path45.join(paths.configProfilesDir, `${name}.json`);
|
|
22712
23155
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22713
23156
|
});
|
|
22714
23157
|
const providerNames = fs14.existsSync(paths.providersDir) ? fs14.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22715
23158
|
const providers = providerNames.map((name) => {
|
|
22716
|
-
const providerPath =
|
|
23159
|
+
const providerPath = path45.join(paths.providersDir, `${name}.json`);
|
|
22717
23160
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22718
23161
|
});
|
|
22719
23162
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22725,12 +23168,12 @@ function collectDoctorReport(params) {
|
|
|
22725
23168
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22726
23169
|
}
|
|
22727
23170
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22728
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
23171
|
+
const pathDirs = (params.env.PATH ?? "").split(path45.delimiter).filter((dir) => dir !== "");
|
|
22729
23172
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22730
23173
|
findPathShadow({
|
|
22731
23174
|
pathDirs,
|
|
22732
|
-
targetDir:
|
|
22733
|
-
targetFilename:
|
|
23175
|
+
targetDir: path45.dirname(shimState.targetPath),
|
|
23176
|
+
targetFilename: path45.basename(shimState.targetPath),
|
|
22734
23177
|
findExecutableInDir
|
|
22735
23178
|
}),
|
|
22736
23179
|
shimState.targetPath,
|
|
@@ -22759,7 +23202,7 @@ function collectDoctorReport(params) {
|
|
|
22759
23202
|
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22760
23203
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22761
23204
|
unreachableIdentities,
|
|
22762
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(
|
|
23205
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(path45.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22763
23206
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22764
23207
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22765
23208
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22774,7 +23217,7 @@ function collectDoctorReport(params) {
|
|
|
22774
23217
|
agentShim: refinePathShadow(
|
|
22775
23218
|
findPathShadow({
|
|
22776
23219
|
pathDirs,
|
|
22777
|
-
targetDir:
|
|
23220
|
+
targetDir: path45.dirname(ownExecutablePath),
|
|
22778
23221
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22779
23222
|
findExecutableInDir
|
|
22780
23223
|
}),
|
|
@@ -22808,7 +23251,7 @@ function collectDoctorReport(params) {
|
|
|
22808
23251
|
logPath: paths.headroomLogPath
|
|
22809
23252
|
}
|
|
22810
23253
|
},
|
|
22811
|
-
...uid === void 0 ? {} : { frontDoor: { state: { path: paths.frontdoorStateFile, raw: realFsPort.readFileUtf8(paths.frontdoorStateFile) }, supervisors: listFrontDoorSupervisors(realRunPort, uid), liveSessions: listFrontDoorSessions(realFarmFs, paths.frontdoorSessionsDir).filter((session) => realIsProcessRunning(session.pid)), draining: listDrainingFrontDoors(realFarmFs, paths.frontdoorDrainingDir, realIsProcessRunning), listeners: servingDoorListeners(paths) } }
|
|
23254
|
+
...uid === void 0 ? {} : { frontDoor: { state: { path: paths.frontdoorStateFile, raw: realFsPort.readFileUtf8(paths.frontdoorStateFile) }, supervisors: listFrontDoorSupervisors(realRunPort, uid), liveSessions: listFrontDoorSessions(realFarmFs, paths.frontdoorSessionsDir).filter((session) => realIsProcessRunning(session.pid)), draining: listDrainingFrontDoors(realFarmFs, paths.frontdoorDrainingDir, realIsProcessRunning), listeners: servingDoorListeners(paths), ...rcSelfHostMintFacts(realFarmFs, paths.identitiesDir, paths.frontdoorDir) } }
|
|
22812
23255
|
});
|
|
22813
23256
|
return report;
|
|
22814
23257
|
}
|
|
@@ -22867,11 +23310,11 @@ var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread o
|
|
|
22867
23310
|
var CheckRunInputSchema = z39.strictObject({
|
|
22868
23311
|
path: z39.string().min(1),
|
|
22869
23312
|
identity: z39.string().min(1).optional()
|
|
22870
|
-
}).refine((input) =>
|
|
23313
|
+
}).refine((input) => path46.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22871
23314
|
var PoolPickInputSchema = z39.strictObject({
|
|
22872
23315
|
pool: z39.string().min(1),
|
|
22873
23316
|
path: z39.string().min(1)
|
|
22874
|
-
}).refine((input) =>
|
|
23317
|
+
}).refine((input) => path46.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22875
23318
|
var DoctorFindingSchema = z39.strictObject({
|
|
22876
23319
|
section: z39.enum(DOCTOR_SECTIONS),
|
|
22877
23320
|
subject: z39.string().optional(),
|
|
@@ -23663,7 +24106,7 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
|
|
|
23663
24106
|
import { openapi as openapi6 } from "@orpc/openapi";
|
|
23664
24107
|
|
|
23665
24108
|
// src/frontdoor/launchSchemas.ts
|
|
23666
|
-
import
|
|
24109
|
+
import path47 from "node:path";
|
|
23667
24110
|
import { z as z45 } from "zod";
|
|
23668
24111
|
init_statusline();
|
|
23669
24112
|
init_claudeVersion();
|
|
@@ -23674,7 +24117,7 @@ var LaunchResolveInputSchema = z45.strictObject({
|
|
|
23674
24117
|
argv: z45.readonly(z45.array(z45.string())).optional(),
|
|
23675
24118
|
/** 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. */
|
|
23676
24119
|
env: z45.record(z45.string(), z45.string()).optional()
|
|
23677
|
-
}).refine((input) =>
|
|
24120
|
+
}).refine((input) => path47.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23678
24121
|
var LaunchPoolDecisionSchema = z45.strictObject({
|
|
23679
24122
|
name: z45.string(),
|
|
23680
24123
|
reasons: z45.readonly(z45.array(z45.string())),
|
|
@@ -24512,15 +24955,15 @@ init_verifiedVersions();
|
|
|
24512
24955
|
// src/frontdoor/rcLiveUsage.ts
|
|
24513
24956
|
init_rcSchemas();
|
|
24514
24957
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
24515
|
-
function
|
|
24958
|
+
function isRecord12(value) {
|
|
24516
24959
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24517
24960
|
}
|
|
24518
24961
|
function rcRateLimitInfoOf(event) {
|
|
24519
24962
|
const payload = event.envelope.payload;
|
|
24520
|
-
if (!
|
|
24963
|
+
if (!isRecord12(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
24521
24964
|
return void 0;
|
|
24522
24965
|
}
|
|
24523
|
-
if (!
|
|
24966
|
+
if (!isRecord12(payload.rate_limit_info)) {
|
|
24524
24967
|
return void 0;
|
|
24525
24968
|
}
|
|
24526
24969
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -24609,7 +25052,7 @@ function createSseParser() {
|
|
|
24609
25052
|
}
|
|
24610
25053
|
};
|
|
24611
25054
|
}
|
|
24612
|
-
function
|
|
25055
|
+
function isRecord13(value) {
|
|
24613
25056
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24614
25057
|
}
|
|
24615
25058
|
function sequenceNumOf(value) {
|
|
@@ -24631,7 +25074,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
24631
25074
|
} catch {
|
|
24632
25075
|
return void 0;
|
|
24633
25076
|
}
|
|
24634
|
-
if (!
|
|
25077
|
+
if (!isRecord13(data)) {
|
|
24635
25078
|
return void 0;
|
|
24636
25079
|
}
|
|
24637
25080
|
const eventType = data.event_type;
|
|
@@ -24888,17 +25331,17 @@ function withClientPlatform(payload, headers) {
|
|
|
24888
25331
|
const platform = headers[CLIENT_PLATFORM_HEADER];
|
|
24889
25332
|
return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
|
|
24890
25333
|
}
|
|
24891
|
-
function
|
|
25334
|
+
function isRecord14(value) {
|
|
24892
25335
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24893
25336
|
}
|
|
24894
|
-
function
|
|
25337
|
+
function parseJsonObject3(body) {
|
|
24895
25338
|
let parsed;
|
|
24896
25339
|
try {
|
|
24897
25340
|
parsed = JSON.parse(body);
|
|
24898
25341
|
} catch {
|
|
24899
25342
|
return void 0;
|
|
24900
25343
|
}
|
|
24901
|
-
return
|
|
25344
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
24902
25345
|
}
|
|
24903
25346
|
function nonEmptyString2(record, field) {
|
|
24904
25347
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -24933,7 +25376,7 @@ function pageOfRcChannel(url, rows, idOf, rowOf3) {
|
|
|
24933
25376
|
async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
24934
25377
|
const { request: request4, response, host } = ctx;
|
|
24935
25378
|
if (tail === "client/presence" && method === "POST") {
|
|
24936
|
-
const body =
|
|
25379
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24937
25380
|
const clientId = nonEmptyString2(body, "client_id");
|
|
24938
25381
|
const clear = body?.clear;
|
|
24939
25382
|
if (clientId === void 0 || clear !== void 0 && typeof clear !== "boolean") {
|
|
@@ -24951,7 +25394,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24951
25394
|
return true;
|
|
24952
25395
|
}
|
|
24953
25396
|
if (tail === "mark_read" && method === "POST") {
|
|
24954
|
-
const body =
|
|
25397
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24955
25398
|
const eventId = nonEmptyString2(body, "event_id");
|
|
24956
25399
|
const clientId = nonEmptyString2(body, "client_id");
|
|
24957
25400
|
if (body !== void 0 && "event_id" in body && eventId === void 0 || "client_id" in (body ?? {}) && clientId === void 0) {
|
|
@@ -24964,7 +25407,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24964
25407
|
return true;
|
|
24965
25408
|
}
|
|
24966
25409
|
if (tail === "teleport-events" && method === "POST") {
|
|
24967
|
-
const body =
|
|
25410
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24968
25411
|
const events = body?.events;
|
|
24969
25412
|
if (!Array.isArray(events) || events.length === 0 || events.length > maxBatchEvents) {
|
|
24970
25413
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: `a teleport write is a non-empty array of at most ${String(maxBatchEvents)} events` } });
|
|
@@ -24972,7 +25415,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24972
25415
|
}
|
|
24973
25416
|
const results = [];
|
|
24974
25417
|
for (const event of events) {
|
|
24975
|
-
if (!
|
|
25418
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
24976
25419
|
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" } });
|
|
24977
25420
|
return true;
|
|
24978
25421
|
}
|
|
@@ -25036,7 +25479,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
25036
25479
|
await ctx.answerJson(response, HTTP_STATUS.notFound, { type: "error", error: { type: "api_error", message: `Session not found: ${address}` } });
|
|
25037
25480
|
return;
|
|
25038
25481
|
}
|
|
25039
|
-
const body =
|
|
25482
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
25040
25483
|
const title = nonEmptyString2(body, "title");
|
|
25041
25484
|
if (title === void 0) {
|
|
25042
25485
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "a compatibility session update is JSON naming a non-empty title" } });
|
|
@@ -25074,17 +25517,17 @@ init_http();
|
|
|
25074
25517
|
init_rcControl();
|
|
25075
25518
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
25076
25519
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
25077
|
-
function
|
|
25520
|
+
function isRecord15(value) {
|
|
25078
25521
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25079
25522
|
}
|
|
25080
|
-
function
|
|
25523
|
+
function parseJsonObject4(body) {
|
|
25081
25524
|
let parsed;
|
|
25082
25525
|
try {
|
|
25083
25526
|
parsed = JSON.parse(body);
|
|
25084
25527
|
} catch {
|
|
25085
25528
|
return void 0;
|
|
25086
25529
|
}
|
|
25087
|
-
return
|
|
25530
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
25088
25531
|
}
|
|
25089
25532
|
function nonEmptyString3(record, field) {
|
|
25090
25533
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -25130,7 +25573,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25130
25573
|
return;
|
|
25131
25574
|
}
|
|
25132
25575
|
if (tail === "events" && method === "POST") {
|
|
25133
|
-
const body =
|
|
25576
|
+
const body = parseJsonObject4(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
25134
25577
|
const events = body?.events;
|
|
25135
25578
|
if (!Array.isArray(events) || events.length === 0 || events.length > ctx.maxBatchEvents) {
|
|
25136
25579
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: `a client event write is a non-empty array of at most ${String(ctx.maxBatchEvents)} events` } });
|
|
@@ -25138,7 +25581,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25138
25581
|
}
|
|
25139
25582
|
const results = [];
|
|
25140
25583
|
for (const event of events) {
|
|
25141
|
-
if (!
|
|
25584
|
+
if (!isRecord15(event) || !isRecord15(event.payload)) {
|
|
25142
25585
|
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" } });
|
|
25143
25586
|
return;
|
|
25144
25587
|
}
|
|
@@ -25164,111 +25607,6 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25164
25607
|
await ctx.answerJson(response, HTTP_STATUS.notFound, { type: "error", error: { type: "api_error", message: `the conversation family serves no path "${tail}"` } });
|
|
25165
25608
|
}
|
|
25166
25609
|
|
|
25167
|
-
// src/frontdoor/rcSelfHostLocal.ts
|
|
25168
|
-
init_http();
|
|
25169
|
-
init_rcControl();
|
|
25170
|
-
var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
|
|
25171
|
-
var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
|
|
25172
|
-
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
25173
|
-
var MS_PER_SECOND6 = 1e3;
|
|
25174
|
-
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
25175
|
-
function isRecord14(value) {
|
|
25176
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25177
|
-
}
|
|
25178
|
-
function parseJsonObject4(body) {
|
|
25179
|
-
let parsed;
|
|
25180
|
-
try {
|
|
25181
|
-
parsed = JSON.parse(body);
|
|
25182
|
-
} catch {
|
|
25183
|
-
return void 0;
|
|
25184
|
-
}
|
|
25185
|
-
return isRecord14(parsed) ? parsed : void 0;
|
|
25186
|
-
}
|
|
25187
|
-
function growthBookFeatures() {
|
|
25188
|
-
return {
|
|
25189
|
-
tengu_ccr_bridge: { defaultValue: true },
|
|
25190
|
-
tengu_bridge_repl_v2: { defaultValue: true },
|
|
25191
|
-
tengu_bridge_repl_v2_cse_shim_enabled: { defaultValue: true },
|
|
25192
|
-
tengu_bridge_min_version: { defaultValue: { minVersion: "0.0.0" } }
|
|
25193
|
-
};
|
|
25194
|
-
}
|
|
25195
|
-
var answerServerJson = (response, status, body) => {
|
|
25196
|
-
const text = JSON.stringify(body);
|
|
25197
|
-
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text, "utf8")) });
|
|
25198
|
-
response.end(text);
|
|
25199
|
-
};
|
|
25200
|
-
function createRcSelfHostLocal(deps) {
|
|
25201
|
-
return {
|
|
25202
|
-
parsesHost: (host) => host === RC_SELF_HOST_OAUTH_HOST,
|
|
25203
|
-
serve: async (host, request4, response) => {
|
|
25204
|
-
const method = (request4.method ?? "").toUpperCase();
|
|
25205
|
-
const pathname = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
25206
|
-
if (host === RC_SELF_HOST_OAUTH_HOST) {
|
|
25207
|
-
if (method === "POST" && pathname === "/v1/oauth/token") {
|
|
25208
|
-
const body = parseJsonObject4(await deps.readBody(request4, CONTROL_BODY_CAP_BYTES));
|
|
25209
|
-
const record = deps.credentialRecord();
|
|
25210
|
-
if (record === void 0) {
|
|
25211
|
-
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
25212
|
-
return true;
|
|
25213
|
-
}
|
|
25214
|
-
if (body?.grant_type !== void 0 && body.grant_type !== "refresh_token") {
|
|
25215
|
-
answerServerJson(response, HTTP_STATUS.badRequest, { error: "unsupported_grant_type" });
|
|
25216
|
-
return true;
|
|
25217
|
-
}
|
|
25218
|
-
answerServerJson(response, HTTP_STATUS.ok, { access_token: record.accessToken, refresh_token: record.refreshToken, expires_in: RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS, scope: RC_SELF_HOST_SCOPE_LIST.join(" ") });
|
|
25219
|
-
return true;
|
|
25220
|
-
}
|
|
25221
|
-
if (method === "GET" && pathname === "/v1/oauth/hello") {
|
|
25222
|
-
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
25223
|
-
return true;
|
|
25224
|
-
}
|
|
25225
|
-
return false;
|
|
25226
|
-
}
|
|
25227
|
-
if (method === "POST" && pathname.startsWith("/api/eval/")) {
|
|
25228
|
-
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
25229
|
-
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND6) });
|
|
25230
|
-
return true;
|
|
25231
|
-
}
|
|
25232
|
-
if (method === "GET" && pathname === "/api/oauth/profile") {
|
|
25233
|
-
const record = deps.credentialRecord();
|
|
25234
|
-
if (record === void 0) {
|
|
25235
|
-
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
25236
|
-
return true;
|
|
25237
|
-
}
|
|
25238
|
-
answerServerJson(response, HTTP_STATUS.ok, {
|
|
25239
|
-
account: { uuid: record.accountUuid, display_name: "agent-shim self-hosted", created_at: (/* @__PURE__ */ new Date(0)).toISOString() },
|
|
25240
|
-
organization: { uuid: record.organizationUuid, organization_type: "claude_max" }
|
|
25241
|
-
});
|
|
25242
|
-
return true;
|
|
25243
|
-
}
|
|
25244
|
-
if (method === "GET" && pathname === "/api/claude_code/policy_limits") {
|
|
25245
|
-
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
25246
|
-
return true;
|
|
25247
|
-
}
|
|
25248
|
-
if (method === "POST" && pathname === "/api/oauth/validate") {
|
|
25249
|
-
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
25250
|
-
const record = deps.credentialRecord();
|
|
25251
|
-
if (record === void 0) {
|
|
25252
|
-
answerServerJson(response, HTTP_SERVICE_UNAVAILABLE, { error: "the front door's self-hosted Remote Control surface is on but no credential has been minted for it" });
|
|
25253
|
-
return true;
|
|
25254
|
-
}
|
|
25255
|
-
answerServerJson(response, HTTP_STATUS.ok, { scopes: [...RC_SELF_HOST_SCOPE_LIST], expiresAt: null, subscriptionType: "max", account_uuid: record.accountUuid, organization_uuid: record.organizationUuid });
|
|
25256
|
-
return true;
|
|
25257
|
-
}
|
|
25258
|
-
if (method === "POST" && (pathname === "/api/event_logging/v2/batch" || pathname === "/api/claude_code/metrics" || pathname === "/api/claude_cli_feedback")) {
|
|
25259
|
-
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
25260
|
-
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
25261
|
-
return true;
|
|
25262
|
-
}
|
|
25263
|
-
if (method === "GET" && pathname === "/api/hello") {
|
|
25264
|
-
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
25265
|
-
return true;
|
|
25266
|
-
}
|
|
25267
|
-
return false;
|
|
25268
|
-
}
|
|
25269
|
-
};
|
|
25270
|
-
}
|
|
25271
|
-
|
|
25272
25610
|
// src/frontdoor/rcWebFetch.ts
|
|
25273
25611
|
init_http();
|
|
25274
25612
|
init_connectEffects();
|
|
@@ -25547,7 +25885,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
25547
25885
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
25548
25886
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
25549
25887
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
25550
|
-
function
|
|
25888
|
+
function isRecord16(value) {
|
|
25551
25889
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25552
25890
|
}
|
|
25553
25891
|
function isWebSearchRefusal(value) {
|
|
@@ -25631,7 +25969,7 @@ function parseJsonObject5(body) {
|
|
|
25631
25969
|
} catch {
|
|
25632
25970
|
return void 0;
|
|
25633
25971
|
}
|
|
25634
|
-
return
|
|
25972
|
+
return isRecord16(parsed) ? parsed : void 0;
|
|
25635
25973
|
}
|
|
25636
25974
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
25637
25975
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -25891,7 +26229,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25891
26229
|
if (status !== void 0) {
|
|
25892
26230
|
session.workerStatus = status;
|
|
25893
26231
|
}
|
|
25894
|
-
if (
|
|
26232
|
+
if (isRecord16(body?.external_metadata)) {
|
|
25895
26233
|
session.externalMetadata = body.external_metadata;
|
|
25896
26234
|
}
|
|
25897
26235
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -25921,7 +26259,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25921
26259
|
}
|
|
25922
26260
|
const results = [];
|
|
25923
26261
|
for (const event of events) {
|
|
25924
|
-
if (!
|
|
26262
|
+
if (!isRecord16(event) || !isRecord16(event.payload)) {
|
|
25925
26263
|
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" } });
|
|
25926
26264
|
return;
|
|
25927
26265
|
}
|
|
@@ -25954,7 +26292,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25954
26292
|
return;
|
|
25955
26293
|
}
|
|
25956
26294
|
for (const event of events) {
|
|
25957
|
-
if (
|
|
26295
|
+
if (isRecord16(event)) {
|
|
25958
26296
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
25959
26297
|
}
|
|
25960
26298
|
}
|
|
@@ -26050,7 +26388,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
26050
26388
|
}
|
|
26051
26389
|
const results = [];
|
|
26052
26390
|
for (const event of events) {
|
|
26053
|
-
if (!
|
|
26391
|
+
if (!isRecord16(event) || !isRecord16(event.payload)) {
|
|
26054
26392
|
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" } });
|
|
26055
26393
|
return;
|
|
26056
26394
|
}
|
|
@@ -26095,7 +26433,9 @@ data: ${JSON.stringify(envelope)}
|
|
|
26095
26433
|
return;
|
|
26096
26434
|
}
|
|
26097
26435
|
if (pathname !== RC_SESSIONS_PATH_PREFIX2 && !pathname.startsWith(`${RC_SESSIONS_PATH_PREFIX2}/`)) {
|
|
26098
|
-
|
|
26436
|
+
const offline = rcSelfHostOfflineAnswer(pathname);
|
|
26437
|
+
deps.log?.(`rc selfhost: answered ${method} ${pathname} locally with ${String(offline.status)}; a self-hosted session's calls never leave the door`);
|
|
26438
|
+
await answerJson2(response, offline.status, offline.body);
|
|
26099
26439
|
return;
|
|
26100
26440
|
}
|
|
26101
26441
|
if (pathname === RC_SESSIONS_PATH_PREFIX2) {
|
|
@@ -26160,7 +26500,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
26160
26500
|
await serveSessionPath(sessions.get(id), tail, request4, response);
|
|
26161
26501
|
}
|
|
26162
26502
|
};
|
|
26163
|
-
const local = createRcSelfHostLocal({ now: deps.now, credentialRecord: deps.credentialRecord, readBody: readBody2 });
|
|
26503
|
+
const local = createRcSelfHostLocal({ now: deps.now, credentialRecord: deps.credentialRecord, readBody: readBody2, ownsLaunch: deps.ownsLaunch, ownsPeer: deps.ownsPeer, ...deps.log === void 0 ? {} : { log: deps.log } });
|
|
26164
26504
|
return {
|
|
26165
26505
|
route,
|
|
26166
26506
|
local,
|
|
@@ -26178,103 +26518,6 @@ data: ${JSON.stringify(envelope)}
|
|
|
26178
26518
|
};
|
|
26179
26519
|
}
|
|
26180
26520
|
|
|
26181
|
-
// src/frontdoor/rcSelfHostMint.ts
|
|
26182
|
-
init_identityRecords();
|
|
26183
|
-
init_account();
|
|
26184
|
-
import path47 from "node:path";
|
|
26185
|
-
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
26186
|
-
var CLAUDE_JSON2 = ".claude.json";
|
|
26187
|
-
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
26188
|
-
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
26189
|
-
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
26190
|
-
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
26191
|
-
function isRecord16(value) {
|
|
26192
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26193
|
-
}
|
|
26194
|
-
function readJsonObject(fs17, file) {
|
|
26195
|
-
const raw = fs17.readFileUtf8(file);
|
|
26196
|
-
if (raw === void 0) {
|
|
26197
|
-
return void 0;
|
|
26198
|
-
}
|
|
26199
|
-
let parsed;
|
|
26200
|
-
try {
|
|
26201
|
-
parsed = JSON.parse(raw);
|
|
26202
|
-
} catch {
|
|
26203
|
-
return void 0;
|
|
26204
|
-
}
|
|
26205
|
-
return isRecord16(parsed) ? parsed : void 0;
|
|
26206
|
-
}
|
|
26207
|
-
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
26208
|
-
const parsed = readJsonObject(fs17, path47.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
26209
|
-
if (parsed === void 0) {
|
|
26210
|
-
return void 0;
|
|
26211
|
-
}
|
|
26212
|
-
const { accessToken, refreshToken, organizationUuid, accountUuid } = parsed;
|
|
26213
|
-
if (typeof accessToken !== "string" || accessToken === "" || typeof refreshToken !== "string" || refreshToken === "" || typeof organizationUuid !== "string" || organizationUuid === "" || typeof accountUuid !== "string" || accountUuid === "") {
|
|
26214
|
-
return void 0;
|
|
26215
|
-
}
|
|
26216
|
-
return { accessToken, refreshToken, organizationUuid, accountUuid };
|
|
26217
|
-
}
|
|
26218
|
-
function mintRcSelfHostCredential(deps) {
|
|
26219
|
-
if (!isIdentityName(deps.identity)) {
|
|
26220
|
-
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
26221
|
-
}
|
|
26222
|
-
const id = identityIdOver(deps.fs, deps.identitiesDir, deps.identity);
|
|
26223
|
-
if (id === void 0) {
|
|
26224
|
-
throw new Error(`No identity named "${deps.identity}".`);
|
|
26225
|
-
}
|
|
26226
|
-
const identityDir = path47.join(deps.identitiesDir, id);
|
|
26227
|
-
const credentialsFile = path47.join(identityDir, CREDENTIALS_FILE2);
|
|
26228
|
-
const claudeJsonFile = path47.join(identityDir, CLAUDE_JSON2);
|
|
26229
|
-
const recordDir = path47.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26230
|
-
const recordFile2 = path47.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
26231
|
-
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
26232
|
-
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
26233
|
-
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
26234
|
-
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
26235
|
-
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
26236
|
-
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
26237
|
-
throw new Error(
|
|
26238
|
-
`identity ${deps.identity} already holds an OAuth credential this door did not mint (a real claude.ai login): pass --force to replace it, or mint into an identity with no login. The self-hosted mode expects no Anthropic credential to be in play.`
|
|
26239
|
-
);
|
|
26240
|
-
}
|
|
26241
|
-
const accessToken = `sk-ant-oat${deps.randomToken()}`;
|
|
26242
|
-
const refreshToken = deps.randomToken();
|
|
26243
|
-
const organizationUuid = deps.newUuid();
|
|
26244
|
-
const accountUuid = deps.newUuid();
|
|
26245
|
-
const mintedAt = new Date(deps.now()).toISOString();
|
|
26246
|
-
deps.fs.mkdirPrivate(path47.dirname(credentialsFile));
|
|
26247
|
-
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)}
|
|
26248
|
-
`);
|
|
26249
|
-
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
26250
|
-
const existingBlock = (value) => isRecord16(value) ? value : {};
|
|
26251
|
-
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
26252
|
-
...claudeJson,
|
|
26253
|
-
oauthAccount: {
|
|
26254
|
-
...existingBlock(claudeJson.oauthAccount),
|
|
26255
|
-
accountUuid,
|
|
26256
|
-
emailAddress: SELF_HOST_EMAIL,
|
|
26257
|
-
organizationUuid,
|
|
26258
|
-
organizationName: "agent-shim self-hosted",
|
|
26259
|
-
// The billing and creation fields exist so the CLI's "populate the account block if it is missing" step finds a complete block and skips its profile fetch; the door answers that fetch locally anyway, so these are the quiet path, not a load-bearing claim.
|
|
26260
|
-
billingType: "stripe_subscription",
|
|
26261
|
-
accountCreatedAt: mintedAt,
|
|
26262
|
-
subscriptionCreatedAt: mintedAt
|
|
26263
|
-
},
|
|
26264
|
-
cachedGrowthBookFeatures: {
|
|
26265
|
-
...existingBlock(claudeJson.cachedGrowthBookFeatures),
|
|
26266
|
-
tengu_ccr_bridge: true,
|
|
26267
|
-
tengu_bridge_repl_v2: true,
|
|
26268
|
-
tengu_bridge_repl_v2_cse_shim_enabled: true
|
|
26269
|
-
}
|
|
26270
|
-
}, null, 2)}
|
|
26271
|
-
`);
|
|
26272
|
-
deps.fs.mkdirPrivate(recordDir);
|
|
26273
|
-
deps.fs.writeFilePrivate(recordFile2, `${JSON.stringify({ accessToken, refreshToken, organizationUuid, accountUuid }, null, 2)}
|
|
26274
|
-
`);
|
|
26275
|
-
return { identity: deps.identity, organizationUuid, credentialsFile, claudeJsonFile, recordFile: recordFile2, replaced: existingIsOwn };
|
|
26276
|
-
}
|
|
26277
|
-
|
|
26278
26521
|
// src/index.ts
|
|
26279
26522
|
init_ensure2();
|
|
26280
26523
|
|