@chibitek/chibi 0.1.200 → 0.1.201
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/{TerminalPanel-DUfFZmEG.js → TerminalPanel-CF3ynjQ5.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-BqQSwr1u.js → abnfDiagram-O67JEVCF-DsLr5Rkp.js} +1 -1
- package/dist/assets/{arc-T05LhWW8.js → arc-BP9MW1JT.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-D_ggH0yg.js → architectureDiagram-NJMV4G6O-DqqmVruY.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-RE8mkopU.js → blockDiagram-BEXU5L5S-DCZycPW_.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BXtV9POP.js → c4Diagram-YGBWAQC7-DAt7A5JI.js} +1 -1
- package/dist/assets/channel-CfAu_VOE.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-7zaRJzef.js → chunk-2Q5K7J3B-D4XUKzBr.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BOxhuNM3.js → chunk-3FUC2YCW-BvKRlW0a.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-Clc6Y-k_.js → chunk-5VM5RSS4-CpaqfcXB.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-D7IERUnR.js → chunk-GTNCS2PH-bFX_YBLa.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-8QL2NNrN.js → chunk-GWA4HPMP-D4ceVX3-.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DKVMCjGt.js → chunk-JWPE2WC7-BrM5oyHo.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-SlxDfy1G.js → chunk-NETBCI7D-DJCITo_6.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-CRtOamAr.js → chunk-WEXAMYUT-DE5Rbq8q.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Dapib2DP.js → chunk-XXDRQBXY-C6QndzP7.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-2D0I10Na.js → classDiagram-v2-NBCMYWYE-DupxtheF.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DF9qnXun.js → cose-bilkent-JH36ORCC-K2_JJ1Os.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DrAkyhcY.js → cynefin-OW5HDTMX-D1iCt_1r.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-KQpEcNdf.js → cynefinDiagram-VND7K2PF-BxIP-LPT.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BbJ2VQn6.js → dagre-6A5THRUB-C9f6kI0w.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BNzSyGUh.js → diagram-22UHCM2B-DX1Js_iQ.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-DjjLDFUp.js → diagram-3UASUU5V-Dok5oHqH.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DC5I0Rdi.js → diagram-ATOU4E4O-CZjPw12I.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-BrXM08dx.js → diagram-CDSNMT55-CcdGyWm0.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-C3YZl0Tw.js → diagram-MLGK6HIB-BuyhR8Yt.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DN6TO0ne.js → diagram-MPIPVDR6-DyfzZWWJ.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-Z-Wj8D9u.js → ebnfDiagram-ZINNZB2B-DbX8lcW9.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-D0oWP8_p.js → elk-276RUBZZ-B_1y08rH.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BzPDI-qn.js → erDiagram-OPXOYQCR-CMNLleGm.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BYYAeWqA.js → flowDiagram-KWPJA3E3-BWNxAxrN.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-k6obyqY7.js → ganttDiagram-FUAMR5RP-DIbuHGn_.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-DinY8xWJ.js → gitGraphDiagram-X574FWY7-DOQ7lEBd.js} +1 -1
- package/dist/assets/{index-ChUqQMGu.js → index-AVvV2BDP.js} +6 -6
- package/dist/assets/{index-YyLa_0lt.js → index-DwCyxkQ-.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-BW2C-iLy.js → infoDiagram-VRGFBTTK-B6jXr3vk.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DVMxtqNy.js → ishikawaDiagram-OU5B5YK6-BMzUYIuP.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-VBQwKC0m.js → journeyDiagram-ZHPQQLJL-BSna9Sw4.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-BjkXxAFy.js → kanban-definition-PNTS6WVX-nGY_xsmB.js} +1 -1
- package/dist/assets/{linear-BvzB7a4B.js → linear-ClawroOG.js} +1 -1
- package/dist/assets/{mermaid.core-BINI6H7d.js → mermaid.core-QWILSY7q.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-b73g38FN.js → mindmap-definition-NLK3R4M7-BHBjOj_N.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-B8b2xdaw.js → pegDiagram-GJSIUBJH-BEhI0umY.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmlfE59D.js → pieDiagram-5QR66LMP-BNrNnFcF.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-DO8GiPy0.js → quadrantDiagram-O4NWA36T-DU8ZKo3R.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DJkdT4GR.js → railroadDiagram-XR7U4H2S-CXpikGSY.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BAx14esZ.js → requirementDiagram-PLB6GJNP-T2kWY6dy.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-CYlEooaw.js → sankeyDiagram-IPEJSGJF-DUVsoHCX.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-BTK7rivc.js → sequenceDiagram-PO4LG4MO-BqI-CnQQ.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-6V9VYNKI.js → sizeCapture-INFHLROL-CHRKcWjb.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-DVRTd965.js → stateDiagram-v2-GCMORJYK-Drb1kh-m.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-Bv1wYyTS.js → swimlanes-2SLR337P-D6bNO7iC.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BBg0kB8F.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-BMnrjUM5.js → timeline-definition-EJHVYXUP-30UJPQln.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-DQNQX-6S.js → usecaseDiagram-POWQR4AR-CsfAqILe.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Cnv1OiVG.js → vennDiagram-UO4OBE2U-D63qiwyq.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Di1yp5Fs.js → wardleyDiagram-VNRHLVJA-CwMexqnm.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-B_sh_5r0.js → xychartDiagram-PMCCYNJV-DFkAUNxr.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +415 -98
- package/dist-server/openmausbot.js +31 -0
- package/dist-server/pair-cli.js +31 -0
- package/dist-server/server/chibitek-mcp-credentials.js +207 -0
- package/dist-server/server/chibitek-mcp-signin.js +124 -0
- package/dist-server/server/company-mcp-tenancy.js +2 -2
- package/dist-server/server/index.js +21 -13
- package/dist-server/server/mcp-tool-hints.js +15 -1
- package/dist-server/server/mcp-turn.js +2 -1
- package/dist-server/server/nexus-memory/backoff.js +40 -8
- package/dist-server/server/nexus-memory/client.js +44 -12
- package/dist-server/server/nexus-memory/index.js +3 -3
- package/dist-server/server/repo-github.js +3 -1
- package/dist-server/server/routine-mochii-sync.js +1 -1
- package/dist-server/server/stiki-desktop-session.js +18 -5
- package/dist-server/server/stiki-session.js +3 -2
- package/package.json +1 -1
- package/dist/assets/channel--GPtxJe9.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Drv2GtYA.js +0 -8
package/dist-server/index.js
CHANGED
|
@@ -32218,7 +32218,7 @@ async function receiveGoalCommand(runtime, store2, botId, threadId, command, tex
|
|
|
32218
32218
|
// server/index.ts
|
|
32219
32219
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
32220
32220
|
import { createHash as createHash57, randomBytes as randomBytes18, randomUUID as randomUUID50, timingSafeEqual as timingSafeEqual9 } from "node:crypto";
|
|
32221
|
-
import { existsSync as existsSync88, readFileSync as
|
|
32221
|
+
import { existsSync as existsSync88, readFileSync as readFileSync112, realpathSync as realpathSync15, rmSync as rmSync25, mkdirSync as mkdirSync77, statSync as statSync31 } from "node:fs";
|
|
32222
32222
|
import { rm as removeDirectory } from "node:fs/promises";
|
|
32223
32223
|
import { createServer as createServer4 } from "node:http";
|
|
32224
32224
|
|
|
@@ -32296,7 +32296,7 @@ var ToolResults = class {
|
|
|
32296
32296
|
};
|
|
32297
32297
|
|
|
32298
32298
|
// server/index.ts
|
|
32299
|
-
import { extname as extname7, isAbsolute as isAbsolute24, join as
|
|
32299
|
+
import { extname as extname7, isAbsolute as isAbsolute24, join as join145, sep as sep11 } from "node:path";
|
|
32300
32300
|
|
|
32301
32301
|
// server/external-runtime.ts
|
|
32302
32302
|
import { createHash as createHash2, timingSafeEqual } from "node:crypto";
|
|
@@ -45731,15 +45731,17 @@ var GITHUB_REPO_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9_.-]{1,100
|
|
|
45731
45731
|
var LIST_URL = "user/repos?per_page=100&sort=pushed&affiliation=owner,collaborator,organization_member";
|
|
45732
45732
|
var JOB_TTL_MS = 60 * 60 * 1e3;
|
|
45733
45733
|
var GitHubRepos = class {
|
|
45734
|
+
jobs = /* @__PURE__ */ new Map();
|
|
45735
|
+
// Plain fields, not parameter properties: Node's type stripping (the dev
|
|
45736
|
+
// and verification server) refuses those.
|
|
45737
|
+
registry;
|
|
45738
|
+
run;
|
|
45739
|
+
folder;
|
|
45734
45740
|
constructor(registry4, run7 = runCommand2, folder3 = join24(homedir10(), "repos")) {
|
|
45735
45741
|
this.registry = registry4;
|
|
45736
45742
|
this.run = run7;
|
|
45737
45743
|
this.folder = folder3;
|
|
45738
45744
|
}
|
|
45739
|
-
registry;
|
|
45740
|
-
run;
|
|
45741
|
-
folder;
|
|
45742
|
-
jobs = /* @__PURE__ */ new Map();
|
|
45743
45745
|
/** The newest hundred repos the account can push to or read as a member. */
|
|
45744
45746
|
async list() {
|
|
45745
45747
|
const cli = await this.cli();
|
|
@@ -54467,6 +54469,185 @@ function exitMeansSignInRequired(code, stderrTail = "") {
|
|
|
54467
54469
|
return code === MCP_SIGN_IN_REQUIRED_EXIT || stderrTail.includes(MCP_SIGN_IN_REQUIRED_MARKER);
|
|
54468
54470
|
}
|
|
54469
54471
|
|
|
54472
|
+
// server/stiki-session.ts
|
|
54473
|
+
var SIGNED_OUT = {
|
|
54474
|
+
accessToken: async () => null,
|
|
54475
|
+
identity: () => null,
|
|
54476
|
+
onChange: () => () => {
|
|
54477
|
+
}
|
|
54478
|
+
};
|
|
54479
|
+
var source = SIGNED_OUT;
|
|
54480
|
+
var relays = /* @__PURE__ */ new Set();
|
|
54481
|
+
var detach = () => {
|
|
54482
|
+
};
|
|
54483
|
+
function stikiSession() {
|
|
54484
|
+
return source;
|
|
54485
|
+
}
|
|
54486
|
+
function setStikiSessionSource(next) {
|
|
54487
|
+
detach();
|
|
54488
|
+
source = next ?? SIGNED_OUT;
|
|
54489
|
+
detach = source.onChange(() => {
|
|
54490
|
+
for (const listener of relays) listener();
|
|
54491
|
+
});
|
|
54492
|
+
for (const listener of relays) listener();
|
|
54493
|
+
}
|
|
54494
|
+
function onStikiSessionChange(listener) {
|
|
54495
|
+
relays.add(listener);
|
|
54496
|
+
return () => relays.delete(listener);
|
|
54497
|
+
}
|
|
54498
|
+
|
|
54499
|
+
// server/chibitek-mcp-credentials.ts
|
|
54500
|
+
var STIKI_BEARER_ENV = "ATOMIC_STIKI_ACCESS_TOKEN";
|
|
54501
|
+
var STIKI_BEARER_HEADER_ARG = `Authorization:Bearer \${${STIKI_BEARER_ENV}}`;
|
|
54502
|
+
var MIN_VALID_MS = 6e4;
|
|
54503
|
+
var RESYNC_BEFORE_MS = 6 * 6e4;
|
|
54504
|
+
var MAX_RESYNC_MS = 15 * 6e4;
|
|
54505
|
+
var MIN_RESYNC_MS = 3e4;
|
|
54506
|
+
var REJECTION_REFRESH_MS = 6e4;
|
|
54507
|
+
var UNKNOWN_EXPIRY_MS = 10 * 6e4;
|
|
54508
|
+
function isAuthorizationHeaderArg(value) {
|
|
54509
|
+
return typeof value === "string" && /^\s*authorization\s*:/i.test(value);
|
|
54510
|
+
}
|
|
54511
|
+
function bridgeHasOwnAuthorization(extraArgs) {
|
|
54512
|
+
return extraArgs.some((arg, index2) => arg === "--header-file" || arg === "--header" && isAuthorizationHeaderArg(extraArgs[index2 + 1]) && extraArgs[index2 + 1] !== STIKI_BEARER_HEADER_ARG);
|
|
54513
|
+
}
|
|
54514
|
+
function takesStikiCredential(spec) {
|
|
54515
|
+
if (!spec || !(isChibitekNexus(spec) || isChibitekMochii(spec))) return false;
|
|
54516
|
+
if ("url" in spec) return !Object.keys(spec.headers ?? {}).some((name2) => name2.toLowerCase() === "authorization");
|
|
54517
|
+
const target = mcpRemoteTarget(spec);
|
|
54518
|
+
if (!target) return false;
|
|
54519
|
+
return !bridgeHasOwnAuthorization(target.extraArgs);
|
|
54520
|
+
}
|
|
54521
|
+
function withStikiCredential(spec, token) {
|
|
54522
|
+
if (!token || !takesStikiCredential(spec)) return spec;
|
|
54523
|
+
if ("url" in spec) return { ...spec, headers: { ...spec.headers, Authorization: `Bearer ${token}` } };
|
|
54524
|
+
const args = spec.args.includes(STIKI_BEARER_HEADER_ARG) ? [...spec.args] : [...spec.args, "--header", STIKI_BEARER_HEADER_ARG];
|
|
54525
|
+
return { ...spec, args, env: { ...spec.env, [STIKI_BEARER_ENV]: token, [MCP_NO_BROWSER_ENV]: "1" } };
|
|
54526
|
+
}
|
|
54527
|
+
function stikiTokenExpiry(token) {
|
|
54528
|
+
const payload = token.split(".")[1];
|
|
54529
|
+
if (!payload) return null;
|
|
54530
|
+
try {
|
|
54531
|
+
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
54532
|
+
return typeof claims.exp === "number" && Number.isFinite(claims.exp) ? Math.floor(claims.exp * 1e3) : null;
|
|
54533
|
+
} catch {
|
|
54534
|
+
return null;
|
|
54535
|
+
}
|
|
54536
|
+
}
|
|
54537
|
+
function missingChibitekMcpDefaults(servers) {
|
|
54538
|
+
const entries2 = Object.entries(servers ?? {});
|
|
54539
|
+
return CHIBITEK_DEFAULT_MCP_SERVERS.filter((server2) => {
|
|
54540
|
+
if (entries2.some(([name2]) => name2 === server2.name)) return false;
|
|
54541
|
+
return !entries2.some(([, entry]) => server2.name === "nexus" ? isChibitekNexus(entry) : isChibitekMochii(entry));
|
|
54542
|
+
});
|
|
54543
|
+
}
|
|
54544
|
+
var sameCredential = (a, b3) => a === b3 || !!a && !!b3 && a.token === b3.token && a.identity.userId === b3.identity.userId;
|
|
54545
|
+
var ChibitekMcpCredentials = class {
|
|
54546
|
+
held = null;
|
|
54547
|
+
syncing = null;
|
|
54548
|
+
syncAgain = null;
|
|
54549
|
+
timer;
|
|
54550
|
+
lastRejectionRefresh = Number.NEGATIVE_INFINITY;
|
|
54551
|
+
stopListening = null;
|
|
54552
|
+
deps;
|
|
54553
|
+
now;
|
|
54554
|
+
constructor(deps) {
|
|
54555
|
+
this.deps = deps;
|
|
54556
|
+
this.now = deps.now ?? Date.now;
|
|
54557
|
+
}
|
|
54558
|
+
/** Follow the sign-in: look now, on every sign-in change, and before the
|
|
54559
|
+
* held token expires. */
|
|
54560
|
+
start() {
|
|
54561
|
+
if (this.stopListening) return;
|
|
54562
|
+
this.stopListening = onStikiSessionChange(() => void this.sync());
|
|
54563
|
+
void this.sync();
|
|
54564
|
+
}
|
|
54565
|
+
stop() {
|
|
54566
|
+
this.stopListening?.();
|
|
54567
|
+
this.stopListening = null;
|
|
54568
|
+
if (this.timer) clearTimeout(this.timer);
|
|
54569
|
+
this.timer = void 0;
|
|
54570
|
+
}
|
|
54571
|
+
/** The credential a start may use now, or null (signed out, or no token
|
|
54572
|
+
* with time left). Synchronous: turns are assembled without waiting. */
|
|
54573
|
+
current() {
|
|
54574
|
+
const held = this.held;
|
|
54575
|
+
if (!held) return null;
|
|
54576
|
+
if (held.expiresAt - this.now() <= MIN_VALID_MS) {
|
|
54577
|
+
void this.sync();
|
|
54578
|
+
return null;
|
|
54579
|
+
}
|
|
54580
|
+
const signedIn2 = this.deps.session().identity();
|
|
54581
|
+
if (!signedIn2 || signedIn2.userId !== held.identity.userId) {
|
|
54582
|
+
void this.sync();
|
|
54583
|
+
return null;
|
|
54584
|
+
}
|
|
54585
|
+
return held;
|
|
54586
|
+
}
|
|
54587
|
+
/** Read the session again (it refreshes a token close to expiry). A call
|
|
54588
|
+
* while a read is running reads once more after it, so a sign-in change
|
|
54589
|
+
* that lands mid-read is never answered with what was read before it. */
|
|
54590
|
+
sync() {
|
|
54591
|
+
if (this.syncing) {
|
|
54592
|
+
this.syncAgain ??= this.syncing.then(() => {
|
|
54593
|
+
this.syncAgain = null;
|
|
54594
|
+
return this.sync();
|
|
54595
|
+
});
|
|
54596
|
+
return this.syncAgain;
|
|
54597
|
+
}
|
|
54598
|
+
this.syncing = this.read(false).finally(() => {
|
|
54599
|
+
this.syncing = null;
|
|
54600
|
+
});
|
|
54601
|
+
return this.syncing;
|
|
54602
|
+
}
|
|
54603
|
+
/** A server refused the held token: ask for a fresh one now. True when a
|
|
54604
|
+
* different token came back, so the refused start is worth retrying at
|
|
54605
|
+
* once; false means the usual back-off should apply. */
|
|
54606
|
+
async refreshAfterRejection() {
|
|
54607
|
+
const before = this.held?.token ?? null;
|
|
54608
|
+
if (this.now() - this.lastRejectionRefresh < REJECTION_REFRESH_MS) {
|
|
54609
|
+
await this.syncing;
|
|
54610
|
+
return Boolean(this.held && this.held.token !== before);
|
|
54611
|
+
}
|
|
54612
|
+
this.lastRejectionRefresh = this.now();
|
|
54613
|
+
this.deps.log?.("a Chibitek MCP server refused the Chibitek sign-in; refreshing it");
|
|
54614
|
+
const next = await this.read(true);
|
|
54615
|
+
return Boolean(next && next.token !== before);
|
|
54616
|
+
}
|
|
54617
|
+
async read(force) {
|
|
54618
|
+
const session = this.deps.session();
|
|
54619
|
+
let token = null;
|
|
54620
|
+
try {
|
|
54621
|
+
token = force && session.refresh ? await session.refresh() : await session.accessToken();
|
|
54622
|
+
} catch {
|
|
54623
|
+
token = null;
|
|
54624
|
+
}
|
|
54625
|
+
const identity3 = session.identity();
|
|
54626
|
+
const next = token && identity3 ? { token, identity: identity3, expiresAt: stikiTokenExpiry(token) ?? this.now() + UNKNOWN_EXPIRY_MS } : null;
|
|
54627
|
+
const before = this.held;
|
|
54628
|
+
this.held = next;
|
|
54629
|
+
this.schedule();
|
|
54630
|
+
if (!sameCredential(before, next)) {
|
|
54631
|
+
const switched = (before?.identity.userId ?? null) !== (next?.identity.userId ?? null);
|
|
54632
|
+
try {
|
|
54633
|
+
this.deps.onChange?.(next, switched);
|
|
54634
|
+
} catch (error51) {
|
|
54635
|
+
this.deps.log?.(`Chibitek MCP sign-in listener failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
54636
|
+
}
|
|
54637
|
+
}
|
|
54638
|
+
return next;
|
|
54639
|
+
}
|
|
54640
|
+
schedule() {
|
|
54641
|
+
if (this.timer) clearTimeout(this.timer);
|
|
54642
|
+
this.timer = void 0;
|
|
54643
|
+
if (!this.held || !this.stopListening) return;
|
|
54644
|
+
const untilResync = this.held.expiresAt - RESYNC_BEFORE_MS - this.now();
|
|
54645
|
+
const wait2 = Math.min(MAX_RESYNC_MS, Math.max(MIN_RESYNC_MS, untilResync));
|
|
54646
|
+
this.timer = setTimeout(() => void this.sync(), wait2);
|
|
54647
|
+
this.timer.unref?.();
|
|
54648
|
+
}
|
|
54649
|
+
};
|
|
54650
|
+
|
|
54470
54651
|
// server/mcp-tool-hints.ts
|
|
54471
54652
|
var HINT_KEYS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
|
|
54472
54653
|
var SNAKE = {
|
|
@@ -54488,9 +54669,20 @@ function toolAnnotations(raw) {
|
|
|
54488
54669
|
function isReadOnlyMcpTool(annotations) {
|
|
54489
54670
|
return annotations?.readOnlyHint === true && annotations.destructiveHint !== true;
|
|
54490
54671
|
}
|
|
54672
|
+
function withoutStikiHeader(args) {
|
|
54673
|
+
const out = [];
|
|
54674
|
+
for (let index2 = 0; index2 < args.length; index2 += 1) {
|
|
54675
|
+
if (args[index2] === "--header" && args[index2 + 1] === STIKI_BEARER_HEADER_ARG) {
|
|
54676
|
+
index2 += 1;
|
|
54677
|
+
continue;
|
|
54678
|
+
}
|
|
54679
|
+
out.push(args[index2]);
|
|
54680
|
+
}
|
|
54681
|
+
return out;
|
|
54682
|
+
}
|
|
54491
54683
|
function mcpServerFingerprint(spec) {
|
|
54492
54684
|
const bridge = "url" in spec ? null : mcpRemoteTarget(spec);
|
|
54493
|
-
const target = "url" in spec ? { type: spec.type, url: spec.url } : bridge ? { mcpRemote: bridge.url, args: bridge.extraArgs } : { command: spec.command, args: spec.args };
|
|
54685
|
+
const target = "url" in spec ? { type: spec.type, url: spec.url } : bridge ? { mcpRemote: bridge.url, args: withoutStikiHeader(bridge.extraArgs) } : { command: spec.command, args: spec.args };
|
|
54494
54686
|
return createHash13("sha256").update(JSON.stringify(target)).digest("hex").slice(0, 32);
|
|
54495
54687
|
}
|
|
54496
54688
|
var MAX_AGE_MS = 7 * 24 * 60 * 6e4;
|
|
@@ -55084,7 +55276,8 @@ function mcpTurnPolicy(deps) {
|
|
|
55084
55276
|
const signals = drainMcpAuthSignals(deps.signalDir());
|
|
55085
55277
|
if (!signals.length) return;
|
|
55086
55278
|
const specs = deps.specs();
|
|
55087
|
-
deps.
|
|
55279
|
+
const refused = (signal) => signal.kind === "sign-in-required" && Boolean(specs[signal.name]) && deps.credentialRefused?.(signal.name, specs[signal.name]) === true;
|
|
55280
|
+
deps.auth.ingest(signals.filter((signal) => !refused(signal)), specs);
|
|
55088
55281
|
for (const signal of deps.health.ingest(signals, specs)) {
|
|
55089
55282
|
if (signal.threadId) deps.reportUnavailable(signal.threadId, `the "${signal.name}" MCP server ${signal.kind === "crashed" ? "stopped during the turn" : "would not start"}; the turn ran on without its tools`);
|
|
55090
55283
|
}
|
|
@@ -72608,14 +72801,14 @@ function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
|
72608
72801
|
console.warn(`[atomic-engine] could not write ${path2}: ${error51.message}`);
|
|
72609
72802
|
}
|
|
72610
72803
|
}
|
|
72611
|
-
var
|
|
72804
|
+
var source2 = null;
|
|
72612
72805
|
function bindAtomicEngineAccountSource(next) {
|
|
72613
|
-
|
|
72806
|
+
source2 = next;
|
|
72614
72807
|
}
|
|
72615
72808
|
function currentAtomicEngineAccounts() {
|
|
72616
|
-
if (!
|
|
72809
|
+
if (!source2) return null;
|
|
72617
72810
|
try {
|
|
72618
|
-
return atomicEngineAccounts(
|
|
72811
|
+
return atomicEngineAccounts(source2());
|
|
72619
72812
|
} catch (error51) {
|
|
72620
72813
|
console.warn(`[atomic-engine] could not list the engine's accounts: ${error51.message}`);
|
|
72621
72814
|
return null;
|
|
@@ -82661,6 +82854,12 @@ var NexusInitializeError = class extends NexusUnavailableError {
|
|
|
82661
82854
|
this.name = "NexusInitializeError";
|
|
82662
82855
|
}
|
|
82663
82856
|
};
|
|
82857
|
+
var NexusAuthError = class extends NexusUnavailableError {
|
|
82858
|
+
constructor(message4) {
|
|
82859
|
+
super(message4);
|
|
82860
|
+
this.name = "NexusAuthError";
|
|
82861
|
+
}
|
|
82862
|
+
};
|
|
82664
82863
|
var NexusRejectedError = class extends Error {
|
|
82665
82864
|
constructor(message4) {
|
|
82666
82865
|
super(message4);
|
|
@@ -82670,7 +82869,12 @@ var NexusRejectedError = class extends Error {
|
|
|
82670
82869
|
var DEFAULT_TIMEOUT_MS3 = 2e4;
|
|
82671
82870
|
var PROTOCOL_VERSION2 = "2025-06-18";
|
|
82672
82871
|
var PRIVATE_SCOPE_ANSWER = /\b(?:private_scope_\w+|private_proof_invalid|personal_scope_requires_private_bot|personal_memory_cannot_be_shared)\b/;
|
|
82673
|
-
var
|
|
82872
|
+
var AUTH_REFUSED = /unauthori[sz]ed|sign ?in|\btoken\b|\b401\b|ATOMIC_MCP_SIGN_IN_REQUIRED/i;
|
|
82873
|
+
var TRANSIENT = /timed? ?out|timeout|ECONN|ENOTFOUND|EAI_AGAIN|fetch failed|network|socket|503|502|504|429|temporar|unavailable|not provisioned/i;
|
|
82874
|
+
function refusalError(message4) {
|
|
82875
|
+
if (AUTH_REFUSED.test(message4)) return new NexusAuthError(message4);
|
|
82876
|
+
return TRANSIENT.test(message4) ? new NexusUnavailableError(message4) : new NexusRejectedError(message4);
|
|
82877
|
+
}
|
|
82674
82878
|
var BRIDGE_URL = /https?:\/\/[^\s"'<>]+/gi;
|
|
82675
82879
|
var BRIDGE_SECRET = /\b(bearer|token|access_token|refresh_token|id_token|authorization|client_secret|api[_-]?key|password|code)\b(\s*[:=]\s*)\S+/gi;
|
|
82676
82880
|
var BRIDGE_JWT = /\beyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]{8,}){2}\b/g;
|
|
@@ -82694,7 +82898,7 @@ function parseToolResult(result) {
|
|
|
82694
82898
|
if (result.isError === true || parsed.success === false) {
|
|
82695
82899
|
const message4 = typeof parsed.error === "string" ? parsed.error : text19 || "Nexus refused the call";
|
|
82696
82900
|
if (PRIVATE_SCOPE_ANSWER.test(message4)) throw new NexusRejectedError(message4);
|
|
82697
|
-
throw
|
|
82901
|
+
throw refusalError(message4);
|
|
82698
82902
|
}
|
|
82699
82903
|
return parsed;
|
|
82700
82904
|
}
|
|
@@ -82712,13 +82916,14 @@ var HttpNexusClient = class {
|
|
|
82712
82916
|
await client.initialize("Atomic Nexus writeback", signal);
|
|
82713
82917
|
} catch (error51) {
|
|
82714
82918
|
await client.close().catch(() => void 0);
|
|
82919
|
+
if (error51 instanceof McpHttpError && error51.kind === "status" && error51.status === 401) throw new NexusAuthError("Nexus answered HTTP 401");
|
|
82715
82920
|
throw new NexusInitializeError(error51 instanceof Error ? error51.message : "Nexus initialize failed");
|
|
82716
82921
|
}
|
|
82717
82922
|
this.client = client;
|
|
82718
82923
|
return client;
|
|
82719
82924
|
})().catch((error51) => {
|
|
82720
82925
|
this.ready = null;
|
|
82721
|
-
throw error51 instanceof NexusInitializeError ? error51 : new NexusInitializeError(error51 instanceof Error ? error51.message : "Nexus initialize failed");
|
|
82926
|
+
throw error51 instanceof NexusInitializeError || error51 instanceof NexusAuthError ? error51 : new NexusInitializeError(error51 instanceof Error ? error51.message : "Nexus initialize failed");
|
|
82722
82927
|
});
|
|
82723
82928
|
return this.ready;
|
|
82724
82929
|
}
|
|
@@ -82730,6 +82935,9 @@ var HttpNexusClient = class {
|
|
|
82730
82935
|
} catch (error51) {
|
|
82731
82936
|
if (error51 instanceof NexusRejectedError || error51 instanceof NexusUnavailableError) throw error51;
|
|
82732
82937
|
await this.reset();
|
|
82938
|
+
if (error51 instanceof McpHttpError && error51.kind === "status" && error51.status === 401) {
|
|
82939
|
+
throw new NexusAuthError("Nexus answered HTTP 401");
|
|
82940
|
+
}
|
|
82733
82941
|
if (error51 instanceof McpHttpError && error51.kind === "status" && error51.status && error51.status < 500 && ![401, 403, 408, 429].includes(error51.status)) {
|
|
82734
82942
|
throw new NexusRejectedError(`Nexus answered HTTP ${error51.status}`);
|
|
82735
82943
|
}
|
|
@@ -82823,26 +83031,29 @@ var StdioNexusClient = class {
|
|
|
82823
83031
|
clearTimeout(entry.timer);
|
|
82824
83032
|
if (frame.error !== void 0) {
|
|
82825
83033
|
const message4 = isRecord7(frame.error) && typeof frame.error.message === "string" ? frame.error.message : "Nexus error";
|
|
82826
|
-
entry.reject(
|
|
83034
|
+
entry.reject(refusalError(message4));
|
|
82827
83035
|
} else entry.resolve(frame.result);
|
|
82828
83036
|
});
|
|
82829
83037
|
child.stdout.on("data", (chunk) => splitter.push(chunk));
|
|
82830
83038
|
let logged = 0;
|
|
82831
83039
|
let handshook = false;
|
|
83040
|
+
let signInRefused = false;
|
|
82832
83041
|
const errSplit = createLineSplitter((line3) => {
|
|
83042
|
+
if (line3.includes(MCP_SIGN_IN_REQUIRED_MARKER)) signInRefused = true;
|
|
82833
83043
|
const redacted = redactBridgeLine(line3);
|
|
82834
83044
|
if (!redacted || logged >= 20) return;
|
|
82835
83045
|
logged += 1;
|
|
82836
83046
|
this.log?.(`bridge: ${redacted}`);
|
|
82837
83047
|
});
|
|
82838
83048
|
child.stderr.on("data", (chunk) => errSplit.push(chunk));
|
|
82839
|
-
const gone = (message4) => {
|
|
83049
|
+
const gone = (message4, code) => {
|
|
82840
83050
|
errSplit.flush();
|
|
82841
83051
|
if (this.child !== child) return;
|
|
82842
|
-
this.fail(
|
|
83052
|
+
if (signInRefused || exitMeansSignInRequired(code ?? null)) this.fail(new NexusAuthError("Nexus refused the sign-in"));
|
|
83053
|
+
else this.fail(handshook ? new NexusUnavailableError(message4) : new NexusInitializeError(message4));
|
|
82843
83054
|
};
|
|
82844
83055
|
child.once("error", () => gone("Nexus bridge failed"));
|
|
82845
|
-
child.once("close", () => gone("Nexus bridge stopped"));
|
|
83056
|
+
child.once("close", (code) => gone("Nexus bridge stopped", code));
|
|
82846
83057
|
await this.send("initialize", {
|
|
82847
83058
|
protocolVersion: PROTOCOL_VERSION2,
|
|
82848
83059
|
capabilities: {},
|
|
@@ -82854,7 +83065,7 @@ var StdioNexusClient = class {
|
|
|
82854
83065
|
})().catch((error51) => {
|
|
82855
83066
|
const message4 = error51 instanceof Error ? error51.message : String(error51);
|
|
82856
83067
|
this.fail(error51 instanceof Error ? error51 : new Error(message4));
|
|
82857
|
-
throw error51 instanceof NexusInitializeError ? error51 : new NexusInitializeError(message4);
|
|
83068
|
+
throw error51 instanceof NexusInitializeError || error51 instanceof NexusAuthError ? error51 : new NexusInitializeError(message4);
|
|
82858
83069
|
});
|
|
82859
83070
|
return this.ready;
|
|
82860
83071
|
}
|
|
@@ -82900,17 +83111,35 @@ var UnavailableBackoff = class {
|
|
|
82900
83111
|
this.until = 0;
|
|
82901
83112
|
}
|
|
82902
83113
|
};
|
|
82903
|
-
function guardNexusClient(client, backoff, now, log) {
|
|
83114
|
+
function guardNexusClient(client, backoff, now, log, signIn) {
|
|
83115
|
+
const current4 = () => {
|
|
83116
|
+
const resolved = typeof client === "function" ? client() : client;
|
|
83117
|
+
if (!resolved) throw new NexusUnavailableError("Nexus is not connected on this computer");
|
|
83118
|
+
return resolved;
|
|
83119
|
+
};
|
|
82904
83120
|
const finish = async (tool2, args, timeoutMs) => {
|
|
82905
83121
|
try {
|
|
82906
|
-
const result = await
|
|
83122
|
+
const result = await current4().call(tool2, args, timeoutMs);
|
|
82907
83123
|
backoff.succeeded();
|
|
82908
83124
|
return result;
|
|
82909
83125
|
} catch (error51) {
|
|
82910
|
-
if (!(error51 instanceof NexusInitializeError) && error51 instanceof NexusUnavailableError) backoff.failed(now());
|
|
83126
|
+
if (!(error51 instanceof NexusInitializeError) && !(error51 instanceof NexusAuthError) && error51 instanceof NexusUnavailableError) backoff.failed(now());
|
|
82911
83127
|
throw error51;
|
|
82912
83128
|
}
|
|
82913
83129
|
};
|
|
83130
|
+
const afterSignInRefused = async (error51, tool2, args, timeoutMs) => {
|
|
83131
|
+
if (signIn && await signIn.refresh().catch(() => false)) {
|
|
83132
|
+
log("Nexus refused the sign-in; refreshed the Chibitek sign-in and retrying now");
|
|
83133
|
+
try {
|
|
83134
|
+
return await finish(tool2, args, timeoutMs);
|
|
83135
|
+
} catch (again) {
|
|
83136
|
+
if (again instanceof NexusAuthError || again instanceof NexusInitializeError) backoff.failed(now());
|
|
83137
|
+
throw again;
|
|
83138
|
+
}
|
|
83139
|
+
}
|
|
83140
|
+
backoff.failed(now());
|
|
83141
|
+
throw error51;
|
|
83142
|
+
};
|
|
82914
83143
|
return {
|
|
82915
83144
|
call: async (tool2, args, timeoutMs) => {
|
|
82916
83145
|
const remaining = backoff.remainingMs(now());
|
|
@@ -82918,17 +83147,19 @@ function guardNexusClient(client, backoff, now, log) {
|
|
|
82918
83147
|
try {
|
|
82919
83148
|
return await finish(tool2, args, timeoutMs);
|
|
82920
83149
|
} catch (error51) {
|
|
83150
|
+
if (error51 instanceof NexusAuthError) return afterSignInRefused(error51, tool2, args, timeoutMs);
|
|
82921
83151
|
if (!(error51 instanceof NexusInitializeError)) throw error51;
|
|
82922
83152
|
log("Nexus initialize failed; retrying once");
|
|
82923
83153
|
try {
|
|
82924
83154
|
return await finish(tool2, args, timeoutMs);
|
|
82925
83155
|
} catch (again) {
|
|
83156
|
+
if (again instanceof NexusAuthError) return afterSignInRefused(again, tool2, args, timeoutMs);
|
|
82926
83157
|
if (again instanceof NexusInitializeError) backoff.failed(now());
|
|
82927
83158
|
throw again;
|
|
82928
83159
|
}
|
|
82929
83160
|
}
|
|
82930
83161
|
},
|
|
82931
|
-
close: () =>
|
|
83162
|
+
close: () => current4().close()
|
|
82932
83163
|
};
|
|
82933
83164
|
}
|
|
82934
83165
|
|
|
@@ -84764,7 +84995,7 @@ var NexusMemory = class {
|
|
|
84764
84995
|
this.client ??= this.deps.clientFor(cfg2);
|
|
84765
84996
|
return this.client;
|
|
84766
84997
|
}
|
|
84767
|
-
const spec = customMcpServers(cfg2).nexus;
|
|
84998
|
+
const spec = this.deps.serverSpec ? this.deps.serverSpec(customMcpServers(cfg2).nexus) : customMcpServers(cfg2).nexus;
|
|
84768
84999
|
const key5 = JSON.stringify(spec ?? null);
|
|
84769
85000
|
if (key5 !== this.clientKey) {
|
|
84770
85001
|
void this.client?.close();
|
|
@@ -84777,7 +85008,7 @@ var NexusMemory = class {
|
|
|
84777
85008
|
getClient() {
|
|
84778
85009
|
const client = this.rawClient();
|
|
84779
85010
|
if (!client) return null;
|
|
84780
|
-
return guardNexusClient(
|
|
85011
|
+
return guardNexusClient(() => this.rawClient(), this.backoff, this.now, this.log, this.deps.signIn);
|
|
84781
85012
|
}
|
|
84782
85013
|
// ── the Private Bot's signed calls ─────────────────────────────────────
|
|
84783
85014
|
privateKey() {
|
|
@@ -95544,7 +95775,7 @@ var RoutineMochiiSync = class _RoutineMochiiSync {
|
|
|
95544
95775
|
}
|
|
95545
95776
|
clientFor(cfg2) {
|
|
95546
95777
|
if (this.deps.clientFor) return this.client ??= this.deps.clientFor(cfg2);
|
|
95547
|
-
const spec = customMcpServers(cfg2).mochii;
|
|
95778
|
+
const spec = this.deps.serverSpec ? this.deps.serverSpec(customMcpServers(cfg2).mochii) : customMcpServers(cfg2).mochii;
|
|
95548
95779
|
const key5 = JSON.stringify(spec ?? null);
|
|
95549
95780
|
if (key5 !== this.clientKey) {
|
|
95550
95781
|
void this.client?.close();
|
|
@@ -122695,33 +122926,6 @@ import { randomUUID as randomUUID47 } from "node:crypto";
|
|
|
122695
122926
|
import { existsSync as existsSync86, mkdirSync as mkdirSync76, readFileSync as readFileSync109, writeFileSync as writeFileSync37 } from "node:fs";
|
|
122696
122927
|
import { join as join142 } from "node:path";
|
|
122697
122928
|
|
|
122698
|
-
// server/stiki-session.ts
|
|
122699
|
-
var SIGNED_OUT = {
|
|
122700
|
-
accessToken: async () => null,
|
|
122701
|
-
identity: () => null,
|
|
122702
|
-
onChange: () => () => {
|
|
122703
|
-
}
|
|
122704
|
-
};
|
|
122705
|
-
var source2 = SIGNED_OUT;
|
|
122706
|
-
var relays = /* @__PURE__ */ new Set();
|
|
122707
|
-
var detach = () => {
|
|
122708
|
-
};
|
|
122709
|
-
function stikiSession() {
|
|
122710
|
-
return source2;
|
|
122711
|
-
}
|
|
122712
|
-
function setStikiSessionSource(next) {
|
|
122713
|
-
detach();
|
|
122714
|
-
source2 = next ?? SIGNED_OUT;
|
|
122715
|
-
detach = source2.onChange(() => {
|
|
122716
|
-
for (const listener of relays) listener();
|
|
122717
|
-
});
|
|
122718
|
-
for (const listener of relays) listener();
|
|
122719
|
-
}
|
|
122720
|
-
function onStikiSessionChange(listener) {
|
|
122721
|
-
relays.add(listener);
|
|
122722
|
-
return () => relays.delete(listener);
|
|
122723
|
-
}
|
|
122724
|
-
|
|
122725
122929
|
// server/team-rooms/installation.ts
|
|
122726
122930
|
import { createHash as createHash56, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey2, generateKeyPairSync as generateKeyPairSync2, randomBytes as randomBytes17, sign as sign2 } from "node:crypto";
|
|
122727
122931
|
import { existsSync as existsSync84, mkdirSync as mkdirSync74, readFileSync as readFileSync107 } from "node:fs";
|
|
@@ -127130,10 +127334,100 @@ function publicTranscriptProvider(options) {
|
|
|
127130
127334
|
};
|
|
127131
127335
|
}
|
|
127132
127336
|
|
|
127337
|
+
// server/chibitek-mcp-signin.ts
|
|
127338
|
+
import { readFileSync as readFileSync111 } from "node:fs";
|
|
127339
|
+
import { join as join144 } from "node:path";
|
|
127340
|
+
var MARKER3 = "chibitek-mcp-signin.json";
|
|
127341
|
+
function createChibitekMcpSignIn(deps) {
|
|
127342
|
+
const credentials = new ChibitekMcpCredentials({
|
|
127343
|
+
session: deps.session,
|
|
127344
|
+
now: deps.now,
|
|
127345
|
+
log: deps.log,
|
|
127346
|
+
onChange: (credential, switched) => {
|
|
127347
|
+
for (const server2 of CHIBITEK_DEFAULT_MCP_SERVERS) {
|
|
127348
|
+
const name2 = Object.entries(deps.servers() ?? {}).find(([key5, entry]) => key5 === server2.name || mcpServerTarget(entry) === server2.url)?.[0] ?? server2.name;
|
|
127349
|
+
if (credential) deps.authState().noteOk(name2);
|
|
127350
|
+
if (switched) deps.notices().clear(name2);
|
|
127351
|
+
}
|
|
127352
|
+
if (credential && switched) void install();
|
|
127353
|
+
deps.changed();
|
|
127354
|
+
}
|
|
127355
|
+
});
|
|
127356
|
+
const markerPath = join144(deps.dataDir, MARKER3);
|
|
127357
|
+
const installedFor = () => {
|
|
127358
|
+
try {
|
|
127359
|
+
const parsed = JSON.parse(readFileSync111(markerPath, "utf8"));
|
|
127360
|
+
return Array.isArray(parsed.installedFor) ? parsed.installedFor.filter((id) => typeof id === "string") : [];
|
|
127361
|
+
} catch {
|
|
127362
|
+
return [];
|
|
127363
|
+
}
|
|
127364
|
+
};
|
|
127365
|
+
const entryFor = (name2, url2) => {
|
|
127366
|
+
const bridge = deps.bridge();
|
|
127367
|
+
return bridge ? { command: "node", args: [bridge, url2], env: { CHIBITEK_MCP_BRAND: name2 }, enabled: true } : { command: "npx", args: ["-y", MCP_REMOTE_PACKAGE, url2], env: { CHIBITEK_MCP_BRAND: name2 }, enabled: true };
|
|
127368
|
+
};
|
|
127369
|
+
async function install(attempt = 0) {
|
|
127370
|
+
const identity3 = deps.session().identity();
|
|
127371
|
+
if (!identity3) return [];
|
|
127372
|
+
const already = installedFor();
|
|
127373
|
+
if (already.includes(identity3.userId)) return [];
|
|
127374
|
+
const missing = missingChibitekMcpDefaults(deps.servers()).filter((server2) => deps.mayInstall(server2.name, server2.url));
|
|
127375
|
+
if (missing.length) {
|
|
127376
|
+
const next = { ...deps.servers() };
|
|
127377
|
+
for (const server2 of missing) next[server2.name] = entryFor(server2.name, server2.url);
|
|
127378
|
+
try {
|
|
127379
|
+
await deps.persist(next);
|
|
127380
|
+
} catch (error51) {
|
|
127381
|
+
if (attempt < 5) setTimeout(() => void install(attempt + 1), 5e3).unref?.();
|
|
127382
|
+
else deps.log(`could not install the Chibitek MCP servers: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
127383
|
+
return [];
|
|
127384
|
+
}
|
|
127385
|
+
deps.log(`signed in with Chibitek: installed ${missing.map((server2) => server2.name).join(", ")}`);
|
|
127386
|
+
}
|
|
127387
|
+
writeFileAtomic(markerPath, `${JSON.stringify({ installedFor: [...already, identity3.userId] }, null, 2)}
|
|
127388
|
+
`);
|
|
127389
|
+
if (missing.length) deps.changed();
|
|
127390
|
+
return missing.map((server2) => server2.name);
|
|
127391
|
+
}
|
|
127392
|
+
const signedIn2 = (spec) => Boolean(spec && credentials.current() && takesStikiCredential(spec));
|
|
127393
|
+
return {
|
|
127394
|
+
credentials,
|
|
127395
|
+
install,
|
|
127396
|
+
start: () => credentials.start(),
|
|
127397
|
+
/** A start of `spec`, signed in with the Chibitek session when it takes one. */
|
|
127398
|
+
credentialed(spec) {
|
|
127399
|
+
const credential = credentials.current();
|
|
127400
|
+
return credential ? withStikiCredential(spec, credential.token) : spec;
|
|
127401
|
+
},
|
|
127402
|
+
signedIn: signedIn2,
|
|
127403
|
+
/** Who Settings says the server is signed in as, or undefined. */
|
|
127404
|
+
signedInAs(spec) {
|
|
127405
|
+
const credential = signedIn2(spec) ? credentials.current() : null;
|
|
127406
|
+
return credential ? { name: credential.identity.name } : void 0;
|
|
127407
|
+
},
|
|
127408
|
+
/** A signed-in start needed a sign-in: refresh the token now. True when
|
|
127409
|
+
* this took over; a refresh with nothing new falls back to the back-off. */
|
|
127410
|
+
refused(name2, spec) {
|
|
127411
|
+
if (!signedIn2(spec)) return false;
|
|
127412
|
+
void credentials.refreshAfterRejection().then((renewed) => {
|
|
127413
|
+
if (!renewed) deps.authState().noteSignInRequired(name2, spec);
|
|
127414
|
+
});
|
|
127415
|
+
return true;
|
|
127416
|
+
},
|
|
127417
|
+
/** Settings' Test and Reconnect: a refused token is refreshed and the
|
|
127418
|
+
* probe tried once more, never a browser. `start` builds the start. */
|
|
127419
|
+
async probe(spec, run7) {
|
|
127420
|
+
const first = await run7();
|
|
127421
|
+
if (first.ok || first.signInRequired !== true || !signedIn2(spec)) return first;
|
|
127422
|
+
return await credentials.refreshAfterRejection() ? run7() : first;
|
|
127423
|
+
}
|
|
127424
|
+
};
|
|
127425
|
+
}
|
|
127426
|
+
|
|
127133
127427
|
// server/stiki-desktop-session.ts
|
|
127134
127428
|
import { randomUUID as randomUUID49 } from "node:crypto";
|
|
127135
127429
|
var ASK_BEFORE_MS = 5 * 6e4;
|
|
127136
|
-
var
|
|
127430
|
+
var MIN_VALID_MS2 = 3e4;
|
|
127137
127431
|
var JWT2 = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
127138
127432
|
var text18 = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max ? value : null;
|
|
127139
127433
|
function decodeSession(raw) {
|
|
@@ -127190,16 +127484,24 @@ var DesktopStikiSession = class {
|
|
|
127190
127484
|
if (!this.held) return null;
|
|
127191
127485
|
if (this.held.expiresAt - this.now() <= ASK_BEFORE_MS) await this.askMain();
|
|
127192
127486
|
const held = this.held;
|
|
127193
|
-
return held && held.expiresAt - this.now() >
|
|
127487
|
+
return held && held.expiresAt - this.now() > MIN_VALID_MS2 ? held.token : null;
|
|
127488
|
+
}
|
|
127489
|
+
/** A server refused the held token: ask main to refresh it now (main
|
|
127490
|
+
* rate-limits this), then hand out whatever it answered. */
|
|
127491
|
+
async refresh() {
|
|
127492
|
+
if (!this.held) return null;
|
|
127493
|
+
await this.askMain(true);
|
|
127494
|
+
const held = this.held;
|
|
127495
|
+
return held && held.expiresAt - this.now() > MIN_VALID_MS2 ? held.token : null;
|
|
127194
127496
|
}
|
|
127195
127497
|
onChange(listener) {
|
|
127196
127498
|
this.listeners.add(listener);
|
|
127197
127499
|
return () => this.listeners.delete(listener);
|
|
127198
127500
|
}
|
|
127199
|
-
askMain() {
|
|
127200
|
-
if (this.asking) return this.asking;
|
|
127501
|
+
askMain(refresh = false) {
|
|
127502
|
+
if (this.asking && !refresh) return this.asking;
|
|
127201
127503
|
const requestId = randomUUID49();
|
|
127202
|
-
|
|
127504
|
+
const answered = new Promise((resolve32) => {
|
|
127203
127505
|
const timer = setTimeout(() => {
|
|
127204
127506
|
this.waiting.delete(requestId);
|
|
127205
127507
|
resolve32();
|
|
@@ -127209,12 +127511,14 @@ var DesktopStikiSession = class {
|
|
|
127209
127511
|
clearTimeout(timer);
|
|
127210
127512
|
resolve32();
|
|
127211
127513
|
});
|
|
127212
|
-
if (!this.send({ type: "openmausbot:stiki-token-request", requestId })) {
|
|
127514
|
+
if (!this.send({ type: "openmausbot:stiki-token-request", requestId, ...refresh ? { refresh: true } : {} })) {
|
|
127213
127515
|
clearTimeout(timer);
|
|
127214
127516
|
this.waiting.delete(requestId);
|
|
127215
127517
|
resolve32();
|
|
127216
127518
|
}
|
|
127217
|
-
})
|
|
127519
|
+
});
|
|
127520
|
+
if (refresh) return answered;
|
|
127521
|
+
this.asking = answered.finally(() => {
|
|
127218
127522
|
this.asking = null;
|
|
127219
127523
|
});
|
|
127220
127524
|
return this.asking;
|
|
@@ -127262,9 +127566,9 @@ function releaseDataDirLeaseAtExit() {
|
|
|
127262
127566
|
}
|
|
127263
127567
|
}
|
|
127264
127568
|
process.once("exit", releaseDataDirLeaseAtExit);
|
|
127265
|
-
var restoredThisBoot = existsSync88(
|
|
127569
|
+
var restoredThisBoot = existsSync88(join145(DATA_DIR, ".backups")) ? applyPendingWorkspaceRestore(DATA_DIR) : { restored: false };
|
|
127266
127570
|
var workspaceRestore = restoredThisBoot;
|
|
127267
|
-
if (existsSync88(
|
|
127571
|
+
if (existsSync88(join145(DATA_DIR, ".backups")) && !workspaceRestore.restored && !workspaceRestore.rolledBack) workspaceRestore = readLastWorkspaceRestore(DATA_DIR) ?? workspaceRestore;
|
|
127268
127572
|
var workspaceMaintenance = new WorkspaceBackupMaintenance();
|
|
127269
127573
|
var ENVIRONMENT_ID = loadEnvironmentId(DATA_DIR);
|
|
127270
127574
|
function signInAllowList() {
|
|
@@ -127272,7 +127576,7 @@ function signInAllowList() {
|
|
|
127272
127576
|
return { admins: parseAllowList(current4?.admins?.join(",")), members: parseAllowList(current4?.members?.join(",")) };
|
|
127273
127577
|
}
|
|
127274
127578
|
var sessions = new SessionRegistry({
|
|
127275
|
-
file:
|
|
127579
|
+
file: join145(DATA_DIR, "sessions.json"),
|
|
127276
127580
|
emailScopesSnapshot: () => {
|
|
127277
127581
|
const membership = signInAllowList();
|
|
127278
127582
|
return (email3) => allowedScopes(email3, membership);
|
|
@@ -127280,8 +127584,8 @@ var sessions = new SessionRegistry({
|
|
|
127280
127584
|
portalMembership: hostedWorkspaceConfiguration()?.portalMembership === true
|
|
127281
127585
|
});
|
|
127282
127586
|
var sharedComputers = new SharedComputers((id) => sessions.isLive(id));
|
|
127283
|
-
var assistants = new ConnectedAssistants({ file:
|
|
127284
|
-
var threadStarters = new ThreadStarters(
|
|
127587
|
+
var assistants = new ConnectedAssistants({ file: join145(DATA_DIR, "connected-assistants.json") });
|
|
127588
|
+
var threadStarters = new ThreadStarters(join145(DATA_DIR, "thread-starters.json"));
|
|
127285
127589
|
var SESSION_COOKIE = sessionCookieName(PORT, ENVIRONMENT_ID);
|
|
127286
127590
|
var HOSTED_WORKSPACE = hostedWorkspaceConfigured();
|
|
127287
127591
|
var workspaceAccess = null;
|
|
@@ -127788,7 +128092,7 @@ if (!hostedModels) {
|
|
|
127788
128092
|
}
|
|
127789
128093
|
}
|
|
127790
128094
|
var bundledSkills2 = [...loadBundledSkills(), ...loadAddonSkillLibraries()];
|
|
127791
|
-
var availableSkills = () => mergeSkills(bundledSkills2, loadUserSkills(
|
|
128095
|
+
var availableSkills = () => mergeSkills(bundledSkills2, loadUserSkills(join145(DATA_DIR, "skills")));
|
|
127792
128096
|
var utilityParentPort = process.parentPort;
|
|
127793
128097
|
installNativeVault(DATA_DIR, utilityParentPort, () => desktopMutationToken, (req) => authorizedInternalCapability(req.headers.authorization));
|
|
127794
128098
|
installWorkspaceSecrets(utilityParentPort, DATA_DIR, restoredThisBoot);
|
|
@@ -127816,7 +128120,7 @@ function applyDesktopMutationTokenMessage(raw) {
|
|
|
127816
128120
|
return true;
|
|
127817
128121
|
}
|
|
127818
128122
|
var browserCleanup = new BrowserCleanupCoordinator({
|
|
127819
|
-
file:
|
|
128123
|
+
file: join145(DATA_DIR, "browser-cleanups.json"),
|
|
127820
128124
|
send: (request4) => {
|
|
127821
128125
|
const status = browserEngineStatus({ managedOnly: true });
|
|
127822
128126
|
const sessions2 = request4.type === "openmausbot:browser-bot-deleted" && request4.botId ? [browserSessionId(request4.botId, "")] : request4.partitionId ? [browserSessionId("", request4.partitionId)] : [];
|
|
@@ -127842,6 +128146,15 @@ var oauthAccounts = new OAuthAccounts({ vault: accountVault, clients: oauthClien
|
|
|
127842
128146
|
if (DESKTOP_MANAGED && utilityParentPort) setMcpSecretSender(postDesktopPrivateMessage);
|
|
127843
128147
|
var desktopStiki = DESKTOP_MANAGED && utilityParentPort ? new DesktopStikiSession(postDesktopPrivateMessage) : null;
|
|
127844
128148
|
if (desktopStiki) setStikiSessionSource(desktopStiki);
|
|
128149
|
+
var mcpSignIn = createChibitekMcpSignIn({ dataDir: DATA_DIR, session: stikiSession, servers: () => cfg.mcpServers, bridge: resolveMcpRemoteBridge, authState: () => mcpAuthState, notices: () => mcpAccessNotices, log: (line3) => console.warn(`[chibitek-mcp] ${line3}`), mayInstall: (name2, url2) => !hostedModels && !HOSTED_WORKSPACE && managedPolicy.mcpAllowed(name2, url2), changed: () => broadcast({ kind: "config", ...configStatus() }), persist: async (next) => {
|
|
128150
|
+
if (mcpConfigBusy) throw new Error("MCP servers are already being updated.");
|
|
128151
|
+
mcpConfigBusy = true;
|
|
128152
|
+
try {
|
|
128153
|
+
await persistMcpServers(next);
|
|
128154
|
+
} finally {
|
|
128155
|
+
mcpConfigBusy = false;
|
|
128156
|
+
}
|
|
128157
|
+
} });
|
|
127845
128158
|
function godModeRefusal() {
|
|
127846
128159
|
return HOSTED_WORKSPACE || hostedModels ? "GOD MODE is not available on a shared workspace" : null;
|
|
127847
128160
|
}
|
|
@@ -127849,7 +128162,7 @@ function godModeActive() {
|
|
|
127849
128162
|
return cfg.godMode === true && godModeRefusal() === null;
|
|
127850
128163
|
}
|
|
127851
128164
|
var godModeSwitch = new GodModeSwitch({
|
|
127852
|
-
file:
|
|
128165
|
+
file: join145(DATA_DIR, "god-mode-grant.json"),
|
|
127853
128166
|
enabled: () => cfg.godMode === true,
|
|
127854
128167
|
refusal: godModeRefusal,
|
|
127855
128168
|
persist: (enabled2) => {
|
|
@@ -127942,7 +128255,7 @@ var activeInternalGenerationByThread = /* @__PURE__ */ new Map();
|
|
|
127942
128255
|
var internalGenerationByProviderTurn = new ProviderTurnGenerationRegistry();
|
|
127943
128256
|
var computerSelectionTurns = /* @__PURE__ */ new Map();
|
|
127944
128257
|
var EXTERNAL_RUNTIME_GENERATION = "external-runtime";
|
|
127945
|
-
var EXTERNAL_RUNTIMES_FILE =
|
|
128258
|
+
var EXTERNAL_RUNTIMES_FILE = join145(DATA_DIR, "external-runtimes.json");
|
|
127946
128259
|
function externalRuntimeMayCall(method, path2) {
|
|
127947
128260
|
if (method === "GET") return path2 === "/api/internal/agents" || /^\/api\/internal\/delegations\/[\w-]+$/.test(path2);
|
|
127948
128261
|
return method === "POST" && (path2 === "/api/internal/ask-bot" || path2 === "/api/internal/delegate-bot");
|
|
@@ -128719,6 +129032,8 @@ setInterval(() => void refreshPersonalMdm(), 5 * 6e4).unref?.();
|
|
|
128719
129032
|
var nexusMemory = new NexusMemory({
|
|
128720
129033
|
dataDir: DATA_DIR,
|
|
128721
129034
|
config: () => cfg,
|
|
129035
|
+
serverSpec: (spec) => spec && mcpSignIn.credentialed(spec),
|
|
129036
|
+
signIn: { refresh: () => mcpSignIn.credentials.refreshAfterRejection() },
|
|
128722
129037
|
// HIPAA mode is the one workspace switch (MDM, environment, or the
|
|
128723
129038
|
// Administrator's setting): patient-data items never go to Nexus.
|
|
128724
129039
|
mdm: () => ({ nexusMemoryAlways: personalMdm.nexusMemoryAlways(), hipaaManaged: workspaceHipaa().enabled }),
|
|
@@ -128751,7 +129066,7 @@ function noteNexusLocalMemory(botId) {
|
|
|
128751
129066
|
}
|
|
128752
129067
|
}
|
|
128753
129068
|
nexusMemory.start();
|
|
128754
|
-
var routineMochiiSync = RoutineMochiiSync.start({ dataDir: DATA_DIR, config: () => cfg, listRoutines: () => routines?.listRoutines() ?? [], listRuns: () => routines?.listRuns() ?? [], botName: (id) => store.bot(id)?.name, timeZone: () => routineTimeZone() });
|
|
129069
|
+
var routineMochiiSync = RoutineMochiiSync.start({ dataDir: DATA_DIR, config: () => cfg, serverSpec: (spec) => spec && mcpSignIn.credentialed(spec), listRoutines: () => routines?.listRoutines() ?? [], listRuns: () => routines?.listRuns() ?? [], botName: (id) => store.bot(id)?.name, timeZone: () => routineTimeZone() });
|
|
128755
129070
|
setTimeout(() => {
|
|
128756
129071
|
if (store.personalBot()) void nexusMemory.registerPrivateKey();
|
|
128757
129072
|
}, 3e3).unref?.();
|
|
@@ -129517,7 +129832,7 @@ async function probeEngine(entry) {
|
|
|
129517
129832
|
if (!instance || providerInstancesChanging.has(entry.instanceId) || providerFleetReloading) return "unknown";
|
|
129518
129833
|
const threadId = probeThreadId(entry.instanceId);
|
|
129519
129834
|
if (probeWaiters.has(threadId)) return "unknown";
|
|
129520
|
-
const cwd =
|
|
129835
|
+
const cwd = join145(DATA_DIR, "engine-probe");
|
|
129521
129836
|
mkdirSync77(cwd, { recursive: true, mode: 448 });
|
|
129522
129837
|
const listed = (id) => Boolean(id) && (instance.models.default === id || instance.models.options.some((option) => option.id === id));
|
|
129523
129838
|
const model2 = listed(entry.model) ? entry.model : instance.models.default || void 0;
|
|
@@ -130329,8 +130644,8 @@ var store = new Store(
|
|
|
130329
130644
|
() => bootSelection,
|
|
130330
130645
|
(selection) => withNewBotEffort(selection, cfg.newBots?.effort, registry3.get(selection.instanceId)?.adapter.capabilities.effortLevels)
|
|
130331
130646
|
);
|
|
130332
|
-
var teamComputers = new TeamComputers(
|
|
130333
|
-
var repoRegistry = new RepoRegistry(
|
|
130647
|
+
var teamComputers = new TeamComputers(join145(DATA_DIR, "team-computers.json"), ENVIRONMENT_ID);
|
|
130648
|
+
var repoRegistry = new RepoRegistry(join145(DATA_DIR, "repos.json"), () => broadcastRepos());
|
|
130334
130649
|
var followupsReady = false;
|
|
130335
130650
|
var sendSequencer = new SendSequencer();
|
|
130336
130651
|
bootSelection = await defaultSelection();
|
|
@@ -130490,7 +130805,7 @@ async function botOverview(bot) {
|
|
|
130490
130805
|
recent
|
|
130491
130806
|
});
|
|
130492
130807
|
}
|
|
130493
|
-
var botWorkModes = new BotWorkModes(
|
|
130808
|
+
var botWorkModes = new BotWorkModes(join145(DATA_DIR, "bot-work-modes.json"));
|
|
130494
130809
|
for (const id of botWorkModes.expired((id2) => sessions.isLive(id2))) store.setAllThreadApprovalMode(id, "ask", true);
|
|
130495
130810
|
var approvalModeForTurn = (bot, peerInitiated = false) => godModeElevates(bot) ? "full" : ownApprovalModeForTurn(bot, peerInitiated);
|
|
130496
130811
|
var ownApprovalModeForTurn = (bot, peerInitiated = false) => ownBotApprovalMode(bot, registry3.cliTarget(bot.modelSelection.instanceId)?.driverKind, peerInitiated, botWorkModes.permits(approvalModeFor(bot)));
|
|
@@ -130909,7 +131224,7 @@ var publicBotQueuedMessages = () => queuedSteerSnapshot((botId, threadId) => Boo
|
|
|
130909
131224
|
var groupTurnOperations = /* @__PURE__ */ new Map();
|
|
130910
131225
|
var groupGoalCoordinatorTurns = /* @__PURE__ */ new Map();
|
|
130911
131226
|
var GROUP_GOAL_COORDINATOR_GUARD_MS = 5 * 6e4;
|
|
130912
|
-
var personalGoals = new PersonalGoalRuntime(
|
|
131227
|
+
var personalGoals = new PersonalGoalRuntime(join145(DATA_DIR, "personal-goals.json"), {
|
|
130913
131228
|
busy: (botId, threadId) => threadBusy(botId, threadId) || Boolean(activeGroupTurnForBot(botId)),
|
|
130914
131229
|
interrupt: async (botId, threadId, goalId) => {
|
|
130915
131230
|
const owns = [...groupGoalCoordinatorTurns.get(threadId) ?? []].some((guard) => guard.personalGoalId === goalId && !guard.discard && (!guard.turnId || guard.turnId === liveTurnByThread.get(threadId)));
|
|
@@ -131134,7 +131449,7 @@ function outstandingAssignmentsPrompt(threadId) {
|
|
|
131134
131449
|
}));
|
|
131135
131450
|
return ` Assignments you already sent are still outstanding, and nothing in this conversation cancelled them: ${JSON.stringify(listed)}. Do not send them again, do not poll or wait for them, and do not tell the user they were lost. Each result returns to this conversation on its own and resumes you then. Answer the message above with that work still in flight.`;
|
|
131136
131451
|
}
|
|
131137
|
-
var roomHandoffs = new RoomHandoffs(
|
|
131452
|
+
var roomHandoffs = new RoomHandoffs(join145(DATA_DIR, "room-handoffs.json"), {
|
|
131138
131453
|
validate: (node2, parent) => roomHandoffProblem(node2, parent) ?? (parent && store.bot(parent.botId)?.approvePeerComms && !peerApprovalWaived(parent.botId, parent.threadId) && !node2.approvalGranted ? "Sender now requires peer approval; submit a new approved request" : void 0),
|
|
131139
131454
|
// A free slot admits fresh work beside a sibling that is actually running
|
|
131140
131455
|
// (#1589). A card waiting on the person still holds fresh work (#1128).
|
|
@@ -131870,7 +132185,7 @@ data: ${JSON.stringify({ ...narrowed, seq: seq2 })}
|
|
|
131870
132185
|
onSteeredQueueChange(() => broadcast({ kind: "bot.queued", queues: publicBotQueuedMessages() }));
|
|
131871
132186
|
var toolMessageByItem = /* @__PURE__ */ new Map();
|
|
131872
132187
|
var askMessageByRequest = /* @__PURE__ */ new Map();
|
|
131873
|
-
var approvalGrants = new ApprovalGrantStore(
|
|
132188
|
+
var approvalGrants = new ApprovalGrantStore(join145(DATA_DIR, "approval-grants.json"));
|
|
131874
132189
|
var grantCandidates = /* @__PURE__ */ new Map();
|
|
131875
132190
|
async function answerRequest(threadId, instanceId, requestId, behavior, message4, decidedFor, always) {
|
|
131876
132191
|
if (always && teamRoomsHost?.active.get(threadId)?.requestedByOwner === false) always = false;
|
|
@@ -132101,7 +132416,7 @@ function clearTurnDigestState(threadId) {
|
|
|
132101
132416
|
liveTurnByThread.delete(threadId);
|
|
132102
132417
|
memoryRowsByThread.delete(threadId);
|
|
132103
132418
|
}
|
|
132104
|
-
var TOOL_RESULTS_DIR =
|
|
132419
|
+
var TOOL_RESULTS_DIR = join145(DATA_DIR, "tool-results");
|
|
132105
132420
|
var TOOL_RESULT_SPILL_MAX = 512 * 1024;
|
|
132106
132421
|
var DIGESTS_AFTER_COMPACTION = 2;
|
|
132107
132422
|
function ingestEngineHook(capability, body) {
|
|
@@ -132143,10 +132458,10 @@ function ingestEngineHook(capability, body) {
|
|
|
132143
132458
|
if (!turnId || !row?.tool) return reply({ ok: true, ignored: "tool not observed in this turn" });
|
|
132144
132459
|
const key5 = `${threadId}:${turnId}:${toolUseId}`;
|
|
132145
132460
|
if (!commandReceipt("hook.ingest", key5)) {
|
|
132146
|
-
const dir =
|
|
132461
|
+
const dir = join145(TOOL_RESULTS_DIR, threadId.replace(/[^\w.-]/g, "_"));
|
|
132147
132462
|
mkdirSync77(dir, { recursive: true, mode: 448 });
|
|
132148
132463
|
const safeId = createHash57("sha256").update(key5).digest("hex");
|
|
132149
|
-
const file2 =
|
|
132464
|
+
const file2 = join145(dir, `${safeId}.txt`);
|
|
132150
132465
|
const redacted = redactSecretsInText(text19);
|
|
132151
132466
|
const bounded4 = redacted.length > TOOL_RESULT_SPILL_MAX ? `${redacted.slice(0, TOOL_RESULT_SPILL_MAX)}
|
|
132152
132467
|
[\u2026 ${redacted.length - TOOL_RESULT_SPILL_MAX} more characters omitted]` : redacted;
|
|
@@ -132250,7 +132565,7 @@ function recordNexusTurn(input, changedFiles, cwd) {
|
|
|
132250
132565
|
if (turnRows.some((row) => row.watch && row.watch.kind !== "answer")) return;
|
|
132251
132566
|
const room = store.groupByThread(input.threadId);
|
|
132252
132567
|
const task2 = store.taskByThread(bot.id, input.threadId);
|
|
132253
|
-
const roots = [cwd,
|
|
132568
|
+
const roots = [cwd, join145(WORKSPACES_DIR, bot.id), join145(TASK_WORKSPACES_DIR, bot.id, input.threadId), bot.cwd].filter((root) => typeof root === "string" && root.length > 0);
|
|
132254
132569
|
noteNexusLocalMemory(bot.id);
|
|
132255
132570
|
nexusMemory.recordTurn({
|
|
132256
132571
|
bot: nexusMemoryBot(bot),
|
|
@@ -132313,7 +132628,7 @@ var localVmThreadTargets = /* @__PURE__ */ new Map();
|
|
|
132313
132628
|
var localVmActiveThreads = /* @__PURE__ */ new Map();
|
|
132314
132629
|
var autoVmClaims = /* @__PURE__ */ new Map();
|
|
132315
132630
|
var LAZY_VM_CLAIM_GRACE_MS = 1500;
|
|
132316
|
-
var LOCAL_VM_TOOL_CACHE =
|
|
132631
|
+
var LOCAL_VM_TOOL_CACHE = join145(DATA_DIR, "local-vm-cua-tools.json");
|
|
132317
132632
|
function lazyLocalVmMount(status) {
|
|
132318
132633
|
if (!status?.runtime) return null;
|
|
132319
132634
|
if (status.ready) return { runtime: status.runtime, deferConnect: false };
|
|
@@ -137430,7 +137745,7 @@ function botInterviewContext(mode) {
|
|
|
137430
137745
|
}
|
|
137431
137746
|
const bridge = isChibitekMochii(parsed.server) || isChibitekNexus(parsed.server);
|
|
137432
137747
|
const spec = customMcpServers(cfg, [name2])[name2];
|
|
137433
|
-
const status = bridge && !(spec && mcpToolHints.seen(name2, spec)) ? "signIn" : "ready";
|
|
137748
|
+
const status = bridge && !mcpSignIn.signedIn(spec) && !(spec && mcpToolHints.seen(name2, spec)) ? "signIn" : "ready";
|
|
137434
137749
|
tools.push({ id: `mcp:${name2}`, kind: "mcp", name: isChibitekMochii(parsed.server) ? "mochii" : isChibitekNexus(parsed.server) ? "nexus" : name2, status });
|
|
137435
137750
|
}
|
|
137436
137751
|
const accounts = oauthAccounts.status();
|
|
@@ -138213,7 +138528,7 @@ function mcpServerResponse() {
|
|
|
138213
138528
|
const unavailable2 = mcpAccessNotices.get(server2.name) ?? mcpHealth.notice(server2.name, spec);
|
|
138214
138529
|
const auth = mcpAuthState.view(server2.name, spec);
|
|
138215
138530
|
const secrets = mcpServerSecretView(server2.name, cfg.mcpServers?.[server2.name]);
|
|
138216
|
-
return { ...listed, ...secrets, ...unavailable2 ? { unavailable: unavailable2 } : {}, ...auth ? { auth } : {} };
|
|
138531
|
+
return { ...listed, ...secrets, ...unavailable2 ? { unavailable: unavailable2 } : {}, ...auth ? { auth } : {}, ...mcpSignIn.signedInAs(spec) ? { chibitekSignIn: mcpSignIn.signedInAs(spec) } : {} };
|
|
138217
138532
|
});
|
|
138218
138533
|
return {
|
|
138219
138534
|
servers,
|
|
@@ -138340,7 +138655,7 @@ function reconcileAddonInstalls(retryFailed = false, overrideThreatScan = false)
|
|
|
138340
138655
|
broadcast({ kind: "config", ...configStatus() });
|
|
138341
138656
|
});
|
|
138342
138657
|
}
|
|
138343
|
-
var mcpToolHints = new McpToolHintStore(
|
|
138658
|
+
var mcpToolHints = new McpToolHintStore(join145(DATA_DIR, "mcp-tool-hints.json"));
|
|
138344
138659
|
var mcpAccessNotices = new McpAccessNotices();
|
|
138345
138660
|
function warmMcpToolHints(custom2) {
|
|
138346
138661
|
const eligible = Object.fromEntries(Object.entries(custom2).filter(([name2]) => mcpReadOnlyAutoAllow(cfg.mcpServers, name2)));
|
|
@@ -138354,19 +138669,20 @@ function warmMcpToolHints(custom2) {
|
|
|
138354
138669
|
return result;
|
|
138355
138670
|
}
|
|
138356
138671
|
if (result.notice) mcpAccessNotices.set(name2, result.notice);
|
|
138357
|
-
if (result.signInRequired) mcpAuthState.noteSignInRequired(name2, spec);
|
|
138672
|
+
if (result.signInRequired && !mcpSignIn.refused(name2, spec)) mcpAuthState.noteSignInRequired(name2, spec);
|
|
138358
138673
|
return result;
|
|
138359
138674
|
})).catch(() => {
|
|
138360
138675
|
});
|
|
138361
138676
|
}
|
|
138362
138677
|
}
|
|
138363
|
-
var mcpAuthState = new McpAuthStateStore(
|
|
138678
|
+
var mcpAuthState = new McpAuthStateStore(join145(DATA_DIR, "mcp-auth-state.json"));
|
|
138364
138679
|
var mcpHealth = new McpHealthStore();
|
|
138365
138680
|
var mcpTurn = mcpTurnPolicy({
|
|
138366
138681
|
auth: mcpAuthState,
|
|
138367
138682
|
health: mcpHealth,
|
|
138368
138683
|
signalDir: mcpAuthSignalDir,
|
|
138369
138684
|
specs: () => customMcpServers(cfg),
|
|
138685
|
+
credentialRefused: (name2, spec) => mcpSignIn.refused(name2, spec),
|
|
138370
138686
|
reportUnavailable: (threadId, detail) => {
|
|
138371
138687
|
const bot = store.botByThread(threadId);
|
|
138372
138688
|
if (bot) reportIncident({ kind: "mcp-unavailable", bot, threadId, detail });
|
|
@@ -138387,7 +138703,7 @@ function engineMcpServers(bot) {
|
|
|
138387
138703
|
const servers = mcpAccessNotices.without(
|
|
138388
138704
|
managedPolicy.filterMcp(customMcpServers(cfg, connectionsFor(bot, requested, personalCfg().connections.mcpServers)))
|
|
138389
138705
|
);
|
|
138390
|
-
for (const [name2, spec] of Object.entries(servers)) servers[name2] = bridgedMcpServer(spec, false);
|
|
138706
|
+
for (const [name2, spec] of Object.entries(servers)) servers[name2] = mcpSignIn.credentialed(bridgedMcpServer(spec, false));
|
|
138391
138707
|
return servers;
|
|
138392
138708
|
}
|
|
138393
138709
|
async function persistMcpServers(next, forceSecure) {
|
|
@@ -138597,15 +138913,15 @@ var claudeUpdatesInFlight = /* @__PURE__ */ new Set();
|
|
|
138597
138913
|
function serveStatic(res, path2) {
|
|
138598
138914
|
if (!STATIC_DIR) return false;
|
|
138599
138915
|
const safe3 = path2 === "/" ? "/index.html" : path2.replace(/\.\./g, "");
|
|
138600
|
-
const file2 =
|
|
138916
|
+
const file2 = join145(STATIC_DIR, safe3);
|
|
138601
138917
|
try {
|
|
138602
|
-
const data =
|
|
138918
|
+
const data = readFileSync112(file2);
|
|
138603
138919
|
res.writeHead(200, { "content-type": MIME3[extname7(file2)] ?? "application/octet-stream" });
|
|
138604
138920
|
res.end(data);
|
|
138605
138921
|
return true;
|
|
138606
138922
|
} catch {
|
|
138607
138923
|
try {
|
|
138608
|
-
const data =
|
|
138924
|
+
const data = readFileSync112(join145(STATIC_DIR, "index.html"));
|
|
138609
138925
|
res.writeHead(200, { "content-type": "text/html" });
|
|
138610
138926
|
res.end(data);
|
|
138611
138927
|
return true;
|
|
@@ -138827,6 +139143,7 @@ function watchAccess() {
|
|
|
138827
139143
|
}
|
|
138828
139144
|
var watchPolicy = () => ({ hipaa: workspaceHipaa().enabled, chibitekSignedIn: watchAccess().allowed });
|
|
138829
139145
|
onStikiSessionChange(() => broadcast({ kind: "config", ...configStatus() }));
|
|
139146
|
+
mcpSignIn.start();
|
|
138830
139147
|
var watchInputs = () => killSwitchInputs({ settings: switchLayer(cfg.watchAlong), managed: managedLayer(personalMdm.watchAlong()), remote: watchRemoteFlags.current() });
|
|
138831
139148
|
function watchGate(bot) {
|
|
138832
139149
|
return watchModelGate({ workspaceHipaa: workspaceHipaa().enabled, botHipaa: bot.hipaa === true });
|
|
@@ -139250,7 +139567,7 @@ ROUTES.push(createPersonalBotRoutes({
|
|
|
139250
139567
|
domains: [personalMdm.googleDomain(), chibitek ? "chibitek.com" : void 0],
|
|
139251
139568
|
hipaa: workspaceHipaa().enabled,
|
|
139252
139569
|
workspaceDirs: [paw.root],
|
|
139253
|
-
privateDirs: [
|
|
139570
|
+
privateDirs: [join145(paw.root, "me", "personal")]
|
|
139254
139571
|
}), ATTACHMENTS_DIR);
|
|
139255
139572
|
},
|
|
139256
139573
|
create: async (input, owner4) => {
|
|
@@ -139585,7 +139902,7 @@ ROUTES.push(createThreadImageRoutes({
|
|
|
139585
139902
|
size: (id) => {
|
|
139586
139903
|
if (!attachmentExists(id)) return null;
|
|
139587
139904
|
try {
|
|
139588
|
-
return statSync31(
|
|
139905
|
+
return statSync31(join145(ATTACHMENTS_DIR, id)).size;
|
|
139589
139906
|
} catch {
|
|
139590
139907
|
return null;
|
|
139591
139908
|
}
|
|
@@ -145640,7 +145957,7 @@ data: ${JSON.stringify({ kind: "ping" })}
|
|
|
145640
145957
|
if (!parsed.ok) return json2(res, 400, { error: parsed.error });
|
|
145641
145958
|
const testBlocked = mcpLaunchBlocker(parsed.server);
|
|
145642
145959
|
if (testBlocked) return json2(res, 409, { error: `${mcpTest[1]} cannot start yet: ${mcpLaunchBlockerReason(testBlocked)}`, code: testBlocked });
|
|
145643
|
-
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(bridgedMcpServer(parsed.server, true))) {
|
|
145960
|
+
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)))) {
|
|
145644
145961
|
return json2(res, 429, { error: "Two MCP connection tests are already running." });
|
|
145645
145962
|
}
|
|
145646
145963
|
const controller = new AbortController();
|
|
@@ -145650,7 +145967,7 @@ data: ${JSON.stringify({ kind: "ping" })}
|
|
|
145650
145967
|
res.once("close", disconnect);
|
|
145651
145968
|
mcpProbesInFlight += 1;
|
|
145652
145969
|
try {
|
|
145653
|
-
const probed2 = await interactiveMcpProbe(bridgedMcpServer(parsed.server, true), controller.signal);
|
|
145970
|
+
const probed2 = await mcpSignIn.probe(parsed.server, () => interactiveMcpProbe(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)), controller.signal));
|
|
145654
145971
|
if (probed2.ok) {
|
|
145655
145972
|
mcpAuthState.noteOk(mcpTest[1]);
|
|
145656
145973
|
mcpHealth.noteOk(mcpTest[1]);
|
|
@@ -145675,7 +145992,7 @@ data: ${JSON.stringify({ kind: "ping" })}
|
|
|
145675
145992
|
if (!parsed.ok) return json2(res, 400, { error: parsed.error });
|
|
145676
145993
|
const reconnectBlocked = mcpLaunchBlocker(parsed.server);
|
|
145677
145994
|
if (reconnectBlocked) return json2(res, 409, { error: `${name2} cannot start yet: ${mcpLaunchBlockerReason(reconnectBlocked)}`, code: reconnectBlocked });
|
|
145678
|
-
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(bridgedMcpServer(parsed.server, true))) {
|
|
145995
|
+
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)))) {
|
|
145679
145996
|
return json2(res, 429, { error: "Two MCP connection tests are already running." });
|
|
145680
145997
|
}
|
|
145681
145998
|
const controller = new AbortController();
|
|
@@ -145685,7 +146002,7 @@ data: ${JSON.stringify({ kind: "ping" })}
|
|
|
145685
146002
|
res.once("close", disconnect);
|
|
145686
146003
|
mcpProbesInFlight += 1;
|
|
145687
146004
|
try {
|
|
145688
|
-
const probed2 = await interactiveMcpProbe(bridgedMcpServer(parsed.server, true), controller.signal);
|
|
146005
|
+
const probed2 = await mcpSignIn.probe(parsed.server, () => interactiveMcpProbe(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)), controller.signal));
|
|
145689
146006
|
if (probed2.ok) {
|
|
145690
146007
|
mcpAuthState.noteOk(name2);
|
|
145691
146008
|
mcpHealth.noteOk(name2);
|