@chibitek/chibi 0.1.157 → 0.1.158

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 (89) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-BkYbog6D.js → abnfDiagram-O67JEVCF-B8-8zzMS.js} +1 -1
  2. package/dist/assets/{arc-QwTuMsxp.js → arc-CSHQ9Dx3.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-GdicO2PQ.js → architectureDiagram-NJMV4G6O-BCHM9rXW.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-Dkr29TFF.js → blockDiagram-BEXU5L5S-B-5uxPFN.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-Dz_3dstx.js → c4Diagram-YGBWAQC7-CuKNM_MR.js} +1 -1
  6. package/dist/assets/channel-bPN03jIt.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-CGsfu-PI.js → chunk-2Q5K7J3B-BNF02GM4.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-CDqI37_6.js → chunk-3FUC2YCW-uEWgBd4M.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-DnmSuyTb.js → chunk-5VM5RSS4-eSZuXctY.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-Dh7tXcJT.js → chunk-GTNCS2PH-CslS8nRS.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-D_SM1ZrY.js → chunk-GWA4HPMP-w71-MeKj.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-DmeMuTsI.js → chunk-JWPE2WC7-Bjju7WGh.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-R1UT9b5f.js → chunk-NETBCI7D-HxrroD4M.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-DpPfU1yO.js → chunk-WEXAMYUT-D7Rz470x.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-DlihfTkM.js → chunk-XXDRQBXY-BWKnAeyM.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-BlTV6lSC.js → classDiagram-v2-NBCMYWYE-CeBDRHmP.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-Br1kPFWw.js → cose-bilkent-JH36ORCC-BBbRKlvr.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-BqPp3ZMd.js → cynefin-OW5HDTMX-W02cnJ0B.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-DFfs_k8-.js → cynefinDiagram-VND7K2PF-Cs47eaxd.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-Ch3xIJA7.js → dagre-6A5THRUB-8mG18hzT.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-DIHUD87N.js → diagram-22UHCM2B-DF4Qrw67.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-CAgQQdeF.js → diagram-3UASUU5V-3BAVoed1.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-9HVKodrI.js → diagram-ATOU4E4O-CKO3pECE.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-DU2kDq_h.js → diagram-CDSNMT55-CZhrGvur.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-D-qTAhHD.js → diagram-MLGK6HIB-C07l9pdQ.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-C31SnI9P.js → diagram-MPIPVDR6-D3or4lkZ.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-BHrdiBVd.js → ebnfDiagram-ZINNZB2B-DV2epXp_.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-DWyljRo5.js → elk-276RUBZZ-DlvEn4-1.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-DyY59XPp.js → erDiagram-OPXOYQCR-CB6X7Wt5.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-BevMIeAy.js → flowDiagram-KWPJA3E3-C3bqz4lC.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-Ct18WHf4.js → ganttDiagram-FUAMR5RP-yo_Evhab.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-yhixO1N3.js → gitGraphDiagram-X574FWY7-Cq2oUlap.js} +1 -1
  33. package/dist/assets/{index-BEJ8EKQt.js → index-CG4AFPb4.js} +1 -1
  34. package/dist/assets/{index-ziyH_uer.js → index-CMcr5k3Z.js} +199 -196
  35. package/dist/assets/index-CZjRcUdn.css +1 -0
  36. package/dist/assets/{infoDiagram-VRGFBTTK-CYa-r_S5.js → infoDiagram-VRGFBTTK-Y3ZrY7qL.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-CnxwM7gY.js → ishikawaDiagram-OU5B5YK6-BpOtSfyi.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-RKQfXBrp.js → journeyDiagram-ZHPQQLJL-UQM727le.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-CSlRDIF6.js → kanban-definition-PNTS6WVX-C3s5oHpY.js} +1 -1
  40. package/dist/assets/{linear-Ch19KVyt.js → linear-hX6nFOQr.js} +1 -1
  41. package/dist/assets/{mermaid.core-Bek7I_t6.js → mermaid.core-DZObGLN7.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-B_LiP8su.js → mindmap-definition-NLK3R4M7-Br-i2E3P.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-DhzQeiZf.js → pegDiagram-GJSIUBJH-D5SERB-N.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-D-BYNKHS.js → pieDiagram-5QR66LMP-BPNf4J3D.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-DnCm0heP.js → quadrantDiagram-O4NWA36T-Bm_Wh7Jr.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-COqgYnhn.js → railroadDiagram-XR7U4H2S-D6bo0abD.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-Dvt72ajf.js → requirementDiagram-PLB6GJNP--1n5rkV7.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-CisC9nbp.js → sankeyDiagram-IPEJSGJF-Ct4tP2kK.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-BO8xqvxa.js → sequenceDiagram-PO4LG4MO-CCG7O5fR.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-DLk1jBzf.js → sizeCapture-INFHLROL-CJJJra9c.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-C_wutSE7.js → stateDiagram-v2-GCMORJYK-BMdRvVEX.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-hqo1UlEi.js → swimlanes-2SLR337P-B1wnogip.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-DWyjdGGR.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-C_DJldPg.js → timeline-definition-EJHVYXUP-l-3yhXUP.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-CsidVXMA.js → usecaseDiagram-POWQR4AR-DtwtCOoJ.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-Bs-IIqn_.js → vennDiagram-UO4OBE2U-BZAEce1B.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-CXEUyxaj.js → wardleyDiagram-VNRHLVJA-Na_BCMMO.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-B9qvmm4P.js → xychartDiagram-PMCCYNJV-BW9dlUfE.js} +1 -1
  59. package/dist/index.html +2 -2
  60. package/dist-server/connector-proxy.js +205 -0
  61. package/dist-server/container-mcp.js +149 -95
  62. package/dist-server/drivers/agents-proxy.js +81 -81
  63. package/dist-server/index.js +4459 -4013
  64. package/dist-server/openmausbot.js +596 -570
  65. package/dist-server/pair-cli.js +596 -570
  66. package/dist-server/server/avatar-subscription.js +51 -0
  67. package/dist-server/server/cli.js +5 -4
  68. package/dist-server/server/colima-docker.js +136 -0
  69. package/dist-server/server/composio.js +1051 -0
  70. package/dist-server/server/connector-proxy.js +249 -0
  71. package/dist-server/server/container-computer.js +31 -63
  72. package/dist-server/server/container-mcp.js +5 -0
  73. package/dist-server/server/engine-failover.js +22 -12
  74. package/dist-server/server/index.js +40 -16
  75. package/dist-server/server/mcp-public-registry.js +325 -0
  76. package/dist-server/server/port-in-use.js +21 -0
  77. package/dist-server/server/session-fallback.js +76 -0
  78. package/dist-server/server/vault/routes.js +43 -0
  79. package/dist-server/server/vault/runtime.js +48 -0
  80. package/dist-server/server/vault/store.js +177 -0
  81. package/dist-server/shared/connector-availability.js +12 -0
  82. package/dist-server/shared/desktop-private-port.js +1 -0
  83. package/dist-server/shared/subscription-bots.js +3 -0
  84. package/dist-server/shared/vault.js +59 -0
  85. package/dist-server/vps-container-mcp.js +85 -83
  86. package/package.json +1 -1
  87. package/dist/assets/channel-D2y0i2ps.js +0 -1
  88. package/dist/assets/index-DGWeJcck.css +0 -1
  89. package/dist/assets/swimlanesDiagram-TC7HE7FX-D15JqTL9.js +0 -8
@@ -0,0 +1,51 @@
1
+ import { decodeGeneratedImage } from "./generated-image.js";
2
+ import { avatarGenerationPrompt, AVATAR_IMAGE_TIMEOUT_MS } from "./avatar-image.js";
3
+ /** Capability and current billing are both required. An authenticated text
4
+ * engine is not evidence that its subscription can generate images. */
5
+ export async function avatarSubscription(instances) {
6
+ for (const instance of instances) {
7
+ if (!instance.enabled || !instance.generateImage)
8
+ continue;
9
+ try {
10
+ const status = await instance.snapshot();
11
+ if (status.state === "available" && status.authenticated === true &&
12
+ status.billing === "subscription" && status.account?.method !== "api-key")
13
+ return instance;
14
+ }
15
+ catch {
16
+ // A broken account must not conceal another eligible signed-in account.
17
+ }
18
+ }
19
+ return null;
20
+ }
21
+ /** Never turn a subscription failure into an unexpected API charge. */
22
+ export async function generateSubscriptionAvatar(instance, bot, direction, timeoutMs = AVATAR_IMAGE_TIMEOUT_MS) {
23
+ if (!instance.generateImage || await avatarSubscription([instance]) !== instance) {
24
+ throw Object.assign(new Error("This image subscription is no longer available. Check its sign-in in Settings."), { status: 409 });
25
+ }
26
+ const controller = new AbortController();
27
+ let timer;
28
+ try {
29
+ const encoded = await Promise.race([
30
+ instance.generateImage(avatarGenerationPrompt(bot, direction), { signal: controller.signal }),
31
+ new Promise((_, reject) => {
32
+ timer = setTimeout(() => {
33
+ controller.abort();
34
+ reject(new Error("timeout"));
35
+ }, timeoutMs);
36
+ }),
37
+ ]);
38
+ const image = decodeGeneratedImage(encoded);
39
+ if (image.mime === "image/gif")
40
+ throw new Error("unsupported avatar format");
41
+ return { bytes: image.bytes, mime: image.mime };
42
+ }
43
+ catch {
44
+ throw Object.assign(new Error(controller.signal.aborted
45
+ ? "Subscription avatar generation timed out. Try again."
46
+ : "Your subscription could not generate this avatar. Check its sign-in and usage allowance, then try again."), { status: 502 });
47
+ }
48
+ finally {
49
+ clearTimeout(timer);
50
+ }
51
+ }
@@ -40,6 +40,7 @@ import { resolveLoopbackTrust } from "./request-auth.js";
40
40
  import { writeFileAtomic } from "./atomic.js";
41
41
  import { ensureCaddy, normalizeDomainOption, startCaddy } from "./caddy.js";
42
42
  import { runServiceCommand } from "./service-cli.js";
43
+ import { reportBusyPort } from "./port-in-use.js";
43
44
  import { colorDepth, renderBanner, shouldShowBanner, terminalBackground } from "./cli-banner.js";
44
45
  import { runFleetCommand } from "./fleet-cli.js";
45
46
  import { startFleetAgent } from "./fleet-agent.js";
@@ -830,6 +831,8 @@ export async function runServe(options, log = console.log) {
830
831
  console.error(`something already answers on http://127.0.0.1:${options.port}; use \`chibi pair\` against it, or --port for a second server`);
831
832
  return 1;
832
833
  }
834
+ if (await reportBusyPort(options.port, options.dataDir === join(homedir(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`))
835
+ return 1;
833
836
  let publicUrl = options.publicUrl;
834
837
  let tailscale = null;
835
838
  if (options.tailscale) {
@@ -1131,10 +1134,8 @@ export async function runOnboardingCommand(options, io = defaultIo(), startServe
1131
1134
  saveCliStartup(options.dataDir, startupPreferences(launch));
1132
1135
  }
1133
1136
  if (options.command === "setup") {
1134
- io.log("\nAll set. Start with: chibi (or npx @chibitek/chibi without a global install).");
1135
- if (options.dataDir !== join(homedir(), ".atomic-app") || options.port !== 8799) {
1136
- io.log(`Use the same --data-dir (${options.dataDir}) and --port (${options.port}) options when starting.`);
1137
- }
1137
+ const flags = [options.dataDir !== join(homedir(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
1138
+ io.log(`\nAll set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
1138
1139
  return 0;
1139
1140
  }
1140
1141
  if (saved)
@@ -0,0 +1,136 @@
1
+ // Colima is the only container engine Atomic starts or talks to for the
2
+ // Local VM on macOS. Docker Desktop is never launched, and a docker context
3
+ // it leaves behind (desktop-linux) must not decide where `docker` commands
4
+ // go, so every docker invocation Atomic makes on a Mac is pinned to the
5
+ // Colima profile's socket through DOCKER_HOST.
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import { homedir } from "node:os";
8
+ import { join } from "node:path";
9
+ export const COLIMA_DEFAULT_PROFILE = "default";
10
+ const readText = (path) => {
11
+ try {
12
+ return readFileSync(path, "utf8");
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ };
18
+ function homeOf(env) {
19
+ return env.HOME?.trim() || homedir();
20
+ }
21
+ /** The Colima profile Atomic uses: the one named by a `colima-<profile>`
22
+ * docker context (DOCKER_CONTEXT, then ~/.docker/config.json), else the
23
+ * default profile. Any other context, Docker Desktop's included, is ignored:
24
+ * it never redirects Atomic away from Colima. Reads a file only; never runs
25
+ * docker, since docker itself is what this pins. */
26
+ export function colimaProfile(env = process.env, read = readText) {
27
+ let context = env.DOCKER_CONTEXT?.trim() ?? "";
28
+ if (!context) {
29
+ const configDir = env.DOCKER_CONFIG?.trim() || join(homeOf(env), ".docker");
30
+ try {
31
+ const parsed = JSON.parse(read(join(configDir, "config.json")) ?? "{}");
32
+ context = typeof parsed.currentContext === "string" ? parsed.currentContext.trim() : "";
33
+ }
34
+ catch {
35
+ context = "";
36
+ }
37
+ }
38
+ if (context.startsWith("colima-") && /^[A-Za-z0-9_.-]+$/.test(context.slice("colima-".length))) {
39
+ return context.slice("colima-".length);
40
+ }
41
+ return COLIMA_DEFAULT_PROFILE;
42
+ }
43
+ /** Colima's docker socket for a profile. COLIMA_HOME wins; otherwise
44
+ * ~/.colima, or ~/.config/colima when only that one holds the profile. */
45
+ export function colimaDockerSocket(profile = COLIMA_DEFAULT_PROFILE, env = process.env, exists = existsSync) {
46
+ const explicit = env.COLIMA_HOME?.trim();
47
+ if (explicit)
48
+ return join(explicit, profile, "docker.sock");
49
+ const home = homeOf(env);
50
+ const legacy = join(home, ".colima");
51
+ const xdg = join(env.XDG_CONFIG_HOME?.trim() || join(home, ".config"), "colima");
52
+ const base = !exists(join(legacy, profile)) && exists(join(xdg, profile)) ? xdg : legacy;
53
+ return join(base, profile, "docker.sock");
54
+ }
55
+ export function colimaDockerHost(profile = COLIMA_DEFAULT_PROFILE, env = process.env, exists) {
56
+ return `unix://${colimaDockerSocket(profile, env, exists)}`;
57
+ }
58
+ /** The environment for one `docker` invocation. On macOS it always targets
59
+ * Colima: DOCKER_HOST is the Colima socket and DOCKER_CONTEXT is dropped (the
60
+ * CLI refuses both at once). Elsewhere the environment is returned as is. */
61
+ export function dockerEnvForColima(env = process.env, platform = process.platform, options = {}) {
62
+ if (platform !== "darwin")
63
+ return env;
64
+ const profile = colimaProfile(env, options.read);
65
+ const pinned = { ...env, DOCKER_HOST: colimaDockerHost(profile, env, options.exists) };
66
+ delete pinned.DOCKER_CONTEXT;
67
+ return pinned;
68
+ }
69
+ const COLIMA_START_TIMEOUT_MS = 4 * 60_000;
70
+ const COLIMA_STOP_TIMEOUT_MS = 60_000;
71
+ /** Colima on the profile the docker CLI is pinned to. `colima start` on a
72
+ * running profile is a no-op, so an instance the person started with their
73
+ * own flags is left exactly as it is. */
74
+ export function colimaStartPlan(env = process.env) {
75
+ const profile = colimaProfile(env);
76
+ const profileArgs = profile === COLIMA_DEFAULT_PROFILE ? [] : ["--profile", profile];
77
+ return {
78
+ label: "Colima",
79
+ profile,
80
+ start: { command: "colima", args: ["start", ...profileArgs], timeoutMs: COLIMA_START_TIMEOUT_MS },
81
+ stop: { command: "colima", args: ["stop", ...profileArgs], timeoutMs: COLIMA_STOP_TIMEOUT_MS },
82
+ };
83
+ }
84
+ /** Bring docker back on Colima: start and wait for `docker info`; if it
85
+ * does not answer, start again (retry); then restart the profile (`colima
86
+ * stop`, `colima start`); then give up with a clear error. Without a plan
87
+ * (Colima not installed) it says so on a Mac. Docker Desktop is never
88
+ * opened on any path. */
89
+ export async function startColima(plan, before, deps) {
90
+ if (!plan) {
91
+ return {
92
+ status: before,
93
+ started: null,
94
+ error: deps.platform === "darwin"
95
+ ? "Docker is not answering and Colima is not installed. Atomic runs the Local VM on Colima only and never opens Docker Desktop: install Colima (brew install colima), then try again."
96
+ : null,
97
+ };
98
+ }
99
+ const sleep = deps.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
100
+ const quietly = async (step) => {
101
+ // Colima can exit non-zero while its VM is still coming up, and the wait
102
+ // below is the real test; a launch that truly failed times out.
103
+ await deps.runner(step.command, step.args, step.timeoutMs).catch(() => undefined);
104
+ };
105
+ const waitUntilUp = async (ms) => {
106
+ const deadline = Date.now() + ms;
107
+ let status = await deps.status();
108
+ while (!status.daemonUp && Date.now() < deadline) {
109
+ await sleep(deps.pollMs ?? 2000);
110
+ status = await deps.status();
111
+ }
112
+ return status;
113
+ };
114
+ await quietly(plan.start);
115
+ let status = await waitUntilUp(deps.waitMs ?? 120_000);
116
+ if (!status.daemonUp) {
117
+ // A VM still booting often answers late.
118
+ await quietly(plan.start);
119
+ status = await waitUntilUp(deps.retryWaitMs ?? 30_000);
120
+ }
121
+ if (!status.daemonUp) {
122
+ // A profile that reads as running but whose socket is dead only comes
123
+ // back after a stop.
124
+ await quietly(plan.stop);
125
+ await quietly(plan.start);
126
+ status = await waitUntilUp(deps.waitMs ?? 120_000);
127
+ }
128
+ const profileFlag = plan.profile === COLIMA_DEFAULT_PROFILE ? "" : ` --profile ${plan.profile}`;
129
+ return {
130
+ status,
131
+ started: plan.label,
132
+ error: status.daemonUp
133
+ ? null
134
+ : `Colima (profile ${plan.profile}) did not answer after a start, a retry and a restart. Run \`colima status${profileFlag}\` to see why; Atomic does not fall back to Docker Desktop.`,
135
+ };
136
+ }