@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.
Files changed (78) hide show
  1. package/dist/assets/{TerminalPanel-DUfFZmEG.js → TerminalPanel-CF3ynjQ5.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-BqQSwr1u.js → abnfDiagram-O67JEVCF-DsLr5Rkp.js} +1 -1
  3. package/dist/assets/{arc-T05LhWW8.js → arc-BP9MW1JT.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-D_ggH0yg.js → architectureDiagram-NJMV4G6O-DqqmVruY.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-RE8mkopU.js → blockDiagram-BEXU5L5S-DCZycPW_.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-BXtV9POP.js → c4Diagram-YGBWAQC7-DAt7A5JI.js} +1 -1
  7. package/dist/assets/channel-CfAu_VOE.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-7zaRJzef.js → chunk-2Q5K7J3B-D4XUKzBr.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-BOxhuNM3.js → chunk-3FUC2YCW-BvKRlW0a.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-Clc6Y-k_.js → chunk-5VM5RSS4-CpaqfcXB.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-D7IERUnR.js → chunk-GTNCS2PH-bFX_YBLa.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-8QL2NNrN.js → chunk-GWA4HPMP-D4ceVX3-.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-DKVMCjGt.js → chunk-JWPE2WC7-BrM5oyHo.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-SlxDfy1G.js → chunk-NETBCI7D-DJCITo_6.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-CRtOamAr.js → chunk-WEXAMYUT-DE5Rbq8q.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-Dapib2DP.js → chunk-XXDRQBXY-C6QndzP7.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-2D0I10Na.js → classDiagram-v2-NBCMYWYE-DupxtheF.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-DF9qnXun.js → cose-bilkent-JH36ORCC-K2_JJ1Os.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-DrAkyhcY.js → cynefin-OW5HDTMX-D1iCt_1r.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-KQpEcNdf.js → cynefinDiagram-VND7K2PF-BxIP-LPT.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-BbJ2VQn6.js → dagre-6A5THRUB-C9f6kI0w.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-BNzSyGUh.js → diagram-22UHCM2B-DX1Js_iQ.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-DjjLDFUp.js → diagram-3UASUU5V-Dok5oHqH.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-DC5I0Rdi.js → diagram-ATOU4E4O-CZjPw12I.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-BrXM08dx.js → diagram-CDSNMT55-CcdGyWm0.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-C3YZl0Tw.js → diagram-MLGK6HIB-BuyhR8Yt.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-DN6TO0ne.js → diagram-MPIPVDR6-DyfzZWWJ.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-Z-Wj8D9u.js → ebnfDiagram-ZINNZB2B-DbX8lcW9.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-D0oWP8_p.js → elk-276RUBZZ-B_1y08rH.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-BzPDI-qn.js → erDiagram-OPXOYQCR-CMNLleGm.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-BYYAeWqA.js → flowDiagram-KWPJA3E3-BWNxAxrN.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-k6obyqY7.js → ganttDiagram-FUAMR5RP-DIbuHGn_.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-DinY8xWJ.js → gitGraphDiagram-X574FWY7-DOQ7lEBd.js} +1 -1
  34. package/dist/assets/{index-ChUqQMGu.js → index-AVvV2BDP.js} +6 -6
  35. package/dist/assets/{index-YyLa_0lt.js → index-DwCyxkQ-.js} +1 -1
  36. package/dist/assets/{infoDiagram-VRGFBTTK-BW2C-iLy.js → infoDiagram-VRGFBTTK-B6jXr3vk.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-DVMxtqNy.js → ishikawaDiagram-OU5B5YK6-BMzUYIuP.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-VBQwKC0m.js → journeyDiagram-ZHPQQLJL-BSna9Sw4.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-BjkXxAFy.js → kanban-definition-PNTS6WVX-nGY_xsmB.js} +1 -1
  40. package/dist/assets/{linear-BvzB7a4B.js → linear-ClawroOG.js} +1 -1
  41. package/dist/assets/{mermaid.core-BINI6H7d.js → mermaid.core-QWILSY7q.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-b73g38FN.js → mindmap-definition-NLK3R4M7-BHBjOj_N.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-B8b2xdaw.js → pegDiagram-GJSIUBJH-BEhI0umY.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DmlfE59D.js → pieDiagram-5QR66LMP-BNrNnFcF.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-DO8GiPy0.js → quadrantDiagram-O4NWA36T-DU8ZKo3R.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-DJkdT4GR.js → railroadDiagram-XR7U4H2S-CXpikGSY.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-BAx14esZ.js → requirementDiagram-PLB6GJNP-T2kWY6dy.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-CYlEooaw.js → sankeyDiagram-IPEJSGJF-DUVsoHCX.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-BTK7rivc.js → sequenceDiagram-PO4LG4MO-BqI-CnQQ.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-6V9VYNKI.js → sizeCapture-INFHLROL-CHRKcWjb.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-DVRTd965.js → stateDiagram-v2-GCMORJYK-Drb1kh-m.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-Bv1wYyTS.js → swimlanes-2SLR337P-D6bNO7iC.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-BBg0kB8F.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-BMnrjUM5.js → timeline-definition-EJHVYXUP-30UJPQln.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-DQNQX-6S.js → usecaseDiagram-POWQR4AR-CsfAqILe.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-Cnv1OiVG.js → vennDiagram-UO4OBE2U-D63qiwyq.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-Di1yp5Fs.js → wardleyDiagram-VNRHLVJA-CwMexqnm.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-B_sh_5r0.js → xychartDiagram-PMCCYNJV-DFkAUNxr.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/dist-server/index.js +415 -98
  61. package/dist-server/openmausbot.js +31 -0
  62. package/dist-server/pair-cli.js +31 -0
  63. package/dist-server/server/chibitek-mcp-credentials.js +207 -0
  64. package/dist-server/server/chibitek-mcp-signin.js +124 -0
  65. package/dist-server/server/company-mcp-tenancy.js +2 -2
  66. package/dist-server/server/index.js +21 -13
  67. package/dist-server/server/mcp-tool-hints.js +15 -1
  68. package/dist-server/server/mcp-turn.js +2 -1
  69. package/dist-server/server/nexus-memory/backoff.js +40 -8
  70. package/dist-server/server/nexus-memory/client.js +44 -12
  71. package/dist-server/server/nexus-memory/index.js +3 -3
  72. package/dist-server/server/repo-github.js +3 -1
  73. package/dist-server/server/routine-mochii-sync.js +1 -1
  74. package/dist-server/server/stiki-desktop-session.js +18 -5
  75. package/dist-server/server/stiki-session.js +3 -2
  76. package/package.json +1 -1
  77. package/dist/assets/channel--GPtxJe9.js +0 -1
  78. package/dist/assets/swimlanesDiagram-TC7HE7FX-Drv2GtYA.js +0 -8
@@ -1,7 +1,7 @@
1
- import { NexusInitializeError, NexusUnavailableError } from "./client.js";
1
+ import { NexusAuthError, NexusInitializeError, NexusUnavailableError } from "./client.js";
2
2
  // One shared wait after Nexus fails: 1, 5, 15, then 30 minutes while the
3
- // outage lasts (unreachable, or signed out, which makes the bridge open a
4
- // sign-in page). A failure more than an hour after the previous one is a
3
+ // outage lasts (unreachable, or a refused sign-in that a refresh could not
4
+ // fix). A failure more than an hour after the previous one is a
5
5
  // new blip and starts over at one minute, so a night of Wi-Fi drops does
6
6
  // not leave every later call blocked for half an hour.
7
7
  const WAITS_MS = [60_000, 300_000, 900_000, 1_800_000];
@@ -27,20 +27,48 @@ export class UnavailableBackoff {
27
27
  }
28
28
  }
29
29
  /** One failed initialize is retried and does not count. The retry failing
30
- * trips the breaker. Any other outage trips immediately. */
31
- export function guardNexusClient(client, backoff, now, log) {
30
+ * trips the breaker. A refused sign-in (NexusAuthError) is not an outage: it
31
+ * refreshes the Chibitek sign-in and retries at once on a client built with
32
+ * the new token; only when no new token comes back does it trip the breaker.
33
+ * Any other outage trips immediately.
34
+ *
35
+ * `client` may be a getter so a retry after a refresh reaches the client the
36
+ * new token built (nexus-memory/index.ts rebuilds it when the spec changes). */
37
+ export function guardNexusClient(client, backoff, now, log, signIn) {
38
+ const current = () => {
39
+ const resolved = typeof client === "function" ? client() : client;
40
+ if (!resolved)
41
+ throw new NexusUnavailableError("Nexus is not connected on this computer");
42
+ return resolved;
43
+ };
32
44
  const finish = async (tool, args, timeoutMs) => {
33
45
  try {
34
- const result = await client.call(tool, args, timeoutMs);
46
+ const result = await current().call(tool, args, timeoutMs);
35
47
  backoff.succeeded();
36
48
  return result;
37
49
  }
38
50
  catch (error) {
39
- if (!(error instanceof NexusInitializeError) && error instanceof NexusUnavailableError)
51
+ if (!(error instanceof NexusInitializeError) && !(error instanceof NexusAuthError) && error instanceof NexusUnavailableError)
40
52
  backoff.failed(now());
41
53
  throw error;
42
54
  }
43
55
  };
56
+ const afterSignInRefused = async (error, tool, args, timeoutMs) => {
57
+ if (signIn && await signIn.refresh().catch(() => false)) {
58
+ log("Nexus refused the sign-in; refreshed the Chibitek sign-in and retrying now");
59
+ try {
60
+ return await finish(tool, args, timeoutMs);
61
+ }
62
+ catch (again) {
63
+ if (again instanceof NexusAuthError || again instanceof NexusInitializeError)
64
+ backoff.failed(now());
65
+ throw again;
66
+ }
67
+ }
68
+ // Nothing new to try: wait like any outage rather than resend a refused token.
69
+ backoff.failed(now());
70
+ throw error;
71
+ };
44
72
  return {
45
73
  call: async (tool, args, timeoutMs) => {
46
74
  const remaining = backoff.remainingMs(now());
@@ -50,6 +78,8 @@ export function guardNexusClient(client, backoff, now, log) {
50
78
  return await finish(tool, args, timeoutMs);
51
79
  }
52
80
  catch (error) {
81
+ if (error instanceof NexusAuthError)
82
+ return afterSignInRefused(error, tool, args, timeoutMs);
53
83
  if (!(error instanceof NexusInitializeError))
54
84
  throw error;
55
85
  log("Nexus initialize failed; retrying once");
@@ -57,12 +87,14 @@ export function guardNexusClient(client, backoff, now, log) {
57
87
  return await finish(tool, args, timeoutMs);
58
88
  }
59
89
  catch (again) {
90
+ if (again instanceof NexusAuthError)
91
+ return afterSignInRefused(again, tool, args, timeoutMs);
60
92
  if (again instanceof NexusInitializeError)
61
93
  backoff.failed(now());
62
94
  throw again;
63
95
  }
64
96
  }
65
97
  },
66
- close: () => client.close(),
98
+ close: () => current().close(),
67
99
  };
68
100
  }
@@ -1,7 +1,8 @@
1
- // How the harness itself calls Nexus tools. Atomic holds no Nexus token: bots
2
- // reach Nexus through the configured `nexus` MCP server, which on a Chibitek
3
- // install is the bundled mcp-remote bridge holding the person's own Stiki
4
- // sign-in in its own cache. The harness speaks MCP to that same server, so
1
+ // How the harness itself calls Nexus tools. Bots reach Nexus through the
2
+ // configured `nexus` MCP server: on a Chibitek install, the bundled mcp-remote
3
+ // bridge carrying the person's Chibitek (Stiki) sign-in from Atomic itself
4
+ // (server/chibitek-mcp-credentials.ts), or its own cached browser sign-in
5
+ // when nobody signed in to Atomic. The harness speaks MCP to that same server, so
5
6
  // every write lands under the signed-in person and no auth code changes.
6
7
  // A remote `nexus` entry (url + headers) is spoken to over HTTP instead.
7
8
  import { PROVIDER_CREDENTIAL_ENV, stripWorkspaceCredentialEnv } from "../config.js";
@@ -9,6 +10,7 @@ import { augmentedPath } from "../env-path.js";
9
10
  import { createLineSplitter } from "../mcp-bridge.js";
10
11
  import { McpHttpError, RemoteMcpClient } from "../mcp-http.js";
11
12
  import { isRemoteMcpServer } from "../mcp-registry.js";
13
+ import { exitMeansSignInRequired, MCP_SIGN_IN_REQUIRED_MARKER } from "../mcp-remote-bridge.js";
12
14
  import { killCliTree, spawnCli } from "../procs.js";
13
15
  /** Nexus could not be reached (offline, signed out, timed out): retry later. */
14
16
  export class NexusUnavailableError extends Error {
@@ -24,6 +26,15 @@ export class NexusInitializeError extends NexusUnavailableError {
24
26
  this.name = "NexusInitializeError";
25
27
  }
26
28
  }
29
+ /** Nexus refused the sign-in (401, an expired or rejected token, or a bridge
30
+ * that would need a browser sign-in). Not an outage: the caller refreshes the
31
+ * Chibitek sign-in and retries at once (backoff.ts). */
32
+ export class NexusAuthError extends NexusUnavailableError {
33
+ constructor(message) {
34
+ super(message);
35
+ this.name = "NexusAuthError";
36
+ }
37
+ }
27
38
  /** Nexus answered and refused this call (bad input): retrying will not help. */
28
39
  export class NexusRejectedError extends Error {
29
40
  constructor(message) {
@@ -35,7 +46,15 @@ const DEFAULT_TIMEOUT_MS = 20_000;
35
46
  const PROTOCOL_VERSION = "2025-06-18";
36
47
  /** Messages that mean "try again later", not "this input is wrong". */
37
48
  const PRIVATE_SCOPE_ANSWER = /\b(?:private_scope_\w+|private_proof_invalid|personal_scope_requires_private_bot|personal_memory_cannot_be_shared)\b/;
38
- const TRANSIENT = /unauthori[sz]ed|sign ?in|token|timed? ?out|timeout|ECONN|ENOTFOUND|EAI_AGAIN|fetch failed|network|socket|503|502|504|429|temporar|unavailable|not provisioned/i;
49
+ /** Messages that mean "the sign-in was refused", checked before TRANSIENT. */
50
+ const AUTH_REFUSED = /unauthori[sz]ed|sign ?in|\btoken\b|\b401\b|ATOMIC_MCP_SIGN_IN_REQUIRED/i;
51
+ const TRANSIENT = /timed? ?out|timeout|ECONN|ENOTFOUND|EAI_AGAIN|fetch failed|network|socket|503|502|504|429|temporar|unavailable|not provisioned/i;
52
+ /** The error a refusal message stands for: sign-in, try-later, or final. */
53
+ function refusalError(message) {
54
+ if (AUTH_REFUSED.test(message))
55
+ return new NexusAuthError(message);
56
+ return TRANSIENT.test(message) ? new NexusUnavailableError(message) : new NexusRejectedError(message);
57
+ }
39
58
  const BRIDGE_URL = /https?:\/\/[^\s"'<>]+/gi;
40
59
  const BRIDGE_SECRET = /\b(bearer|token|access_token|refresh_token|id_token|authorization|client_secret|api[_-]?key|password|code)\b(\s*[:=]\s*)\S+/gi;
41
60
  const BRIDGE_JWT = /\beyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]{8,}){2}\b/g;
@@ -73,7 +92,7 @@ export function parseToolResult(result) {
73
92
  // Nexus's private-scope answers are final, never "try later" (chibitek/nexus#151).
74
93
  if (PRIVATE_SCOPE_ANSWER.test(message))
75
94
  throw new NexusRejectedError(message);
76
- throw TRANSIENT.test(message) ? new NexusUnavailableError(message) : new NexusRejectedError(message);
95
+ throw refusalError(message);
77
96
  }
78
97
  return parsed;
79
98
  }
@@ -93,13 +112,15 @@ class HttpNexusClient {
93
112
  }
94
113
  catch (error) {
95
114
  await client.close().catch(() => undefined);
115
+ if (error instanceof McpHttpError && error.kind === "status" && error.status === 401)
116
+ throw new NexusAuthError("Nexus answered HTTP 401");
96
117
  throw new NexusInitializeError(error instanceof Error ? error.message : "Nexus initialize failed");
97
118
  }
98
119
  this.client = client;
99
120
  return client;
100
121
  })().catch((error) => {
101
122
  this.ready = null;
102
- throw error instanceof NexusInitializeError ? error : new NexusInitializeError(error instanceof Error ? error.message : "Nexus initialize failed");
123
+ throw error instanceof NexusInitializeError || error instanceof NexusAuthError ? error : new NexusInitializeError(error instanceof Error ? error.message : "Nexus initialize failed");
103
124
  });
104
125
  return this.ready;
105
126
  }
@@ -114,6 +135,9 @@ class HttpNexusClient {
114
135
  throw error;
115
136
  // A dropped session must re-handshake next time.
116
137
  await this.reset();
138
+ if (error instanceof McpHttpError && error.kind === "status" && error.status === 401) {
139
+ throw new NexusAuthError("Nexus answered HTTP 401");
140
+ }
117
141
  if (error instanceof McpHttpError && error.kind === "status" && error.status && error.status < 500 && ![401, 403, 408, 429].includes(error.status)) {
118
142
  throw new NexusRejectedError(`Nexus answered HTTP ${error.status}`);
119
143
  }
@@ -217,7 +241,7 @@ class StdioNexusClient {
217
241
  clearTimeout(entry.timer);
218
242
  if (frame.error !== undefined) {
219
243
  const message = isRecord(frame.error) && typeof frame.error.message === "string" ? frame.error.message : "Nexus error";
220
- entry.reject(TRANSIENT.test(message) ? new NexusUnavailableError(message) : new NexusRejectedError(message));
244
+ entry.reject(refusalError(message));
221
245
  }
222
246
  else
223
247
  entry.resolve(frame.result);
@@ -225,7 +249,10 @@ class StdioNexusClient {
225
249
  child.stdout.on("data", (chunk) => splitter.push(chunk));
226
250
  let logged = 0;
227
251
  let handshook = false;
252
+ let signInRefused = false;
228
253
  const errSplit = createLineSplitter((line) => {
254
+ if (line.includes(MCP_SIGN_IN_REQUIRED_MARKER))
255
+ signInRefused = true;
229
256
  const redacted = redactBridgeLine(line);
230
257
  // ponytail: 20 lines per child; raise if a handshake needs more of the log
231
258
  if (!redacted || logged >= 20)
@@ -234,14 +261,19 @@ class StdioNexusClient {
234
261
  this.log?.(`bridge: ${redacted}`);
235
262
  });
236
263
  child.stderr.on("data", (chunk) => errSplit.push(chunk));
237
- const gone = (message) => {
264
+ const gone = (message, code) => {
238
265
  errSplit.flush();
239
266
  if (this.child !== child)
240
267
  return;
241
- this.fail(handshook ? new NexusUnavailableError(message) : new NexusInitializeError(message));
268
+ // The bridge exits 77 when the server refused its sign-in and it may
269
+ // not open a browser (server/mcp-remote-bridge.ts).
270
+ if (signInRefused || exitMeansSignInRequired(code ?? null))
271
+ this.fail(new NexusAuthError("Nexus refused the sign-in"));
272
+ else
273
+ this.fail(handshook ? new NexusUnavailableError(message) : new NexusInitializeError(message));
242
274
  };
243
275
  child.once("error", () => gone("Nexus bridge failed"));
244
- child.once("close", () => gone("Nexus bridge stopped"));
276
+ child.once("close", (code) => gone("Nexus bridge stopped", code));
245
277
  await this.send("initialize", {
246
278
  protocolVersion: PROTOCOL_VERSION,
247
279
  capabilities: {},
@@ -252,7 +284,7 @@ class StdioNexusClient {
252
284
  })().catch((error) => {
253
285
  const message = error instanceof Error ? error.message : String(error);
254
286
  this.fail(error instanceof Error ? error : new Error(message));
255
- throw error instanceof NexusInitializeError ? error : new NexusInitializeError(message);
287
+ throw error instanceof NexusInitializeError || error instanceof NexusAuthError ? error : new NexusInitializeError(message);
256
288
  });
257
289
  return this.ready;
258
290
  }
@@ -171,8 +171,8 @@ export class NexusMemory {
171
171
  this.client ??= this.deps.clientFor(cfg);
172
172
  return this.client;
173
173
  }
174
- const spec = customMcpServers(cfg).nexus;
175
- const key = JSON.stringify(spec ?? null);
174
+ const spec = this.deps.serverSpec ? this.deps.serverSpec(customMcpServers(cfg).nexus) : customMcpServers(cfg).nexus;
175
+ const key = JSON.stringify(spec ?? null); // holds a mounted token (memory only): a refreshed token builds a new client
176
176
  if (key !== this.clientKey) {
177
177
  void this.client?.close();
178
178
  this.client = nexusClientFor(spec, (message) => this.log(message));
@@ -185,7 +185,7 @@ export class NexusMemory {
185
185
  const client = this.rawClient();
186
186
  if (!client)
187
187
  return null;
188
- return guardNexusClient(client, this.backoff, this.now, this.log);
188
+ return guardNexusClient(() => this.rawClient(), this.backoff, this.now, this.log, this.deps.signIn);
189
189
  }
190
190
  // ── the Private Bot's signed calls ─────────────────────────────────────
191
191
  privateKey() {
@@ -13,10 +13,12 @@ export const GITHUB_REPO_NAME = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\/[A-Za-z0-9_
13
13
  const LIST_URL = "user/repos?per_page=100&sort=pushed&affiliation=owner,collaborator,organization_member";
14
14
  const JOB_TTL_MS = 60 * 60 * 1000;
15
15
  export class GitHubRepos {
16
+ jobs = new Map();
17
+ // Plain fields, not parameter properties: Node's type stripping (the dev
18
+ // and verification server) refuses those.
16
19
  registry;
17
20
  run;
18
21
  folder;
19
- jobs = new Map();
20
22
  constructor(registry, run = runCommand, folder = join(homedir(), "repos")) {
21
23
  this.registry = registry;
22
24
  this.run = run;
@@ -217,7 +217,7 @@ export class RoutineMochiiSync {
217
217
  clientFor(cfg) {
218
218
  if (this.deps.clientFor)
219
219
  return (this.client ??= this.deps.clientFor(cfg));
220
- const spec = customMcpServers(cfg).mochii;
220
+ const spec = this.deps.serverSpec ? this.deps.serverSpec(customMcpServers(cfg).mochii) : customMcpServers(cfg).mochii;
221
221
  const key = JSON.stringify(spec ?? null);
222
222
  if (key !== this.clientKey) {
223
223
  void this.client?.close();
@@ -83,15 +83,24 @@ export class DesktopStikiSession {
83
83
  const held = this.held;
84
84
  return held && held.expiresAt - this.now() > MIN_VALID_MS ? held.token : null;
85
85
  }
86
+ /** A server refused the held token: ask main to refresh it now (main
87
+ * rate-limits this), then hand out whatever it answered. */
88
+ async refresh() {
89
+ if (!this.held)
90
+ return null;
91
+ await this.askMain(true);
92
+ const held = this.held;
93
+ return held && held.expiresAt - this.now() > MIN_VALID_MS ? held.token : null;
94
+ }
86
95
  onChange(listener) {
87
96
  this.listeners.add(listener);
88
97
  return () => this.listeners.delete(listener);
89
98
  }
90
- askMain() {
91
- if (this.asking)
99
+ askMain(refresh = false) {
100
+ if (this.asking && !refresh)
92
101
  return this.asking;
93
102
  const requestId = randomUUID();
94
- this.asking = new Promise((resolve) => {
103
+ const answered = new Promise((resolve) => {
95
104
  const timer = setTimeout(() => {
96
105
  this.waiting.delete(requestId);
97
106
  resolve();
@@ -101,12 +110,16 @@ export class DesktopStikiSession {
101
110
  clearTimeout(timer);
102
111
  resolve();
103
112
  });
104
- if (!this.send({ type: "openmausbot:stiki-token-request", requestId })) {
113
+ if (!this.send({ type: "openmausbot:stiki-token-request", requestId, ...(refresh ? { refresh: true } : {}) })) {
105
114
  clearTimeout(timer);
106
115
  this.waiting.delete(requestId);
107
116
  resolve();
108
117
  }
109
- }).finally(() => {
118
+ });
119
+ // A forced refresh runs on its own; it never replaces the shared ask.
120
+ if (refresh)
121
+ return answered;
122
+ this.asking = answered.finally(() => {
110
123
  this.asking = null;
111
124
  });
112
125
  return this.asking;
@@ -4,8 +4,9 @@
4
4
  // (electron/stiki-signin.mjs): PKCE public client, tokens in the OS-encrypted
5
5
  // credential store, refreshed there, shown in Settings. The desktop server
6
6
  // registers server/stiki-desktop-session.ts with `setStikiSessionSource`.
7
- // This module is the seam: Team Rooms (server/team-rooms/) reads the
8
- // signed-in person only through `stikiSession()`. Without a source (plain
7
+ // This module is the seam: Team Rooms (server/team-rooms/) and the Chibitek
8
+ // MCP servers (server/chibitek-mcp-credentials.ts) read the signed-in person
9
+ // only through `stikiSession()`. Without a source (plain
9
10
  // Node, or nobody signed in) Atomic is signed out and Team Rooms stay off;
10
11
  // everything else in Atomic keeps working.
11
12
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chibitek/chibi",
3
- "version": "0.1.200",
3
+ "version": "0.1.201",
4
4
  "description": "Atomic by Chibitek: run your AI team's server anywhere and pair your devices to it",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-BINI6H7d.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-KWPJA3E3-BYYAeWqA.js";import{_ as a}from"./mermaid.core-BINI6H7d.js";import"./chunk-5VM5RSS4-Clc6Y-k_.js";import"./chunk-XXDRQBXY-Dapib2DP.js";import"./chunk-WEXAMYUT-CRtOamAr.js";import"./chunk-GWA4HPMP-8QL2NNrN.js";import"./channel--GPtxJe9.js";import"./index-ChUqQMGu.js";var o=a(t=>`${e(t)}
2
- .swimlane.cluster:not([data-color-id]) rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),s=o,u=r({styles:s});export{u as diagram};