@base44-preview/cli 0.1.15-pr.630.0a500b0 → 0.1.15-pr.630.0d946d9

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/cli/index.js CHANGED
@@ -276132,2056 +276132,2273 @@ function TextInput({ value: originalValue, placeholder = "", focus = true, mask,
276132
276132
  }
276133
276133
  var build_default = TextInput;
276134
276134
 
276135
- // src/cli/commands/code/session.tsx
276136
- var import_react23 = __toESM(require_react(), 1);
276135
+ // ../../node_modules/open/index.js
276136
+ import process30 from "node:process";
276137
+ import path16 from "node:path";
276138
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
276139
+ import childProcess3 from "node:child_process";
276140
+ import fs20, { constants as fsConstants2 } from "node:fs/promises";
276137
276141
 
276138
- // src/cli/commands/code/logo.ts
276139
- var ROWS = 6;
276140
- var ASPECT = 0.44;
276141
- var SAMPLES = 4;
276142
- var FILL = 0.6;
276143
- var GAP_ROW = 3.5 + 0.5;
276144
- var GAP_HEIGHT_ROWS = 0.8;
276145
- var LOGO_COLS = Math.max(2, Math.floor(ROWS / ASPECT + 0.5));
276146
- var OCTANT = {
276147
- rx: 2,
276148
- ry: 4,
276149
- table: Array.from(" \uD83E\uDF82\uD833\uDD00▘\uD833\uDD01\uD833\uDD02\uD833\uDD03\uD833\uDD04▝\uD833\uDD05\uD833\uDD06\uD833\uDD07\uD833\uDD08▀\uD833\uDD09\uD833\uDD0A\uD833\uDD0B\uD833\uDD0C\uD833\uDD00\uD833\uDD0D\uD833\uDD0E\uD833\uDD0F\uD833\uDD10\uD833\uDD11\uD833\uDD12\uD833\uDD13\uD833\uDD14\uD833\uDD15\uD833\uDD16\uD833\uDD17\uD833\uDD18\uD833\uDD19\uD833\uDD1A\uD833\uDD1B\uD833\uDD1C\uD833\uDD1D\uD833\uDD1E\uD833\uDD1F\uD833\uDD03\uD833\uDD20\uD833\uDD21\uD833\uDD22\uD833\uDD23\uD833\uDD24\uD833\uDD25\uD833\uDD26\uD833\uDD27\uD833\uDD28\uD833\uDD29\uD833\uDD2A\uD833\uDD2B\uD833\uDD2C\uD833\uDD2D\uD833\uDD2E\uD833\uDD2F\uD833\uDD30\uD833\uDD31\uD833\uDD32\uD833\uDD33\uD833\uDD34\uD833\uDD35\uD83E\uDF85 \uD833\uDD36\uD833\uDD37\uD833\uDD38\uD833\uDD39\uD833\uDD3A\uD833\uDD3B\uD833\uDD3C\uD833\uDD3D\uD833\uDD3E\uD833\uDD3F\uD833\uDD40\uD833\uDD41\uD833\uDD42\uD833\uDD43\uD833\uDD44▖\uD833\uDD45\uD833\uDD46\uD833\uDD47\uD833\uDD48▌\uD833\uDD49\uD833\uDD4A\uD833\uDD4B\uD833\uDD4C▞\uD833\uDD4D\uD833\uDD4E\uD833\uDD4F\uD833\uDD50▛\uD833\uDD51\uD833\uDD52\uD833\uDD53\uD833\uDD54\uD833\uDD55\uD833\uDD56\uD833\uDD57\uD833\uDD58\uD833\uDD59\uD833\uDD5A\uD833\uDD5B\uD833\uDD5C\uD833\uDD5D\uD833\uDD5E\uD833\uDD5F\uD833\uDD60\uD833\uDD61\uD833\uDD62\uD833\uDD63\uD833\uDD64\uD833\uDD65\uD833\uDD66\uD833\uDD67\uD833\uDD68\uD833\uDD69\uD833\uDD6A\uD833\uDD6B\uD833\uDD6C\uD833\uDD6D\uD833\uDD6E\uD833\uDD6F\uD833\uDD70 \uD833\uDD71\uD833\uDD72\uD833\uDD73\uD833\uDD74\uD833\uDD75\uD833\uDD76\uD833\uDD77\uD833\uDD78\uD833\uDD79\uD833\uDD7A\uD833\uDD7B\uD833\uDD7C\uD833\uDD7D\uD833\uDD7E\uD833\uDD7F\uD833\uDD80\uD833\uDD81\uD833\uDD82\uD833\uDD83\uD833\uDD84\uD833\uDD85\uD833\uDD86\uD833\uDD87\uD833\uDD88\uD833\uDD89\uD833\uDD8A\uD833\uDD8B\uD833\uDD8C\uD833\uDD8D\uD833\uDD8E\uD833\uDD8F▗\uD833\uDD90\uD833\uDD91\uD833\uDD92\uD833\uDD93▚\uD833\uDD94\uD833\uDD95\uD833\uDD96\uD833\uDD97▐\uD833\uDD98\uD833\uDD99\uD833\uDD9A\uD833\uDD9B▜\uD833\uDD9C\uD833\uDD9D\uD833\uDD9E\uD833\uDD9F\uD833\uDDA0\uD833\uDDA1\uD833\uDDA2\uD833\uDDA3\uD833\uDDA4\uD833\uDDA5\uD833\uDDA6\uD833\uDDA7\uD833\uDDA8\uD833\uDDA9\uD833\uDDAA\uD833\uDDAB▂\uD833\uDDAC\uD833\uDDAD\uD833\uDDAE\uD833\uDDAF\uD833\uDDB0\uD833\uDDB1\uD833\uDDB2\uD833\uDDB3\uD833\uDDB4\uD833\uDDB5\uD833\uDDB6\uD833\uDDB7\uD833\uDDB8\uD833\uDDB9\uD833\uDDBA\uD833\uDDBB\uD833\uDDBC\uD833\uDDBD\uD833\uDDBE\uD833\uDDBF\uD833\uDDC0\uD833\uDDC1\uD833\uDDC2\uD833\uDDC3\uD833\uDDC4\uD833\uDDC5\uD833\uDDC6\uD833\uDDC7\uD833\uDDC8\uD833\uDDC9\uD833\uDDCA\uD833\uDDCB\uD833\uDDCC\uD833\uDDCD\uD833\uDDCE\uD833\uDDCF\uD833\uDDD0\uD833\uDDD1\uD833\uDDD2\uD833\uDDD3\uD833\uDDD4\uD833\uDDD5\uD833\uDDD6\uD833\uDDD7\uD833\uDDD8\uD833\uDDD9\uD833\uDDDA▄\uD833\uDDDB\uD833\uDDDC\uD833\uDDDD\uD833\uDDDE▙\uD833\uDDDF\uD833\uDDE0\uD833\uDDE1\uD833\uDDE2▟\uD833\uDDE3▆\uD833\uDDE4\uD833\uDDE5█")
276150
- };
276151
- var QUAD = {
276152
- rx: 2,
276153
- ry: 2,
276154
- table: Array.from(" ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█")
276155
- };
276156
- function detectTier(env = process.env) {
276157
- const term = env.TERM ?? "";
276158
- const prog = env.TERM_PROGRAM ?? "";
276159
- if (prog === "ghostty" || term.includes("ghostty"))
276160
- return "octant";
276161
- if (env.KITTY_WINDOW_ID || term.includes("kitty"))
276162
- return "octant";
276163
- if (env.WEZTERM_PANE || env.WEZTERM_EXECUTABLE)
276164
- return "octant";
276165
- if (term.startsWith("foot") || prog === "contour")
276166
- return "octant";
276167
- return "quad";
276168
- }
276169
- function coverageGrid(rows, cols, aspect, pixelH) {
276170
- const worldH = rows * pixelH;
276171
- const worldW = cols * aspect;
276172
- const radius = Math.min(worldH, worldW) / 2;
276173
- const cx = worldW / 2;
276174
- const cy = worldH / 2;
276175
- const step = 1 / SAMPLES;
276176
- const grid = [];
276177
- for (let py = 0;py < rows; py++) {
276178
- const y0 = py * pixelH;
276179
- const y1 = y0 + pixelH;
276180
- const dyLo = y0 <= cy && cy <= y1 ? 0 : Math.min(Math.abs(y0 - cy), Math.abs(y1 - cy));
276181
- const dyHi = Math.max(Math.abs(y0 - cy), Math.abs(y1 - cy));
276182
- const line = [];
276183
- for (let px = 0;px < cols; px++) {
276184
- const x0 = px * aspect;
276185
- const x1 = x0 + aspect;
276186
- const dxLo = x0 <= cx && cx <= x1 ? 0 : Math.min(Math.abs(x0 - cx), Math.abs(x1 - cx));
276187
- const dxHi = Math.max(Math.abs(x0 - cx), Math.abs(x1 - cx));
276188
- if (Math.hypot(dxLo, dyLo) >= radius) {
276189
- line.push(0);
276190
- continue;
276191
- }
276192
- if (Math.hypot(dxHi, dyHi) <= radius) {
276193
- line.push(1);
276194
- continue;
276195
- }
276196
- let hits = 0;
276197
- for (let j = 0;j < SAMPLES; j++) {
276198
- const dy = y0 + (j + 0.5) * step * pixelH - cy;
276199
- for (let i = 0;i < SAMPLES; i++) {
276200
- const dx = x0 + (i + 0.5) * step * aspect - cx;
276201
- if (Math.hypot(dx, dy) <= radius)
276202
- hits++;
276203
- }
276204
- }
276205
- line.push(hits / (SAMPLES * SAMPLES));
276206
- }
276207
- grid.push(line);
276208
- }
276209
- return grid;
276210
- }
276211
- function carveGap(grid, ry) {
276212
- const n = grid.length;
276213
- const thick = Math.max(1, Math.round(GAP_HEIGHT_ROWS * ry));
276214
- const centre = GAP_ROW >= 0 ? GAP_ROW * ry : n + GAP_ROW * ry;
276215
- const start = Math.max(0, Math.min(n - thick, centre - thick / 2));
276216
- for (let i = Math.trunc(start);i < Math.trunc(start + thick); i++) {
276217
- grid[i].fill(0);
276142
+ // ../../node_modules/wsl-utils/index.js
276143
+ import { promisify as promisify6 } from "node:util";
276144
+ import childProcess2 from "node:child_process";
276145
+ import fs19, { constants as fsConstants } from "node:fs/promises";
276146
+
276147
+ // ../../node_modules/is-wsl/index.js
276148
+ import process24 from "node:process";
276149
+ import os4 from "node:os";
276150
+ import fs18 from "node:fs";
276151
+
276152
+ // ../../node_modules/is-inside-container/index.js
276153
+ import fs17 from "node:fs";
276154
+
276155
+ // ../../node_modules/is-docker/index.js
276156
+ import fs16 from "node:fs";
276157
+ var isDockerCached;
276158
+ function hasDockerEnv() {
276159
+ try {
276160
+ fs16.statSync("/.dockerenv");
276161
+ return true;
276162
+ } catch {
276163
+ return false;
276218
276164
  }
276219
276165
  }
276220
- function logoRows(color, tier = detectTier()) {
276221
- const { rx, ry, table } = tier === "octant" ? OCTANT : QUAD;
276222
- const grid = coverageGrid(ROWS * ry, LOGO_COLS * rx, ASPECT / rx, 1 / ry);
276223
- carveGap(grid, ry);
276224
- const fg = color ? source_default.hex(color) : (s) => s;
276225
- const bg = color ? source_default.bgHex(color) : (s) => s;
276226
- const full = (1 << rx * ry) - 1;
276227
- const out = [];
276228
- for (let r = 0;r < ROWS; r++) {
276229
- let row = "";
276230
- for (let c = 0;c < LOGO_COLS; c++) {
276231
- let mask = 0;
276232
- for (let sr = 0;sr < ry; sr++) {
276233
- for (let sc = 0;sc < rx; sc++) {
276234
- if (grid[r * ry + sr][c * rx + sc] >= FILL)
276235
- mask |= 1 << sr * rx + sc;
276236
- }
276237
- }
276238
- const glyph = table[mask];
276239
- if (glyph === " ")
276240
- row += " ";
276241
- else if (mask === full && color)
276242
- row += bg(" ");
276243
- else
276244
- row += fg(glyph);
276245
- }
276246
- out.push(row);
276166
+ function hasDockerCGroup() {
276167
+ try {
276168
+ return fs16.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
276169
+ } catch {
276170
+ return false;
276247
276171
  }
276248
- return out;
276249
276172
  }
276250
-
276251
- // src/cli/commands/code/paste.ts
276252
- import { PassThrough as PassThrough3 } from "node:stream";
276253
- var START = "\x1B[200~";
276254
- var END = "\x1B[201~";
276255
- function partialSuffix(s, marker) {
276256
- for (let n = Math.min(marker.length - 1, s.length);n > 0; n--) {
276257
- if (marker.startsWith(s.slice(-n)))
276258
- return s.slice(-n);
276173
+ function isDocker() {
276174
+ if (isDockerCached === undefined) {
276175
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
276259
276176
  }
276260
- return "";
276261
- }
276262
- function makePasteSanitizer() {
276263
- let inPaste = false;
276264
- let carry = "";
276265
- const clean = (t) => t.replace(/\r\n|\r|\n/g, " ").replace(/\t/g, " ");
276266
- return (chunk) => {
276267
- let s = carry + chunk;
276268
- carry = "";
276269
- let out = "";
276270
- while (s.length > 0) {
276271
- if (!inPaste) {
276272
- const i = s.indexOf(START);
276273
- if (i === -1) {
276274
- const tail = partialSuffix(s, START);
276275
- out += s.slice(0, s.length - tail.length);
276276
- carry = tail;
276277
- s = "";
276278
- } else {
276279
- out += s.slice(0, i);
276280
- s = s.slice(i + START.length);
276281
- inPaste = true;
276282
- }
276283
- } else {
276284
- const j = s.indexOf(END);
276285
- if (j === -1) {
276286
- const tail = partialSuffix(s, END);
276287
- out += clean(s.slice(0, s.length - tail.length));
276288
- carry = tail;
276289
- s = "";
276290
- } else {
276291
- out += clean(s.slice(0, j));
276292
- s = s.slice(j + END.length);
276293
- inPaste = false;
276294
- }
276295
- }
276296
- }
276297
- return out;
276298
- };
276299
- }
276300
- function createPasteFriendlyStdin(real) {
276301
- const out = new PassThrough3;
276302
- const sanitize = makePasteSanitizer();
276303
- const onData = (buf) => {
276304
- const text = sanitize(buf.toString("utf8"));
276305
- if (text)
276306
- out.write(text);
276307
- };
276308
- real.on("data", onData);
276309
- const proxy = out;
276310
- proxy.isTTY = true;
276311
- proxy.setRawMode = (mode) => {
276312
- real.setRawMode?.(mode);
276313
- return proxy;
276314
- };
276315
- proxy.ref = () => real.ref?.();
276316
- proxy.unref = () => real.unref?.();
276317
- proxy.cleanup = () => {
276318
- real.off("data", onData);
276319
- real.pause();
276320
- };
276321
- return proxy;
276177
+ return isDockerCached;
276322
276178
  }
276323
276179
 
276324
- // src/core/resources/apps/pending.ts
276325
- var CHOICE_TOOLS = new Set([
276326
- "ask_clarifying_questions",
276327
- "ask_plan_questions"
276328
- ]);
276329
- var SECRET_TOOLS = new Set(["set_secrets"]);
276330
- var PERMISSION_TOOLS = new Set(["request_agent_tool_permissions"]);
276331
- var BROWSER_TOOLS = new Set([
276332
- "connect_github_account",
276333
- "request_oauth_authorization",
276334
- "register_workspace_connector",
276335
- "configure_psp_credentials",
276336
- "plaid_connect"
276337
- ]);
276338
- var str2 = (v) => typeof v === "string" && v.trim() ? v.trim() : undefined;
276339
- function parseArgs(raw) {
276180
+ // ../../node_modules/is-inside-container/index.js
276181
+ var cachedResult;
276182
+ var hasContainerEnv = () => {
276340
276183
  try {
276341
- const parsed = JSON.parse(raw ?? "");
276342
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
276184
+ fs17.statSync("/run/.containerenv");
276185
+ return true;
276343
276186
  } catch {
276344
- return {};
276187
+ return false;
276188
+ }
276189
+ };
276190
+ function isInsideContainer() {
276191
+ if (cachedResult === undefined) {
276192
+ cachedResult = hasContainerEnv() || isDocker();
276345
276193
  }
276194
+ return cachedResult;
276346
276195
  }
276347
- function questionsFrom(args) {
276348
- const raw = Array.isArray(args.questions) ? args.questions : [];
276349
- return raw.flatMap((q) => {
276350
- if (!q || typeof q !== "object")
276351
- return [];
276352
- const item = q;
276353
- const question = str2(item.question);
276354
- if (!question)
276355
- return [];
276356
- const options = (Array.isArray(item.options) ? item.options : []).flatMap((o) => {
276357
- const opt = o;
276358
- const label = str2(opt?.label);
276359
- return label ? [{ label, description: str2(opt.description) }] : [];
276360
- });
276361
- return [
276362
- {
276363
- question,
276364
- description: str2(item.description),
276365
- options,
276366
- multiSelect: item.multi_select === true
276367
- }
276368
- ];
276369
- });
276370
- }
276371
- function secretsFrom(args) {
276372
- const raw = Array.isArray(args.secrets_schema) ? args.secrets_schema : [];
276373
- return raw.flatMap((s) => {
276374
- const item = s;
276375
- const name = str2(item?.secretName) ?? str2(item?.name);
276376
- return name ? [{ name, description: str2(item.description) }] : [];
276377
- });
276378
- }
276379
- function permissionKey(row) {
276380
- switch (row.type) {
276381
- case "entity":
276382
- return row.entity_name ? `entity:${row.entity_name}` : null;
276383
- case "backend_function":
276384
- return row.function_name ? `backend_function:${row.function_name}` : null;
276385
- case "app_user_connector":
276386
- return row.connector_id ? `app_user_connector:${row.connector_id}` : null;
276387
- default:
276388
- return null;
276196
+
276197
+ // ../../node_modules/is-wsl/index.js
276198
+ var isWsl = () => {
276199
+ if (process24.platform !== "linux") {
276200
+ return false;
276389
276201
  }
276390
- }
276391
- function permissionsFrom(args) {
276392
- const raw = Array.isArray(args.requested_permissions) ? args.requested_permissions : [];
276393
- return raw.flatMap((r) => {
276394
- const row = r;
276395
- const key = permissionKey(row);
276396
- if (!key)
276397
- return [];
276398
- const ops = Array.isArray(row.allowed_operations) ? ` (${row.allowed_operations.join(", ")})` : "";
276399
- const target = str2(row.entity_name) ?? str2(row.function_name) ?? str2(row.connector_name) ?? key;
276400
- return [
276401
- { key, label: `${row.type}: ${target}${ops}`, reason: str2(row.reason) }
276402
- ];
276403
- });
276404
- }
276405
- function guardFrom(results) {
276406
- const value = typeof results === "string" ? (() => {
276407
- try {
276408
- return JSON.parse(results);
276409
- } catch {
276410
- return null;
276411
- }
276412
- })() : results;
276413
- if (!value || typeof value !== "object")
276414
- return null;
276415
- const g = value;
276416
- if (!str2(g.guard))
276417
- return null;
276418
- return { title: `${g.guard}: needs your approval`, detail: str2(g.reason) };
276419
- }
276420
- function humanize(tool) {
276421
- return tool.replace(/_/g, " ");
276422
- }
276423
- function pendingInputs(messages) {
276424
- const out = [];
276425
- for (const message of messages) {
276426
- for (const call of message.tool_calls ?? []) {
276427
- if (call.status !== "waiting_for_user_input")
276428
- continue;
276429
- const args = parseArgs(call.arguments_string);
276430
- const base = {
276431
- toolCallId: call.id,
276432
- messageId: message.id,
276433
- tool: call.name
276434
- };
276435
- const summary = str2(args.summary);
276436
- if (CHOICE_TOOLS.has(call.name)) {
276437
- out.push({
276438
- ...base,
276439
- kind: "choice",
276440
- title: summary ?? "The agent has a few questions",
276441
- questions: questionsFrom(args)
276442
- });
276443
- } else if (SECRET_TOOLS.has(call.name)) {
276444
- out.push({
276445
- ...base,
276446
- kind: "secrets",
276447
- title: summary ?? "The agent needs secrets",
276448
- secrets: secretsFrom(args)
276449
- });
276450
- } else if (PERMISSION_TOOLS.has(call.name)) {
276451
- out.push({
276452
- ...base,
276453
- kind: "permissions",
276454
- title: summary ?? "Grant the app's agent these permissions?",
276455
- detail: str2(args.reason),
276456
- permissions: permissionsFrom(args)
276457
- });
276458
- } else if (BROWSER_TOOLS.has(call.name)) {
276459
- out.push({
276460
- ...base,
276461
- kind: "browser",
276462
- title: summary ?? humanize(call.name),
276463
- detail: str2(args.reason)
276464
- });
276465
- } else {
276466
- const guard = guardFrom(call.results);
276467
- const integration = str2(args.integration_type);
276468
- out.push({
276469
- ...base,
276470
- kind: "approval",
276471
- title: guard?.title ?? (integration ? `Enable ${integration}?` : summary ?? `${humanize(call.name)}?`),
276472
- detail: guard?.detail ?? (integration ? summary : undefined)
276473
- });
276474
- }
276202
+ if (os4.release().toLowerCase().includes("microsoft")) {
276203
+ if (isInsideContainer()) {
276204
+ return false;
276475
276205
  }
276206
+ return true;
276476
276207
  }
276477
- return out;
276478
- }
276479
- function choiceAnswers(questions, selections) {
276480
- const answers = questions.flatMap((q, index) => {
276481
- const sel = selections[index];
276482
- if (!sel || sel.labels.length === 0 && !sel.customText)
276483
- return [];
276484
- const answer = { question_index: index };
276485
- if (q.multiSelect) {
276486
- if (sel.labels.length)
276487
- answer.selected_labels = sel.labels;
276488
- } else if (sel.labels[0]) {
276489
- answer.selected_label = sel.labels[0];
276490
- }
276491
- if (sel.customText)
276492
- answer.custom_text = sel.customText;
276493
- return [answer];
276208
+ try {
276209
+ return fs18.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
276210
+ } catch {
276211
+ return false;
276212
+ }
276213
+ };
276214
+ var is_wsl_default = process24.env.__IS_WSL_TEST__ ? isWsl : isWsl();
276215
+
276216
+ // ../../node_modules/powershell-utils/index.js
276217
+ import process25 from "node:process";
276218
+ import { Buffer as Buffer7 } from "node:buffer";
276219
+ import { promisify as promisify5 } from "node:util";
276220
+ import childProcess from "node:child_process";
276221
+ var execFile = promisify5(childProcess.execFile);
276222
+ var powerShellPath = () => `${process25.env.SYSTEMROOT || process25.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
276223
+ var executePowerShell = async (command, options = {}) => {
276224
+ const {
276225
+ powerShellPath: psPath,
276226
+ ...execFileOptions
276227
+ } = options;
276228
+ const encodedCommand = executePowerShell.encodeCommand(command);
276229
+ return execFile(psPath ?? powerShellPath(), [
276230
+ ...executePowerShell.argumentsPrefix,
276231
+ encodedCommand
276232
+ ], {
276233
+ encoding: "utf8",
276234
+ ...execFileOptions
276494
276235
  });
276495
- return { answers };
276496
- }
276236
+ };
276237
+ executePowerShell.argumentsPrefix = [
276238
+ "-NoProfile",
276239
+ "-NonInteractive",
276240
+ "-ExecutionPolicy",
276241
+ "Bypass",
276242
+ "-EncodedCommand"
276243
+ ];
276244
+ executePowerShell.encodeCommand = (command) => Buffer7.from(command, "utf16le").toString("base64");
276245
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
276497
276246
 
276498
- // src/cli/commands/code/pending-card.ts
276499
- function openCard(pending) {
276500
- return {
276501
- pending,
276502
- step: 0,
276503
- cursor: 0,
276504
- selections: (pending.questions ?? []).map(() => ({ labels: [] })),
276505
- granted: new Set((pending.permissions ?? []).map((p) => p.key)),
276506
- typing: pending.kind === "secrets" ? "secret" : null,
276507
- secretValues: {}
276508
- };
276509
- }
276510
- var done = (action, input = {}) => ({ state: null, submit: { action, input } });
276511
- var later = { state: null, dismissed: true };
276512
- function choiceRows(state) {
276513
- return (state.pending.questions?.[state.step]?.options.length ?? 0) + 1;
276514
- }
276515
- function advanceChoice(state) {
276516
- const questions = state.pending.questions ?? [];
276517
- if (state.step + 1 < questions.length) {
276518
- return {
276519
- state: { ...state, step: state.step + 1, cursor: 0, typing: null }
276520
- };
276247
+ // ../../node_modules/wsl-utils/utilities.js
276248
+ function parseMountPointFromConfig(content) {
276249
+ for (const line of content.split(`
276250
+ `)) {
276251
+ if (/^\s*#/.test(line)) {
276252
+ continue;
276253
+ }
276254
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
276255
+ if (!match) {
276256
+ continue;
276257
+ }
276258
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
276521
276259
  }
276522
- return done("approved", choiceAnswers(questions, state.selections));
276523
276260
  }
276524
- function choiceKey(state, key) {
276525
- const question = state.pending.questions?.[state.step];
276526
- if (!question)
276527
- return done("approved", { answers: [] });
276528
- const rows = choiceRows(state);
276529
- const custom = state.cursor === rows - 1;
276530
- const sel = state.selections[state.step] ?? { labels: [] };
276531
- const setSel = (next) => {
276532
- const selections = [...state.selections];
276533
- selections[state.step] = next;
276534
- return { ...state, selections };
276535
- };
276536
- switch (key) {
276537
- case "up":
276538
- return { state: { ...state, cursor: (state.cursor - 1 + rows) % rows } };
276539
- case "down":
276540
- return { state: { ...state, cursor: (state.cursor + 1) % rows } };
276541
- case "space": {
276542
- if (custom)
276543
- return { state: { ...state, typing: "custom" } };
276544
- const label = question.options[state.cursor].label;
276545
- const labels = question.multiSelect ? sel.labels.includes(label) ? sel.labels.filter((l) => l !== label) : [...sel.labels, label] : [label];
276546
- return { state: setSel({ ...sel, labels }) };
276261
+
276262
+ // ../../node_modules/wsl-utils/index.js
276263
+ var execFile2 = promisify6(childProcess2.execFile);
276264
+ var wslDrivesMountPoint = (() => {
276265
+ const defaultMountPoint = "/mnt/";
276266
+ let mountPoint;
276267
+ return async function() {
276268
+ if (mountPoint) {
276269
+ return mountPoint;
276547
276270
  }
276548
- case "enter": {
276549
- if (custom)
276550
- return { state: { ...state, typing: "custom" } };
276551
- if (question.multiSelect) {
276552
- if (sel.labels.length === 0 && !sel.customText)
276553
- return { state };
276554
- return advanceChoice(state);
276555
- }
276556
- const label = question.options[state.cursor].label;
276557
- return advanceChoice(setSel({ labels: [label] }));
276271
+ const configFilePath = "/etc/wsl.conf";
276272
+ let isConfigFileExists = false;
276273
+ try {
276274
+ await fs19.access(configFilePath, fsConstants.F_OK);
276275
+ isConfigFileExists = true;
276276
+ } catch {}
276277
+ if (!isConfigFileExists) {
276278
+ return defaultMountPoint;
276558
276279
  }
276559
- case "s":
276560
- return done("approved", { answers: [] });
276561
- case "escape":
276562
- return later;
276563
- default:
276564
- return { state };
276565
- }
276566
- }
276567
- function permissionsKey(state, key) {
276568
- const rows = state.pending.permissions ?? [];
276569
- switch (key) {
276570
- case "up":
276571
- return {
276572
- state: {
276573
- ...state,
276574
- cursor: (state.cursor - 1 + rows.length) % rows.length
276575
- }
276576
- };
276577
- case "down":
276578
- return { state: { ...state, cursor: (state.cursor + 1) % rows.length } };
276579
- case "space": {
276580
- const k = rows[state.cursor]?.key;
276581
- if (!k)
276582
- return { state };
276583
- const granted = new Set(state.granted);
276584
- if (granted.has(k))
276585
- granted.delete(k);
276586
- else
276587
- granted.add(k);
276588
- return { state: { ...state, granted } };
276280
+ const configContent = await fs19.readFile(configFilePath, { encoding: "utf8" });
276281
+ const parsedMountPoint = parseMountPointFromConfig(configContent);
276282
+ if (parsedMountPoint === undefined) {
276283
+ return defaultMountPoint;
276589
276284
  }
276590
- case "enter":
276591
- case "y":
276592
- return done("approved", {
276593
- approved_permission_keys: rows.map((r) => r.key).filter((k) => state.granted.has(k))
276594
- });
276595
- case "n":
276596
- return done("rejected");
276597
- case "escape":
276598
- return later;
276599
- default:
276600
- return { state };
276601
- }
276602
- }
276603
- function cardKey(state, key) {
276604
- if (state.typing) {
276605
- if (key === "escape") {
276606
- return state.typing === "secret" ? later : { state: { ...state, typing: null } };
276285
+ mountPoint = parsedMountPoint;
276286
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
276287
+ return mountPoint;
276288
+ };
276289
+ })();
276290
+ var powerShellPathFromWsl = async () => {
276291
+ const mountPoint = await wslDrivesMountPoint();
276292
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
276293
+ };
276294
+ var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
276295
+ var canAccessPowerShellPromise;
276296
+ var canAccessPowerShell = async () => {
276297
+ canAccessPowerShellPromise ??= (async () => {
276298
+ try {
276299
+ const psPath = await powerShellPath2();
276300
+ await fs19.access(psPath, fsConstants.X_OK);
276301
+ return true;
276302
+ } catch {
276303
+ return false;
276607
276304
  }
276608
- return { state };
276305
+ })();
276306
+ return canAccessPowerShellPromise;
276307
+ };
276308
+ var wslDefaultBrowser = async () => {
276309
+ const psPath = await powerShellPath2();
276310
+ const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
276311
+ const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
276312
+ return stdout.trim();
276313
+ };
276314
+ var convertWslPathToWindows = async (path) => {
276315
+ if (/^[a-z]+:\/\//i.test(path)) {
276316
+ return path;
276609
276317
  }
276610
- switch (state.pending.kind) {
276611
- case "choice":
276612
- return choiceKey(state, key);
276613
- case "permissions":
276614
- return permissionsKey(state, key);
276615
- default:
276616
- if (key === "y" || key === "enter")
276617
- return done("approved");
276618
- if (key === "n")
276619
- return done("rejected");
276620
- if (key === "escape")
276621
- return later;
276622
- return { state };
276318
+ try {
276319
+ const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
276320
+ return stdout.trim();
276321
+ } catch {
276322
+ return path;
276623
276323
  }
276324
+ };
276325
+
276326
+ // ../../node_modules/define-lazy-prop/index.js
276327
+ function defineLazyProperty(object, propertyName, valueGetter) {
276328
+ const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
276329
+ Object.defineProperty(object, propertyName, {
276330
+ configurable: true,
276331
+ enumerable: true,
276332
+ get() {
276333
+ const result = valueGetter();
276334
+ define2(result);
276335
+ return result;
276336
+ },
276337
+ set(value) {
276338
+ define2(value);
276339
+ }
276340
+ });
276341
+ return object;
276624
276342
  }
276625
- function cardText(state, text) {
276626
- const value = text.trim();
276627
- if (state.typing === "custom") {
276628
- if (!value)
276629
- return { state: { ...state, typing: null } };
276630
- const selections = [...state.selections];
276631
- const current = selections[state.step] ?? { labels: [] };
276632
- selections[state.step] = { ...current, customText: value };
276633
- return advanceChoice({ ...state, selections, typing: null });
276343
+
276344
+ // ../../node_modules/default-browser/index.js
276345
+ import { promisify as promisify10 } from "node:util";
276346
+ import process28 from "node:process";
276347
+ import { execFile as execFile6 } from "node:child_process";
276348
+
276349
+ // ../../node_modules/default-browser-id/index.js
276350
+ import { promisify as promisify7 } from "node:util";
276351
+ import process26 from "node:process";
276352
+ import { execFile as execFile3 } from "node:child_process";
276353
+ var execFileAsync = promisify7(execFile3);
276354
+ async function defaultBrowserId() {
276355
+ if (process26.platform !== "darwin") {
276356
+ throw new Error("macOS only");
276634
276357
  }
276635
- if (state.typing === "secret") {
276636
- const fields = state.pending.secrets ?? [];
276637
- const field = fields[state.step];
276638
- if (!field || !value)
276639
- return { state };
276640
- const secretValues = { ...state.secretValues, [field.name]: value };
276641
- if (state.step + 1 < fields.length) {
276642
- return { state: { ...state, secretValues, step: state.step + 1 } };
276643
- }
276644
- return done("approved", { secrets: secretValues });
276358
+ const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
276359
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
276360
+ const browserId = match?.groups.id ?? "com.apple.Safari";
276361
+ if (browserId === "com.apple.safari") {
276362
+ return "com.apple.Safari";
276645
276363
  }
276646
- return { state };
276364
+ return browserId;
276647
276365
  }
276648
- function cardLines(state) {
276649
- const p = state.pending;
276650
- const head = [source_default.bold(`⏸ ${p.title}`)];
276651
- if (p.detail)
276652
- head.push(source_default.dim(` ${p.detail}`));
276653
- switch (p.kind) {
276654
- case "choice": {
276655
- const q = p.questions?.[state.step];
276656
- if (!q)
276657
- return [...head, source_default.dim(" (no questions) · Enter to continue")];
276658
- const total = p.questions?.length ?? 1;
276659
- const sel = state.selections[state.step] ?? { labels: [] };
276660
- const rows = q.options.map((o, i) => {
276661
- const on = sel.labels.includes(o.label);
276662
- const mark = q.multiSelect ? on ? "☑" : "☐" : on ? "●" : "○";
276663
- const text = `${state.cursor === i ? "▸" : " "} ${mark} ${o.label}${o.description ? source_default.dim(` — ${o.description}`) : ""}`;
276664
- return state.cursor === i ? source_default.cyan(text) : text;
276665
- });
276666
- const customRow = `${state.cursor === q.options.length ? "▸" : " "} ✎ something else${sel.customText ? source_default.dim(` — ${sel.customText}`) : ""}`;
276667
- rows.push(state.cursor === q.options.length ? source_default.cyan(customRow) : customRow);
276668
- return [
276669
- ...head,
276670
- ` ${source_default.bold(q.question)} ${source_default.dim(`(${state.step + 1}/${total})`)}`,
276671
- ...q.description ? [source_default.dim(` ${q.description}`)] : [],
276672
- ...rows.map((r) => ` ${r}`),
276673
- source_default.dim(q.multiSelect ? " ↑↓ move · space toggle · Enter next · s skip all · Esc later" : " ↑↓ move · Enter choose · s skip all · Esc later")
276674
- ];
276675
- }
276676
- case "permissions": {
276677
- const rows = (p.permissions ?? []).map((r, i) => {
276678
- const text = `${state.cursor === i ? "▸" : " "} ${state.granted.has(r.key) ? "☑" : "☐"} ${r.label}${r.reason ? source_default.dim(` — ${r.reason}`) : ""}`;
276679
- return ` ${state.cursor === i ? source_default.cyan(text) : text}`;
276680
- });
276681
- return [
276682
- ...head,
276683
- ...rows,
276684
- source_default.dim(" space toggle · Enter grant ticked · n reject all · Esc later")
276685
- ];
276686
- }
276687
- case "secrets": {
276688
- const fields = p.secrets ?? [];
276689
- const rows = fields.map((f, i) => {
276690
- const filled = f.name in state.secretValues;
276691
- const mark = filled ? source_default.green("✓") : i === state.step ? "▸" : "○";
276692
- return ` ${mark} ${f.name}${f.description ? source_default.dim(` — ${f.description}`) : ""}`;
276693
- });
276694
- return [
276695
- ...head,
276696
- ...rows,
276697
- source_default.dim(" type the value below (hidden) · Enter next · Esc later")
276698
- ];
276699
- }
276700
- case "browser":
276701
- return [
276702
- ...head,
276703
- source_default.dim(" finish this step in the editor (footer link), then press y"),
276704
- source_default.dim(" y continue · n reject · Esc later")
276705
- ];
276706
- default:
276707
- return [...head, source_default.dim(" y approve · n reject · Esc later")];
276366
+
276367
+ // ../../node_modules/run-applescript/index.js
276368
+ import process27 from "node:process";
276369
+ import { promisify as promisify8 } from "node:util";
276370
+ import { execFile as execFile4, execFileSync } from "node:child_process";
276371
+ var execFileAsync2 = promisify8(execFile4);
276372
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
276373
+ if (process27.platform !== "darwin") {
276374
+ throw new Error("macOS only");
276375
+ }
276376
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
276377
+ const execOptions = {};
276378
+ if (signal) {
276379
+ execOptions.signal = signal;
276708
276380
  }
276381
+ const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
276382
+ return stdout.trim();
276709
276383
  }
276710
276384
 
276711
- // src/cli/commands/code/session-engine.ts
276712
- var POLL_MS = 1000;
276713
- function createSessionEngine(options) {
276714
- const running = new Map;
276715
- const diffState = newStreamState();
276716
- let stopped = false;
276717
- let polling = false;
276718
- let pollStartedAt = 0;
276719
- let timer = null;
276720
- let sendsInFlight = 0;
276721
- let activeTurnId = null;
276722
- let turnStartedAt = null;
276723
- let pendingSubmitAt = null;
276724
- let lastTurnMs = null;
276725
- let lastTurnOk = true;
276726
- let settledCount = 0;
276727
- let awaitingTurn = options.awaitingTurnLabel ?? null;
276728
- const awaitingSince = Date.now();
276729
- let lastEventAt = Date.now();
276730
- let pending = [];
276731
- const answered = new Set;
276732
- const answer = (p, action, input = {}) => {
276733
- answered.add(p.toolCallId);
276734
- pending = pending.filter((x) => x.toolCallId !== p.toolCallId);
276735
- const verb = action === "rejected" ? source_default.red("✗ rejected") : Object.keys(input).length ? source_default.green("→ answered") : source_default.green("✓ approved");
276736
- options.onLine(`${verb} ${source_default.dim("—")} ${p.title}`);
276737
- pendingSubmitAt = Date.now();
276738
- sendsInFlight++;
276739
- answerToolCall({ toolCallId: p.toolCallId, messageId: p.messageId, action, input }, options.branchId).catch((error) => {
276740
- const status = error instanceof ApiError ? error.statusCode : undefined;
276741
- const edgeDrop = status === 502 || status === 503 || status === 504 || /timeout|gateway/i.test(error instanceof Error ? error.message : "");
276742
- if (edgeDrop && (turnStartedAt != null || pendingSubmitAt == null)) {
276743
- return;
276744
- }
276745
- answered.delete(p.toolCallId);
276746
- pendingSubmitAt = null;
276747
- options.onLine(source_default.red(`✗ answer failed: ${error instanceof Error ? error.message : String(error)}`));
276748
- }).finally(() => {
276749
- sendsInFlight--;
276750
- });
276751
- };
276752
- const submit = (raw) => {
276753
- const typed = raw.trim();
276754
- if (!typed)
276755
- return;
276756
- const text = typed;
276757
- options.onLine(`${source_default.cyan("❯")} ${source_default.bold(typed)}`);
276758
- pendingSubmitAt = Date.now();
276759
- const submitTurnId = activeTurnId;
276760
- sendsInFlight++;
276761
- sendTurn(text, options.branchId).then((turn) => {
276762
- if (turn.queued) {
276763
- options.onLine(source_default.dim("· queued — runs after the current turn"));
276764
- }
276765
- }).catch((error) => {
276766
- const delivered = activeTurnId !== submitTurnId || turnStartedAt != null || pendingSubmitAt == null;
276767
- const status = error instanceof ApiError ? error.statusCode : undefined;
276768
- const edgeDrop = status === 502 || status === 503 || status === 504 || /timeout|gateway/i.test(error instanceof Error ? error.message : "");
276769
- if (edgeDrop && delivered)
276770
- return;
276771
- pendingSubmitAt = null;
276772
- const message = error instanceof Error ? error.message : String(error);
276773
- options.onLine(source_default.red(`✗ send failed: ${message}`));
276774
- }).finally(() => {
276775
- sendsInFlight--;
276776
- });
276777
- };
276778
- const poll = async (prime) => {
276779
- const STUCK_POLL_MS = 45000;
276780
- if (polling && Date.now() - pollStartedAt < STUCK_POLL_MS)
276781
- return;
276782
- polling = true;
276783
- pollStartedAt = Date.now();
276784
- try {
276785
- let messages;
276786
- try {
276787
- messages = await getFullConversation(30, options.branchId);
276788
- } catch {
276789
- return;
276790
- }
276791
- const events = diffConversation(diffState, messages);
276792
- const waiting = pendingInputs(messages);
276793
- for (const id of answered) {
276794
- if (!waiting.some((w) => w.toolCallId === id))
276795
- answered.delete(id);
276796
- }
276797
- pending = waiting.filter((w) => !answered.has(w.toolCallId));
276798
- if (!prime) {
276799
- for (const event of events) {
276800
- if (event.kind === "tool_start") {
276801
- const startedAt = Date.now();
276802
- running.set(event.id, {
276803
- alias: toolAlias(event.name),
276804
- label: event.label,
276805
- summary: event.summary,
276806
- startedAt
276807
- });
276808
- options.onLine({ running: event, startedAt });
276809
- continue;
276810
- }
276811
- if (event.kind === "tool_end") {
276812
- const started = running.get(event.id)?.startedAt;
276813
- running.delete(event.id);
276814
- lastEventAt = Date.now();
276815
- options.onLine({
276816
- event,
276817
- elapsedMs: started != null ? Date.now() - started : undefined
276818
- });
276819
- continue;
276820
- }
276821
- const line = eventLine(event, undefined, {
276822
- waitingHint: "answer in the card below"
276823
- });
276824
- if (line != null) {
276825
- lastEventAt = Date.now();
276826
- options.onLine(line);
276827
- }
276828
- }
276829
- }
276830
- const turn = newestUserTurn(messages);
276831
- if (!turn)
276832
- return;
276833
- const kickoffDetection = awaitingTurn != null && activeTurnId === null;
276834
- awaitingTurn = null;
276835
- if (turn.id !== activeTurnId) {
276836
- activeTurnId = turn.id;
276837
- if (!turn.settled) {
276838
- turnStartedAt = pendingSubmitAt ?? (kickoffDetection ? awaitingSince : Date.now());
276839
- pendingSubmitAt = null;
276840
- running.clear();
276841
- } else if (prime) {
276842
- turnStartedAt = null;
276843
- }
276844
- }
276845
- if (turn.settled && turnStartedAt != null && turn.id === activeTurnId) {
276846
- const durationMs = Date.now() - turnStartedAt;
276847
- turnStartedAt = null;
276848
- running.clear();
276849
- lastTurnMs = durationMs;
276850
- const ok = !turn.backendStatus?.startsWith("error");
276851
- lastTurnOk = ok;
276852
- options.onLine(ok ? source_default.dim(`— turn finished · ${formatDuration2(durationMs)}`) : source_default.red(`— turn failed (${turn.backendStatus ?? "unknown"}) · ${formatDuration2(durationMs)}`));
276853
- const info = {
276854
- turnIndex: settledCount++,
276855
- ok,
276856
- backendStatus: turn.backendStatus,
276857
- durationMs
276858
- };
276859
- try {
276860
- await options.onTurnSettled?.(info);
276861
- } catch {}
276862
- }
276863
- } finally {
276864
- polling = false;
276865
- }
276866
- };
276867
- return {
276868
- async start(primeFirstPoll) {
276869
- await poll(primeFirstPoll);
276870
- timer = setInterval(() => {
276871
- if (!stopped)
276872
- poll(false);
276873
- }, POLL_MS);
276874
- timer.unref?.();
276875
- },
276876
- stop() {
276877
- stopped = true;
276878
- if (timer)
276879
- clearInterval(timer);
276880
- },
276881
- stopTurn() {
276882
- if (turnStartedAt == null && sendsInFlight === 0 && pendingSubmitAt == null)
276883
- return;
276884
- options.onLine(source_default.dim("· stopping…"));
276885
- stopTurn(options.branchId).catch((error) => {
276886
- options.onLine(source_default.red(` stop failed: ${error instanceof Error ? error.message : String(error)}`));
276887
- });
276888
- },
276889
- submit,
276890
- answer,
276891
- status() {
276892
- let phase = "idle";
276893
- if (awaitingTurn != null)
276894
- phase = "awaiting";
276895
- else if (turnStartedAt != null)
276896
- phase = "running";
276897
- else if (sendsInFlight > 0 || pendingSubmitAt != null)
276898
- phase = "sending";
276899
- let runningTool = null;
276900
- if (running.size > 0) {
276901
- const newest = [...running.values()].at(-1);
276902
- runningTool = { ...newest, others: running.size - 1 };
276903
- }
276904
- return {
276905
- phase,
276906
- awaitingLabel: awaitingTurn ?? undefined,
276907
- idleHint: options.idleHint,
276908
- quietForMs: Date.now() - lastEventAt,
276909
- awaitingSince,
276910
- turnStartedAt,
276911
- runningTool,
276912
- lastTurnMs,
276913
- lastTurnOk,
276914
- pending
276915
- };
276916
- },
276917
- turnRunning() {
276918
- return turnStartedAt != null;
276919
- }
276920
- };
276385
+ // ../../node_modules/bundle-name/index.js
276386
+ async function bundleName(bundleId) {
276387
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
276388
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
276921
276389
  }
276922
276390
 
276923
- // src/cli/commands/code/session.tsx
276924
- var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
276925
- var FRAMES2 = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
276926
- var BRAND_ORANGE = "#E86B3C";
276927
- var altScreenActive = false;
276928
- var altExitHooked = false;
276929
- function enterAltScreen() {
276930
- process.stdout.write("\x1B[?1049h\x1B[?1007h\x1B[2J\x1B[H");
276931
- altScreenActive = true;
276932
- if (!altExitHooked) {
276933
- altExitHooked = true;
276934
- process.on("exit", () => {
276935
- if (altScreenActive)
276936
- process.stdout.write("\x1B[?1007l\x1B[?1049l");
276937
- });
276938
- }
276391
+ // ../../node_modules/default-browser/windows.js
276392
+ import { promisify as promisify9 } from "node:util";
276393
+ import { execFile as execFile5 } from "node:child_process";
276394
+ var execFileAsync3 = promisify9(execFile5);
276395
+ var windowsBrowserProgIds = {
276396
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
276397
+ MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
276398
+ MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
276399
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
276400
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
276401
+ ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
276402
+ ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
276403
+ ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
276404
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
276405
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
276406
+ BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
276407
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
276408
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
276409
+ OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
276410
+ VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
276411
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
276412
+ };
276413
+ var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
276414
+
276415
+ class UnknownBrowserError extends Error {
276939
276416
  }
276940
- function exitAltScreen() {
276941
- if (!altScreenActive)
276942
- return;
276943
- altScreenActive = false;
276944
- process.stdout.write("\x1B[?1007l\x1B[?1049l");
276417
+ async function defaultBrowser(_execFileAsync = execFileAsync3) {
276418
+ const { stdout } = await _execFileAsync("reg", [
276419
+ "QUERY",
276420
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
276421
+ "/v",
276422
+ "ProgId"
276423
+ ]);
276424
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
276425
+ if (!match) {
276426
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
276427
+ }
276428
+ const { id } = match.groups;
276429
+ const dotIndex = id.lastIndexOf(".");
276430
+ const hyphenIndex = id.lastIndexOf("-");
276431
+ const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
276432
+ const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
276433
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
276945
276434
  }
276946
- function withEntry(items, entry) {
276947
- if (typeof entry !== "string" && "event" in entry) {
276948
- const i = items.findIndex((e) => typeof e !== "string" && ("running" in e) && e.running.id === entry.event.id);
276949
- if (i >= 0) {
276950
- const next = [...items];
276951
- next[i] = entry;
276952
- return next;
276953
- }
276435
+
276436
+ // ../../node_modules/default-browser/index.js
276437
+ var execFileAsync4 = promisify10(execFile6);
276438
+ var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
276439
+ async function defaultBrowser2() {
276440
+ if (process28.platform === "darwin") {
276441
+ const id = await defaultBrowserId();
276442
+ const name = await bundleName(id);
276443
+ return { name, id };
276444
+ }
276445
+ if (process28.platform === "linux") {
276446
+ const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
276447
+ const id = stdout.trim();
276448
+ const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
276449
+ return { name, id };
276954
276450
  }
276955
- return [...items, entry];
276956
- }
276957
- function statusText(status, musingSeed) {
276958
- const frame = FRAMES2[Math.floor(Date.now() / 120) % FRAMES2.length];
276959
- switch (status.phase) {
276960
- case "awaiting":
276961
- return source_default.dim(`${frame} ${status.awaitingLabel} (${formatDuration2(Date.now() - status.awaitingSince)})`);
276962
- case "running": {
276963
- const turnFor = formatDuration2(Date.now() - (status.turnStartedAt ?? Date.now()));
276964
- const quiet = status.quietForMs > 60000 ? " · a long private step — details render in the editor" : "";
276965
- return `${source_default.magenta(shimmer())} ${source_default.dim(`${idleMusing(musingSeed)} (${turnFor})${quiet}`)}`;
276966
- }
276967
- case "sending":
276968
- return source_default.dim(`${frame} sending…`);
276969
- case "idle": {
276970
- const hint = status.idleHint ? ` — ${status.idleHint}` : "";
276971
- const last = status.lastTurnMs != null ? ` · last turn ${formatDuration2(status.lastTurnMs)}${status.lastTurnOk ? "" : " (failed)"}` : "";
276972
- return source_default.dim(`ready${hint}${last}`);
276973
- }
276451
+ if (process28.platform === "win32") {
276452
+ return defaultBrowser();
276974
276453
  }
276454
+ throw new Error("Only macOS, Linux, and Windows are supported");
276975
276455
  }
276976
- function SessionView({ engine, footer, subscribe }) {
276977
- const { exit } = use_app_default();
276978
- const [items, setItems] = import_react23.useState([]);
276979
- const [verbose, setVerbose] = import_react23.useState(false);
276980
- const [input, setInput] = import_react23.useState("");
276981
- const [scroll, setScroll] = import_react23.useState(0);
276982
- const [, tick] = import_react23.useReducer((x) => x + 1, 0);
276983
- const [musingSeed] = import_react23.useState(() => Math.floor(Math.random() * 97));
276984
- const [currentModel, setCurrentModel] = import_react23.useState(null);
276985
- const [pickerIndex, setPickerIndex] = import_react23.useState(null);
276986
- const [card, setCard] = import_react23.useState(null);
276987
- const dismissedRef = import_react23.useRef(new Set);
276988
- const maxScrollRef = import_react23.useRef(0);
276989
- const meIdRef = import_react23.useRef(null);
276990
- const emit = (entry) => setItems((h) => withEntry(h, entry));
276991
- import_react23.useEffect(() => subscribe((entry) => setItems((h) => withEntry(h, entry))), [subscribe]);
276992
- import_react23.useEffect(() => {
276993
- const timer = setInterval(tick, 120);
276994
- return () => clearInterval(timer);
276995
- }, []);
276996
- import_react23.useEffect(() => {
276997
- getMe().then((me) => {
276998
- meIdRef.current = me.id;
276999
- setCurrentModel(me.builder_model ?? null);
277000
- }).catch(() => {});
277001
- }, []);
277002
- const applyModel = async (pick) => {
277003
- const orange = source_default.hex(BRAND_ORANGE);
276456
+
276457
+ // ../../node_modules/is-in-ssh/index.js
276458
+ import process29 from "node:process";
276459
+ var isInSsh = Boolean(process29.env.SSH_CONNECTION || process29.env.SSH_CLIENT || process29.env.SSH_TTY);
276460
+ var is_in_ssh_default = isInSsh;
276461
+
276462
+ // ../../node_modules/open/index.js
276463
+ var fallbackAttemptSymbol = Symbol("fallbackAttempt");
276464
+ var __dirname2 = import.meta.url ? path16.dirname(fileURLToPath4(import.meta.url)) : "";
276465
+ var localXdgOpenPath = path16.join(__dirname2, "xdg-open");
276466
+ var { platform: platform7, arch } = process30;
276467
+ var tryEachApp = async (apps, opener) => {
276468
+ if (apps.length === 0) {
276469
+ return;
276470
+ }
276471
+ const errors = [];
276472
+ for (const app of apps) {
277004
276473
  try {
277005
- if ((pick.id ?? null) === currentModel) {
277006
- emit(source_default.dim(` already on ${pick.name}`));
277007
- return;
277008
- }
277009
- let id = meIdRef.current;
277010
- if (!id) {
277011
- id = (await getMe()).id;
277012
- meIdRef.current = id;
277013
- }
277014
- await saveBuilderModel(id, pick.id);
277015
- setCurrentModel(pick.id);
277016
- emit(pick.id === null ? source_default.dim(" model reset — Base44 chooses per app") : ` ${orange("●")} model set to ${source_default.bold(pick.name)}`);
276474
+ return await opener(app);
277017
276475
  } catch (error) {
277018
- emit(source_default.red(` /model: ${error instanceof Error ? error.message : String(error)}`));
276476
+ errors.push(error);
277019
276477
  }
276478
+ }
276479
+ throw new AggregateError(errors, "Failed to open in all supported apps");
276480
+ };
276481
+ var baseOpen = async (options) => {
276482
+ options = {
276483
+ wait: false,
276484
+ background: false,
276485
+ newInstance: false,
276486
+ allowNonzeroExitCode: false,
276487
+ ...options
277020
276488
  };
277021
- const runModelSlash = (arg) => {
277022
- if (!arg) {
277023
- const cur = MODELS.findIndex((m) => (m.id ?? null) === currentModel);
277024
- setPickerIndex(cur >= 0 ? cur : 0);
277025
- return;
276489
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
276490
+ delete options[fallbackAttemptSymbol];
276491
+ if (Array.isArray(options.app)) {
276492
+ return tryEachApp(options.app, (singleApp) => baseOpen({
276493
+ ...options,
276494
+ app: singleApp,
276495
+ [fallbackAttemptSymbol]: true
276496
+ }));
276497
+ }
276498
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
276499
+ appArguments = [...appArguments];
276500
+ if (Array.isArray(app)) {
276501
+ return tryEachApp(app, (appName) => baseOpen({
276502
+ ...options,
276503
+ app: {
276504
+ name: appName,
276505
+ arguments: appArguments
276506
+ },
276507
+ [fallbackAttemptSymbol]: true
276508
+ }));
276509
+ }
276510
+ if (app === "browser" || app === "browserPrivate") {
276511
+ const ids = {
276512
+ "com.google.chrome": "chrome",
276513
+ "google-chrome.desktop": "chrome",
276514
+ "com.brave.browser": "brave",
276515
+ "org.mozilla.firefox": "firefox",
276516
+ "firefox.desktop": "firefox",
276517
+ "com.microsoft.msedge": "edge",
276518
+ "com.microsoft.edge": "edge",
276519
+ "com.microsoft.edgemac": "edge",
276520
+ "microsoft-edge.desktop": "edge",
276521
+ "com.apple.safari": "safari"
276522
+ };
276523
+ const flags = {
276524
+ chrome: "--incognito",
276525
+ brave: "--incognito",
276526
+ firefox: "--private-window",
276527
+ edge: "--inPrivate"
276528
+ };
276529
+ let browser;
276530
+ if (is_wsl_default) {
276531
+ const progId = await wslDefaultBrowser();
276532
+ const browserInfo = _windowsBrowserProgIdMap.get(progId);
276533
+ browser = browserInfo ?? {};
276534
+ } else {
276535
+ browser = await defaultBrowser2();
277026
276536
  }
277027
- try {
277028
- applyModel(resolvePick(arg));
277029
- } catch (error) {
277030
- emit(source_default.red(` /model: ${error instanceof Error ? error.message : String(error)}`));
276537
+ if (browser.id in ids) {
276538
+ const browserName = ids[browser.id.toLowerCase()];
276539
+ if (app === "browserPrivate") {
276540
+ if (browserName === "safari") {
276541
+ throw new Error("Safari doesn't support opening in private mode via command line");
276542
+ }
276543
+ appArguments.push(flags[browserName]);
276544
+ }
276545
+ return baseOpen({
276546
+ ...options,
276547
+ app: {
276548
+ name: apps[browserName],
276549
+ arguments: appArguments
276550
+ }
276551
+ });
277031
276552
  }
277032
- };
277033
- const applyCard = (outcome) => {
277034
- if (outcome.submit && card) {
277035
- engine.answer(card.pending, outcome.submit.action, outcome.submit.input);
276553
+ throw new Error(`${browser.name} is not supported as a default browser`);
276554
+ }
276555
+ let command;
276556
+ const cliArguments = [];
276557
+ const childProcessOptions = {};
276558
+ let shouldUseWindowsInWsl = false;
276559
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
276560
+ shouldUseWindowsInWsl = await canAccessPowerShell();
276561
+ }
276562
+ if (platform7 === "darwin") {
276563
+ command = "open";
276564
+ if (options.wait) {
276565
+ cliArguments.push("--wait-apps");
277036
276566
  }
277037
- if (outcome.dismissed && card) {
277038
- dismissedRef.current.add(card.pending.toolCallId);
276567
+ if (options.background) {
276568
+ cliArguments.push("--background");
277039
276569
  }
277040
- setCard(outcome.state);
277041
- };
277042
- const pending = engine.status().pending;
277043
- import_react23.useEffect(() => {
277044
- if (card) {
277045
- if (!pending.some((p) => p.toolCallId === card.pending.toolCallId)) {
277046
- setCard(null);
277047
- }
277048
- return;
276570
+ if (options.newInstance) {
276571
+ cliArguments.push("--new");
277049
276572
  }
277050
- if (pickerIndex !== null)
277051
- return;
277052
- const next = pending.find((p) => !dismissedRef.current.has(p.toolCallId));
277053
- if (next)
277054
- setCard(openCard(next));
277055
- }, [pending, card, pickerIndex]);
277056
- use_input_default((char, key) => {
277057
- if (pickerIndex !== null) {
277058
- if (key.upArrow)
277059
- setPickerIndex((i) => ((i ?? 0) - 1 + MODELS.length) % MODELS.length);
277060
- else if (key.downArrow)
277061
- setPickerIndex((i) => ((i ?? 0) + 1) % MODELS.length);
277062
- else if (key.return) {
277063
- const pick = MODELS[pickerIndex];
277064
- setPickerIndex(null);
277065
- applyModel(pick);
277066
- } else if (key.escape || key.ctrl && char === "c") {
277067
- setPickerIndex(null);
277068
- }
277069
- return;
276573
+ if (app) {
276574
+ cliArguments.push("-a", app);
277070
276575
  }
277071
- if (key.tab && !card) {
277072
- const next = pending.find((p) => dismissedRef.current.has(p.toolCallId));
277073
- if (next) {
277074
- dismissedRef.current.delete(next.toolCallId);
277075
- setCard(openCard(next));
277076
- }
277077
- return;
276576
+ } else if (platform7 === "win32" || shouldUseWindowsInWsl) {
276577
+ command = await powerShellPath2();
276578
+ cliArguments.push(...executePowerShell.argumentsPrefix);
276579
+ if (!is_wsl_default) {
276580
+ childProcessOptions.windowsVerbatimArguments = true;
277078
276581
  }
277079
- if (card) {
277080
- const mapped = key.upArrow ? "up" : key.downArrow ? "down" : key.return ? "enter" : key.escape ? "escape" : char === " " ? "space" : char === "y" || char === "n" || char === "s" ? char : null;
277081
- if (card.typing && mapped !== "escape")
277082
- return;
277083
- if (mapped)
277084
- applyCard(cardKey(card, mapped));
277085
- if (mapped || !card.typing)
277086
- return;
276582
+ if (is_wsl_default && options.target) {
276583
+ options.target = await convertWslPathToWindows(options.target);
277087
276584
  }
277088
- if (key.ctrl && char === "c") {
277089
- if (input)
277090
- setInput("");
277091
- else
277092
- exit();
277093
- return;
276585
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
276586
+ if (options.wait) {
276587
+ encodedArguments.push("-Wait");
276588
+ }
276589
+ if (app) {
276590
+ encodedArguments.push(executePowerShell.escapeArgument(app));
276591
+ if (options.target) {
276592
+ appArguments.push(options.target);
276593
+ }
276594
+ } else if (options.target) {
276595
+ encodedArguments.push(executePowerShell.escapeArgument(options.target));
277094
276596
  }
277095
- if (key.ctrl && char === "d") {
277096
- exit();
277097
- return;
276597
+ if (appArguments.length > 0) {
276598
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
276599
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
277098
276600
  }
277099
- if (key.ctrl && char === "o") {
277100
- setVerbose((v) => !v);
277101
- return;
276601
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
276602
+ if (!options.wait) {
276603
+ childProcessOptions.stdio = "ignore";
277102
276604
  }
277103
- if (key.upArrow) {
277104
- setScroll((s) => Math.min(s + 3, maxScrollRef.current));
277105
- return;
276605
+ } else {
276606
+ if (app) {
276607
+ command = app;
276608
+ } else {
276609
+ const isBundled = !__dirname2 || __dirname2 === "/";
276610
+ let exeLocalXdgOpen = false;
276611
+ try {
276612
+ await fs20.access(localXdgOpenPath, fsConstants2.X_OK);
276613
+ exeLocalXdgOpen = true;
276614
+ } catch {}
276615
+ const useSystemXdgOpen = process30.versions.electron ?? (platform7 === "android" || isBundled || !exeLocalXdgOpen);
276616
+ command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
277106
276617
  }
277107
- if (key.downArrow) {
277108
- setScroll((s) => Math.max(0, s - 3));
277109
- return;
276618
+ if (appArguments.length > 0) {
276619
+ cliArguments.push(...appArguments);
277110
276620
  }
277111
- if (key.pageUp) {
277112
- setScroll((s) => Math.min(s + 20, maxScrollRef.current));
277113
- return;
276621
+ if (!options.wait) {
276622
+ childProcessOptions.stdio = "ignore";
276623
+ childProcessOptions.detached = true;
277114
276624
  }
277115
- if (key.pageDown) {
277116
- setScroll((s) => Math.max(0, s - 20));
277117
- return;
276625
+ }
276626
+ if (platform7 === "darwin" && appArguments.length > 0) {
276627
+ cliArguments.push("--args", ...appArguments);
276628
+ }
276629
+ if (options.target) {
276630
+ cliArguments.push(options.target);
276631
+ }
276632
+ const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
276633
+ if (options.wait) {
276634
+ return new Promise((resolve, reject) => {
276635
+ subprocess.once("error", reject);
276636
+ subprocess.once("close", (exitCode) => {
276637
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
276638
+ reject(new Error(`Exited with code ${exitCode}`));
276639
+ return;
276640
+ }
276641
+ resolve(subprocess);
276642
+ });
276643
+ });
276644
+ }
276645
+ if (isFallbackAttempt) {
276646
+ return new Promise((resolve, reject) => {
276647
+ subprocess.once("error", reject);
276648
+ subprocess.once("spawn", () => {
276649
+ subprocess.once("close", (exitCode) => {
276650
+ subprocess.off("error", reject);
276651
+ if (exitCode !== 0) {
276652
+ reject(new Error(`Exited with code ${exitCode}`));
276653
+ return;
276654
+ }
276655
+ subprocess.unref();
276656
+ resolve(subprocess);
276657
+ });
276658
+ });
276659
+ });
276660
+ }
276661
+ subprocess.unref();
276662
+ return new Promise((resolve, reject) => {
276663
+ subprocess.once("error", reject);
276664
+ subprocess.once("spawn", () => {
276665
+ subprocess.off("error", reject);
276666
+ resolve(subprocess);
276667
+ });
276668
+ });
276669
+ };
276670
+ var open = (target, options) => {
276671
+ if (typeof target !== "string") {
276672
+ throw new TypeError("Expected a `target`");
276673
+ }
276674
+ return baseOpen({
276675
+ ...options,
276676
+ target
276677
+ });
276678
+ };
276679
+ function detectArchBinary(binary) {
276680
+ if (typeof binary === "string" || Array.isArray(binary)) {
276681
+ return binary;
276682
+ }
276683
+ const { [arch]: archBinary } = binary;
276684
+ if (!archBinary) {
276685
+ throw new Error(`${arch} is not supported`);
276686
+ }
276687
+ return archBinary;
276688
+ }
276689
+ function detectPlatformBinary({ [platform7]: platformBinary }, { wsl } = {}) {
276690
+ if (wsl && is_wsl_default) {
276691
+ return detectArchBinary(wsl);
276692
+ }
276693
+ if (!platformBinary) {
276694
+ throw new Error(`${platform7} is not supported`);
276695
+ }
276696
+ return detectArchBinary(platformBinary);
276697
+ }
276698
+ var apps = {
276699
+ browser: "browser",
276700
+ browserPrivate: "browserPrivate"
276701
+ };
276702
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
276703
+ darwin: "google chrome",
276704
+ win32: "chrome",
276705
+ linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
276706
+ }, {
276707
+ wsl: {
276708
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
276709
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
276710
+ }
276711
+ }));
276712
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
276713
+ darwin: "brave browser",
276714
+ win32: "brave",
276715
+ linux: ["brave-browser", "brave"]
276716
+ }, {
276717
+ wsl: {
276718
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
276719
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
276720
+ }
276721
+ }));
276722
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
276723
+ darwin: "firefox",
276724
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
276725
+ linux: "firefox"
276726
+ }, {
276727
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
276728
+ }));
276729
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
276730
+ darwin: "microsoft edge",
276731
+ win32: "msedge",
276732
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
276733
+ }, {
276734
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
276735
+ }));
276736
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
276737
+ darwin: "Safari"
276738
+ }));
276739
+ var open_default = open;
276740
+
276741
+ // src/cli/commands/code/session.tsx
276742
+ var import_react23 = __toESM(require_react(), 1);
276743
+
276744
+ // src/cli/commands/code/logo.ts
276745
+ var ROWS = 6;
276746
+ var ASPECT = 0.44;
276747
+ var SAMPLES = 4;
276748
+ var FILL = 0.6;
276749
+ var GAP_ROW = 3.5 + 0.5;
276750
+ var GAP_HEIGHT_ROWS = 0.8;
276751
+ var LOGO_COLS = Math.max(2, Math.floor(ROWS / ASPECT + 0.5));
276752
+ var OCTANT = {
276753
+ rx: 2,
276754
+ ry: 4,
276755
+ table: Array.from(" \uD83E\uDF82\uD833\uDD00▘\uD833\uDD01\uD833\uDD02\uD833\uDD03\uD833\uDD04▝\uD833\uDD05\uD833\uDD06\uD833\uDD07\uD833\uDD08▀\uD833\uDD09\uD833\uDD0A\uD833\uDD0B\uD833\uDD0C\uD833\uDD00\uD833\uDD0D\uD833\uDD0E\uD833\uDD0F\uD833\uDD10\uD833\uDD11\uD833\uDD12\uD833\uDD13\uD833\uDD14\uD833\uDD15\uD833\uDD16\uD833\uDD17\uD833\uDD18\uD833\uDD19\uD833\uDD1A\uD833\uDD1B\uD833\uDD1C\uD833\uDD1D\uD833\uDD1E\uD833\uDD1F\uD833\uDD03\uD833\uDD20\uD833\uDD21\uD833\uDD22\uD833\uDD23\uD833\uDD24\uD833\uDD25\uD833\uDD26\uD833\uDD27\uD833\uDD28\uD833\uDD29\uD833\uDD2A\uD833\uDD2B\uD833\uDD2C\uD833\uDD2D\uD833\uDD2E\uD833\uDD2F\uD833\uDD30\uD833\uDD31\uD833\uDD32\uD833\uDD33\uD833\uDD34\uD833\uDD35\uD83E\uDF85 \uD833\uDD36\uD833\uDD37\uD833\uDD38\uD833\uDD39\uD833\uDD3A\uD833\uDD3B\uD833\uDD3C\uD833\uDD3D\uD833\uDD3E\uD833\uDD3F\uD833\uDD40\uD833\uDD41\uD833\uDD42\uD833\uDD43\uD833\uDD44▖\uD833\uDD45\uD833\uDD46\uD833\uDD47\uD833\uDD48▌\uD833\uDD49\uD833\uDD4A\uD833\uDD4B\uD833\uDD4C▞\uD833\uDD4D\uD833\uDD4E\uD833\uDD4F\uD833\uDD50▛\uD833\uDD51\uD833\uDD52\uD833\uDD53\uD833\uDD54\uD833\uDD55\uD833\uDD56\uD833\uDD57\uD833\uDD58\uD833\uDD59\uD833\uDD5A\uD833\uDD5B\uD833\uDD5C\uD833\uDD5D\uD833\uDD5E\uD833\uDD5F\uD833\uDD60\uD833\uDD61\uD833\uDD62\uD833\uDD63\uD833\uDD64\uD833\uDD65\uD833\uDD66\uD833\uDD67\uD833\uDD68\uD833\uDD69\uD833\uDD6A\uD833\uDD6B\uD833\uDD6C\uD833\uDD6D\uD833\uDD6E\uD833\uDD6F\uD833\uDD70 \uD833\uDD71\uD833\uDD72\uD833\uDD73\uD833\uDD74\uD833\uDD75\uD833\uDD76\uD833\uDD77\uD833\uDD78\uD833\uDD79\uD833\uDD7A\uD833\uDD7B\uD833\uDD7C\uD833\uDD7D\uD833\uDD7E\uD833\uDD7F\uD833\uDD80\uD833\uDD81\uD833\uDD82\uD833\uDD83\uD833\uDD84\uD833\uDD85\uD833\uDD86\uD833\uDD87\uD833\uDD88\uD833\uDD89\uD833\uDD8A\uD833\uDD8B\uD833\uDD8C\uD833\uDD8D\uD833\uDD8E\uD833\uDD8F▗\uD833\uDD90\uD833\uDD91\uD833\uDD92\uD833\uDD93▚\uD833\uDD94\uD833\uDD95\uD833\uDD96\uD833\uDD97▐\uD833\uDD98\uD833\uDD99\uD833\uDD9A\uD833\uDD9B▜\uD833\uDD9C\uD833\uDD9D\uD833\uDD9E\uD833\uDD9F\uD833\uDDA0\uD833\uDDA1\uD833\uDDA2\uD833\uDDA3\uD833\uDDA4\uD833\uDDA5\uD833\uDDA6\uD833\uDDA7\uD833\uDDA8\uD833\uDDA9\uD833\uDDAA\uD833\uDDAB▂\uD833\uDDAC\uD833\uDDAD\uD833\uDDAE\uD833\uDDAF\uD833\uDDB0\uD833\uDDB1\uD833\uDDB2\uD833\uDDB3\uD833\uDDB4\uD833\uDDB5\uD833\uDDB6\uD833\uDDB7\uD833\uDDB8\uD833\uDDB9\uD833\uDDBA\uD833\uDDBB\uD833\uDDBC\uD833\uDDBD\uD833\uDDBE\uD833\uDDBF\uD833\uDDC0\uD833\uDDC1\uD833\uDDC2\uD833\uDDC3\uD833\uDDC4\uD833\uDDC5\uD833\uDDC6\uD833\uDDC7\uD833\uDDC8\uD833\uDDC9\uD833\uDDCA\uD833\uDDCB\uD833\uDDCC\uD833\uDDCD\uD833\uDDCE\uD833\uDDCF\uD833\uDDD0\uD833\uDDD1\uD833\uDDD2\uD833\uDDD3\uD833\uDDD4\uD833\uDDD5\uD833\uDDD6\uD833\uDDD7\uD833\uDDD8\uD833\uDDD9\uD833\uDDDA▄\uD833\uDDDB\uD833\uDDDC\uD833\uDDDD\uD833\uDDDE▙\uD833\uDDDF\uD833\uDDE0\uD833\uDDE1\uD833\uDDE2▟\uD833\uDDE3▆\uD833\uDDE4\uD833\uDDE5█")
276756
+ };
276757
+ var QUAD = {
276758
+ rx: 2,
276759
+ ry: 2,
276760
+ table: Array.from(" ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█")
276761
+ };
276762
+ function detectTier(env = process.env) {
276763
+ const term = env.TERM ?? "";
276764
+ const prog = env.TERM_PROGRAM ?? "";
276765
+ if (prog === "ghostty" || term.includes("ghostty"))
276766
+ return "octant";
276767
+ if (env.KITTY_WINDOW_ID || term.includes("kitty"))
276768
+ return "octant";
276769
+ if (env.WEZTERM_PANE || env.WEZTERM_EXECUTABLE)
276770
+ return "octant";
276771
+ if (term.startsWith("foot") || prog === "contour")
276772
+ return "octant";
276773
+ return "quad";
276774
+ }
276775
+ function coverageGrid(rows, cols, aspect, pixelH) {
276776
+ const worldH = rows * pixelH;
276777
+ const worldW = cols * aspect;
276778
+ const radius = Math.min(worldH, worldW) / 2;
276779
+ const cx = worldW / 2;
276780
+ const cy = worldH / 2;
276781
+ const step = 1 / SAMPLES;
276782
+ const grid = [];
276783
+ for (let py = 0;py < rows; py++) {
276784
+ const y0 = py * pixelH;
276785
+ const y1 = y0 + pixelH;
276786
+ const dyLo = y0 <= cy && cy <= y1 ? 0 : Math.min(Math.abs(y0 - cy), Math.abs(y1 - cy));
276787
+ const dyHi = Math.max(Math.abs(y0 - cy), Math.abs(y1 - cy));
276788
+ const line = [];
276789
+ for (let px = 0;px < cols; px++) {
276790
+ const x0 = px * aspect;
276791
+ const x1 = x0 + aspect;
276792
+ const dxLo = x0 <= cx && cx <= x1 ? 0 : Math.min(Math.abs(x0 - cx), Math.abs(x1 - cx));
276793
+ const dxHi = Math.max(Math.abs(x0 - cx), Math.abs(x1 - cx));
276794
+ if (Math.hypot(dxLo, dyLo) >= radius) {
276795
+ line.push(0);
276796
+ continue;
276797
+ }
276798
+ if (Math.hypot(dxHi, dyHi) <= radius) {
276799
+ line.push(1);
276800
+ continue;
276801
+ }
276802
+ let hits = 0;
276803
+ for (let j = 0;j < SAMPLES; j++) {
276804
+ const dy = y0 + (j + 0.5) * step * pixelH - cy;
276805
+ for (let i = 0;i < SAMPLES; i++) {
276806
+ const dx = x0 + (i + 0.5) * step * aspect - cx;
276807
+ if (Math.hypot(dx, dy) <= radius)
276808
+ hits++;
276809
+ }
276810
+ }
276811
+ line.push(hits / (SAMPLES * SAMPLES));
277118
276812
  }
277119
- if (key.escape) {
277120
- if (engine.turnRunning())
277121
- engine.stopTurn();
276813
+ grid.push(line);
276814
+ }
276815
+ return grid;
276816
+ }
276817
+ function carveGap(grid, ry) {
276818
+ const n = grid.length;
276819
+ const thick = Math.max(1, Math.round(GAP_HEIGHT_ROWS * ry));
276820
+ const centre = GAP_ROW >= 0 ? GAP_ROW * ry : n + GAP_ROW * ry;
276821
+ const start = Math.max(0, Math.min(n - thick, centre - thick / 2));
276822
+ for (let i = Math.trunc(start);i < Math.trunc(start + thick); i++) {
276823
+ grid[i].fill(0);
276824
+ }
276825
+ }
276826
+ function logoRows(color, tier = detectTier()) {
276827
+ const { rx, ry, table } = tier === "octant" ? OCTANT : QUAD;
276828
+ const grid = coverageGrid(ROWS * ry, LOGO_COLS * rx, ASPECT / rx, 1 / ry);
276829
+ carveGap(grid, ry);
276830
+ const fg = color ? source_default.hex(color) : (s) => s;
276831
+ const bg = color ? source_default.bgHex(color) : (s) => s;
276832
+ const full = (1 << rx * ry) - 1;
276833
+ const out = [];
276834
+ for (let r = 0;r < ROWS; r++) {
276835
+ let row = "";
276836
+ for (let c = 0;c < LOGO_COLS; c++) {
276837
+ let mask = 0;
276838
+ for (let sr = 0;sr < ry; sr++) {
276839
+ for (let sc = 0;sc < rx; sc++) {
276840
+ if (grid[r * ry + sr][c * rx + sc] >= FILL)
276841
+ mask |= 1 << sr * rx + sc;
276842
+ }
276843
+ }
276844
+ const glyph = table[mask];
276845
+ if (glyph === " ")
276846
+ row += " ";
276847
+ else if (mask === full && color)
276848
+ row += bg(" ");
277122
276849
  else
277123
- setScroll(0);
276850
+ row += fg(glyph);
277124
276851
  }
277125
- });
277126
- const columns = process.stdout.columns || 80;
277127
- const rows = process.stdout.rows || 24;
277128
- const width = columns;
277129
- const innerWidth = Math.max(10, width - 4);
277130
- const inputRows = Math.max(1, Math.ceil((input.length + 3) / innerWidth));
277131
- const pickerOpen = pickerIndex !== null;
277132
- const cardOpen = card !== null && !card.typing;
277133
- const cardRows = card ? cardLines(card).length : 0;
277134
- const inputBlockHeight = pickerOpen ? MODELS.length + 3 : cardOpen ? cardRows + 2 : inputRows + 2 + (card?.typing ? 1 : 0);
277135
- const widgetHeight = inputBlockHeight + 3 + (footer.length ? 1 : 0);
277136
- const viewHeight = Math.max(3, rows - widgetHeight - 1);
277137
- const lines = items.flatMap((item) => hardWrapAnsi(`${renderEntry(item, { verbose, foldHint: "Ctrl+O to expand" })}
277138
- `, columns));
277139
- const maxScroll = Math.max(0, lines.length - viewHeight);
277140
- maxScrollRef.current = maxScroll;
277141
- const clamped = Math.min(scroll, maxScroll);
277142
- const end = lines.length - clamped;
277143
- const visible = lines.slice(Math.max(0, end - viewHeight), end);
277144
- const scrollNote = clamped > 0 ? source_default.yellow(` ↑ ${clamped} lines — Esc for live`) : "";
277145
- const statusLine = hardWrapAnsi(`${statusText(engine.status(), musingSeed)}${scrollNote}`, Math.max(10, columns - 1))[0];
277146
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277147
- flexDirection: "column",
277148
- children: [
277149
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277150
- flexDirection: "column",
277151
- height: viewHeight,
277152
- children: visible.map((line, index) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277153
- wrap: "truncate-end",
277154
- children: line || " "
277155
- }, `${index}-${line.length}`, false, undefined, this))
277156
- }, undefined, false, undefined, this),
277157
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277158
- wrap: "truncate-end",
277159
- children: statusLine
277160
- }, undefined, false, undefined, this),
277161
- pickerOpen ? /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277162
- flexDirection: "column",
277163
- borderStyle: "round",
277164
- borderColor: "cyan",
277165
- paddingX: 1,
277166
- width,
277167
- children: [
277168
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277169
- children: [
277170
- source_default.bold("Pick a model"),
277171
- source_default.dim(" ↑↓ move · Enter select · Esc cancel")
277172
- ]
277173
- }, undefined, true, undefined, this),
277174
- MODELS.map((m, i) => {
277175
- const selected = i === pickerIndex;
277176
- const isCurrent = (m.id ?? null) === currentModel;
277177
- const label = `${selected ? "▸" : " "} ${isCurrent ? "●" : "○"} ${m.name}${m.note ? ` (${m.note})` : ""}`;
277178
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277179
- color: selected ? "cyan" : undefined,
277180
- wrap: "truncate-end",
277181
- children: selected ? label : source_default.dim(label)
277182
- }, m.name, false, undefined, this);
277183
- })
277184
- ]
277185
- }, undefined, true, undefined, this) : cardOpen && card ? /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277186
- flexDirection: "column",
277187
- borderStyle: "round",
277188
- borderColor: "yellow",
277189
- paddingX: 1,
277190
- width,
277191
- children: cardLines(card).map((line, i) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277192
- wrap: "truncate-end",
277193
- children: line
277194
- }, i, false, undefined, this))
277195
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277196
- flexDirection: "column",
277197
- borderStyle: "round",
277198
- borderColor: card?.typing ? "yellow" : "gray",
277199
- paddingX: 1,
277200
- width,
277201
- children: [
277202
- card?.typing === "secret" && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277203
- wrap: "truncate-end",
277204
- children: [
277205
- source_default.bold(card.pending.secrets?.[card.step]?.name ?? "secret"),
277206
- source_default.dim(" — value is hidden · Enter to save · Esc to cancel")
277207
- ]
277208
- }, undefined, true, undefined, this),
277209
- card?.typing === "custom" && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277210
- wrap: "truncate-end",
277211
- children: [
277212
- source_default.bold(card.pending.questions?.[card.step]?.question ?? ""),
277213
- source_default.dim(" — your own answer · Enter to save · Esc to go back")
277214
- ]
277215
- }, undefined, true, undefined, this),
277216
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277217
- children: [
277218
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277219
- color: "cyan",
277220
- children: "❯ "
277221
- }, undefined, false, undefined, this),
277222
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(build_default, {
277223
- value: input,
277224
- onChange: setInput,
277225
- mask: card?.typing === "secret" ? "•" : undefined,
277226
- onSubmit: (value) => {
277227
- if (card?.typing) {
277228
- applyCard(cardText(card, value));
277229
- setInput("");
277230
- return;
277231
- }
277232
- const trimmed = value.trim();
277233
- if (trimmed === "/model" || trimmed.startsWith("/model ")) {
277234
- runModelSlash(trimmed.slice("/model".length).trim());
277235
- } else if (trimmed) {
277236
- engine.submit(value);
277237
- }
277238
- setInput("");
277239
- }
277240
- }, undefined, false, undefined, this)
277241
- ]
277242
- }, undefined, true, undefined, this)
277243
- ]
277244
- }, undefined, true, undefined, this),
277245
- footer.length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277246
- wrap: "truncate-end",
277247
- children: ` ${footer.join(source_default.dim(" · "))}`
277248
- }, undefined, false, undefined, this),
277249
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277250
- wrap: "truncate-end",
277251
- children: ` ${source_default.dim("model")} ${source_default.hex(BRAND_ORANGE)(displayName(currentModel))}`
277252
- }, undefined, false, undefined, this),
277253
- /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277254
- dimColor: true,
277255
- wrap: "truncate-end",
277256
- children: pickerOpen ? " ↑↓ to move · Enter to select · Esc to cancel" : cardOpen ? " the agent is waiting on you · answer above, or Esc for later" : pending.length > 0 && !card ? ` ⏸ ${pending[0].title} — Tab to answer · Ctrl+C to exit` : engine.turnRunning() ? " Esc to stop · type to queue · scroll to read · Ctrl+O to expand · Ctrl+C to exit" : " Enter to send · /model to switch model · Esc for live · Ctrl+O to expand · Ctrl+C to exit"
277257
- }, undefined, false, undefined, this)
277258
- ]
277259
- }, undefined, true, undefined, this);
276852
+ out.push(row);
276853
+ }
276854
+ return out;
277260
276855
  }
277261
- function renderHeader(who, mode) {
277262
- const orange = source_default.hex(BRAND_ORANGE);
277263
- const cwd = process.cwd().replace(process.env.HOME ?? "", "~");
277264
- const logo = logoRows(BRAND_ORANGE);
277265
- const logoW = LOGO_COLS;
277266
- const text = [
277267
- `${orange.bold("Base44 Code")} ${source_default.dim(`v${package_default.version}`)}`,
277268
- source_default.bold(who ? `Welcome back, ${who}!` : "Welcome!"),
277269
- source_default.dim(getBase44ApiUrl().replace(/^https:\/\//, "")),
277270
- source_default.dim(cwd),
277271
- ...mode ? [`${orange("●")} ${source_default.dim(mode)}`] : []
277272
- ];
277273
- const height = Math.max(logo.length, text.length);
277274
- const textTop = Math.max(0, Math.floor((logo.length - text.length) / 2));
277275
- const out = [];
277276
- for (let i = 0;i < height; i++) {
277277
- const left = i < logo.length ? logo[i] : " ".repeat(logoW);
277278
- const right = text[i - textTop] ?? "";
277279
- out.push(` ${left} ${right}`.trimEnd());
276856
+
276857
+ // src/cli/commands/code/paste.ts
276858
+ import { PassThrough as PassThrough3 } from "node:stream";
276859
+ var START = "\x1B[200~";
276860
+ var END = "\x1B[201~";
276861
+ function partialSuffix(s, marker) {
276862
+ for (let n = Math.min(marker.length - 1, s.length);n > 0; n--) {
276863
+ if (marker.startsWith(s.slice(-n)))
276864
+ return s.slice(-n);
277280
276865
  }
277281
- return out.join(`
277282
- `);
276866
+ return "";
277283
276867
  }
277284
- async function currentUserName() {
276868
+ function makePasteSanitizer() {
276869
+ let inPaste = false;
276870
+ let carry = "";
276871
+ const clean = (t) => t.replace(/\r\n|\r|\n/g, " ").replace(/\t/g, " ");
276872
+ return (chunk) => {
276873
+ let s = carry + chunk;
276874
+ carry = "";
276875
+ let out = "";
276876
+ while (s.length > 0) {
276877
+ if (!inPaste) {
276878
+ const i = s.indexOf(START);
276879
+ if (i === -1) {
276880
+ const tail = partialSuffix(s, START);
276881
+ out += s.slice(0, s.length - tail.length);
276882
+ carry = tail;
276883
+ s = "";
276884
+ } else {
276885
+ out += s.slice(0, i);
276886
+ s = s.slice(i + START.length);
276887
+ inPaste = true;
276888
+ }
276889
+ } else {
276890
+ const j = s.indexOf(END);
276891
+ if (j === -1) {
276892
+ const tail = partialSuffix(s, END);
276893
+ out += clean(s.slice(0, s.length - tail.length));
276894
+ carry = tail;
276895
+ s = "";
276896
+ } else {
276897
+ out += clean(s.slice(0, j));
276898
+ s = s.slice(j + END.length);
276899
+ inPaste = false;
276900
+ }
276901
+ }
276902
+ }
276903
+ return out;
276904
+ };
276905
+ }
276906
+ function createPasteFriendlyStdin(real) {
276907
+ const out = new PassThrough3;
276908
+ const sanitize = makePasteSanitizer();
276909
+ const onData = (buf) => {
276910
+ const text = sanitize(buf.toString("utf8"));
276911
+ if (text)
276912
+ out.write(text);
276913
+ };
276914
+ real.on("data", onData);
276915
+ const proxy = out;
276916
+ proxy.isTTY = true;
276917
+ proxy.setRawMode = (mode) => {
276918
+ real.setRawMode?.(mode);
276919
+ return proxy;
276920
+ };
276921
+ proxy.ref = () => real.ref?.();
276922
+ proxy.unref = () => real.unref?.();
276923
+ proxy.cleanup = () => {
276924
+ real.off("data", onData);
276925
+ real.pause();
276926
+ };
276927
+ return proxy;
276928
+ }
276929
+
276930
+ // src/core/resources/apps/pending.ts
276931
+ var CHOICE_TOOLS = new Set([
276932
+ "ask_clarifying_questions",
276933
+ "ask_plan_questions"
276934
+ ]);
276935
+ var SECRET_TOOLS = new Set(["set_secrets"]);
276936
+ var LIST_CHOICE_TOOLS = {
276937
+ select_payment_provider: {
276938
+ key: "providers",
276939
+ question: "Which payment provider?",
276940
+ answer: "provider"
276941
+ }
276942
+ };
276943
+ var PERMISSION_TOOLS = new Set(["request_agent_tool_permissions"]);
276944
+ var BROWSER_TOOLS = new Set([
276945
+ "connect_github_account",
276946
+ "request_oauth_authorization",
276947
+ "register_workspace_connector",
276948
+ "configure_psp_credentials",
276949
+ "plaid_connect"
276950
+ ]);
276951
+ var str2 = (v) => typeof v === "string" && v.trim() ? v.trim() : undefined;
276952
+ function parseArgs(raw) {
277285
276953
  try {
277286
- const auth = await readAuth();
277287
- return auth.name || auth.email || "";
276954
+ const parsed = JSON.parse(raw ?? "");
276955
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
277288
276956
  } catch {
277289
- return "";
276957
+ return {};
277290
276958
  }
277291
276959
  }
277292
- async function buildHeader(mode) {
277293
- return renderHeader(await currentUserName(), mode);
276960
+ function questionsFrom(args) {
276961
+ const raw = Array.isArray(args.questions) ? args.questions : [];
276962
+ return raw.flatMap((q) => {
276963
+ if (!q || typeof q !== "object")
276964
+ return [];
276965
+ const item = q;
276966
+ const question = str2(item.question);
276967
+ if (!question)
276968
+ return [];
276969
+ const options = (Array.isArray(item.options) ? item.options : []).flatMap((o) => {
276970
+ const opt = o;
276971
+ const label = str2(opt?.label);
276972
+ return label ? [{ label, description: str2(opt.description) }] : [];
276973
+ });
276974
+ return [
276975
+ {
276976
+ question,
276977
+ description: str2(item.description),
276978
+ options,
276979
+ multiSelect: item.multi_select === true
276980
+ }
276981
+ ];
276982
+ });
277294
276983
  }
277295
- async function runInteractiveSession(options) {
277296
- const sessionStartedAt = Date.now();
277297
- const listeners = new Set;
277298
- const buffered = [];
277299
- const onLine = (line) => {
277300
- if (listeners.size === 0) {
277301
- buffered.push(line);
277302
- return;
277303
- }
277304
- for (const listener of listeners)
277305
- listener(line);
277306
- };
277307
- const subscribe = (listener) => {
277308
- listeners.add(listener);
277309
- if (buffered.length) {
277310
- for (const line of buffered.splice(0))
277311
- listener(line);
277312
- }
277313
- return () => listeners.delete(listener);
277314
- };
277315
- const engine = createSessionEngine({
277316
- branchId: options.branchId,
277317
- awaitingTurnLabel: options.awaitingTurnLabel,
277318
- idleHint: options.idleHint,
277319
- onLine,
277320
- onTurnSettled: options.onTurnSettled
276984
+ function secretsFrom(args) {
276985
+ const raw = Array.isArray(args.secrets_schema) ? args.secrets_schema : [];
276986
+ return raw.flatMap((s) => {
276987
+ const item = s;
276988
+ const name = str2(item?.secretName) ?? str2(item?.name);
276989
+ return name ? [{ name, description: str2(item.description) }] : [];
277321
276990
  });
277322
- enterAltScreen();
277323
- onLine(await buildHeader());
277324
- process.stdout.write("\x1B[?2004h");
277325
- const stdinProxy = createPasteFriendlyStdin(process.stdin);
277326
- const app = render_default(/* @__PURE__ */ jsx_dev_runtime.jsxDEV(SessionView, {
277327
- engine,
277328
- footer: options.footer,
277329
- subscribe
277330
- }, undefined, false, undefined, this), { exitOnCtrlC: false, stdin: stdinProxy });
277331
- try {
277332
- await engine.start(options.primeFirstPoll);
277333
- if (options.initialMessage)
277334
- engine.submit(options.initialMessage);
277335
- await app.waitUntilExit();
277336
- } finally {
277337
- process.stdout.write("\x1B[?2004l");
277338
- stdinProxy.cleanup();
277339
- engine.stop();
277340
- exitAltScreen();
277341
- if (options.footer.length) {
277342
- process.stdout.write(`${options.footer.join(source_default.dim(" · "))}
277343
- `);
277344
- }
277345
- const note = engine.turnRunning() ? " — the running turn continues server-side (watch it in the editor)" : "";
277346
- process.stdout.write(`${source_default.dim(`session ended · ${formatDuration2(Date.now() - sessionStartedAt)}${note}`)}
277347
- `);
276991
+ }
276992
+ function permissionKey(row) {
276993
+ switch (row.type) {
276994
+ case "entity":
276995
+ return row.entity_name ? `entity:${row.entity_name}` : null;
276996
+ case "backend_function":
276997
+ return row.function_name ? `backend_function:${row.function_name}` : null;
276998
+ case "app_user_connector":
276999
+ return row.connector_id ? `app_user_connector:${row.connector_id}` : null;
277000
+ default:
277001
+ return null;
277348
277002
  }
277349
277003
  }
277350
- async function runGenesisSession(options) {
277351
- const sessionStartedAt = Date.now();
277352
- const listeners = new Set;
277353
- const buffered = [];
277354
- const onLine = (line) => {
277355
- if (listeners.size === 0) {
277356
- buffered.push(line);
277357
- return;
277358
- }
277359
- for (const listener of listeners)
277360
- listener(line);
277361
- };
277362
- const subscribe = (listener) => {
277363
- listeners.add(listener);
277364
- if (buffered.length) {
277365
- for (const line of buffered.splice(0))
277366
- listener(line);
277004
+ function permissionsFrom(args) {
277005
+ const raw = Array.isArray(args.requested_permissions) ? args.requested_permissions : [];
277006
+ return raw.flatMap((r) => {
277007
+ const row = r;
277008
+ const key = permissionKey(row);
277009
+ if (!key)
277010
+ return [];
277011
+ const ops = Array.isArray(row.allowed_operations) ? ` (${row.allowed_operations.join(", ")})` : "";
277012
+ const target = str2(row.entity_name) ?? str2(row.function_name) ?? str2(row.connector_name) ?? key;
277013
+ return [
277014
+ { key, label: `${row.type}: ${target}${ops}`, reason: str2(row.reason) }
277015
+ ];
277016
+ });
277017
+ }
277018
+ function guardFrom(results) {
277019
+ const value = typeof results === "string" ? (() => {
277020
+ try {
277021
+ return JSON.parse(results);
277022
+ } catch {
277023
+ return null;
277367
277024
  }
277368
- return () => listeners.delete(listener);
277369
- };
277370
- let inner = null;
277371
- let creating = false;
277372
- let creatingSince = 0;
277373
- const IDLE_STATUS = {
277374
- phase: "idle",
277375
- idleHint: options.idleHint,
277376
- awaitingSince: 0,
277377
- turnStartedAt: null,
277378
- runningTool: null,
277379
- lastTurnMs: null,
277380
- lastTurnOk: true,
277381
- pending: [],
277382
- quietForMs: 0
277383
- };
277384
- const genesis = {
277385
- async start() {},
277386
- stop() {
277387
- inner?.stop();
277388
- },
277389
- stopTurn() {
277390
- inner?.stopTurn();
277391
- },
277392
- submit(text) {
277393
- if (inner) {
277394
- inner.submit(text);
277395
- return;
277396
- }
277397
- if (creating) {
277398
- onLine(source_default.dim("· hold on — still creating the app"));
277399
- return;
277400
- }
277401
- creating = true;
277402
- creatingSince = Date.now();
277403
- onLine(`${source_default.cyan("❯")} ${source_default.bold(text)}`);
277404
- options.createApp(text, onLine).then(async (config) => {
277405
- const engine = createSessionEngine({
277406
- branchId: config.branchId,
277407
- awaitingTurnLabel: config.awaitingTurnLabel,
277408
- onLine,
277409
- onTurnSettled: config.onTurnSettled
277025
+ })() : results;
277026
+ if (!value || typeof value !== "object")
277027
+ return null;
277028
+ const g = value;
277029
+ if (!str2(g.guard))
277030
+ return null;
277031
+ return { title: `${g.guard}: needs your approval`, detail: str2(g.reason) };
277032
+ }
277033
+ function humanize(tool) {
277034
+ return tool.replace(/_/g, " ");
277035
+ }
277036
+ function pendingInputs(messages) {
277037
+ const out = [];
277038
+ for (const message of messages) {
277039
+ for (const call of message.tool_calls ?? []) {
277040
+ if (call.status !== "waiting_for_user_input")
277041
+ continue;
277042
+ const args = parseArgs(call.arguments_string);
277043
+ const base = {
277044
+ toolCallId: call.id,
277045
+ messageId: message.id,
277046
+ tool: call.name
277047
+ };
277048
+ const summary = str2(args.summary);
277049
+ if (CHOICE_TOOLS.has(call.name)) {
277050
+ out.push({
277051
+ ...base,
277052
+ kind: "choice",
277053
+ title: summary ?? "The agent has a few questions",
277054
+ questions: questionsFrom(args)
277055
+ });
277056
+ } else if (SECRET_TOOLS.has(call.name)) {
277057
+ out.push({
277058
+ ...base,
277059
+ kind: "secrets",
277060
+ title: summary ?? "The agent needs secrets",
277061
+ secrets: secretsFrom(args)
277062
+ });
277063
+ } else if (PERMISSION_TOOLS.has(call.name)) {
277064
+ out.push({
277065
+ ...base,
277066
+ kind: "permissions",
277067
+ title: summary ?? "Grant the app's agent these permissions?",
277068
+ detail: str2(args.reason),
277069
+ permissions: permissionsFrom(args)
277070
+ });
277071
+ } else if (LIST_CHOICE_TOOLS[call.name]) {
277072
+ const spec = LIST_CHOICE_TOOLS[call.name];
277073
+ const raw = Array.isArray(args[spec.key]) ? args[spec.key] : [];
277074
+ const options = raw.flatMap((o) => {
277075
+ const label = typeof o === "string" ? o : str2(o?.label);
277076
+ return label ? [{ label }] : [];
277077
+ });
277078
+ out.push({
277079
+ ...base,
277080
+ kind: "choice",
277081
+ title: summary ?? spec.question,
277082
+ detail: str2(args.reason),
277083
+ questions: [{ question: spec.question, options, multiSelect: false }],
277084
+ answerKey: spec.answer
277085
+ });
277086
+ } else if (BROWSER_TOOLS.has(call.name)) {
277087
+ const integration = str2(args.integration_type);
277088
+ out.push({
277089
+ ...base,
277090
+ kind: "browser",
277091
+ title: summary ?? (call.name === "connect_github_account" ? "Connect your GitHub account" : integration ? `Authorize ${integration}` : humanize(call.name)),
277092
+ detail: str2(args.reason),
277093
+ browser: call.name === "connect_github_account" ? { flow: "github" } : {
277094
+ flow: "connector",
277095
+ integrationType: integration,
277096
+ connectorId: str2(args.connector_id),
277097
+ scopes: Array.isArray(args.scopes) ? args.scopes.filter((x) => typeof x === "string") : undefined,
277098
+ forceReconnect: args.force_reconnect === true
277099
+ }
277100
+ });
277101
+ } else if (call.waiting_on?.kind === "choice" || call.waiting_on?.kind === "input") {
277102
+ out.push({
277103
+ ...base,
277104
+ kind: "unknown",
277105
+ title: summary ?? humanize(call.name),
277106
+ detail: str2(args.reason)
277107
+ });
277108
+ } else {
277109
+ const guard = guardFrom(call.results);
277110
+ const integration = str2(args.integration_type);
277111
+ out.push({
277112
+ ...base,
277113
+ kind: "approval",
277114
+ title: guard?.title ?? (integration ? `Enable ${integration}?` : summary ?? `${humanize(call.name)}?`),
277115
+ detail: guard?.detail ?? (integration ? summary : undefined)
277410
277116
  });
277411
- await engine.start(false);
277412
- inner = engine;
277413
- }).catch(async (error) => {
277414
- creating = false;
277415
- const message = error instanceof Error ? error.message : String(error);
277416
- onLine(source_default.red(`✗ create failed: ${message}`));
277417
- if (isGithubUserTokenError(error)) {
277418
- const link = await startGithubReauth().catch(() => null);
277419
- onLine(source_default.yellow("GitHub authorization expired — reconnect, then try again:"));
277420
- onLine(link ? terminalLink("Reconnect GitHub", link) : "Open Base44 → GitHub settings to reconnect your account.");
277421
- }
277422
- });
277423
- },
277424
- status() {
277425
- if (inner)
277426
- return inner.status();
277427
- if (creating) {
277428
- return {
277429
- ...IDLE_STATUS,
277430
- phase: "awaiting",
277431
- awaitingLabel: options.creatingLabel,
277432
- awaitingSince: creatingSince
277433
- };
277434
277117
  }
277435
- return IDLE_STATUS;
277436
- },
277437
- answer(p, action, input) {
277438
- inner?.answer(p, action, input);
277439
- },
277440
- turnRunning() {
277441
- return inner?.turnRunning() ?? creating;
277442
- }
277443
- };
277444
- enterAltScreen();
277445
- onLine(await buildHeader(options.modeLabel));
277446
- process.stdout.write("\x1B[?2004h");
277447
- const stdinProxy = createPasteFriendlyStdin(process.stdin);
277448
- const app = render_default(/* @__PURE__ */ jsx_dev_runtime.jsxDEV(SessionView, {
277449
- engine: genesis,
277450
- footer: options.footer,
277451
- subscribe
277452
- }, undefined, false, undefined, this), { exitOnCtrlC: false, stdin: stdinProxy });
277453
- try {
277454
- await app.waitUntilExit();
277455
- } finally {
277456
- process.stdout.write("\x1B[?2004l");
277457
- stdinProxy.cleanup();
277458
- genesis.stop();
277459
- exitAltScreen();
277460
- if (options.footer.length) {
277461
- process.stdout.write(`${options.footer.join(source_default.dim(" · "))}
277462
- `);
277463
277118
  }
277464
- const note = genesis.turnRunning() ? " — the running turn continues server-side (watch it in the editor)" : "";
277465
- process.stdout.write(`${source_default.dim(`session ended · ${formatDuration2(Date.now() - sessionStartedAt)}${note}`)}
277466
- `);
277467
277119
  }
277120
+ return out;
277468
277121
  }
277469
-
277470
- // src/cli/commands/code/index.ts
277471
- var BRAND_ORANGE2 = "#E86B3C";
277472
- async function bootstrapApp(prompt, footer, emit, onCreated, importRepo, path, wixInstance) {
277473
- let app;
277474
- try {
277475
- app = await createAndLinkApp({ prompt, importRepo, path, wixInstance });
277476
- } catch (error) {
277477
- for (const line of await githubReauthLines(error) ?? [])
277478
- emit(line);
277479
- throw error;
277122
+ function choiceAnswers(questions, selections, answerKey) {
277123
+ if (answerKey) {
277124
+ const first = selections[0];
277125
+ return { [answerKey]: first?.labels[0] ?? first?.customText ?? "" };
277480
277126
  }
277481
- onCreated(app);
277482
- footer.push(source_default.dim(`dir ${app.here ? "./" : `./${app.dirName}`}`));
277483
- if (app.repoUrl)
277484
- footer.push(terminalLink("repo", app.repoUrl));
277485
- footer.push(terminalLink("editor", app.editorUrl));
277486
- emit(source_default.dim(app.here ? "linked ./ (this directory)" : `linked ./${app.dirName} (cd ${app.dirName} after the session)`));
277487
- const branchId = await resolveActiveBranchId().catch(() => {
277488
- return;
277127
+ const answers = questions.flatMap((q, index) => {
277128
+ const sel = selections[index];
277129
+ if (!sel || sel.labels.length === 0 && !sel.customText)
277130
+ return [];
277131
+ const answer = { question_index: index };
277132
+ if (q.multiSelect) {
277133
+ if (sel.labels.length)
277134
+ answer.selected_labels = sel.labels;
277135
+ } else if (sel.labels[0]) {
277136
+ answer.selected_label = sel.labels[0];
277137
+ }
277138
+ if (sel.customText)
277139
+ answer.custom_text = sel.customText;
277140
+ return [answer];
277489
277141
  });
277490
- let previewPushed = false;
277142
+ return { answers };
277143
+ }
277144
+
277145
+ // src/cli/commands/code/pending-card.ts
277146
+ function openCard(pending) {
277491
277147
  return {
277492
- branchId,
277493
- awaitingTurnLabel: "provisioning the sandbox and starting the build",
277494
- onTurnSettled: async ({
277495
- turnIndex,
277496
- ok
277497
- }) => {
277498
- if (turnIndex !== 0 || !ok || previewPushed)
277499
- return;
277500
- const url = await getPreviewUrl().catch(() => {
277501
- return;
277502
- });
277503
- if (url) {
277504
- previewPushed = true;
277505
- footer.push(terminalLink("preview", url));
277506
- }
277507
- }
277148
+ pending,
277149
+ step: 0,
277150
+ cursor: 0,
277151
+ selections: (pending.questions ?? []).map(() => ({ labels: [] })),
277152
+ granted: new Set((pending.permissions ?? []).map((p) => p.key)),
277153
+ typing: pending.kind === "secrets" ? "secret" : null,
277154
+ secretValues: {},
277155
+ ...pending.kind === "browser" ? { browser: { status: "idle" } } : {}
277508
277156
  };
277509
277157
  }
277510
- async function codeAction({ log }, options, appId) {
277511
- const orange = source_default.hex(BRAND_ORANGE2);
277512
- const chip = (label) => source_default.dim(`${orange("●")} ${label}`);
277513
- if (process.stdout.isTTY !== true) {
277514
- throw new InvalidInputError("base44 code is an interactive session and needs a terminal.");
277515
- }
277516
- let linked = false;
277517
- try {
277518
- await initAppContext(appId ? { appId } : {});
277519
- linked = true;
277520
- } catch {}
277521
- if (linked) {
277522
- if (options.import || options.path || options.wixInstance) {
277523
- throw new InvalidInputError("--import, --path and --wix-instance create a new app; run them outside a linked project, without --app-id.");
277524
- }
277525
- const { id, projectRoot } = getAppContext();
277526
- const state = await assertBuilderApp(id);
277527
- const branchId = await resolveActiveBranchId().catch(() => {
277528
- return;
277529
- });
277530
- await runInteractiveSession({
277531
- branchId,
277532
- footer: [chip(appTypeChip(state))],
277533
- primeFirstPoll: true,
277534
- idleHint: "what should the agent do next?"
277535
- });
277536
- if (projectRoot) {
277537
- log.message(source_default.dim(`app dir ${projectRoot}`));
277538
- return {
277539
- outroMessage: "Session closed. Run `base44 code` here to resume."
277540
- };
277541
- }
277158
+ var done = (action, input = {}) => ({ state: null, submit: { action, input } });
277159
+ var later = { state: null, dismissed: true };
277160
+ function choiceRows(state) {
277161
+ return (state.pending.questions?.[state.step]?.options.length ?? 0) + 1;
277162
+ }
277163
+ function advanceChoice(state) {
277164
+ const questions = state.pending.questions ?? [];
277165
+ if (state.step + 1 < questions.length) {
277542
277166
  return {
277543
- outroMessage: `Session closed. Resume with \`base44 code --app-id ${id}\`.`
277167
+ state: { ...state, step: state.step + 1, cursor: 0, typing: null }
277544
277168
  };
277545
277169
  }
277546
- if (options.wixInstance && options.import) {
277547
- throw new InvalidInputError("--wix-instance and --import are exclusive.");
277548
- }
277549
- const wixInstance = options.wixInstance?.trim() ? {
277550
- signedInstance: options.wixInstance.trim(),
277551
- wixClientId: options.wixClientId?.trim() || undefined
277552
- } : undefined;
277553
- let created;
277554
- const footer = [
277555
- chip(options.import ? repoLabel(options.import) : wixInstance ? "web app · wix" : "web app")
277556
- ];
277557
- await runGenesisSession({
277558
- idleHint: options.import ? "describe what to build over the repository" : "describe the app you want to build · have one already? base44 code --app-id <id>, or base44 link",
277559
- creatingLabel: options.import ? "importing the repository" : "creating your app",
277560
- modeLabel: options.import ? `Repository — ${repoLabel(options.import)}` : wixInstance ? "Web app — Wix launch (connector connected first)" : "Web app — Base44 template + builder agent",
277561
- footer,
277562
- createApp: (prompt, emit) => bootstrapApp(prompt, footer, emit, (app) => {
277563
- created = app;
277564
- }, options.import, options.path, wixInstance)
277565
- });
277566
- if (!created) {
277567
- return { outroMessage: "Session closed. No app was created." };
277568
- }
277569
- for (const line of nextStepsLines(created))
277570
- log.message(line);
277571
- log.message(source_default.dim(` editor ${created.editorUrl}`));
277572
- return { outroMessage: "Session closed." };
277573
- }
277574
- function getCodeCommand() {
277575
- const command = new Base44Command("code", { requireAppContext: false });
277576
- command.description("Open Base44 Code, an interactive builder session. In a linked directory (or with --app-id <id>) it opens that app; anywhere else your first prompt creates one (--import <repo> to build over your own repository). Attach a directory to an existing app with base44 link.").option("--import <repo>", "Build over an existing GitHub repository instead of the Base44 template").option("--path <dir>", "Directory to link the new app to (default: the current directory when empty, else ./<name>)").option("--wix-instance <token>", "Create the new app through the Wix route with this signed instance (your first prompt is what the agent runs)").option("--wix-client-id <id>", "The companion OAuth app's client id").action((ctx, options) => codeAction(ctx, options, command.optsWithGlobals().appId));
277577
- return command;
277578
- }
277579
-
277580
- // ../../node_modules/open/index.js
277581
- import process30 from "node:process";
277582
- import path16 from "node:path";
277583
- import { fileURLToPath as fileURLToPath4 } from "node:url";
277584
- import childProcess3 from "node:child_process";
277585
- import fs20, { constants as fsConstants2 } from "node:fs/promises";
277586
-
277587
- // ../../node_modules/wsl-utils/index.js
277588
- import { promisify as promisify6 } from "node:util";
277589
- import childProcess2 from "node:child_process";
277590
- import fs19, { constants as fsConstants } from "node:fs/promises";
277591
-
277592
- // ../../node_modules/is-wsl/index.js
277593
- import process24 from "node:process";
277594
- import os4 from "node:os";
277595
- import fs18 from "node:fs";
277596
-
277597
- // ../../node_modules/is-inside-container/index.js
277598
- import fs17 from "node:fs";
277599
-
277600
- // ../../node_modules/is-docker/index.js
277601
- import fs16 from "node:fs";
277602
- var isDockerCached;
277603
- function hasDockerEnv() {
277604
- try {
277605
- fs16.statSync("/.dockerenv");
277606
- return true;
277607
- } catch {
277608
- return false;
277609
- }
277610
- }
277611
- function hasDockerCGroup() {
277612
- try {
277613
- return fs16.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
277614
- } catch {
277615
- return false;
277616
- }
277170
+ return done("approved", choiceAnswers(questions, state.selections, state.pending.answerKey));
277617
277171
  }
277618
- function isDocker() {
277619
- if (isDockerCached === undefined) {
277620
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
277172
+ function choiceKey(state, key) {
277173
+ const question = state.pending.questions?.[state.step];
277174
+ if (!question)
277175
+ return done("approved", { answers: [] });
277176
+ const rows = choiceRows(state);
277177
+ const custom = state.cursor === rows - 1;
277178
+ const sel = state.selections[state.step] ?? { labels: [] };
277179
+ const setSel = (next) => {
277180
+ const selections = [...state.selections];
277181
+ selections[state.step] = next;
277182
+ return { ...state, selections };
277183
+ };
277184
+ switch (key) {
277185
+ case "up":
277186
+ return { state: { ...state, cursor: (state.cursor - 1 + rows) % rows } };
277187
+ case "down":
277188
+ return { state: { ...state, cursor: (state.cursor + 1) % rows } };
277189
+ case "space": {
277190
+ if (custom)
277191
+ return { state: { ...state, typing: "custom" } };
277192
+ const label = question.options[state.cursor].label;
277193
+ const labels = question.multiSelect ? sel.labels.includes(label) ? sel.labels.filter((l) => l !== label) : [...sel.labels, label] : [label];
277194
+ return { state: setSel({ ...sel, labels }) };
277195
+ }
277196
+ case "enter": {
277197
+ if (custom)
277198
+ return { state: { ...state, typing: "custom" } };
277199
+ if (question.multiSelect) {
277200
+ if (sel.labels.length === 0 && !sel.customText)
277201
+ return { state };
277202
+ return advanceChoice(state);
277203
+ }
277204
+ const label = question.options[state.cursor].label;
277205
+ return advanceChoice(setSel({ labels: [label] }));
277206
+ }
277207
+ case "s":
277208
+ return done("approved", { answers: [] });
277209
+ case "escape":
277210
+ return later;
277211
+ default:
277212
+ return { state };
277621
277213
  }
277622
- return isDockerCached;
277623
277214
  }
277624
-
277625
- // ../../node_modules/is-inside-container/index.js
277626
- var cachedResult;
277627
- var hasContainerEnv = () => {
277628
- try {
277629
- fs17.statSync("/run/.containerenv");
277630
- return true;
277631
- } catch {
277632
- return false;
277633
- }
277634
- };
277635
- function isInsideContainer() {
277636
- if (cachedResult === undefined) {
277637
- cachedResult = hasContainerEnv() || isDocker();
277215
+ function permissionsKey(state, key) {
277216
+ const rows = state.pending.permissions ?? [];
277217
+ switch (key) {
277218
+ case "up":
277219
+ return {
277220
+ state: {
277221
+ ...state,
277222
+ cursor: (state.cursor - 1 + rows.length) % rows.length
277223
+ }
277224
+ };
277225
+ case "down":
277226
+ return { state: { ...state, cursor: (state.cursor + 1) % rows.length } };
277227
+ case "space": {
277228
+ const k = rows[state.cursor]?.key;
277229
+ if (!k)
277230
+ return { state };
277231
+ const granted = new Set(state.granted);
277232
+ if (granted.has(k))
277233
+ granted.delete(k);
277234
+ else
277235
+ granted.add(k);
277236
+ return { state: { ...state, granted } };
277237
+ }
277238
+ case "enter":
277239
+ case "y":
277240
+ return done("approved", {
277241
+ approved_permission_keys: rows.map((r) => r.key).filter((k) => state.granted.has(k))
277242
+ });
277243
+ case "n":
277244
+ return done("rejected");
277245
+ case "escape":
277246
+ return later;
277247
+ default:
277248
+ return { state };
277638
277249
  }
277639
- return cachedResult;
277640
277250
  }
277641
-
277642
- // ../../node_modules/is-wsl/index.js
277643
- var isWsl = () => {
277644
- if (process24.platform !== "linux") {
277645
- return false;
277251
+ function cardKey(state, key) {
277252
+ if (state.typing) {
277253
+ if (key === "escape") {
277254
+ return state.typing === "secret" ? later : { state: { ...state, typing: null } };
277255
+ }
277256
+ return { state };
277646
277257
  }
277647
- if (os4.release().toLowerCase().includes("microsoft")) {
277648
- if (isInsideContainer()) {
277649
- return false;
277258
+ switch (state.pending.kind) {
277259
+ case "choice":
277260
+ return choiceKey(state, key);
277261
+ case "permissions":
277262
+ return permissionsKey(state, key);
277263
+ case "browser": {
277264
+ const status = state.browser?.status ?? "idle";
277265
+ if (key === "n")
277266
+ return done("rejected");
277267
+ if (key === "escape")
277268
+ return later;
277269
+ if (key === "y" || key === "enter") {
277270
+ if (status === "active")
277271
+ return done("approved");
277272
+ if (status !== "waiting") {
277273
+ return {
277274
+ state: {
277275
+ ...state,
277276
+ browser: { ...state.browser, status: "waiting" }
277277
+ },
277278
+ startBrowser: true
277279
+ };
277280
+ }
277281
+ }
277282
+ return { state };
277650
277283
  }
277651
- return true;
277284
+ case "unknown":
277285
+ if (key === "n")
277286
+ return done("rejected");
277287
+ if (key === "escape")
277288
+ return later;
277289
+ return { state };
277290
+ default:
277291
+ if (key === "y" || key === "enter")
277292
+ return done("approved");
277293
+ if (key === "n")
277294
+ return done("rejected");
277295
+ if (key === "escape")
277296
+ return later;
277297
+ return { state };
277652
277298
  }
277653
- try {
277654
- return fs18.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
277655
- } catch {
277656
- return false;
277299
+ }
277300
+ function browserUpdate(state, update) {
277301
+ return {
277302
+ ...state,
277303
+ browser: { url: update.url ?? state.browser?.url, status: update.status }
277304
+ };
277305
+ }
277306
+ function cardText(state, text) {
277307
+ const value = text.trim();
277308
+ if (state.typing === "custom") {
277309
+ if (!value)
277310
+ return { state: { ...state, typing: null } };
277311
+ const selections = [...state.selections];
277312
+ const current = selections[state.step] ?? { labels: [] };
277313
+ selections[state.step] = { ...current, customText: value };
277314
+ return advanceChoice({ ...state, selections, typing: null });
277657
277315
  }
277658
- };
277659
- var is_wsl_default = process24.env.__IS_WSL_TEST__ ? isWsl : isWsl();
277660
-
277661
- // ../../node_modules/powershell-utils/index.js
277662
- import process25 from "node:process";
277663
- import { Buffer as Buffer7 } from "node:buffer";
277664
- import { promisify as promisify5 } from "node:util";
277665
- import childProcess from "node:child_process";
277666
- var execFile = promisify5(childProcess.execFile);
277667
- var powerShellPath = () => `${process25.env.SYSTEMROOT || process25.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
277668
- var executePowerShell = async (command, options = {}) => {
277669
- const {
277670
- powerShellPath: psPath,
277671
- ...execFileOptions
277672
- } = options;
277673
- const encodedCommand = executePowerShell.encodeCommand(command);
277674
- return execFile(psPath ?? powerShellPath(), [
277675
- ...executePowerShell.argumentsPrefix,
277676
- encodedCommand
277677
- ], {
277678
- encoding: "utf8",
277679
- ...execFileOptions
277680
- });
277681
- };
277682
- executePowerShell.argumentsPrefix = [
277683
- "-NoProfile",
277684
- "-NonInteractive",
277685
- "-ExecutionPolicy",
277686
- "Bypass",
277687
- "-EncodedCommand"
277688
- ];
277689
- executePowerShell.encodeCommand = (command) => Buffer7.from(command, "utf16le").toString("base64");
277690
- executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
277691
-
277692
- // ../../node_modules/wsl-utils/utilities.js
277693
- function parseMountPointFromConfig(content) {
277694
- for (const line of content.split(`
277695
- `)) {
277696
- if (/^\s*#/.test(line)) {
277697
- continue;
277698
- }
277699
- const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
277700
- if (!match) {
277701
- continue;
277316
+ if (state.typing === "secret") {
277317
+ const fields = state.pending.secrets ?? [];
277318
+ const field = fields[state.step];
277319
+ if (!field || !value)
277320
+ return { state };
277321
+ const secretValues = { ...state.secretValues, [field.name]: value };
277322
+ if (state.step + 1 < fields.length) {
277323
+ return { state: { ...state, secretValues, step: state.step + 1 } };
277702
277324
  }
277703
- return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
277325
+ return done("approved", { secrets: secretValues });
277704
277326
  }
277327
+ return { state };
277705
277328
  }
277706
-
277707
- // ../../node_modules/wsl-utils/index.js
277708
- var execFile2 = promisify6(childProcess2.execFile);
277709
- var wslDrivesMountPoint = (() => {
277710
- const defaultMountPoint = "/mnt/";
277711
- let mountPoint;
277712
- return async function() {
277713
- if (mountPoint) {
277714
- return mountPoint;
277329
+ function cardLines(state) {
277330
+ const p = state.pending;
277331
+ const head = [source_default.bold(`⏸ ${p.title}`)];
277332
+ if (p.detail)
277333
+ head.push(source_default.dim(` ${p.detail}`));
277334
+ switch (p.kind) {
277335
+ case "choice": {
277336
+ const q = p.questions?.[state.step];
277337
+ if (!q)
277338
+ return [...head, source_default.dim(" (no questions) · Enter to continue")];
277339
+ const total = p.questions?.length ?? 1;
277340
+ const sel = state.selections[state.step] ?? { labels: [] };
277341
+ const rows = q.options.map((o, i) => {
277342
+ const on = sel.labels.includes(o.label);
277343
+ const mark = q.multiSelect ? on ? "☑" : "☐" : on ? "●" : "○";
277344
+ const text = `${state.cursor === i ? "▸" : " "} ${mark} ${o.label}${o.description ? source_default.dim(` — ${o.description}`) : ""}`;
277345
+ return state.cursor === i ? source_default.cyan(text) : text;
277346
+ });
277347
+ const customRow = `${state.cursor === q.options.length ? "▸" : " "} ✎ something else${sel.customText ? source_default.dim(` — ${sel.customText}`) : ""}`;
277348
+ rows.push(state.cursor === q.options.length ? source_default.cyan(customRow) : customRow);
277349
+ return [
277350
+ ...head,
277351
+ ` ${source_default.bold(q.question)} ${source_default.dim(`(${state.step + 1}/${total})`)}`,
277352
+ ...q.description ? [source_default.dim(` ${q.description}`)] : [],
277353
+ ...rows.map((r) => ` ${r}`),
277354
+ source_default.dim(q.multiSelect ? " ↑↓ move · space toggle · Enter next · s skip all · Esc later" : " ↑↓ move · Enter choose · s skip all · Esc later")
277355
+ ];
277715
277356
  }
277716
- const configFilePath = "/etc/wsl.conf";
277717
- let isConfigFileExists = false;
277718
- try {
277719
- await fs19.access(configFilePath, fsConstants.F_OK);
277720
- isConfigFileExists = true;
277721
- } catch {}
277722
- if (!isConfigFileExists) {
277723
- return defaultMountPoint;
277357
+ case "permissions": {
277358
+ const rows = (p.permissions ?? []).map((r, i) => {
277359
+ const text = `${state.cursor === i ? "▸" : " "} ${state.granted.has(r.key) ? "☑" : "☐"} ${r.label}${r.reason ? source_default.dim(` — ${r.reason}`) : ""}`;
277360
+ return ` ${state.cursor === i ? source_default.cyan(text) : text}`;
277361
+ });
277362
+ return [
277363
+ ...head,
277364
+ ...rows,
277365
+ source_default.dim(" space toggle · Enter grant ticked · n reject all · Esc later")
277366
+ ];
277367
+ }
277368
+ case "secrets": {
277369
+ const fields = p.secrets ?? [];
277370
+ const rows = fields.map((f, i) => {
277371
+ const filled = f.name in state.secretValues;
277372
+ const mark = filled ? source_default.green("✓") : i === state.step ? "▸" : "○";
277373
+ return ` ${mark} ${f.name}${f.description ? source_default.dim(` — ${f.description}`) : ""}`;
277374
+ });
277375
+ return [
277376
+ ...head,
277377
+ ...rows,
277378
+ source_default.dim(" type the value below (hidden) · Enter next · Esc later")
277379
+ ];
277724
277380
  }
277725
- const configContent = await fs19.readFile(configFilePath, { encoding: "utf8" });
277726
- const parsedMountPoint = parseMountPointFromConfig(configContent);
277727
- if (parsedMountPoint === undefined) {
277728
- return defaultMountPoint;
277381
+ case "browser": {
277382
+ const b = state.browser ?? { status: "idle" };
277383
+ const link = b.url ? [` ${source_default.cyan(b.url)}`] : [];
277384
+ switch (b.status) {
277385
+ case "waiting":
277386
+ return [
277387
+ ...head,
277388
+ source_default.dim(" opened in your browser — or use the link:"),
277389
+ ...link,
277390
+ source_default.dim(" waiting for the authorization to complete… · n reject · Esc later")
277391
+ ];
277392
+ case "active":
277393
+ return [
277394
+ ...head,
277395
+ source_default.green(" ✓ connected"),
277396
+ source_default.dim(" y continue · n reject")
277397
+ ];
277398
+ case "failed":
277399
+ return [
277400
+ ...head,
277401
+ source_default.red(" ✗ authorization failed"),
277402
+ source_default.dim(" y try again · n reject · Esc later")
277403
+ ];
277404
+ case "timeout":
277405
+ return [
277406
+ ...head,
277407
+ source_default.yellow(" ⏱ no response yet"),
277408
+ ...link,
277409
+ source_default.dim(" y try again · n reject · Esc later")
277410
+ ];
277411
+ default:
277412
+ return [
277413
+ ...head,
277414
+ source_default.dim(" y open the authorization link · n reject · Esc later")
277415
+ ];
277416
+ }
277729
277417
  }
277730
- mountPoint = parsedMountPoint;
277731
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
277732
- return mountPoint;
277418
+ case "unknown":
277419
+ return [
277420
+ ...head,
277421
+ source_default.yellow(" this question needs the editor — answer it there and the session continues"),
277422
+ source_default.dim(" n reject · Esc later")
277423
+ ];
277424
+ default:
277425
+ return [...head, source_default.dim(" y approve · n reject · Esc later")];
277426
+ }
277427
+ }
277428
+
277429
+ // src/cli/commands/code/session-engine.ts
277430
+ var POLL_MS = 1000;
277431
+ function createSessionEngine(options) {
277432
+ const running = new Map;
277433
+ const diffState = newStreamState();
277434
+ let stopped = false;
277435
+ let polling = false;
277436
+ let pollStartedAt = 0;
277437
+ let timer = null;
277438
+ let sendsInFlight = 0;
277439
+ let activeTurnId = null;
277440
+ let turnStartedAt = null;
277441
+ let pendingSubmitAt = null;
277442
+ let lastTurnMs = null;
277443
+ let lastTurnOk = true;
277444
+ let settledCount = 0;
277445
+ let awaitingTurn = options.awaitingTurnLabel ?? null;
277446
+ const awaitingSince = Date.now();
277447
+ let lastEventAt = Date.now();
277448
+ let pending = [];
277449
+ const answered = new Set;
277450
+ const answer = (p, action, input = {}) => {
277451
+ answered.add(p.toolCallId);
277452
+ pending = pending.filter((x) => x.toolCallId !== p.toolCallId);
277453
+ const verb = action === "rejected" ? source_default.red("✗ rejected") : Object.keys(input).length ? source_default.green("→ answered") : source_default.green("✓ approved");
277454
+ options.onLine(`${verb} ${source_default.dim("—")} ${p.title}`);
277455
+ pendingSubmitAt = Date.now();
277456
+ sendsInFlight++;
277457
+ answerToolCall({ toolCallId: p.toolCallId, messageId: p.messageId, action, input }, options.branchId).catch((error) => {
277458
+ const status = error instanceof ApiError ? error.statusCode : undefined;
277459
+ const edgeDrop = status === 502 || status === 503 || status === 504 || /timeout|gateway/i.test(error instanceof Error ? error.message : "");
277460
+ if (edgeDrop && (turnStartedAt != null || pendingSubmitAt == null)) {
277461
+ return;
277462
+ }
277463
+ answered.delete(p.toolCallId);
277464
+ pendingSubmitAt = null;
277465
+ options.onLine(source_default.red(`✗ answer failed: ${error instanceof Error ? error.message : String(error)}`));
277466
+ }).finally(() => {
277467
+ sendsInFlight--;
277468
+ });
277733
277469
  };
277734
- })();
277735
- var powerShellPathFromWsl = async () => {
277736
- const mountPoint = await wslDrivesMountPoint();
277737
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
277738
- };
277739
- var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
277740
- var canAccessPowerShellPromise;
277741
- var canAccessPowerShell = async () => {
277742
- canAccessPowerShellPromise ??= (async () => {
277470
+ const submit = (raw) => {
277471
+ const typed = raw.trim();
277472
+ if (!typed)
277473
+ return;
277474
+ const text = typed;
277475
+ options.onLine(`${source_default.cyan("❯")} ${source_default.bold(typed)}`);
277476
+ pendingSubmitAt = Date.now();
277477
+ const submitTurnId = activeTurnId;
277478
+ sendsInFlight++;
277479
+ sendTurn(text, options.branchId).then((turn) => {
277480
+ if (turn.queued) {
277481
+ options.onLine(source_default.dim("· queued — runs after the current turn"));
277482
+ }
277483
+ }).catch((error) => {
277484
+ const delivered = activeTurnId !== submitTurnId || turnStartedAt != null || pendingSubmitAt == null;
277485
+ const status = error instanceof ApiError ? error.statusCode : undefined;
277486
+ const edgeDrop = status === 502 || status === 503 || status === 504 || /timeout|gateway/i.test(error instanceof Error ? error.message : "");
277487
+ if (edgeDrop && delivered)
277488
+ return;
277489
+ pendingSubmitAt = null;
277490
+ const message = error instanceof Error ? error.message : String(error);
277491
+ options.onLine(source_default.red(`✗ send failed: ${message}`));
277492
+ }).finally(() => {
277493
+ sendsInFlight--;
277494
+ });
277495
+ };
277496
+ const poll = async (prime) => {
277497
+ const STUCK_POLL_MS = 45000;
277498
+ if (polling && Date.now() - pollStartedAt < STUCK_POLL_MS)
277499
+ return;
277500
+ polling = true;
277501
+ pollStartedAt = Date.now();
277743
277502
  try {
277744
- const psPath = await powerShellPath2();
277745
- await fs19.access(psPath, fsConstants.X_OK);
277746
- return true;
277747
- } catch {
277748
- return false;
277503
+ let messages;
277504
+ try {
277505
+ messages = await getFullConversation(30, options.branchId);
277506
+ } catch {
277507
+ return;
277508
+ }
277509
+ const events = diffConversation(diffState, messages);
277510
+ const waiting = pendingInputs(messages);
277511
+ for (const id of answered) {
277512
+ if (!waiting.some((w) => w.toolCallId === id))
277513
+ answered.delete(id);
277514
+ }
277515
+ pending = waiting.filter((w) => !answered.has(w.toolCallId));
277516
+ if (!prime) {
277517
+ for (const event of events) {
277518
+ if (event.kind === "tool_start") {
277519
+ const startedAt = Date.now();
277520
+ running.set(event.id, {
277521
+ alias: toolAlias(event.name),
277522
+ label: event.label,
277523
+ summary: event.summary,
277524
+ startedAt
277525
+ });
277526
+ options.onLine({ running: event, startedAt });
277527
+ continue;
277528
+ }
277529
+ if (event.kind === "tool_end") {
277530
+ const started = running.get(event.id)?.startedAt;
277531
+ running.delete(event.id);
277532
+ lastEventAt = Date.now();
277533
+ options.onLine({
277534
+ event,
277535
+ elapsedMs: started != null ? Date.now() - started : undefined
277536
+ });
277537
+ continue;
277538
+ }
277539
+ const line = eventLine(event, undefined, {
277540
+ waitingHint: "answer in the card below"
277541
+ });
277542
+ if (line != null) {
277543
+ lastEventAt = Date.now();
277544
+ options.onLine(line);
277545
+ }
277546
+ }
277547
+ }
277548
+ const turn = newestUserTurn(messages);
277549
+ if (!turn)
277550
+ return;
277551
+ const kickoffDetection = awaitingTurn != null && activeTurnId === null;
277552
+ awaitingTurn = null;
277553
+ if (turn.id !== activeTurnId) {
277554
+ activeTurnId = turn.id;
277555
+ if (!turn.settled) {
277556
+ turnStartedAt = pendingSubmitAt ?? (kickoffDetection ? awaitingSince : Date.now());
277557
+ pendingSubmitAt = null;
277558
+ running.clear();
277559
+ } else if (prime) {
277560
+ turnStartedAt = null;
277561
+ }
277562
+ }
277563
+ if (turn.settled && turnStartedAt != null && turn.id === activeTurnId) {
277564
+ const durationMs = Date.now() - turnStartedAt;
277565
+ turnStartedAt = null;
277566
+ running.clear();
277567
+ lastTurnMs = durationMs;
277568
+ const ok = !turn.backendStatus?.startsWith("error");
277569
+ lastTurnOk = ok;
277570
+ options.onLine(ok ? source_default.dim(`— turn finished · ${formatDuration2(durationMs)}`) : source_default.red(turn.backendStatus === "error_paywall" ? `— the workspace is out of credits; nothing ran · ${formatDuration2(durationMs)}` : `— turn failed (${turn.backendStatus ?? "unknown"}) · ${formatDuration2(durationMs)}`));
277571
+ const info = {
277572
+ turnIndex: settledCount++,
277573
+ ok,
277574
+ backendStatus: turn.backendStatus,
277575
+ durationMs
277576
+ };
277577
+ try {
277578
+ await options.onTurnSettled?.(info);
277579
+ } catch {}
277580
+ }
277581
+ } finally {
277582
+ polling = false;
277749
277583
  }
277750
- })();
277751
- return canAccessPowerShellPromise;
277752
- };
277753
- var wslDefaultBrowser = async () => {
277754
- const psPath = await powerShellPath2();
277755
- const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
277756
- const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
277757
- return stdout.trim();
277758
- };
277759
- var convertWslPathToWindows = async (path) => {
277760
- if (/^[a-z]+:\/\//i.test(path)) {
277761
- return path;
277762
- }
277763
- try {
277764
- const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
277765
- return stdout.trim();
277766
- } catch {
277767
- return path;
277768
- }
277769
- };
277770
-
277771
- // ../../node_modules/define-lazy-prop/index.js
277772
- function defineLazyProperty(object, propertyName, valueGetter) {
277773
- const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
277774
- Object.defineProperty(object, propertyName, {
277775
- configurable: true,
277776
- enumerable: true,
277777
- get() {
277778
- const result = valueGetter();
277779
- define2(result);
277780
- return result;
277584
+ };
277585
+ return {
277586
+ async start(primeFirstPoll) {
277587
+ await poll(primeFirstPoll);
277588
+ timer = setInterval(() => {
277589
+ if (!stopped)
277590
+ poll(false);
277591
+ }, POLL_MS);
277592
+ timer.unref?.();
277593
+ },
277594
+ stop() {
277595
+ stopped = true;
277596
+ if (timer)
277597
+ clearInterval(timer);
277598
+ },
277599
+ stopTurn() {
277600
+ if (turnStartedAt == null && sendsInFlight === 0 && pendingSubmitAt == null)
277601
+ return;
277602
+ options.onLine(source_default.dim("· stopping…"));
277603
+ stopTurn(options.branchId).catch((error) => {
277604
+ options.onLine(source_default.red(` stop failed: ${error instanceof Error ? error.message : String(error)}`));
277605
+ });
277606
+ },
277607
+ submit,
277608
+ answer,
277609
+ status() {
277610
+ let phase = "idle";
277611
+ if (awaitingTurn != null)
277612
+ phase = "awaiting";
277613
+ else if (turnStartedAt != null)
277614
+ phase = "running";
277615
+ else if (sendsInFlight > 0 || pendingSubmitAt != null)
277616
+ phase = "sending";
277617
+ let runningTool = null;
277618
+ if (running.size > 0) {
277619
+ const newest = [...running.values()].at(-1);
277620
+ runningTool = { ...newest, others: running.size - 1 };
277621
+ }
277622
+ return {
277623
+ phase,
277624
+ awaitingLabel: awaitingTurn ?? undefined,
277625
+ idleHint: options.idleHint,
277626
+ quietForMs: Date.now() - lastEventAt,
277627
+ awaitingSince,
277628
+ turnStartedAt,
277629
+ runningTool,
277630
+ lastTurnMs,
277631
+ lastTurnOk,
277632
+ pending
277633
+ };
277781
277634
  },
277782
- set(value) {
277783
- define2(value);
277635
+ turnRunning() {
277636
+ return turnStartedAt != null;
277784
277637
  }
277785
- });
277786
- return object;
277638
+ };
277787
277639
  }
277788
277640
 
277789
- // ../../node_modules/default-browser/index.js
277790
- import { promisify as promisify10 } from "node:util";
277791
- import process28 from "node:process";
277792
- import { execFile as execFile6 } from "node:child_process";
277793
-
277794
- // ../../node_modules/default-browser-id/index.js
277795
- import { promisify as promisify7 } from "node:util";
277796
- import process26 from "node:process";
277797
- import { execFile as execFile3 } from "node:child_process";
277798
- var execFileAsync = promisify7(execFile3);
277799
- async function defaultBrowserId() {
277800
- if (process26.platform !== "darwin") {
277801
- throw new Error("macOS only");
277641
+ // src/core/resources/apps/connections.ts
277642
+ var InitiateSchema = object({
277643
+ redirect_url: string2().nullish(),
277644
+ connection_id: string2().nullish(),
277645
+ integration_type: string2().nullish()
277646
+ });
277647
+ async function startConnectorOAuth(options) {
277648
+ let response;
277649
+ try {
277650
+ response = await getAppClient().post("external-auth/initiate", {
277651
+ json: {
277652
+ integration_type: options.integrationType,
277653
+ scopes: options.scopes ?? null,
277654
+ connector_id: options.connectorId ?? null,
277655
+ force_reconnect: options.forceReconnect === true
277656
+ }
277657
+ });
277658
+ } catch (error) {
277659
+ throw await ApiError.fromHttpError(error, "starting connector authorization");
277802
277660
  }
277803
- const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
277804
- const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
277805
- const browserId = match?.groups.id ?? "com.apple.Safari";
277806
- if (browserId === "com.apple.safari") {
277807
- return "com.apple.Safari";
277661
+ const parsed = InitiateSchema.parse(await response.json());
277662
+ if (!parsed.redirect_url || !parsed.connection_id) {
277663
+ throw new ApiError("The connector did not return an authorization link.");
277808
277664
  }
277809
- return browserId;
277665
+ return {
277666
+ url: parsed.redirect_url,
277667
+ connectionId: parsed.connection_id,
277668
+ integrationType: parsed.integration_type ?? options.integrationType
277669
+ };
277810
277670
  }
277811
-
277812
- // ../../node_modules/run-applescript/index.js
277813
- import process27 from "node:process";
277814
- import { promisify as promisify8 } from "node:util";
277815
- import { execFile as execFile4, execFileSync } from "node:child_process";
277816
- var execFileAsync2 = promisify8(execFile4);
277817
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
277818
- if (process27.platform !== "darwin") {
277819
- throw new Error("macOS only");
277671
+ async function waitForConnectorOAuth(started, options = {}) {
277672
+ const deadline = Date.now() + (options.timeoutMs ?? 10 * 60000);
277673
+ const interval = options.intervalMs ?? 3000;
277674
+ while (Date.now() < deadline && !options.signal?.aborted) {
277675
+ const status = await getOAuthStatus(started.integrationType, started.connectionId).catch(() => null);
277676
+ if (status?.status === "ACTIVE" || status?.status === "FAILED") {
277677
+ return status.status;
277678
+ }
277679
+ await new Promise((r) => setTimeout(r, interval));
277820
277680
  }
277821
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
277822
- const execOptions = {};
277823
- if (signal) {
277824
- execOptions.signal = signal;
277681
+ return "PENDING";
277682
+ }
277683
+ var GithubStatusSchema = object({ connected: boolean2() });
277684
+ async function githubConnected() {
277685
+ try {
277686
+ const response = await base44Client.get("api/github/oauth/status");
277687
+ return GithubStatusSchema.parse(await response.json()).connected;
277688
+ } catch {
277689
+ return false;
277825
277690
  }
277826
- const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
277827
- return stdout.trim();
277828
277691
  }
277829
277692
 
277830
- // ../../node_modules/bundle-name/index.js
277831
- async function bundleName(bundleId) {
277832
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
277833
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
277693
+ // src/cli/commands/code/session.tsx
277694
+ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
277695
+ var FRAMES2 = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
277696
+ var BRAND_ORANGE = "#E86B3C";
277697
+ var altScreenActive = false;
277698
+ var altExitHooked = false;
277699
+ function enterAltScreen() {
277700
+ process.stdout.write("\x1B[?1049h\x1B[?1007h\x1B[2J\x1B[H");
277701
+ altScreenActive = true;
277702
+ if (!altExitHooked) {
277703
+ altExitHooked = true;
277704
+ process.on("exit", () => {
277705
+ if (altScreenActive)
277706
+ process.stdout.write("\x1B[?1007l\x1B[?1049l");
277707
+ });
277708
+ }
277834
277709
  }
277835
-
277836
- // ../../node_modules/default-browser/windows.js
277837
- import { promisify as promisify9 } from "node:util";
277838
- import { execFile as execFile5 } from "node:child_process";
277839
- var execFileAsync3 = promisify9(execFile5);
277840
- var windowsBrowserProgIds = {
277841
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
277842
- MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
277843
- MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
277844
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
277845
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
277846
- ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
277847
- ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
277848
- ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
277849
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
277850
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
277851
- BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
277852
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
277853
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
277854
- OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
277855
- VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
277856
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
277857
- };
277858
- var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
277859
-
277860
- class UnknownBrowserError extends Error {
277710
+ function exitAltScreen() {
277711
+ if (!altScreenActive)
277712
+ return;
277713
+ altScreenActive = false;
277714
+ process.stdout.write("\x1B[?1007l\x1B[?1049l");
277861
277715
  }
277862
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
277863
- const { stdout } = await _execFileAsync("reg", [
277864
- "QUERY",
277865
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
277866
- "/v",
277867
- "ProgId"
277868
- ]);
277869
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
277870
- if (!match) {
277871
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
277716
+ function withEntry(items, entry) {
277717
+ if (typeof entry !== "string" && "event" in entry) {
277718
+ const i = items.findIndex((e) => typeof e !== "string" && ("running" in e) && e.running.id === entry.event.id);
277719
+ if (i >= 0) {
277720
+ const next = [...items];
277721
+ next[i] = entry;
277722
+ return next;
277723
+ }
277872
277724
  }
277873
- const { id } = match.groups;
277874
- const dotIndex = id.lastIndexOf(".");
277875
- const hyphenIndex = id.lastIndexOf("-");
277876
- const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
277877
- const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
277878
- return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
277725
+ return [...items, entry];
277879
277726
  }
277880
-
277881
- // ../../node_modules/default-browser/index.js
277882
- var execFileAsync4 = promisify10(execFile6);
277883
- var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
277884
- async function defaultBrowser2() {
277885
- if (process28.platform === "darwin") {
277886
- const id = await defaultBrowserId();
277887
- const name = await bundleName(id);
277888
- return { name, id };
277889
- }
277890
- if (process28.platform === "linux") {
277891
- const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
277892
- const id = stdout.trim();
277893
- const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
277894
- return { name, id };
277895
- }
277896
- if (process28.platform === "win32") {
277897
- return defaultBrowser();
277727
+ function statusText(status, musingSeed) {
277728
+ const frame = FRAMES2[Math.floor(Date.now() / 120) % FRAMES2.length];
277729
+ switch (status.phase) {
277730
+ case "awaiting":
277731
+ return source_default.dim(`${frame} ${status.awaitingLabel} (${formatDuration2(Date.now() - status.awaitingSince)})`);
277732
+ case "running": {
277733
+ const turnFor = formatDuration2(Date.now() - (status.turnStartedAt ?? Date.now()));
277734
+ const quiet = status.quietForMs > 60000 ? " · a long private step — details render in the editor" : "";
277735
+ return `${source_default.magenta(shimmer())} ${source_default.dim(`${idleMusing(musingSeed)} (${turnFor})${quiet}`)}`;
277736
+ }
277737
+ case "sending":
277738
+ return source_default.dim(`${frame} sending…`);
277739
+ case "idle": {
277740
+ const hint = status.idleHint ? ` — ${status.idleHint}` : "";
277741
+ const last = status.lastTurnMs != null ? ` · last turn ${formatDuration2(status.lastTurnMs)}${status.lastTurnOk ? "" : " (failed)"}` : "";
277742
+ return source_default.dim(`ready${hint}${last}`);
277743
+ }
277898
277744
  }
277899
- throw new Error("Only macOS, Linux, and Windows are supported");
277900
277745
  }
277901
-
277902
- // ../../node_modules/is-in-ssh/index.js
277903
- import process29 from "node:process";
277904
- var isInSsh = Boolean(process29.env.SSH_CONNECTION || process29.env.SSH_CLIENT || process29.env.SSH_TTY);
277905
- var is_in_ssh_default = isInSsh;
277906
-
277907
- // ../../node_modules/open/index.js
277908
- var fallbackAttemptSymbol = Symbol("fallbackAttempt");
277909
- var __dirname2 = import.meta.url ? path16.dirname(fileURLToPath4(import.meta.url)) : "";
277910
- var localXdgOpenPath = path16.join(__dirname2, "xdg-open");
277911
- var { platform: platform7, arch } = process30;
277912
- var tryEachApp = async (apps, opener) => {
277913
- if (apps.length === 0) {
277914
- return;
277915
- }
277916
- const errors = [];
277917
- for (const app of apps) {
277746
+ function SessionView({ engine, footer, subscribe }) {
277747
+ const { exit } = use_app_default();
277748
+ const [items, setItems] = import_react23.useState([]);
277749
+ const [verbose, setVerbose] = import_react23.useState(false);
277750
+ const [input, setInput] = import_react23.useState("");
277751
+ const [scroll, setScroll] = import_react23.useState(0);
277752
+ const [, tick] = import_react23.useReducer((x) => x + 1, 0);
277753
+ const [musingSeed] = import_react23.useState(() => Math.floor(Math.random() * 97));
277754
+ const [currentModel, setCurrentModel] = import_react23.useState(null);
277755
+ const [pickerIndex, setPickerIndex] = import_react23.useState(null);
277756
+ const [card, setCard] = import_react23.useState(null);
277757
+ const dismissedRef = import_react23.useRef(new Set);
277758
+ const maxScrollRef = import_react23.useRef(0);
277759
+ const meIdRef = import_react23.useRef(null);
277760
+ const emit = (entry) => setItems((h) => withEntry(h, entry));
277761
+ import_react23.useEffect(() => subscribe((entry) => setItems((h) => withEntry(h, entry))), [subscribe]);
277762
+ import_react23.useEffect(() => {
277763
+ const timer = setInterval(tick, 120);
277764
+ return () => clearInterval(timer);
277765
+ }, []);
277766
+ import_react23.useEffect(() => {
277767
+ getMe().then((me) => {
277768
+ meIdRef.current = me.id;
277769
+ setCurrentModel(me.builder_model ?? null);
277770
+ }).catch(() => {});
277771
+ }, []);
277772
+ const applyModel = async (pick) => {
277773
+ const orange = source_default.hex(BRAND_ORANGE);
277918
277774
  try {
277919
- return await opener(app);
277775
+ if ((pick.id ?? null) === currentModel) {
277776
+ emit(source_default.dim(` already on ${pick.name}`));
277777
+ return;
277778
+ }
277779
+ let id = meIdRef.current;
277780
+ if (!id) {
277781
+ id = (await getMe()).id;
277782
+ meIdRef.current = id;
277783
+ }
277784
+ await saveBuilderModel(id, pick.id);
277785
+ setCurrentModel(pick.id);
277786
+ emit(pick.id === null ? source_default.dim(" model reset — Base44 chooses per app") : ` ${orange("●")} model set to ${source_default.bold(pick.name)}`);
277787
+ } catch (error) {
277788
+ emit(source_default.red(` /model: ${error instanceof Error ? error.message : String(error)}`));
277789
+ }
277790
+ };
277791
+ const runModelSlash = (arg) => {
277792
+ if (!arg) {
277793
+ const cur = MODELS.findIndex((m) => (m.id ?? null) === currentModel);
277794
+ setPickerIndex(cur >= 0 ? cur : 0);
277795
+ return;
277796
+ }
277797
+ try {
277798
+ applyModel(resolvePick(arg));
277799
+ } catch (error) {
277800
+ emit(source_default.red(` /model: ${error instanceof Error ? error.message : String(error)}`));
277801
+ }
277802
+ };
277803
+ const browserRunRef = import_react23.useRef(null);
277804
+ const runBrowserStep = async (state) => {
277805
+ browserRunRef.current?.abort();
277806
+ const run = new AbortController;
277807
+ browserRunRef.current = run;
277808
+ const step = state.pending.browser;
277809
+ try {
277810
+ let url;
277811
+ let wait;
277812
+ if (step?.flow === "github") {
277813
+ url = await startGithubReauth();
277814
+ wait = async () => {
277815
+ const deadline = Date.now() + 10 * 60000;
277816
+ while (Date.now() < deadline && !run.signal.aborted) {
277817
+ if (await githubConnected())
277818
+ return "ACTIVE";
277819
+ await new Promise((r) => setTimeout(r, 3000));
277820
+ }
277821
+ return "PENDING";
277822
+ };
277823
+ } else {
277824
+ const started = await startConnectorOAuth({
277825
+ integrationType: step?.integrationType ?? "",
277826
+ scopes: step?.scopes,
277827
+ connectorId: step?.connectorId,
277828
+ forceReconnect: step?.forceReconnect
277829
+ });
277830
+ url = started.url;
277831
+ wait = () => waitForConnectorOAuth(started, { signal: run.signal });
277832
+ }
277833
+ setCard((c) => c ? browserUpdate(c, { url, status: "waiting" }) : c);
277834
+ emit(source_default.dim(` authorization link: ${url}`));
277835
+ await open_default(url).catch(() => {
277836
+ return;
277837
+ });
277838
+ const outcome = await wait();
277839
+ if (run.signal.aborted)
277840
+ return;
277841
+ setCard((c) => c ? browserUpdate(c, {
277842
+ status: outcome === "ACTIVE" ? "active" : outcome === "FAILED" ? "failed" : "timeout"
277843
+ }) : c);
277920
277844
  } catch (error) {
277921
- errors.push(error);
277845
+ if (run.signal.aborted)
277846
+ return;
277847
+ emit(source_default.red(` authorization failed to start: ${error instanceof Error ? error.message : String(error)}`));
277848
+ setCard((c) => c ? browserUpdate(c, { status: "failed" }) : c);
277922
277849
  }
277923
- }
277924
- throw new AggregateError(errors, "Failed to open in all supported apps");
277925
- };
277926
- var baseOpen = async (options) => {
277927
- options = {
277928
- wait: false,
277929
- background: false,
277930
- newInstance: false,
277931
- allowNonzeroExitCode: false,
277932
- ...options
277933
277850
  };
277934
- const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
277935
- delete options[fallbackAttemptSymbol];
277936
- if (Array.isArray(options.app)) {
277937
- return tryEachApp(options.app, (singleApp) => baseOpen({
277938
- ...options,
277939
- app: singleApp,
277940
- [fallbackAttemptSymbol]: true
277941
- }));
277942
- }
277943
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
277944
- appArguments = [...appArguments];
277945
- if (Array.isArray(app)) {
277946
- return tryEachApp(app, (appName) => baseOpen({
277947
- ...options,
277948
- app: {
277949
- name: appName,
277950
- arguments: appArguments
277951
- },
277952
- [fallbackAttemptSymbol]: true
277953
- }));
277954
- }
277955
- if (app === "browser" || app === "browserPrivate") {
277956
- const ids = {
277957
- "com.google.chrome": "chrome",
277958
- "google-chrome.desktop": "chrome",
277959
- "com.brave.browser": "brave",
277960
- "org.mozilla.firefox": "firefox",
277961
- "firefox.desktop": "firefox",
277962
- "com.microsoft.msedge": "edge",
277963
- "com.microsoft.edge": "edge",
277964
- "com.microsoft.edgemac": "edge",
277965
- "microsoft-edge.desktop": "edge",
277966
- "com.apple.safari": "safari"
277967
- };
277968
- const flags = {
277969
- chrome: "--incognito",
277970
- brave: "--incognito",
277971
- firefox: "--private-window",
277972
- edge: "--inPrivate"
277973
- };
277974
- let browser;
277975
- if (is_wsl_default) {
277976
- const progId = await wslDefaultBrowser();
277977
- const browserInfo = _windowsBrowserProgIdMap.get(progId);
277978
- browser = browserInfo ?? {};
277979
- } else {
277980
- browser = await defaultBrowser2();
277851
+ const applyCard = (outcome) => {
277852
+ if (outcome.submit && card) {
277853
+ browserRunRef.current?.abort();
277854
+ engine.answer(card.pending, outcome.submit.action, outcome.submit.input);
277981
277855
  }
277982
- if (browser.id in ids) {
277983
- const browserName = ids[browser.id.toLowerCase()];
277984
- if (app === "browserPrivate") {
277985
- if (browserName === "safari") {
277986
- throw new Error("Safari doesn't support opening in private mode via command line");
277987
- }
277988
- appArguments.push(flags[browserName]);
277856
+ if (outcome.dismissed && card) {
277857
+ browserRunRef.current?.abort();
277858
+ dismissedRef.current.add(card.pending.toolCallId);
277859
+ }
277860
+ setCard(outcome.state);
277861
+ if (outcome.startBrowser && outcome.state) {
277862
+ runBrowserStep(outcome.state);
277863
+ }
277864
+ };
277865
+ const pending = engine.status().pending;
277866
+ import_react23.useEffect(() => {
277867
+ if (card) {
277868
+ if (!pending.some((p) => p.toolCallId === card.pending.toolCallId)) {
277869
+ setCard(null);
277989
277870
  }
277990
- return baseOpen({
277991
- ...options,
277992
- app: {
277993
- name: apps[browserName],
277994
- arguments: appArguments
277995
- }
277996
- });
277871
+ return;
277997
277872
  }
277998
- throw new Error(`${browser.name} is not supported as a default browser`);
277873
+ if (pickerIndex !== null)
277874
+ return;
277875
+ const next = pending.find((p) => !dismissedRef.current.has(p.toolCallId));
277876
+ if (next)
277877
+ setCard(openCard(next));
277878
+ }, [pending, card, pickerIndex]);
277879
+ use_input_default((char, key) => {
277880
+ if (pickerIndex !== null) {
277881
+ if (key.upArrow)
277882
+ setPickerIndex((i) => ((i ?? 0) - 1 + MODELS.length) % MODELS.length);
277883
+ else if (key.downArrow)
277884
+ setPickerIndex((i) => ((i ?? 0) + 1) % MODELS.length);
277885
+ else if (key.return) {
277886
+ const pick = MODELS[pickerIndex];
277887
+ setPickerIndex(null);
277888
+ applyModel(pick);
277889
+ } else if (key.escape || key.ctrl && char === "c") {
277890
+ setPickerIndex(null);
277891
+ }
277892
+ return;
277893
+ }
277894
+ if (key.tab && !card) {
277895
+ const next = pending.find((p) => dismissedRef.current.has(p.toolCallId));
277896
+ if (next) {
277897
+ dismissedRef.current.delete(next.toolCallId);
277898
+ setCard(openCard(next));
277899
+ }
277900
+ return;
277901
+ }
277902
+ if (card) {
277903
+ const mapped = key.upArrow ? "up" : key.downArrow ? "down" : key.return ? "enter" : key.escape ? "escape" : char === " " ? "space" : char === "y" || char === "n" || char === "s" ? char : null;
277904
+ if (card.typing && mapped !== "escape")
277905
+ return;
277906
+ if (mapped)
277907
+ applyCard(cardKey(card, mapped));
277908
+ if (mapped || !card.typing)
277909
+ return;
277910
+ }
277911
+ if (key.ctrl && char === "c") {
277912
+ if (input)
277913
+ setInput("");
277914
+ else
277915
+ exit();
277916
+ return;
277917
+ }
277918
+ if (key.ctrl && char === "d") {
277919
+ exit();
277920
+ return;
277921
+ }
277922
+ if (key.ctrl && char === "o") {
277923
+ setVerbose((v) => !v);
277924
+ return;
277925
+ }
277926
+ if (key.upArrow) {
277927
+ setScroll((s) => Math.min(s + 3, maxScrollRef.current));
277928
+ return;
277929
+ }
277930
+ if (key.downArrow) {
277931
+ setScroll((s) => Math.max(0, s - 3));
277932
+ return;
277933
+ }
277934
+ if (key.pageUp) {
277935
+ setScroll((s) => Math.min(s + 20, maxScrollRef.current));
277936
+ return;
277937
+ }
277938
+ if (key.pageDown) {
277939
+ setScroll((s) => Math.max(0, s - 20));
277940
+ return;
277941
+ }
277942
+ if (key.escape) {
277943
+ if (engine.turnRunning())
277944
+ engine.stopTurn();
277945
+ else
277946
+ setScroll(0);
277947
+ }
277948
+ });
277949
+ const columns = process.stdout.columns || 80;
277950
+ const rows = process.stdout.rows || 24;
277951
+ const width = columns;
277952
+ const innerWidth = Math.max(10, width - 4);
277953
+ const inputRows = Math.max(1, Math.ceil((input.length + 3) / innerWidth));
277954
+ const pickerOpen = pickerIndex !== null;
277955
+ const cardOpen = card !== null && !card.typing;
277956
+ const cardRows = card ? cardLines(card).length : 0;
277957
+ const inputBlockHeight = pickerOpen ? MODELS.length + 3 : cardOpen ? cardRows + 2 : inputRows + 2 + (card?.typing ? 1 : 0);
277958
+ const widgetHeight = inputBlockHeight + 3 + (footer.length ? 1 : 0);
277959
+ const viewHeight = Math.max(3, rows - widgetHeight - 1);
277960
+ const lines = items.flatMap((item) => hardWrapAnsi(`${renderEntry(item, { verbose, foldHint: "Ctrl+O to expand" })}
277961
+ `, columns));
277962
+ const maxScroll = Math.max(0, lines.length - viewHeight);
277963
+ maxScrollRef.current = maxScroll;
277964
+ const clamped = Math.min(scroll, maxScroll);
277965
+ const end = lines.length - clamped;
277966
+ const visible = lines.slice(Math.max(0, end - viewHeight), end);
277967
+ const scrollNote = clamped > 0 ? source_default.yellow(` ↑ ${clamped} lines — Esc for live`) : "";
277968
+ const statusLine = hardWrapAnsi(`${statusText(engine.status(), musingSeed)}${scrollNote}`, Math.max(10, columns - 1))[0];
277969
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277970
+ flexDirection: "column",
277971
+ children: [
277972
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277973
+ flexDirection: "column",
277974
+ height: viewHeight,
277975
+ children: visible.map((line, index) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277976
+ wrap: "truncate-end",
277977
+ children: line || " "
277978
+ }, `${index}-${line.length}`, false, undefined, this))
277979
+ }, undefined, false, undefined, this),
277980
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277981
+ wrap: "truncate-end",
277982
+ children: statusLine
277983
+ }, undefined, false, undefined, this),
277984
+ pickerOpen ? /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
277985
+ flexDirection: "column",
277986
+ borderStyle: "round",
277987
+ borderColor: "cyan",
277988
+ paddingX: 1,
277989
+ width,
277990
+ children: [
277991
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
277992
+ children: [
277993
+ source_default.bold("Pick a model"),
277994
+ source_default.dim(" ↑↓ move · Enter select · Esc cancel")
277995
+ ]
277996
+ }, undefined, true, undefined, this),
277997
+ MODELS.map((m, i) => {
277998
+ const selected = i === pickerIndex;
277999
+ const isCurrent = (m.id ?? null) === currentModel;
278000
+ const label = `${selected ? "▸" : " "} ${isCurrent ? "●" : "○"} ${m.name}${m.note ? ` (${m.note})` : ""}`;
278001
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278002
+ color: selected ? "cyan" : undefined,
278003
+ wrap: "truncate-end",
278004
+ children: selected ? label : source_default.dim(label)
278005
+ }, m.name, false, undefined, this);
278006
+ })
278007
+ ]
278008
+ }, undefined, true, undefined, this) : cardOpen && card ? /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
278009
+ flexDirection: "column",
278010
+ borderStyle: "round",
278011
+ borderColor: "yellow",
278012
+ paddingX: 1,
278013
+ width,
278014
+ children: cardLines(card).map((line, i) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278015
+ wrap: "truncate-end",
278016
+ children: line
278017
+ }, i, false, undefined, this))
278018
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
278019
+ flexDirection: "column",
278020
+ borderStyle: "round",
278021
+ borderColor: card?.typing ? "yellow" : "gray",
278022
+ paddingX: 1,
278023
+ width,
278024
+ children: [
278025
+ card?.typing === "secret" && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278026
+ wrap: "truncate-end",
278027
+ children: [
278028
+ source_default.bold(card.pending.secrets?.[card.step]?.name ?? "secret"),
278029
+ source_default.dim(" — value is hidden · Enter to save · Esc to cancel")
278030
+ ]
278031
+ }, undefined, true, undefined, this),
278032
+ card?.typing === "custom" && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278033
+ wrap: "truncate-end",
278034
+ children: [
278035
+ source_default.bold(card.pending.questions?.[card.step]?.question ?? ""),
278036
+ source_default.dim(" — your own answer · Enter to save · Esc to go back")
278037
+ ]
278038
+ }, undefined, true, undefined, this),
278039
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
278040
+ children: [
278041
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278042
+ color: "cyan",
278043
+ children: "❯ "
278044
+ }, undefined, false, undefined, this),
278045
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(build_default, {
278046
+ value: input,
278047
+ onChange: setInput,
278048
+ mask: card?.typing === "secret" ? "•" : undefined,
278049
+ onSubmit: (value) => {
278050
+ if (card?.typing) {
278051
+ applyCard(cardText(card, value));
278052
+ setInput("");
278053
+ return;
278054
+ }
278055
+ const trimmed = value.trim();
278056
+ if (trimmed === "/model" || trimmed.startsWith("/model ")) {
278057
+ runModelSlash(trimmed.slice("/model".length).trim());
278058
+ } else if (trimmed) {
278059
+ engine.submit(value);
278060
+ }
278061
+ setInput("");
278062
+ }
278063
+ }, undefined, false, undefined, this)
278064
+ ]
278065
+ }, undefined, true, undefined, this)
278066
+ ]
278067
+ }, undefined, true, undefined, this),
278068
+ footer.length > 0 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278069
+ wrap: "truncate-end",
278070
+ children: ` ${footer.join(source_default.dim(" · "))}`
278071
+ }, undefined, false, undefined, this),
278072
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278073
+ wrap: "truncate-end",
278074
+ children: ` ${source_default.dim("model")} ${source_default.hex(BRAND_ORANGE)(displayName(currentModel))}`
278075
+ }, undefined, false, undefined, this),
278076
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
278077
+ dimColor: true,
278078
+ wrap: "truncate-end",
278079
+ children: pickerOpen ? " ↑↓ to move · Enter to select · Esc to cancel" : cardOpen ? " the agent is waiting on you · answer above, or Esc for later" : pending.length > 0 && !card ? ` ⏸ ${pending[0].title} — Tab to answer · Ctrl+C to exit` : engine.turnRunning() ? " Esc to stop · type to queue · scroll to read · Ctrl+O to expand · Ctrl+C to exit" : " Enter to send · /model to switch model · Esc for live · Ctrl+O to expand · Ctrl+C to exit"
278080
+ }, undefined, false, undefined, this)
278081
+ ]
278082
+ }, undefined, true, undefined, this);
278083
+ }
278084
+ function renderHeader(who, mode) {
278085
+ const orange = source_default.hex(BRAND_ORANGE);
278086
+ const cwd = process.cwd().replace(process.env.HOME ?? "", "~");
278087
+ const logo = logoRows(BRAND_ORANGE);
278088
+ const logoW = LOGO_COLS;
278089
+ const text = [
278090
+ `${orange.bold("Base44 Code")} ${source_default.dim(`v${package_default.version}`)}`,
278091
+ source_default.bold(who ? `Welcome back, ${who}!` : "Welcome!"),
278092
+ source_default.dim(getBase44ApiUrl().replace(/^https:\/\//, "")),
278093
+ source_default.dim(cwd),
278094
+ ...mode ? [`${orange("●")} ${source_default.dim(mode)}`] : []
278095
+ ];
278096
+ const height = Math.max(logo.length, text.length);
278097
+ const textTop = Math.max(0, Math.floor((logo.length - text.length) / 2));
278098
+ const out = [];
278099
+ for (let i = 0;i < height; i++) {
278100
+ const left = i < logo.length ? logo[i] : " ".repeat(logoW);
278101
+ const right = text[i - textTop] ?? "";
278102
+ out.push(` ${left} ${right}`.trimEnd());
277999
278103
  }
278000
- let command;
278001
- const cliArguments = [];
278002
- const childProcessOptions = {};
278003
- let shouldUseWindowsInWsl = false;
278004
- if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
278005
- shouldUseWindowsInWsl = await canAccessPowerShell();
278104
+ return out.join(`
278105
+ `);
278106
+ }
278107
+ async function currentUserName() {
278108
+ try {
278109
+ const auth = await readAuth();
278110
+ return auth.name || auth.email || "";
278111
+ } catch {
278112
+ return "";
278006
278113
  }
278007
- if (platform7 === "darwin") {
278008
- command = "open";
278009
- if (options.wait) {
278010
- cliArguments.push("--wait-apps");
278011
- }
278012
- if (options.background) {
278013
- cliArguments.push("--background");
278014
- }
278015
- if (options.newInstance) {
278016
- cliArguments.push("--new");
278114
+ }
278115
+ async function buildHeader(mode) {
278116
+ return renderHeader(await currentUserName(), mode);
278117
+ }
278118
+ async function runInteractiveSession(options) {
278119
+ const sessionStartedAt = Date.now();
278120
+ const listeners = new Set;
278121
+ const buffered = [];
278122
+ const onLine = (line) => {
278123
+ if (listeners.size === 0) {
278124
+ buffered.push(line);
278125
+ return;
278017
278126
  }
278018
- if (app) {
278019
- cliArguments.push("-a", app);
278127
+ for (const listener of listeners)
278128
+ listener(line);
278129
+ };
278130
+ const subscribe = (listener) => {
278131
+ listeners.add(listener);
278132
+ if (buffered.length) {
278133
+ for (const line of buffered.splice(0))
278134
+ listener(line);
278020
278135
  }
278021
- } else if (platform7 === "win32" || shouldUseWindowsInWsl) {
278022
- command = await powerShellPath2();
278023
- cliArguments.push(...executePowerShell.argumentsPrefix);
278024
- if (!is_wsl_default) {
278025
- childProcessOptions.windowsVerbatimArguments = true;
278136
+ return () => listeners.delete(listener);
278137
+ };
278138
+ const engine = createSessionEngine({
278139
+ branchId: options.branchId,
278140
+ awaitingTurnLabel: options.awaitingTurnLabel,
278141
+ idleHint: options.idleHint,
278142
+ onLine,
278143
+ onTurnSettled: options.onTurnSettled
278144
+ });
278145
+ enterAltScreen();
278146
+ onLine(await buildHeader());
278147
+ process.stdout.write("\x1B[?2004h");
278148
+ const stdinProxy = createPasteFriendlyStdin(process.stdin);
278149
+ const app = render_default(/* @__PURE__ */ jsx_dev_runtime.jsxDEV(SessionView, {
278150
+ engine,
278151
+ footer: options.footer,
278152
+ subscribe
278153
+ }, undefined, false, undefined, this), { exitOnCtrlC: false, stdin: stdinProxy });
278154
+ try {
278155
+ await engine.start(options.primeFirstPoll);
278156
+ if (options.initialMessage)
278157
+ engine.submit(options.initialMessage);
278158
+ await app.waitUntilExit();
278159
+ } finally {
278160
+ process.stdout.write("\x1B[?2004l");
278161
+ stdinProxy.cleanup();
278162
+ engine.stop();
278163
+ exitAltScreen();
278164
+ if (options.footer.length) {
278165
+ process.stdout.write(`${options.footer.join(source_default.dim(" · "))}
278166
+ `);
278026
278167
  }
278027
- if (is_wsl_default && options.target) {
278028
- options.target = await convertWslPathToWindows(options.target);
278168
+ const note = engine.turnRunning() ? " — the running turn continues server-side (watch it in the editor)" : "";
278169
+ process.stdout.write(`${source_default.dim(`session ended · ${formatDuration2(Date.now() - sessionStartedAt)}${note}`)}
278170
+ `);
278171
+ }
278172
+ }
278173
+ async function runGenesisSession(options) {
278174
+ const sessionStartedAt = Date.now();
278175
+ const listeners = new Set;
278176
+ const buffered = [];
278177
+ const onLine = (line) => {
278178
+ if (listeners.size === 0) {
278179
+ buffered.push(line);
278180
+ return;
278029
278181
  }
278030
- const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
278031
- if (options.wait) {
278032
- encodedArguments.push("-Wait");
278182
+ for (const listener of listeners)
278183
+ listener(line);
278184
+ };
278185
+ const subscribe = (listener) => {
278186
+ listeners.add(listener);
278187
+ if (buffered.length) {
278188
+ for (const line of buffered.splice(0))
278189
+ listener(line);
278033
278190
  }
278034
- if (app) {
278035
- encodedArguments.push(executePowerShell.escapeArgument(app));
278036
- if (options.target) {
278037
- appArguments.push(options.target);
278191
+ return () => listeners.delete(listener);
278192
+ };
278193
+ let inner = null;
278194
+ let creating = false;
278195
+ let creatingSince = 0;
278196
+ const IDLE_STATUS = {
278197
+ phase: "idle",
278198
+ idleHint: options.idleHint,
278199
+ awaitingSince: 0,
278200
+ turnStartedAt: null,
278201
+ runningTool: null,
278202
+ lastTurnMs: null,
278203
+ lastTurnOk: true,
278204
+ pending: [],
278205
+ quietForMs: 0
278206
+ };
278207
+ const genesis = {
278208
+ async start() {},
278209
+ stop() {
278210
+ inner?.stop();
278211
+ },
278212
+ stopTurn() {
278213
+ inner?.stopTurn();
278214
+ },
278215
+ submit(text) {
278216
+ if (inner) {
278217
+ inner.submit(text);
278218
+ return;
278038
278219
  }
278039
- } else if (options.target) {
278040
- encodedArguments.push(executePowerShell.escapeArgument(options.target));
278041
- }
278042
- if (appArguments.length > 0) {
278043
- appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
278044
- encodedArguments.push("-ArgumentList", appArguments.join(","));
278045
- }
278046
- options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
278047
- if (!options.wait) {
278048
- childProcessOptions.stdio = "ignore";
278049
- }
278050
- } else {
278051
- if (app) {
278052
- command = app;
278053
- } else {
278054
- const isBundled = !__dirname2 || __dirname2 === "/";
278055
- let exeLocalXdgOpen = false;
278056
- try {
278057
- await fs20.access(localXdgOpenPath, fsConstants2.X_OK);
278058
- exeLocalXdgOpen = true;
278059
- } catch {}
278060
- const useSystemXdgOpen = process30.versions.electron ?? (platform7 === "android" || isBundled || !exeLocalXdgOpen);
278061
- command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
278062
- }
278063
- if (appArguments.length > 0) {
278064
- cliArguments.push(...appArguments);
278220
+ if (creating) {
278221
+ onLine(source_default.dim("· hold on — still creating the app"));
278222
+ return;
278223
+ }
278224
+ creating = true;
278225
+ creatingSince = Date.now();
278226
+ onLine(`${source_default.cyan("❯")} ${source_default.bold(text)}`);
278227
+ options.createApp(text, onLine).then(async (config) => {
278228
+ const engine = createSessionEngine({
278229
+ branchId: config.branchId,
278230
+ awaitingTurnLabel: config.awaitingTurnLabel,
278231
+ onLine,
278232
+ onTurnSettled: config.onTurnSettled
278233
+ });
278234
+ await engine.start(false);
278235
+ inner = engine;
278236
+ }).catch(async (error) => {
278237
+ creating = false;
278238
+ const message = error instanceof Error ? error.message : String(error);
278239
+ onLine(source_default.red(`✗ create failed: ${message}`));
278240
+ if (isGithubUserTokenError(error)) {
278241
+ const link = await startGithubReauth().catch(() => null);
278242
+ onLine(source_default.yellow("GitHub authorization expired — reconnect, then try again:"));
278243
+ onLine(link ? terminalLink("Reconnect GitHub", link) : "Open Base44 → GitHub settings to reconnect your account.");
278244
+ }
278245
+ });
278246
+ },
278247
+ status() {
278248
+ if (inner)
278249
+ return inner.status();
278250
+ if (creating) {
278251
+ return {
278252
+ ...IDLE_STATUS,
278253
+ phase: "awaiting",
278254
+ awaitingLabel: options.creatingLabel,
278255
+ awaitingSince: creatingSince
278256
+ };
278257
+ }
278258
+ return IDLE_STATUS;
278259
+ },
278260
+ answer(p, action, input) {
278261
+ inner?.answer(p, action, input);
278262
+ },
278263
+ turnRunning() {
278264
+ return inner?.turnRunning() ?? creating;
278065
278265
  }
278066
- if (!options.wait) {
278067
- childProcessOptions.stdio = "ignore";
278068
- childProcessOptions.detached = true;
278266
+ };
278267
+ enterAltScreen();
278268
+ onLine(await buildHeader(options.modeLabel));
278269
+ process.stdout.write("\x1B[?2004h");
278270
+ const stdinProxy = createPasteFriendlyStdin(process.stdin);
278271
+ const app = render_default(/* @__PURE__ */ jsx_dev_runtime.jsxDEV(SessionView, {
278272
+ engine: genesis,
278273
+ footer: options.footer,
278274
+ subscribe
278275
+ }, undefined, false, undefined, this), { exitOnCtrlC: false, stdin: stdinProxy });
278276
+ try {
278277
+ await app.waitUntilExit();
278278
+ } finally {
278279
+ process.stdout.write("\x1B[?2004l");
278280
+ stdinProxy.cleanup();
278281
+ genesis.stop();
278282
+ exitAltScreen();
278283
+ if (options.footer.length) {
278284
+ process.stdout.write(`${options.footer.join(source_default.dim(" · "))}
278285
+ `);
278069
278286
  }
278287
+ const note = genesis.turnRunning() ? " — the running turn continues server-side (watch it in the editor)" : "";
278288
+ process.stdout.write(`${source_default.dim(`session ended · ${formatDuration2(Date.now() - sessionStartedAt)}${note}`)}
278289
+ `);
278070
278290
  }
278071
- if (platform7 === "darwin" && appArguments.length > 0) {
278072
- cliArguments.push("--args", ...appArguments);
278073
- }
278074
- if (options.target) {
278075
- cliArguments.push(options.target);
278291
+ }
278292
+
278293
+ // src/cli/commands/code/index.ts
278294
+ var BRAND_ORANGE2 = "#E86B3C";
278295
+ async function bootstrapApp(prompt, footer, emit, onCreated, importRepo, path, wixInstance) {
278296
+ let app;
278297
+ try {
278298
+ app = await createAndLinkApp({ prompt, importRepo, path, wixInstance });
278299
+ } catch (error) {
278300
+ for (const line of await githubReauthLines(error) ?? [])
278301
+ emit(line);
278302
+ throw error;
278076
278303
  }
278077
- const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
278078
- if (options.wait) {
278079
- return new Promise((resolve, reject) => {
278080
- subprocess.once("error", reject);
278081
- subprocess.once("close", (exitCode) => {
278082
- if (!options.allowNonzeroExitCode && exitCode !== 0) {
278083
- reject(new Error(`Exited with code ${exitCode}`));
278084
- return;
278085
- }
278086
- resolve(subprocess);
278304
+ onCreated(app);
278305
+ footer.push(source_default.dim(`dir ${app.here ? "./" : `./${app.dirName}`}`));
278306
+ if (app.repoUrl)
278307
+ footer.push(terminalLink("repo", app.repoUrl));
278308
+ footer.push(terminalLink("editor", app.editorUrl));
278309
+ emit(source_default.dim(app.here ? "linked ./ (this directory)" : `linked ./${app.dirName} (cd ${app.dirName} after the session)`));
278310
+ const branchId = await resolveActiveBranchId().catch(() => {
278311
+ return;
278312
+ });
278313
+ let previewPushed = false;
278314
+ return {
278315
+ branchId,
278316
+ awaitingTurnLabel: "provisioning the sandbox and starting the build",
278317
+ onTurnSettled: async ({
278318
+ turnIndex,
278319
+ ok
278320
+ }) => {
278321
+ if (turnIndex !== 0 || !ok || previewPushed)
278322
+ return;
278323
+ const url = await getPreviewUrl().catch(() => {
278324
+ return;
278087
278325
  });
278088
- });
278326
+ if (url) {
278327
+ previewPushed = true;
278328
+ footer.push(terminalLink("preview", url));
278329
+ }
278330
+ }
278331
+ };
278332
+ }
278333
+ async function codeAction({ log }, options, appId) {
278334
+ const orange = source_default.hex(BRAND_ORANGE2);
278335
+ const chip = (label) => source_default.dim(`${orange("●")} ${label}`);
278336
+ if (process.stdout.isTTY !== true) {
278337
+ throw new InvalidInputError("base44 code is an interactive session and needs a terminal.");
278089
278338
  }
278090
- if (isFallbackAttempt) {
278091
- return new Promise((resolve, reject) => {
278092
- subprocess.once("error", reject);
278093
- subprocess.once("spawn", () => {
278094
- subprocess.once("close", (exitCode) => {
278095
- subprocess.off("error", reject);
278096
- if (exitCode !== 0) {
278097
- reject(new Error(`Exited with code ${exitCode}`));
278098
- return;
278099
- }
278100
- subprocess.unref();
278101
- resolve(subprocess);
278102
- });
278103
- });
278339
+ let linked = false;
278340
+ try {
278341
+ await initAppContext(appId ? { appId } : {});
278342
+ linked = true;
278343
+ } catch {}
278344
+ if (linked) {
278345
+ if (options.import || options.path || options.wixInstance) {
278346
+ throw new InvalidInputError("--import, --path and --wix-instance create a new app; run them outside a linked project, without --app-id.");
278347
+ }
278348
+ const { id, projectRoot } = getAppContext();
278349
+ const state = await assertBuilderApp(id);
278350
+ const branchId = await resolveActiveBranchId().catch(() => {
278351
+ return;
278104
278352
  });
278105
- }
278106
- subprocess.unref();
278107
- return new Promise((resolve, reject) => {
278108
- subprocess.once("error", reject);
278109
- subprocess.once("spawn", () => {
278110
- subprocess.off("error", reject);
278111
- resolve(subprocess);
278353
+ await runInteractiveSession({
278354
+ branchId,
278355
+ footer: [chip(appTypeChip(state))],
278356
+ primeFirstPoll: true,
278357
+ idleHint: "what should the agent do next?"
278112
278358
  });
278113
- });
278114
- };
278115
- var open = (target, options) => {
278116
- if (typeof target !== "string") {
278117
- throw new TypeError("Expected a `target`");
278359
+ if (projectRoot) {
278360
+ log.message(source_default.dim(`app dir ${projectRoot}`));
278361
+ return {
278362
+ outroMessage: "Session closed. Run `base44 code` here to resume."
278363
+ };
278364
+ }
278365
+ return {
278366
+ outroMessage: `Session closed. Resume with \`base44 code --app-id ${id}\`.`
278367
+ };
278118
278368
  }
278119
- return baseOpen({
278120
- ...options,
278121
- target
278122
- });
278123
- };
278124
- function detectArchBinary(binary) {
278125
- if (typeof binary === "string" || Array.isArray(binary)) {
278126
- return binary;
278369
+ if (options.wixInstance && options.import) {
278370
+ throw new InvalidInputError("--wix-instance and --import are exclusive.");
278127
278371
  }
278128
- const { [arch]: archBinary } = binary;
278129
- if (!archBinary) {
278130
- throw new Error(`${arch} is not supported`);
278372
+ const wixInstance = options.wixInstance?.trim() ? {
278373
+ signedInstance: options.wixInstance.trim(),
278374
+ wixClientId: options.wixClientId?.trim() || undefined
278375
+ } : undefined;
278376
+ let created;
278377
+ const footer = [
278378
+ chip(options.import ? repoLabel(options.import) : wixInstance ? "web app · wix" : "web app")
278379
+ ];
278380
+ await runGenesisSession({
278381
+ idleHint: options.import ? "describe what to build over the repository" : "describe the app you want to build · have one already? base44 code --app-id <id>, or base44 link",
278382
+ creatingLabel: options.import ? "importing the repository" : "creating your app",
278383
+ modeLabel: options.import ? `Repository — ${repoLabel(options.import)}` : wixInstance ? "Web app — Wix launch (connector connected first)" : "Web app — Base44 template + builder agent",
278384
+ footer,
278385
+ createApp: (prompt, emit) => bootstrapApp(prompt, footer, emit, (app) => {
278386
+ created = app;
278387
+ }, options.import, options.path, wixInstance)
278388
+ });
278389
+ if (!created) {
278390
+ return { outroMessage: "Session closed. No app was created." };
278131
278391
  }
278132
- return archBinary;
278392
+ for (const line of nextStepsLines(created))
278393
+ log.message(line);
278394
+ log.message(source_default.dim(` editor ${created.editorUrl}`));
278395
+ return { outroMessage: "Session closed." };
278133
278396
  }
278134
- function detectPlatformBinary({ [platform7]: platformBinary }, { wsl } = {}) {
278135
- if (wsl && is_wsl_default) {
278136
- return detectArchBinary(wsl);
278137
- }
278138
- if (!platformBinary) {
278139
- throw new Error(`${platform7} is not supported`);
278140
- }
278141
- return detectArchBinary(platformBinary);
278397
+ function getCodeCommand() {
278398
+ const command = new Base44Command("code", { requireAppContext: false });
278399
+ command.description("Open Base44 Code, an interactive builder session. In a linked directory (or with --app-id <id>) it opens that app; anywhere else your first prompt creates one (--import <repo> to build over your own repository). Attach a directory to an existing app with base44 link.").option("--import <repo>", "Build over an existing GitHub repository instead of the Base44 template").option("--path <dir>", "Directory to link the new app to (default: the current directory when empty, else ./<name>)").option("--wix-instance <token>", "Create the new app through the Wix route with this signed instance (your first prompt is what the agent runs)").option("--wix-client-id <id>", "The companion OAuth app's client id").action((ctx, options) => codeAction(ctx, options, command.optsWithGlobals().appId));
278400
+ return command;
278142
278401
  }
278143
- var apps = {
278144
- browser: "browser",
278145
- browserPrivate: "browserPrivate"
278146
- };
278147
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
278148
- darwin: "google chrome",
278149
- win32: "chrome",
278150
- linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
278151
- }, {
278152
- wsl: {
278153
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
278154
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
278155
- }
278156
- }));
278157
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
278158
- darwin: "brave browser",
278159
- win32: "brave",
278160
- linux: ["brave-browser", "brave"]
278161
- }, {
278162
- wsl: {
278163
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
278164
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
278165
- }
278166
- }));
278167
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
278168
- darwin: "firefox",
278169
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
278170
- linux: "firefox"
278171
- }, {
278172
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
278173
- }));
278174
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
278175
- darwin: "microsoft edge",
278176
- win32: "msedge",
278177
- linux: ["microsoft-edge", "microsoft-edge-dev"]
278178
- }, {
278179
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
278180
- }));
278181
- defineLazyProperty(apps, "safari", () => detectPlatformBinary({
278182
- darwin: "Safari"
278183
- }));
278184
- var open_default = open;
278185
278402
 
278186
278403
  // src/cli/commands/connectors/oauth-prompt.ts
278187
278404
  var POLL_INTERVAL_MS = 2000;
@@ -289242,4 +289459,4 @@ export {
289242
289459
  runCLI
289243
289460
  };
289244
289461
 
289245
- //# debugId=F9AF4FAF927903AE64756E2164756E21
289462
+ //# debugId=E4D675A68B5DE05064756E2164756E21