@base44-preview/cli 0.2.3-pr.682.9217d4b → 0.2.6-pr.684.c1fb02f

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
@@ -121436,7 +121436,7 @@ function getDataProtocolModuleFormat(parsed) {
121436
121436
  const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null, null];
121437
121437
  return mimeToFormat(mime);
121438
121438
  }
121439
- function extname2(url3) {
121439
+ function extname3(url3) {
121440
121440
  const pathname = url3.pathname;
121441
121441
  let index = pathname.length;
121442
121442
  while (index--) {
@@ -121451,7 +121451,7 @@ function extname2(url3) {
121451
121451
  return "";
121452
121452
  }
121453
121453
  function getFileProtocolModuleFormat(url3, _context, ignoreErrors) {
121454
- const value = extname2(url3);
121454
+ const value = extname3(url3);
121455
121455
  if (value === ".js") {
121456
121456
  const packageType = getPackageType(url3);
121457
121457
  if (packageType !== "none") {
@@ -239384,7 +239384,7 @@ import { join as join13 } from "node:path";
239384
239384
  // package.json
239385
239385
  var package_default = {
239386
239386
  name: "base44",
239387
- version: "0.2.3",
239387
+ version: "0.2.6",
239388
239388
  description: "Base44 CLI - Unified interface for managing Base44 applications",
239389
239389
  type: "module",
239390
239390
  bin: {
@@ -265009,7 +265009,7 @@ var import_ms2 = __toESM(require_ms(), 1);
265009
265009
 
265010
265010
  // src/core/session-import/api.ts
265011
265011
  import { randomUUID as randomUUID5 } from "node:crypto";
265012
- var MAX_SESSION_BYTES = 25 * 1024 * 1024;
265012
+ var MAX_SESSION_BYTES = 50 * 1024 * 1024;
265013
265013
  var SessionImportResponseSchema = object({
265014
265014
  branch_id: string2(),
265015
265015
  branch_name: string2(),
@@ -265017,7 +265017,8 @@ var SessionImportResponseSchema = object({
265017
265017
  turn_count: number2(),
265018
265018
  branch_url: string2(),
265019
265019
  continued: boolean2(),
265020
- source_ref: string2()
265020
+ source_ref: string2(),
265021
+ reimported: boolean2().default(false)
265021
265022
  }).transform((data) => ({
265022
265023
  branchId: data.branch_id,
265023
265024
  branchName: data.branch_name,
@@ -265025,7 +265026,8 @@ var SessionImportResponseSchema = object({
265025
265026
  turnCount: data.turn_count,
265026
265027
  branchUrl: data.branch_url,
265027
265028
  continued: data.continued,
265028
- sourceRef: data.source_ref
265029
+ sourceRef: data.source_ref,
265030
+ reimported: data.reimported
265029
265031
  }));
265030
265032
  var ErrorEnvelopeSchema = object({
265031
265033
  error: object({
@@ -265038,6 +265040,12 @@ function messageFor(status, code, details, viaToken) {
265038
265040
  if (code === "branch_exists" && details?.branch_url) {
265039
265041
  return `Base Code already has ${details.branch_name ?? "a branch for this session"}. Open it: ${new URL(details.branch_url, getBase44ApiUrl())}`;
265040
265042
  }
265043
+ if (code === "session_changed" && details?.branch_url) {
265044
+ return `This session changed since it was imported into ${details.branch_name ?? "its branch"}, so its newer messages can't be added there. In Base Code, open Import session and choose Import into a new branch: ${new URL(details.branch_url, getBase44ApiUrl())}`;
265045
+ }
265046
+ if (code === "branch_busy") {
265047
+ return `${details?.branch_name ?? "The session's branch"} is still working in Base Code. Wait for it to finish, then import again.`;
265048
+ }
265041
265049
  if (code === "idempotency_key_in_use") {
265042
265050
  return "An import of this session is still running. Wait a moment and try again.";
265043
265051
  }
@@ -265053,7 +265061,7 @@ function messageFor(status, code, details, viaToken) {
265053
265061
  if (status === 404)
265054
265062
  return "Session import isn't available for this app.";
265055
265063
  if (status === 413)
265056
- return "This session is over 25 MB and can't be imported.";
265064
+ return "This session is over 50 MB and can't be imported.";
265057
265065
  if (code === "unsupported_file") {
265058
265066
  return "That file isn't a Claude Code or Codex session.";
265059
265067
  }
@@ -265114,9 +265122,140 @@ async function uploadSession(appId, content, { token, sourceBranch } = {}) {
265114
265122
  return result.data;
265115
265123
  }
265116
265124
 
265125
+ // src/core/session-import/images.ts
265126
+ import { stat as stat4 } from "node:fs/promises";
265127
+ import { extname as extname2 } from "node:path";
265128
+ var MEDIA_TYPES = {
265129
+ ".png": "image/png",
265130
+ ".jpg": "image/jpeg",
265131
+ ".jpeg": "image/jpeg",
265132
+ ".gif": "image/gif",
265133
+ ".webp": "image/webp"
265134
+ };
265135
+ var MAX_ATTACHED_IMAGES = 20;
265136
+ var MAX_ATTACHED_IMAGE_BYTES = 10 * 1024 * 1024;
265137
+ var IMAGE_PATH = /(?:\/|[A-Za-z]:\\)[^\s"'`<>()]+\.(?:png|jpe?g|gif|webp)\b/gi;
265138
+ var asRecord = (value) => value && typeof value === "object" ? value : {};
265139
+ var isImage = (value) => ["image", "input_image"].includes(String(asRecord(value).type));
265140
+ function withoutImages(value) {
265141
+ if (Array.isArray(value)) {
265142
+ return value.filter((item) => !isImage(item)).map(withoutImages);
265143
+ }
265144
+ if (value && typeof value === "object") {
265145
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, withoutImages(item)]));
265146
+ }
265147
+ return value;
265148
+ }
265149
+ function strings(value) {
265150
+ if (typeof value === "string")
265151
+ return [value];
265152
+ if (Array.isArray(value))
265153
+ return value.flatMap(strings);
265154
+ if (value && typeof value === "object") {
265155
+ return Object.values(value).flatMap(strings);
265156
+ }
265157
+ return [];
265158
+ }
265159
+ var payloadOf = (entry) => asRecord(entry.payload);
265160
+ var messageOf = (entry) => asRecord(entry.message);
265161
+ function isTypedUserMessage(entry) {
265162
+ if (entry.type === "user") {
265163
+ if (entry.isMeta || entry.isSidechain)
265164
+ return false;
265165
+ const content = asRecord(entry.message).content;
265166
+ return typeof content === "string" || Array.isArray(content) && !content.some((block) => asRecord(block).type === "tool_result");
265167
+ }
265168
+ const payload = asRecord(entry.payload);
265169
+ return entry.type === "response_item" && payload.type === "message" && payload.role === "user";
265170
+ }
265171
+ function toolInputs(entries) {
265172
+ return entries.flatMap((entry) => {
265173
+ const payload = asRecord(entry.payload);
265174
+ if (entry.type === "response_item") {
265175
+ return String(payload.type).endsWith("_call") ? strings([payload.input, payload.arguments]) : [];
265176
+ }
265177
+ const content = messageOf(entry).content;
265178
+ return (Array.isArray(content) ? content : []).filter((block) => asRecord(block).type === "tool_use").flatMap((block) => strings(asRecord(block).input));
265179
+ }).join(`
265180
+ `);
265181
+ }
265182
+ async function imageBlock(path, codex) {
265183
+ const mediaType = MEDIA_TYPES[extname2(path).toLowerCase()];
265184
+ const size = await stat4(path).then((info) => info.isFile() ? info.size : 0, () => 0);
265185
+ if (!mediaType || !size || size > MAX_ATTACHED_IMAGE_BYTES)
265186
+ return;
265187
+ const data = (await readFile(path)).toString("base64");
265188
+ return codex ? { type: "input_image", image_url: `data:${mediaType};base64,${data}` } : {
265189
+ type: "image",
265190
+ source: { type: "base64", media_type: mediaType, data }
265191
+ };
265192
+ }
265193
+ async function prepareSessionImages(content) {
265194
+ const lines = Buffer.from(content).toString("utf8").split(`
265195
+ `);
265196
+ const entries = lines.map((line) => {
265197
+ try {
265198
+ const entry = JSON.parse(line);
265199
+ return entry && typeof entry === "object" ? entry : undefined;
265200
+ } catch {
265201
+ return;
265202
+ }
265203
+ });
265204
+ const changed = new Set;
265205
+ entries.forEach((entry, i) => {
265206
+ if (!entry || !lines[i]?.includes("image"))
265207
+ return;
265208
+ const message = messageOf(entry);
265209
+ if (entry.type === "user" && Array.isArray(message.content) && message.content.some((block) => asRecord(block).type === "tool_result")) {
265210
+ const content = message.content.map((block) => asRecord(block).type === "tool_result" ? withoutImages(block) : block);
265211
+ const { toolUseResult: _, ...rest } = entry;
265212
+ entries[i] = { ...rest, message: { ...message, content } };
265213
+ changed.add(i);
265214
+ } else if (entry.type === "response_item" && String(asRecord(entry.payload).type).endsWith("_output")) {
265215
+ entries[i] = { ...entry, payload: withoutImages(entry.payload) };
265216
+ changed.add(i);
265217
+ }
265218
+ });
265219
+ const opened = toolInputs(entries.filter((entry) => !!entry));
265220
+ let budget = MAX_ATTACHED_IMAGES;
265221
+ for (let i = entries.length - 1;i >= 0 && budget > 0; i--) {
265222
+ const entry = entries[i];
265223
+ if (!entry || !isTypedUserMessage(entry))
265224
+ continue;
265225
+ const codex = entry.type === "response_item";
265226
+ const raw = codex ? payloadOf(entry).content : messageOf(entry).content;
265227
+ const blocks = typeof raw === "string" ? [{ type: "text", text: raw }] : Array.isArray(raw) ? [...raw] : [];
265228
+ const paths = new Set(strings(blocks.filter((block) => !isImage(block))).flatMap((text) => text.match(IMAGE_PATH) ?? []));
265229
+ const added = [];
265230
+ for (const path of paths) {
265231
+ if (budget === 0 || !opened.includes(path))
265232
+ continue;
265233
+ const block = await imageBlock(path, codex);
265234
+ if (block) {
265235
+ added.push(block);
265236
+ budget--;
265237
+ }
265238
+ }
265239
+ if (!added.length)
265240
+ continue;
265241
+ entries[i] = codex ? {
265242
+ ...entry,
265243
+ payload: { ...payloadOf(entry), content: [...blocks, ...added] }
265244
+ } : {
265245
+ ...entry,
265246
+ message: { ...messageOf(entry), content: [...blocks, ...added] }
265247
+ };
265248
+ changed.add(i);
265249
+ }
265250
+ if (!changed.size)
265251
+ return content;
265252
+ return Buffer.from(lines.map((line, i) => changed.has(i) ? JSON.stringify(entries[i]) : line).join(`
265253
+ `));
265254
+ }
265255
+
265117
265256
  // src/core/session-import/sessions.ts
265118
265257
  import { createReadStream as createReadStream3 } from "node:fs";
265119
- import { realpath, rm as rm3, stat as stat4 } from "node:fs/promises";
265258
+ import { realpath, rm as rm3, stat as stat5 } from "node:fs/promises";
265120
265259
  import { homedir as homedir4 } from "node:os";
265121
265260
  import { dirname as dirname23, join as join31 } from "node:path";
265122
265261
  import { createInterface as createInterface2 } from "node:readline";
@@ -265151,12 +265290,12 @@ async function scanLines(path, pick, maxLines = Number.POSITIVE_INFINITY) {
265151
265290
  }
265152
265291
  return;
265153
265292
  }
265154
- var asRecord = (value) => value && typeof value === "object" ? value : {};
265155
- var codexCwd = (entry) => entry.type === "session_meta" ? String(asRecord(entry.payload).cwd ?? "") : undefined;
265293
+ var asRecord2 = (value) => value && typeof value === "object" ? value : {};
265294
+ var codexCwd = (entry) => entry.type === "session_meta" ? String(asRecord2(entry.payload).cwd ?? "") : undefined;
265156
265295
  async function newest(paths) {
265157
265296
  let best;
265158
265297
  for (const path of paths) {
265159
- const { mtimeMs } = await stat4(path);
265298
+ const { mtimeMs } = await stat5(path);
265160
265299
  if (!best || mtimeMs > best.mtime)
265161
265300
  best = { path, mtime: mtimeMs };
265162
265301
  }
@@ -265207,11 +265346,11 @@ async function findCurrentSession(cwd) {
265207
265346
  function claudeUserText(entry) {
265208
265347
  if (entry.type !== "user" || entry.isMeta || entry.isSidechain)
265209
265348
  return;
265210
- const content = asRecord(entry.message).content;
265349
+ const content = asRecord2(entry.message).content;
265211
265350
  return typeof content === "string" && !content.startsWith("<") ? content : undefined;
265212
265351
  }
265213
265352
  function codexUserText(entry) {
265214
- const payload = asRecord(entry.payload);
265353
+ const payload = asRecord2(entry.payload);
265215
265354
  return entry.type === "event_msg" && payload.type === "user_message" ? String(payload.message ?? "") : undefined;
265216
265355
  }
265217
265356
  var PICKER_LIMIT = 20;
@@ -265230,7 +265369,7 @@ async function listSessions(cwd) {
265230
265369
  ];
265231
265370
  const dated = await Promise.all(candidates.map(async (c) => ({
265232
265371
  ...c,
265233
- updatedAt: (await stat4(c.path)).mtime
265372
+ updatedAt: (await stat5(c.path)).mtime
265234
265373
  })));
265235
265374
  dated.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
265236
265375
  const sessions = [];
@@ -265252,7 +265391,7 @@ var TELEPORT_PROMPT = "Reply with OK.";
265252
265391
  var TELEPORT_NOTE = "This session is being continued from another machine";
265253
265392
  function parseLine(line) {
265254
265393
  try {
265255
- return asRecord(JSON.parse(line));
265394
+ return asRecord2(JSON.parse(line));
265256
265395
  } catch {
265257
265396
  return {};
265258
265397
  }
@@ -265261,7 +265400,7 @@ function stripTeleportExchange(content) {
265261
265400
  const lines = content.split(`
265262
265401
  `);
265263
265402
  const entries = lines.map(parseLine);
265264
- const userText = (entry) => entry.type === "user" ? asRecord(entry.message).content : undefined;
265403
+ const userText = (entry) => entry.type === "user" ? asRecord2(entry.message).content : undefined;
265265
265404
  let end = lines.length;
265266
265405
  for (let i = lines.length - 1;i >= 0; i--) {
265267
265406
  if (userText(entries[i] ?? {}) === TELEPORT_PROMPT) {
@@ -265308,7 +265447,7 @@ async function teleportSession(sessionId, cwd) {
265308
265447
  cwd: claudeDir(),
265309
265448
  absolute: true
265310
265449
  })) {
265311
- if ((await stat4(path)).mtimeMs < startedAt)
265450
+ if ((await stat5(path)).mtimeMs < startedAt)
265312
265451
  continue;
265313
265452
  const sessionCwd = await scanLines(path, (entry) => typeof entry.cwd === "string" ? entry.cwd : undefined, 50);
265314
265453
  if (sessionCwd === repo || sessionCwd === repoReal)
@@ -265387,9 +265526,9 @@ async function importAction(ctx, link, options, command) {
265387
265526
  throw new InvalidInputError("Pass only one of: a session link, --current, or --file.");
265388
265527
  }
265389
265528
  const appId = requireApp(ctx).id;
265390
- const content = await readSession(ctx, link, options);
265529
+ const content = await prepareSessionImages(await readSession(ctx, link, options));
265391
265530
  if (content.length > MAX_SESSION_BYTES) {
265392
- throw new InvalidInputError("This session is over 25 MB and can't be imported.", { hints: [] });
265531
+ throw new InvalidInputError("This session is over 50 MB and can't be imported.", { hints: [] });
265393
265532
  }
265394
265533
  const git = link || options.file ? undefined : await readGitState(process.cwd());
265395
265534
  if (git?.unpushed && !options.skipPushCheck) {
@@ -265406,7 +265545,7 @@ async function importAction(ctx, link, options, command) {
265406
265545
  const url = `${getBase44ApiUrl()}${imported.branchUrl}`;
265407
265546
  return {
265408
265547
  outroMessage: [
265409
- imported.continued ? `✓ Imported ${imported.turnCount} messages from ${TOOL_LABELS[imported.source]}. Continued on "${imported.branchName}".` : `✓ Imported ${imported.turnCount} messages from ${TOOL_LABELS[imported.source]} into branch "${imported.branchName}".`,
265548
+ outcome(imported),
265410
265549
  ...note ? [note] : [],
265411
265550
  `Open it: ${url}`
265412
265551
  ].join(`
@@ -265414,6 +265553,14 @@ async function importAction(ctx, link, options, command) {
265414
265553
  stdout: ctx.jsonMode ? toJsonStdout({ ...imported, url, ...note ? { note } : {} }) : undefined
265415
265554
  };
265416
265555
  }
265556
+ function outcome(imported) {
265557
+ const { turnCount, branchName } = imported;
265558
+ const tool = TOOL_LABELS[imported.source];
265559
+ if (imported.reimported) {
265560
+ return turnCount ? `✓ Added ${turnCount} new messages from ${tool} to "${branchName}".` : `✓ Nothing new to import. "${branchName}" already has every message.`;
265561
+ }
265562
+ return imported.continued ? `✓ Imported ${turnCount} messages from ${tool}. Continued on "${branchName}".` : `✓ Imported ${turnCount} messages from ${tool} into branch "${branchName}".`;
265563
+ }
265417
265564
  function getSessionsImportCommand() {
265418
265565
  return new Base44Command("import", { requireAuth: false }).description("Continue a Claude Code or Codex session in Base Code").argument("[session-link]", "A claude.ai session address (https://claude.ai/code/session_…)").option("--current", "Import the session this command runs inside").option("--file <path>", "Import this session file as is").option("--skip-push-check", "Import even though local changes aren't on GitHub (they won't be included)").option("--token <key>", "One-time import key from Base Code (no login needed)").action(importAction);
265419
265566
  }
@@ -268286,11 +268433,11 @@ import { relative as relative11 } from "node:path";
268286
268433
  // ../../node_modules/chokidar/index.js
268287
268434
  import { EventEmitter as EventEmitter3 } from "node:events";
268288
268435
  import { stat as statcb, Stats } from "node:fs";
268289
- import { readdir as readdir3, stat as stat8 } from "node:fs/promises";
268436
+ import { readdir as readdir3, stat as stat9 } from "node:fs/promises";
268290
268437
  import * as sp3 from "node:path";
268291
268438
 
268292
268439
  // ../../node_modules/readdirp/index.js
268293
- import { lstat as lstat2, readdir as readdir2, realpath as realpath2, stat as stat6 } from "node:fs/promises";
268440
+ import { lstat as lstat2, readdir as readdir2, realpath as realpath2, stat as stat7 } from "node:fs/promises";
268294
268441
  import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
268295
268442
  import { Readable as Readable6 } from "node:stream";
268296
268443
  var EntryTypes = {
@@ -268372,7 +268519,7 @@ class ReaddirpStream extends Readable6 {
268372
268519
  const { root, type } = opts;
268373
268520
  this._fileFilter = normalizeFilter(opts.fileFilter);
268374
268521
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
268375
- const statMethod = opts.lstat ? lstat2 : stat6;
268522
+ const statMethod = opts.lstat ? lstat2 : stat7;
268376
268523
  if (wantBigintFsStats) {
268377
268524
  this._stat = (path) => statMethod(path, { bigint: true });
268378
268525
  } else {
@@ -268525,7 +268672,7 @@ function readdirp(root, options = {}) {
268525
268672
 
268526
268673
  // ../../node_modules/chokidar/handler.js
268527
268674
  import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
268528
- import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat7 } from "node:fs/promises";
268675
+ import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat8 } from "node:fs/promises";
268529
268676
  import { type as osType } from "node:os";
268530
268677
  import * as sp2 from "node:path";
268531
268678
  var STR_DATA = "data";
@@ -268551,7 +268698,7 @@ var EVENTS = {
268551
268698
  };
268552
268699
  var EV = EVENTS;
268553
268700
  var THROTTLE_MODE_WATCH = "watch";
268554
- var statMethods = { lstat: lstat3, stat: stat7 };
268701
+ var statMethods = { lstat: lstat3, stat: stat8 };
268555
268702
  var KEY_LISTENERS = "listeners";
268556
268703
  var KEY_ERR = "errHandlers";
268557
268704
  var KEY_RAW = "rawEmitters";
@@ -269022,7 +269169,7 @@ class NodeFsHandler {
269022
269169
  return;
269023
269170
  if (!newStats || newStats.mtimeMs === 0) {
269024
269171
  try {
269025
- const newStats = await stat7(file);
269172
+ const newStats = await stat8(file);
269026
269173
  if (this.fsw.closed)
269027
269174
  return;
269028
269175
  const at = newStats.atimeMs;
@@ -269694,7 +269841,7 @@ class FSWatcher extends EventEmitter3 {
269694
269841
  const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
269695
269842
  let stats;
269696
269843
  try {
269697
- stats = await stat8(fullPath);
269844
+ stats = await stat9(fullPath);
269698
269845
  } catch (err) {}
269699
269846
  if (!stats || this.closed)
269700
269847
  return;
@@ -274649,4 +274796,4 @@ export {
274649
274796
  runCLI
274650
274797
  };
274651
274798
 
274652
- //# debugId=B7C73C57031F826A64756E2164756E21
274799
+ //# debugId=874BE39039B3832564756E2164756E21