@chibitek/chibi 0.1.200 → 0.1.202
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-BqQaJQrc.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-BqQSwr1u.js → abnfDiagram-O67JEVCF-BCeO-FJ-.js} +1 -1
- package/dist/assets/{arc-T05LhWW8.js → arc-DAcyEY9g.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-D_ggH0yg.js → architectureDiagram-NJMV4G6O-Dwzl21OF.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-RE8mkopU.js → blockDiagram-BEXU5L5S-CB9lZurW.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BXtV9POP.js → c4Diagram-YGBWAQC7-enWMxZTY.js} +1 -1
- package/dist/assets/channel-DfJpivlk.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-7zaRJzef.js → chunk-2Q5K7J3B-CiQIhCM0.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BOxhuNM3.js → chunk-3FUC2YCW-LA3V3P14.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-Clc6Y-k_.js → chunk-5VM5RSS4-C24r0tJ3.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-D7IERUnR.js → chunk-GTNCS2PH-_BXj6Flz.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-8QL2NNrN.js → chunk-GWA4HPMP-CcOUNIER.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DKVMCjGt.js → chunk-JWPE2WC7-65CF3zSi.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-SlxDfy1G.js → chunk-NETBCI7D-33XJs1ao.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-CRtOamAr.js → chunk-WEXAMYUT-Bf108rcV.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Dapib2DP.js → chunk-XXDRQBXY-CPtVeZ9w.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-2D0I10Na.js → classDiagram-v2-NBCMYWYE-9IR2tQzs.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DF9qnXun.js → cose-bilkent-JH36ORCC-DCqYmLmJ.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DrAkyhcY.js → cynefin-OW5HDTMX-D21Oj5DP.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-KQpEcNdf.js → cynefinDiagram-VND7K2PF-DTbN6FwN.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BbJ2VQn6.js → dagre-6A5THRUB-CCmPZ43E.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BNzSyGUh.js → diagram-22UHCM2B-CJyMaY9z.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-DjjLDFUp.js → diagram-3UASUU5V-LKeJRoef.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DC5I0Rdi.js → diagram-ATOU4E4O-jjufFAkX.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-BrXM08dx.js → diagram-CDSNMT55-Dq3h17-z.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-C3YZl0Tw.js → diagram-MLGK6HIB-Ca97pK2N.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DN6TO0ne.js → diagram-MPIPVDR6-jRckT1gO.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-Z-Wj8D9u.js → ebnfDiagram-ZINNZB2B-BPaoE5L2.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-D0oWP8_p.js → elk-276RUBZZ-C6Y5YZAN.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BzPDI-qn.js → erDiagram-OPXOYQCR-k77jMxHA.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BYYAeWqA.js → flowDiagram-KWPJA3E3-Co1J8TdL.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-k6obyqY7.js → ganttDiagram-FUAMR5RP-DZqEDtow.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-DinY8xWJ.js → gitGraphDiagram-X574FWY7-B-noo13S.js} +1 -1
- package/dist/assets/{index-YyLa_0lt.js → index-BThKfVMa.js} +1 -1
- package/dist/assets/index-C36j3Mf7.css +1 -0
- package/dist/assets/{index-ChUqQMGu.js → index-D_v7jkw4.js} +137 -137
- package/dist/assets/{infoDiagram-VRGFBTTK-BW2C-iLy.js → infoDiagram-VRGFBTTK-BT5S_4rV.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DVMxtqNy.js → ishikawaDiagram-OU5B5YK6-CBIJFAO1.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-VBQwKC0m.js → journeyDiagram-ZHPQQLJL-DpfvTmha.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-BjkXxAFy.js → kanban-definition-PNTS6WVX-B_PzfC-4.js} +1 -1
- package/dist/assets/{linear-BvzB7a4B.js → linear-x7oeFpwu.js} +1 -1
- package/dist/assets/{mermaid.core-BINI6H7d.js → mermaid.core-CRUgO9rc.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-b73g38FN.js → mindmap-definition-NLK3R4M7-BRyqRB1b.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-B8b2xdaw.js → pegDiagram-GJSIUBJH-B40H6nbN.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmlfE59D.js → pieDiagram-5QR66LMP-I_zHV9hF.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-DO8GiPy0.js → quadrantDiagram-O4NWA36T-DuoQbk_z.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DJkdT4GR.js → railroadDiagram-XR7U4H2S-DRgi73Cb.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BAx14esZ.js → requirementDiagram-PLB6GJNP-B4uiAonn.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-CYlEooaw.js → sankeyDiagram-IPEJSGJF-Dzirs5sT.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-BTK7rivc.js → sequenceDiagram-PO4LG4MO-D07Gg-lu.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-6V9VYNKI.js → sizeCapture-INFHLROL-D-jPw2ZR.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-DVRTd965.js → stateDiagram-v2-GCMORJYK-CrQbI0yG.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-Bv1wYyTS.js → swimlanes-2SLR337P-S3fTHH2F.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-D4aUOLcM.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-BMnrjUM5.js → timeline-definition-EJHVYXUP-BcOKypXw.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-DQNQX-6S.js → usecaseDiagram-POWQR4AR-ekrATLwu.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Cnv1OiVG.js → vennDiagram-UO4OBE2U-BN23smbd.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Di1yp5Fs.js → wardleyDiagram-VNRHLVJA-ChulRrvn.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-B_sh_5r0.js → xychartDiagram-PMCCYNJV-NFJS73i9.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/companion/src/routes.js +5 -0
- package/dist-server/index.js +1947 -1487
- package/dist-server/openmausbot.js +36 -0
- package/dist-server/pair-cli.js +36 -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 +23 -15
- 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/import-offer-copy.js +9 -0
- package/dist-server/server/nexus-memory/import-offer.js +147 -0
- package/dist-server/server/nexus-memory/index.js +3 -3
- package/dist-server/server/repo-github.js +3 -1
- package/dist-server/server/routes/nexus-memory.js +15 -0
- 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/index-DBOyvapT.css +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Drv2GtYA.js +0 -8
|
@@ -33370,6 +33370,36 @@ var init_mcp_remote_bridge = __esm({
|
|
|
33370
33370
|
}
|
|
33371
33371
|
});
|
|
33372
33372
|
|
|
33373
|
+
// server/company-mcp-tenancy.ts
|
|
33374
|
+
var init_company_mcp_tenancy = __esm({
|
|
33375
|
+
"server/company-mcp-tenancy.ts"() {
|
|
33376
|
+
"use strict";
|
|
33377
|
+
}
|
|
33378
|
+
});
|
|
33379
|
+
|
|
33380
|
+
// server/stiki-session.ts
|
|
33381
|
+
var init_stiki_session = __esm({
|
|
33382
|
+
"server/stiki-session.ts"() {
|
|
33383
|
+
"use strict";
|
|
33384
|
+
}
|
|
33385
|
+
});
|
|
33386
|
+
|
|
33387
|
+
// server/chibitek-mcp-credentials.ts
|
|
33388
|
+
var STIKI_BEARER_ENV, STIKI_BEARER_HEADER_ARG, RESYNC_BEFORE_MS, MAX_RESYNC_MS, UNKNOWN_EXPIRY_MS;
|
|
33389
|
+
var init_chibitek_mcp_credentials = __esm({
|
|
33390
|
+
"server/chibitek-mcp-credentials.ts"() {
|
|
33391
|
+
"use strict";
|
|
33392
|
+
init_company_mcp_tenancy();
|
|
33393
|
+
init_mcp_remote_bridge();
|
|
33394
|
+
init_stiki_session();
|
|
33395
|
+
STIKI_BEARER_ENV = "ATOMIC_STIKI_ACCESS_TOKEN";
|
|
33396
|
+
STIKI_BEARER_HEADER_ARG = `Authorization:Bearer \${${STIKI_BEARER_ENV}}`;
|
|
33397
|
+
RESYNC_BEFORE_MS = 6 * 6e4;
|
|
33398
|
+
MAX_RESYNC_MS = 15 * 6e4;
|
|
33399
|
+
UNKNOWN_EXPIRY_MS = 10 * 6e4;
|
|
33400
|
+
}
|
|
33401
|
+
});
|
|
33402
|
+
|
|
33373
33403
|
// server/mcp-tool-hints.ts
|
|
33374
33404
|
function toolAnnotations(raw) {
|
|
33375
33405
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
@@ -33387,6 +33417,7 @@ var init_mcp_tool_hints = __esm({
|
|
|
33387
33417
|
"use strict";
|
|
33388
33418
|
init_mcp_tool_ref();
|
|
33389
33419
|
init_mcp_remote_bridge();
|
|
33420
|
+
init_chibitek_mcp_credentials();
|
|
33390
33421
|
HINT_KEYS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
|
|
33391
33422
|
SNAKE = {
|
|
33392
33423
|
readOnlyHint: "read_only_hint",
|
|
@@ -62326,6 +62357,11 @@ var ALLOWED = [
|
|
|
62326
62357
|
// on/off only. The full server list stays on the computer, since a local
|
|
62327
62358
|
// server's arguments can carry anything.
|
|
62328
62359
|
{ method: "GET", path: /^\/api\/mcp\/defaults$/ },
|
|
62360
|
+
// The Nexus memory-import offer the computer decides on (sign-in check
|
|
62361
|
+
// included): what to show, and the person's answer. Nothing else under
|
|
62362
|
+
// /api/nexus-memory is reachable from a phone.
|
|
62363
|
+
{ method: "GET", path: /^\/api\/nexus-memory\/import-offer$/ },
|
|
62364
|
+
{ method: "POST", path: /^\/api\/nexus-memory\/import-offer$/ },
|
|
62329
62365
|
// A marketplace connect card. The harness adds only Atomic's featured,
|
|
62330
62366
|
// vendor-run servers, threat-scans them and saves them switched off.
|
|
62331
62367
|
{ method: "POST", path: /^\/api\/mcp\/registry\/add$/ }
|
package/dist-server/pair-cli.js
CHANGED
|
@@ -33370,6 +33370,36 @@ var init_mcp_remote_bridge = __esm({
|
|
|
33370
33370
|
}
|
|
33371
33371
|
});
|
|
33372
33372
|
|
|
33373
|
+
// server/company-mcp-tenancy.ts
|
|
33374
|
+
var init_company_mcp_tenancy = __esm({
|
|
33375
|
+
"server/company-mcp-tenancy.ts"() {
|
|
33376
|
+
"use strict";
|
|
33377
|
+
}
|
|
33378
|
+
});
|
|
33379
|
+
|
|
33380
|
+
// server/stiki-session.ts
|
|
33381
|
+
var init_stiki_session = __esm({
|
|
33382
|
+
"server/stiki-session.ts"() {
|
|
33383
|
+
"use strict";
|
|
33384
|
+
}
|
|
33385
|
+
});
|
|
33386
|
+
|
|
33387
|
+
// server/chibitek-mcp-credentials.ts
|
|
33388
|
+
var STIKI_BEARER_ENV, STIKI_BEARER_HEADER_ARG, RESYNC_BEFORE_MS, MAX_RESYNC_MS, UNKNOWN_EXPIRY_MS;
|
|
33389
|
+
var init_chibitek_mcp_credentials = __esm({
|
|
33390
|
+
"server/chibitek-mcp-credentials.ts"() {
|
|
33391
|
+
"use strict";
|
|
33392
|
+
init_company_mcp_tenancy();
|
|
33393
|
+
init_mcp_remote_bridge();
|
|
33394
|
+
init_stiki_session();
|
|
33395
|
+
STIKI_BEARER_ENV = "ATOMIC_STIKI_ACCESS_TOKEN";
|
|
33396
|
+
STIKI_BEARER_HEADER_ARG = `Authorization:Bearer \${${STIKI_BEARER_ENV}}`;
|
|
33397
|
+
RESYNC_BEFORE_MS = 6 * 6e4;
|
|
33398
|
+
MAX_RESYNC_MS = 15 * 6e4;
|
|
33399
|
+
UNKNOWN_EXPIRY_MS = 10 * 6e4;
|
|
33400
|
+
}
|
|
33401
|
+
});
|
|
33402
|
+
|
|
33373
33403
|
// server/mcp-tool-hints.ts
|
|
33374
33404
|
function toolAnnotations(raw) {
|
|
33375
33405
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
@@ -33387,6 +33417,7 @@ var init_mcp_tool_hints = __esm({
|
|
|
33387
33417
|
"use strict";
|
|
33388
33418
|
init_mcp_tool_ref();
|
|
33389
33419
|
init_mcp_remote_bridge();
|
|
33420
|
+
init_chibitek_mcp_credentials();
|
|
33390
33421
|
HINT_KEYS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
|
|
33391
33422
|
SNAKE = {
|
|
33392
33423
|
readOnlyHint: "read_only_hint",
|
|
@@ -62326,6 +62357,11 @@ var ALLOWED = [
|
|
|
62326
62357
|
// on/off only. The full server list stays on the computer, since a local
|
|
62327
62358
|
// server's arguments can carry anything.
|
|
62328
62359
|
{ method: "GET", path: /^\/api\/mcp\/defaults$/ },
|
|
62360
|
+
// The Nexus memory-import offer the computer decides on (sign-in check
|
|
62361
|
+
// included): what to show, and the person's answer. Nothing else under
|
|
62362
|
+
// /api/nexus-memory is reachable from a phone.
|
|
62363
|
+
{ method: "GET", path: /^\/api\/nexus-memory\/import-offer$/ },
|
|
62364
|
+
{ method: "POST", path: /^\/api\/nexus-memory\/import-offer$/ },
|
|
62329
62365
|
// A marketplace connect card. The harness adds only Atomic's featured,
|
|
62330
62366
|
// vendor-run servers, threat-scans them and saves them switched off.
|
|
62331
62367
|
{ method: "POST", path: /^\/api\/mcp\/registry\/add$/ }
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// Atomic's Chibitek (Stiki) sign-in as the credential of Chibitek's own MCP
|
|
2
|
+
// servers, Nexus and Mochii (server/company-mcp-tenancy.ts).
|
|
3
|
+
//
|
|
4
|
+
// Both servers accept the person's Stiki access token as their bearer. So
|
|
5
|
+
// once someone signs in to Atomic with Chibitek (first-run setup or Settings,
|
|
6
|
+
// the same Electron-held session, electron/stiki-signin.mjs), every start of
|
|
7
|
+
// those two servers carries that token: no second browser OAuth, and no way
|
|
8
|
+
// for the MCP sign-in to drift onto a different or expired Stiki account.
|
|
9
|
+
//
|
|
10
|
+
// - A bridged entry (mcp-remote, the default) gets
|
|
11
|
+
// `--header Authorization:Bearer ${ATOMIC_STIKI_ACCESS_TOKEN}` on argv and
|
|
12
|
+
// the token itself only in its environment (mcp-remote expands the
|
|
13
|
+
// placeholder), plus ATOMIC_MCP_NO_BROWSER=1: a refused token exits 77
|
|
14
|
+
// instead of opening a sign-in page.
|
|
15
|
+
// - A remote (url) entry gets an Authorization header.
|
|
16
|
+
// - An entry that brings its own Authorization is the person's: untouched.
|
|
17
|
+
//
|
|
18
|
+
// The token is held in memory only, refreshed before it expires, and a turn
|
|
19
|
+
// reads it synchronously (`current()`). A token a server refuses asks Electron
|
|
20
|
+
// main for a refresh right away (`refreshAfterRejection()`); only when that
|
|
21
|
+
// yields nothing new does the usual sign-in back-off apply.
|
|
22
|
+
import { isChibitekMochii, isChibitekNexus, CHIBITEK_DEFAULT_MCP_SERVERS } from "./company-mcp-tenancy.js";
|
|
23
|
+
import { MCP_NO_BROWSER_ENV, mcpRemoteTarget } from "./mcp-remote-bridge.js";
|
|
24
|
+
import { onStikiSessionChange } from "./stiki-session.js";
|
|
25
|
+
/** The bridge's environment variable that holds the token. */
|
|
26
|
+
export const STIKI_BEARER_ENV = "ATOMIC_STIKI_ACCESS_TOKEN";
|
|
27
|
+
/** The `--header` value: a placeholder, never the token itself. */
|
|
28
|
+
export const STIKI_BEARER_HEADER_ARG = `Authorization:Bearer \${${STIKI_BEARER_ENV}}`;
|
|
29
|
+
/** A token with less than this left is not handed to a new start. */
|
|
30
|
+
const MIN_VALID_MS = 60_000;
|
|
31
|
+
/** Look again this long before the held token expires. */
|
|
32
|
+
const RESYNC_BEFORE_MS = 6 * 60_000;
|
|
33
|
+
/** And at least this often, so a refresh main did on its own is picked up. */
|
|
34
|
+
const MAX_RESYNC_MS = 15 * 60_000;
|
|
35
|
+
const MIN_RESYNC_MS = 30_000;
|
|
36
|
+
/** One forced refresh per this long, however many starts were refused. */
|
|
37
|
+
const REJECTION_REFRESH_MS = 60_000;
|
|
38
|
+
/** Without a readable `exp`, treat a token as good for this long. */
|
|
39
|
+
const UNKNOWN_EXPIRY_MS = 10 * 60_000;
|
|
40
|
+
function isAuthorizationHeaderArg(value) {
|
|
41
|
+
return typeof value === "string" && /^\s*authorization\s*:/i.test(value);
|
|
42
|
+
}
|
|
43
|
+
/** Does this bridge's own argv already carry an Authorization header? */
|
|
44
|
+
function bridgeHasOwnAuthorization(extraArgs) {
|
|
45
|
+
return extraArgs.some((arg, index) => arg === "--header-file" || (arg === "--header" && isAuthorizationHeaderArg(extraArgs[index + 1]) && extraArgs[index + 1] !== STIKI_BEARER_HEADER_ARG));
|
|
46
|
+
}
|
|
47
|
+
/** Is this one of Chibitek's MCP servers with no credential of its own, so
|
|
48
|
+
* the Chibitek sign-in should sign it in? */
|
|
49
|
+
export function takesStikiCredential(spec) {
|
|
50
|
+
if (!spec || !(isChibitekNexus(spec) || isChibitekMochii(spec)))
|
|
51
|
+
return false;
|
|
52
|
+
if ("url" in spec)
|
|
53
|
+
return !Object.keys(spec.headers ?? {}).some((name) => name.toLowerCase() === "authorization");
|
|
54
|
+
const target = mcpRemoteTarget(spec);
|
|
55
|
+
// Some other program that happens to reach the URL: not ours to sign in.
|
|
56
|
+
if (!target)
|
|
57
|
+
return false;
|
|
58
|
+
return !bridgeHasOwnAuthorization(target.extraArgs);
|
|
59
|
+
}
|
|
60
|
+
/** The spec to start with the person's Stiki token; anything that does not
|
|
61
|
+
* take it comes back unchanged (the same object). */
|
|
62
|
+
export function withStikiCredential(spec, token) {
|
|
63
|
+
if (!token || !takesStikiCredential(spec))
|
|
64
|
+
return spec;
|
|
65
|
+
if ("url" in spec)
|
|
66
|
+
return { ...spec, headers: { ...spec.headers, Authorization: `Bearer ${token}` } };
|
|
67
|
+
const args = spec.args.includes(STIKI_BEARER_HEADER_ARG) ? [...spec.args] : [...spec.args, "--header", STIKI_BEARER_HEADER_ARG];
|
|
68
|
+
return { ...spec, args, env: { ...spec.env, [STIKI_BEARER_ENV]: token, [MCP_NO_BROWSER_ENV]: "1" } };
|
|
69
|
+
}
|
|
70
|
+
/** The token's own `exp`, in ms, read only to know when to look again.
|
|
71
|
+
* Nothing is decided from it: the servers verify the token. */
|
|
72
|
+
export function stikiTokenExpiry(token) {
|
|
73
|
+
const payload = token.split(".")[1];
|
|
74
|
+
if (!payload)
|
|
75
|
+
return null;
|
|
76
|
+
try {
|
|
77
|
+
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
78
|
+
return typeof claims.exp === "number" && Number.isFinite(claims.exp) ? Math.floor(claims.exp * 1000) : null;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The Chibitek MCP defaults a config lacks (by name or by URL). */
|
|
85
|
+
export function missingChibitekMcpDefaults(servers) {
|
|
86
|
+
const entries = Object.entries(servers ?? {});
|
|
87
|
+
return CHIBITEK_DEFAULT_MCP_SERVERS.filter((server) => {
|
|
88
|
+
if (entries.some(([name]) => name === server.name))
|
|
89
|
+
return false;
|
|
90
|
+
return !entries.some(([, entry]) => (server.name === "nexus" ? isChibitekNexus(entry) : isChibitekMochii(entry)));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const sameCredential = (a, b) => a === b || (!!a && !!b && a.token === b.token && a.identity.userId === b.identity.userId);
|
|
94
|
+
export class ChibitekMcpCredentials {
|
|
95
|
+
held = null;
|
|
96
|
+
syncing = null;
|
|
97
|
+
syncAgain = null;
|
|
98
|
+
timer;
|
|
99
|
+
lastRejectionRefresh = Number.NEGATIVE_INFINITY;
|
|
100
|
+
stopListening = null;
|
|
101
|
+
deps;
|
|
102
|
+
now;
|
|
103
|
+
constructor(deps) {
|
|
104
|
+
this.deps = deps;
|
|
105
|
+
this.now = deps.now ?? Date.now;
|
|
106
|
+
}
|
|
107
|
+
/** Follow the sign-in: look now, on every sign-in change, and before the
|
|
108
|
+
* held token expires. */
|
|
109
|
+
start() {
|
|
110
|
+
if (this.stopListening)
|
|
111
|
+
return;
|
|
112
|
+
this.stopListening = onStikiSessionChange(() => void this.sync());
|
|
113
|
+
void this.sync();
|
|
114
|
+
}
|
|
115
|
+
stop() {
|
|
116
|
+
this.stopListening?.();
|
|
117
|
+
this.stopListening = null;
|
|
118
|
+
if (this.timer)
|
|
119
|
+
clearTimeout(this.timer);
|
|
120
|
+
this.timer = undefined;
|
|
121
|
+
}
|
|
122
|
+
/** The credential a start may use now, or null (signed out, or no token
|
|
123
|
+
* with time left). Synchronous: turns are assembled without waiting. */
|
|
124
|
+
current() {
|
|
125
|
+
const held = this.held;
|
|
126
|
+
if (!held)
|
|
127
|
+
return null;
|
|
128
|
+
if (held.expiresAt - this.now() <= MIN_VALID_MS) {
|
|
129
|
+
void this.sync();
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const signedIn = this.deps.session().identity();
|
|
133
|
+
if (!signedIn || signedIn.userId !== held.identity.userId) {
|
|
134
|
+
void this.sync();
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return held;
|
|
138
|
+
}
|
|
139
|
+
/** Read the session again (it refreshes a token close to expiry). A call
|
|
140
|
+
* while a read is running reads once more after it, so a sign-in change
|
|
141
|
+
* that lands mid-read is never answered with what was read before it. */
|
|
142
|
+
sync() {
|
|
143
|
+
if (this.syncing) {
|
|
144
|
+
this.syncAgain ??= this.syncing.then(() => {
|
|
145
|
+
this.syncAgain = null;
|
|
146
|
+
return this.sync();
|
|
147
|
+
});
|
|
148
|
+
return this.syncAgain;
|
|
149
|
+
}
|
|
150
|
+
this.syncing = this.read(false).finally(() => {
|
|
151
|
+
this.syncing = null;
|
|
152
|
+
});
|
|
153
|
+
return this.syncing;
|
|
154
|
+
}
|
|
155
|
+
/** A server refused the held token: ask for a fresh one now. True when a
|
|
156
|
+
* different token came back, so the refused start is worth retrying at
|
|
157
|
+
* once; false means the usual back-off should apply. */
|
|
158
|
+
async refreshAfterRejection() {
|
|
159
|
+
const before = this.held?.token ?? null;
|
|
160
|
+
if (this.now() - this.lastRejectionRefresh < REJECTION_REFRESH_MS) {
|
|
161
|
+
await this.syncing;
|
|
162
|
+
return Boolean(this.held && this.held.token !== before);
|
|
163
|
+
}
|
|
164
|
+
this.lastRejectionRefresh = this.now();
|
|
165
|
+
this.deps.log?.("a Chibitek MCP server refused the Chibitek sign-in; refreshing it");
|
|
166
|
+
const next = await this.read(true);
|
|
167
|
+
return Boolean(next && next.token !== before);
|
|
168
|
+
}
|
|
169
|
+
async read(force) {
|
|
170
|
+
const session = this.deps.session();
|
|
171
|
+
let token = null;
|
|
172
|
+
try {
|
|
173
|
+
token = force && session.refresh ? await session.refresh() : await session.accessToken();
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
token = null;
|
|
177
|
+
}
|
|
178
|
+
const identity = session.identity();
|
|
179
|
+
const next = token && identity
|
|
180
|
+
? { token, identity, expiresAt: stikiTokenExpiry(token) ?? this.now() + UNKNOWN_EXPIRY_MS }
|
|
181
|
+
: null;
|
|
182
|
+
const before = this.held;
|
|
183
|
+
this.held = next;
|
|
184
|
+
this.schedule();
|
|
185
|
+
if (!sameCredential(before, next)) {
|
|
186
|
+
const switched = (before?.identity.userId ?? null) !== (next?.identity.userId ?? null);
|
|
187
|
+
try {
|
|
188
|
+
this.deps.onChange?.(next, switched);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
this.deps.log?.(`Chibitek MCP sign-in listener failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return next;
|
|
195
|
+
}
|
|
196
|
+
schedule() {
|
|
197
|
+
if (this.timer)
|
|
198
|
+
clearTimeout(this.timer);
|
|
199
|
+
this.timer = undefined;
|
|
200
|
+
if (!this.held || !this.stopListening)
|
|
201
|
+
return;
|
|
202
|
+
const untilResync = this.held.expiresAt - RESYNC_BEFORE_MS - this.now();
|
|
203
|
+
const wait = Math.min(MAX_RESYNC_MS, Math.max(MIN_RESYNC_MS, untilResync));
|
|
204
|
+
this.timer = setTimeout(() => void this.sync(), wait);
|
|
205
|
+
this.timer.unref?.();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// The server side of "signing in to Atomic with Chibitek signs Nexus and
|
|
2
|
+
// Mochii in" (server/chibitek-mcp-credentials.ts holds the token itself):
|
|
3
|
+
//
|
|
4
|
+
// - every start of those servers carries the Stiki token (`credentialed`);
|
|
5
|
+
// - a refused token is refreshed at once instead of backing off
|
|
6
|
+
// (`refused`, `probe`), and only a refresh with nothing new backs off;
|
|
7
|
+
// - signing in installs any missing Nexus/Mochii entry, once per person,
|
|
8
|
+
// so a server that person removes afterwards stays removed (`install`);
|
|
9
|
+
// - a new token or another person clears what the old one was told
|
|
10
|
+
// (a stale "sign in again", or "not enabled for your organization").
|
|
11
|
+
//
|
|
12
|
+
// index.ts wires it; every dependency is read lazily because the sign-in is
|
|
13
|
+
// created before the stores it updates.
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { writeFileAtomic } from "./atomic.js";
|
|
17
|
+
import { ChibitekMcpCredentials, missingChibitekMcpDefaults, takesStikiCredential, withStikiCredential } from "./chibitek-mcp-credentials.js";
|
|
18
|
+
import { CHIBITEK_DEFAULT_MCP_SERVERS, mcpServerTarget } from "./company-mcp-tenancy.js";
|
|
19
|
+
import { MCP_REMOTE_PACKAGE } from "./mcp-featured-add.js";
|
|
20
|
+
const MARKER = "chibitek-mcp-signin.json";
|
|
21
|
+
export function createChibitekMcpSignIn(deps) {
|
|
22
|
+
const credentials = new ChibitekMcpCredentials({
|
|
23
|
+
session: deps.session,
|
|
24
|
+
now: deps.now,
|
|
25
|
+
log: deps.log,
|
|
26
|
+
onChange: (credential, switched) => {
|
|
27
|
+
for (const server of CHIBITEK_DEFAULT_MCP_SERVERS) {
|
|
28
|
+
const name = Object.entries(deps.servers() ?? {}).find(([key, entry]) => key === server.name || mcpServerTarget(entry) === server.url)?.[0] ?? server.name;
|
|
29
|
+
if (credential)
|
|
30
|
+
deps.authState().noteOk(name);
|
|
31
|
+
if (switched)
|
|
32
|
+
deps.notices().clear(name);
|
|
33
|
+
}
|
|
34
|
+
if (credential && switched)
|
|
35
|
+
void install();
|
|
36
|
+
deps.changed();
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const markerPath = join(deps.dataDir, MARKER);
|
|
40
|
+
const installedFor = () => {
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(readFileSync(markerPath, "utf8"));
|
|
43
|
+
return Array.isArray(parsed.installedFor) ? parsed.installedFor.filter((id) => typeof id === "string") : [];
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/** The entry a Chibitek default starts with: the bundled bridge, the same
|
|
50
|
+
* shape the desktop seeds (electron/chibitek-defaults.mjs). */
|
|
51
|
+
const entryFor = (name, url) => {
|
|
52
|
+
const bridge = deps.bridge();
|
|
53
|
+
return bridge
|
|
54
|
+
? { command: "node", args: [bridge, url], env: { CHIBITEK_MCP_BRAND: name }, enabled: true }
|
|
55
|
+
: { command: "npx", args: ["-y", MCP_REMOTE_PACKAGE, url], env: { CHIBITEK_MCP_BRAND: name }, enabled: true };
|
|
56
|
+
};
|
|
57
|
+
/** Install the missing Nexus/Mochii entries for whoever is signed in. */
|
|
58
|
+
async function install(attempt = 0) {
|
|
59
|
+
const identity = deps.session().identity();
|
|
60
|
+
if (!identity)
|
|
61
|
+
return [];
|
|
62
|
+
const already = installedFor();
|
|
63
|
+
if (already.includes(identity.userId))
|
|
64
|
+
return [];
|
|
65
|
+
const missing = missingChibitekMcpDefaults(deps.servers()).filter((server) => deps.mayInstall(server.name, server.url));
|
|
66
|
+
if (missing.length) {
|
|
67
|
+
const next = { ...deps.servers() };
|
|
68
|
+
for (const server of missing)
|
|
69
|
+
next[server.name] = entryFor(server.name, server.url);
|
|
70
|
+
try {
|
|
71
|
+
await deps.persist(next);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
// Another MCP change is being saved: try again shortly.
|
|
75
|
+
if (attempt < 5)
|
|
76
|
+
setTimeout(() => void install(attempt + 1), 5_000).unref?.();
|
|
77
|
+
else
|
|
78
|
+
deps.log(`could not install the Chibitek MCP servers: ${error instanceof Error ? error.message : String(error)}`);
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
deps.log(`signed in with Chibitek: installed ${missing.map((server) => server.name).join(", ")}`);
|
|
82
|
+
}
|
|
83
|
+
writeFileAtomic(markerPath, `${JSON.stringify({ installedFor: [...already, identity.userId] }, null, 2)}\n`);
|
|
84
|
+
if (missing.length)
|
|
85
|
+
deps.changed();
|
|
86
|
+
return missing.map((server) => server.name);
|
|
87
|
+
}
|
|
88
|
+
const signedIn = (spec) => Boolean(spec && credentials.current() && takesStikiCredential(spec));
|
|
89
|
+
return {
|
|
90
|
+
credentials,
|
|
91
|
+
install,
|
|
92
|
+
start: () => credentials.start(),
|
|
93
|
+
/** A start of `spec`, signed in with the Chibitek session when it takes one. */
|
|
94
|
+
credentialed(spec) {
|
|
95
|
+
const credential = credentials.current();
|
|
96
|
+
return credential ? withStikiCredential(spec, credential.token) : spec;
|
|
97
|
+
},
|
|
98
|
+
signedIn,
|
|
99
|
+
/** Who Settings says the server is signed in as, or undefined. */
|
|
100
|
+
signedInAs(spec) {
|
|
101
|
+
const credential = signedIn(spec) ? credentials.current() : null;
|
|
102
|
+
return credential ? { name: credential.identity.name } : undefined;
|
|
103
|
+
},
|
|
104
|
+
/** A signed-in start needed a sign-in: refresh the token now. True when
|
|
105
|
+
* this took over; a refresh with nothing new falls back to the back-off. */
|
|
106
|
+
refused(name, spec) {
|
|
107
|
+
if (!signedIn(spec))
|
|
108
|
+
return false;
|
|
109
|
+
void credentials.refreshAfterRejection().then((renewed) => {
|
|
110
|
+
if (!renewed)
|
|
111
|
+
deps.authState().noteSignInRequired(name, spec);
|
|
112
|
+
});
|
|
113
|
+
return true;
|
|
114
|
+
},
|
|
115
|
+
/** Settings' Test and Reconnect: a refused token is refreshed and the
|
|
116
|
+
* probe tried once more, never a browser. `start` builds the start. */
|
|
117
|
+
async probe(spec, run) {
|
|
118
|
+
const first = await run();
|
|
119
|
+
if (first.ok || first.signInRequired !== true || !signedIn(spec))
|
|
120
|
+
return first;
|
|
121
|
+
return (await credentials.refreshAfterRejection()) ? run() : first;
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
// error: "<a calm sentence for the person>" }`.
|
|
14
14
|
//
|
|
15
15
|
// So Atomic never sends an organization of its own: it connects as the person.
|
|
16
|
-
// What it does here is recognise these two servers (
|
|
17
|
-
//
|
|
16
|
+
// What it does here is recognise these two servers (Atomic's Chibitek sign-in
|
|
17
|
+
// signs them in: server/chibitek-mcp-signin.ts) and turn Nexus's "not enabled" answer into a calm
|
|
18
18
|
// notice that is shown as-is, instead of a failure.
|
|
19
19
|
/** Kept equal to CHIBITEK_MCP_SERVERS in electron/chibitek-defaults.mjs
|
|
20
20
|
* (company-mcp-tenancy.test.ts checks it). */
|
|
@@ -321,7 +321,7 @@ import { createSubscriptionBotRoutes } from "./routes/subscription-bots.js";
|
|
|
321
321
|
import { createTeamRoomsRoutes } from "./routes/team-rooms.js";
|
|
322
322
|
import { TeamRoomsHost } from "./team-rooms/host.js";
|
|
323
323
|
import { engineCanHideFiles, restrictIntegrations, roomPromptSections, roomTurnInput } from "./team-rooms/turn.js";
|
|
324
|
-
import { createNexusMemoryRoutes } from "./routes/nexus-memory.js";
|
|
324
|
+
import { createNexusMemoryRoutes, NexusImportOffer } from "./routes/nexus-memory.js";
|
|
325
325
|
import { createBoardRoutes } from "./routes/board.js";
|
|
326
326
|
import { readBoardFromNexus } from "./board/nexus-board.js";
|
|
327
327
|
import { LocalModelInventory, localModePlacement, machineMemory } from "./local-models-mode.js";
|
|
@@ -351,6 +351,7 @@ import { appClientEnabled, sourceEnabled } from "./watch-along/transcript-source
|
|
|
351
351
|
import { pastedTranscriptProvider } from "./watch-along/pasted-transcript.js";
|
|
352
352
|
import { publicTranscriptProvider } from "./watch-along/youtube-public-transcript.js";
|
|
353
353
|
import { onStikiSessionChange, setStikiSessionSource, stikiSession } from "./stiki-session.js";
|
|
354
|
+
import { createChibitekMcpSignIn } from "./chibitek-mcp-signin.js";
|
|
354
355
|
import { DesktopStikiSession } from "./stiki-desktop-session.js";
|
|
355
356
|
import { CLEANUP_INSTRUCTIONS } from "./dictation.js";
|
|
356
357
|
import { hipaaState } from "./hipaa.js";
|
|
@@ -1251,11 +1252,17 @@ const oauthAccounts = new OAuthAccounts({ vault: accountVault, clients: oauthCli
|
|
|
1251
1252
|
// private channel (server/mcp-secrets.ts).
|
|
1252
1253
|
if (DESKTOP_MANAGED && utilityParentPort)
|
|
1253
1254
|
setMcpSecretSender(postDesktopPrivateMessage);
|
|
1254
|
-
// The Chibitek sign-in (Team Rooms' identity): Electron main owns it and
|
|
1255
|
-
// pushes the current token here; signed out until it does.
|
|
1255
|
+
// The Chibitek sign-in (Team Rooms' identity, and Nexus's and Mochii's: server/chibitek-mcp-signin.ts): Electron main owns it and pushes the current token here; signed out until it does.
|
|
1256
1256
|
const desktopStiki = DESKTOP_MANAGED && utilityParentPort ? new DesktopStikiSession(postDesktopPrivateMessage) : null;
|
|
1257
1257
|
if (desktopStiki)
|
|
1258
1258
|
setStikiSessionSource(desktopStiki);
|
|
1259
|
+
const mcpSignIn = createChibitekMcpSignIn({ dataDir: DATA_DIR, session: stikiSession, servers: () => cfg.mcpServers, bridge: resolveMcpRemoteBridge, authState: () => mcpAuthState, notices: () => mcpAccessNotices, log: (line) => console.warn(`[chibitek-mcp] ${line}`), mayInstall: (name, url) => !hostedModels && !HOSTED_WORKSPACE && managedPolicy.mcpAllowed(name, url), changed: () => broadcast({ kind: "config", ...configStatus() }), persist: async (next) => { if (mcpConfigBusy)
|
|
1260
|
+
throw new Error("MCP servers are already being updated."); mcpConfigBusy = true; try {
|
|
1261
|
+
await persistMcpServers(next);
|
|
1262
|
+
}
|
|
1263
|
+
finally {
|
|
1264
|
+
mcpConfigBusy = false;
|
|
1265
|
+
} } });
|
|
1259
1266
|
/** Why this server may not run GOD MODE, or null. A shared or hosted
|
|
1260
1267
|
* workspace refuses it for the same reason it refuses a bot's Full access:
|
|
1261
1268
|
* there, only the operator's own shared-workspace policy may grant Full. */
|
|
@@ -2399,7 +2406,7 @@ setInterval(() => void refreshPersonalMdm(), 5 * 60_000).unref?.();
|
|
|
2399
2406
|
// MDM profile the Private Bot reads (NexusMemory, HipaaMode keys).
|
|
2400
2407
|
const nexusMemory = new NexusMemory({
|
|
2401
2408
|
dataDir: DATA_DIR,
|
|
2402
|
-
config: () => cfg,
|
|
2409
|
+
config: () => cfg, serverSpec: (spec) => spec && mcpSignIn.credentialed(spec), signIn: { refresh: () => mcpSignIn.credentials.refreshAfterRejection() },
|
|
2403
2410
|
// HIPAA mode is the one workspace switch (MDM, environment, or the
|
|
2404
2411
|
// Administrator's setting): patient-data items never go to Nexus.
|
|
2405
2412
|
mdm: () => ({ nexusMemoryAlways: personalMdm.nexusMemoryAlways(), hipaaManaged: workspaceHipaa().enabled }),
|
|
@@ -2438,7 +2445,7 @@ function noteNexusLocalMemory(botId) {
|
|
|
2438
2445
|
}
|
|
2439
2446
|
}
|
|
2440
2447
|
nexusMemory.start();
|
|
2441
|
-
const routineMochiiSync = RoutineMochiiSync.start({ dataDir: DATA_DIR, config: () => cfg, listRoutines: () => routines?.listRoutines() ?? [], listRuns: () => routines?.listRuns() ?? [], botName: (id) => store.bot(id)?.name, timeZone: () => routineTimeZone() });
|
|
2448
|
+
const 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() });
|
|
2442
2449
|
// Register the Private Bot's Nexus key as soon as there is a Private Bot, so
|
|
2443
2450
|
// nothing else can register first (Nexus trusts the first key).
|
|
2444
2451
|
// (Deferred: the store is created further down.)
|
|
@@ -13634,7 +13641,7 @@ function botInterviewContext(mode) {
|
|
|
13634
13641
|
// page nobody opened.
|
|
13635
13642
|
const bridge = isChibitekMochii(parsed.server) || isChibitekNexus(parsed.server);
|
|
13636
13643
|
const spec = customMcpServers(cfg, [name])[name];
|
|
13637
|
-
const status = bridge && !(spec && mcpToolHints.seen(name, spec)) ? "signIn" : "ready";
|
|
13644
|
+
const status = bridge && !mcpSignIn.signedIn(spec) && !(spec && mcpToolHints.seen(name, spec)) ? "signIn" : "ready";
|
|
13638
13645
|
tools.push({ id: `mcp:${name}`, kind: "mcp", name: isChibitekMochii(parsed.server) ? "mochii" : isChibitekNexus(parsed.server) ? "nexus" : name, status });
|
|
13639
13646
|
}
|
|
13640
13647
|
const accounts = oauthAccounts.status();
|
|
@@ -14561,7 +14568,7 @@ function mcpServerResponse() {
|
|
|
14561
14568
|
// which keys sit in the OS secure store, and what needs the person;
|
|
14562
14569
|
// names and ids only, never a value
|
|
14563
14570
|
const secrets = mcpServerSecretView(server.name, cfg.mcpServers?.[server.name]);
|
|
14564
|
-
return { ...listed, ...secrets, ...(unavailable ? { unavailable } : {}), ...(auth ? { auth } : {}) };
|
|
14571
|
+
return { ...listed, ...secrets, ...(unavailable ? { unavailable } : {}), ...(auth ? { auth } : {}), ...(mcpSignIn.signedInAs(spec) ? { chibitekSignIn: mcpSignIn.signedInAs(spec) } : {}) };
|
|
14565
14572
|
});
|
|
14566
14573
|
return {
|
|
14567
14574
|
servers,
|
|
@@ -14762,7 +14769,7 @@ function warmMcpToolHints(custom) {
|
|
|
14762
14769
|
if (result.notice)
|
|
14763
14770
|
mcpAccessNotices.set(name, result.notice);
|
|
14764
14771
|
// A background check is a background start: a missing sign-in backs the server off, never opens a browser.
|
|
14765
|
-
if (result.signInRequired)
|
|
14772
|
+
if (result.signInRequired && !mcpSignIn.refused(name, spec))
|
|
14766
14773
|
mcpAuthState.noteSignInRequired(name, spec);
|
|
14767
14774
|
return result;
|
|
14768
14775
|
})).catch(() => { });
|
|
@@ -14771,7 +14778,7 @@ function warmMcpToolHints(custom) {
|
|
|
14771
14778
|
/** Each configured server's sign-in state, and whether it is otherwise broken. */
|
|
14772
14779
|
const mcpAuthState = new McpAuthStateStore(join(DATA_DIR, "mcp-auth-state.json"));
|
|
14773
14780
|
const mcpHealth = new McpHealthStore();
|
|
14774
|
-
const mcpTurn = mcpTurnPolicy({ auth: mcpAuthState, health: mcpHealth, signalDir: mcpAuthSignalDir, specs: () => customMcpServers(cfg),
|
|
14781
|
+
const mcpTurn = mcpTurnPolicy({ auth: mcpAuthState, health: mcpHealth, signalDir: mcpAuthSignalDir, specs: () => customMcpServers(cfg), credentialRefused: (name, spec) => mcpSignIn.refused(name, spec),
|
|
14775
14782
|
reportUnavailable: (threadId, detail) => { const bot = store.botByThread(threadId); if (bot)
|
|
14776
14783
|
reportIncident({ kind: "mcp-unavailable", bot, threadId, detail }); } });
|
|
14777
14784
|
function syncMcpAuthState() { mcpTurn.sync(); }
|
|
@@ -14793,7 +14800,7 @@ function engineMcpServers(bot) {
|
|
|
14793
14800
|
// "nexus_not_enabled") is not mounted: no turn waits on a refusal.
|
|
14794
14801
|
const servers = mcpAccessNotices.without(managedPolicy.filterMcp(customMcpServers(cfg, connectionsFor(bot, requested, personalCfg().connections.mcpServers))));
|
|
14795
14802
|
for (const [name, spec] of Object.entries(servers))
|
|
14796
|
-
servers[name] = bridgedMcpServer(spec, false);
|
|
14803
|
+
servers[name] = mcpSignIn.credentialed(bridgedMcpServer(spec, false));
|
|
14797
14804
|
return servers;
|
|
14798
14805
|
}
|
|
14799
14806
|
/** Save `mcpServers`: secrets sealed in the desktop's encrypted store first,
|
|
@@ -15322,6 +15329,7 @@ function watchAccess() {
|
|
|
15322
15329
|
const watchPolicy = () => ({ hipaa: workspaceHipaa().enabled, chibitekSignedIn: watchAccess().allowed });
|
|
15323
15330
|
// Signing in or out of Stiki can change who sees Watch-Along.
|
|
15324
15331
|
onStikiSessionChange(() => broadcast({ kind: "config", ...configStatus() }));
|
|
15332
|
+
mcpSignIn.start(); // the Chibitek MCP sign-in's stores all exist by now
|
|
15325
15333
|
const watchInputs = () => killSwitchInputs({ settings: switchLayer(cfg.watchAlong), managed: managedLayer(personalMdm.watchAlong()), remote: watchRemoteFlags.current() });
|
|
15326
15334
|
/** HIPAA mode, the workspace's or the bot's own: no Watch-Along model call
|
|
15327
15335
|
* and no frame leaves this Mac. */
|
|
@@ -15701,7 +15709,7 @@ ROUTES.push(createNexusMemoryRoutes({
|
|
|
15701
15709
|
flush: () => nexusMemory.flush(),
|
|
15702
15710
|
items: (scope) => nexusMemory.listItems(scope),
|
|
15703
15711
|
forget: (kind, id) => nexusMemory.forget(kind, id),
|
|
15704
|
-
fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null,
|
|
15712
|
+
fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null, importOffer: new NexusImportOffer({ dataDir: DATA_DIR, enabled: () => nexusMemory.settings().connected && !nexusMemory.settings().personalConnection, session: stikiSession, client: () => nexusMemory.getClient(), botId: () => (store.personalBot() ?? store.bots[0])?.id ?? null }), // the first-connect memory-import offer (server/nexus-memory/import-offer.ts)
|
|
15705
15713
|
bots: {
|
|
15706
15714
|
find: (botId) => {
|
|
15707
15715
|
const bot = store.bot(botId);
|
|
@@ -23923,7 +23931,7 @@ const handleRequest = async (req, res) => {
|
|
|
23923
23931
|
const testBlocked = mcpLaunchBlocker(parsed.server);
|
|
23924
23932
|
if (testBlocked)
|
|
23925
23933
|
return json(res, 409, { error: `${mcpTest[1]} cannot start yet: ${mcpLaunchBlockerReason(testBlocked)}`, code: testBlocked });
|
|
23926
|
-
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(bridgedMcpServer(parsed.server, true))) {
|
|
23934
|
+
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)))) {
|
|
23927
23935
|
return json(res, 429, { error: "Two MCP connection tests are already running." });
|
|
23928
23936
|
}
|
|
23929
23937
|
const controller = new AbortController();
|
|
@@ -23936,7 +23944,7 @@ const handleRequest = async (req, res) => {
|
|
|
23936
23944
|
try {
|
|
23937
23945
|
// Test may open a browser even without ?connect=1. Keep its callback
|
|
23938
23946
|
// listener alive for the same MFA window as Reconnect.
|
|
23939
|
-
const probed = await interactiveMcpProbe(bridgedMcpServer(parsed.server, true), controller.signal);
|
|
23947
|
+
const probed = await mcpSignIn.probe(parsed.server, () => interactiveMcpProbe(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)), controller.signal));
|
|
23940
23948
|
if (probed.ok) {
|
|
23941
23949
|
mcpAuthState.noteOk(mcpTest[1]);
|
|
23942
23950
|
mcpHealth.noteOk(mcpTest[1]);
|
|
@@ -23975,7 +23983,7 @@ const handleRequest = async (req, res) => {
|
|
|
23975
23983
|
const reconnectBlocked = mcpLaunchBlocker(parsed.server);
|
|
23976
23984
|
if (reconnectBlocked)
|
|
23977
23985
|
return json(res, 409, { error: `${name} cannot start yet: ${mcpLaunchBlockerReason(reconnectBlocked)}`, code: reconnectBlocked });
|
|
23978
|
-
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(bridgedMcpServer(parsed.server, true))) {
|
|
23986
|
+
if (mcpProbesInFlight >= MAX_CONCURRENT_MCP_PROBES && !interactiveMcpProbe.has(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)))) {
|
|
23979
23987
|
return json(res, 429, { error: "Two MCP connection tests are already running." });
|
|
23980
23988
|
}
|
|
23981
23989
|
const controller = new AbortController();
|
|
@@ -23986,7 +23994,7 @@ const handleRequest = async (req, res) => {
|
|
|
23986
23994
|
res.once("close", disconnect);
|
|
23987
23995
|
mcpProbesInFlight += 1;
|
|
23988
23996
|
try {
|
|
23989
|
-
const probed = await interactiveMcpProbe(bridgedMcpServer(parsed.server, true), controller.signal);
|
|
23997
|
+
const probed = await mcpSignIn.probe(parsed.server, () => interactiveMcpProbe(mcpSignIn.credentialed(bridgedMcpServer(parsed.server, true)), controller.signal));
|
|
23990
23998
|
if (probed.ok) {
|
|
23991
23999
|
mcpAuthState.noteOk(name);
|
|
23992
24000
|
mcpHealth.noteOk(name);
|
|
@@ -22,6 +22,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
|
22
22
|
import { dirname } from "node:path";
|
|
23
23
|
import { MCP_TOOL_NAME as TOOL_NAME } from "../shared/mcp-tool-ref.js";
|
|
24
24
|
import { mcpRemoteTarget } from "./mcp-remote-bridge.js";
|
|
25
|
+
import { STIKI_BEARER_HEADER_ARG } from "./chibitek-mcp-credentials.js";
|
|
25
26
|
const HINT_KEYS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
|
|
26
27
|
const SNAKE = {
|
|
27
28
|
readOnlyHint: "read_only_hint",
|
|
@@ -49,6 +50,19 @@ export function toolAnnotations(raw) {
|
|
|
49
50
|
export function isReadOnlyMcpTool(annotations) {
|
|
50
51
|
return annotations?.readOnlyHint === true && annotations.destructiveHint !== true;
|
|
51
52
|
}
|
|
53
|
+
/** The Chibitek sign-in's header (server/chibitek-mcp-credentials.ts) is a
|
|
54
|
+
* credential, not a different server: a signed-in start is the same server. */
|
|
55
|
+
function withoutStikiHeader(args) {
|
|
56
|
+
const out = [];
|
|
57
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
58
|
+
if (args[index] === "--header" && args[index + 1] === STIKI_BEARER_HEADER_ARG) {
|
|
59
|
+
index += 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
out.push(args[index]);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
52
66
|
/** Identifies a server's transport target, never its credentials: hints
|
|
53
67
|
* learned from one command or address are not reused for another server
|
|
54
68
|
* that was later given the same name. */
|
|
@@ -58,7 +72,7 @@ export function mcpServerFingerprint(spec) {
|
|
|
58
72
|
const bridge = "url" in spec ? null : mcpRemoteTarget(spec);
|
|
59
73
|
const target = "url" in spec
|
|
60
74
|
? { type: spec.type, url: spec.url }
|
|
61
|
-
: bridge ? { mcpRemote: bridge.url, args: bridge.extraArgs } : { command: spec.command, args: spec.args };
|
|
75
|
+
: bridge ? { mcpRemote: bridge.url, args: withoutStikiHeader(bridge.extraArgs) } : { command: spec.command, args: spec.args };
|
|
62
76
|
return createHash("sha256").update(JSON.stringify(target)).digest("hex").slice(0, 32);
|
|
63
77
|
}
|
|
64
78
|
/** Hints older than this are not trusted at all: a tool that changed from a
|
|
@@ -7,7 +7,8 @@ export function mcpTurnPolicy(deps) {
|
|
|
7
7
|
if (!signals.length)
|
|
8
8
|
return;
|
|
9
9
|
const specs = deps.specs();
|
|
10
|
-
deps.
|
|
10
|
+
const refused = (signal) => signal.kind === "sign-in-required" && Boolean(specs[signal.name]) && deps.credentialRefused?.(signal.name, specs[signal.name]) === true;
|
|
11
|
+
deps.auth.ingest(signals.filter((signal) => !refused(signal)), specs);
|
|
11
12
|
for (const signal of deps.health.ingest(signals, specs)) {
|
|
12
13
|
if (signal.threadId)
|
|
13
14
|
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`);
|