claude-use 14.5.1 → 14.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1555 -1124
- package/dist/index.cjs +506 -271
- package/dist/index.mjs +506 -271
- package/dist/types/index.d.ts +52 -12
- 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
|
|
|
@@ -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.0",
|
|
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;
|
|
@@ -20985,7 +21133,7 @@ var ResetRowSchema = z29.strictObject({
|
|
|
20985
21133
|
var ResetScheduleSchema = z29.strictObject({ resets: z29.readonly(z29.array(ResetRowSchema)) });
|
|
20986
21134
|
|
|
20987
21135
|
// src/frontdoor/controlSchemas.ts
|
|
20988
|
-
import
|
|
21136
|
+
import path46 from "node:path";
|
|
20989
21137
|
import { z as z39 } from "zod";
|
|
20990
21138
|
|
|
20991
21139
|
// src/codex/doctor.ts
|
|
@@ -21075,7 +21223,7 @@ init_signIn();
|
|
|
21075
21223
|
init_identityAccounts();
|
|
21076
21224
|
init_read();
|
|
21077
21225
|
init_providerReachability();
|
|
21078
|
-
import
|
|
21226
|
+
import path45 from "node:path";
|
|
21079
21227
|
|
|
21080
21228
|
// src/doctorNameFinding.ts
|
|
21081
21229
|
init_names();
|
|
@@ -21920,6 +22068,284 @@ function pushHeadroomAllowlist(push, allowlist, daemon) {
|
|
|
21920
22068
|
// src/doctorReport.ts
|
|
21921
22069
|
init_state2();
|
|
21922
22070
|
init_supervisor2();
|
|
22071
|
+
|
|
22072
|
+
// src/frontdoor/rcSelfHostMint.ts
|
|
22073
|
+
init_identityRecords();
|
|
22074
|
+
init_account();
|
|
22075
|
+
import path44 from "node:path";
|
|
22076
|
+
|
|
22077
|
+
// src/frontdoor/rcSelfHostLocal.ts
|
|
22078
|
+
init_http();
|
|
22079
|
+
init_rcControl();
|
|
22080
|
+
|
|
22081
|
+
// src/frontdoor/rcSelfHostOffline.ts
|
|
22082
|
+
init_http();
|
|
22083
|
+
var GITHUB_SYNC_PATH = /^\/api\/oauth\/organizations\/[^/]+\/sync\/github\/auth$/;
|
|
22084
|
+
var OFF_STATE_ENTRIES = [
|
|
22085
|
+
{ matches: (pathname) => pathname === "/api/claude_cli/bootstrap", answer: { status: HTTP_STATUS.ok, body: {} } },
|
|
22086
|
+
{ matches: (pathname) => pathname === "/api/claude_code_penguin_mode", answer: { status: HTTP_STATUS.ok, body: { enabled: false, disabled_reason: "preference" } } },
|
|
22087
|
+
{ matches: (pathname) => GITHUB_SYNC_PATH.test(pathname), answer: { status: HTTP_STATUS.ok, body: { is_authenticated: false } } },
|
|
22088
|
+
{ matches: (pathname) => pathname === "/v1/mcp_servers", answer: { status: HTTP_STATUS.ok, body: { data: [], next_page: null } } },
|
|
22089
|
+
{ matches: (pathname) => pathname === "/mcp-registry/v0/servers", answer: { status: HTTP_STATUS.ok, body: { servers: [], metadata: { count: 0 } } } }
|
|
22090
|
+
];
|
|
22091
|
+
function rcSelfHostOfflineAnswer(pathname) {
|
|
22092
|
+
const entry = OFF_STATE_ENTRIES.find((candidate) => candidate.matches(pathname));
|
|
22093
|
+
if (entry !== void 0) {
|
|
22094
|
+
return entry.answer;
|
|
22095
|
+
}
|
|
22096
|
+
return {
|
|
22097
|
+
status: HTTP_STATUS.notFound,
|
|
22098
|
+
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` } }
|
|
22099
|
+
};
|
|
22100
|
+
}
|
|
22101
|
+
function isRcSessionFamilyPath(pathname) {
|
|
22102
|
+
return pathname === "/v1/code/sessions" || pathname.startsWith("/v1/code/sessions/") || pathname === "/v1/sessions" || pathname.startsWith("/v1/sessions/");
|
|
22103
|
+
}
|
|
22104
|
+
|
|
22105
|
+
// src/frontdoor/rcSelfHostLocal.ts
|
|
22106
|
+
init_route();
|
|
22107
|
+
var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
|
|
22108
|
+
var RC_SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
22109
|
+
var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
|
|
22110
|
+
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
22111
|
+
var MS_PER_SECOND6 = 1e3;
|
|
22112
|
+
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
22113
|
+
function isRecord10(value) {
|
|
22114
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22115
|
+
}
|
|
22116
|
+
function parseJsonObject2(body) {
|
|
22117
|
+
let parsed;
|
|
22118
|
+
try {
|
|
22119
|
+
parsed = JSON.parse(body);
|
|
22120
|
+
} catch {
|
|
22121
|
+
return void 0;
|
|
22122
|
+
}
|
|
22123
|
+
return isRecord10(parsed) ? parsed : void 0;
|
|
22124
|
+
}
|
|
22125
|
+
function growthBookFeatures() {
|
|
22126
|
+
return {
|
|
22127
|
+
tengu_ccr_bridge: { defaultValue: true },
|
|
22128
|
+
tengu_bridge_repl_v2: { defaultValue: true },
|
|
22129
|
+
tengu_bridge_repl_v2_cse_shim_enabled: { defaultValue: true },
|
|
22130
|
+
tengu_bridge_min_version: { defaultValue: { minVersion: "0.0.0" } }
|
|
22131
|
+
};
|
|
22132
|
+
}
|
|
22133
|
+
var answerServerJson = (response, status, body) => {
|
|
22134
|
+
const text = JSON.stringify(body);
|
|
22135
|
+
response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text, "utf8")) });
|
|
22136
|
+
response.end(text);
|
|
22137
|
+
};
|
|
22138
|
+
function createRcSelfHostLocal(deps) {
|
|
22139
|
+
const answerOffline = (method, pathname, request4, response) => {
|
|
22140
|
+
request4.resume();
|
|
22141
|
+
const offline = rcSelfHostOfflineAnswer(pathname);
|
|
22142
|
+
deps.log?.(`rc selfhost: answered ${method} ${pathname} locally with ${String(offline.status)}; a self-hosted session's calls never leave the door`);
|
|
22143
|
+
answerServerJson(response, offline.status, offline.body);
|
|
22144
|
+
};
|
|
22145
|
+
return {
|
|
22146
|
+
ownsLaunch: deps.ownsLaunch,
|
|
22147
|
+
ownsPeer: deps.ownsPeer,
|
|
22148
|
+
mintGeneration: () => {
|
|
22149
|
+
const minted = deps.credentialRecord();
|
|
22150
|
+
return minted === void 0 ? "none" : minted.identityId === void 0 ? "every" : `identity:${minted.identityId}`;
|
|
22151
|
+
},
|
|
22152
|
+
serve: async (host, request4, response) => {
|
|
22153
|
+
const method = (request4.method ?? "").toUpperCase();
|
|
22154
|
+
const pathname = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
22155
|
+
const minted = deps.credentialRecord();
|
|
22156
|
+
if (minted !== void 0 && minted.identityId === void 0) {
|
|
22157
|
+
request4.resume();
|
|
22158
|
+
deps.log?.(`rc selfhost: refused ${method} ${pathname}: the minted credential names no identity; mint it again`);
|
|
22159
|
+
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" } });
|
|
22160
|
+
return true;
|
|
22161
|
+
}
|
|
22162
|
+
if (host === RC_SELF_HOST_OAUTH_HOST) {
|
|
22163
|
+
if (method === "POST" && pathname === "/v1/oauth/token") {
|
|
22164
|
+
const body = parseJsonObject2(await deps.readBody(request4, CONTROL_BODY_CAP_BYTES));
|
|
22165
|
+
const record = deps.credentialRecord();
|
|
22166
|
+
if (record === void 0) {
|
|
22167
|
+
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" });
|
|
22168
|
+
return true;
|
|
22169
|
+
}
|
|
22170
|
+
if (body?.grant_type !== void 0 && body.grant_type !== "refresh_token") {
|
|
22171
|
+
answerServerJson(response, HTTP_STATUS.badRequest, { error: "unsupported_grant_type" });
|
|
22172
|
+
return true;
|
|
22173
|
+
}
|
|
22174
|
+
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(" ") });
|
|
22175
|
+
return true;
|
|
22176
|
+
}
|
|
22177
|
+
if (method === "GET" && pathname === "/v1/oauth/hello") {
|
|
22178
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22179
|
+
return true;
|
|
22180
|
+
}
|
|
22181
|
+
answerOffline(method, pathname, request4, response);
|
|
22182
|
+
return true;
|
|
22183
|
+
}
|
|
22184
|
+
if (method === "POST" && pathname.startsWith("/api/eval/")) {
|
|
22185
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22186
|
+
answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND6) });
|
|
22187
|
+
return true;
|
|
22188
|
+
}
|
|
22189
|
+
if (method === "GET" && pathname === "/api/oauth/profile") {
|
|
22190
|
+
const record = deps.credentialRecord();
|
|
22191
|
+
if (record === void 0) {
|
|
22192
|
+
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" });
|
|
22193
|
+
return true;
|
|
22194
|
+
}
|
|
22195
|
+
answerServerJson(response, HTTP_STATUS.ok, {
|
|
22196
|
+
// The email is required: the client's profile schema rejects an answer without `account.email`, discarding the whole profile.
|
|
22197
|
+
account: { uuid: record.accountUuid, email: RC_SELF_HOST_EMAIL, display_name: "agent-shim self-hosted", created_at: (/* @__PURE__ */ new Date(0)).toISOString() },
|
|
22198
|
+
organization: { uuid: record.organizationUuid, organization_type: "claude_max" }
|
|
22199
|
+
});
|
|
22200
|
+
return true;
|
|
22201
|
+
}
|
|
22202
|
+
if (method === "GET" && pathname === "/api/claude_code/policy_limits") {
|
|
22203
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22204
|
+
return true;
|
|
22205
|
+
}
|
|
22206
|
+
if (method === "POST" && pathname === "/api/oauth/validate") {
|
|
22207
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22208
|
+
const record = deps.credentialRecord();
|
|
22209
|
+
if (record === void 0) {
|
|
22210
|
+
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" });
|
|
22211
|
+
return true;
|
|
22212
|
+
}
|
|
22213
|
+
answerServerJson(response, HTTP_STATUS.ok, { scopes: [...RC_SELF_HOST_SCOPE_LIST], expiresAt: null, subscriptionType: "max", account_uuid: record.accountUuid, organization_uuid: record.organizationUuid });
|
|
22214
|
+
return true;
|
|
22215
|
+
}
|
|
22216
|
+
if (method === "POST" && (pathname === "/api/event_logging/v2/batch" || pathname === "/api/claude_code/metrics" || pathname === "/api/claude_cli_feedback")) {
|
|
22217
|
+
await deps.readBody(request4, CONTROL_BODY_CAP_BYTES);
|
|
22218
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22219
|
+
return true;
|
|
22220
|
+
}
|
|
22221
|
+
if (method === "GET" && pathname === "/api/hello") {
|
|
22222
|
+
answerServerJson(response, HTTP_STATUS.ok, {});
|
|
22223
|
+
return true;
|
|
22224
|
+
}
|
|
22225
|
+
if (pathname.startsWith("/v1/") && (isRcSessionFamilyPath(pathname) || internalHeaderValue(request4.headers, PROVIDER_HEADER) !== void 0)) {
|
|
22226
|
+
return false;
|
|
22227
|
+
}
|
|
22228
|
+
answerOffline(method, pathname, request4, response);
|
|
22229
|
+
return true;
|
|
22230
|
+
}
|
|
22231
|
+
};
|
|
22232
|
+
}
|
|
22233
|
+
|
|
22234
|
+
// src/frontdoor/rcSelfHostMint.ts
|
|
22235
|
+
init_capability();
|
|
22236
|
+
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
22237
|
+
var CLAUDE_JSON2 = ".claude.json";
|
|
22238
|
+
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
22239
|
+
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
22240
|
+
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
22241
|
+
function isRecord11(value) {
|
|
22242
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22243
|
+
}
|
|
22244
|
+
function readJsonObject(fs17, file) {
|
|
22245
|
+
const raw = fs17.readFileUtf8(file);
|
|
22246
|
+
if (raw === void 0) {
|
|
22247
|
+
return void 0;
|
|
22248
|
+
}
|
|
22249
|
+
let parsed;
|
|
22250
|
+
try {
|
|
22251
|
+
parsed = JSON.parse(raw);
|
|
22252
|
+
} catch {
|
|
22253
|
+
return void 0;
|
|
22254
|
+
}
|
|
22255
|
+
return isRecord11(parsed) ? parsed : void 0;
|
|
22256
|
+
}
|
|
22257
|
+
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
22258
|
+
const parsed = readJsonObject(fs17, path44.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
22259
|
+
if (parsed === void 0) {
|
|
22260
|
+
return void 0;
|
|
22261
|
+
}
|
|
22262
|
+
const { accessToken, refreshToken, organizationUuid, accountUuid, identityId } = parsed;
|
|
22263
|
+
if (typeof accessToken !== "string" || accessToken === "" || typeof refreshToken !== "string" || refreshToken === "" || typeof organizationUuid !== "string" || organizationUuid === "" || typeof accountUuid !== "string" || accountUuid === "") {
|
|
22264
|
+
return void 0;
|
|
22265
|
+
}
|
|
22266
|
+
return { accessToken, refreshToken, organizationUuid, accountUuid, ...typeof identityId === "string" && identityId !== "" ? { identityId } : {} };
|
|
22267
|
+
}
|
|
22268
|
+
function identitiesHoldingMint(fs17, identitiesDir, record) {
|
|
22269
|
+
return fs17.readdir(identitiesDir).filter((id) => {
|
|
22270
|
+
if (id.startsWith(".")) {
|
|
22271
|
+
return false;
|
|
22272
|
+
}
|
|
22273
|
+
const oauth = readJsonObject(fs17, path44.join(identitiesDir, id, CREDENTIALS_FILE2))?.claudeAiOauth;
|
|
22274
|
+
return isRecord11(oauth) && typeof oauth.accessToken === "string" && isLiveCapability(oauth.accessToken, [record.accessToken]);
|
|
22275
|
+
});
|
|
22276
|
+
}
|
|
22277
|
+
function rcSelfHostMintFacts(fs17, identitiesDir, frontdoorDir) {
|
|
22278
|
+
const record = readRcSelfHostRecord(fs17, frontdoorDir);
|
|
22279
|
+
if (record === void 0) {
|
|
22280
|
+
return {};
|
|
22281
|
+
}
|
|
22282
|
+
if (record.identityId !== void 0) {
|
|
22283
|
+
return { rcSelfHostMint: { attributable: true } };
|
|
22284
|
+
}
|
|
22285
|
+
const holders = identitiesHoldingMint(fs17, identitiesDir, record).length;
|
|
22286
|
+
return { rcSelfHostMint: { attributable: holders === 1, holders } };
|
|
22287
|
+
}
|
|
22288
|
+
function mintRcSelfHostCredential(deps) {
|
|
22289
|
+
if (!isIdentityName(deps.identity)) {
|
|
22290
|
+
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
22291
|
+
}
|
|
22292
|
+
const id = identityIdOver(deps.fs, deps.identitiesDir, deps.identity);
|
|
22293
|
+
if (id === void 0) {
|
|
22294
|
+
throw new Error(`No identity named "${deps.identity}".`);
|
|
22295
|
+
}
|
|
22296
|
+
const identityDir = path44.join(deps.identitiesDir, id);
|
|
22297
|
+
const credentialsFile = path44.join(identityDir, CREDENTIALS_FILE2);
|
|
22298
|
+
const claudeJsonFile = path44.join(identityDir, CLAUDE_JSON2);
|
|
22299
|
+
const recordDir = path44.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
22300
|
+
const recordFile2 = path44.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
22301
|
+
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
22302
|
+
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
22303
|
+
const existingOauth = isRecord11(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
22304
|
+
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
22305
|
+
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
22306
|
+
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
22307
|
+
throw new Error(
|
|
22308
|
+
`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.`
|
|
22309
|
+
);
|
|
22310
|
+
}
|
|
22311
|
+
const accessToken = `sk-ant-oat${deps.randomToken()}`;
|
|
22312
|
+
const refreshToken = deps.randomToken();
|
|
22313
|
+
const organizationUuid = deps.newUuid();
|
|
22314
|
+
const accountUuid = deps.newUuid();
|
|
22315
|
+
const mintedAt = new Date(deps.now()).toISOString();
|
|
22316
|
+
deps.fs.mkdirPrivate(path44.dirname(credentialsFile));
|
|
22317
|
+
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)}
|
|
22318
|
+
`);
|
|
22319
|
+
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
22320
|
+
const existingBlock = (value) => isRecord11(value) ? value : {};
|
|
22321
|
+
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
22322
|
+
...claudeJson,
|
|
22323
|
+
oauthAccount: {
|
|
22324
|
+
...existingBlock(claudeJson.oauthAccount),
|
|
22325
|
+
accountUuid,
|
|
22326
|
+
emailAddress: RC_SELF_HOST_EMAIL,
|
|
22327
|
+
organizationUuid,
|
|
22328
|
+
organizationName: "agent-shim self-hosted",
|
|
22329
|
+
// 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.
|
|
22330
|
+
billingType: "stripe_subscription",
|
|
22331
|
+
accountCreatedAt: mintedAt,
|
|
22332
|
+
subscriptionCreatedAt: mintedAt
|
|
22333
|
+
},
|
|
22334
|
+
cachedGrowthBookFeatures: {
|
|
22335
|
+
...existingBlock(claudeJson.cachedGrowthBookFeatures),
|
|
22336
|
+
tengu_ccr_bridge: true,
|
|
22337
|
+
tengu_bridge_repl_v2: true,
|
|
22338
|
+
tengu_bridge_repl_v2_cse_shim_enabled: true
|
|
22339
|
+
}
|
|
22340
|
+
}, null, 2)}
|
|
22341
|
+
`);
|
|
22342
|
+
deps.fs.mkdirPrivate(recordDir);
|
|
22343
|
+
deps.fs.writeFilePrivate(recordFile2, `${JSON.stringify({ accessToken, refreshToken, organizationUuid, accountUuid, identityId: id }, null, 2)}
|
|
22344
|
+
`);
|
|
22345
|
+
return { identity: deps.identity, organizationUuid, credentialsFile, claudeJsonFile, recordFile: recordFile2, replaced: existingIsOwn };
|
|
22346
|
+
}
|
|
22347
|
+
|
|
22348
|
+
// src/doctorReport.ts
|
|
21923
22349
|
init_state();
|
|
21924
22350
|
|
|
21925
22351
|
// src/doctorFrontDoor.ts
|
|
@@ -21981,6 +22407,17 @@ function pushFrontDoorListeners(push, readings) {
|
|
|
21981
22407
|
);
|
|
21982
22408
|
}
|
|
21983
22409
|
}
|
|
22410
|
+
function pushRcSelfHostMint(push, mint) {
|
|
22411
|
+
if (mint !== void 0 && !mint.attributable) {
|
|
22412
|
+
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>.`);
|
|
22413
|
+
}
|
|
22414
|
+
}
|
|
22415
|
+
function pushFrontDoorReadings(push, readings) {
|
|
22416
|
+
if (readings.listeners !== void 0) {
|
|
22417
|
+
pushFrontDoorListeners(push, readings.listeners);
|
|
22418
|
+
}
|
|
22419
|
+
pushRcSelfHostMint(push, readings.rcSelfHostMint);
|
|
22420
|
+
}
|
|
21984
22421
|
|
|
21985
22422
|
// src/frontdoor/listenerReadings.ts
|
|
21986
22423
|
init_probe();
|
|
@@ -22173,7 +22610,7 @@ function tcpPortEraRecord(raw) {
|
|
|
22173
22610
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
22174
22611
|
}
|
|
22175
22612
|
function pushPathResolution(push, resolution) {
|
|
22176
|
-
const ownDir =
|
|
22613
|
+
const ownDir = path45.dirname(resolution.ownExecutablePath);
|
|
22177
22614
|
switch (resolution.agentShim.status) {
|
|
22178
22615
|
case "ok":
|
|
22179
22616
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -22293,14 +22730,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
22293
22730
|
}
|
|
22294
22731
|
function pushLegacyName(push, params) {
|
|
22295
22732
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
22296
|
-
if (legacyVariables.length === 0 &&
|
|
22733
|
+
if (legacyVariables.length === 0 && path45.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
22297
22734
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
22298
22735
|
return;
|
|
22299
22736
|
}
|
|
22300
22737
|
for (const name of legacyVariables) {
|
|
22301
22738
|
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
22739
|
}
|
|
22303
|
-
if (
|
|
22740
|
+
if (path45.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
22304
22741
|
push(
|
|
22305
22742
|
"legacy-name",
|
|
22306
22743
|
"warn",
|
|
@@ -22390,7 +22827,7 @@ function runDoctor(params) {
|
|
|
22390
22827
|
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
22828
|
}
|
|
22392
22829
|
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.`,
|
|
22830
|
+
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
22831
|
}
|
|
22395
22832
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22396
22833
|
const signedInAccounts = [];
|
|
@@ -22660,9 +23097,7 @@ function runDoctor(params) {
|
|
|
22660
23097
|
if (params.frontDoor !== void 0) {
|
|
22661
23098
|
const validated3 = params.frontDoor.state.raw === void 0 ? void 0 : validateJson(FrontDoorStateSchema, params.frontDoor.state);
|
|
22662
23099
|
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
|
-
}
|
|
23100
|
+
pushFrontDoorReadings(push, params.frontDoor);
|
|
22666
23101
|
}
|
|
22667
23102
|
if (params.activeIdentity.raw === void 0) {
|
|
22668
23103
|
push("active-identity", "pass", "No active identity set.");
|
|
@@ -22688,9 +23123,9 @@ function collectDoctorReport(params) {
|
|
|
22688
23123
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22689
23124
|
const records = identityRecords(paths);
|
|
22690
23125
|
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 =
|
|
23126
|
+
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) => {
|
|
23127
|
+
const farmRoot = path45.join(paths.identitiesDir, id);
|
|
23128
|
+
const identityPath = path45.join(farmRoot, "identity.json");
|
|
22694
23129
|
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
23130
|
});
|
|
22696
23131
|
const usageSnapshots = {};
|
|
@@ -22708,12 +23143,12 @@ function collectDoctorReport(params) {
|
|
|
22708
23143
|
}
|
|
22709
23144
|
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
23145
|
const configProfiles = profileNames.map((name) => {
|
|
22711
|
-
const profilePath =
|
|
23146
|
+
const profilePath = path45.join(paths.configProfilesDir, `${name}.json`);
|
|
22712
23147
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22713
23148
|
});
|
|
22714
23149
|
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
23150
|
const providers = providerNames.map((name) => {
|
|
22716
|
-
const providerPath =
|
|
23151
|
+
const providerPath = path45.join(paths.providersDir, `${name}.json`);
|
|
22717
23152
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22718
23153
|
});
|
|
22719
23154
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22725,12 +23160,12 @@ function collectDoctorReport(params) {
|
|
|
22725
23160
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22726
23161
|
}
|
|
22727
23162
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22728
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
23163
|
+
const pathDirs = (params.env.PATH ?? "").split(path45.delimiter).filter((dir) => dir !== "");
|
|
22729
23164
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22730
23165
|
findPathShadow({
|
|
22731
23166
|
pathDirs,
|
|
22732
|
-
targetDir:
|
|
22733
|
-
targetFilename:
|
|
23167
|
+
targetDir: path45.dirname(shimState.targetPath),
|
|
23168
|
+
targetFilename: path45.basename(shimState.targetPath),
|
|
22734
23169
|
findExecutableInDir
|
|
22735
23170
|
}),
|
|
22736
23171
|
shimState.targetPath,
|
|
@@ -22759,7 +23194,7 @@ function collectDoctorReport(params) {
|
|
|
22759
23194
|
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22760
23195
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22761
23196
|
unreachableIdentities,
|
|
22762
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(
|
|
23197
|
+
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
23198
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22764
23199
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22765
23200
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22774,7 +23209,7 @@ function collectDoctorReport(params) {
|
|
|
22774
23209
|
agentShim: refinePathShadow(
|
|
22775
23210
|
findPathShadow({
|
|
22776
23211
|
pathDirs,
|
|
22777
|
-
targetDir:
|
|
23212
|
+
targetDir: path45.dirname(ownExecutablePath),
|
|
22778
23213
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22779
23214
|
findExecutableInDir
|
|
22780
23215
|
}),
|
|
@@ -22808,7 +23243,7 @@ function collectDoctorReport(params) {
|
|
|
22808
23243
|
logPath: paths.headroomLogPath
|
|
22809
23244
|
}
|
|
22810
23245
|
},
|
|
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) } }
|
|
23246
|
+
...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
23247
|
});
|
|
22813
23248
|
return report;
|
|
22814
23249
|
}
|
|
@@ -22867,11 +23302,11 @@ var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread o
|
|
|
22867
23302
|
var CheckRunInputSchema = z39.strictObject({
|
|
22868
23303
|
path: z39.string().min(1),
|
|
22869
23304
|
identity: z39.string().min(1).optional()
|
|
22870
|
-
}).refine((input) =>
|
|
23305
|
+
}).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
23306
|
var PoolPickInputSchema = z39.strictObject({
|
|
22872
23307
|
pool: z39.string().min(1),
|
|
22873
23308
|
path: z39.string().min(1)
|
|
22874
|
-
}).refine((input) =>
|
|
23309
|
+
}).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
23310
|
var DoctorFindingSchema = z39.strictObject({
|
|
22876
23311
|
section: z39.enum(DOCTOR_SECTIONS),
|
|
22877
23312
|
subject: z39.string().optional(),
|
|
@@ -23663,7 +24098,7 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
|
|
|
23663
24098
|
import { openapi as openapi6 } from "@orpc/openapi";
|
|
23664
24099
|
|
|
23665
24100
|
// src/frontdoor/launchSchemas.ts
|
|
23666
|
-
import
|
|
24101
|
+
import path47 from "node:path";
|
|
23667
24102
|
import { z as z45 } from "zod";
|
|
23668
24103
|
init_statusline();
|
|
23669
24104
|
init_claudeVersion();
|
|
@@ -23674,7 +24109,7 @@ var LaunchResolveInputSchema = z45.strictObject({
|
|
|
23674
24109
|
argv: z45.readonly(z45.array(z45.string())).optional(),
|
|
23675
24110
|
/** 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
24111
|
env: z45.record(z45.string(), z45.string()).optional()
|
|
23677
|
-
}).refine((input) =>
|
|
24112
|
+
}).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
24113
|
var LaunchPoolDecisionSchema = z45.strictObject({
|
|
23679
24114
|
name: z45.string(),
|
|
23680
24115
|
reasons: z45.readonly(z45.array(z45.string())),
|
|
@@ -24512,15 +24947,15 @@ init_verifiedVersions();
|
|
|
24512
24947
|
// src/frontdoor/rcLiveUsage.ts
|
|
24513
24948
|
init_rcSchemas();
|
|
24514
24949
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
24515
|
-
function
|
|
24950
|
+
function isRecord12(value) {
|
|
24516
24951
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24517
24952
|
}
|
|
24518
24953
|
function rcRateLimitInfoOf(event) {
|
|
24519
24954
|
const payload = event.envelope.payload;
|
|
24520
|
-
if (!
|
|
24955
|
+
if (!isRecord12(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
24521
24956
|
return void 0;
|
|
24522
24957
|
}
|
|
24523
|
-
if (!
|
|
24958
|
+
if (!isRecord12(payload.rate_limit_info)) {
|
|
24524
24959
|
return void 0;
|
|
24525
24960
|
}
|
|
24526
24961
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -24609,7 +25044,7 @@ function createSseParser() {
|
|
|
24609
25044
|
}
|
|
24610
25045
|
};
|
|
24611
25046
|
}
|
|
24612
|
-
function
|
|
25047
|
+
function isRecord13(value) {
|
|
24613
25048
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24614
25049
|
}
|
|
24615
25050
|
function sequenceNumOf(value) {
|
|
@@ -24631,7 +25066,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
24631
25066
|
} catch {
|
|
24632
25067
|
return void 0;
|
|
24633
25068
|
}
|
|
24634
|
-
if (!
|
|
25069
|
+
if (!isRecord13(data)) {
|
|
24635
25070
|
return void 0;
|
|
24636
25071
|
}
|
|
24637
25072
|
const eventType = data.event_type;
|
|
@@ -24888,17 +25323,17 @@ function withClientPlatform(payload, headers) {
|
|
|
24888
25323
|
const platform = headers[CLIENT_PLATFORM_HEADER];
|
|
24889
25324
|
return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
|
|
24890
25325
|
}
|
|
24891
|
-
function
|
|
25326
|
+
function isRecord14(value) {
|
|
24892
25327
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24893
25328
|
}
|
|
24894
|
-
function
|
|
25329
|
+
function parseJsonObject3(body) {
|
|
24895
25330
|
let parsed;
|
|
24896
25331
|
try {
|
|
24897
25332
|
parsed = JSON.parse(body);
|
|
24898
25333
|
} catch {
|
|
24899
25334
|
return void 0;
|
|
24900
25335
|
}
|
|
24901
|
-
return
|
|
25336
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
24902
25337
|
}
|
|
24903
25338
|
function nonEmptyString2(record, field) {
|
|
24904
25339
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -24933,7 +25368,7 @@ function pageOfRcChannel(url, rows, idOf, rowOf3) {
|
|
|
24933
25368
|
async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
24934
25369
|
const { request: request4, response, host } = ctx;
|
|
24935
25370
|
if (tail === "client/presence" && method === "POST") {
|
|
24936
|
-
const body =
|
|
25371
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24937
25372
|
const clientId = nonEmptyString2(body, "client_id");
|
|
24938
25373
|
const clear = body?.clear;
|
|
24939
25374
|
if (clientId === void 0 || clear !== void 0 && typeof clear !== "boolean") {
|
|
@@ -24951,7 +25386,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24951
25386
|
return true;
|
|
24952
25387
|
}
|
|
24953
25388
|
if (tail === "mark_read" && method === "POST") {
|
|
24954
|
-
const body =
|
|
25389
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24955
25390
|
const eventId = nonEmptyString2(body, "event_id");
|
|
24956
25391
|
const clientId = nonEmptyString2(body, "client_id");
|
|
24957
25392
|
if (body !== void 0 && "event_id" in body && eventId === void 0 || "client_id" in (body ?? {}) && clientId === void 0) {
|
|
@@ -24964,7 +25399,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24964
25399
|
return true;
|
|
24965
25400
|
}
|
|
24966
25401
|
if (tail === "teleport-events" && method === "POST") {
|
|
24967
|
-
const body =
|
|
25402
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
24968
25403
|
const events = body?.events;
|
|
24969
25404
|
if (!Array.isArray(events) || events.length === 0 || events.length > maxBatchEvents) {
|
|
24970
25405
|
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 +25407,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
24972
25407
|
}
|
|
24973
25408
|
const results = [];
|
|
24974
25409
|
for (const event of events) {
|
|
24975
|
-
if (!
|
|
25410
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
24976
25411
|
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
25412
|
return true;
|
|
24978
25413
|
}
|
|
@@ -25036,7 +25471,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
25036
25471
|
await ctx.answerJson(response, HTTP_STATUS.notFound, { type: "error", error: { type: "api_error", message: `Session not found: ${address}` } });
|
|
25037
25472
|
return;
|
|
25038
25473
|
}
|
|
25039
|
-
const body =
|
|
25474
|
+
const body = parseJsonObject3(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
25040
25475
|
const title = nonEmptyString2(body, "title");
|
|
25041
25476
|
if (title === void 0) {
|
|
25042
25477
|
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 +25509,17 @@ init_http();
|
|
|
25074
25509
|
init_rcControl();
|
|
25075
25510
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
25076
25511
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
25077
|
-
function
|
|
25512
|
+
function isRecord15(value) {
|
|
25078
25513
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25079
25514
|
}
|
|
25080
|
-
function
|
|
25515
|
+
function parseJsonObject4(body) {
|
|
25081
25516
|
let parsed;
|
|
25082
25517
|
try {
|
|
25083
25518
|
parsed = JSON.parse(body);
|
|
25084
25519
|
} catch {
|
|
25085
25520
|
return void 0;
|
|
25086
25521
|
}
|
|
25087
|
-
return
|
|
25522
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
25088
25523
|
}
|
|
25089
25524
|
function nonEmptyString3(record, field) {
|
|
25090
25525
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -25130,7 +25565,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25130
25565
|
return;
|
|
25131
25566
|
}
|
|
25132
25567
|
if (tail === "events" && method === "POST") {
|
|
25133
|
-
const body =
|
|
25568
|
+
const body = parseJsonObject4(await ctx.readBody(request4.body, CONTROL_BODY_CAP_BYTES));
|
|
25134
25569
|
const events = body?.events;
|
|
25135
25570
|
if (!Array.isArray(events) || events.length === 0 || events.length > ctx.maxBatchEvents) {
|
|
25136
25571
|
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 +25573,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25138
25573
|
}
|
|
25139
25574
|
const results = [];
|
|
25140
25575
|
for (const event of events) {
|
|
25141
|
-
if (!
|
|
25576
|
+
if (!isRecord15(event) || !isRecord15(event.payload)) {
|
|
25142
25577
|
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
25578
|
return;
|
|
25144
25579
|
}
|
|
@@ -25164,111 +25599,6 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
25164
25599
|
await ctx.answerJson(response, HTTP_STATUS.notFound, { type: "error", error: { type: "api_error", message: `the conversation family serves no path "${tail}"` } });
|
|
25165
25600
|
}
|
|
25166
25601
|
|
|
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
25602
|
// src/frontdoor/rcWebFetch.ts
|
|
25273
25603
|
init_http();
|
|
25274
25604
|
init_connectEffects();
|
|
@@ -25547,7 +25877,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
25547
25877
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
25548
25878
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
25549
25879
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
25550
|
-
function
|
|
25880
|
+
function isRecord16(value) {
|
|
25551
25881
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25552
25882
|
}
|
|
25553
25883
|
function isWebSearchRefusal(value) {
|
|
@@ -25631,7 +25961,7 @@ function parseJsonObject5(body) {
|
|
|
25631
25961
|
} catch {
|
|
25632
25962
|
return void 0;
|
|
25633
25963
|
}
|
|
25634
|
-
return
|
|
25964
|
+
return isRecord16(parsed) ? parsed : void 0;
|
|
25635
25965
|
}
|
|
25636
25966
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
25637
25967
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -25891,7 +26221,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25891
26221
|
if (status !== void 0) {
|
|
25892
26222
|
session.workerStatus = status;
|
|
25893
26223
|
}
|
|
25894
|
-
if (
|
|
26224
|
+
if (isRecord16(body?.external_metadata)) {
|
|
25895
26225
|
session.externalMetadata = body.external_metadata;
|
|
25896
26226
|
}
|
|
25897
26227
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -25921,7 +26251,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25921
26251
|
}
|
|
25922
26252
|
const results = [];
|
|
25923
26253
|
for (const event of events) {
|
|
25924
|
-
if (!
|
|
26254
|
+
if (!isRecord16(event) || !isRecord16(event.payload)) {
|
|
25925
26255
|
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
26256
|
return;
|
|
25927
26257
|
}
|
|
@@ -25954,7 +26284,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25954
26284
|
return;
|
|
25955
26285
|
}
|
|
25956
26286
|
for (const event of events) {
|
|
25957
|
-
if (
|
|
26287
|
+
if (isRecord16(event)) {
|
|
25958
26288
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
25959
26289
|
}
|
|
25960
26290
|
}
|
|
@@ -26050,7 +26380,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
26050
26380
|
}
|
|
26051
26381
|
const results = [];
|
|
26052
26382
|
for (const event of events) {
|
|
26053
|
-
if (!
|
|
26383
|
+
if (!isRecord16(event) || !isRecord16(event.payload)) {
|
|
26054
26384
|
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
26385
|
return;
|
|
26056
26386
|
}
|
|
@@ -26095,7 +26425,9 @@ data: ${JSON.stringify(envelope)}
|
|
|
26095
26425
|
return;
|
|
26096
26426
|
}
|
|
26097
26427
|
if (pathname !== RC_SESSIONS_PATH_PREFIX2 && !pathname.startsWith(`${RC_SESSIONS_PATH_PREFIX2}/`)) {
|
|
26098
|
-
|
|
26428
|
+
const offline = rcSelfHostOfflineAnswer(pathname);
|
|
26429
|
+
deps.log?.(`rc selfhost: answered ${method} ${pathname} locally with ${String(offline.status)}; a self-hosted session's calls never leave the door`);
|
|
26430
|
+
await answerJson2(response, offline.status, offline.body);
|
|
26099
26431
|
return;
|
|
26100
26432
|
}
|
|
26101
26433
|
if (pathname === RC_SESSIONS_PATH_PREFIX2) {
|
|
@@ -26160,7 +26492,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
26160
26492
|
await serveSessionPath(sessions.get(id), tail, request4, response);
|
|
26161
26493
|
}
|
|
26162
26494
|
};
|
|
26163
|
-
const local = createRcSelfHostLocal({ now: deps.now, credentialRecord: deps.credentialRecord, readBody: readBody2 });
|
|
26495
|
+
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
26496
|
return {
|
|
26165
26497
|
route,
|
|
26166
26498
|
local,
|
|
@@ -26178,103 +26510,6 @@ data: ${JSON.stringify(envelope)}
|
|
|
26178
26510
|
};
|
|
26179
26511
|
}
|
|
26180
26512
|
|
|
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
26513
|
// src/index.ts
|
|
26279
26514
|
init_ensure2();
|
|
26280
26515
|
|