@base44-preview/cli 0.2.6-pr.685.56bddb0 → 0.2.6-pr.686.168cf90
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 +244 -56
- package/dist/cli/index.js.map +8 -7
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -121158,7 +121158,7 @@ function parse42(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
121158
121158
|
}
|
|
121159
121159
|
return res;
|
|
121160
121160
|
}
|
|
121161
|
-
async function
|
|
121161
|
+
async function readFile6(file) {
|
|
121162
121162
|
if (isUrlString(file)) {
|
|
121163
121163
|
file = new URL(file);
|
|
121164
121164
|
}
|
|
@@ -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
|
|
121439
|
+
function extname4(url3) {
|
|
121440
121440
|
const pathname = url3.pathname;
|
|
121441
121441
|
let index = pathname.length;
|
|
121442
121442
|
while (index--) {
|
|
@@ -121451,7 +121451,7 @@ function extname3(url3) {
|
|
|
121451
121451
|
return "";
|
|
121452
121452
|
}
|
|
121453
121453
|
function getFileProtocolModuleFormat(url3, _context, ignoreErrors) {
|
|
121454
|
-
const value =
|
|
121454
|
+
const value = extname4(url3);
|
|
121455
121455
|
if (value === ".js") {
|
|
121456
121456
|
const packageType = getPackageType(url3);
|
|
121457
121457
|
if (packageType !== "none") {
|
|
@@ -134952,7 +134952,7 @@ ${codeblock}`, options8);
|
|
|
134952
134952
|
"\\": "\\"
|
|
134953
134953
|
};
|
|
134954
134954
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
134955
|
-
read_file_default =
|
|
134955
|
+
read_file_default = readFile6;
|
|
134956
134956
|
loadConfigFromPackageJson = process.versions.bun ? async function loadConfigFromBunPackageJson(file) {
|
|
134957
134957
|
const { prettier } = await readBunPackageJson(file);
|
|
134958
134958
|
return prettier;
|
|
@@ -238778,11 +238778,8 @@ async function fetchFunctionLogs(functionName, filters = {}) {
|
|
|
238778
238778
|
}
|
|
238779
238779
|
// src/core/resources/function/config.ts
|
|
238780
238780
|
import { basename as basename4, dirname as dirname8, join as join10, relative as relative3, resolve as resolve2 } from "node:path";
|
|
238781
|
-
function getSharedDir(functionsDir) {
|
|
238782
|
-
return resolve2(functionsDir, "..", "shared");
|
|
238783
|
-
}
|
|
238784
238781
|
async function readSharedFiles(functionsDir) {
|
|
238785
|
-
const sharedDir =
|
|
238782
|
+
const sharedDir = resolve2(functionsDir, "..", "shared");
|
|
238786
238783
|
if (!await pathExists(sharedDir)) {
|
|
238787
238784
|
return [];
|
|
238788
238785
|
}
|
|
@@ -265020,7 +265017,10 @@ var SessionImportResponseSchema = object({
|
|
|
265020
265017
|
turn_count: number2(),
|
|
265021
265018
|
branch_url: string2(),
|
|
265022
265019
|
continued: boolean2(),
|
|
265023
|
-
source_ref: string2()
|
|
265020
|
+
source_ref: string2(),
|
|
265021
|
+
reimported: boolean2().default(false),
|
|
265022
|
+
imported_artifacts: number2().default(0),
|
|
265023
|
+
skipped_artifacts: number2().default(0)
|
|
265024
265024
|
}).transform((data) => ({
|
|
265025
265025
|
branchId: data.branch_id,
|
|
265026
265026
|
branchName: data.branch_name,
|
|
@@ -265028,7 +265028,10 @@ var SessionImportResponseSchema = object({
|
|
|
265028
265028
|
turnCount: data.turn_count,
|
|
265029
265029
|
branchUrl: data.branch_url,
|
|
265030
265030
|
continued: data.continued,
|
|
265031
|
-
sourceRef: data.source_ref
|
|
265031
|
+
sourceRef: data.source_ref,
|
|
265032
|
+
reimported: data.reimported,
|
|
265033
|
+
importedArtifacts: data.imported_artifacts,
|
|
265034
|
+
skippedArtifacts: data.skipped_artifacts
|
|
265032
265035
|
}));
|
|
265033
265036
|
var ErrorEnvelopeSchema = object({
|
|
265034
265037
|
error: object({
|
|
@@ -265041,6 +265044,12 @@ function messageFor(status, code, details, viaToken) {
|
|
|
265041
265044
|
if (code === "branch_exists" && details?.branch_url) {
|
|
265042
265045
|
return `Base Code already has ${details.branch_name ?? "a branch for this session"}. Open it: ${new URL(details.branch_url, getBase44ApiUrl())}`;
|
|
265043
265046
|
}
|
|
265047
|
+
if (code === "session_changed" && details?.branch_url) {
|
|
265048
|
+
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())}`;
|
|
265049
|
+
}
|
|
265050
|
+
if (code === "branch_busy") {
|
|
265051
|
+
return `${details?.branch_name ?? "The session's branch"} is still working in Base Code. Wait for it to finish, then import again.`;
|
|
265052
|
+
}
|
|
265044
265053
|
if (code === "idempotency_key_in_use") {
|
|
265045
265054
|
return "An import of this session is still running. Wait a moment and try again.";
|
|
265046
265055
|
}
|
|
@@ -265086,11 +265095,24 @@ async function toImportError(error, viaToken) {
|
|
|
265086
265095
|
hints: known ? [] : fallback.hints
|
|
265087
265096
|
});
|
|
265088
265097
|
}
|
|
265089
|
-
async function uploadSession(appId, content, {
|
|
265098
|
+
async function uploadSession(appId, content, {
|
|
265099
|
+
token,
|
|
265100
|
+
sourceBranch,
|
|
265101
|
+
artifacts = []
|
|
265102
|
+
} = {}) {
|
|
265090
265103
|
const form = new FormData;
|
|
265091
265104
|
form.append("file", new Blob([content]), "session.jsonl");
|
|
265092
265105
|
if (sourceBranch)
|
|
265093
265106
|
form.append("source_branch", sourceBranch);
|
|
265107
|
+
for (const { data, fileName } of artifacts) {
|
|
265108
|
+
form.append("artifacts", new Blob([data]), fileName);
|
|
265109
|
+
}
|
|
265110
|
+
if (artifacts.length) {
|
|
265111
|
+
form.append("artifact_manifest", JSON.stringify(artifacts.map((a) => ({
|
|
265112
|
+
tool_use_id: a.toolUseId,
|
|
265113
|
+
file_name: a.fileName
|
|
265114
|
+
}))));
|
|
265115
|
+
}
|
|
265094
265116
|
const idempotencyKey = randomUUID5();
|
|
265095
265117
|
let response;
|
|
265096
265118
|
try {
|
|
@@ -265117,9 +265139,152 @@ async function uploadSession(appId, content, { token, sourceBranch } = {}) {
|
|
|
265117
265139
|
return result.data;
|
|
265118
265140
|
}
|
|
265119
265141
|
|
|
265142
|
+
// src/core/session-import/artifacts.ts
|
|
265143
|
+
import { readFile as readFile5, stat as stat4 } from "node:fs/promises";
|
|
265144
|
+
import { basename as basename9, extname as extname2, resolve as resolve16 } from "node:path";
|
|
265145
|
+
var ALLOWED = new Set("html htm pdf png jpg jpeg gif webp txt md csv json".split(" "));
|
|
265146
|
+
var IMAGE_TYPES = {
|
|
265147
|
+
".png": "image/png",
|
|
265148
|
+
".jpg": "image/jpeg",
|
|
265149
|
+
".jpeg": "image/jpeg",
|
|
265150
|
+
".gif": "image/gif",
|
|
265151
|
+
".webp": "image/webp"
|
|
265152
|
+
};
|
|
265153
|
+
var MAX_FILES = 10;
|
|
265154
|
+
var MAX_BYTES = 10 * 1024 * 1024;
|
|
265155
|
+
var MAX_REQUEST_BYTES = 95 * 1024 * 1024;
|
|
265156
|
+
var MULTIPART_MARGIN = 1024 * 1024;
|
|
265157
|
+
var OPENS_FILE = /open_in_codex\(\s*\{\s*["']?target["']?\s*:\s*\{([^}]*)\}/g;
|
|
265158
|
+
var FILE_TARGET = /["']?type["']?\s*:\s*["']file["']/;
|
|
265159
|
+
var TARGET_PATH = /(?:^|[\s,])["']?path["']?\s*:\s*(["'])((?:\\.|(?!\1).)*)\1/;
|
|
265160
|
+
var IMG_SRC = /(<img\b[^>]*?\bsrc\s*=\s*)(["'])(.*?)\2/gi;
|
|
265161
|
+
var asRecord = (value) => value && typeof value === "object" ? value : {};
|
|
265162
|
+
function toolUses(entry) {
|
|
265163
|
+
const content = asRecord(entry.message).content;
|
|
265164
|
+
return (Array.isArray(content) ? content : []).map(asRecord).filter((block) => block.type === "tool_use");
|
|
265165
|
+
}
|
|
265166
|
+
function findArtifacts(entries) {
|
|
265167
|
+
const found = [];
|
|
265168
|
+
for (const entry of entries) {
|
|
265169
|
+
const cwd = typeof entry.cwd === "string" ? entry.cwd : "";
|
|
265170
|
+
if (entry.type === "assistant" && !entry.isSidechain) {
|
|
265171
|
+
for (const block of toolUses(entry)) {
|
|
265172
|
+
const input = asRecord(block.input);
|
|
265173
|
+
if (block.name === "Artifact" && typeof block.id === "string" && typeof input.file_path === "string" && (input.action ?? "publish") === "publish" && !input.asset && !input.type_url) {
|
|
265174
|
+
const files = Object.fromEntries(Object.entries(asRecord(input.files)).filter(([, local]) => typeof local === "string").map(([key, local]) => [key, resolve16(cwd, local)]));
|
|
265175
|
+
found.push({
|
|
265176
|
+
toolUseId: block.id,
|
|
265177
|
+
path: input.file_path,
|
|
265178
|
+
claude: true,
|
|
265179
|
+
files
|
|
265180
|
+
});
|
|
265181
|
+
}
|
|
265182
|
+
}
|
|
265183
|
+
}
|
|
265184
|
+
const payload = asRecord(entry.payload);
|
|
265185
|
+
if (entry.type === "response_item" && payload.type === "custom_tool_call" && payload.name === "exec" && typeof payload.input === "string" && typeof payload.call_id === "string") {
|
|
265186
|
+
for (const [, target = ""] of payload.input.matchAll(OPENS_FILE)) {
|
|
265187
|
+
if (!FILE_TARGET.test(target))
|
|
265188
|
+
continue;
|
|
265189
|
+
const path = TARGET_PATH.exec(target)?.[2]?.replace(/\\(.)/g, "$1");
|
|
265190
|
+
if (path)
|
|
265191
|
+
found.push({ toolUseId: payload.call_id, path, claude: false });
|
|
265192
|
+
}
|
|
265193
|
+
}
|
|
265194
|
+
}
|
|
265195
|
+
return found;
|
|
265196
|
+
}
|
|
265197
|
+
function lastCleanWrite(entries, path) {
|
|
265198
|
+
let content;
|
|
265199
|
+
for (const entry of entries) {
|
|
265200
|
+
for (const block of toolUses(entry)) {
|
|
265201
|
+
const input = asRecord(block.input);
|
|
265202
|
+
if (input.file_path !== path)
|
|
265203
|
+
continue;
|
|
265204
|
+
if (block.name === "Write" && typeof input.content === "string") {
|
|
265205
|
+
content = input.content;
|
|
265206
|
+
} else if (block.name === "Edit" || block.name === "MultiEdit") {
|
|
265207
|
+
content = undefined;
|
|
265208
|
+
}
|
|
265209
|
+
}
|
|
265210
|
+
}
|
|
265211
|
+
return content === undefined ? undefined : Buffer.from(content);
|
|
265212
|
+
}
|
|
265213
|
+
var readRegularFile = (path) => stat4(path).then((info) => info.isFile() ? readFile5(path) : undefined, () => {
|
|
265214
|
+
return;
|
|
265215
|
+
});
|
|
265216
|
+
async function inlineImages(html, files) {
|
|
265217
|
+
const text = html.toString("utf8");
|
|
265218
|
+
const uris = new Map;
|
|
265219
|
+
for (const [, , , src = ""] of text.matchAll(IMG_SRC)) {
|
|
265220
|
+
const local = files[src];
|
|
265221
|
+
const mediaType = local && IMAGE_TYPES[extname2(local).toLowerCase()];
|
|
265222
|
+
const data = mediaType && await readRegularFile(local);
|
|
265223
|
+
if (data)
|
|
265224
|
+
uris.set(src, `data:${mediaType};base64,${data.toString("base64")}`);
|
|
265225
|
+
}
|
|
265226
|
+
if (!uris.size)
|
|
265227
|
+
return html;
|
|
265228
|
+
return Buffer.from(text.replace(IMG_SRC, (match, prefix, quote, src) => {
|
|
265229
|
+
const uri = uris.get(src);
|
|
265230
|
+
return uri ? `${prefix}${quote}${uri}${quote}` : match;
|
|
265231
|
+
}));
|
|
265232
|
+
}
|
|
265233
|
+
async function collectArtifacts2(session, budget = MAX_REQUEST_BYTES - session.length - MULTIPART_MARGIN) {
|
|
265234
|
+
const entries = Buffer.from(session).toString("utf8").split(`
|
|
265235
|
+
`).map((line) => {
|
|
265236
|
+
try {
|
|
265237
|
+
return asRecord(JSON.parse(line));
|
|
265238
|
+
} catch {
|
|
265239
|
+
return {};
|
|
265240
|
+
}
|
|
265241
|
+
});
|
|
265242
|
+
const byPath = new Map;
|
|
265243
|
+
for (const found of findArtifacts(entries)) {
|
|
265244
|
+
byPath.delete(found.path);
|
|
265245
|
+
byPath.set(found.path, found);
|
|
265246
|
+
}
|
|
265247
|
+
const newest = [...byPath.values()];
|
|
265248
|
+
const skipped = newest.slice(0, -MAX_FILES).map(({ path }) => ({
|
|
265249
|
+
fileName: basename9(path),
|
|
265250
|
+
reason: `only the newest ${MAX_FILES} are sent`
|
|
265251
|
+
}));
|
|
265252
|
+
const artifacts = [];
|
|
265253
|
+
for (const found of newest.slice(-MAX_FILES)) {
|
|
265254
|
+
const fileName = basename9(found.path);
|
|
265255
|
+
if (!ALLOWED.has(extname2(fileName).slice(1).toLowerCase())) {
|
|
265256
|
+
skipped.push({ fileName, reason: "its file type isn't supported" });
|
|
265257
|
+
continue;
|
|
265258
|
+
}
|
|
265259
|
+
let data = await readRegularFile(found.path) ?? (found.claude ? lastCleanWrite(entries, found.path) : undefined);
|
|
265260
|
+
if (!data) {
|
|
265261
|
+
skipped.push({ fileName, reason: "the file isn't on disk anymore" });
|
|
265262
|
+
continue;
|
|
265263
|
+
}
|
|
265264
|
+
if (found.files && /\.html?$/i.test(fileName)) {
|
|
265265
|
+
data = await inlineImages(data, found.files);
|
|
265266
|
+
}
|
|
265267
|
+
if (data.length > MAX_BYTES) {
|
|
265268
|
+
skipped.push({ fileName, reason: "it's larger than 10 MB" });
|
|
265269
|
+
continue;
|
|
265270
|
+
}
|
|
265271
|
+
artifacts.push({ toolUseId: found.toolUseId, fileName, data });
|
|
265272
|
+
}
|
|
265273
|
+
let total = artifacts.reduce((sum, { data }) => sum + data.length, 0);
|
|
265274
|
+
while (total > budget) {
|
|
265275
|
+
const oldest = artifacts.shift();
|
|
265276
|
+
total -= oldest.data.length;
|
|
265277
|
+
skipped.push({
|
|
265278
|
+
fileName: oldest.fileName,
|
|
265279
|
+
reason: "the upload would be over 95 MB"
|
|
265280
|
+
});
|
|
265281
|
+
}
|
|
265282
|
+
return { artifacts, skipped };
|
|
265283
|
+
}
|
|
265284
|
+
|
|
265120
265285
|
// src/core/session-import/images.ts
|
|
265121
|
-
import { stat as
|
|
265122
|
-
import { extname as
|
|
265286
|
+
import { stat as stat5 } from "node:fs/promises";
|
|
265287
|
+
import { extname as extname3 } from "node:path";
|
|
265123
265288
|
var MEDIA_TYPES = {
|
|
265124
265289
|
".png": "image/png",
|
|
265125
265290
|
".jpg": "image/jpeg",
|
|
@@ -265130,8 +265295,8 @@ var MEDIA_TYPES = {
|
|
|
265130
265295
|
var MAX_ATTACHED_IMAGES = 20;
|
|
265131
265296
|
var MAX_ATTACHED_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
265132
265297
|
var IMAGE_PATH = /(?:\/|[A-Za-z]:\\)[^\s"'`<>()]+\.(?:png|jpe?g|gif|webp)\b/gi;
|
|
265133
|
-
var
|
|
265134
|
-
var isImage = (value) => ["image", "input_image"].includes(String(
|
|
265298
|
+
var asRecord2 = (value) => value && typeof value === "object" ? value : {};
|
|
265299
|
+
var isImage = (value) => ["image", "input_image"].includes(String(asRecord2(value).type));
|
|
265135
265300
|
function withoutImages(value) {
|
|
265136
265301
|
if (Array.isArray(value)) {
|
|
265137
265302
|
return value.filter((item) => !isImage(item)).map(withoutImages);
|
|
@@ -265151,32 +265316,32 @@ function strings(value) {
|
|
|
265151
265316
|
}
|
|
265152
265317
|
return [];
|
|
265153
265318
|
}
|
|
265154
|
-
var payloadOf = (entry) =>
|
|
265155
|
-
var messageOf = (entry) =>
|
|
265319
|
+
var payloadOf = (entry) => asRecord2(entry.payload);
|
|
265320
|
+
var messageOf = (entry) => asRecord2(entry.message);
|
|
265156
265321
|
function isTypedUserMessage(entry) {
|
|
265157
265322
|
if (entry.type === "user") {
|
|
265158
265323
|
if (entry.isMeta || entry.isSidechain)
|
|
265159
265324
|
return false;
|
|
265160
|
-
const content =
|
|
265161
|
-
return typeof content === "string" || Array.isArray(content) && !content.some((block) =>
|
|
265325
|
+
const content = asRecord2(entry.message).content;
|
|
265326
|
+
return typeof content === "string" || Array.isArray(content) && !content.some((block) => asRecord2(block).type === "tool_result");
|
|
265162
265327
|
}
|
|
265163
|
-
const payload =
|
|
265328
|
+
const payload = asRecord2(entry.payload);
|
|
265164
265329
|
return entry.type === "response_item" && payload.type === "message" && payload.role === "user";
|
|
265165
265330
|
}
|
|
265166
265331
|
function toolInputs(entries) {
|
|
265167
265332
|
return entries.flatMap((entry) => {
|
|
265168
|
-
const payload =
|
|
265333
|
+
const payload = asRecord2(entry.payload);
|
|
265169
265334
|
if (entry.type === "response_item") {
|
|
265170
265335
|
return String(payload.type).endsWith("_call") ? strings([payload.input, payload.arguments]) : [];
|
|
265171
265336
|
}
|
|
265172
265337
|
const content = messageOf(entry).content;
|
|
265173
|
-
return (Array.isArray(content) ? content : []).filter((block) =>
|
|
265338
|
+
return (Array.isArray(content) ? content : []).filter((block) => asRecord2(block).type === "tool_use").flatMap((block) => strings(asRecord2(block).input));
|
|
265174
265339
|
}).join(`
|
|
265175
265340
|
`);
|
|
265176
265341
|
}
|
|
265177
265342
|
async function imageBlock(path, codex) {
|
|
265178
|
-
const mediaType = MEDIA_TYPES[
|
|
265179
|
-
const size = await
|
|
265343
|
+
const mediaType = MEDIA_TYPES[extname3(path).toLowerCase()];
|
|
265344
|
+
const size = await stat5(path).then((info) => info.isFile() ? info.size : 0, () => 0);
|
|
265180
265345
|
if (!mediaType || !size || size > MAX_ATTACHED_IMAGE_BYTES)
|
|
265181
265346
|
return;
|
|
265182
265347
|
const data = (await readFile(path)).toString("base64");
|
|
@@ -265201,12 +265366,12 @@ async function prepareSessionImages(content) {
|
|
|
265201
265366
|
if (!entry || !lines[i]?.includes("image"))
|
|
265202
265367
|
return;
|
|
265203
265368
|
const message = messageOf(entry);
|
|
265204
|
-
if (entry.type === "user" && Array.isArray(message.content) && message.content.some((block) =>
|
|
265205
|
-
const content = message.content.map((block) =>
|
|
265369
|
+
if (entry.type === "user" && Array.isArray(message.content) && message.content.some((block) => asRecord2(block).type === "tool_result")) {
|
|
265370
|
+
const content = message.content.map((block) => asRecord2(block).type === "tool_result" ? withoutImages(block) : block);
|
|
265206
265371
|
const { toolUseResult: _, ...rest } = entry;
|
|
265207
265372
|
entries[i] = { ...rest, message: { ...message, content } };
|
|
265208
265373
|
changed.add(i);
|
|
265209
|
-
} else if (entry.type === "response_item" && String(
|
|
265374
|
+
} else if (entry.type === "response_item" && String(asRecord2(entry.payload).type).endsWith("_output")) {
|
|
265210
265375
|
entries[i] = { ...entry, payload: withoutImages(entry.payload) };
|
|
265211
265376
|
changed.add(i);
|
|
265212
265377
|
}
|
|
@@ -265250,7 +265415,7 @@ async function prepareSessionImages(content) {
|
|
|
265250
265415
|
|
|
265251
265416
|
// src/core/session-import/sessions.ts
|
|
265252
265417
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
265253
|
-
import { realpath, rm as rm3, stat as
|
|
265418
|
+
import { realpath, rm as rm3, stat as stat6 } from "node:fs/promises";
|
|
265254
265419
|
import { homedir as homedir4 } from "node:os";
|
|
265255
265420
|
import { dirname as dirname23, join as join31 } from "node:path";
|
|
265256
265421
|
import { createInterface as createInterface2 } from "node:readline";
|
|
@@ -265285,12 +265450,12 @@ async function scanLines(path, pick, maxLines = Number.POSITIVE_INFINITY) {
|
|
|
265285
265450
|
}
|
|
265286
265451
|
return;
|
|
265287
265452
|
}
|
|
265288
|
-
var
|
|
265289
|
-
var codexCwd = (entry) => entry.type === "session_meta" ? String(
|
|
265453
|
+
var asRecord3 = (value) => value && typeof value === "object" ? value : {};
|
|
265454
|
+
var codexCwd = (entry) => entry.type === "session_meta" ? String(asRecord3(entry.payload).cwd ?? "") : undefined;
|
|
265290
265455
|
async function newest(paths) {
|
|
265291
265456
|
let best;
|
|
265292
265457
|
for (const path of paths) {
|
|
265293
|
-
const { mtimeMs } = await
|
|
265458
|
+
const { mtimeMs } = await stat6(path);
|
|
265294
265459
|
if (!best || mtimeMs > best.mtime)
|
|
265295
265460
|
best = { path, mtime: mtimeMs };
|
|
265296
265461
|
}
|
|
@@ -265341,11 +265506,11 @@ async function findCurrentSession(cwd) {
|
|
|
265341
265506
|
function claudeUserText(entry) {
|
|
265342
265507
|
if (entry.type !== "user" || entry.isMeta || entry.isSidechain)
|
|
265343
265508
|
return;
|
|
265344
|
-
const content =
|
|
265509
|
+
const content = asRecord3(entry.message).content;
|
|
265345
265510
|
return typeof content === "string" && !content.startsWith("<") ? content : undefined;
|
|
265346
265511
|
}
|
|
265347
265512
|
function codexUserText(entry) {
|
|
265348
|
-
const payload =
|
|
265513
|
+
const payload = asRecord3(entry.payload);
|
|
265349
265514
|
return entry.type === "event_msg" && payload.type === "user_message" ? String(payload.message ?? "") : undefined;
|
|
265350
265515
|
}
|
|
265351
265516
|
var PICKER_LIMIT = 20;
|
|
@@ -265364,7 +265529,7 @@ async function listSessions(cwd) {
|
|
|
265364
265529
|
];
|
|
265365
265530
|
const dated = await Promise.all(candidates.map(async (c) => ({
|
|
265366
265531
|
...c,
|
|
265367
|
-
updatedAt: (await
|
|
265532
|
+
updatedAt: (await stat6(c.path)).mtime
|
|
265368
265533
|
})));
|
|
265369
265534
|
dated.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
265370
265535
|
const sessions = [];
|
|
@@ -265386,7 +265551,7 @@ var TELEPORT_PROMPT = "Reply with OK.";
|
|
|
265386
265551
|
var TELEPORT_NOTE = "This session is being continued from another machine";
|
|
265387
265552
|
function parseLine(line) {
|
|
265388
265553
|
try {
|
|
265389
|
-
return
|
|
265554
|
+
return asRecord3(JSON.parse(line));
|
|
265390
265555
|
} catch {
|
|
265391
265556
|
return {};
|
|
265392
265557
|
}
|
|
@@ -265395,7 +265560,7 @@ function stripTeleportExchange(content) {
|
|
|
265395
265560
|
const lines = content.split(`
|
|
265396
265561
|
`);
|
|
265397
265562
|
const entries = lines.map(parseLine);
|
|
265398
|
-
const userText = (entry) => entry.type === "user" ?
|
|
265563
|
+
const userText = (entry) => entry.type === "user" ? asRecord3(entry.message).content : undefined;
|
|
265399
265564
|
let end = lines.length;
|
|
265400
265565
|
for (let i = lines.length - 1;i >= 0; i--) {
|
|
265401
265566
|
if (userText(entries[i] ?? {}) === TELEPORT_PROMPT) {
|
|
@@ -265442,7 +265607,7 @@ async function teleportSession(sessionId, cwd) {
|
|
|
265442
265607
|
cwd: claudeDir(),
|
|
265443
265608
|
absolute: true
|
|
265444
265609
|
})) {
|
|
265445
|
-
if ((await
|
|
265610
|
+
if ((await stat6(path)).mtimeMs < startedAt)
|
|
265446
265611
|
continue;
|
|
265447
265612
|
const sessionCwd = await scanLines(path, (entry) => typeof entry.cwd === "string" ? entry.cwd : undefined, 50);
|
|
265448
265613
|
if (sessionCwd === repo || sessionCwd === repoReal)
|
|
@@ -265532,22 +265697,47 @@ async function importAction(ctx, link, options, command) {
|
|
|
265532
265697
|
const note = git?.unpushed ? "Base Code started from what's on GitHub; your local changes aren't included." : undefined;
|
|
265533
265698
|
if (!options.token)
|
|
265534
265699
|
await ensureAuth(ctx);
|
|
265700
|
+
const { artifacts, skipped } = await collectArtifacts2(content);
|
|
265535
265701
|
ctx.log.info("This uploads the full conversation to Base Code.");
|
|
265702
|
+
if (artifacts.length) {
|
|
265703
|
+
ctx.log.info(`Sending ${artifacts.length} artifact${artifacts.length === 1 ? "" : "s"}: ${artifacts.map((a) => a.fileName).join(", ")}`);
|
|
265704
|
+
}
|
|
265705
|
+
for (const { fileName, reason } of skipped) {
|
|
265706
|
+
ctx.log.warn(`Not sending ${fileName}: ${reason}.`);
|
|
265707
|
+
}
|
|
265536
265708
|
const imported = await ctx.runTask("Importing session", () => uploadSession(appId, content, {
|
|
265537
265709
|
token: options.token,
|
|
265538
|
-
sourceBranch: git?.branch
|
|
265710
|
+
sourceBranch: git?.branch,
|
|
265711
|
+
artifacts
|
|
265539
265712
|
}));
|
|
265540
265713
|
const url = `${getBase44ApiUrl()}${imported.branchUrl}`;
|
|
265714
|
+
const { importedArtifacts: saved, skippedArtifacts: refused } = imported;
|
|
265715
|
+
const artifactLine = saved || refused ? `Artifacts: ${saved} saved${refused ? `, ${refused} not saved` : ""}.` : undefined;
|
|
265541
265716
|
return {
|
|
265542
265717
|
outroMessage: [
|
|
265543
|
-
imported
|
|
265718
|
+
outcome(imported),
|
|
265719
|
+
...artifactLine ? [artifactLine] : [],
|
|
265544
265720
|
...note ? [note] : [],
|
|
265545
265721
|
`Open it: ${url}`
|
|
265546
265722
|
].join(`
|
|
265547
265723
|
`),
|
|
265548
|
-
stdout: ctx.jsonMode ? toJsonStdout({
|
|
265724
|
+
stdout: ctx.jsonMode ? toJsonStdout({
|
|
265725
|
+
...imported,
|
|
265726
|
+
url,
|
|
265727
|
+
sentArtifacts: artifacts.map((a) => a.fileName),
|
|
265728
|
+
unsentArtifacts: skipped,
|
|
265729
|
+
...note ? { note } : {}
|
|
265730
|
+
}) : undefined
|
|
265549
265731
|
};
|
|
265550
265732
|
}
|
|
265733
|
+
function outcome(imported) {
|
|
265734
|
+
const { turnCount, branchName } = imported;
|
|
265735
|
+
const tool = TOOL_LABELS[imported.source];
|
|
265736
|
+
if (imported.reimported) {
|
|
265737
|
+
return turnCount ? `✓ Added ${turnCount} new messages from ${tool} to "${branchName}".` : `✓ Nothing new to import. "${branchName}" already has every message.`;
|
|
265738
|
+
}
|
|
265739
|
+
return imported.continued ? `✓ Imported ${turnCount} messages from ${tool}. Continued on "${branchName}".` : `✓ Imported ${turnCount} messages from ${tool} into branch "${branchName}".`;
|
|
265740
|
+
}
|
|
265551
265741
|
function getSessionsImportCommand() {
|
|
265552
265742
|
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);
|
|
265553
265743
|
}
|
|
@@ -265558,7 +265748,7 @@ function getSessionsCommand() {
|
|
|
265558
265748
|
}
|
|
265559
265749
|
|
|
265560
265750
|
// src/cli/commands/site/deploy.ts
|
|
265561
|
-
import { resolve as
|
|
265751
|
+
import { resolve as resolve17 } from "node:path";
|
|
265562
265752
|
async function deployAction2(ctx, options) {
|
|
265563
265753
|
const { isNonInteractive } = ctx;
|
|
265564
265754
|
if (isNonInteractive && !options.yes) {
|
|
@@ -265643,7 +265833,7 @@ async function deployArchive({ runTask, jsonMode }, outputDir) {
|
|
|
265643
265833
|
}
|
|
265644
265834
|
function siteOutputDir(project) {
|
|
265645
265835
|
const { outputDirectory = DEFAULT_SITE.outputDirectory } = siteOrDefault(project);
|
|
265646
|
-
return
|
|
265836
|
+
return resolve17(project.root, outputDirectory);
|
|
265647
265837
|
}
|
|
265648
265838
|
function getSiteDeployCommand() {
|
|
265649
265839
|
return new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)").option("--publish", "Serve this build in production once it is deployed").addOption(new Option2("--git-hash <hash>", "Deploy by the commit the build came from, through the deployments API").argParser(parseGitHash)).addOption(new Option2("--concurrency <n>", "Parallel asset uploads").default(DEFAULT_UPLOAD_CONCURRENCY).argParser(parseConcurrency)).action(deployAction2);
|
|
@@ -268420,11 +268610,11 @@ import { relative as relative11 } from "node:path";
|
|
|
268420
268610
|
// ../../node_modules/chokidar/index.js
|
|
268421
268611
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
268422
268612
|
import { stat as statcb, Stats } from "node:fs";
|
|
268423
|
-
import { readdir as readdir3, stat as
|
|
268613
|
+
import { readdir as readdir3, stat as stat10 } from "node:fs/promises";
|
|
268424
268614
|
import * as sp3 from "node:path";
|
|
268425
268615
|
|
|
268426
268616
|
// ../../node_modules/readdirp/index.js
|
|
268427
|
-
import { lstat as lstat2, readdir as readdir2, realpath as realpath2, stat as
|
|
268617
|
+
import { lstat as lstat2, readdir as readdir2, realpath as realpath2, stat as stat8 } from "node:fs/promises";
|
|
268428
268618
|
import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
|
|
268429
268619
|
import { Readable as Readable6 } from "node:stream";
|
|
268430
268620
|
var EntryTypes = {
|
|
@@ -268506,7 +268696,7 @@ class ReaddirpStream extends Readable6 {
|
|
|
268506
268696
|
const { root, type } = opts;
|
|
268507
268697
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
268508
268698
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
268509
|
-
const statMethod = opts.lstat ? lstat2 :
|
|
268699
|
+
const statMethod = opts.lstat ? lstat2 : stat8;
|
|
268510
268700
|
if (wantBigintFsStats) {
|
|
268511
268701
|
this._stat = (path) => statMethod(path, { bigint: true });
|
|
268512
268702
|
} else {
|
|
@@ -268659,7 +268849,7 @@ function readdirp(root, options = {}) {
|
|
|
268659
268849
|
|
|
268660
268850
|
// ../../node_modules/chokidar/handler.js
|
|
268661
268851
|
import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
|
|
268662
|
-
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as
|
|
268852
|
+
import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat9 } from "node:fs/promises";
|
|
268663
268853
|
import { type as osType } from "node:os";
|
|
268664
268854
|
import * as sp2 from "node:path";
|
|
268665
268855
|
var STR_DATA = "data";
|
|
@@ -268685,7 +268875,7 @@ var EVENTS = {
|
|
|
268685
268875
|
};
|
|
268686
268876
|
var EV = EVENTS;
|
|
268687
268877
|
var THROTTLE_MODE_WATCH = "watch";
|
|
268688
|
-
var statMethods = { lstat: lstat3, stat:
|
|
268878
|
+
var statMethods = { lstat: lstat3, stat: stat9 };
|
|
268689
268879
|
var KEY_LISTENERS = "listeners";
|
|
268690
268880
|
var KEY_ERR = "errHandlers";
|
|
268691
268881
|
var KEY_RAW = "rawEmitters";
|
|
@@ -269156,7 +269346,7 @@ class NodeFsHandler {
|
|
|
269156
269346
|
return;
|
|
269157
269347
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
269158
269348
|
try {
|
|
269159
|
-
const newStats = await
|
|
269349
|
+
const newStats = await stat9(file);
|
|
269160
269350
|
if (this.fsw.closed)
|
|
269161
269351
|
return;
|
|
269162
269352
|
const at = newStats.atimeMs;
|
|
@@ -269828,7 +270018,7 @@ class FSWatcher extends EventEmitter3 {
|
|
|
269828
270018
|
const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
|
|
269829
270019
|
let stats;
|
|
269830
270020
|
try {
|
|
269831
|
-
stats = await
|
|
270021
|
+
stats = await stat10(fullPath);
|
|
269832
270022
|
} catch (err) {}
|
|
269833
270023
|
if (!stats || this.closed)
|
|
269834
270024
|
return;
|
|
@@ -270211,16 +270401,14 @@ async function createDevServer(options) {
|
|
|
270211
270401
|
emitEntityEvent = (appId, entityName, event) => {
|
|
270212
270402
|
broadcastEntityEvent(io, appId, entityName, event);
|
|
270213
270403
|
};
|
|
270214
|
-
const functionsDir = join40(dirname29(project.configPath), project.functionsDir);
|
|
270215
270404
|
const base44ConfigWatcher = new WatchBase44({
|
|
270216
|
-
functions: functionsDir,
|
|
270217
|
-
shared: getSharedDir(functionsDir),
|
|
270405
|
+
functions: join40(dirname29(project.configPath), project.functionsDir),
|
|
270218
270406
|
entities: join40(dirname29(project.configPath), project.entitiesDir)
|
|
270219
270407
|
}, devLogger);
|
|
270220
270408
|
base44ConfigWatcher.on("change", async (name) => {
|
|
270221
270409
|
try {
|
|
270222
270410
|
const { functions, entities } = await options.loadResources();
|
|
270223
|
-
if (name === "functions"
|
|
270411
|
+
if (name === "functions") {
|
|
270224
270412
|
const previousFunctionCount = functionManager.getFunctionNames().length;
|
|
270225
270413
|
await functionManager.reload(functions);
|
|
270226
270414
|
const names = functionManager.getFunctionNames();
|
|
@@ -270575,7 +270763,7 @@ Examples:
|
|
|
270575
270763
|
}
|
|
270576
270764
|
|
|
270577
270765
|
// src/cli/commands/project/eject.ts
|
|
270578
|
-
import { resolve as
|
|
270766
|
+
import { resolve as resolve21 } from "node:path";
|
|
270579
270767
|
var import_kebabCase2 = __toESM(require_kebabCase(), 1);
|
|
270580
270768
|
async function eject(ctx, options, command) {
|
|
270581
270769
|
const { log, runTask, isNonInteractive } = ctx;
|
|
@@ -270639,7 +270827,7 @@ async function eject(ctx, options, command) {
|
|
|
270639
270827
|
Ne("Operation cancelled.");
|
|
270640
270828
|
throw new CLIExitError(0);
|
|
270641
270829
|
}
|
|
270642
|
-
const resolvedPath =
|
|
270830
|
+
const resolvedPath = resolve21(selectedPath);
|
|
270643
270831
|
await runTask("Downloading your project's code...", async (updateMessage) => {
|
|
270644
270832
|
await createProjectFilesForExistingProject({
|
|
270645
270833
|
projectId,
|
|
@@ -274785,4 +274973,4 @@ export {
|
|
|
274785
274973
|
runCLI
|
|
274786
274974
|
};
|
|
274787
274975
|
|
|
274788
|
-
//# debugId=
|
|
274976
|
+
//# debugId=4C7BDDBFD564720964756E2164756E21
|