@chibitek/chibi 0.1.183 → 0.1.185
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/assets/{abnfDiagram-O67JEVCF-BJRKA6IQ.js → abnfDiagram-O67JEVCF-CVenv9f1.js} +1 -1
- package/dist/assets/{arc-CZc_uW-u.js → arc-CIRWjkSZ.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DNLaTXeO.js → architectureDiagram-NJMV4G6O-DmIpOaYd.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DLXsik0_.js → blockDiagram-BEXU5L5S-BYhb8Ycm.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-DG6hN1C0.js → c4Diagram-YGBWAQC7-B9rBcCno.js} +1 -1
- package/dist/assets/channel-NYf_L8uU.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D5Yjh7-1.js → chunk-2Q5K7J3B-CV6TX9gt.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-Bxyjopy0.js → chunk-3FUC2YCW-DiOotfQU.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DDQZDrcU.js → chunk-5VM5RSS4-Br5QWC-1.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-OwVykJDf.js → chunk-GTNCS2PH-BmvI8RMK.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BJRJdRRn.js → chunk-GWA4HPMP-Do93bTCh.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-D0rQf2t4.js → chunk-JWPE2WC7-qIjG-mTw.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DbgIhGxq.js → chunk-NETBCI7D-DZFFFHT2.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-NVC6qgIT.js → chunk-WEXAMYUT-qqsVaC1g.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-B9iYAoH7.js → chunk-XXDRQBXY-EI-aQ-Wn.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-Cma68soF.js → classDiagram-v2-NBCMYWYE-D9D8dkAx.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BrXaARl8.js → cose-bilkent-JH36ORCC-m575JDuA.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DaxVySTi.js → cynefin-OW5HDTMX-BMm2bhgv.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BhqakyPn.js → cynefinDiagram-VND7K2PF-Dl2MlsqG.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-C1GSPYtM.js → dagre-6A5THRUB-Cw8yJ-SY.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BJ3lUPTt.js → diagram-22UHCM2B-DyY0F1qK.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-B15DdW5N.js → diagram-3UASUU5V-sMOszbgV.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CXiw2lST.js → diagram-ATOU4E4O-DPo3fHpo.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-DoqH99bW.js → diagram-CDSNMT55-BAHqm-cq.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-snN4K-CB.js → diagram-MLGK6HIB-BdI4Tf9M.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DgJvwpZO.js → diagram-MPIPVDR6-BxqEl_S5.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-AO646Cux.js → ebnfDiagram-ZINNZB2B-DLJ3VRtx.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BQwiFuXz.js → elk-276RUBZZ-Yhxabhx6.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-B5VI88HR.js → erDiagram-OPXOYQCR-DZ4Es64N.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BNaAddPG.js → flowDiagram-KWPJA3E3-E36WtrEY.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-C_ZoEfA5.js → ganttDiagram-FUAMR5RP-OpUEVvtU.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-xthNWdmM.js → gitGraphDiagram-X574FWY7-DTZFNsL8.js} +1 -1
- package/dist/assets/{index-DmYwoh4R.js → index-Bgf1dXAl.js} +133 -133
- package/dist/assets/{index-ASohJJer.js → index-Bzph058J.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-Qhrkz09J.js → infoDiagram-VRGFBTTK-mCP2UtfM.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DzU3-GrV.js → ishikawaDiagram-OU5B5YK6-M71dvinX.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-Dif-aG4a.js → journeyDiagram-ZHPQQLJL-B2VdVbYS.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-NJ0l6rbK.js → kanban-definition-PNTS6WVX-l4HpN_KC.js} +1 -1
- package/dist/assets/{linear-DpEaZ_8H.js → linear-CN0tWTVj.js} +1 -1
- package/dist/assets/{mermaid.core-DOBTmT-1.js → mermaid.core-DpBToEGQ.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-kPRBSQ6K.js → mindmap-definition-NLK3R4M7--DJgZ72R.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-BgX62j0G.js → pegDiagram-GJSIUBJH-DmTBsA2I.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DpC0-6hx.js → pieDiagram-5QR66LMP-Cy6JwGMR.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CNrmwxvV.js → quadrantDiagram-O4NWA36T-DjTftbBA.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-wl7o4Y2J.js → railroadDiagram-XR7U4H2S-DeKIQoik.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-D2qhVvpT.js → requirementDiagram-PLB6GJNP-B02KsDuy.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-DZOSOZWs.js → sankeyDiagram-IPEJSGJF-4RLO5vMI.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-eBogKj3g.js → sequenceDiagram-PO4LG4MO-CcBW737M.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Dp_Vdw0m.js → sizeCapture-INFHLROL-CaLSjl7R.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-K79Em0_p.js → stateDiagram-v2-GCMORJYK-blyzRgvD.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-ByKYlFa_.js → swimlanes-2SLR337P-BIi-tuCD.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DWtkSjpb.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-CzeMeYU0.js → timeline-definition-EJHVYXUP-oNE7PiRv.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-uQjp5Yz3.js → usecaseDiagram-POWQR4AR-DzmCYS5I.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-De8_78dQ.js → vennDiagram-UO4OBE2U-T51P02io.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Dk_VO2LR.js → wardleyDiagram-VNRHLVJA-1GfD8Fys.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DMx2Y7qW.js → xychartDiagram-PMCCYNJV-BhNMe0uk.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -5
- package/dist/index.html +1 -1
- package/dist-server/index.js +1087 -988
- package/dist-server/openmausbot.js +224 -176
- package/dist-server/pair-cli.js +224 -176
- package/dist-server/server/computer-stop-names.js +35 -0
- package/dist-server/server/connection-cap-failover.js +1 -1
- package/dist-server/server/drivers/claude-auth-status.js +25 -0
- package/dist-server/server/drivers/claude.js +6 -5
- package/dist-server/server/drivers/retry.js +1 -0
- package/dist-server/server/engine-failover.js +14 -5
- package/dist-server/server/engine-failure.js +4 -4
- package/dist-server/server/index.js +13 -14
- package/dist-server/server/injected-model-rest.js +9 -0
- package/dist-server/server/model-access-refusal.js +62 -0
- package/dist-server/server/workspace-backup-copy.js +34 -1
- package/dist-server/server/workspace-backup-http.js +8 -5
- package/dist-server/server/workspace-backup-secrets.js +2 -2
- package/dist-server/server/workspace-backup.js +38 -52
- package/dist-server/shared/workspace-backup.js +23 -1
- package/package.json +1 -1
- package/dist/assets/channel-DmcLphYK.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BnN5frkm.js +0 -8
package/dist-server/pair-cli.js
CHANGED
|
@@ -25619,6 +25619,44 @@ var init_provider_safety = __esm({
|
|
|
25619
25619
|
}
|
|
25620
25620
|
});
|
|
25621
25621
|
|
|
25622
|
+
// server/model-access-refusal.ts
|
|
25623
|
+
function isModelAccessRefused(text5) {
|
|
25624
|
+
if (!text5 || SIGN_IN_WORDS.test(text5)) return false;
|
|
25625
|
+
return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text5));
|
|
25626
|
+
}
|
|
25627
|
+
var AUTH_STATUS, MODEL_NAME, MODEL_ACCESS_REFUSED, SIGN_IN_WORDS;
|
|
25628
|
+
var init_model_access_refusal = __esm({
|
|
25629
|
+
"server/model-access-refusal.ts"() {
|
|
25630
|
+
"use strict";
|
|
25631
|
+
AUTH_STATUS = [
|
|
25632
|
+
// "API Error: 401", "HTTP 403", "HTTP/1.1 403", "status code 401", "error
|
|
25633
|
+
// code: 403", JSON "status":401. A bare "code" is not enough ("exited with
|
|
25634
|
+
// code 403" is a process), and neither is a count ("Error 403 files").
|
|
25635
|
+
/\b(?:api error|http(?:\/\d(?:\.\d)?)?|(?:status|error|response)(?:[ _]?code)?)\b["\s:=([]*40[13]\b(?!\s+(?:of|files?|rows?|items?|messages?|tokens?|results?|lines?|bytes|tests?|errors?|warnings?|seconds?|minutes?|ms|times)\b)|"code"\s*:\s*40[13]\b/i,
|
|
25636
|
+
// OpenCode's ACP shape, "Upstream request failed: [401] ...". The bracket
|
|
25637
|
+
// alone is not a status: "[403] indexing files" is a log line.
|
|
25638
|
+
/\b(?:failed|error|rejected)\b[^\n[]{0,12}\[40[13]\]/i,
|
|
25639
|
+
// "Request failed with 401", "Request failed (403)": the number ends the
|
|
25640
|
+
// thought.
|
|
25641
|
+
/\b(?:failed|rejected|responded|answered)(?: with)?(?: (?:a|an|status|http|code))* \(?40[13]\)?(?=\s*(?:$|[.,;:)\]]|from\b|error\b|response\b))/i,
|
|
25642
|
+
// "received 403 from upstream". These verbs also count things ("returned
|
|
25643
|
+
// 401."), so the number needs what it came from.
|
|
25644
|
+
/\b(?:returned|received|got) (?:a |an )?\(?40[13]\)?(?=\s*(?:from\b|error\b|response\b))/i,
|
|
25645
|
+
/\b40[13]\b[^\n]{0,160}\b(?:unauthori[sz]ed|unauthenticated|authenticat\w*|api[ _-]?key|oauth|(?:access |bearer )?token|credentials?|log(?:ged)?[ -]?in|sign(?:ed)?[ -]?in)\b/i
|
|
25646
|
+
];
|
|
25647
|
+
MODEL_NAME = "model|claude-[\\w.-]+|gpt-[\\w.-]+|gemini-[\\w.-]+|grok-[\\w.-]+|opus|sonnet|haiku|fable";
|
|
25648
|
+
MODEL_ACCESS_REFUSED = [
|
|
25649
|
+
/\bissue with the selected model\b|\bmodel\b[^\n]{0,120}\b(?:may|does) not exist or you (?:may |do )?not have access\b/i,
|
|
25650
|
+
/\b(?:do(?:es)?n['’]?t|do(?:es)? not) (?:currently )?have access to (?:the |this |that )?(?:model\b|claude-|gpt-|gemini-|grok-|o\d)/i,
|
|
25651
|
+
new RegExp(`\\b(?:plan|subscription|organi[sz]ation|account|tier) (?:does not|doesn['\u2019]?t) (?:include|support|allow|have access to)\\b[^.\\n]{0,80}\\b(?:${MODEL_NAME})\\b`, "i"),
|
|
25652
|
+
/\b(?:model|claude-[\w.-]+|opus|sonnet|haiku|fable)\b(?:[^.\n]|\.\d){0,80}\b(?:is |are )?(?:not available|unavailable|not included|not enabled|not supported) (?:on|in|for|with) (?:your|this|the) (?:current )?(?:plan|subscription|account|organi[sz]ation|tier)\b/i,
|
|
25653
|
+
/\bmodel_not_found\b|\bnot_found_error\b[^\n]{0,200}\bmodel\b|\bmodel\b[^\n]{0,40}\bnot_found_error\b/i,
|
|
25654
|
+
new RegExp(`\\bpermission_error\\b[^\\n]{0,240}\\b(?:${MODEL_NAME})\\b`, "i")
|
|
25655
|
+
];
|
|
25656
|
+
SIGN_IN_WORDS = /\bnot (?:logged|signed) in\b|\b(?:please )?run \/login\b|\blog ?in again\b|\bsign ?in again\b|\bre-?authenticat\w*|\b(?:login|sign-?in|token|session|credentials?) (?:has |have )?expired\b|\b(?:token|key|credentials?|session) (?:has |have |was |were )?(?:been )?revoked\b|\bauthentication_error\b|\boauth\b|\bscope requirement\b|\binvalid[ _-]?(?:x-)?api[ _-]?key\b|\bkey (?:has |was )?(?:been )?(?:expired|revoked)\b/i;
|
|
25657
|
+
}
|
|
25658
|
+
});
|
|
25659
|
+
|
|
25622
25660
|
// server/engine-failure.ts
|
|
25623
25661
|
function statedReset(text5, now = Date.now()) {
|
|
25624
25662
|
const reset = parseReset(text5, now);
|
|
@@ -25654,6 +25692,7 @@ function classifyEngineFailure(text5, now = Date.now()) {
|
|
|
25654
25692
|
return { kind: "usage_limited", ...statedReset(text5, now) };
|
|
25655
25693
|
}
|
|
25656
25694
|
if (isCredentialDead(text5)) return { kind: "auth_failed", permanent: true };
|
|
25695
|
+
if (isModelAccessRefused(text5)) return { kind: "request_rejected" };
|
|
25657
25696
|
if (AUTH_FAILED.some((pattern) => pattern.test(text5))) return { kind: "auth_failed" };
|
|
25658
25697
|
if (STALLED.some((pattern) => pattern.test(text5))) return { kind: "stalled" };
|
|
25659
25698
|
if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(text5))) {
|
|
@@ -25857,6 +25896,7 @@ var MAX_WINDOW_MS, ROLLING_WINDOW, USAGE_LIMITED, EXHAUSTED, TOO_FAST, RATE_LIMI
|
|
|
25857
25896
|
var init_engine_failure = __esm({
|
|
25858
25897
|
"server/engine-failure.ts"() {
|
|
25859
25898
|
"use strict";
|
|
25899
|
+
init_model_access_refusal();
|
|
25860
25900
|
MAX_WINDOW_MS = 7 * 24 * 60 * 6e4;
|
|
25861
25901
|
ROLLING_WINDOW = /\brolling\s+(\d+(?:\.\d+)?)[\s-]*(minute|min|hour|hr|h|day|d|week|wk)s?\b(?:[\s-]*window)?|\b(\d+(?:\.\d+)?)[\s-]*(minute|min|hour|hr|h|day|d|week|wk)s?\s+rolling\s+window\b/i;
|
|
25862
25902
|
USAGE_LIMITED = [
|
|
@@ -25915,13 +25955,11 @@ var init_engine_failure = __esm({
|
|
|
25915
25955
|
// Claude Code: "Not logged in · Please run /login", "Login expired · Run /login ...", "Invalid API key · ...";
|
|
25916
25956
|
// Anthropic API: 401 authentication_error "invalid x-api-key";
|
|
25917
25957
|
// OpenAI: "Incorrect API key provided"; ACP agents: -32000 "Authentication required".
|
|
25918
|
-
|
|
25958
|
+
...AUTH_STATUS,
|
|
25959
|
+
// a 401/403 as a status or beside sign-in words, never a bare number
|
|
25919
25960
|
/\bunauthori[sz]ed\b|\bunauthenticated\b|\bforbidden\b/i,
|
|
25920
25961
|
/\bauthentication[_ ](?:error|failed|required)\b|\binvalid_credentials\b|\bAUTH_REQUIRED\b/i,
|
|
25921
25962
|
/\b(?:invalid|incorrect)[ _-]?(?:x-)?api[ _-]?key\b|\bapi key (?:is )?(?:invalid|expired|revoked|not valid)\b/i,
|
|
25922
|
-
// OpenCode, 2026-10-19, as a JSON-RPC internal error: "Internal error:
|
|
25923
|
-
// This API key has expired. Create a new API key in OpenCode Console ..."
|
|
25924
|
-
/\bapi[ _-]?key (?:has |was )(?:been )?(?:expired|revoked|disabled)\b/i,
|
|
25925
25963
|
/\bnot (?:logged|signed) in\b|\b(?:logged|signed) out\b|\b(?:please )?run \/login\b|\b(?:login|sign-?in) (?:has )?expired\b|\bmissing bearer\b/i,
|
|
25926
25964
|
/\b(?:token|session|credentials?) (?:has |have )?expired\b|\bexpired (?:token|session|credentials?)\b/i
|
|
25927
25965
|
];
|
|
@@ -26135,6 +26173,7 @@ var init_retry = __esm({
|
|
|
26135
26173
|
"use strict";
|
|
26136
26174
|
init_provider_safety();
|
|
26137
26175
|
init_engine_failure();
|
|
26176
|
+
init_model_access_refusal();
|
|
26138
26177
|
RETRY_MAX_RETRIES = 2;
|
|
26139
26178
|
RETRY_MAX_ATTEMPTS = RETRY_MAX_RETRIES + 1;
|
|
26140
26179
|
BACKOFF_BASE_MS = [1e3, 3e3, 8e3];
|
|
@@ -29123,6 +29162,12 @@ var init_claude_account_connectors = __esm({
|
|
|
29123
29162
|
});
|
|
29124
29163
|
|
|
29125
29164
|
// server/drivers/claude-auth-status.ts
|
|
29165
|
+
import { join as join22 } from "node:path";
|
|
29166
|
+
function isolateAnthropicProfile(env, instanceEnvironment, dataDir) {
|
|
29167
|
+
if (choseAnthropicProfile(instanceEnvironment)) return;
|
|
29168
|
+
delete env.ANTHROPIC_PROFILE;
|
|
29169
|
+
env.ANTHROPIC_CONFIG_DIR = join22(dataDir, "claude-no-anthropic-profile");
|
|
29170
|
+
}
|
|
29126
29171
|
function claudeOwnLogin(status, namedAccount) {
|
|
29127
29172
|
if (!status || typeof status !== "object" || !("loggedIn" in status) || status.loggedIn !== true) return false;
|
|
29128
29173
|
return !(namedAccount && "authMethod" in status && status.authMethod === "oauth_token");
|
|
@@ -29150,10 +29195,12 @@ function claudeAuthStatus(cli, env, run2 = execCli, namedAccount = false) {
|
|
|
29150
29195
|
});
|
|
29151
29196
|
});
|
|
29152
29197
|
}
|
|
29198
|
+
var choseAnthropicProfile;
|
|
29153
29199
|
var init_claude_auth_status = __esm({
|
|
29154
29200
|
"server/drivers/claude-auth-status.ts"() {
|
|
29155
29201
|
"use strict";
|
|
29156
29202
|
init_procs();
|
|
29203
|
+
choseAnthropicProfile = (instanceEnvironment) => Boolean(instanceEnvironment.ANTHROPIC_PROFILE || instanceEnvironment.ANTHROPIC_CONFIG_DIR);
|
|
29157
29204
|
}
|
|
29158
29205
|
});
|
|
29159
29206
|
|
|
@@ -29161,14 +29208,14 @@ var init_claude_auth_status = __esm({
|
|
|
29161
29208
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
29162
29209
|
import { realpathSync } from "node:fs";
|
|
29163
29210
|
import { homedir as homedir8 } from "node:os";
|
|
29164
|
-
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute3, join as
|
|
29211
|
+
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute3, join as join23, resolve as resolve6 } from "node:path";
|
|
29165
29212
|
import { stripVTControlCharacters as stripVTControlCharacters5 } from "node:util";
|
|
29166
29213
|
function canonicalPath(path4) {
|
|
29167
29214
|
try {
|
|
29168
29215
|
return realpathSync(path4);
|
|
29169
29216
|
} catch {
|
|
29170
29217
|
const parent = dirname8(path4);
|
|
29171
|
-
return parent === path4 ? path4 :
|
|
29218
|
+
return parent === path4 ? path4 : join23(canonicalPath(parent), basename6(path4));
|
|
29172
29219
|
}
|
|
29173
29220
|
}
|
|
29174
29221
|
function claudeSignInLink(value) {
|
|
@@ -29226,7 +29273,7 @@ var init_claude_login_auth = __esm({
|
|
|
29226
29273
|
if (!isAbsolute3(home) || env.CLAUDE_CONFIG_DIR && !isAbsolute3(env.CLAUDE_CONFIG_DIR)) {
|
|
29227
29274
|
throw new Error("Use an absolute HOME and CLAUDE_CONFIG_DIR path for this server's Claude provider before signing in.");
|
|
29228
29275
|
}
|
|
29229
|
-
const homeKey = canonicalPath(resolve6(env.CLAUDE_CONFIG_DIR ||
|
|
29276
|
+
const homeKey = canonicalPath(resolve6(env.CLAUDE_CONFIG_DIR || join23(home, ".claude")));
|
|
29230
29277
|
if (authenticatingHomes.has(homeKey)) {
|
|
29231
29278
|
throw new Error("A Claude sign-in is already running for this server account. Finish or cancel it before starting another.");
|
|
29232
29279
|
}
|
|
@@ -29322,7 +29369,7 @@ var init_claude_login_auth = __esm({
|
|
|
29322
29369
|
if (!isAbsolute3(home) || env.CLAUDE_CONFIG_DIR && !isAbsolute3(env.CLAUDE_CONFIG_DIR)) {
|
|
29323
29370
|
throw new Error("Use an absolute HOME and CLAUDE_CONFIG_DIR path for this server's Claude provider before signing out.");
|
|
29324
29371
|
}
|
|
29325
|
-
const homeKey = canonicalPath(resolve6(env.CLAUDE_CONFIG_DIR ||
|
|
29372
|
+
const homeKey = canonicalPath(resolve6(env.CLAUDE_CONFIG_DIR || join23(home, ".claude")));
|
|
29326
29373
|
if (authenticatingHomes.has(homeKey)) {
|
|
29327
29374
|
throw new Error("A Claude sign-in is running for this server account. Finish or cancel it before signing out.");
|
|
29328
29375
|
}
|
|
@@ -29843,11 +29890,11 @@ import { createHash as createHash7, randomBytes as randomBytes2 } from "node:cry
|
|
|
29843
29890
|
import { chmodSync as chmodSync4, existsSync as existsSync13, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync3, readFileSync as readFileSync10, rmSync as rmSync6, unlinkSync as unlinkSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
29844
29891
|
import { createServer as createNetServer } from "node:net";
|
|
29845
29892
|
import { homedir as homedir9, tmpdir as tmpdir3 } from "node:os";
|
|
29846
|
-
import { join as
|
|
29893
|
+
import { join as join24, dirname as dirname9, isAbsolute as isAbsolute4, normalize } from "node:path";
|
|
29847
29894
|
function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
29848
29895
|
const home = env.HOME || env.USERPROFILE || homedir9();
|
|
29849
|
-
const configured = configDir2?.trim() || env.CLAUDE_CONFIG_DIR?.trim() ||
|
|
29850
|
-
const expanded = configured === "~" ? home : configured.startsWith("~/") ?
|
|
29896
|
+
const configured = configDir2?.trim() || env.CLAUDE_CONFIG_DIR?.trim() || join24(home, ".claude");
|
|
29897
|
+
const expanded = configured === "~" ? home : configured.startsWith("~/") ? join24(home, configured.slice(2)) : configured;
|
|
29851
29898
|
if (!isAbsolute4(expanded) || /[\p{Cc}\p{Cf}]/u.test(expanded)) {
|
|
29852
29899
|
throw new Error("claude: configDir must be an absolute path or start with ~/");
|
|
29853
29900
|
}
|
|
@@ -29855,7 +29902,7 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
|
29855
29902
|
}
|
|
29856
29903
|
function claudeAuthFailure(frame, text5) {
|
|
29857
29904
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
29858
|
-
return frame.error === "authentication_failed" || classifyError({ text: text5 }).reason === "auth_failed";
|
|
29905
|
+
return !isModelAccessRefused(text5) && (frame.error === "authentication_failed" || classifyError({ text: text5 }).reason === "auth_failed");
|
|
29859
29906
|
}
|
|
29860
29907
|
function claudeCredentialRefreshConflict(frame, text5) {
|
|
29861
29908
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
@@ -29881,6 +29928,7 @@ function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnv
|
|
|
29881
29928
|
}
|
|
29882
29929
|
delete env.CLAUDECODE;
|
|
29883
29930
|
delete env.CLAUDE_CODE_ENTRYPOINT;
|
|
29931
|
+
isolateAnthropicProfile(env, instanceEnvironment, DATA_DIR);
|
|
29884
29932
|
stripWorkspaceCredentialEnv(env);
|
|
29885
29933
|
const applied = applyClaudeInject(env, model);
|
|
29886
29934
|
if (!applied.injected && !instanceEnvironment.ANTHROPIC_API_KEY) delete env.ANTHROPIC_API_KEY;
|
|
@@ -29899,7 +29947,7 @@ function claudeInheritWarning(env) {
|
|
|
29899
29947
|
function readClaudeAuthSettings(env, instanceEnvironment = {}) {
|
|
29900
29948
|
if (CLAUDE_ACCOUNT_ENV_KEYS.some((key) => instanceEnvironment[key])) return {};
|
|
29901
29949
|
try {
|
|
29902
|
-
const settings2 = JSON.parse(readFileSync10(
|
|
29950
|
+
const settings2 = JSON.parse(readFileSync10(join24(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
|
|
29903
29951
|
const authEnv = {};
|
|
29904
29952
|
for (const key of CLAUDE_ACCOUNT_ENV_KEYS) {
|
|
29905
29953
|
if (!key.endsWith("_FILE_DESCRIPTOR") && typeof settings2?.env?.[key] === "string") {
|
|
@@ -29917,7 +29965,7 @@ function readClaudeAuthSettings(env, instanceEnvironment = {}) {
|
|
|
29917
29965
|
function projectMcpServers(cwd) {
|
|
29918
29966
|
let parsed;
|
|
29919
29967
|
try {
|
|
29920
|
-
parsed = JSON.parse(readFileSync10(
|
|
29968
|
+
parsed = JSON.parse(readFileSync10(join24(cwd, ".mcp.json"), "utf8"));
|
|
29921
29969
|
} catch {
|
|
29922
29970
|
return {};
|
|
29923
29971
|
}
|
|
@@ -29990,7 +30038,7 @@ function extrasFromUnknown(value) {
|
|
|
29990
30038
|
function readClaudeModelCatalog(env = process.env) {
|
|
29991
30039
|
let settings2 = {};
|
|
29992
30040
|
try {
|
|
29993
|
-
settings2 = JSON.parse(readFileSync10(
|
|
30041
|
+
settings2 = JSON.parse(readFileSync10(join24(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
|
|
29994
30042
|
} catch {
|
|
29995
30043
|
settings2 = {};
|
|
29996
30044
|
}
|
|
@@ -30040,7 +30088,7 @@ function askSummary(ask) {
|
|
|
30040
30088
|
}
|
|
30041
30089
|
function hookTokenFile(threadId, botId) {
|
|
30042
30090
|
const digest2 = createHash7("sha256").update(`${botId ?? ""}\0${threadId}`).digest("hex").slice(0, 24);
|
|
30043
|
-
return
|
|
30091
|
+
return join24(DATA_DIR, "hook-tokens", `${digest2}.token`);
|
|
30044
30092
|
}
|
|
30045
30093
|
function claudeHookSettings(helperPath) {
|
|
30046
30094
|
const command = process.platform === "win32" ? '"%OMB_HOOK_NODE%" "%OMB_HOOK_HELPER%"' : [process.execPath, helperPath].map((path4) => `'${path4.replace(/'/g, "'\\''")}'`).join(" ");
|
|
@@ -30066,7 +30114,7 @@ function brokerSocketCandidates(threadId, botId) {
|
|
|
30066
30114
|
const base2 = permissionSocketPath(threadId, botId);
|
|
30067
30115
|
if (process.platform !== "win32") {
|
|
30068
30116
|
const scope = createHash7("sha256").update(`${DATA_DIR}\0${process.pid}\0${botId ?? ""}\0${threadId}`).digest("hex").slice(0, 16);
|
|
30069
|
-
return [base2,
|
|
30117
|
+
return [base2, join24(tmpdir3(), `omb-perm-${scope}.sock`)];
|
|
30070
30118
|
}
|
|
30071
30119
|
return [
|
|
30072
30120
|
base2,
|
|
@@ -30389,7 +30437,7 @@ var init_claude = __esm({
|
|
|
30389
30437
|
const { instanceId, config: config2 } = input;
|
|
30390
30438
|
const environment = (model) => claudeEnvironment(config2.managed ? void 0 : model, { ...process.env, ...input.environment }, config2.configDir, input.environment);
|
|
30391
30439
|
const catalogEnv = environment();
|
|
30392
|
-
const namedAccount = Boolean(config2.configDir?.trim());
|
|
30440
|
+
const namedAccount = Boolean(config2.configDir?.trim()) && !choseAnthropicProfile(input.environment);
|
|
30393
30441
|
if (inheritsUserConfig(catalogEnv)) {
|
|
30394
30442
|
console.error(`claude (${instanceId}): OMB_CLAUDE_INHERIT_USER_CONFIG=1 \u2014 bots inherit this machine's Claude Code MCP servers, skills, hooks and CLAUDE.md on every turn; remove it unless a bot needs a user-scope server`);
|
|
30395
30443
|
}
|
|
@@ -30649,7 +30697,7 @@ var init_claude = __esm({
|
|
|
30649
30697
|
allowed.push("mcp__ogb");
|
|
30650
30698
|
let mcpConfigPath = null;
|
|
30651
30699
|
if (Object.keys(mcpServers).length) {
|
|
30652
|
-
mcpConfigPath =
|
|
30700
|
+
mcpConfigPath = join24(mkdtempSync3(join24(tmpdir3(), "omb-mcp-")), "mcp.json");
|
|
30653
30701
|
args.push("--mcp-config", mcpConfigPath);
|
|
30654
30702
|
args.push("--allowedTools", allowed.join(","));
|
|
30655
30703
|
}
|
|
@@ -30685,7 +30733,7 @@ var init_claude = __esm({
|
|
|
30685
30733
|
...plan ? { PreToolUse: claudePlanHook(process.execPath, SPAWNED_PROXIES.planHook) } : {}
|
|
30686
30734
|
};
|
|
30687
30735
|
if (Object.keys(hookBlock).length) settings2.hooks = hookBlock;
|
|
30688
|
-
const authSettingsPath = mcpConfigPath && Object.keys(settings2).length ?
|
|
30736
|
+
const authSettingsPath = mcpConfigPath && Object.keys(settings2).length ? join24(dirname9(mcpConfigPath), "auth-settings.json") : null;
|
|
30689
30737
|
if (authSettingsPath) args.push("--settings", authSettingsPath);
|
|
30690
30738
|
env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS = "1";
|
|
30691
30739
|
const cwd = turn.cwd ?? homedir9();
|
|
@@ -30768,7 +30816,7 @@ var init_claude = __esm({
|
|
|
30768
30816
|
try {
|
|
30769
30817
|
const systemText = turn.systemStable ?? turn.system;
|
|
30770
30818
|
if (systemText) {
|
|
30771
|
-
systemPromptPath =
|
|
30819
|
+
systemPromptPath = join24(mkdtempSync3(join24(tmpdir3(), "omb-system-")), "prompt.txt");
|
|
30772
30820
|
writeFileSync7(systemPromptPath, systemText, { mode: 384 });
|
|
30773
30821
|
args.push("--append-system-prompt-file", systemPromptPath);
|
|
30774
30822
|
}
|
|
@@ -31752,13 +31800,13 @@ var init_toml_lite = __esm({
|
|
|
31752
31800
|
|
|
31753
31801
|
// server/mcp-auth-signal.ts
|
|
31754
31802
|
import { mkdirSync as mkdirSync12, readFileSync as readFileSync11, readdirSync as readdirSync3, renameSync as renameSync7, rmSync as rmSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
31755
|
-
import { join as
|
|
31803
|
+
import { join as join25 } from "node:path";
|
|
31756
31804
|
function writeMcpAuthSignal(dir, signal) {
|
|
31757
31805
|
if (!dir) return;
|
|
31758
31806
|
try {
|
|
31759
31807
|
mkdirSync12(dir, { recursive: true, mode: 448 });
|
|
31760
31808
|
const safe = signal.name.replace(/[^A-Za-z0-9_-]/g, "-").slice(0, 40) || "mcp";
|
|
31761
|
-
const file2 =
|
|
31809
|
+
const file2 = join25(dir, `${signal.at}-${process.pid}-${safe}-${signal.kind}${SUFFIX}`);
|
|
31762
31810
|
const temp = `${file2}.tmp`;
|
|
31763
31811
|
writeFileSync8(temp, JSON.stringify(signal), { mode: 384 });
|
|
31764
31812
|
renameSync7(temp, file2);
|
|
@@ -31776,7 +31824,7 @@ var init_mcp_auth_signal = __esm({
|
|
|
31776
31824
|
// server/drivers/codex-mcp-names.ts
|
|
31777
31825
|
import { readFileSync as readFileSync12 } from "node:fs";
|
|
31778
31826
|
import { homedir as homedir10 } from "node:os";
|
|
31779
|
-
import { isAbsolute as isAbsolute5, join as
|
|
31827
|
+
import { isAbsolute as isAbsolute5, join as join26, resolve as resolve7 } from "node:path";
|
|
31780
31828
|
function mcpServerNamesInToml(toml) {
|
|
31781
31829
|
const names = /* @__PURE__ */ new Set();
|
|
31782
31830
|
for (const match of toml.matchAll(HEADER)) {
|
|
@@ -31804,11 +31852,11 @@ function mcpServersInToml(toml) {
|
|
|
31804
31852
|
function codexHomeFor(env, cwd) {
|
|
31805
31853
|
const configured = env.CODEX_HOME;
|
|
31806
31854
|
if (configured) return isAbsolute5(configured) ? configured : resolve7(cwd ?? process.cwd(), configured);
|
|
31807
|
-
return
|
|
31855
|
+
return join26(env.HOME || env.USERPROFILE || homedir10(), ".codex");
|
|
31808
31856
|
}
|
|
31809
31857
|
function codexConfigMcpServers(env, cwd) {
|
|
31810
31858
|
try {
|
|
31811
|
-
return mcpServersInToml(readFileSync12(
|
|
31859
|
+
return mcpServersInToml(readFileSync12(join26(codexHomeFor(env, cwd), "config.toml"), "utf8"));
|
|
31812
31860
|
} catch {
|
|
31813
31861
|
return /* @__PURE__ */ new Map();
|
|
31814
31862
|
}
|
|
@@ -31852,11 +31900,11 @@ var init_codex_mcp_names = __esm({
|
|
|
31852
31900
|
// server/drivers/codex-personal.ts
|
|
31853
31901
|
import { existsSync as existsSync14, readdirSync as readdirSync4 } from "node:fs";
|
|
31854
31902
|
import { homedir as homedir11 } from "node:os";
|
|
31855
|
-
import { join as
|
|
31903
|
+
import { join as join27, resolve as resolve8 } from "node:path";
|
|
31856
31904
|
function codexPersonalSkillFiles(env, cwd) {
|
|
31857
31905
|
const home = env.HOME || env.USERPROFILE || homedir11();
|
|
31858
|
-
const roots = [
|
|
31859
|
-
if (!cwd || resolve8(cwd) !== resolve8(home)) roots.push(
|
|
31906
|
+
const roots = [join27(codexHomeFor(env, cwd), "skills")];
|
|
31907
|
+
if (!cwd || resolve8(cwd) !== resolve8(home)) roots.push(join27(home, ".agents", "skills"));
|
|
31860
31908
|
const files = [];
|
|
31861
31909
|
for (const root of roots) {
|
|
31862
31910
|
let names;
|
|
@@ -31866,7 +31914,7 @@ function codexPersonalSkillFiles(env, cwd) {
|
|
|
31866
31914
|
continue;
|
|
31867
31915
|
}
|
|
31868
31916
|
for (const name of names) {
|
|
31869
|
-
const file2 =
|
|
31917
|
+
const file2 = join27(root, name, "SKILL.md");
|
|
31870
31918
|
if (existsSync14(file2)) files.push(file2);
|
|
31871
31919
|
}
|
|
31872
31920
|
}
|
|
@@ -31890,10 +31938,10 @@ var init_codex_personal = __esm({
|
|
|
31890
31938
|
// server/drivers/codex-image.ts
|
|
31891
31939
|
import { mkdtemp as mkdtemp3, rm as rm4 } from "node:fs/promises";
|
|
31892
31940
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
31893
|
-
import { join as
|
|
31941
|
+
import { join as join28 } from "node:path";
|
|
31894
31942
|
async function codexImage(cli, env, prompt, signal, diagnostic, model) {
|
|
31895
31943
|
signal.throwIfAborted();
|
|
31896
|
-
const cwd = await mkdtemp3(
|
|
31944
|
+
const cwd = await mkdtemp3(join28(tmpdir4(), "atomic-avatar-"));
|
|
31897
31945
|
const args = [
|
|
31898
31946
|
"app-server",
|
|
31899
31947
|
...codexToolSurfaceArgs(),
|
|
@@ -32152,7 +32200,7 @@ var init_codex_elicitation = __esm({
|
|
|
32152
32200
|
// server/drivers/codex-catalog.ts
|
|
32153
32201
|
import { readdirSync as readdirSync5, readFileSync as readFileSync13 } from "node:fs";
|
|
32154
32202
|
import { homedir as homedir12 } from "node:os";
|
|
32155
|
-
import { basename as basename7, join as
|
|
32203
|
+
import { basename as basename7, join as join29 } from "node:path";
|
|
32156
32204
|
function encodeCodexSelection(provider, model) {
|
|
32157
32205
|
return `${provider}${SEP}${model}`;
|
|
32158
32206
|
}
|
|
@@ -32268,7 +32316,7 @@ function readCodexAppServerModelCatalog(cli, env, timeoutMs = 8e3) {
|
|
|
32268
32316
|
}
|
|
32269
32317
|
function codexHome(env) {
|
|
32270
32318
|
if (env.CODEX_HOME) return env.CODEX_HOME;
|
|
32271
|
-
return
|
|
32319
|
+
return join29(env.HOME || env.USERPROFILE || homedir12(), ".codex");
|
|
32272
32320
|
}
|
|
32273
32321
|
function unquote(raw) {
|
|
32274
32322
|
let value = raw.trim();
|
|
@@ -32354,11 +32402,11 @@ function niceLabel(model, provider, known, named) {
|
|
|
32354
32402
|
}
|
|
32355
32403
|
function collectCatalogNames(home) {
|
|
32356
32404
|
const named = /* @__PURE__ */ new Map();
|
|
32357
|
-
for (const file2 of listDir(
|
|
32405
|
+
for (const file2 of listDir(join29(home, "model-catalogs"))) {
|
|
32358
32406
|
if (!file2.endsWith(".json")) continue;
|
|
32359
32407
|
const provider = basename7(file2, ".json").replace(/-models$/, "");
|
|
32360
32408
|
if (!PROVIDER_ID.test(provider)) continue;
|
|
32361
|
-
const raw = readText(
|
|
32409
|
+
const raw = readText(join29(home, "model-catalogs", file2));
|
|
32362
32410
|
if (!raw) continue;
|
|
32363
32411
|
let parsed;
|
|
32364
32412
|
try {
|
|
@@ -32410,7 +32458,7 @@ async function probeProviderModels(provider, env, fetchImpl) {
|
|
|
32410
32458
|
async function readCodexModelCatalog(env = process.env, fetchImpl = fetch, cli) {
|
|
32411
32459
|
const official = (cli ? await readCodexAppServerModelCatalog(cli, env) : null) ?? STATIC_CODEX_MODELS;
|
|
32412
32460
|
const home = codexHome(env);
|
|
32413
|
-
const mainText = readText(
|
|
32461
|
+
const mainText = readText(join29(home, "config.toml"));
|
|
32414
32462
|
if (!mainText) return mergeLocalInject(official, env, fetchImpl);
|
|
32415
32463
|
const main2 = parseCodexToml(mainText);
|
|
32416
32464
|
const known = new Map(main2.providers.map((provider) => [provider.id, provider]));
|
|
@@ -32425,7 +32473,7 @@ async function readCodexModelCatalog(env = process.env, fetchImpl = fetch, cli)
|
|
|
32425
32473
|
remember(main2.modelProvider, main2.model);
|
|
32426
32474
|
for (const file2 of listDir(home)) {
|
|
32427
32475
|
if (!file2.endsWith(".config.toml")) continue;
|
|
32428
|
-
const profile = parseCodexToml(readText(
|
|
32476
|
+
const profile = parseCodexToml(readText(join29(home, file2)) ?? "");
|
|
32429
32477
|
for (const provider of profile.providers) {
|
|
32430
32478
|
if (!known.has(provider.id)) known.set(provider.id, provider);
|
|
32431
32479
|
}
|
|
@@ -32492,7 +32540,7 @@ var init_codex_catalog = __esm({
|
|
|
32492
32540
|
// server/drivers/codex-instructions.ts
|
|
32493
32541
|
import { createHash as createHash8 } from "node:crypto";
|
|
32494
32542
|
import { mkdirSync as mkdirSync13, readFileSync as readFileSync14 } from "node:fs";
|
|
32495
|
-
import { join as
|
|
32543
|
+
import { join as join30 } from "node:path";
|
|
32496
32544
|
function codexDeveloperInstructions(config2, botInstructions) {
|
|
32497
32545
|
if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) {
|
|
32498
32546
|
throw new Error("Codex returned no effective configuration; cannot safely update bot instructions.");
|
|
@@ -32506,8 +32554,8 @@ function codexDeveloperInstructions(config2, botInstructions) {
|
|
|
32506
32554
|
${configured}` : botInstructions;
|
|
32507
32555
|
}
|
|
32508
32556
|
async function syncCodexInstructions(key, nativeThreadId, instructions, resumed, request) {
|
|
32509
|
-
const directory =
|
|
32510
|
-
const path4 =
|
|
32557
|
+
const directory = join30(DATA_DIR, "codex-instructions");
|
|
32558
|
+
const path4 = join30(directory, `${digest(JSON.stringify([key, nativeThreadId]))}.sha256`);
|
|
32511
32559
|
const fingerprint2 = digest(instructions);
|
|
32512
32560
|
let previous;
|
|
32513
32561
|
try {
|
|
@@ -32554,14 +32602,14 @@ var init_codex_instructions = __esm({
|
|
|
32554
32602
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
32555
32603
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
32556
32604
|
import { homedir as homedir13 } from "node:os";
|
|
32557
|
-
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute6, join as
|
|
32605
|
+
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute6, join as join31, resolve as resolve9 } from "node:path";
|
|
32558
32606
|
import { stripVTControlCharacters as stripVTControlCharacters6 } from "node:util";
|
|
32559
32607
|
function canonicalPath2(path4) {
|
|
32560
32608
|
try {
|
|
32561
32609
|
return realpathSync2(path4);
|
|
32562
32610
|
} catch {
|
|
32563
32611
|
const parent = dirname10(path4);
|
|
32564
|
-
return parent === path4 ? path4 :
|
|
32612
|
+
return parent === path4 ? path4 : join31(canonicalPath2(parent), basename8(path4));
|
|
32565
32613
|
}
|
|
32566
32614
|
}
|
|
32567
32615
|
function codexDevicePrompt(output) {
|
|
@@ -32612,7 +32660,7 @@ var init_codex_device_auth = __esm({
|
|
|
32612
32660
|
if (!isAbsolute6(home) || env.CODEX_HOME && !isAbsolute6(env.CODEX_HOME)) {
|
|
32613
32661
|
throw new Error("Use an absolute HOME and CODEX_HOME path for this server's Codex provider before signing in.");
|
|
32614
32662
|
}
|
|
32615
|
-
const homeKey = canonicalPath2(resolve9(env.CODEX_HOME ||
|
|
32663
|
+
const homeKey = canonicalPath2(resolve9(env.CODEX_HOME || join31(home, ".codex")));
|
|
32616
32664
|
if (authenticatingHomes2.has(homeKey)) {
|
|
32617
32665
|
throw new Error("A ChatGPT sign-in is already running for this server account. Finish or cancel it before starting another.");
|
|
32618
32666
|
}
|
|
@@ -32691,7 +32739,7 @@ var init_codex_device_auth = __esm({
|
|
|
32691
32739
|
if (!isAbsolute6(home) || env.CODEX_HOME && !isAbsolute6(env.CODEX_HOME)) {
|
|
32692
32740
|
throw new Error("Use an absolute HOME and CODEX_HOME path for this server's Codex provider before signing out.");
|
|
32693
32741
|
}
|
|
32694
|
-
const homeKey = canonicalPath2(resolve9(env.CODEX_HOME ||
|
|
32742
|
+
const homeKey = canonicalPath2(resolve9(env.CODEX_HOME || join31(home, ".codex")));
|
|
32695
32743
|
if (authenticatingHomes2.has(homeKey)) {
|
|
32696
32744
|
throw new Error("A ChatGPT sign-in is running for this server account. Finish or cancel it before signing out.");
|
|
32697
32745
|
}
|
|
@@ -32850,11 +32898,11 @@ var init_codex_device_auth = __esm({
|
|
|
32850
32898
|
|
|
32851
32899
|
// server/drivers/codex-identity.ts
|
|
32852
32900
|
import { homedir as homedir14 } from "node:os";
|
|
32853
|
-
import { isAbsolute as isAbsolute7, join as
|
|
32901
|
+
import { isAbsolute as isAbsolute7, join as join32, resolve as resolve10 } from "node:path";
|
|
32854
32902
|
function codexHome2(env) {
|
|
32855
32903
|
if (env.CODEX_HOME) return isAbsolute7(env.CODEX_HOME) ? resolve10(env.CODEX_HOME) : null;
|
|
32856
32904
|
const home = env.HOME || env.USERPROFILE || homedir14();
|
|
32857
|
-
return isAbsolute7(home) ?
|
|
32905
|
+
return isAbsolute7(home) ? join32(home, ".codex") : null;
|
|
32858
32906
|
}
|
|
32859
32907
|
async function codexAccountEmail(cli, env, timeoutMs = 3e3) {
|
|
32860
32908
|
const cwd = env.HOME || env.USERPROFILE || homedir14();
|
|
@@ -42256,7 +42304,7 @@ import {
|
|
|
42256
42304
|
unlinkSync as unlinkSync4,
|
|
42257
42305
|
writeFileSync as writeFileSync9
|
|
42258
42306
|
} from "node:fs";
|
|
42259
|
-
import { dirname as dirname11, join as
|
|
42307
|
+
import { dirname as dirname11, join as join33 } from "node:path";
|
|
42260
42308
|
function hasCode(error51, code) {
|
|
42261
42309
|
return error51 instanceof Error && "code" in error51 && error51.code === code;
|
|
42262
42310
|
}
|
|
@@ -42277,13 +42325,13 @@ function readEnvironmentId(file2) {
|
|
|
42277
42325
|
return id;
|
|
42278
42326
|
}
|
|
42279
42327
|
function loadEnvironmentId(dataDir) {
|
|
42280
|
-
const file2 =
|
|
42328
|
+
const file2 = join33(dataDir, "environment-id");
|
|
42281
42329
|
const existing = readEnvironmentId(file2);
|
|
42282
42330
|
if (existing) return existing;
|
|
42283
42331
|
const directory = dirname11(file2);
|
|
42284
42332
|
mkdirSync14(directory, { recursive: true, mode: 448 });
|
|
42285
42333
|
const id = randomUUID10();
|
|
42286
|
-
const temporaryFile =
|
|
42334
|
+
const temporaryFile = join33(directory, `.environment-id.${process.pid}.${randomUUID10()}.tmp`);
|
|
42287
42335
|
let descriptor;
|
|
42288
42336
|
try {
|
|
42289
42337
|
descriptor = openSync5(temporaryFile, "wx", 384);
|
|
@@ -42320,7 +42368,7 @@ var init_environment = __esm({
|
|
|
42320
42368
|
// server/box-create-idempotency.ts
|
|
42321
42369
|
import { createHash as createHash9, randomUUID as randomUUID11 } from "node:crypto";
|
|
42322
42370
|
import { linkSync as linkSync3, mkdirSync as mkdirSync15, readFileSync as readFileSync17, unlinkSync as unlinkSync5, writeFileSync as writeFileSync10 } from "node:fs";
|
|
42323
|
-
import { join as
|
|
42371
|
+
import { join as join34 } from "node:path";
|
|
42324
42372
|
function isRequest(value) {
|
|
42325
42373
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
42326
42374
|
const request = value;
|
|
@@ -42579,8 +42627,8 @@ var init_box_create_idempotency = __esm({
|
|
|
42579
42627
|
"use strict";
|
|
42580
42628
|
init_atomic();
|
|
42581
42629
|
init_config();
|
|
42582
|
-
FILE =
|
|
42583
|
-
LOCK_FILE =
|
|
42630
|
+
FILE = join34(DATA_DIR, "box-create-requests.json");
|
|
42631
|
+
LOCK_FILE = join34(DATA_DIR, "box-create-requests.lock");
|
|
42584
42632
|
KEY_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
42585
42633
|
MAX_REQUESTS = 4096;
|
|
42586
42634
|
LOCK_WAIT_MS = 2e3;
|
|
@@ -42596,7 +42644,7 @@ var init_box_create_idempotency = __esm({
|
|
|
42596
42644
|
// server/box-delete-journal.ts
|
|
42597
42645
|
import { createHash as createHash10, randomUUID as randomUUID12 } from "node:crypto";
|
|
42598
42646
|
import { linkSync as linkSync4, mkdirSync as mkdirSync16, readFileSync as readFileSync18, unlinkSync as unlinkSync6, writeFileSync as writeFileSync11 } from "node:fs";
|
|
42599
|
-
import { join as
|
|
42647
|
+
import { join as join35 } from "node:path";
|
|
42600
42648
|
function validTimestamp(value) {
|
|
42601
42649
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
42602
42650
|
}
|
|
@@ -42844,8 +42892,8 @@ var init_box_delete_journal = __esm({
|
|
|
42844
42892
|
"use strict";
|
|
42845
42893
|
init_atomic();
|
|
42846
42894
|
init_config();
|
|
42847
|
-
FILE2 =
|
|
42848
|
-
LOCK_FILE2 =
|
|
42895
|
+
FILE2 = join35(DATA_DIR, "box-delete-requests.json");
|
|
42896
|
+
LOCK_FILE2 = join35(DATA_DIR, "box-delete-requests.lock");
|
|
42849
42897
|
MAX_RECORDS = 4096;
|
|
42850
42898
|
LOCK_WAIT_MS2 = 2e3;
|
|
42851
42899
|
LOCK_RETRY_MS2 = 20;
|
|
@@ -44398,7 +44446,7 @@ var init_grok = __esm({
|
|
|
44398
44446
|
// server/drivers/acp/grok.ts
|
|
44399
44447
|
import { existsSync as existsSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync12 } from "node:fs";
|
|
44400
44448
|
import { homedir as homedir17 } from "node:os";
|
|
44401
|
-
import { join as
|
|
44449
|
+
import { join as join36 } from "node:path";
|
|
44402
44450
|
function decodeGrokModelText(text5) {
|
|
44403
44451
|
if (/\bnot authenticated\b/i.test(text5)) return null;
|
|
44404
44452
|
const options = [];
|
|
@@ -44432,7 +44480,7 @@ function fetchGrokModels(cli, env, run2 = execCli) {
|
|
|
44432
44480
|
}
|
|
44433
44481
|
function grokHome(env) {
|
|
44434
44482
|
if (env.GROK_HOME) return env.GROK_HOME;
|
|
44435
|
-
return
|
|
44483
|
+
return join36(env.HOME || env.USERPROFILE || homedir17(), ".grok");
|
|
44436
44484
|
}
|
|
44437
44485
|
function unquote2(raw) {
|
|
44438
44486
|
const value = raw.trim();
|
|
@@ -44442,7 +44490,7 @@ function unquote2(raw) {
|
|
|
44442
44490
|
return value;
|
|
44443
44491
|
}
|
|
44444
44492
|
function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
44445
|
-
const path4 =
|
|
44493
|
+
const path4 = join36(grokHome(env), "config.toml");
|
|
44446
44494
|
let text5 = "";
|
|
44447
44495
|
try {
|
|
44448
44496
|
text5 = readFileSync19(path4, "utf8");
|
|
@@ -44521,7 +44569,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44521
44569
|
if (!inject) return modelId;
|
|
44522
44570
|
const host = localHost(inject.host);
|
|
44523
44571
|
if (!host) return modelId;
|
|
44524
|
-
const path4 =
|
|
44572
|
+
const path4 = join36(grokHome(env), "config.toml");
|
|
44525
44573
|
let text5 = "";
|
|
44526
44574
|
try {
|
|
44527
44575
|
text5 = readFileSync19(path4, "utf8");
|
|
@@ -44677,7 +44725,7 @@ var init_grok2 = __esm({
|
|
|
44677
44725
|
pickAuthMethod: (methods) => methods.some((m3) => m3.id === "cached_token") ? "cached_token" : null,
|
|
44678
44726
|
authFailure: "fail",
|
|
44679
44727
|
classifyError: classifyGrokError,
|
|
44680
|
-
isAuthenticated: (env) => existsSync16(env.GROK_HOME ?
|
|
44728
|
+
isAuthenticated: (env) => existsSync16(env.GROK_HOME ? join36(env.GROK_HOME, "auth.json") : join36(homedir17(), ".grok", "auth.json")),
|
|
44681
44729
|
// `--append-system-prompt`/`--rules` are accepted by the CLI but do NOT
|
|
44682
44730
|
// reach the agent-stdio system prompt (verified against 1.0.0), so the
|
|
44683
44731
|
// persona is prepended codex-style.
|
|
@@ -44692,10 +44740,10 @@ ${turn.text}` : turn.text
|
|
|
44692
44740
|
// server/drivers/acp/gemini.ts
|
|
44693
44741
|
import { existsSync as existsSync17, readFileSync as readFileSync20 } from "node:fs";
|
|
44694
44742
|
import { homedir as homedir18 } from "node:os";
|
|
44695
|
-
import { join as
|
|
44743
|
+
import { join as join37 } from "node:path";
|
|
44696
44744
|
function liveOauthCredential() {
|
|
44697
44745
|
try {
|
|
44698
|
-
const creds = JSON.parse(readFileSync20(
|
|
44746
|
+
const creds = JSON.parse(readFileSync20(join37(homedir18(), ".gemini", "oauth_creds.json"), "utf8"));
|
|
44699
44747
|
if (typeof creds.access_token !== "string" || creds.access_token.trim().length === 0) return false;
|
|
44700
44748
|
const hasRefresh = typeof creds.refresh_token === "string" && creds.refresh_token.trim().length > 0;
|
|
44701
44749
|
if (creds.expiry_date !== void 0) {
|
|
@@ -44708,7 +44756,7 @@ function liveOauthCredential() {
|
|
|
44708
44756
|
}
|
|
44709
44757
|
}
|
|
44710
44758
|
function geminiIsAuthenticated(env) {
|
|
44711
|
-
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(
|
|
44759
|
+
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(join37(homedir18(), ".gemini", "oauth_creds.json")) && liveOauthCredential();
|
|
44712
44760
|
}
|
|
44713
44761
|
function geminiApprovalArgs(fullAuto, approvalMode) {
|
|
44714
44762
|
if (fullAuto) return ["--yolo"];
|
|
@@ -44764,15 +44812,15 @@ ${turn.text}` : turn.text
|
|
|
44764
44812
|
// server/drivers/acp/kimi.ts
|
|
44765
44813
|
import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "node:fs";
|
|
44766
44814
|
import { homedir as homedir19 } from "node:os";
|
|
44767
|
-
import { join as
|
|
44815
|
+
import { join as join38 } from "node:path";
|
|
44768
44816
|
function isLocalInjectAlias(slug) {
|
|
44769
44817
|
return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
|
|
44770
44818
|
}
|
|
44771
44819
|
function kimiDataRoot(env) {
|
|
44772
|
-
return env.KIMI_CODE_HOME ||
|
|
44820
|
+
return env.KIMI_CODE_HOME || join38(env.HOME || env.USERPROFILE || homedir19(), ".kimi-code");
|
|
44773
44821
|
}
|
|
44774
44822
|
function credentialsPath(env) {
|
|
44775
|
-
return
|
|
44823
|
+
return join38(kimiDataRoot(env), "credentials", "kimi-code.json");
|
|
44776
44824
|
}
|
|
44777
44825
|
function quoteToml2(value) {
|
|
44778
44826
|
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -45060,7 +45108,7 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
45060
45108
|
const alias = `${inject.host}/${inject.model.replace(/\//g, "-")}`;
|
|
45061
45109
|
const dataRoot = kimiDataRoot(env);
|
|
45062
45110
|
mkdirSync17(dataRoot, { recursive: true });
|
|
45063
|
-
const path4 =
|
|
45111
|
+
const path4 = join38(dataRoot, "config.toml");
|
|
45064
45112
|
let text5 = "";
|
|
45065
45113
|
try {
|
|
45066
45114
|
text5 = readFileSync21(path4, "utf8");
|
|
@@ -45125,7 +45173,7 @@ function readKimiModelCatalog(env) {
|
|
|
45125
45173
|
const dataRoot = kimiDataRoot(env);
|
|
45126
45174
|
let text5 = "";
|
|
45127
45175
|
try {
|
|
45128
|
-
text5 = readFileSync21(
|
|
45176
|
+
text5 = readFileSync21(join38(dataRoot, "config.toml"), "utf8");
|
|
45129
45177
|
} catch {
|
|
45130
45178
|
return STATIC_KIMI_MODELS;
|
|
45131
45179
|
}
|
|
@@ -45275,10 +45323,10 @@ ${turn.text}` : turn.text
|
|
|
45275
45323
|
// server/drivers/acp/droid.ts
|
|
45276
45324
|
import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
|
|
45277
45325
|
import { homedir as homedir20 } from "node:os";
|
|
45278
|
-
import { join as
|
|
45326
|
+
import { join as join39 } from "node:path";
|
|
45279
45327
|
function authFilePaths(env) {
|
|
45280
45328
|
const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir20();
|
|
45281
|
-
return AUTH_FILES.map((name) =>
|
|
45329
|
+
return AUTH_FILES.map((name) => join39(home, ".factory", name));
|
|
45282
45330
|
}
|
|
45283
45331
|
function droidInjectId(host, model) {
|
|
45284
45332
|
const safe = `${host}-${model}`.replace(/[^a-zA-Z0-9._+-]+/g, "-").replace(/-+/g, "-");
|
|
@@ -45293,9 +45341,9 @@ function ensureDroidInjectModel(modelId, env = process.env) {
|
|
|
45293
45341
|
const host = localHost(inject.host);
|
|
45294
45342
|
if (!host) return modelId;
|
|
45295
45343
|
const id = droidInjectId(inject.host, inject.model);
|
|
45296
|
-
const dir =
|
|
45344
|
+
const dir = join39(factoryHome(env), ".factory");
|
|
45297
45345
|
mkdirSync18(dir, { recursive: true });
|
|
45298
|
-
const path4 =
|
|
45346
|
+
const path4 = join39(dir, "settings.json");
|
|
45299
45347
|
let settings2 = {};
|
|
45300
45348
|
try {
|
|
45301
45349
|
settings2 = JSON.parse(readFileSync22(path4, "utf8"));
|
|
@@ -45335,7 +45383,7 @@ function applyDroidLocalAuthEnv(env, modelId) {
|
|
|
45335
45383
|
env.FACTORY_API_KEY = "openmausbot-local";
|
|
45336
45384
|
}
|
|
45337
45385
|
function readSettings(env) {
|
|
45338
|
-
return JSON.parse(readFileSync22(
|
|
45386
|
+
return JSON.parse(readFileSync22(join39(factoryHome(env), ".factory", "settings.json"), "utf8"));
|
|
45339
45387
|
}
|
|
45340
45388
|
async function resolveModels(env) {
|
|
45341
45389
|
let catalog2 = MODELS3;
|
|
@@ -47225,11 +47273,11 @@ var init_muse_code_login = __esm({
|
|
|
47225
47273
|
import { existsSync as existsSync20, mkdtempSync as mkdtempSync4, readFileSync as readFileSync23, rmSync as rmSync8, statSync as statSync5 } from "node:fs";
|
|
47226
47274
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
47227
47275
|
import { homedir as homedir21, tmpdir as tmpdir5 } from "node:os";
|
|
47228
|
-
import { join as
|
|
47276
|
+
import { join as join40 } from "node:path";
|
|
47229
47277
|
function museCredentialPath(env, platform = process.platform) {
|
|
47230
47278
|
if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
|
|
47231
47279
|
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir21();
|
|
47232
|
-
return
|
|
47280
|
+
return join40(env.XDG_CONFIG_HOME?.trim() || join40(home, ".config"), "muse", "auth.json");
|
|
47233
47281
|
}
|
|
47234
47282
|
function museCredential(path4) {
|
|
47235
47283
|
let raw;
|
|
@@ -47491,7 +47539,7 @@ var init_muse_code = __esm({
|
|
|
47491
47539
|
lastRefresh = Date.now();
|
|
47492
47540
|
});
|
|
47493
47541
|
const listModels = async () => {
|
|
47494
|
-
const cwd = mkdtempSync4(
|
|
47542
|
+
const cwd = mkdtempSync4(join40(tmpdir5(), "atomic-muse-models-"));
|
|
47495
47543
|
let host;
|
|
47496
47544
|
try {
|
|
47497
47545
|
host = await startHost(["serve", "--disable-shell", "--disable-write", "--no-session-log", "--contributor-mode", "off"], cwd, "models", false);
|
|
@@ -47989,7 +48037,7 @@ ${body}` : body;
|
|
|
47989
48037
|
// server/drivers/acp/opencode-go.ts
|
|
47990
48038
|
import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync24, writeFileSync as writeFileSync15 } from "node:fs";
|
|
47991
48039
|
import { homedir as homedir22 } from "node:os";
|
|
47992
|
-
import { join as
|
|
48040
|
+
import { join as join41 } from "node:path";
|
|
47993
48041
|
function labelForModel(id) {
|
|
47994
48042
|
return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
47995
48043
|
}
|
|
@@ -48092,7 +48140,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
|
|
|
48092
48140
|
}
|
|
48093
48141
|
function opencodeConfigDir(env) {
|
|
48094
48142
|
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
48095
|
-
return
|
|
48143
|
+
return join41(env.XDG_CONFIG_HOME || join41(home, ".config"), "opencode");
|
|
48096
48144
|
}
|
|
48097
48145
|
function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
48098
48146
|
const inject = decodeInjectId(modelId);
|
|
@@ -48102,7 +48150,7 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
48102
48150
|
const native = `${inject.host}/${inject.model}`;
|
|
48103
48151
|
const dir = opencodeConfigDir(env);
|
|
48104
48152
|
mkdirSync19(dir, { recursive: true });
|
|
48105
|
-
const path4 =
|
|
48153
|
+
const path4 = join41(dir, "opencode.json");
|
|
48106
48154
|
let config2 = { $schema: "https://opencode.ai/config.json" };
|
|
48107
48155
|
if (existsSync21(path4)) {
|
|
48108
48156
|
try {
|
|
@@ -48140,10 +48188,10 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
48140
48188
|
function storedAuthPaths(env) {
|
|
48141
48189
|
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
48142
48190
|
const roots = [
|
|
48143
|
-
env.XDG_DATA_HOME ||
|
|
48144
|
-
process.platform === "darwin" ?
|
|
48191
|
+
env.XDG_DATA_HOME || join41(home, ".local", "share"),
|
|
48192
|
+
process.platform === "darwin" ? join41(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join41(home, "AppData", "Local") : ""
|
|
48145
48193
|
].filter(Boolean);
|
|
48146
|
-
return [...new Set(roots)].map((root) =>
|
|
48194
|
+
return [...new Set(roots)].map((root) => join41(root, "opencode", "auth.json"));
|
|
48147
48195
|
}
|
|
48148
48196
|
function usableAuthEntry(parsed) {
|
|
48149
48197
|
return Object.values(parsed).some((auth) => {
|
|
@@ -48302,10 +48350,10 @@ ${turn.text}` : turn.text
|
|
|
48302
48350
|
import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
|
|
48303
48351
|
import { createHash as createHash13 } from "node:crypto";
|
|
48304
48352
|
import { homedir as homedir23 } from "node:os";
|
|
48305
|
-
import { join as
|
|
48353
|
+
import { join as join42 } from "node:path";
|
|
48306
48354
|
function qwenHome(env) {
|
|
48307
48355
|
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir23() : env.HOME || env.USERPROFILE || homedir23();
|
|
48308
|
-
return
|
|
48356
|
+
return join42(home, ".qwen");
|
|
48309
48357
|
}
|
|
48310
48358
|
function isRecord5(value) {
|
|
48311
48359
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -48317,7 +48365,7 @@ function qwenModelLabel(id, name) {
|
|
|
48317
48365
|
function readQwenRoutes(env) {
|
|
48318
48366
|
let settings2;
|
|
48319
48367
|
try {
|
|
48320
|
-
settings2 = JSON.parse(readFileSync25(
|
|
48368
|
+
settings2 = JSON.parse(readFileSync25(join42(qwenHome(env), "settings.json"), "utf8"));
|
|
48321
48369
|
} catch {
|
|
48322
48370
|
return [];
|
|
48323
48371
|
}
|
|
@@ -48401,7 +48449,7 @@ function ensureQwenInjectModel(modelId, env = process.env) {
|
|
|
48401
48449
|
if (!host) return modelId;
|
|
48402
48450
|
const dir = qwenHome(env);
|
|
48403
48451
|
mkdirSync20(dir, { recursive: true });
|
|
48404
|
-
const path4 =
|
|
48452
|
+
const path4 = join42(dir, "settings.json");
|
|
48405
48453
|
let settings2 = {};
|
|
48406
48454
|
if (existsSync22(path4)) {
|
|
48407
48455
|
try {
|
|
@@ -48907,12 +48955,12 @@ var init_claude_accounts = __esm({
|
|
|
48907
48955
|
// server/atomic-engine-accounts.ts
|
|
48908
48956
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
|
|
48909
48957
|
import { homedir as homedir24 } from "node:os";
|
|
48910
|
-
import { join as
|
|
48958
|
+
import { join as join43 } from "node:path";
|
|
48911
48959
|
function rawConfig2(entry) {
|
|
48912
48960
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
48913
48961
|
}
|
|
48914
48962
|
function expandHome(path4) {
|
|
48915
|
-
return path4 === "~" ? homedir24() : path4.startsWith("~/") ?
|
|
48963
|
+
return path4 === "~" ? homedir24() : path4.startsWith("~/") ? join43(homedir24(), path4.slice(2)) : path4;
|
|
48916
48964
|
}
|
|
48917
48965
|
function asAccount(id, entry) {
|
|
48918
48966
|
if (entry.enabled === false) return null;
|
|
@@ -48944,7 +48992,7 @@ function asAccount(id, entry) {
|
|
|
48944
48992
|
kind: "codex-cli",
|
|
48945
48993
|
label,
|
|
48946
48994
|
billing: "subscription",
|
|
48947
|
-
home: home ? expandHome(home) :
|
|
48995
|
+
home: home ? expandHome(home) : join43(homedir24(), ".codex"),
|
|
48948
48996
|
model: FAILOVER_MODEL["openai-codex"]
|
|
48949
48997
|
} };
|
|
48950
48998
|
}
|
|
@@ -49006,7 +49054,7 @@ function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
|
49006
49054
|
const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
|
|
49007
49055
|
const text5 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
|
|
49008
49056
|
`;
|
|
49009
|
-
const path4 =
|
|
49057
|
+
const path4 = join43(engineHome, ACCOUNTS_FILE);
|
|
49010
49058
|
try {
|
|
49011
49059
|
if (readFileSync26(path4, "utf8") === text5) return;
|
|
49012
49060
|
} catch {
|
|
@@ -49083,20 +49131,20 @@ var init_atomic_engine_release = __esm({
|
|
|
49083
49131
|
// server/atomic-engine-runtime.ts
|
|
49084
49132
|
import { createHash as createHash14, randomUUID as randomUUID15 } from "node:crypto";
|
|
49085
49133
|
import { createWriteStream as createWriteStream2, existsSync as existsSync23, mkdirSync as mkdirSync22, readdirSync as readdirSync6, readFileSync as readFileSync27, rmSync as rmSync9, writeFileSync as writeFileSync18 } from "node:fs";
|
|
49086
|
-
import { join as
|
|
49134
|
+
import { join as join44 } from "node:path";
|
|
49087
49135
|
import { Readable, Transform as Transform2 } from "node:stream";
|
|
49088
49136
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
49089
49137
|
function atomicEngineHome(baseDir = DATA_DIR) {
|
|
49090
|
-
return
|
|
49138
|
+
return join44(baseDir, "tools", "atomic-engine");
|
|
49091
49139
|
}
|
|
49092
49140
|
function atomicEnginePython(root, platform = process.platform) {
|
|
49093
|
-
return platform === "win32" ?
|
|
49141
|
+
return platform === "win32" ? join44(root, "atomic-engine", "python", "python.exe") : join44(root, "atomic-engine", "python", "bin", "python3");
|
|
49094
49142
|
}
|
|
49095
49143
|
function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), platform = process.platform) {
|
|
49096
49144
|
if (!asset) return null;
|
|
49097
|
-
const root =
|
|
49145
|
+
const root = join44(atomicEngineHome(baseDir), asset.version);
|
|
49098
49146
|
try {
|
|
49099
|
-
if (readFileSync27(
|
|
49147
|
+
if (readFileSync27(join44(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
|
|
49100
49148
|
} catch {
|
|
49101
49149
|
return null;
|
|
49102
49150
|
}
|
|
@@ -49106,7 +49154,7 @@ function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), pl
|
|
|
49106
49154
|
function systemTar(platform = process.platform) {
|
|
49107
49155
|
if (platform !== "win32") return "/usr/bin/tar";
|
|
49108
49156
|
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
49109
|
-
return
|
|
49157
|
+
return join44(systemRoot, "System32", "tar.exe");
|
|
49110
49158
|
}
|
|
49111
49159
|
async function download(asset, file2, options) {
|
|
49112
49160
|
let response;
|
|
@@ -49151,8 +49199,8 @@ async function installOnce3(options) {
|
|
|
49151
49199
|
const home = atomicEngineHome(baseDir);
|
|
49152
49200
|
mkdirSync22(home, { recursive: true });
|
|
49153
49201
|
const id = randomUUID15();
|
|
49154
|
-
const archive =
|
|
49155
|
-
const staging =
|
|
49202
|
+
const archive = join44(home, `.download-${id}.tar.gz`);
|
|
49203
|
+
const staging = join44(home, `.staging-${id}`);
|
|
49156
49204
|
try {
|
|
49157
49205
|
await download(asset, archive, options);
|
|
49158
49206
|
options.onProgress?.({ phase: "installing" });
|
|
@@ -49163,7 +49211,7 @@ async function installOnce3(options) {
|
|
|
49163
49211
|
throw new AtomicEngineInstallError("install", `Could not unpack Atomic Engine: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
49164
49212
|
}
|
|
49165
49213
|
if (!existsSync23(atomicEnginePython(staging))) throw new AtomicEngineInstallError("install", "The Atomic Engine package has no Python runtime for this computer");
|
|
49166
|
-
const root =
|
|
49214
|
+
const root = join44(home, asset.version);
|
|
49167
49215
|
rmSync9(root, { recursive: true, force: true });
|
|
49168
49216
|
await promoteDirectory(staging, root);
|
|
49169
49217
|
const python = atomicEnginePython(root);
|
|
@@ -49174,10 +49222,10 @@ async function installOnce3(options) {
|
|
|
49174
49222
|
await removeDirectoryQuietly(root, "Atomic Engine has no install marker there, so it is not used");
|
|
49175
49223
|
throw new AtomicEngineInstallError("install", `Atomic Engine did not start after installing: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
49176
49224
|
}
|
|
49177
|
-
writeFileSync18(
|
|
49225
|
+
writeFileSync18(join44(root, MARKER2), `${asset.sha512}
|
|
49178
49226
|
`);
|
|
49179
49227
|
for (const name of readdirSync6(home)) {
|
|
49180
|
-
if (name !== asset.version && !name.startsWith(".")) rmSync9(
|
|
49228
|
+
if (name !== asset.version && !name.startsWith(".")) rmSync9(join44(home, name), { recursive: true, force: true });
|
|
49181
49229
|
}
|
|
49182
49230
|
const installed = managedAtomicEngine(baseDir, asset);
|
|
49183
49231
|
if (!installed) throw new AtomicEngineInstallError("install", "Atomic Engine did not install completely");
|
|
@@ -56101,7 +56149,7 @@ var init_memory_policy = __esm({
|
|
|
56101
56149
|
// server/drivers/acp/hermes-memory-lock.ts
|
|
56102
56150
|
import { createHash as createHash15 } from "node:crypto";
|
|
56103
56151
|
import { mkdirSync as mkdirSync23, readdirSync as readdirSync7, readFileSync as readFileSync28, writeFileSync as writeFileSync19 } from "node:fs";
|
|
56104
|
-
import { join as
|
|
56152
|
+
import { join as join45 } from "node:path";
|
|
56105
56153
|
function readText2(path4) {
|
|
56106
56154
|
try {
|
|
56107
56155
|
return readFileSync28(path4, "utf8");
|
|
@@ -56128,24 +56176,24 @@ function memoryProviderPlugins(pluginsDir) {
|
|
|
56128
56176
|
return [];
|
|
56129
56177
|
}
|
|
56130
56178
|
return dirs.flatMap((dir) => {
|
|
56131
|
-
const source2 = (readText2(
|
|
56179
|
+
const source2 = (readText2(join45(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
|
|
56132
56180
|
if (!source2.includes("register_memory_provider") && !source2.includes("MemoryProvider")) return [];
|
|
56133
|
-
const name = record3(parseYamlSafe(readText2(
|
|
56181
|
+
const name = record3(parseYamlSafe(readText2(join45(pluginsDir, dir, "plugin.yaml"))))?.name;
|
|
56134
56182
|
return typeof name === "string" && name.trim() && name.trim() !== dir ? [dir, name.trim()] : [dir];
|
|
56135
56183
|
});
|
|
56136
56184
|
}
|
|
56137
56185
|
function lockHermesMemory(env, home, dataDir = DATA_DIR) {
|
|
56138
|
-
const own = record3(record3(parseYamlSafe(readText2(
|
|
56186
|
+
const own = record3(record3(parseYamlSafe(readText2(join45(home, "config.yaml"))))?.plugins);
|
|
56139
56187
|
const disabled = new Set(Array.isArray(own?.disabled) ? own.disabled.map(String) : []);
|
|
56140
|
-
for (const name of memoryProviderPlugins(
|
|
56188
|
+
for (const name of memoryProviderPlugins(join45(home, "plugins"))) disabled.add(name);
|
|
56141
56189
|
for (const name of BLOCKED_HERMES_MEMORY_PLUGINS) disabled.add(name);
|
|
56142
56190
|
const overlay = stringify3({
|
|
56143
56191
|
memory: { provider: "", memory_enabled: false, user_profile_enabled: false },
|
|
56144
56192
|
plugins: { disabled: [...disabled].sort() }
|
|
56145
56193
|
});
|
|
56146
|
-
const dir =
|
|
56194
|
+
const dir = join45(dataDir, "hermes-managed", createHash15("sha256").update(home).digest("hex").slice(0, 16));
|
|
56147
56195
|
mkdirSync23(dir, { recursive: true });
|
|
56148
|
-
const file2 =
|
|
56196
|
+
const file2 = join45(dir, "config.yaml");
|
|
56149
56197
|
if (readText2(file2) !== overlay) writeFileSync19(file2, overlay);
|
|
56150
56198
|
env.HERMES_MANAGED_DIR = dir;
|
|
56151
56199
|
return dir;
|
|
@@ -56163,7 +56211,7 @@ var init_hermes_memory_lock = __esm({
|
|
|
56163
56211
|
import { spawn as spawn7 } from "node:child_process";
|
|
56164
56212
|
import { mkdirSync as mkdirSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
56165
56213
|
import { homedir as homedir25 } from "node:os";
|
|
56166
|
-
import { join as
|
|
56214
|
+
import { join as join46 } from "node:path";
|
|
56167
56215
|
function bindHermesScreenshotCompat(env, modelId) {
|
|
56168
56216
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
|
|
56169
56217
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL];
|
|
@@ -56173,7 +56221,7 @@ function bindHermesScreenshotCompat(env, modelId) {
|
|
|
56173
56221
|
env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
|
|
56174
56222
|
}
|
|
56175
56223
|
function hermesHome(env) {
|
|
56176
|
-
return env.HERMES_HOME ||
|
|
56224
|
+
return env.HERMES_HOME || join46(env.HOME || env.USERPROFILE || homedir25(), ".hermes");
|
|
56177
56225
|
}
|
|
56178
56226
|
function quoteYaml(value) {
|
|
56179
56227
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
@@ -56215,7 +56263,7 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
|
|
|
56215
56263
|
if (!host) return modelId;
|
|
56216
56264
|
const dir = home;
|
|
56217
56265
|
mkdirSync24(dir, { recursive: true });
|
|
56218
|
-
const path4 =
|
|
56266
|
+
const path4 = join46(dir, "config.yaml");
|
|
56219
56267
|
let text5 = "";
|
|
56220
56268
|
try {
|
|
56221
56269
|
text5 = readFileSync29(path4, "utf8");
|
|
@@ -56286,13 +56334,13 @@ function hermesConfiguredModel(env = process.env) {
|
|
|
56286
56334
|
const dir = hermesHome(env);
|
|
56287
56335
|
let secrets = "";
|
|
56288
56336
|
try {
|
|
56289
|
-
secrets = readFileSync29(
|
|
56337
|
+
secrets = readFileSync29(join46(dir, ".env"), "utf8");
|
|
56290
56338
|
} catch {
|
|
56291
56339
|
}
|
|
56292
56340
|
const hasHostedProviderKey = HERMES_HOSTED_PROVIDER_KEYS.some((name) => nonEmptyDotenvValue(secrets, name));
|
|
56293
56341
|
let configuredDefault = null;
|
|
56294
56342
|
try {
|
|
56295
|
-
configuredDefault = hermesConfigDefault(readFileSync29(
|
|
56343
|
+
configuredDefault = hermesConfigDefault(readFileSync29(join46(dir, "config.yaml"), "utf8"));
|
|
56296
56344
|
} catch {
|
|
56297
56345
|
}
|
|
56298
56346
|
const configuredProvider = configuredDefault?.provider.toLowerCase() ?? "";
|
|
@@ -56337,7 +56385,7 @@ function oauthRowSignedIn(row, now) {
|
|
|
56337
56385
|
return present(row.access_token) && notExpired(row, now);
|
|
56338
56386
|
}
|
|
56339
56387
|
function hermesSignedInProviders(env = process.env, now = Date.now()) {
|
|
56340
|
-
const store = record4(readJson(
|
|
56388
|
+
const store = record4(readJson(join46(hermesHome(env), "auth.json")));
|
|
56341
56389
|
const out = /* @__PURE__ */ new Set();
|
|
56342
56390
|
if (!store) return out;
|
|
56343
56391
|
const providers = record4(store.providers) ?? {};
|
|
@@ -56361,7 +56409,7 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
56361
56409
|
const dir = hermesHome(env);
|
|
56362
56410
|
let secrets = "";
|
|
56363
56411
|
try {
|
|
56364
|
-
secrets = readFileSync29(
|
|
56412
|
+
secrets = readFileSync29(join46(dir, ".env"), "utf8");
|
|
56365
56413
|
} catch {
|
|
56366
56414
|
}
|
|
56367
56415
|
const keyed = ["GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"].some((name) => present(env[name]) || nonEmptyDotenvValue(secrets, name));
|
|
@@ -56369,21 +56417,21 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
56369
56417
|
const coding = (url2) => typeof url2 === "string" && /\/api\/coding\/paas\//i.test(url2);
|
|
56370
56418
|
const override = present(env.GLM_BASE_URL) ? env.GLM_BASE_URL : nonEmptyDotenvValue(secrets, "GLM_BASE_URL");
|
|
56371
56419
|
if (override) return coding(override);
|
|
56372
|
-
const detected = record4(record4(record4(record4(readJson(
|
|
56420
|
+
const detected = record4(record4(record4(record4(readJson(join46(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
|
|
56373
56421
|
return coding(detected?.base_url);
|
|
56374
56422
|
}
|
|
56375
56423
|
function hermesZaiPlanHosts(options, codingPlan) {
|
|
56376
56424
|
return codingPlan ? options.map((option) => option.provider === "zai" ? { ...option, provider: "zai-coding-plan" } : option) : [...options];
|
|
56377
56425
|
}
|
|
56378
56426
|
function hermesCachedModels(home, provider) {
|
|
56379
|
-
const catalog2 = record4(record4(record4(readJson(
|
|
56427
|
+
const catalog2 = record4(record4(record4(readJson(join46(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
|
|
56380
56428
|
const name = String(record4(catalog2?.metadata)?.display_name ?? "").trim() || provider;
|
|
56381
56429
|
const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record4).filter((row) => row && present(row.id)) : [];
|
|
56382
56430
|
if (rows.length) {
|
|
56383
56431
|
const ordered = [...rows.filter((row) => row.default === true), ...rows.filter((row) => row.default !== true)];
|
|
56384
56432
|
return { ids: ordered.map((row) => String(row.id).trim()), name };
|
|
56385
56433
|
}
|
|
56386
|
-
const cached3 = record4(record4(readJson(
|
|
56434
|
+
const cached3 = record4(record4(readJson(join46(home, "provider_models_cache.json")))?.[provider])?.models;
|
|
56387
56435
|
return { ids: Array.isArray(cached3) ? cached3.filter(present).map((id) => String(id).trim()) : [], name };
|
|
56388
56436
|
}
|
|
56389
56437
|
function hermesAuthStoreModels(env = process.env, now = Date.now()) {
|
|
@@ -56401,7 +56449,7 @@ function hermesConfiguredHostModel(env = process.env) {
|
|
|
56401
56449
|
const home = hermesHome(env);
|
|
56402
56450
|
let configured = null;
|
|
56403
56451
|
try {
|
|
56404
|
-
configured = hermesConfigDefault(readFileSync29(
|
|
56452
|
+
configured = hermesConfigDefault(readFileSync29(join46(home, "config.yaml"), "utf8"));
|
|
56405
56453
|
} catch {
|
|
56406
56454
|
return null;
|
|
56407
56455
|
}
|
|
@@ -56619,7 +56667,7 @@ ${turn.text}` : turn.text
|
|
|
56619
56667
|
|
|
56620
56668
|
// server/drivers/acp/custom.ts
|
|
56621
56669
|
import { homedir as homedir26 } from "node:os";
|
|
56622
|
-
import { basename as basename9, join as
|
|
56670
|
+
import { basename as basename9, join as join47 } from "node:path";
|
|
56623
56671
|
function isAtomicEngine(instanceId, cli) {
|
|
56624
56672
|
const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
|
|
56625
56673
|
return instanceId === "atomic-engine" || basename9(program) === "atomic";
|
|
@@ -56644,7 +56692,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
|
|
|
56644
56692
|
return { state: "available", version: version2, authenticated: true };
|
|
56645
56693
|
}
|
|
56646
56694
|
function atomicEngineHome2(env) {
|
|
56647
|
-
return env.HERMES_HOME ||
|
|
56695
|
+
return env.HERMES_HOME || join47(env.HOME || env.USERPROFILE || homedir26(), ".atomic");
|
|
56648
56696
|
}
|
|
56649
56697
|
function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
|
|
56650
56698
|
if (!isAtomicEngine(instanceId, cli)) return;
|
|
@@ -57047,7 +57095,7 @@ var init_openai_compat = __esm({
|
|
|
57047
57095
|
// server/drivers/pi.ts
|
|
57048
57096
|
import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync5, readFileSync as readFileSync30, rmSync as rmSync10, writeFileSync as writeFileSync21 } from "node:fs";
|
|
57049
57097
|
import { homedir as homedir27, tmpdir as tmpdir6 } from "node:os";
|
|
57050
|
-
import { join as
|
|
57098
|
+
import { join as join48 } from "node:path";
|
|
57051
57099
|
function readPiPromptImages(turn) {
|
|
57052
57100
|
return (turn.images ?? []).map((image) => ({
|
|
57053
57101
|
type: "image",
|
|
@@ -57169,7 +57217,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
|
|
|
57169
57217
|
return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
|
|
57170
57218
|
}
|
|
57171
57219
|
function piAgentDir(env) {
|
|
57172
|
-
return
|
|
57220
|
+
return join48(env.HOME || env.USERPROFILE || homedir27(), ".pi", "agent");
|
|
57173
57221
|
}
|
|
57174
57222
|
function ensurePiInjectModel(modelId, env = process.env) {
|
|
57175
57223
|
const split = splitPiModel(modelId);
|
|
@@ -57180,7 +57228,7 @@ function ensurePiInjectModel(modelId, env = process.env) {
|
|
|
57180
57228
|
if (!host) return split;
|
|
57181
57229
|
const dir = piAgentDir(env);
|
|
57182
57230
|
mkdirSync25(dir, { recursive: true });
|
|
57183
|
-
const path4 =
|
|
57231
|
+
const path4 = join48(dir, "models.json");
|
|
57184
57232
|
let root = { providers: {} };
|
|
57185
57233
|
if (existsSync24(path4)) {
|
|
57186
57234
|
try {
|
|
@@ -57400,9 +57448,9 @@ var init_pi = __esm({
|
|
|
57400
57448
|
const mcpServers = buildMcpServers(turn);
|
|
57401
57449
|
let mcpTempDir = null;
|
|
57402
57450
|
if (mcpServers) {
|
|
57403
|
-
mcpTempDir = mkdtempSync5(
|
|
57451
|
+
mcpTempDir = mkdtempSync5(join48(tmpdir6(), "omb-pi-mcp-"));
|
|
57404
57452
|
try {
|
|
57405
|
-
writeFileSync21(
|
|
57453
|
+
writeFileSync21(join48(mcpTempDir, "mcp.json"), JSON.stringify({ mcpServers }), { mode: 384 });
|
|
57406
57454
|
} catch (err) {
|
|
57407
57455
|
try {
|
|
57408
57456
|
rmSync10(mcpTempDir, { recursive: true, force: true });
|
|
@@ -57421,7 +57469,7 @@ var init_pi = __esm({
|
|
|
57421
57469
|
env: piEnvironment({
|
|
57422
57470
|
...process.env,
|
|
57423
57471
|
...input.environment,
|
|
57424
|
-
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG:
|
|
57472
|
+
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG: join48(mcpTempDir, "mcp.json") } : {}
|
|
57425
57473
|
})
|
|
57426
57474
|
});
|
|
57427
57475
|
} catch (err) {
|
|
@@ -57568,7 +57616,7 @@ var init_pi = __esm({
|
|
|
57568
57616
|
const mcpTool = isQuestion ? null : piMcpToolRef(
|
|
57569
57617
|
evt.title,
|
|
57570
57618
|
customServerNames,
|
|
57571
|
-
mcpTempDir ?
|
|
57619
|
+
mcpTempDir ? join48(mcpTempDir, PI_TOOL_HINTS_FILE) : null
|
|
57572
57620
|
);
|
|
57573
57621
|
emit({
|
|
57574
57622
|
...base2(threadId, turnId),
|
|
@@ -57903,14 +57951,14 @@ var init_mistral = __esm({
|
|
|
57903
57951
|
// server/drivers/minimax.ts
|
|
57904
57952
|
import { readFileSync as readFileSync31 } from "node:fs";
|
|
57905
57953
|
import { homedir as homedir28 } from "node:os";
|
|
57906
|
-
import { join as
|
|
57954
|
+
import { join as join49 } from "node:path";
|
|
57907
57955
|
function normalizedApiUrl(value) {
|
|
57908
57956
|
const root = value.trim().replace(/\/+$/, "");
|
|
57909
57957
|
return root.endsWith("/v1") ? root : `${root}/v1`;
|
|
57910
57958
|
}
|
|
57911
57959
|
function loadLocalMiniMaxConfig(home = homedir28()) {
|
|
57912
57960
|
try {
|
|
57913
|
-
const raw = localConfigSchema.parse(JSON.parse(readFileSync31(
|
|
57961
|
+
const raw = localConfigSchema.parse(JSON.parse(readFileSync31(join49(home, ".mmx", "config.json"), "utf8")));
|
|
57914
57962
|
const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
|
|
57915
57963
|
return {
|
|
57916
57964
|
apiKey: raw.api_key?.trim() ?? "",
|
|
@@ -58017,7 +58065,7 @@ var init_minimax = __esm({
|
|
|
58017
58065
|
// server/apple-intelligence.ts
|
|
58018
58066
|
import { spawn as spawn8 } from "node:child_process";
|
|
58019
58067
|
import { accessSync, constants as constants2 } from "node:fs";
|
|
58020
|
-
import { join as
|
|
58068
|
+
import { join as join50 } from "node:path";
|
|
58021
58069
|
function intelligenceErrorMessage(code) {
|
|
58022
58070
|
return MESSAGES[code] ?? `Apple Intelligence failed (${code}).`;
|
|
58023
58071
|
}
|
|
@@ -58025,9 +58073,9 @@ function resolveIntelligenceHelper(env = process.env, platform = process.platfor
|
|
|
58025
58073
|
if (platform !== "darwin" || arch !== "arm64") return null;
|
|
58026
58074
|
const candidates = [
|
|
58027
58075
|
env.ATOMIC_INTELLIGENCE_HELPER,
|
|
58028
|
-
env.OMB_RESOURCES_PATH &&
|
|
58029
|
-
|
|
58030
|
-
|
|
58076
|
+
env.OMB_RESOURCES_PATH && join50(env.OMB_RESOURCES_PATH, HELPER),
|
|
58077
|
+
join50(serverRoot, "..", HELPER),
|
|
58078
|
+
join50(serverRoot, "..", "dist-native", "arm64", HELPER)
|
|
58031
58079
|
];
|
|
58032
58080
|
for (const candidate of candidates) {
|
|
58033
58081
|
if (!candidate) continue;
|
|
@@ -58215,7 +58263,7 @@ var init_apple_intelligence = __esm({
|
|
|
58215
58263
|
"concurrent-requests": "Apple Intelligence is busy. Try again in a moment.",
|
|
58216
58264
|
"timeout": "Apple Intelligence took too long to answer."
|
|
58217
58265
|
};
|
|
58218
|
-
HELPER =
|
|
58266
|
+
HELPER = join50("Atomic Intelligence.app", "Contents", "MacOS", "intelligence-helper");
|
|
58219
58267
|
}
|
|
58220
58268
|
});
|
|
58221
58269
|
|
|
@@ -58574,7 +58622,7 @@ __export(cli_setup_exports, {
|
|
|
58574
58622
|
});
|
|
58575
58623
|
import { spawn as spawn9 } from "node:child_process";
|
|
58576
58624
|
import { readFileSync as readFileSync32 } from "node:fs";
|
|
58577
|
-
import { join as
|
|
58625
|
+
import { join as join51, resolve as resolve11 } from "node:path";
|
|
58578
58626
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
58579
58627
|
async function inspect(id, entry) {
|
|
58580
58628
|
const registry2 = new ProviderRegistry(BUILT_IN_DRIVERS);
|
|
@@ -58611,7 +58659,7 @@ function assertDataDir(dataDir) {
|
|
|
58611
58659
|
}
|
|
58612
58660
|
function checkStoredConfig(dataDir) {
|
|
58613
58661
|
try {
|
|
58614
|
-
parseStoredConfig(JSON.parse(readFileSync32(
|
|
58662
|
+
parseStoredConfig(JSON.parse(readFileSync32(join51(dataDir, "config.json"), "utf8")));
|
|
58615
58663
|
} catch (error51) {
|
|
58616
58664
|
if (error51.code === "ENOENT") return;
|
|
58617
58665
|
throw new Error("Existing config.json could not be read or validated. Setup has not changed it; repair it before continuing.");
|
|
@@ -58891,7 +58939,7 @@ var init_browser_engine_release = __esm({
|
|
|
58891
58939
|
});
|
|
58892
58940
|
|
|
58893
58941
|
// server/browser-bundle-release.ts
|
|
58894
|
-
import { join as
|
|
58942
|
+
import { join as join52 } from "node:path";
|
|
58895
58943
|
function browserBundleSpec(target) {
|
|
58896
58944
|
if (!Object.hasOwn(CHROME_ASSETS, target)) throw new Error(`Unsupported desktop browser target: ${target}`);
|
|
58897
58945
|
const pinned = CHROME_ASSETS[target];
|
|
@@ -58927,10 +58975,10 @@ function browserBundlePaths(bundleDirectory, target) {
|
|
|
58927
58975
|
const spec = browserBundleSpec(target);
|
|
58928
58976
|
return {
|
|
58929
58977
|
directory: bundleDirectory,
|
|
58930
|
-
manifest:
|
|
58931
|
-
engine:
|
|
58932
|
-
chrome:
|
|
58933
|
-
licenses:
|
|
58978
|
+
manifest: join52(bundleDirectory, "manifest.json"),
|
|
58979
|
+
engine: join52(bundleDirectory, spec.engine.executable),
|
|
58980
|
+
chrome: join52(bundleDirectory, spec.chrome.executable),
|
|
58981
|
+
licenses: join52(bundleDirectory, "licenses")
|
|
58934
58982
|
};
|
|
58935
58983
|
}
|
|
58936
58984
|
var CHROME_VERSION, CHROME_ASSETS;
|
|
@@ -58972,7 +59020,7 @@ var init_browser_runtime = __esm({
|
|
|
58972
59020
|
});
|
|
58973
59021
|
|
|
58974
59022
|
// server/bot-folder.ts
|
|
58975
|
-
import { join as
|
|
59023
|
+
import { join as join53 } from "node:path";
|
|
58976
59024
|
var BOTS_DIR;
|
|
58977
59025
|
var init_bot_folder = __esm({
|
|
58978
59026
|
"server/bot-folder.ts"() {
|
|
@@ -58980,7 +59028,7 @@ var init_bot_folder = __esm({
|
|
|
58980
59028
|
init_atomic();
|
|
58981
59029
|
init_config();
|
|
58982
59030
|
init_bot_profile();
|
|
58983
|
-
BOTS_DIR =
|
|
59031
|
+
BOTS_DIR = join53(DATA_DIR, "bots");
|
|
58984
59032
|
}
|
|
58985
59033
|
});
|
|
58986
59034
|
|
|
@@ -59023,7 +59071,7 @@ __export(browser_engine_exports, {
|
|
|
59023
59071
|
import { createHash as createHash16, randomBytes as randomBytes3, randomUUID as randomUUID17 } from "node:crypto";
|
|
59024
59072
|
import { chmodSync as chmodSync7, constants as constants3, copyFileSync, existsSync as existsSync25, mkdirSync as mkdirSync26, readFileSync as readFileSync33, readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync11, statSync as statSync6, unlinkSync as unlinkSync7, writeFileSync as writeFileSync22 } from "node:fs";
|
|
59025
59073
|
import { homedir as homedir29, tmpdir as tmpdir7 } from "node:os";
|
|
59026
|
-
import { delimiter as delimiter7, dirname as dirname12, join as
|
|
59074
|
+
import { delimiter as delimiter7, dirname as dirname12, join as join54, resolve as resolve12 } from "node:path";
|
|
59027
59075
|
function browserRestoreKey(session) {
|
|
59028
59076
|
if (!/^[A-Za-z0-9_.-]{1,96}$/.test(session)) throw new Error("Invalid browser session.");
|
|
59029
59077
|
return `omb-${createHash16("sha256").update(session).digest("hex")}`;
|
|
@@ -59032,11 +59080,11 @@ function browserSessionsDirectory(env) {
|
|
|
59032
59080
|
const namespace = env.AGENT_BROWSER_NAMESPACE;
|
|
59033
59081
|
if (namespace && !/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(namespace)) throw new Error("Invalid browser namespace.");
|
|
59034
59082
|
const home = (process.platform === "win32" ? env.USERPROFILE : env.HOME) || homedir29();
|
|
59035
|
-
const stateRoot = namespace ?
|
|
59036
|
-
return
|
|
59083
|
+
const stateRoot = namespace ? join54(home, ".agent-browser", "namespaces", namespace, "state") : join54(home, ".agent-browser");
|
|
59084
|
+
return join54(stateRoot, "sessions");
|
|
59037
59085
|
}
|
|
59038
59086
|
function managedBrowserConfigPath(env) {
|
|
59039
|
-
return
|
|
59087
|
+
return join54(browserSessionsDirectory(env), "..", "omb-managed-config.json");
|
|
59040
59088
|
}
|
|
59041
59089
|
function ensureManagedBrowserConfig(env) {
|
|
59042
59090
|
const path4 = managedBrowserConfigPath(env);
|
|
@@ -59133,11 +59181,11 @@ async function prepareBrowserSessionState(binaryPath, session, options = {}) {
|
|
|
59133
59181
|
ensureManagedBrowserConfig(env);
|
|
59134
59182
|
if (options.persistent === false) return;
|
|
59135
59183
|
const directory = browserSessionsDirectory(env);
|
|
59136
|
-
const key =
|
|
59184
|
+
const key = join54(directory, session);
|
|
59137
59185
|
let pending = preparedBrowserSessions.get(key);
|
|
59138
59186
|
if (!pending) {
|
|
59139
59187
|
pending = (async () => {
|
|
59140
|
-
const targetBase =
|
|
59188
|
+
const targetBase = join54(directory, `${restoreKey}-${session}`);
|
|
59141
59189
|
const hasTarget = () => existsSync25(`${targetBase}.json.enc`) || existsSync25(`${targetBase}.json`);
|
|
59142
59190
|
if (hasTarget()) return;
|
|
59143
59191
|
check2();
|
|
@@ -59147,7 +59195,7 @@ async function prepareBrowserSessionState(binaryPath, session, options = {}) {
|
|
|
59147
59195
|
check2();
|
|
59148
59196
|
if (hasTarget()) return;
|
|
59149
59197
|
const candidates = [".json.enc", ".json"].flatMap((suffix) => {
|
|
59150
|
-
const path4 =
|
|
59198
|
+
const path4 = join54(directory, `${session}-${session}${suffix}`);
|
|
59151
59199
|
try {
|
|
59152
59200
|
const stat5 = statSync6(path4);
|
|
59153
59201
|
if (!stat5.isFile()) throw new Error("Saved browser state is not a file.");
|
|
@@ -59182,7 +59230,7 @@ function isMusl(platform = process.platform, exists = existsSync25) {
|
|
|
59182
59230
|
}
|
|
59183
59231
|
function pinnedBinaryPath(dataDir = DATA_DIR, platform = process.platform, arch = process.arch) {
|
|
59184
59232
|
const version2 = agentBrowserReleaseVersion(resolveAgentBrowserReleaseAsset(platform, arch));
|
|
59185
|
-
return
|
|
59233
|
+
return join54(dataDir, ENGINE_DIR, version2, executableName(platform));
|
|
59186
59234
|
}
|
|
59187
59235
|
function onPath(env, platform, exists) {
|
|
59188
59236
|
const pathValue = platform === "win32" ? Object.entries(env).findLast(([key]) => key.toUpperCase() === "PATH")?.[1] : env.PATH;
|
|
@@ -59198,7 +59246,7 @@ function packagedBrowser(options) {
|
|
|
59198
59246
|
const resources = (options.env ?? process.env).OMB_RESOURCES_PATH;
|
|
59199
59247
|
if (!resources) return null;
|
|
59200
59248
|
try {
|
|
59201
|
-
return browserBundlePaths(
|
|
59249
|
+
return browserBundlePaths(join54(resolve12(resources), "browser-engine"), `${options.platform ?? process.platform}-${options.arch ?? process.arch}`);
|
|
59202
59250
|
} catch {
|
|
59203
59251
|
return null;
|
|
59204
59252
|
}
|
|
@@ -59236,7 +59284,7 @@ async function installAgentBrowserBinary(options = {}) {
|
|
|
59236
59284
|
const asset = options.asset ?? resolveAgentBrowserReleaseAsset(platform, options.arch ?? process.arch, options.musl ?? isMusl(platform));
|
|
59237
59285
|
if (!asset) throw new Error(`agent-browser publishes no build for ${platform}-${options.arch ?? process.arch}.`);
|
|
59238
59286
|
const destination = pinnedBinaryPath(options.dataDir, platform, options.arch);
|
|
59239
|
-
const directory =
|
|
59287
|
+
const directory = join54(destination, "..");
|
|
59240
59288
|
mkdirSync26(directory, { recursive: true, mode: 448 });
|
|
59241
59289
|
const url2 = agentBrowserReleaseUrl(asset);
|
|
59242
59290
|
options.log?.(`downloading agent-browser ${agentBrowserReleaseVersion(asset)} (${Math.round(asset.bytes / 1024 / 1024)} MB, digest pinned)`);
|
|
@@ -59279,7 +59327,7 @@ async function installAgentBrowserBinary(options = {}) {
|
|
|
59279
59327
|
for (const name of readdirSync8(directory)) {
|
|
59280
59328
|
if (!name.endsWith(".part")) continue;
|
|
59281
59329
|
try {
|
|
59282
|
-
unlinkSync7(
|
|
59330
|
+
unlinkSync7(join54(directory, name));
|
|
59283
59331
|
} catch {
|
|
59284
59332
|
}
|
|
59285
59333
|
}
|
|
@@ -59338,7 +59386,7 @@ function ensureChrome(binaryPath, options = {}) {
|
|
|
59338
59386
|
});
|
|
59339
59387
|
}
|
|
59340
59388
|
function browserEngineEncryptionKey(dataDir = DATA_DIR) {
|
|
59341
|
-
const file2 =
|
|
59389
|
+
const file2 = join54(dataDir, KEY_FILE);
|
|
59342
59390
|
try {
|
|
59343
59391
|
const existing = readFileSync33(file2, "utf8").trim();
|
|
59344
59392
|
if (/^[0-9a-f]{64}$/u.test(existing)) return existing;
|
|
@@ -59399,7 +59447,7 @@ function agentBrowserIntegration(input) {
|
|
|
59399
59447
|
return { command: input.binaryPath, args: ["mcp", "--tools", "core", "--no-webmcp"], env };
|
|
59400
59448
|
}
|
|
59401
59449
|
function agentBrowserFrame(input) {
|
|
59402
|
-
const file2 =
|
|
59450
|
+
const file2 = join54(tmpdir7(), `openmausbot-browser-${randomUUID17()}.png`);
|
|
59403
59451
|
return new Promise((settle, fail) => {
|
|
59404
59452
|
const child = spawnCommand(input.binaryPath, ["screenshot", file2], {
|
|
59405
59453
|
env: browserRuntimeEnv(input.env),
|
|
@@ -59469,8 +59517,8 @@ async function clearBrowserSessionState(binaryPath, session, options = {}) {
|
|
|
59469
59517
|
}
|
|
59470
59518
|
};
|
|
59471
59519
|
try {
|
|
59472
|
-
for (const base2 of bases) for (const suffix of [".json", ".json.enc", ".json.previous", ".json.enc.previous"]) remove(
|
|
59473
|
-
const pendingDirectory =
|
|
59520
|
+
for (const base2 of bases) for (const suffix of [".json", ".json.enc", ".json.previous", ".json.enc.previous"]) remove(join54(directory, base2 + suffix));
|
|
59521
|
+
const pendingDirectory = join54(directory, ".tmp");
|
|
59474
59522
|
let pendingFiles = [];
|
|
59475
59523
|
try {
|
|
59476
59524
|
pendingFiles = readdirSync8(pendingDirectory);
|
|
@@ -59478,8 +59526,8 @@ async function clearBrowserSessionState(binaryPath, session, options = {}) {
|
|
|
59478
59526
|
if (error51.code !== "ENOENT") throw error51;
|
|
59479
59527
|
}
|
|
59480
59528
|
const candidates = bases.map((base2) => new RegExp(`^${base2}-candidate-[0-9]+\\.json(?:\\.enc)?$`));
|
|
59481
|
-
for (const name of pendingFiles) if (candidates.some((candidate) => candidate.test(name))) remove(
|
|
59482
|
-
preparedBrowserSessions.delete(
|
|
59529
|
+
for (const name of pendingFiles) if (candidates.some((candidate) => candidate.test(name))) remove(join54(pendingDirectory, name));
|
|
59530
|
+
preparedBrowserSessions.delete(join54(directory, session));
|
|
59483
59531
|
return true;
|
|
59484
59532
|
} catch {
|
|
59485
59533
|
return false;
|
|
@@ -59588,7 +59636,7 @@ import { spawn as spawn10 } from "node:child_process";
|
|
|
59588
59636
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
59589
59637
|
import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync34 } from "node:fs";
|
|
59590
59638
|
import { homedir as homedir30 } from "node:os";
|
|
59591
|
-
import { dirname as dirname13, join as
|
|
59639
|
+
import { dirname as dirname13, join as join55, resolve as resolve13 } from "node:path";
|
|
59592
59640
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
59593
59641
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
59594
59642
|
|
|
@@ -63308,7 +63356,7 @@ function parseArgs2(argv, env = process.env) {
|
|
|
63308
63356
|
const options = {
|
|
63309
63357
|
command: command === "--help" || command === "-h" ? "help" : command,
|
|
63310
63358
|
port: Number(env.OMB_PORT || 8799),
|
|
63311
|
-
dataDir: env.OMB_DATA_DIR ||
|
|
63359
|
+
dataDir: env.OMB_DATA_DIR || join55(homedir30(), ".atomic-app"),
|
|
63312
63360
|
tailscale: false,
|
|
63313
63361
|
tunnel: false,
|
|
63314
63362
|
client: false,
|
|
@@ -63447,7 +63495,7 @@ async function isWorkspaceRunning(options) {
|
|
|
63447
63495
|
try {
|
|
63448
63496
|
const { status, body } = await api(options.port, "/api/health");
|
|
63449
63497
|
if (status !== 200 || body?.app !== "openmausbot") return false;
|
|
63450
|
-
const expected = readFileSync34(
|
|
63498
|
+
const expected = readFileSync34(join55(options.dataDir, "environment-id"), "utf8").trim();
|
|
63451
63499
|
const descriptor = await api(options.port, "/.well-known/openmausbot/environment");
|
|
63452
63500
|
return /^[0-9a-f-]{36}$/i.test(expected) && descriptor.status === 200 && descriptor.body?.environmentId === expected;
|
|
63453
63501
|
} catch {
|
|
@@ -63686,7 +63734,7 @@ async function runStatus(options, io2 = defaultIo()) {
|
|
|
63686
63734
|
return code;
|
|
63687
63735
|
}
|
|
63688
63736
|
async function runAccess(options, io2 = defaultIo()) {
|
|
63689
|
-
const file2 =
|
|
63737
|
+
const file2 = join55(options.dataDir, "config.json");
|
|
63690
63738
|
let raw = {};
|
|
63691
63739
|
if (existsSync26(file2)) {
|
|
63692
63740
|
try {
|
|
@@ -63852,16 +63900,16 @@ async function runBrowser(options, io2 = defaultIo()) {
|
|
|
63852
63900
|
return 0;
|
|
63853
63901
|
}
|
|
63854
63902
|
function serverEntry(here = HERE2) {
|
|
63855
|
-
const bundled =
|
|
63903
|
+
const bundled = join55(here, "index.js");
|
|
63856
63904
|
const root = resolve13(here, "..");
|
|
63857
63905
|
if (existsSync26(bundled)) {
|
|
63858
|
-
const staticDir2 = [
|
|
63859
|
-
const skillsDir = existsSync26(
|
|
63906
|
+
const staticDir2 = [join55(root, "dist"), join55(here, "..", "ui")].find((d) => existsSync26(join55(d, "index.html"))) ?? null;
|
|
63907
|
+
const skillsDir = existsSync26(join55(root, "skills")) ? join55(root, "skills") : null;
|
|
63860
63908
|
return { command: process.execPath, args: [bundled], staticDir: staticDir2, skillsDir };
|
|
63861
63909
|
}
|
|
63862
|
-
const source2 =
|
|
63863
|
-
const staticDir = existsSync26(
|
|
63864
|
-
return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir: existsSync26(
|
|
63910
|
+
const source2 = join55(here, "index.ts");
|
|
63911
|
+
const staticDir = existsSync26(join55(root, "dist", "index.html")) ? join55(root, "dist") : null;
|
|
63912
|
+
return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir: existsSync26(join55(root, "skills")) ? join55(root, "skills") : null };
|
|
63865
63913
|
}
|
|
63866
63914
|
async function planTunnel(options, log) {
|
|
63867
63915
|
let access2 = null;
|
|
@@ -63904,7 +63952,7 @@ async function runServe(options, log = console.log) {
|
|
|
63904
63952
|
console.error(`something already answers on http://127.0.0.1:${options.port}; use \`chibi pair\` against it, or --port for a second server`);
|
|
63905
63953
|
return 1;
|
|
63906
63954
|
}
|
|
63907
|
-
if (await reportBusyPort(options.port, options.dataDir ===
|
|
63955
|
+
if (await reportBusyPort(options.port, options.dataDir === join55(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
|
|
63908
63956
|
let publicUrl = options.publicUrl;
|
|
63909
63957
|
let tailscale = null;
|
|
63910
63958
|
if (options.tailscale) {
|
|
@@ -63966,9 +64014,9 @@ async function runServe(options, log = console.log) {
|
|
|
63966
64014
|
let child;
|
|
63967
64015
|
try {
|
|
63968
64016
|
if (options.guided) {
|
|
63969
|
-
const logsDir =
|
|
64017
|
+
const logsDir = join55(options.dataDir, "logs");
|
|
63970
64018
|
mkdirSync27(logsDir, { recursive: true, mode: 448 });
|
|
63971
|
-
logPath =
|
|
64019
|
+
logPath = join55(logsDir, `server-${Date.now()}-${process.pid}.log`);
|
|
63972
64020
|
logFd = openSync6(logPath, "wx", 384);
|
|
63973
64021
|
log("\nStarting your workspace\u2026");
|
|
63974
64022
|
}
|
|
@@ -64172,7 +64220,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
|
|
|
64172
64220
|
saveCliStartup2(options.dataDir, startupPreferences(launch));
|
|
64173
64221
|
}
|
|
64174
64222
|
if (options.command === "setup") {
|
|
64175
|
-
const flags = [options.dataDir !==
|
|
64223
|
+
const flags = [options.dataDir !== join55(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
|
|
64176
64224
|
io2.log(`
|
|
64177
64225
|
All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
|
|
64178
64226
|
return 0;
|