@kombai/cli 0.1.0 → 0.1.2-beta.1

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/kombai.mjs CHANGED
@@ -613,9 +613,9 @@ var init_env = __esm({
613
613
  preprod: { api: "https://api.assistant.preprod.kombai.com", web: "https://agent.preprod.kombai.com" },
614
614
  prod: { api: "https://api.assistant.app.kombai.com", web: "https://agent.kombai.com" }
615
615
  });
616
- DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "prod") ? (
616
+ DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "dev") ? (
617
617
  /** @type {EnvName} */
618
- "prod"
618
+ "dev"
619
619
  ) : "prod";
620
620
  }
621
621
  });
@@ -818,11 +818,11 @@ var init_version = __esm({
818
818
  "src/lib/version.js"() {
819
819
  "use strict";
820
820
  init_define_KOMBAI_TELEMETRY();
821
- CLI_VERSION = true ? "0.1.0" : (
821
+ CLI_VERSION = true ? "0.1.2-beta.1" : (
822
822
  /** @type {{ version: string }} */
823
823
  JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version
824
824
  );
825
- CLI_RUN = true ? "npx -y @kombai/cli@latest" : "npx -y @kombai/cli@latest";
825
+ CLI_RUN = true ? "npx -y @kombai/cli@next" : "npx -y @kombai/cli@latest";
826
826
  }
827
827
  });
828
828
 
@@ -2621,7 +2621,10 @@ var init_auth = __esm({
2621
2621
  cliVersion: ctx.version
2622
2622
  }
2623
2623
  });
2624
- started = res.body;
2624
+ const b = res.body;
2625
+ if (!b || typeof b.code !== "string" || typeof b.matchCode !== "string" || typeof b.approveUrl !== "string" || !b.approveUrl.startsWith(`${hosts.web}/`) || !Number.isFinite(Date.parse(b.expiresAt)))
2626
+ throw new CliError("CLI_BAD_ANSWER", "The sign-in answer was not a login code.", { next: "kombai login" });
2627
+ started = b;
2625
2628
  } catch (error2) {
2626
2629
  if (error2 instanceof LostAnswer) error2.next = "kombai login";
2627
2630
  throw error2;
@@ -5194,7 +5197,7 @@ var init_browser = __esm({
5194
5197
  });
5195
5198
 
5196
5199
  // ../design-mode/packages/shared/src/tailwind-script.ts
5197
- var TAILWIND_BROWSER_PATH, TAILWIND_BROWSER_VERSION, TAILWIND_BROWSER_ROUTE, TAILWIND_SCRIPT_TAG, TAILWIND_CDN_SRI, TAILWIND_CDN_SCRIPT_TAG, TAILWIND_PROBE_ATTR, TAILWIND_PROBE_HTML;
5200
+ var TAILWIND_BROWSER_PATH, TAILWIND_BROWSER_VERSION, TAILWIND_BROWSER_ROUTE, TAILWIND_SCRIPT_TAG, TAILWIND_PROBE_ATTR, TAILWIND_PROBE_HTML;
5198
5201
  var init_tailwind_script = __esm({
5199
5202
  "../design-mode/packages/shared/src/tailwind-script.ts"() {
5200
5203
  "use strict";
@@ -5203,24 +5206,113 @@ var init_tailwind_script = __esm({
5203
5206
  TAILWIND_BROWSER_VERSION = "4.3.3";
5204
5207
  TAILWIND_BROWSER_ROUTE = `${TAILWIND_BROWSER_PATH}?v=${TAILWIND_BROWSER_VERSION}`;
5205
5208
  TAILWIND_SCRIPT_TAG = `<script src="${TAILWIND_BROWSER_ROUTE}"></script>`;
5206
- TAILWIND_CDN_SRI = "sha384-2ql948lIdLcGEE0/qxNiudyTjgauA3RDJERu5xW75kFCvSl5a9odyQYCb6tEjnmB";
5207
- TAILWIND_CDN_SCRIPT_TAG = `<script src="https://unpkg.com/@tailwindcss/browser@${TAILWIND_BROWSER_VERSION}/dist/index.global.js" integrity="${TAILWIND_CDN_SRI}" crossorigin="anonymous"></script>`;
5208
5209
  TAILWIND_PROBE_ATTR = "data-kombai-tw-probe";
5209
5210
  TAILWIND_PROBE_HTML = `<div ${TAILWIND_PROBE_ATTR} class="flex" style="position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none"></div>`;
5210
5211
  }
5211
5212
  });
5212
5213
 
5214
+ // ../design-mode/packages/shared/src/tailwind-detection.ts
5215
+ function withoutScripts(html) {
5216
+ return html.replace(
5217
+ RAW_ELEMENTS,
5218
+ (element, name) => name.toLowerCase() === "script" ? "" : element
5219
+ );
5220
+ }
5221
+ function attribute(attrs, name) {
5222
+ const match = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(attrs);
5223
+ return match?.[1] ?? match?.[2] ?? match?.[3] ?? "";
5224
+ }
5225
+ function hasTailwindRuntime(html) {
5226
+ const clean = html.replace(/<!--[\s\S]*?(?:-->|$)/g, "").replace(RAW_ELEMENTS, (element, name) => name.toLowerCase() === "style" ? "" : element);
5227
+ for (const match of clean.matchAll(/<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>([\s\S]*?)(?:<\/script\s*>|$)/gi)) {
5228
+ if (attribute(match[1] ?? "", TAILWIND_RELAY_ATTR) === "true") return true;
5229
+ if (RUNTIME_URL.test(attribute(match[1] ?? "", "src")) || RUNTIME_URL.test(match[2] ?? "")) return true;
5230
+ }
5231
+ return false;
5232
+ }
5233
+ function hasCompiledTailwind(html) {
5234
+ const clean = withoutScripts(html.replace(/<!--[\s\S]*?(?:-->|$)/g, ""));
5235
+ const markup = clean.replace(RAW_ELEMENTS, "");
5236
+ for (const match of markup.matchAll(/<link\b((?:"[^"]*"|'[^']*'|[^'">])*)>/gi)) {
5237
+ if (COMPILED_URL.test(attribute(match[1] ?? "", "href"))) return true;
5238
+ }
5239
+ for (const match of clean.matchAll(/<style\b((?:"[^"]*"|'[^']*'|[^'">])*)>([\s\S]*?)<\/style\s*>/gi)) {
5240
+ const css = match[2] ?? "";
5241
+ const uncommentedCss = css.replace(/\/\*[\s\S]*?\*\//g, "");
5242
+ for (const imported of uncommentedCss.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s);]+))/gi)) {
5243
+ if (COMPILED_URL.test(imported[1] ?? imported[2] ?? imported[3] ?? "")) return true;
5244
+ }
5245
+ if (attribute(match[1] ?? "", "id") === "__tw-css" && css.trim().length > 0 || /tailwindcss\s+v\d/i.test(css) || css.includes("@layer utilities") && /--tw-[\w-]+\s*:/.test(css))
5246
+ return true;
5247
+ }
5248
+ return false;
5249
+ }
5250
+ function needsTailwindRuntime(html) {
5251
+ if (hasTailwindRuntime(html) || hasCompiledTailwind(html)) return false;
5252
+ const clean = withoutScripts(html.replace(/<!--[\s\S]*?(?:-->|$)/g, ""));
5253
+ for (const style of clean.matchAll(RAW_ELEMENTS)) {
5254
+ if (attribute(style[2] ?? "", "type").toLowerCase() === "text/tailwindcss") return true;
5255
+ }
5256
+ const markup = clean.replace(
5257
+ RAW_ELEMENTS,
5258
+ (_match, name) => name.toLowerCase() === "style" ? "<style>" : ""
5259
+ );
5260
+ const utilities = /* @__PURE__ */ new Set();
5261
+ let hasClasses = false;
5262
+ let hasStylesheet = false;
5263
+ for (const tag of markup.matchAll(/<([a-z][\w:-]*)\b((?:"[^"]*"|'[^']*'|[^'">])*)(?:>|$)/gi)) {
5264
+ const name = tag[1].toLowerCase();
5265
+ const attrs = tag[2] ?? "";
5266
+ if (name === "style" || name === "link" && attribute(attrs, "rel").toLowerCase().split(/\s+/).includes("stylesheet"))
5267
+ hasStylesheet = true;
5268
+ for (const candidate of attribute(attrs, "class").split(/\s+/).filter(Boolean)) {
5269
+ hasClasses = true;
5270
+ const token = candidate.replace(/^!|!$/g, "");
5271
+ const variant = VARIANT.exec(token);
5272
+ const base = variant?.[1] ?? token;
5273
+ if (ARBITRARY.test(base) || variant !== null && UTILITY.test(base) || /^(?:min-|max-)?[wh]-(?:screen|[sdl]v[wh])$/.test(base))
5274
+ return true;
5275
+ if (UTILITY.test(base)) utilities.add(base);
5276
+ }
5277
+ }
5278
+ return utilities.size >= 3 && [...utilities].some((name) => name.includes("-")) || hasClasses && !hasStylesheet;
5279
+ }
5280
+ function tailwindScanInput(html, overrides) {
5281
+ return `${overrides?.head ?? ""}<html ${overrides?.htmlAttrs ?? ""}><body ${overrides?.bodyAttrs ?? ""}>${html}`;
5282
+ }
5283
+ var OPTIONAL_TAILWIND_CDN_URL, OPTIONAL_TAILWIND_SCRIPT_TAG, TAILWIND_CDN_SCRIPT_TAG, TAILWIND_RELAY_ATTR, TAILWIND_RUNTIME_SELECTOR, TAILWIND_DOCUMENT_SELECTOR, RUNTIME_URL, COMPILED_URL, UTILITY, ARBITRARY, VARIANT, RAW_ELEMENTS;
5284
+ var init_tailwind_detection = __esm({
5285
+ "../design-mode/packages/shared/src/tailwind-detection.ts"() {
5286
+ "use strict";
5287
+ init_define_KOMBAI_TELEMETRY();
5288
+ init_tailwind_script();
5289
+ OPTIONAL_TAILWIND_CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
5290
+ OPTIONAL_TAILWIND_SCRIPT_TAG = `<script src="${OPTIONAL_TAILWIND_CDN_URL}"></script>`;
5291
+ TAILWIND_CDN_SCRIPT_TAG = OPTIONAL_TAILWIND_SCRIPT_TAG;
5292
+ TAILWIND_RELAY_ATTR = "data-kombai-tailwind-runtime";
5293
+ TAILWIND_RUNTIME_SELECTOR = 'script[src*="@tailwindcss/browser"],script[src*="cdn.tailwindcss.com"],script[src*="/api/tailwind/browser.js"]';
5294
+ TAILWIND_DOCUMENT_SELECTOR = `${TAILWIND_RUNTIME_SELECTOR},meta[name="kombai-tailwind-runtime"]`;
5295
+ RUNTIME_URL = /@tailwindcss\/browser(?:@|[/?#]|$)|cdn\.tailwindcss\.com(?:[/?#]|$)|\/api\/tailwind\/browser\.js(?:[?#]|$)/i;
5296
+ COMPILED_URL = /tailwind(?:css)?(?:[.-][\w-]+)*\.css(?:[?#]|$)/i;
5297
+ UTILITY = /^-?(?:(?:[mp][trblxyse]?|gap(?:-[xy])?|space-[xy]|w|h|min-[wh]|max-[wh]|size|inset|top|right|bottom|left|z|opacity|order|grow|shrink)-(?:\d+(?:\.\d+)?(?:\/\d+)?|px|auto|full|screen|fit|min|max|none)|(?:bg|text|border|ring|fill|stroke|from|via|to)-(?:[a-z]+-\d{2,3}|white|black|transparent|current)|(?:grid-cols|col-span|row-span)-\d+|(?:items|justify|self|content)-(?:start|end|center|between|around|stretch)|(?:flex|inline-flex|grid|inline-grid|block|hidden|relative|absolute|fixed|sticky)|rounded(?:-(?:none|sm|md|lg|xl|2xl|3xl|full))?|shadow(?:-(?:none|sm|md|lg|xl|2xl))?|font-(?:sans|serif|mono|thin|light|normal|medium|semibold|bold|extrabold|black)|text-(?:xs|sm|base|lg|xl|[2-9]xl|left|center|right|justify|start|end)|tracking-(?:tighter|tight|normal|wide|wider|widest)|leading-(?:none|tight|snug|normal|relaxed|loose|\d+(?:\.\d+)?)|uppercase|lowercase|capitalize|normal-case|italic|not-italic|underline|overline|line-through|no-underline|truncate|line-clamp-(?:\d+|none)|whitespace-(?:normal|nowrap|pre|pre-line|pre-wrap|break-spaces)|overflow(?:-[xy])?-(?:auto|hidden|clip|visible|scroll)|object-(?:contain|cover|fill|none|scale-down)|aspect-(?:square|video|auto)|transition(?:-(?:all|colors|opacity|shadow|transform|none))?|duration-\d+|cursor-pointer)$/;
5298
+ ARBITRARY = /^(?:[a-z][a-z0-9-]*-)?(?:\[[^\]]+\]|\(--[\w-]+\))$/i;
5299
+ VARIANT = /^(?:(?:sm|md|lg|xl|2xl|dark|hover|focus|focus-visible|active|disabled|group-hover):)+(.+)$/;
5300
+ RAW_ELEMENTS = /<(script|style)\b((?:"[^"]*"|'[^']*'|[^'">])*)>[\s\S]*?(?:<\/\1\s*>|$)/gi;
5301
+ }
5302
+ });
5303
+
5213
5304
  // src/render/page.js
5214
5305
  function composePage({ html, overrides, images }) {
5215
5306
  const rewrite = (text) => rewriteImages(text, images);
5216
5307
  const captured = Boolean(overrides);
5217
5308
  const htmlAttrs = overrides?.htmlAttrs ? ` ${overrides.htmlAttrs.trimStart()}` : "";
5218
5309
  const bodyAttrs = overrides?.bodyAttrs ? ` ${rewrite(overrides.bodyAttrs.trimStart())}` : "";
5310
+ const tailwind = needsTailwindRuntime(tailwindScanInput(html, overrides ?? void 0)) ? TAILWIND_CDN_SCRIPT_TAG : "";
5219
5311
  return `<!DOCTYPE html>
5220
5312
  <html${htmlAttrs}>
5221
5313
  <head>
5222
5314
  <meta charset="utf-8">
5223
- ${captured ? rewrite(overrides?.head ?? "") : TAILWIND_CDN_SCRIPT_TAG}
5315
+ ${captured ? rewrite(overrides?.head ?? "") : tailwind}
5224
5316
  <style>${captured ? "" : FRAGMENT_RESET_CSS}
5225
5317
  ${ROOT_CSS}</style>
5226
5318
  </head>
@@ -5241,7 +5333,7 @@ var init_page = __esm({
5241
5333
  "src/render/page.js"() {
5242
5334
  "use strict";
5243
5335
  init_define_KOMBAI_TELEMETRY();
5244
- init_tailwind_script();
5336
+ init_tailwind_detection();
5245
5337
  FRAGMENT_RESET_CSS = "html, body { margin: 0; padding: 0; }";
5246
5338
  ROOT_CSS = "#root { display: contents; }";
5247
5339
  }
@@ -7026,6 +7118,151 @@ var init_dskit = __esm({
7026
7118
  }
7027
7119
  });
7028
7120
 
7121
+ // ../shared/src/utils/inspirationLibrary.ts
7122
+ var INSPIRATION_LIBRARY_SEGMENT, LIBRARY_PATH_PREFIX;
7123
+ var init_inspirationLibrary = __esm({
7124
+ "../shared/src/utils/inspirationLibrary.ts"() {
7125
+ "use strict";
7126
+ init_define_KOMBAI_TELEMETRY();
7127
+ INSPIRATION_LIBRARY_SEGMENT = "kombai-inspiration-library";
7128
+ LIBRARY_PATH_PREFIX = `${INSPIRATION_LIBRARY_SEGMENT}/`;
7129
+ }
7130
+ });
7131
+
7132
+ // ../design-mode/packages/shared/src/preset-design-system.ts
7133
+ function isSafePresetId(id) {
7134
+ return SAFE_PRESET_ID.test(id);
7135
+ }
7136
+ function isRecord2(v) {
7137
+ return typeof v === "object" && v !== null && !Array.isArray(v);
7138
+ }
7139
+ function isTextSpec(v) {
7140
+ return isRecord2(v) && isString(v.family) && typeof v.weight === "number" && isString(v.size) && isString(v.lineHeight);
7141
+ }
7142
+ function isPreview(v) {
7143
+ if (!isRecord2(v) || !isMode(v.mode) || !isRecord2(v.colors)) return false;
7144
+ const colors2 = v.colors;
7145
+ return PREVIEW_COLOR_ROLES.every((r) => isString(colors2[r])) && isTextSpec(v.heading) && isTextSpec(v.body) && isString(v.radius);
7146
+ }
7147
+ function isCard(v) {
7148
+ return isRecord2(v) && Array.isArray(v.tags) && v.tags.every(isString) && isOptionalString(v.thumbnailPath) && isOptionalString(v.videoLink) && isOptionalString(v.category) && isOptionalString(v.sourceUrl);
7149
+ }
7150
+ function isPresetDesignSystem(v) {
7151
+ return isRecord2(v) && isNonEmptyString(v.id) && isNonEmptyString(v.name) && isString(v.description) && Array.isArray(v.modes) && v.modes.every(isMode) && isPreview(v.preview) && isCard(v.card);
7152
+ }
7153
+ function resolveLibraryPath(p, base) {
7154
+ if (!p) return void 0;
7155
+ if (/^https?:\/\//i.test(p)) return p;
7156
+ return `${base}/${p.replace(/^\/+/, "")}`;
7157
+ }
7158
+ function toPresetListItem(preset, base) {
7159
+ const { card } = preset;
7160
+ return {
7161
+ id: preset.id,
7162
+ name: preset.name,
7163
+ description: preset.description,
7164
+ modes: preset.modes,
7165
+ preview: preset.preview,
7166
+ card: {
7167
+ thumbnailUrl: resolveLibraryPath(card.thumbnailPath, base),
7168
+ videoLink: card.videoLink,
7169
+ category: card.category,
7170
+ tags: card.tags,
7171
+ // Clients open this in a browser, so only an absolute http(s) URL is ever served.
7172
+ sourceUrl: card.sourceUrl && /^https?:\/\//i.test(card.sourceUrl) ? card.sourceUrl : void 0
7173
+ }
7174
+ };
7175
+ }
7176
+ function presetListItems(items, libraryBaseUrl) {
7177
+ const base = libraryBaseUrl.replace(/\/+$/, "");
7178
+ const seen = /* @__PURE__ */ new Set();
7179
+ const presets = [];
7180
+ const dropped = [];
7181
+ for (const item of items) {
7182
+ if (!isPresetDesignSystem(item)) {
7183
+ dropped.push({ id: isRecord2(item) ? item.id : void 0, reason: "malformed" /* Malformed */ });
7184
+ continue;
7185
+ }
7186
+ if (seen.has(item.id)) {
7187
+ dropped.push({ id: item.id, reason: "duplicate" /* Duplicate */ });
7188
+ continue;
7189
+ }
7190
+ seen.add(item.id);
7191
+ presets.push(item);
7192
+ }
7193
+ presets.sort((a, b) => a.name.localeCompare(b.name, "en", { sensitivity: "base" }));
7194
+ return { items: presets.map((preset) => toPresetListItem(preset, base)), dropped };
7195
+ }
7196
+ var PRESET_DESIGN_SYSTEM_FILE, PRESET_DESIGN_SYSTEM_FILE_VERSION, SAFE_PRESET_ID, PREVIEW_COLOR_ROLES, isString, isNonEmptyString, isOptionalString, isMode;
7197
+ var init_preset_design_system = __esm({
7198
+ "../design-mode/packages/shared/src/preset-design-system.ts"() {
7199
+ "use strict";
7200
+ init_define_KOMBAI_TELEMETRY();
7201
+ PRESET_DESIGN_SYSTEM_FILE = "preset-design-system.json";
7202
+ PRESET_DESIGN_SYSTEM_FILE_VERSION = 1;
7203
+ SAFE_PRESET_ID = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
7204
+ PREVIEW_COLOR_ROLES = ["background", "surface", "text", "primary", "accent"];
7205
+ isString = (v) => typeof v === "string";
7206
+ isNonEmptyString = (v) => isString(v) && v.trim() !== "";
7207
+ isOptionalString = (v) => v === void 0 || isString(v);
7208
+ isMode = (v) => v === "light" || v === "dark";
7209
+ }
7210
+ });
7211
+
7212
+ // src/lib/presets.js
7213
+ function libraryBase(web) {
7214
+ return `${web.replace(/\/+$/, "")}/${INSPIRATION_LIBRARY_SEGMENT}`;
7215
+ }
7216
+ async function libraryText(ctx, web, file2) {
7217
+ try {
7218
+ const res = await ctx.fetch(`${libraryBase(web)}/${file2}`, { signal: AbortSignal.timeout(LIBRARY_LIMIT_MS) });
7219
+ return { status: res.status, text: await res.text() };
7220
+ } catch (error2) {
7221
+ throw blockedRequest(ctx.sandbox, error2) ?? unavailable2("the library did not answer");
7222
+ }
7223
+ }
7224
+ async function listPublic(ctx, web) {
7225
+ const { status, text } = await libraryText(ctx, web, PRESET_DESIGN_SYSTEM_FILE);
7226
+ if (status !== 200 || !text.trimStart().startsWith("{")) throw unavailable2(`the library has no list (${status})`);
7227
+ let file2;
7228
+ try {
7229
+ file2 = JSON.parse(text);
7230
+ } catch {
7231
+ throw unavailable2("the list is not JSON");
7232
+ }
7233
+ if (file2?.version !== PRESET_DESIGN_SYSTEM_FILE_VERSION || !Array.isArray(file2.items))
7234
+ throw unavailable2("the list is in a version this CLI does not read");
7235
+ return presetListItems(file2.items, libraryBase(web)).items.filter((item) => isSafePresetId(item.id));
7236
+ }
7237
+ async function readPublicDoc(ctx, web, id) {
7238
+ const folder = `inspirations/${encodeURIComponent(id)}`;
7239
+ const ds = await libraryText(ctx, web, `${folder}/design.ds`);
7240
+ if (ds.status === 200 && ds.text.trimStart().startsWith("---")) return ds.text;
7241
+ if (ds.status !== 200 && ds.status !== 404) throw unavailable2(`the library answered ${ds.status} for ${id}`);
7242
+ const md = await libraryText(ctx, web, `${folder}/design.md`);
7243
+ if (md.status === 404) return "";
7244
+ if (md.status !== 200) throw unavailable2(`the library answered ${md.status} for ${id}`);
7245
+ return /^<(!doctype|html)\b/i.test(md.text.trimStart()) ? "" : md.text;
7246
+ }
7247
+ function unavailable2(reason) {
7248
+ return new CliError(
7249
+ "CLI_PUBLIC_UNAVAILABLE",
7250
+ `Kombai's public design systems could not be read: ${reason}. Try again later.`
7251
+ );
7252
+ }
7253
+ var LIBRARY_LIMIT_MS;
7254
+ var init_presets = __esm({
7255
+ "src/lib/presets.js"() {
7256
+ "use strict";
7257
+ init_define_KOMBAI_TELEMETRY();
7258
+ init_inspirationLibrary();
7259
+ init_preset_design_system();
7260
+ init_output();
7261
+ init_sandbox();
7262
+ LIBRARY_LIMIT_MS = 8e3;
7263
+ }
7264
+ });
7265
+
7029
7266
  // src/commands/ds.js
7030
7267
  import { randomBytes as randomBytes6 } from "node:crypto";
7031
7268
  import fs15 from "node:fs/promises";
@@ -7043,6 +7280,31 @@ function dsPaths(home, env, ownerKey, slug) {
7043
7280
  lock: path15.join(dir, `.${slug}.lock`)
7044
7281
  };
7045
7282
  }
7283
+ function publicDir(home, env) {
7284
+ return path15.join(home, env, "design-systems", "public");
7285
+ }
7286
+ async function pullPublic(ctx, id) {
7287
+ if (!isSafePresetId(id)) {
7288
+ throw badValues("ds pull", [`"${id}" is not a public design system id (letters, digits, _ and -)`]);
7289
+ }
7290
+ const session = await openSession(ctx);
7291
+ const [listed, doc] = await Promise.all([
7292
+ listPublic(ctx, session.hosts.web),
7293
+ readPublicDoc(ctx, session.hosts.web, id)
7294
+ ]);
7295
+ const found = listed.find((item) => item.id === id);
7296
+ if (!found || !doc.trim()) {
7297
+ throw new CliError(
7298
+ "CLI_PUBLIC_NOT_FOUND",
7299
+ found ? `Kombai's public design system ${id} has no published document.` : `Kombai has no public design system "${id}".`,
7300
+ { next: "kombai ds list", details: { id } }
7301
+ );
7302
+ }
7303
+ const file2 = path15.join(publicDir(ctx.home, session.env), `${id}.ds`);
7304
+ await ensureDir(path15.dirname(file2));
7305
+ await writeFileAtomic(file2, doc, { mode: 420 });
7306
+ return { id, name: found.name, public: true, file: file2 };
7307
+ }
7046
7308
  async function forgetDesignSystem(paths, slug, ownerKey) {
7047
7309
  if (!await fs15.stat(paths.dir).catch(() => null)) return null;
7048
7310
  return withLock(paths.lock, async () => {
@@ -7252,16 +7514,36 @@ var init_ds = __esm({
7252
7514
  init_fsx();
7253
7515
  init_lock();
7254
7516
  init_output();
7517
+ init_presets();
7255
7518
  init_project();
7256
7519
  init_session();
7257
7520
  init_store();
7258
7521
  UTF8 = new TextDecoder("utf-8", { fatal: true });
7259
7522
  dsList = {
7260
7523
  name: "ds list",
7261
- summary: "The user's design systems, across their organizations and their own. file is null when not pulled here.",
7524
+ summary: "The user's design systems, across their organizations and their own, and in publicDesignSystems Kombai's public ones (read-only; null, with a warning, when they cannot be read). file is null when not pulled here.",
7262
7525
  async run(ctx) {
7263
7526
  const session = await openSession(ctx);
7264
- const items = await listAll(session.api);
7527
+ const [items, listed] = await Promise.all([
7528
+ listAll(session.api),
7529
+ listPublic(ctx, session.hosts.web).catch((error2) => {
7530
+ if (!(error2 instanceof CliError)) throw error2;
7531
+ ctx.warnings.add({ code: error2.code, message: error2.message });
7532
+ return null;
7533
+ })
7534
+ ]);
7535
+ const publicFolder = publicDir(ctx.home, session.env);
7536
+ const publicDesignSystems = listed && await Promise.all(
7537
+ listed.map(async (item) => {
7538
+ const file2 = path15.join(publicFolder, `${item.id}.ds`);
7539
+ return {
7540
+ id: item.id,
7541
+ name: item.name,
7542
+ description: item.description,
7543
+ file: await exists(file2) ? file2 : null
7544
+ };
7545
+ })
7546
+ );
7265
7547
  return {
7266
7548
  designSystems: await Promise.all(
7267
7549
  items.map(async (item) => {
@@ -7275,16 +7557,26 @@ var init_ds = __esm({
7275
7557
  file: await hashFile(file2) === null ? null : file2
7276
7558
  };
7277
7559
  })
7278
- )
7560
+ ),
7561
+ publicDesignSystems
7279
7562
  };
7280
7563
  }
7281
7564
  };
7282
7565
  dsPull = {
7283
7566
  name: "ds pull",
7284
- summary: "Get a design system as a .ds file. --owner picks one when the slug is in several scopes. Refused (exit 2) over an edit that was not pushed, unless --discard.",
7567
+ summary: "Get a design system as a .ds file. --owner picks one when the slug is in several scopes. Refused (exit 2) over an edit that was not pushed, unless --discard. --public gets one of Kombai's public design systems by its id (ds list's publicDesignSystems): read-only, written over the last copy.",
7285
7568
  args: [{ name: "slug", required: true }],
7286
- flags: { owner: { type: "string", placeholder: "<ownerKey>" }, discard: { type: "boolean" } },
7569
+ flags: {
7570
+ owner: { type: "string", placeholder: "<ownerKey>" },
7571
+ discard: { type: "boolean" },
7572
+ public: { type: "boolean" }
7573
+ },
7574
+ exclusive: [
7575
+ ["public", "owner"],
7576
+ ["public", "discard"]
7577
+ ],
7287
7578
  async run(ctx, { args, flags }) {
7579
+ if (flags.public) return pullPublic(ctx, args[0]);
7288
7580
  const slug = args[0];
7289
7581
  let ownerKey = typeof flags.owner === "string" ? flags.owner : void 0;
7290
7582
  const problems = [];
@@ -7347,6 +7639,14 @@ var init_ds = __esm({
7347
7639
  async run(ctx, { args, flags }) {
7348
7640
  const session = await openSession(ctx);
7349
7641
  const given2 = path15.resolve(ctx.cwd, args[0]);
7642
+ const inPublic = path15.relative(publicDir(ctx.home, session.env), given2);
7643
+ if (!inPublic.startsWith("..") && !path15.isAbsolute(inPublic)) {
7644
+ throw new CliError(
7645
+ "CLI_PUBLIC_READ_ONLY",
7646
+ `${given2} is one of Kombai's public design systems, which are read-only: it cannot be pushed.`,
7647
+ { details: { path: given2 } }
7648
+ );
7649
+ }
7350
7650
  let bytes;
7351
7651
  try {
7352
7652
  bytes = await fs15.readFile(given2);
@@ -7503,6 +7803,19 @@ var init_ds = __esm({
7503
7803
  details: { ownerKeys: owners }
7504
7804
  });
7505
7805
  }
7806
+ if (!owners.length) {
7807
+ const listed = await listPublic(ctx, session.hosts.web).catch((error2) => {
7808
+ if (error2 instanceof CliError) return [];
7809
+ throw error2;
7810
+ });
7811
+ if (listed.some((item) => item.id === slug)) {
7812
+ throw new CliError(
7813
+ "CLI_PUBLIC_READ_ONLY",
7814
+ `${slug} is one of Kombai's public design systems, which are read-only: it cannot be deleted.`,
7815
+ { details: { id: slug } }
7816
+ );
7817
+ }
7818
+ }
7506
7819
  ownerKey = owners[0];
7507
7820
  }
7508
7821
  for (let attempt = 0; ; attempt++) {
@@ -29935,6 +30248,11 @@ function createLoginRunner(ctx) {
29935
30248
  };
29936
30249
  return {
29937
30250
  start,
30251
+ reopen: async () => {
30252
+ const url2 = current?.waiting?.url;
30253
+ if (typeof url2 !== "string" || !ctx.hasDisplay) return false;
30254
+ return ctx.openUrl(url2);
30255
+ },
29938
30256
  running: () => current !== null,
29939
30257
  takeUnread,
29940
30258
  takeFailure: (reader) => {
@@ -30405,8 +30723,18 @@ var init_tools = __esm({
30405
30723
 
30406
30724
  // src/mcp/sign-in-card.js
30407
30725
  function refused(code2, message, plansLink) {
30408
- const body = { error_code: code2, error_message: message, ...plansLink ? { plans_link: plansLink } : {} };
30409
- return { isError: true, content: [{ type: "text", text: JSON.stringify(body) }] };
30726
+ return { isError: true, content: [{ type: "text", text: refusalText(code2, message, plansLink) }] };
30727
+ }
30728
+ function cardWords(code2, message, plansLink, extra) {
30729
+ return { content: [{ type: "text", text: refusalText(code2, message, plansLink, extra) }] };
30730
+ }
30731
+ function refusalText(code2, message, plansLink, extra) {
30732
+ return JSON.stringify({
30733
+ error_code: code2,
30734
+ error_message: message,
30735
+ ...plansLink ? { plans_link: plansLink } : {},
30736
+ ...extra
30737
+ });
30410
30738
  }
30411
30739
  async function signInCardData(ctx, reason) {
30412
30740
  const reasons = (
@@ -30424,30 +30752,48 @@ async function signInCardData(ctx, reason) {
30424
30752
  const entry = await readEntry(ctx.home, env);
30425
30753
  if (!hasGuest(entry)) {
30426
30754
  const keyLive = typeof entry.key === "string" && entry.key !== "" && Date.parse(entry.expires ?? "") > ctx.now();
30427
- return keyLive ? refused("signed_in", "This machine is signed in to Kombai.") : refused("not_guest", "There is no guest canvas on this machine. Run kombai login in a terminal to sign in.");
30755
+ if (keyLive) return cardWords("signed_in", "This machine is signed in to Kombai.", void 0, emailOf(entry));
30756
+ return { reason: SignInReason.Start, line: LINES[SignInReason.Start], guest: !holdsAccount(entry) };
30428
30757
  }
30758
+ if (valid === SignInReason.Start) return { reason: SignInReason.Account, line: LINES[SignInReason.Account] };
30429
30759
  if (valid === SignInReason.Ending) {
30430
30760
  const daysLeft = Math.ceil((Date.parse(entry.guestExpires ?? "") - ctx.now()) / DAY_MS);
30431
30761
  if (!(daysLeft >= 1 && daysLeft <= ENDING_DAYS)) {
30432
- return refused("not_ending", `This guest canvas does not end within ${ENDING_DAYS} days.`);
30762
+ return cardWords(
30763
+ "not_ending",
30764
+ `This guest canvas does not end within ${ENDING_DAYS} days.`,
30765
+ void 0,
30766
+ typeof entry.guestExpires === "string" && daysLeft > ENDING_DAYS ? { ends_at: entry.guestExpires } : void 0
30767
+ );
30433
30768
  }
30434
30769
  const line = daysLeft === 1 ? "Your guest canvas ends tomorrow." : `Your guest canvas ends in ${daysLeft} days.`;
30435
30770
  return { reason: valid, line };
30436
30771
  }
30437
30772
  return { reason: valid, line: LINES[valid] };
30438
30773
  }
30774
+ function emailOf(entry) {
30775
+ return typeof entry.email === "string" && entry.email ? { email: entry.email } : void 0;
30776
+ }
30439
30777
  async function showSignIn(ctx, args) {
30440
30778
  const data = await signInCardData(ctx, args.reason);
30441
30779
  if ("content" in data) return data;
30442
- return {
30443
- structuredContent: { sign_in: data },
30444
- content: [
30445
- {
30446
- type: "text",
30447
- text: `Showing Kombai's sign-in card in the chat. The user signs in from it: ${END_TURN}`
30448
- }
30449
- ]
30450
- };
30780
+ const text = data.reason === SignInReason.Start ? data.guest ? `Showing Kombai's sign-in card in the chat, which asks the user to sign in or try Kombai without an account. Don't ask in text: ${END_TURN} When the user says to carry on, run kombai whoami.` : `Showing Kombai's sign-in card in the chat. This machine has signed in before, so it offers sign-in only: ${END_TURN} When the user says to carry on, run kombai whoami.` : data.reason === SignInReason.Ending ? (
30781
+ // A reminder, not a refusal: the guest can still design, so the request goes on.
30782
+ "Showing Kombai's sign-in card in the chat, which tells the user the guest canvas ends soon and offers sign-in. Carry on with the user's request; don't run or offer kombai login in text."
30783
+ ) : `Showing Kombai's sign-in card in the chat. The user signs in from it: ${END_TURN}`;
30784
+ return { structuredContent: { sign_in: data }, content: [{ type: "text", text }] };
30785
+ }
30786
+ async function chatGuest(ctx) {
30787
+ try {
30788
+ const line = (
30789
+ /** @type {Record<string, unknown>} */
30790
+ await guest.run(ctx, { flags: {}, args: [] })
30791
+ );
30792
+ return answer(line.status === "guest" ? { status: SignInStatus.Guest } : { status: SignInStatus.SignedIn });
30793
+ } catch (error2) {
30794
+ if (!(error2 instanceof CliError)) throw error2;
30795
+ return answer(failedWith(error2));
30796
+ }
30451
30797
  }
30452
30798
  function statusOfClaim(claim2) {
30453
30799
  if (claim2 === null) return { status: SignInStatus.SignedIn };
@@ -30469,17 +30815,18 @@ function statusOfClaim(claim2) {
30469
30815
  }
30470
30816
  }
30471
30817
  }
30472
- async function chatSignIn(ctx, runner, args) {
30818
+ async function chatSignIn(ctx, runner, args, besideChat) {
30473
30819
  const waitS = typeof args.wait === "number" && Number.isFinite(args.wait) ? Math.min(SIGN_IN_MAX_WAIT_S, Math.max(0, Math.floor(args.wait))) : 0;
30820
+ if (args.reopen === true) return answer({ reopened: await runner.reopen() });
30474
30821
  const { claimOrg } = args;
30475
30822
  if (claimOrg !== void 0) {
30476
30823
  if (typeof claimOrg !== "string" || !DESIGN_ID.orgId.test(claimOrg)) {
30477
30824
  return refused("invalid_arguments", "claimOrg must be an organization id.");
30478
30825
  }
30479
- return answer(await claimInto(ctx, claimOrg));
30826
+ return answer(await withCanvas(ctx, await claimInto(ctx, claimOrg), besideChat));
30480
30827
  }
30481
30828
  const unread = runner.running() ? null : runner.takeUnread(LoginReader.Card);
30482
- if (unread) return answer(statusOfLogin(unread));
30829
+ if (unread) return answer(await withCanvas(ctx, statusOfLogin(unread), besideChat));
30483
30830
  const state = runner.start();
30484
30831
  await state.started;
30485
30832
  const settled = await Promise.race([state.settled, ctx.sleep(waitS * 1e3).then(() => null)]);
@@ -30488,7 +30835,29 @@ async function chatSignIn(ctx, runner, args) {
30488
30835
  return answer({ status: SignInStatus.SigningIn, match_code: typeof matchCode === "string" ? matchCode : null });
30489
30836
  }
30490
30837
  runner.takeUnread(LoginReader.Card);
30491
- return answer(statusOfLogin(settled));
30838
+ return answer(await withCanvas(ctx, statusOfLogin(settled), besideChat));
30839
+ }
30840
+ async function withCanvas(ctx, claimed, besideChat) {
30841
+ const { canvas } = claimed;
30842
+ if (claimed.status !== SignInStatus.Claimed || typeof canvas !== "string") return claimed;
30843
+ const status = { ...claimed, beside_chat: besideChat };
30844
+ try {
30845
+ const session = await openSession(ctx, { claim: false });
30846
+ const read2 = (
30847
+ /** @type {{ document?: { name?: unknown, nodes?: Record<string, { type?: unknown }> } }} */
30848
+ (await session.api.call({ method: "GET", path: `/design/canvases/${canvas}` })).body
30849
+ );
30850
+ const nodes = read2?.document?.nodes;
30851
+ return {
30852
+ ...status,
30853
+ canvas_name: typeof read2?.document?.name === "string" ? read2.document.name : null,
30854
+ designs: nodes && typeof nodes === "object" ? Object.values(nodes).filter((n) => n?.type === "variant").length : null,
30855
+ url: `${session.hosts.web}/c/${canvas}`
30856
+ };
30857
+ } catch (error2) {
30858
+ if (!(error2 instanceof CliError)) throw error2;
30859
+ return status;
30860
+ }
30492
30861
  }
30493
30862
  async function claimInto(ctx, orgId) {
30494
30863
  try {
@@ -30513,6 +30882,7 @@ var init_sign_in_card = __esm({
30513
30882
  init_define_KOMBAI_TELEMETRY();
30514
30883
  init_contract();
30515
30884
  init_output();
30885
+ init_auth();
30516
30886
  init_session();
30517
30887
  init_store();
30518
30888
  init_login_runner();
@@ -30529,10 +30899,16 @@ var init_sign_in_card = __esm({
30529
30899
  /** Any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED. */
30530
30900
  Account: "account",
30531
30901
  /** Once, in the guest's last 7 days. */
30532
- Ending: "ending"
30902
+ Ending: "ending",
30903
+ /**
30904
+ * A machine with no key and no guest: the first choice, sign in or try Kombai as a guest (`guest: false` when this
30905
+ * machine has signed in before, which offers sign-in only). Any reason on such a machine shows it.
30906
+ */
30907
+ Start: "start"
30533
30908
  });
30534
30909
  END_TURN = "end your turn, and don't run or offer kombai login in text.";
30535
30910
  LINES = Object.freeze({
30911
+ [SignInReason.Start]: "Kombai works best signed in. Sign in now, or try it without an account?",
30536
30912
  [SignInReason.CanvasFull]: "This guest canvas is full.",
30537
30913
  [SignInReason.SecondCanvas]: "More canvases need a Kombai account.",
30538
30914
  [SignInReason.Taste]: "Taste needs a Kombai account.",
@@ -30551,7 +30927,9 @@ var init_sign_in_card = __esm({
30551
30927
  /** Signed in, with nothing left to claim. */
30552
30928
  SignedIn: "signed_in",
30553
30929
  /** The sign-in or the claim ended for good: `error` is its code and words. */
30554
- Failed: "failed"
30930
+ Failed: "failed",
30931
+ /** chat_guest made this machine a guest (or found it one already). */
30932
+ Guest: "guest"
30555
30933
  });
30556
30934
  DAY_MS = 24 * 60 * 60 * 1e3;
30557
30935
  ENDING_DAYS = 7;
@@ -30585,7 +30963,7 @@ function createCards(ctx, options) {
30585
30963
  const toolsOf = (spec) => {
30586
30964
  if (spec === TASTE) return [tasteTool(uriOf(spec))];
30587
30965
  if (spec === PLANS) return [plansTool(uriOf(spec)), checkoutTool()];
30588
- if (spec === SIGN_IN) return [signInTool(uriOf(spec)), chatSignInTool()];
30966
+ if (spec === SIGN_IN) return [signInTool(uriOf(spec)), chatSignInTool(), chatGuestTool()];
30589
30967
  return [];
30590
30968
  };
30591
30969
  return (await available(set2)).flatMap(toolsOf);
@@ -30630,7 +31008,10 @@ function createCards(ctx, options) {
30630
31008
  if (name === PLANS_CARD_TOOL && specs.includes(PLANS)) return showPlans(ctx, signInBuilt);
30631
31009
  if (name === CHECKOUT_TOOL && specs.includes(PLANS)) return checkout(ctx, args, signInBuilt);
30632
31010
  if (name === SIGN_IN_CARD_TOOL && specs.includes(SIGN_IN)) return showSignIn(ctx, args);
30633
- if (name === CHAT_SIGN_IN_TOOL && specs.includes(SIGN_IN)) return chatSignIn(ctx, options.login, args);
31011
+ if (name === CHAT_SIGN_IN_TOOL && specs.includes(SIGN_IN)) {
31012
+ return chatSignIn(ctx, options.login, args, set2 === Cards.All);
31013
+ }
31014
+ if (name === CHAT_GUEST_TOOL && specs.includes(SIGN_IN)) return chatGuest(ctx);
30634
31015
  return null;
30635
31016
  }
30636
31017
  };
@@ -30655,7 +31036,7 @@ async function showTaste(ctx, args, signInBuilt) {
30655
31036
  } catch (error2) {
30656
31037
  if (!(error2 instanceof CliError)) throw error2;
30657
31038
  if (error2.code === SIGNIN_REQUIRED) return guestRefusal(error2, SignInReason.Taste, signInBuilt);
30658
- return failed(`Kombai could not show this taste brief: ${error2.message}`);
31039
+ return shownWords(`Kombai could not show this taste brief: ${error2.message}`);
30659
31040
  }
30660
31041
  }
30661
31042
  async function showPlans(ctx, signInBuilt) {
@@ -30667,7 +31048,7 @@ async function showPlans(ctx, signInBuilt) {
30667
31048
  const session = await openSession(ctx);
30668
31049
  const status = await readSubscriptionStatus(session);
30669
31050
  if (status?.assistantSubscriptionIsTeamPlan) {
30670
- return refused("team_plan", "A team's plan is bought by the team's admin, on Kombai's plans page.", plansLink);
31051
+ return cardWords("team_plan", "A team's plan is bought by the team's admin, on Kombai's plans page.", plansLink);
30671
31052
  }
30672
31053
  account = accountOf(status);
30673
31054
  plans = (await session.api.call({
@@ -30679,7 +31060,7 @@ async function showPlans(ctx, signInBuilt) {
30679
31060
  } catch (error2) {
30680
31061
  if (!(error2 instanceof CliError)) throw error2;
30681
31062
  if (error2.code === SIGNIN_REQUIRED) return guestRefusal(error2, SignInReason.Account, signInBuilt);
30682
- return refused("plans_failed", `Kombai could not load its plans (${error2.code}).`, plansLink);
31063
+ return cardWords("plans_failed", `Kombai could not load its plans (${error2.code}).`, plansLink);
30683
31064
  }
30684
31065
  return {
30685
31066
  // The card hands workspace_root back on Buy, as it does to the gateway; chat_checkout does not read it.
@@ -30771,7 +31152,6 @@ function guestRefusal(error2, reason, signInBuilt) {
30771
31152
  error_message: `${line} Kombai's sign-in card is showing in the chat: ${END_TURN}`
30772
31153
  };
30773
31154
  return {
30774
- isError: true,
30775
31155
  structuredContent: { sign_in: { reason, line } },
30776
31156
  content: [{ type: "text", text: JSON.stringify(body) }]
30777
31157
  };
@@ -30779,7 +31159,10 @@ function guestRefusal(error2, reason, signInBuilt) {
30779
31159
  function failed(message) {
30780
31160
  return { isError: true, content: [{ type: "text", text: message }] };
30781
31161
  }
30782
- var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, chatSignInTool;
31162
+ function shownWords(message) {
31163
+ return { content: [{ type: "text", text: message }] };
31164
+ }
31165
+ var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, CHAT_GUEST_TOOL, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, chatSignInTool, chatGuestTool;
30783
31166
  var init_cards = __esm({
30784
31167
  "src/mcp/cards.js"() {
30785
31168
  "use strict";
@@ -30799,12 +31182,14 @@ var init_cards = __esm({
30799
31182
  CHECKOUT_TOOL = "chat_checkout";
30800
31183
  SIGN_IN_CARD_TOOL = "sign_in_card";
30801
31184
  CHAT_SIGN_IN_TOOL = "chat_sign_in";
31185
+ CHAT_GUEST_TOOL = "chat_guest";
30802
31186
  SIGNIN_REQUIRED = "CLI_SIGNIN_REQUIRED";
30803
31187
  CARDS_DIR = fileURLToPath(new URL("./mcp-apps/", import.meta.url));
30804
31188
  GOOGLE_FONTS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
30805
31189
  INLINE = {
30806
31190
  "openai/ui": { preferredDisplayMode: "inline", availableDisplayModes: ["inline"] },
30807
- "openai/widgetShowCodexWidgetInline": true
31191
+ "openai/widgetShowCodexWidgetInline": true,
31192
+ "openai/widgetMinFrameHeight": 120
30808
31193
  };
30809
31194
  TASTE = {
30810
31195
  uriBase: "ui://kombai/cli-design-taste",
@@ -30827,11 +31212,17 @@ var init_cards = __esm({
30827
31212
  SIGN_IN = {
30828
31213
  uriBase: "ui://kombai/cli-sign-in",
30829
31214
  bundle: "sign-in.js",
30830
- title: "Kombai sign-in",
31215
+ // Codex heads the card "Opened <title>": "Opened Kombai sign-in" read as if a sign-in page had opened.
31216
+ title: "Kombai",
30831
31217
  rootId: "kombai-sign-in",
30832
31218
  global: "__kombaiSignIn",
30833
31219
  // No fetches at all: the card's data comes in the tool result, and Sign in goes through chat_sign_in.
30834
- meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true }, ...INLINE }
31220
+ // Codex sizes a card at 480 px until it reports its height; the sign-in card's states are about a third of that.
31221
+ meta: {
31222
+ ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true },
31223
+ ...INLINE,
31224
+ "openai/widgetHeightHint": 180
31225
+ }
30835
31226
  };
30836
31227
  specsIn = (set2) => set2 === Cards.All ? [TASTE, PLANS, SIGN_IN] : set2 === Cards.Taste ? [TASTE, SIGN_IN] : [];
30837
31228
  reads = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
@@ -30890,8 +31281,8 @@ var init_cards = __esm({
30890
31281
  });
30891
31282
  signInTool = (resourceUri) => ({
30892
31283
  name: SIGN_IN_CARD_TOOL,
30893
- title: "Kombai sign-in",
30894
- description: "Show Kombai's sign-in card in this chat for a guest (kombai whoami printed status guest, or claim pending). Call it with the reason instead of offering kombai login in text: canvas_full for DESIGN_GUEST_LIMIT with no canvasId in details; second_canvas for DESIGN_GUEST_LIMIT with one (still use that canvas); taste when taste is refused or asked for; repo_images for CLI_SIGNIN_REQUIRED with images in details; account for any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED; ending once per conversation when whoami's expires is within 7 days. Then end your turn. The user signs in from the card; never run kombai login for them unless they ask in the chat. When they say they have signed in, run kombai whoami.",
31284
+ title: "Kombai",
31285
+ description: "Show Kombai's sign-in card in this chat for a guest (kombai whoami printed status guest, or claim pending), or for a machine with neither a guest nor an account (reason start). Call it with the reason instead of offering kombai login in text: start when kombai whoami exits 3 (CLI_NOT_SIGNED_IN), in place of asking whether to sign in or try Kombai without an account; canvas_full for DESIGN_GUEST_LIMIT with no canvasId in details; second_canvas for DESIGN_GUEST_LIMIT with one (still use that canvas); taste when taste is refused or asked for; repo_images for CLI_SIGNIN_REQUIRED with images in details; account for any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED; ending once per conversation when whoami's expires is within 7 days. Then end your turn, except after ending, a reminder, where you carry on with the request. The user signs in from the card; never run kombai login for them unless they ask in the chat. When they say they have signed in, run kombai whoami.",
30895
31286
  inputSchema: {
30896
31287
  type: "object",
30897
31288
  properties: { reason: { type: "string", enum: Object.values(SignInReason) } },
@@ -30910,7 +31301,8 @@ var init_cards = __esm({
30910
31301
  type: "object",
30911
31302
  properties: {
30912
31303
  wait: { type: "integer", minimum: 0, maximum: SIGN_IN_MAX_WAIT_S },
30913
- claimOrg: { type: "string" }
31304
+ claimOrg: { type: "string" },
31305
+ reopen: { type: "boolean" }
30914
31306
  },
30915
31307
  additionalProperties: false
30916
31308
  },
@@ -30918,6 +31310,15 @@ var init_cards = __esm({
30918
31310
  annotations: acts,
30919
31311
  _meta: { ui: { visibility: ["app"] } }
30920
31312
  });
31313
+ chatGuestTool = () => ({
31314
+ name: CHAT_GUEST_TOOL,
31315
+ title: "Try Kombai as a guest",
31316
+ description: "The start card's Try without an account: makes this machine a Kombai guest (kombai guest), with one canvas.",
31317
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
31318
+ icons: icons(),
31319
+ annotations: acts,
31320
+ _meta: { ui: { visibility: ["app"] } }
31321
+ });
30921
31322
  }
30922
31323
  });
30923
31324
 
@@ -30959,9 +31360,9 @@ var init_stdio3 = __esm({
30959
31360
 
30960
31361
  // src/mcp/view-html.js
30961
31362
  function viewHtml(version2, host, options = {}) {
30962
- return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS));
31363
+ return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS)).replace("{{COVER_MS}}", String(options.coverMs ?? COVER_MS)).replace("{{RECHECK_MS}}", String(options.recheckMs ?? RECHECK_MS));
30963
31364
  }
30964
- var VIEW_HTML, CLAIM_RETRY_MS;
31365
+ var VIEW_HTML, CLAIM_RETRY_MS, COVER_MS, RECHECK_MS;
30965
31366
  var init_view_html = __esm({
30966
31367
  "src/mcp/view-html.js"() {
30967
31368
  "use strict";
@@ -30977,34 +31378,57 @@ html,body{margin:0;height:100%;overflow:hidden;font:13px system-ui,sans-serif;co
30977
31378
  html.dark body{color:#f1f3f5;background:#1e1e1e}
30978
31379
  #frame{position:fixed;inset:0;width:100%;height:100%;border:0;display:none;background:transparent}
30979
31380
  #screen{position:fixed;inset:0;display:grid;place-items:center;text-align:center;padding:24px}
30980
- #screen b{display:block;font-size:15px;margin-bottom:6px}
30981
- #screen p{margin:0 0 14px;color:#68717b;max-width:36em}
31381
+ #screen.over{z-index:3;background:rgba(252,251,244,.72);backdrop-filter:blur(2px)}
31382
+ html.dark #screen.over{background:rgba(20,20,20,.72)}
31383
+ #panel{max-width:380px}
31384
+ #screen.over #panel{text-align:left;padding:24px;border:1px solid #e3e5e8;border-radius:12px;background:#fff;box-shadow:0 8px 28px rgba(0,0,0,.12)}
31385
+ html.dark #screen.over #panel{background:#262626;border-color:#3a3a3a;box-shadow:0 8px 28px rgba(0,0,0,.4)}
31386
+ #screen b{display:block;font-size:16px;font-weight:600;margin-bottom:6px}
31387
+ #screen p{margin:0 0 16px;color:#68717b;max-width:36em;line-height:1.5}
30982
31388
  html.dark #screen p{color:#9aa3ad}
30983
- #screen code{font:600 15px ui-monospace,Menlo,monospace;letter-spacing:.08em}
31389
+ #code{display:inline-block;margin:0 0 16px;padding:6px 12px;border:1px solid #d8dbdf;border-radius:8px;background:rgba(0,0,0,.03);font:600 20px ui-monospace,Menlo,monospace;letter-spacing:.08em}
31390
+ html.dark #code{border-color:#444;background:rgba(255,255,255,.05)}
31391
+ #actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
31392
+ #screen.over #actions{justify-content:flex-start}
31393
+ #actions.stack{flex-direction:column;align-items:stretch}
31394
+ #actions.stack button{text-align:left}
30984
31395
  button{font:inherit;padding:7px 14px;border-radius:8px;border:1px solid #c9ccd1;background:#fff;color:#272c31;cursor:pointer}
30985
31396
  html.dark button{background:#2a2a2a;color:#f1f3f5;border-color:#444}
30986
- button.primary{background:#1f6f5c;color:#fff;border-color:#1f6f5c}
31397
+ button:focus-visible{outline:2px solid #48de94;outline-offset:1px}
31398
+ /* Both selectors: html.dark button would otherwise win over a lone button.primary and grey the main action out. */
31399
+ button.primary,html.dark button.primary{background:#48de94;color:#151615;border-color:#48de94;font-weight:600}
31400
+ button.primary:hover,html.dark button.primary:hover{background:#3bc583;border-color:#3bc583}
30987
31401
  #link{position:fixed;left:0;right:0;top:0;display:none;align-items:center;gap:10px;padding:8px 12px;background:#fff;border-bottom:1px solid #e3e5e8;box-shadow:0 2px 8px rgba(0,0,0,.08);z-index:2}
30988
31402
  html.dark #link{background:#262626;border-color:#3a3a3a}
30989
31403
  #link span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
30990
31404
  #notice{position:fixed;left:0;right:0;top:0;display:none;align-items:center;gap:10px;padding:8px 12px;background:#fff;border-bottom:1px solid #e3e5e8;box-shadow:0 2px 8px rgba(0,0,0,.08);z-index:2}
30991
31405
  html.dark #notice{background:#262626;border-color:#3a3a3a}
30992
31406
  #notice span{flex:1;min-width:0}
31407
+ /* The cover over a page being replaced: a veil in the view's background that takes every click, under the hosted
31408
+ page's logo loader (components/ui/loader.tsx LogoLoader) as CSS can draw it: the logo's fill, size and glow. */
31409
+ #cover{position:fixed;inset:0;z-index:1;display:grid;place-items:center;cursor:progress;background:rgba(252,251,244,.6)}
31410
+ html.dark #cover{background:rgba(30,30,30,.6)}
31411
+ #cover::after{content:'';width:56px;height:56px;border-radius:10px;background:#48de94;animation:glow 1.5s ease-in-out infinite alternate}
31412
+ @keyframes glow{from{opacity:.35;filter:drop-shadow(0 0 0 rgba(72,222,148,0))}to{opacity:1;filter:drop-shadow(0 0 16px rgba(72,222,148,.55))}}
31413
+ @media (prefers-reduced-motion:reduce){#cover::after{animation:none}}
30993
31414
  [hidden]{display:none!important}
30994
31415
  </style>
30995
31416
  </head>
30996
31417
  <body>
30997
- <div id="screen" role="status"><div><b id="title">Kombai</b><p id="body">Connecting to {{HOST_LABEL}}…</p><div id="actions"></div></div></div>
31418
+ <div id="screen" role="status"><div id="panel"><b id="title">Kombai</b><p id="body">Connecting to {{HOST_LABEL}}…</p><code id="code" hidden></code><div id="actions"></div></div></div>
30998
31419
  <div id="link"><span id="link-text"></span><button id="link-open" class="primary" type="button">Open</button><button id="link-dismiss" type="button">Not now</button></div>
30999
31420
  <div id="notice"><span>Sign-in didn't finish.</span><button id="notice-retry" class="primary" type="button">Try again</button></div>
31000
31421
  <iframe id="frame" title="Kombai canvas" allow="clipboard-write"></iframe>
31422
+ <div id="cover" role="status" aria-label="Loading" hidden></div>
31001
31423
  <script>
31002
31424
  (() => {
31003
31425
  var CLI_VERSION = '{{CLI_VERSION}}';
31004
31426
  var HOST_LABEL = '{{HOST_LABEL}}', HOST_EMBED = '{{HOST_EMBED}}';
31005
31427
  var CLAIM_RETRY_MS = {{CLAIM_RETRY_MS}}, CLAIM_TRIES = 3;
31428
+ var COVER_MS = {{COVER_MS}}, RECHECK_MS = {{RECHECK_MS}};
31006
31429
  var SESSION_TOOL = 'canvas_app_session', ACCOUNT_TOOL = 'canvas_app_account', CREATE_TOOL = 'canvas_app_create';
31007
- // Until the hosted canvas frame fix lands, every message from the page is a draft, whatever the page asked.
31430
+ // Every message from the page is a draft, whatever the page asked, while this and the page's ACTIONS_SENT_INTO_CHAT
31431
+ // are off (embed-bridge.ts says why that is a product decision now, not a wait for the frame fix).
31008
31432
  var SEND_ACTIONS = false;
31009
31433
  var EMBED = 'embed', PROTOCOL = 1;
31010
31434
  var RESULT_WAIT_MS = 2000, SIGN_IN_WAIT_S = 20;
@@ -31015,15 +31439,24 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31015
31439
  var title = document.getElementById('title');
31016
31440
  var body = document.getElementById('body');
31017
31441
  var actions = document.getElementById('actions');
31442
+ var code = document.getElementById('code');
31018
31443
  var frame = document.getElementById('frame');
31019
31444
  var linkBar = document.getElementById('link');
31020
31445
  var linkText = document.getElementById('link-text');
31021
31446
  var notice = document.getElementById('notice');
31447
+ var cover = document.getElementById('cover');
31022
31448
 
31023
- function show(t, b, buttons) {
31449
+ // opts.code: a match code, shown on its own line to compare with the browser's. opts.over: drawn over the framed
31450
+ // canvas, which stays as it is underneath, so closing the screen needs no reload. opts.stack: one button per row.
31451
+ function show(t, b, buttons, opts) {
31452
+ opts = opts || {};
31453
+ unwatch();
31024
31454
  title.textContent = t;
31025
31455
  body.textContent = b;
31456
+ code.textContent = opts.code || '';
31457
+ code.hidden = !opts.code;
31026
31458
  actions.textContent = '';
31459
+ actions.className = opts.stack ? 'stack' : '';
31027
31460
  (buttons || []).forEach(function (spec) {
31028
31461
  var button = document.createElement('button');
31029
31462
  button.type = 'button';
@@ -31032,13 +31465,41 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31032
31465
  button.addEventListener('click', spec.onClick);
31033
31466
  actions.appendChild(button);
31034
31467
  });
31468
+ var over = !!opts.over && framed();
31469
+ screen.classList.toggle('over', over);
31035
31470
  screen.hidden = false;
31036
- frame.style.display = 'none';
31037
31471
  notice.style.display = 'none';
31038
- // A screen replaces the frame: the home is no longer what the person sees.
31472
+ // A screen replaces the cover over a page switch; one drawn over the page leaves the page as it is.
31473
+ uncoverFrame();
31474
+ if (over) return;
31475
+ frame.style.display = 'none';
31476
+ // A screen replaces the frame: the home is no longer what the person sees. One drawn over it leaves it there.
31039
31477
  framedHome = false;
31040
31478
  framedGuest = false;
31041
31479
  }
31480
+ function framed() { return frame.style.display === 'block' && !!frame.getAttribute('src'); }
31481
+
31482
+ // A sign-in or no-canvas screen asks again now and then while it is on screen, and when the view comes back into
31483
+ // sight: the user may have signed in, or made a canvas, from another chat since. Only an answer that changes the
31484
+ // screen is acted on; any other screen stops the asking.
31485
+ var watching = null, watchTimer = null;
31486
+ function watch(status) { watching = status; clearTimeout(watchTimer); watchTimer = setTimeout(recheck, RECHECK_MS); }
31487
+ function unwatch() { watching = null; clearTimeout(watchTimer); }
31488
+ function recheck() {
31489
+ var was = watching;
31490
+ if (!was) return;
31491
+ if (document.hidden) { watch(was); return; }
31492
+ callTool(SESSION_TOOL, sessionArgs()).then(function (answer) {
31493
+ if (watching !== was) return;
31494
+ if (answer.status === was) { watch(was); return; }
31495
+ unwatch();
31496
+ settle(answer);
31497
+ }, function () { if (watching === was) watch(was); });
31498
+ }
31499
+ document.addEventListener('visibilitychange', function () {
31500
+ if (!document.hidden && watching) { clearTimeout(watchTimer); recheck(); }
31501
+ });
31502
+ function closeScreen() { screen.hidden = true; screen.classList.remove('over'); }
31042
31503
 
31043
31504
  if (window.parent === window) { show('Kombai', 'Open this view from ' + HOST_LABEL + '.'); return; }
31044
31505
 
@@ -31063,6 +31524,8 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31063
31524
  var canvas = null, node = null;
31064
31525
  var openingResult = null, openingError = null, openingArgs = null;
31065
31526
  var claimTries = 0, retryTimer = null;
31527
+ // Each open's number: only the latest one's answer is used. The cover's own timer (coverFrame).
31528
+ var opens = 0, coverTimer = null;
31066
31529
  var sawResult;
31067
31530
  var resultSeen = new Promise(function (resolve) { sawResult = resolve; });
31068
31531
 
@@ -31201,14 +31664,15 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31201
31664
  function fromPage(m) {
31202
31665
  if (!m || m.kombai !== EMBED || m.v !== PROTOCOL || typeof m.kind !== 'string') return;
31203
31666
  if (m.kind === 'ready') { postToFrame(hello()); return; }
31204
- // A design's script can forge this: only the loaded home (no design in it) signs in at once.
31667
+ // A design's script can forge this: only the loaded home (no design in it), or a message right after a click,
31668
+ // signs in at once.
31205
31669
  if (m.kind === 'sign-in') {
31206
31670
  clearTimeout(retryTimer);
31207
- if (framedHome) signIn(); else signInScreen();
31671
+ if (framedHome || justClicked()) signIn(); else signInScreen();
31208
31672
  return;
31209
31673
  }
31210
31674
  // The page could not redeem its ticket: this page's sign-in screen (only a screen, so a forged one costs nothing).
31211
- if (m.kind === 'signed-out') { clearTimeout(retryTimer); signInScreen(); return; }
31675
+ if (m.kind === 'signed-out') { clearTimeout(retryTimer); signInScreen(null, true); return; }
31212
31676
  // The page finished a claim: a fresh ticket for the same canvas, framed again.
31213
31677
  if (m.kind === 'claimed') { claimTries = 0; open(); return; }
31214
31678
  if ((m.kind === 'action' || m.kind === 'draft') && typeof m.text === 'string' && m.text) {
@@ -31250,8 +31714,14 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31250
31714
  if (m.kind === 'open-link' && typeof m.url === 'string' && /^https:\/\//i.test(m.url)) offerLink(m.url);
31251
31715
  }
31252
31716
 
31717
+ /** The user clicked this page or the frame a moment ago (transient user activation). */
31718
+ function justClicked() { return !!(navigator.userActivation && navigator.userActivation.isActive); }
31719
+
31253
31720
  var offeredUrl = null;
31254
31721
  function offerLink(url) {
31722
+ var origin = '';
31723
+ try { origin = new URL(url).origin; } catch (e) { return; }
31724
+ if (origin === hosted && justClicked()) { request('ui/open-link', { url: url }).catch(function () {}); return; }
31255
31725
  // One offer at a time: a later message cannot swap the address under a bar the user is about to click.
31256
31726
  if (offeredUrl) return;
31257
31727
  offeredUrl = url;
@@ -31285,14 +31755,24 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31285
31755
  var mark = '&r=' + ++reloads;
31286
31756
  address = address.indexOf('#') < 0 ? address + mark : address.replace('#', mark + '#');
31287
31757
  }
31288
- screen.hidden = true;
31758
+ // The page already in the frame stays its window until the new one loads: covered, so it never shows bare again.
31759
+ // The timer runs from here, not from open(): a ticket call always ends (showFrame or show); a load may never come.
31760
+ if (current) {
31761
+ coverFrame();
31762
+ coverTimer = setTimeout(uncoverFrame, COVER_MS);
31763
+ }
31764
+ closeScreen();
31289
31765
  notice.style.display = 'none';
31290
31766
  frame.style.display = 'block';
31291
31767
  // Trusted as the home only once loaded; the account is read on each load of the signed-in home.
31292
31768
  var home = !canvas;
31293
31769
  framedHome = false;
31294
31770
  framedGuest = false;
31771
+ var shown = opens;
31295
31772
  frame.addEventListener('load', function () {
31773
+ // The page being left finishing its load after a later open: it neither lifts the cover nor is trusted.
31774
+ if (shown !== opens) return;
31775
+ uncoverFrame();
31296
31776
  framedHome = home;
31297
31777
  framedGuest = home && guest;
31298
31778
  if (home && !guest) readAccount();
@@ -31303,6 +31783,18 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31303
31783
  var reloads = 0;
31304
31784
  function stripReload(address) { return address.replace(/&r=\d+$/, ''); }
31305
31785
 
31786
+ // The cover (#cover) keeps the page on screen, veiled and taking no click, from the moment the next page is asked
31787
+ // for until that page's load. A screen replaces it (show); showFrame lifts it after COVER_MS with no load, so a
31788
+ // page that never loads does not hold the view.
31789
+ function coverFrame() {
31790
+ clearTimeout(coverTimer);
31791
+ cover.hidden = false;
31792
+ }
31793
+ function uncoverFrame() {
31794
+ clearTimeout(coverTimer);
31795
+ cover.hidden = true;
31796
+ }
31797
+
31306
31798
  // The session tool answers the canvas id (and the design) it normalised from what the view was given, which may
31307
31799
  // be the raw canvas_app argument (a link) when the view fell back to tool-input. With no canvas it sends none, and
31308
31800
  // the answer carries none: the ticket is for /canvases.
@@ -31317,13 +31809,22 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31317
31809
  if (typeof answer.node === 'string') node = answer.node;
31318
31810
  }
31319
31811
  var SIGNING_IN = 'Finish in the browser; this view follows.';
31320
- var MATCH_CODE = 'Approve in the browser only if it shows this code; this view follows.';
31321
- function signInScreen(message) {
31322
- var title = canvas ? 'Sign in to Kombai to see this canvas' : 'Sign in to Kombai to see your canvases';
31812
+ var CHECK_CODE = 'Check that your browser shows this code, then approve. This view follows.';
31813
+ // replace: the framed page is of no use behind the screen (it could not redeem its ticket), so the screen takes its
31814
+ // place, as with nothing framed.
31815
+ function signInScreen(message, replace) {
31323
31816
  var buttons = [{ label: 'Sign in', primary: true, onClick: function () { signIn(); } }];
31324
- // With a frame already loaded (a guest's canvas) the person can go back to it; with none there is nothing to go back to.
31817
+ // Over a framed canvas (a guest's, whose page asked to sign in): Not now just closes this, and the canvas is as it
31818
+ // was. A frame loaded but hidden by an earlier screen opens again; with none there is nothing to go back to.
31819
+ if (framed() && !replace) {
31820
+ buttons.push({ label: 'Not now', onClick: closeScreen });
31821
+ show('Sign in to Kombai', message || 'Your guest canvas comes with you, at the same link. Kombai\u2019s sign-in opens in your browser.', buttons, { over: true });
31822
+ return;
31823
+ }
31325
31824
  if (frame.getAttribute('src')) buttons.push({ label: 'Not now', onClick: function () { open(); } });
31326
- show(title, message || 'Your browser opens Kombai\u2019s sign-in; this view follows.', buttons);
31825
+ var title = canvas ? 'Sign in to Kombai to see this canvas' : 'Sign in to Kombai to see your canvases';
31826
+ show(title, message || 'Kombai\u2019s sign-in opens in your browser; this view follows.', buttons);
31827
+ watch('not_signed_in');
31327
31828
  }
31328
31829
 
31329
31830
  // The statuses every session answer shares. False for one it does not know: the caller words that.
@@ -31343,7 +31844,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31343
31844
  showFrame(null);
31344
31845
  return true;
31345
31846
  }
31346
- if (answer.status === 'no_canvas') { show('Kombai', 'Ask your agent to make a design.'); return true; }
31847
+ if (answer.status === 'no_canvas') { show('Kombai', 'Ask your agent to make a design.'); watch('no_canvas'); return true; }
31347
31848
  if (answer.status === 'needs_org') {
31348
31849
  var buttons = (Array.isArray(answer.orgs) ? answer.orgs : [])
31349
31850
  .filter(function (org) {
@@ -31351,7 +31852,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31351
31852
  })
31352
31853
  .map(function (org) { return { label: org.name, onClick: function () { claim(org.id); } }; });
31353
31854
  if (!buttons.length) { askAgent(); return true; }
31354
- show('Which organization gets this canvas?', 'Your guest canvas moves into the one you choose.', buttons);
31855
+ show('Choose where this canvas goes', 'You\u2019re in more than one organization. The canvas moves into the one you pick.', buttons, { over: true, stack: true });
31355
31856
  return true;
31356
31857
  }
31357
31858
  if (answer.status === 'claim_pending') {
@@ -31374,7 +31875,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31374
31875
  return false;
31375
31876
  }
31376
31877
  function claim(orgId) {
31377
- show('Signing in…', 'Moving this canvas into your account…');
31878
+ show('Signing in…', 'Moving this canvas into your account…', [], { over: true });
31378
31879
  callTool(SESSION_TOOL, sessionArgs({ claimOrg: orgId })).then(settle, function (error) { show('Kombai', error.message); });
31379
31880
  }
31380
31881
  function settle(answer) {
@@ -31398,7 +31899,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31398
31899
  function signIn(code, polling) {
31399
31900
  clearTimeout(retryTimer);
31400
31901
  signingIn = true;
31401
- show('Signing in…', code ? 'Match code ' + code + '. ' + MATCH_CODE : SIGNING_IN);
31902
+ show('Approve in your browser', code ? CHECK_CODE : SIGNING_IN, [], { code: code, over: true });
31402
31903
  callTool(SESSION_TOOL, sessionArgs({ signIn: true, wait: polling ? SIGN_IN_WAIT_S : 0 })).then(function (answer) {
31403
31904
  takeIds(answer);
31404
31905
  if (answer.status === 'signing_in') {
@@ -31411,11 +31912,26 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31411
31912
  }, function (error) { signingIn = false; signInScreen(error.message); });
31412
31913
  }
31413
31914
 
31414
- // retry is the claim's own timer: the screen it set stays.
31915
+ // retry is the claim's own timer: the screen it set stays. A page on screen stays there under the cover until the
31916
+ // next one loads; with none, the opening screen. Only the latest open's answer is used: an earlier one's frames
31917
+ // nothing, however late it comes.
31415
31918
  function open(retry) {
31416
31919
  clearTimeout(retryTimer);
31417
- if (!retry) show('Kombai', canvas ? 'Opening the canvas…' : 'Opening Kombai…');
31418
- callTool(SESSION_TOOL, sessionArgs()).then(settle, function (error) { show('Kombai', error.message); });
31920
+ var mine = ++opens;
31921
+ if (!retry && frame.style.display === 'block') {
31922
+ // As a screen would, the page being left is no longer trusted as the home, and the notice goes; the page stays.
31923
+ notice.style.display = 'none';
31924
+ framedHome = false;
31925
+ framedGuest = false;
31926
+ coverFrame();
31927
+ } else if (!retry) {
31928
+ show('Kombai', canvas ? 'Opening the canvas…' : 'Opening Kombai…');
31929
+ }
31930
+ callTool(SESSION_TOOL, sessionArgs()).then(function (answer) {
31931
+ if (mine === opens) settle(answer);
31932
+ }, function (error) {
31933
+ if (mine === opens) show('Kombai', error.message);
31934
+ });
31419
31935
  }
31420
31936
 
31421
31937
  request('ui/initialize', {
@@ -31446,6 +31962,8 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31446
31962
  </body>
31447
31963
  </html>`;
31448
31964
  CLAIM_RETRY_MS = 3e3;
31965
+ COVER_MS = 1e4;
31966
+ RECHECK_MS = 2e4;
31449
31967
  }
31450
31968
  });
31451
31969
 
@@ -31654,7 +32172,7 @@ var init_claude_desktop = __esm({
31654
32172
  var design_system_default;
31655
32173
  var init_design_system = __esm({
31656
32174
  "src/skill/design-system.md"() {
31657
- design_system_default = '# Design systems\n\nA design system is a .ds file in the user\'s Kombai account, not the repo: YAML front matter between\n`---` lines holds the tokens; the markdown after it says how to use them. Read a pulled one as the\nmodel. `kombai ds push` checks it with ds-kit.\n\n- `name` (required) and `modes`: `[light]`, `[dark]` or `[light, dark]`.\n- `color.palette` (required): named colors as quoted hex, rgb() or hsl().\n- `color.semantic`: the 11 roles in the example. Each is a ref, or `{ light: <ref>, dark: <ref> }`.\n- `typography.family`, and `typography.textStyle` with fontFamily, fontSize, fontWeight, lineHeight.\n- Optional: spacing, radius, shadow, border, opacity, motion, breakpoint, components.\n\nEvery ref must name a key you defined: `{colors.X}` (palette, also written `{color.palette.X}`), `{typography.X}` (textStyle),\n`{radius.X}`, `{spacing.X}`, `{shadow.X}`. One ref per value. The body starts with a `>` line, then\noptional `##` sections: Instructions, Brand & Accent, Surface, Text, Status & Semantic, Fonts, Layout,\nComponents, Do, Don\'t, Notes. At most 1 MB.\n\n```\n---\nname: Acme\nmodes: [light]\ncolor:\n palette: { brand: "#3b5bdb", white: "#ffffff", ink: "#16181d", line: "#e4e7ec" }\n semantic:\n background.canvas: "{colors.white}"\n surface.default: "{colors.white}"\n surface.raised: "{colors.white}"\n text.primary: "{colors.ink}"\n text.secondary: "{colors.ink}"\n text.tertiary: "{colors.ink}"\n text.link: "{colors.brand}"\n border.default: "{colors.line}"\n border.focus: "{colors.brand}"\n primary.bg: "{colors.brand}"\n primary.fg: "{colors.white}"\ntypography:\n family: { sans: "Inter" }\n textStyle:\n body: { fontFamily: "Inter", fontSize: "16px", fontWeight: 400, lineHeight: 1.5 }\ncomponents:\n button: { type: button, label: "Get started", backgroundColor: "{colors.brand}", textColor: "{colors.white}", typography: "{typography.body}", padding: "10px 18px" }\n---\n\n> One indigo accent on white, Inter throughout.\n```\n\n## Commands\n\n- `kombai ds list`: each one\'s slug, name, ownerKey, and file (null if not pulled here).\n- `kombai ds pull <slug>` writes the file it prints. Edit it, then `kombai ds push <file>`.\n- To make one, write `<slug>.ds` outside the repo and push it. The file name gives the slug (lowercase\n letters, digits, dashes; a leading `ds-` is dropped); pick one `ds list` does not show. Then edit\n the file the push prints: pushing your first file again is a conflict.\n- A refused file exits 1 with CLI_INVALID_DESIGN_SYSTEM naming each problem: fix them and push again.\n Fix its warnings too.\n- `kombai ds delete <slug>` deletes one for everyone. Run it only when the user asks.\n\nownerKey is `org:<id>` (an organization\'s) or `user:<id>` (the user\'s own). A pulled file goes back to\nits owner; a new one goes to `--org <id>`, else the organization `kombai config org` saved. On\nDESIGN_ORG_REQUIRED, ask the user which of details.orgIds, then push with `--org <id>`. On\nCLI_OWNER_REQUIRED (a slug in several scopes), add `--owner <ownerKey>` from details.ownerKeys, asking\nthe user if unclear.\n\n## From a repo\n\n1. Read the Tailwind config, CSS custom properties (globals.css :root and .dark), theme or token\n files, the font setup and the shared components.\n2. Copy values; never invent a color. Name keys as the code does. Write `--primary: 222 47% 11%` as\n `"hsl(222 47% 11%)"`, and oklch or named colors as hex.\n3. Map each role by how the code uses a color: page, cards, text levels, links, dividers, focus ring,\n primary button and its text. With no match, reuse the closest ref.\n4. `[light, dark]` only when the code has dark values; roles that change become light/dark maps.\n5. Add text styles (headings, body, labels) and the spacing, radius, shadow and breakpoint scales the\n code defines.\n6. Add each real component and variant, typed button, link, icon, icon-round, input, tab, badge, nav,\n avatar, logo, section, card, divider or check, with a label from the UI.\n7. Body: up to 8 Instructions (which token for what), color sections naming `{colors.X}`, Fonts,\n Layout (max width, grid, gutters), a line per component, Do and Don\'t, and Notes for gaps.\n8. Check every ref, then push.\n\n## In designs\n\nDesigns do not link to a design system: canvas.json and nodes have no field for it. Pull it and write\nits values into the HTML (`bg-[#3b5bdb]`, or CSS variables in a `<style>`), following its\nInstructions, Do and Don\'t. The canvas\'s Apply menu asks to regenerate a design "with the <name>\ndesign system": find it by name in `kombai ds list`, pull it and the node, restyle the design keeping\nits content, and push the node. The user can view one at /ds/<slug> on the canvas site.\n\n## Conflicts\n\nExit 2 on a push (DESIGN_DESIGN_SYSTEM_CHANGED): it changed since you pulled it, or already existed.\nThe stored version is saved at details.remote. Merge it into your file and run the error\'s next\n(`kombai ds push <file> --merged`); if it is a different design system, rename your file instead.\n`kombai ds pull <slug> --discard` takes the stored one. Exit 2 on a pull: push your edits first, or\npull with --discard.\n';
32175
+ design_system_default = '# Design systems\n\nA design system is a .ds file in the user\'s Kombai account, not the repo: YAML front matter between\n`---` lines holds the tokens; the markdown after it says how to use them. Read a pulled one as the\nmodel. `kombai ds push` checks it with ds-kit.\n\n- `name` (required) and `modes`: `[light]`, `[dark]` or `[light, dark]`.\n- `color.palette` (required): named colors as quoted hex, rgb() or hsl().\n- `color.semantic`: the 11 roles in the example. Each is a ref, or `{ light: <ref>, dark: <ref> }`.\n- `typography.family`, and `typography.textStyle` with fontFamily, fontSize, fontWeight, lineHeight.\n- Optional: spacing, radius, shadow, border, opacity, motion, breakpoint, components.\n\nEvery ref must name a key you defined: `{colors.X}` (palette, also written `{color.palette.X}`), `{typography.X}` (textStyle),\n`{radius.X}`, `{spacing.X}`, `{shadow.X}`. One ref per value. The body starts with a `>` line, then\noptional `##` sections: Instructions, Brand & Accent, Surface, Text, Status & Semantic, Fonts, Layout,\nComponents, Do, Don\'t, Notes. At most 1 MB.\n\n```\n---\nname: Acme\nmodes: [light]\ncolor:\n palette: { brand: "#3b5bdb", white: "#ffffff", ink: "#16181d", line: "#e4e7ec" }\n semantic:\n background.canvas: "{colors.white}"\n surface.default: "{colors.white}"\n surface.raised: "{colors.white}"\n text.primary: "{colors.ink}"\n text.secondary: "{colors.ink}"\n text.tertiary: "{colors.ink}"\n text.link: "{colors.brand}"\n border.default: "{colors.line}"\n border.focus: "{colors.brand}"\n primary.bg: "{colors.brand}"\n primary.fg: "{colors.white}"\ntypography:\n family: { sans: "Inter" }\n textStyle:\n body: { fontFamily: "Inter", fontSize: "16px", fontWeight: 400, lineHeight: 1.5 }\ncomponents:\n button: { type: button, label: "Get started", backgroundColor: "{colors.brand}", textColor: "{colors.white}", typography: "{typography.body}", padding: "10px 18px" }\n---\n\n> One indigo accent on white, Inter throughout.\n```\n\n## Commands\n\n- `kombai ds list`: each one\'s slug, name, ownerKey, and file (null if not pulled here), and in\n publicDesignSystems Kombai\'s public ones, each with its id, name, description and file.\n- `kombai ds pull <slug>` writes the file it prints. Edit it, then `kombai ds push <file>`.\n- A public one is read-only: `kombai ds pull <id> --public` writes the file it prints. Use it as it is;\n never push or delete it.\n- To make one, write `<slug>.ds` outside the repo and push it. The file name gives the slug (lowercase\n letters, digits, dashes; a leading `ds-` is dropped); pick one `ds list` does not show. Then edit\n the file the push prints: pushing your first file again is a conflict.\n- A refused file exits 1 with CLI_INVALID_DESIGN_SYSTEM naming each problem: fix them and push again.\n Fix its warnings too.\n- `kombai ds delete <slug>` deletes one for everyone. Run it only when the user asks.\n\nownerKey is `org:<id>` (an organization\'s) or `user:<id>` (the user\'s own). A pulled file goes back to\nits owner; a new one goes to `--org <id>`, else the organization `kombai config org` saved. On\nDESIGN_ORG_REQUIRED, ask the user which of details.orgIds, then push with `--org <id>`. On\nCLI_OWNER_REQUIRED (a slug in several scopes), add `--owner <ownerKey>` from details.ownerKeys, asking\nthe user if unclear.\n\n## From a repo\n\n1. Read the Tailwind config, CSS custom properties (globals.css :root and .dark), theme or token\n files, the font setup and the shared components.\n2. Copy values; never invent a color. Name keys as the code does. Write `--primary: 222 47% 11%` as\n `"hsl(222 47% 11%)"`, and oklch or named colors as hex.\n3. Map each role by how the code uses a color: page, cards, text levels, links, dividers, focus ring,\n primary button and its text. With no match, reuse the closest ref.\n4. `[light, dark]` only when the code has dark values; roles that change become light/dark maps.\n5. Add text styles (headings, body, labels) and the spacing, radius, shadow and breakpoint scales the\n code defines.\n6. Add each real component and variant, typed button, link, icon, icon-round, input, tab, badge, nav,\n avatar, logo, section, card, divider or check, with a label from the UI.\n7. Body: up to 8 Instructions (which token for what), color sections naming `{colors.X}`, Fonts,\n Layout (max width, grid, gutters), a line per component, Do and Don\'t, and Notes for gaps.\n8. Check every ref, then push.\n\n## In designs\n\nDesigns do not link to a design system: canvas.json and nodes have no field for it. Pull it and write\nits values into the HTML (`bg-[#3b5bdb]`, or CSS variables in a `<style>`), following its\nInstructions, Do and Don\'t. The canvas\'s Apply menu asks to regenerate a design "with the <name>\ndesign system": find it by name in `kombai ds list`, pull it and the node, restyle the design keeping\nits content, and push the node. A pasted `Use the "<name>" design system: <link>` names it by its link:\nfor ?preset=<id> run `kombai ds pull <id> --public`, for /ds/<slug> run `kombai ds pull <slug>`. The\nuser can view one at /ds/<slug>, a public one at /ds?preset=<id>, on the canvas site.\n\n## Conflicts\n\nExit 2 on a push (DESIGN_DESIGN_SYSTEM_CHANGED): it changed since you pulled it, or already existed.\nThe stored version is saved at details.remote. Merge it into your file and run the error\'s next\n(`kombai ds push <file> --merged`); if it is a different design system, rename your file instead.\n`kombai ds pull <slug> --discard` takes the stored one. Exit 2 on a pull: push your edits first, or\npull with --discard.\n';
31658
32176
  }
31659
32177
  });
31660
32178
 
@@ -31694,7 +32212,7 @@ var init_opening = __esm({
31694
32212
  var overview_default;
31695
32213
  var init_overview = __esm({
31696
32214
  "src/skill/overview.md"() {
31697
- overview_default = '# Kombai design\n\nDesign UI on a hosted Kombai canvas; design systems need no canvas. `kombai <command> --help` gives its\nflags. Read each JSON result: next can be a command, a link or advice. Follow it after handling the error\nand any required user choice.\nSkill text and default help are plain text. Tell the user in one line before and after each step that\ntakes more than a few seconds.\n\n{{RUN}}\n\nRun `kombai` outside any sandbox from the first try: it needs network and writes ~/.kombai.\n\n{{APP}}\n\n## Choose the task\n\n- New design: follow New designs below.\n- Existing canvas or node (a link, "On my Kombai canvas" message, or a named canvas): read\n `kombai skill actions`, pull the target and follow that request. An edit needs no new canvas or\n taste; variants seeking new ideas do.\n- Create or edit a .ds file: read `kombai skill design-system`.\n- Shapes, pictures or layout: read `kombai skill drawings`.\n\nBefore account operations run `kombai whoami`. Unless it prints an email with no claim, read\n`kombai skill sign-in` and follow it. Read it before any `kombai login`.\n\n## New designs\n\n1. Read `kombai skill brief` and the repo before writing a brief outside the repo. The topic says\n when a reference or reflow skips taste.\n2. When taste is needed (never for a guest), tell the user their `kombai credits` balance first,\n then run `kombai taste start --brief <file> --variants <1-4>`, one per design. A run takes minutes:\n do step 3 meanwhile, then `kombai taste wait <run>`, again while its status is running. Follow\n directions.md. On TASTE_NO_CREDITS, call plans_card if listed, else show next\'s plan link; stop.\n3. Create a canvas: `kombai canvas create --name "<what it is>"`. Reuse one only when the user points\n to it or this conversation made it; `kombai canvas list` finds it by name. Ask if the target is\n unclear. On DESIGN_ORG_REQUIRED, ask which listed org, save `kombai config org <id>`, then retry.\n Read `kombai skill opening` and show the canvas once when creating or first using it.\n It starts private; share only when asked.\n4. Before writing HTML, read `kombai skill html`: it says how to build in passes. For each design,\n `kombai node start --canvas <id> --label "<label>"` (`--parent <node>` for a variant), then write\n and push it as that topic says.\n\n## Check a finished design\n\nAfter a design\'s last push, run the complete screenshot fill its next names in the background. Then run\n`kombai screenshot wait --canvas <id> --node <node> --tiles` and inspect each image it prints.\nRun node lock, fix and push again, at most 3 rounds. On CLI_NO_BROWSER or CLI_LAUNCH_FAILED from fill,\nask before the roughly 100 MB download; then `kombai browser install --yes` and retry fill.\nIf wait reports CLI_NOTHING_RENDERING, run its suggested fill only if none is running; on\nCLI_SCREENSHOT_FAILED, inspect the failure reason before retrying.\n\n## Recover from errors\n\nExit 2 is not always a changed node.\nFor DESIGN_NODE_CHANGED on node push, merge the stored version at error.details.remote into your\nfile, then `kombai node push --canvas <id> --node <node> --merged`. Only to discard your edit, use\n`kombai node pull --canvas <id> --node <node> --discard`.\n\nRun commands that change a canvas\'s files (node start, node push, node pull, canvas pull, canvas push)\none at a time per canvas, and edit files only between them; screenshot fill and screenshot wait can run\nbeside them.\n\nExit codes: 0 done, 1 failed, 2 refused or conflict, 3 not signed in, 4 timed out. A wait timeout\ndoes not mean the work failed: follow its next; check a fill\'s result if no image arrives.\n';
32215
+ overview_default = '# Kombai design\n\nDesign UI on a hosted Kombai canvas; design systems need no canvas. `kombai <command> --help` gives its\nflags. Read each JSON result: next can be a command, a link or advice. Follow it after handling the error\nand any required user choice.\nSkill text and default help are plain text. Tell the user in one line before and after each step that\ntakes more than a few seconds.\n\n{{RUN}}\n\nRun `kombai` outside any sandbox from the first try: it needs network and writes ~/.kombai.\n\n{{APP}}\n\n## Choose the task\n\n- New design: follow New designs below.\n- Existing canvas or node (a link, "On my Kombai canvas" message, or a named canvas): read\n `kombai skill actions`, pull the target and follow that request. An edit needs no new canvas or\n taste; variants seeking new ideas do.\n- Design systems (.ds): read `kombai skill design-system`.\n- Shapes, pictures or layout: read `kombai skill drawings`.\n\nBefore account operations run `kombai whoami`. Unless it prints an email with no claim, read\n`kombai skill sign-in` and follow it. Read it before any `kombai login`.\n\n## New designs\n\n1. Read `kombai skill brief` and the repo before writing a brief outside the repo. The topic says\n when a reference or reflow skips taste.\n2. When taste is needed (never for a guest), tell the user their `kombai credits` balance first,\n then run `kombai taste start --brief <file> --variants <1-4>`, one per design. A run takes minutes:\n do step 3 meanwhile, then `kombai taste wait <run>`, again while its status is running. Follow\n directions.md. On TASTE_NO_CREDITS, call plans_card if listed, else show next\'s plan link; stop.\n3. Create a canvas: `kombai canvas create --name "<what it is>"`. Reuse one only when the user points\n to it or this conversation made it; `kombai canvas list` finds it by name. Ask if the target is\n unclear. On DESIGN_ORG_REQUIRED, ask which listed org, save `kombai config org <id>`, then retry.\n Read `kombai skill opening` and show the canvas once when creating or first using it.\n It starts private; share only when asked.\n4. Before writing HTML, read `kombai skill html`: it says how to build in passes. For each design,\n `kombai node start --canvas <id> --label "<label>"` (`--parent <node>` for a variant), then write\n and push it as that topic says.\n\n## Check a finished design\n\nAfter a design\'s last push, run the complete screenshot fill its next names in the background. Then run\n`kombai screenshot wait --canvas <id> --node <node> --tiles` and inspect each image it prints.\nRun node lock, fix and push again, at most 3 rounds. On CLI_NO_BROWSER or CLI_LAUNCH_FAILED from fill,\nask before the roughly 100 MB download; then `kombai browser install --yes` and retry fill.\nIf wait reports CLI_NOTHING_RENDERING, run its suggested fill only if none is running; on\nCLI_SCREENSHOT_FAILED, inspect the failure reason before retrying.\n\n## Recover from errors\n\nExit 2 is not always a changed node.\nFor DESIGN_NODE_CHANGED on node push, merge the stored version at error.details.remote into your\nfile, then `kombai node push --canvas <id> --node <node> --merged`. Only to discard your edit, use\n`kombai node pull --canvas <id> --node <node> --discard`.\n\nRun commands that change a canvas\'s files (node start, node push, node pull, canvas pull, canvas push)\none at a time per canvas, and edit files only between them; screenshot fill and screenshot wait can run\nbeside them.\n\nExit codes: 0 done, 1 failed, 2 refused or conflict, 3 not signed in, 4 timed out. A wait timeout\ndoes not mean the work failed: follow its next; check a fill\'s result if no image arrives.\n';
31698
32216
  }
31699
32217
  });
31700
32218
 
@@ -31702,7 +32220,7 @@ var init_overview = __esm({
31702
32220
  var sign_in_default;
31703
32221
  var init_sign_in = __esm({
31704
32222
  "src/skill/sign-in.md"() {
31705
- sign_in_default = "# Signing in, or trying Kombai as a guest\n\nWhat `kombai whoami` printed decides. The reasons below apply to any exit-3 CLI_NOT_SIGNED_IN, not just whoami's:\n\n- Exit 3 with details.reason none: ask once, \"Kombai works best signed in. Sign in now, or try it without an account?\"\n Sign in: run `kombai login`. Try it: run `kombai guest`, then work as a guest (below).\n- Exit 3 with reason expired or signed_out: the user has an account. Offer sign-in only, never guest mode. With\n claim pending in details, signing in also moves the guest canvas into the account.\n- Any other or missing reason: offer sign-in only.\n- Exit 0 with status guest: the user already chose. Work as a guest without asking again.\n- An email with claim needs_org: ask which listed organization gets the guest canvas, then run\n `kombai claim --org <id>`. With claim pending, the next command finishes it.\n\nTo sign in, run `kombai login` in the background and show the matchCode from its first line; the user approves on\nthe page it opens in their browser, or, if they see none, at the url from that line. If you have a browser panel the\nuser can see, run `kombai login --no-browser` in the background instead, show the matchCode, and open the url from\nits first line in your panel: the user signs in and approves there. Never type into, click on or approve that page\nyourself: the approval is the user's check that the match code is theirs. If they'd rather use their own browser,\ngive them that url, for them alone: whoever approves it signs this CLI into their account. When the signed-in line\nhas claimed, the guest canvas is now in the account, same link. When it has claim needs_org, ask as above.\n\n## As a guest\n\n- Skip taste: no brief and no `kombai taste start`. Go straight to `kombai canvas create`. A guest has one canvas: when\n canvas create answers DESIGN_GUEST_LIMIT with a canvasId in details, use that canvas.\n- Use no repo images (/api/local/images/\u2026): CSS, inline SVG or public https images instead.\n- The canvas link is the user's own. Open it for them; don't suggest sending it to anyone.\n- When whoami's expires is within 7 days, say once in this conversation that the guest canvas ends on that date and\n that signing in keeps it.\n- End each turn with one line: signing in unlocks taste directions, repo images, design systems and sharing.\n\n## Refusals\n\n- DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED: tell the user in one line what signing in unlocks, and run\n `kombai login` only if they agree.\n- DESIGN_GUEST_LIMIT on any other command (node start, node push, screenshot fill): the guest canvas is full. Say so\n in one line, and that signing in keeps the canvas and lifts the limit; run `kombai login` only if they agree. Don't\n retry or work around it, and keep the unpushed files: push them again after sign-in.\n- SIGNIN_GUEST_EXPIRED as an error from a guest's own command: say the guest canvas expired, and ask again: sign in,\n or start fresh with `kombai guest`.\n- SIGNIN_GUEST_EXPIRED as a warning on a signed-in line (an email is printed): say in one line that the old guest\n canvas expired and is gone. Never offer `kombai guest`.\n- SIGNIN_GUEST_CLAIMED as an error from a guest's own command: the canvas moved into an account; signing in reaches\n it. As a warning on a signed-in line: nothing to do.\n\n## The sign-in card\n\nWhere your tools list `sign_in_card`, call it in place of the lines above, with the moment's reason, and end your\nturn; don't run or offer `kombai login` in text:\n\n- canvas_full: DESIGN_GUEST_LIMIT with no canvasId in details. second_canvas: with one (still use that canvas).\n- taste: taste refused or asked for. repo_images: CLI_SIGNIN_REQUIRED with images in details.\n- account: any other DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED.\n- ending: once, when whoami's expires is within 7 days.\n\nWithout `sign_in_card`, use the lines above.\n";
32223
+ sign_in_default = "# Signing in, or trying Kombai as a guest\n\nWhat `kombai whoami` printed decides. The reasons below apply to any exit-3 CLI_NOT_SIGNED_IN, not just whoami's:\n\n- Exit 3 with details.reason none: ask once, \"Kombai works best signed in. Sign in now, or try it without an account?\"\n Sign in: run `kombai login`. Try it: run `kombai guest`, then work as a guest (below).\n- Exit 3 with reason expired or signed_out: the user has an account. Offer sign-in only, never guest mode. With\n claim pending in details, signing in also moves the guest canvas into the account.\n- Any other or missing reason: offer sign-in only.\n- Exit 0 with status guest: the user already chose. Work as a guest without asking again.\n- An email with claim needs_org: ask which listed organization gets the guest canvas, then run\n `kombai claim --org <id>`. With claim pending, the next command finishes it.\n\nTo sign in, run `kombai login` in the background and show the matchCode from its first line; the user approves on\nthe page it opens in their browser, or, if they see none, at the url from that line. If you have a browser panel the\nuser can see, run `kombai login --no-browser` in the background instead, show the matchCode, and open the url from\nits first line in your panel: the user signs in and approves there. Never type into, click on or approve that page\nyourself: the approval is the user's check that the match code is theirs. If they'd rather use their own browser,\ngive them that url, for them alone: whoever approves it signs this CLI into their account. When the signed-in line\nhas claimed, the guest canvas is now in the account, same link. When it has claim needs_org, ask as above.\n\n## As a guest\n\n- Run `kombai whoami` again at the start of each new request: the user may have signed in since, in another chat\n or on a card. When it no longer says guest, drop everything below.\n- Skip taste: no brief and no `kombai taste start`. Go straight to `kombai canvas create`. A guest has one canvas: when\n canvas create answers DESIGN_GUEST_LIMIT with a canvasId in details, use that canvas.\n- Use no repo images (/api/local/images/\u2026): CSS, inline SVG or public https images instead.\n- The canvas link is the user's own. Open it for them; don't suggest sending it to anyone.\n- When whoami's expires is within 7 days, say once in this conversation that the guest canvas ends on that date and\n that signing in keeps it.\n- End each turn with one line: signing in unlocks taste directions, repo images, design systems and sharing.\n\n## Refusals\n\n- DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED: tell the user in one line what signing in unlocks, and run\n `kombai login` only if they agree.\n- DESIGN_GUEST_LIMIT on any other command (node start, node push, screenshot fill): the guest canvas is full. Say so\n in one line, and that signing in keeps the canvas and lifts the limit; run `kombai login` only if they agree. Don't\n retry or work around it, and keep the unpushed files: push them again after sign-in.\n- SIGNIN_GUEST_EXPIRED as an error from a guest's own command: say the guest canvas expired, and ask again: sign in,\n or start fresh with `kombai guest`.\n- SIGNIN_GUEST_EXPIRED as a warning on a signed-in line (an email is printed): say in one line that the old guest\n canvas expired and is gone. Never offer `kombai guest`.\n- SIGNIN_GUEST_CLAIMED as an error from a guest's own command: the canvas moved into an account; signing in reaches\n it. As a warning on a signed-in line: nothing to do.\n\n## The sign-in card\n\nWhere your tools list `sign_in_card`, call it in place of the lines above, with the moment's reason, and end your\nturn; don't run or offer `kombai login` in text:\n\n- start: whoami exits 3, in place of asking whether to sign in or try it without an account. The user chooses on the\n card; when they say to carry on, run `kombai whoami` and go on as it says.\n- canvas_full: DESIGN_GUEST_LIMIT with no canvasId in details. second_canvas: with one (still use that canvas).\n- taste: taste refused or asked for. repo_images: CLI_SIGNIN_REQUIRED with images in details.\n- account: any other DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED.\n- ending: once, when whoami's expires is within 7 days. It is a reminder, not a refusal: don't end your turn after\n it; carry on with the request.\n\nWithout `sign_in_card`, use the lines above.\n";
31706
32224
  }
31707
32225
  });
31708
32226
 
@@ -31712,7 +32230,7 @@ function fillSkillText(text, inClaudeDesktop) {
31712
32230
 
31713
32231
  ` : "").trimEnd();
31714
32232
  }
31715
- var TOPICS, TEAM_BUILD, RUN, skill, PLAIN_TEXT;
32233
+ var TOPICS, RUN, skill, PLAIN_TEXT;
31716
32234
  var init_skill = __esm({
31717
32235
  "src/commands/skill.js"() {
31718
32236
  "use strict";
@@ -31740,11 +32258,8 @@ var init_skill = __esm({
31740
32258
  "sign-in": sign_in_default,
31741
32259
  faq: faq_default
31742
32260
  };
31743
- TEAM_BUILD = CLI_RUN.includes("@kombai-io/");
31744
32261
  RUN = `Commands here are written as \`kombai <command>\`. If \`kombai --version\` does not run, put
31745
- \`${CLI_RUN}\` in place of \`kombai\` in every command, in full, never from a variable.${TEAM_BUILD ? `
31746
- That package is on GitHub Packages: npx finds it only once npm has @kombai-io:registry set to
31747
- https://npm.pkg.github.com and a token for it. If npx fails with 401 or 404, ask the user to set that up.` : ""}`;
32262
+ \`${CLI_RUN}\` in place of \`kombai\` in every command, in full, never from a variable.`;
31748
32263
  skill = {
31749
32264
  name: "skill",
31750
32265
  summary: "Print the skill's text, or one topic of it. Plain text: these are the agent's instructions.",
@@ -33569,6 +34084,15 @@ var init_posthog = __esm({
33569
34084
  import { spawn as spawn4 } from "node:child_process";
33570
34085
  import { randomUUID as randomUUID3 } from "node:crypto";
33571
34086
  import os3 from "node:os";
34087
+ async function guestBefore(ctx) {
34088
+ if (!ctx.telemetry.keys) return void 0;
34089
+ try {
34090
+ const { env } = await currentEnv(ctx);
34091
+ return isPureGuest(await readEntry(ctx.home, env));
34092
+ } catch {
34093
+ return false;
34094
+ }
34095
+ }
33572
34096
  async function sendTelemetry(ctx, ran) {
33573
34097
  const table = ctx.telemetry.keys;
33574
34098
  if (!table) return;
@@ -33583,7 +34107,7 @@ async function sendTelemetry(ctx, ran) {
33583
34107
  const scope = {
33584
34108
  env,
33585
34109
  userId: entry ? keyOf(entry)?.userId : void 0,
33586
- guest: entry ? isPureGuest(entry) : false,
34110
+ guest: (entry ? isPureGuest(entry) : false) || ran.wasGuest === true && !(entry && holdsAccount(entry)),
33587
34111
  command: ran.command
33588
34112
  };
33589
34113
  const requests = [];
@@ -33811,7 +34335,7 @@ async function run(argv, overrides = {}) {
33811
34335
  const ctx = createContext(overrides);
33812
34336
  ctx.pretty = argv.includes("--pretty");
33813
34337
  const started = ctx.now();
33814
- const ran = { command: null, help: false };
34338
+ const ran = { command: null, help: false, wasGuest: await guestBefore(ctx) };
33815
34339
  const exit = await execute(ctx, argv, ran);
33816
34340
  await sendTelemetry(ctx, { ...ran, exit, ms: ctx.now() - started });
33817
34341
  return exit;