@base44-preview/cli 0.2.2-pr.679.27ae567 → 0.2.2-pr.680.e01ae1e

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
@@ -228838,7 +228838,7 @@ function normalizeBase44Env() {
228838
228838
  loadProjectEnvFiles();
228839
228839
 
228840
228840
  // src/cli/index.ts
228841
- import { dirname as dirname31, join as join42 } from "node:path";
228841
+ import { dirname as dirname30, join as join41 } from "node:path";
228842
228842
  import { fileURLToPath as fileURLToPath7 } from "node:url";
228843
228843
 
228844
228844
  // ../../node_modules/@clack/core/dist/index.mjs
@@ -230795,8 +230795,7 @@ var TestOverridesSchema = object({
230795
230795
  id: string2(),
230796
230796
  projectRoot: string2()
230797
230797
  }).optional(),
230798
- latestVersion: string2().nullable().optional(),
230799
- claudeBin: string2().optional()
230798
+ latestVersion: string2().nullable().optional()
230800
230799
  });
230801
230800
 
230802
230801
  // src/core/config.ts
@@ -236978,9 +236977,16 @@ var BackendFunctionToolConfigSchema = object({
236978
236977
  function_name: string2().min(1),
236979
236978
  description: string2().default("agent backend function")
236980
236979
  });
236980
+ var ServerRouteToolConfigSchema = object({
236981
+ tool_name: string2().regex(/^[A-Za-z0-9_-]{1,64}$/, "tool_name must be 1-64 letters, digits, '_' or '-'"),
236982
+ route_path: string2().trim().max(2000).regex(/^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@%/]*$/, "route_path must be an app-relative route like '/api/orders'"),
236983
+ method: _enum(["get", "post", "put", "patch", "delete"]).default("post"),
236984
+ description: string2().default("agent server route")
236985
+ });
236981
236986
  var ToolConfigSchema = union([
236982
236987
  EntityToolConfigSchema,
236983
- BackendFunctionToolConfigSchema
236988
+ BackendFunctionToolConfigSchema,
236989
+ ServerRouteToolConfigSchema
236984
236990
  ]);
236985
236991
  var MemoryConfigSchema = object({
236986
236992
  enabled: boolean2().default(true),
@@ -246852,17 +246858,6 @@ var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
246852
246858
  function isGitCommitHash(value) {
246853
246859
  return GIT_HASH_PATTERN.test(value);
246854
246860
  }
246855
- async function hasUnpushedWork(cwd) {
246856
- const status = await execa("git", ["status", "--porcelain", "--branch"], {
246857
- cwd,
246858
- reject: false
246859
- });
246860
- if (status.exitCode !== 0)
246861
- return false;
246862
- const [branch = "", ...changes] = status.stdout.split(`
246863
- `).filter(Boolean);
246864
- return changes.length > 0 || !branch.includes("...") || branch.includes("[ahead");
246865
- }
246866
246861
 
246867
246862
  // src/core/site/git-hash.ts
246868
246863
  function workerBuildNeedsGitHashError() {
@@ -269798,374 +269793,6 @@ Examples:
269798
269793
  $ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
269799
269794
  }
269800
269795
 
269801
- // src/cli/commands/import.ts
269802
- var import_ms2 = __toESM(require_ms(), 1);
269803
-
269804
- // src/core/session-import/api.ts
269805
- var MAX_SESSION_BYTES = 25 * 1024 * 1024;
269806
- var SessionImportResponseSchema = object({
269807
- branch_id: string2(),
269808
- branch_name: string2(),
269809
- source: _enum(["claude_code", "codex"]),
269810
- turn_count: number2(),
269811
- branch_url: string2()
269812
- }).transform((data) => ({
269813
- branchId: data.branch_id,
269814
- branchName: data.branch_name,
269815
- source: data.source,
269816
- turnCount: data.turn_count,
269817
- branchUrl: data.branch_url
269818
- }));
269819
- var ErrorEnvelopeSchema = object({
269820
- error: object({ code: string2().optional() })
269821
- });
269822
- var NETWORK_BLOCKED = "claude.ai is blocking Base44. In this session's environment settings, open Network access, add `app.base44.com` and `base44.app` to Allowed domains, save, and try again.";
269823
- function messageFor(status, code, viaToken) {
269824
- if (status === 401 && viaToken) {
269825
- return "This import key expired or was already used. In Base Code, open Import session and copy a new prompt.";
269826
- }
269827
- if (status === 403) {
269828
- return "You don't have edit access to this app, or this key was made for a different app.";
269829
- }
269830
- if (status === 404)
269831
- return "Session import isn't available for this app.";
269832
- if (status === 413)
269833
- return "This session is over 25 MB and can't be imported.";
269834
- if (code === "unsupported_file") {
269835
- return "That file isn't a Claude Code or Codex session.";
269836
- }
269837
- if (code === "repository_mismatch") {
269838
- return "This session is from a different repository than the app.";
269839
- }
269840
- if (status === 429)
269841
- return "Too many imports. Wait a minute and try again.";
269842
- return;
269843
- }
269844
- async function toImportError(error, viaToken) {
269845
- if (!(error instanceof HTTPError)) {
269846
- const reason = error instanceof Error ? error.message : String(error);
269847
- return new ApiError(process.env.CLAUDE_CODE_REMOTE ? NETWORK_BLOCKED : `Couldn't reach Base44: ${reason}`, { hints: [] });
269848
- }
269849
- const { status } = error.response;
269850
- const fallback = await ApiError.fromHttpError(error, "importing session");
269851
- const envelope = ErrorEnvelopeSchema.safeParse(fallback.responseBody);
269852
- const code = envelope.success ? envelope.data.error.code : undefined;
269853
- const blocked = process.env.CLAUDE_CODE_REMOTE && status === 403 && typeof fallback.responseBody !== "object";
269854
- const known = blocked ? NETWORK_BLOCKED : messageFor(status, code, viaToken);
269855
- return new ApiError(known ?? fallback.message, {
269856
- statusCode: status,
269857
- requestUrl: error.request.url,
269858
- requestMethod: error.request.method,
269859
- requestId: fallback.requestId,
269860
- hints: known ? [] : fallback.hints
269861
- });
269862
- }
269863
- async function uploadSession(appId, content, token) {
269864
- const form = new FormData;
269865
- form.append("file", new Blob([content]), "session.jsonl");
269866
- let response;
269867
- try {
269868
- response = token ? await distribution_default.post(new URL(`/api/apps/${appId}/imported/session-imports`, getBase44ApiUrl()), {
269869
- body: form,
269870
- headers: {
269871
- Authorization: `Bearer ${token}`,
269872
- "User-Agent": "Base44 CLI"
269873
- },
269874
- timeout: 180000
269875
- }) : await getAppClient().post("imported/session-imports", {
269876
- body: form,
269877
- timeout: 180000
269878
- });
269879
- } catch (error) {
269880
- throw await toImportError(error, Boolean(token));
269881
- }
269882
- const result = SessionImportResponseSchema.safeParse(await response.json());
269883
- if (!result.success) {
269884
- throw new SchemaValidationError("Invalid session import response from server", result.error);
269885
- }
269886
- return result.data;
269887
- }
269888
-
269889
- // src/core/session-import/sessions.ts
269890
- import { createReadStream as createReadStream3 } from "node:fs";
269891
- import { realpath as realpath2, rm as rm5, stat as stat8 } from "node:fs/promises";
269892
- import { homedir as homedir5 } from "node:os";
269893
- import { dirname as dirname29, join as join41 } from "node:path";
269894
- import { createInterface as createInterface2 } from "node:readline";
269895
- var claudeDir = () => process.env.CLAUDE_CONFIG_DIR || join41(homedir5(), ".claude");
269896
- var codexDir = () => process.env.CODEX_HOME || join41(homedir5(), ".codex");
269897
- async function scanLines(path, pick, maxLines = Number.POSITIVE_INFINITY) {
269898
- const lines = createInterface2({ input: createReadStream3(path) });
269899
- let count = 0;
269900
- try {
269901
- for await (const line of lines) {
269902
- if (++count > maxLines)
269903
- return;
269904
- try {
269905
- const found = pick(JSON.parse(line));
269906
- if (found !== undefined)
269907
- return found;
269908
- } catch {}
269909
- }
269910
- } finally {
269911
- lines.close();
269912
- }
269913
- return;
269914
- }
269915
- var asRecord = (value) => value && typeof value === "object" ? value : {};
269916
- var codexCwd = (entry) => entry.type === "session_meta" ? String(asRecord(entry.payload).cwd ?? "") : undefined;
269917
- async function newest(paths) {
269918
- let best;
269919
- for (const path of paths) {
269920
- const { mtimeMs } = await stat8(path);
269921
- if (!best || mtimeMs > best.mtime)
269922
- best = { path, mtime: mtimeMs };
269923
- }
269924
- return best?.path;
269925
- }
269926
- async function sameDir(a, b) {
269927
- if (a === b)
269928
- return true;
269929
- const [ra, rb] = await Promise.all([
269930
- realpath2(a).catch(() => a),
269931
- realpath2(b).catch(() => b)
269932
- ]);
269933
- return ra === rb;
269934
- }
269935
- var codexRollouts = () => globby("sessions/*/*/*/rollout-*.jsonl", {
269936
- cwd: codexDir(),
269937
- absolute: true
269938
- });
269939
- async function codexRolloutsIn(cwd) {
269940
- const matches = [];
269941
- for (const path of await codexRollouts()) {
269942
- const recorded = await scanLines(path, codexCwd, 1);
269943
- if (recorded && await sameDir(recorded, cwd))
269944
- matches.push(path);
269945
- }
269946
- return matches;
269947
- }
269948
- async function findCurrentSession(cwd) {
269949
- const claudeId = process.env.CLAUDE_CODE_SESSION_ID;
269950
- if (claudeId) {
269951
- const [path] = await globby(`projects/*/${claudeId}.jsonl`, {
269952
- cwd: claudeDir(),
269953
- absolute: true
269954
- });
269955
- return path;
269956
- }
269957
- const codexId = process.env.CODEX_THREAD_ID;
269958
- if (codexId) {
269959
- const rollouts = await codexRollouts();
269960
- return rollouts.find((path) => path.endsWith(`-${codexId}.jsonl`));
269961
- }
269962
- return newest(await codexRolloutsIn(cwd));
269963
- }
269964
- function claudeUserText(entry) {
269965
- if (entry.type !== "user" || entry.isMeta || entry.isSidechain)
269966
- return;
269967
- const content = asRecord(entry.message).content;
269968
- return typeof content === "string" && !content.startsWith("<") ? content : undefined;
269969
- }
269970
- function codexUserText(entry) {
269971
- const payload = asRecord(entry.payload);
269972
- return entry.type === "event_msg" && payload.type === "user_message" ? String(payload.message ?? "") : undefined;
269973
- }
269974
- var PICKER_LIMIT = 20;
269975
- async function listSessions(cwd) {
269976
- const claudeFolder = cwd.replace(/[^a-zA-Z0-9]/g, "-");
269977
- const claude = await globby(`projects/${claudeFolder}/*.jsonl`, {
269978
- cwd: claudeDir(),
269979
- absolute: true
269980
- });
269981
- const candidates = [
269982
- ...claude.map((path) => ({ tool: "claude_code", path })),
269983
- ...(await codexRolloutsIn(cwd)).map((path) => ({
269984
- tool: "codex",
269985
- path
269986
- }))
269987
- ];
269988
- const dated = await Promise.all(candidates.map(async (c) => ({
269989
- ...c,
269990
- updatedAt: (await stat8(c.path)).mtime
269991
- })));
269992
- dated.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
269993
- const sessions = [];
269994
- for (const candidate of dated.slice(0, PICKER_LIMIT)) {
269995
- const firstMessage = await scanLines(candidate.path, candidate.tool === "claude_code" ? claudeUserText : codexUserText);
269996
- if (firstMessage)
269997
- sessions.push({ ...candidate, firstMessage });
269998
- }
269999
- return sessions;
270000
- }
270001
- var SESSION_ID = /session_[A-Za-z0-9]+/;
270002
- function parseSessionLink(link) {
270003
- if (/cshk_/.test(link) || !SESSION_ID.test(link)) {
270004
- throw new InvalidInputError(`That isn't a claude.ai session address. Copy it from your browser's address bar (not "Copy link").`, { hints: [] });
270005
- }
270006
- return link.match(SESSION_ID)[0];
270007
- }
270008
- var TELEPORT_PROMPT = "Reply with OK.";
270009
- var TELEPORT_NOTE = "This session is being continued from another machine";
270010
- function parseLine(line) {
270011
- try {
270012
- return asRecord(JSON.parse(line));
270013
- } catch {
270014
- return {};
270015
- }
270016
- }
270017
- function stripTeleportExchange(content) {
270018
- const lines = content.split(`
270019
- `);
270020
- const entries = lines.map(parseLine);
270021
- const userText = (entry) => entry.type === "user" ? asRecord(entry.message).content : undefined;
270022
- let end = lines.length;
270023
- for (let i = lines.length - 1;i >= 0; i--) {
270024
- if (userText(entries[i] ?? {}) === TELEPORT_PROMPT) {
270025
- end = i;
270026
- break;
270027
- }
270028
- }
270029
- return lines.slice(0, end).filter((_, i) => {
270030
- const entry = entries[i] ?? {};
270031
- const text = userText(entry);
270032
- const queued = entry.type === "queue-operation" && entry.content === TELEPORT_PROMPT;
270033
- const note = typeof text === "string" && text.startsWith(TELEPORT_NOTE);
270034
- return !queued && !note;
270035
- }).join(`
270036
- `);
270037
- }
270038
- var NEEDS_CLAUDE = "Claude Code must be installed and signed in to the same claude.ai account to import a claude.ai session.";
270039
- async function teleportSession(sessionId, cwd) {
270040
- const origin = await execa("git", ["remote", "get-url", "origin"], {
270041
- cwd,
270042
- reject: false
270043
- });
270044
- if (origin.exitCode !== 0 || !origin.stdout) {
270045
- throw new InvalidInputError("Run this from a folder with the app's GitHub repository, so the session can be checked out.");
270046
- }
270047
- const tmp = await $dir({ unsafeCleanup: true });
270048
- const repo = join41(tmp.path, "repo");
270049
- let projectFolder;
270050
- try {
270051
- await execa("git", ["clone", "--quiet", origin.stdout, repo]);
270052
- const repoReal = await realpath2(repo);
270053
- const startedAt = Date.now();
270054
- const claudeBin = getTestOverrides()?.claudeBin ?? "claude";
270055
- try {
270056
- await execa(claudeBin, ["--teleport", sessionId, "-p", TELEPORT_PROMPT], {
270057
- cwd: repo,
270058
- stdin: "ignore"
270059
- });
270060
- } catch {
270061
- throw new DependencyNotFoundError(NEEDS_CLAUDE, { hints: [] });
270062
- }
270063
- const fresh = [];
270064
- for (const path of await globby("projects/*/*.jsonl", {
270065
- cwd: claudeDir(),
270066
- absolute: true
270067
- })) {
270068
- if ((await stat8(path)).mtimeMs < startedAt)
270069
- continue;
270070
- const sessionCwd = await scanLines(path, (entry) => typeof entry.cwd === "string" ? entry.cwd : undefined, 50);
270071
- if (sessionCwd === repo || sessionCwd === repoReal)
270072
- fresh.push(path);
270073
- }
270074
- const file = await newest(fresh);
270075
- if (!file)
270076
- throw new DependencyNotFoundError(NEEDS_CLAUDE, { hints: [] });
270077
- projectFolder = dirname29(file);
270078
- return stripTeleportExchange((await readFile(file)).toString("utf8"));
270079
- } finally {
270080
- if (projectFolder)
270081
- await rm5(projectFolder, { recursive: true, force: true });
270082
- await tmp.cleanup();
270083
- }
270084
- }
270085
-
270086
- // src/cli/commands/import.ts
270087
- var TOOL_LABELS = {
270088
- claude_code: "Claude Code",
270089
- codex: "Codex"
270090
- };
270091
- async function pickSession(cwd) {
270092
- const sessions = await listSessions(cwd);
270093
- if (sessions.length === 0) {
270094
- throw new InvalidInputError("No Claude Code or Codex sessions found in this folder. Pass --file <path>.");
270095
- }
270096
- const choice = await Je({
270097
- message: "Which session do you want to continue in Base Code?",
270098
- options: sessions.map((session) => ({
270099
- value: session.path,
270100
- label: session.firstMessage.replace(/\s+/g, " ").slice(0, 70),
270101
- hint: `${TOOL_LABELS[session.tool]}, ${import_ms2.default(Date.now() - session.updatedAt.getTime())} ago`
270102
- }))
270103
- });
270104
- if (Ct(choice)) {
270105
- Ne("Operation cancelled.");
270106
- throw new CLIExitError(0);
270107
- }
270108
- return choice;
270109
- }
270110
- async function readSession(ctx, link, options) {
270111
- const cwd = process.cwd();
270112
- if (options.file)
270113
- return readFile(options.file);
270114
- if (link) {
270115
- const sessionId = parseSessionLink(link);
270116
- const content = await ctx.runTask("Downloading the claude.ai session", () => teleportSession(sessionId, cwd));
270117
- return Buffer.from(content);
270118
- }
270119
- if (options.current) {
270120
- const path = await findCurrentSession(cwd);
270121
- if (!path) {
270122
- throw new InvalidInputError("Couldn't find the current session. Run this from inside Claude Code or Codex, or pass --file <path>.", { hints: [] });
270123
- }
270124
- return readFile(path);
270125
- }
270126
- if (ctx.isNonInteractive || ctx.jsonMode) {
270127
- throw new InvalidInputError("Choose a session: pass --current, a claude.ai session link, or --file <path>.");
270128
- }
270129
- return readFile(await pickSession(cwd));
270130
- }
270131
- async function importAction(ctx, link, options, command) {
270132
- ctx.errorReporter.setContext({
270133
- command: {
270134
- name: "import",
270135
- args: link ? ["[not reported]"] : [],
270136
- options: {
270137
- ...command.opts(),
270138
- ...options.token ? { token: "[not reported]" } : {}
270139
- }
270140
- }
270141
- });
270142
- const chosen = [link, options.current, options.file].filter(Boolean).length;
270143
- if (chosen > 1) {
270144
- throw new InvalidInputError("Pass only one of: a session link, --current, or --file.");
270145
- }
270146
- const appId = requireApp(ctx).id;
270147
- const content = await readSession(ctx, link, options);
270148
- if (content.length > MAX_SESSION_BYTES) {
270149
- throw new InvalidInputError("This session is over 25 MB and can't be imported.", { hints: [] });
270150
- }
270151
- if (await hasUnpushedWork(process.cwd())) {
270152
- ctx.log.warn("Base Code only sees what's on GitHub. Push your changes so the new branch has them.");
270153
- }
270154
- if (!options.token)
270155
- await ensureAuth(ctx);
270156
- ctx.log.info("This uploads the full conversation to Base Code.");
270157
- const imported = await ctx.runTask("Importing session", () => uploadSession(appId, content, options.token));
270158
- const url = `${getBase44ApiUrl()}${imported.branchUrl}`;
270159
- return {
270160
- outroMessage: `✓ Imported ${imported.turnCount} messages from ${TOOL_LABELS[imported.source]} into branch "${imported.branchName}".
270161
- Open it: ${url}`,
270162
- stdout: ctx.jsonMode ? toJsonStdout({ ...imported, url }) : undefined
270163
- };
270164
- }
270165
- function getImportCommand() {
270166
- return new Base44Command("import", { requireAuth: false }).description("Continue a Claude Code or Codex session in a new Base Code branch").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("--token <key>", "One-time import key from Base Code (no login needed)").action(importAction);
270167
- }
270168
-
270169
269796
  // src/cli/commands/project/eject.ts
270170
269797
  import { resolve as resolve20 } from "node:path";
270171
269798
  var import_kebabCase2 = __toESM(require_kebabCase(), 1);
@@ -270329,7 +269956,6 @@ function createProgram(context) {
270329
269956
  program.addCommand(getExecCommand());
270330
269957
  program.addCommand(getDevCommand());
270331
269958
  program.addCommand(getLogsCommand());
270332
- program.addCommand(getImportCommand());
270333
269959
  return program;
270334
269960
  }
270335
269961
 
@@ -270338,7 +269964,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
270338
269964
  import { release, type } from "node:os";
270339
269965
 
270340
269966
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
270341
- import { dirname as dirname30, posix, sep as sep2 } from "path";
269967
+ import { dirname as dirname29, posix, sep as sep2 } from "path";
270342
269968
  function createModulerModifier() {
270343
269969
  const getModuleFromFileName = createGetModuleFromFilename();
270344
269970
  return async (frames) => {
@@ -270347,7 +269973,7 @@ function createModulerModifier() {
270347
269973
  return frames;
270348
269974
  };
270349
269975
  }
270350
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname30(process.argv[1]) : process.cwd(), isWindows = sep2 === "\\") {
269976
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname29(process.argv[1]) : process.cwd(), isWindows = sep2 === "\\") {
270351
269977
  const normalizedBase = isWindows ? normalizeWindowsPath2(basePath) : basePath;
270352
269978
  return (filename) => {
270353
269979
  if (!filename)
@@ -272382,8 +272008,8 @@ class ReduceableCache {
272382
272008
  }
272383
272009
  }
272384
272010
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
272385
- import { createReadStream as createReadStream4 } from "node:fs";
272386
- import { createInterface as createInterface3 } from "node:readline";
272011
+ import { createReadStream as createReadStream3 } from "node:fs";
272012
+ import { createInterface as createInterface2 } from "node:readline";
272387
272013
  var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
272388
272014
  var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
272389
272015
  var DEFAULT_LINES_OF_CONTEXT = 7;
@@ -272426,8 +272052,8 @@ async function addSourceContext(frames) {
272426
272052
  }
272427
272053
  function getContextLinesFromFile(path, ranges, output) {
272428
272054
  return new Promise((resolve) => {
272429
- const stream = createReadStream4(path);
272430
- const lineReaded = createInterface3({
272055
+ const stream = createReadStream3(path);
272056
+ const lineReaded = createInterface2({
272431
272057
  input: stream
272432
272058
  });
272433
272059
  function destroyStreamAndResolve() {
@@ -274336,9 +273962,9 @@ function addCommandInfoToErrorReporter(program, errorReporter) {
274336
273962
  });
274337
273963
  }
274338
273964
  // src/cli/index.ts
274339
- var __dirname4 = dirname31(fileURLToPath7(import.meta.url));
273965
+ var __dirname4 = dirname30(fileURLToPath7(import.meta.url));
274340
273966
  async function runCLI(options) {
274341
- ensureNpmAssets(join42(__dirname4, "../assets"));
273967
+ ensureNpmAssets(join41(__dirname4, "../assets"));
274342
273968
  const errorReporter = new ErrorReporter;
274343
273969
  errorReporter.registerProcessErrorHandlers();
274344
273970
  const jsonMode = process.argv.includes("--json");
@@ -274377,4 +274003,4 @@ export {
274377
274003
  runCLI
274378
274004
  };
274379
274005
 
274380
- //# debugId=A7200797A10A03A864756E2164756E21
274006
+ //# debugId=F5AF8E758862A48664756E2164756E21