@base44-preview/cli 0.1.15-pr.630.e926db5 → 0.1.15-pr.630.eac8d78
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 +1291 -828
- package/dist/cli/index.js.map +16 -15
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -142409,7 +142409,7 @@ function parse42(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
142409
142409
|
}
|
|
142410
142410
|
return res;
|
|
142411
142411
|
}
|
|
142412
|
-
async function
|
|
142412
|
+
async function readFile6(file) {
|
|
142413
142413
|
if (isUrlString(file)) {
|
|
142414
142414
|
file = new URL(file);
|
|
142415
142415
|
}
|
|
@@ -156203,7 +156203,7 @@ ${codeblock}`, options8);
|
|
|
156203
156203
|
"\\": "\\"
|
|
156204
156204
|
};
|
|
156205
156205
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
156206
|
-
read_file_default =
|
|
156206
|
+
read_file_default = readFile6;
|
|
156207
156207
|
loadConfigFromPackageJson = process.versions.bun ? async function loadConfigFromBunPackageJson(file) {
|
|
156208
156208
|
const { prettier } = await readBunPackageJson(file);
|
|
156209
156209
|
return prettier;
|
|
@@ -270010,7 +270010,7 @@ function getModelCommand() {
|
|
|
270010
270010
|
}
|
|
270011
270011
|
|
|
270012
270012
|
// src/cli/commands/builder/shared.ts
|
|
270013
|
-
import { mkdir as mkdir3, writeFile as writeFile2 } from "node:fs/promises";
|
|
270013
|
+
import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
270014
270014
|
import { basename as basename6, join as join25, relative as relative6, resolve as resolve8 } from "node:path";
|
|
270015
270015
|
|
|
270016
270016
|
// src/cli/commands/code/render.ts
|
|
@@ -270564,6 +270564,221 @@ async function getPreviewUrl() {
|
|
|
270564
270564
|
return /^https?:\/\//.test(url) ? url : `https://${url}`;
|
|
270565
270565
|
}
|
|
270566
270566
|
|
|
270567
|
+
// src/core/resources/apps/pending.ts
|
|
270568
|
+
var CHOICE_TOOLS = new Set([
|
|
270569
|
+
"ask_clarifying_questions",
|
|
270570
|
+
"ask_plan_questions"
|
|
270571
|
+
]);
|
|
270572
|
+
var SECRET_TOOLS = new Set(["set_secrets"]);
|
|
270573
|
+
var LIST_CHOICE_TOOLS = {
|
|
270574
|
+
select_payment_provider: {
|
|
270575
|
+
key: "providers",
|
|
270576
|
+
question: "Which payment provider?",
|
|
270577
|
+
answer: "provider"
|
|
270578
|
+
}
|
|
270579
|
+
};
|
|
270580
|
+
var PERMISSION_TOOLS = new Set(["request_agent_tool_permissions"]);
|
|
270581
|
+
var BROWSER_TOOLS = new Set([
|
|
270582
|
+
"connect_github_account",
|
|
270583
|
+
"request_oauth_authorization",
|
|
270584
|
+
"register_workspace_connector",
|
|
270585
|
+
"configure_psp_credentials",
|
|
270586
|
+
"plaid_connect"
|
|
270587
|
+
]);
|
|
270588
|
+
var str2 = (v) => typeof v === "string" && v.trim() ? v.trim() : undefined;
|
|
270589
|
+
function parseArgs(raw) {
|
|
270590
|
+
try {
|
|
270591
|
+
const parsed = JSON.parse(raw ?? "");
|
|
270592
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
270593
|
+
} catch {
|
|
270594
|
+
return {};
|
|
270595
|
+
}
|
|
270596
|
+
}
|
|
270597
|
+
function questionsFrom(args) {
|
|
270598
|
+
const raw = Array.isArray(args.questions) ? args.questions : [];
|
|
270599
|
+
return raw.flatMap((q) => {
|
|
270600
|
+
if (!q || typeof q !== "object")
|
|
270601
|
+
return [];
|
|
270602
|
+
const item = q;
|
|
270603
|
+
const question = str2(item.question);
|
|
270604
|
+
if (!question)
|
|
270605
|
+
return [];
|
|
270606
|
+
const options = (Array.isArray(item.options) ? item.options : []).flatMap((o) => {
|
|
270607
|
+
const opt = o;
|
|
270608
|
+
const label = str2(opt?.label);
|
|
270609
|
+
return label ? [{ label, description: str2(opt.description) }] : [];
|
|
270610
|
+
});
|
|
270611
|
+
return [
|
|
270612
|
+
{
|
|
270613
|
+
question,
|
|
270614
|
+
description: str2(item.description),
|
|
270615
|
+
options,
|
|
270616
|
+
multiSelect: item.multi_select === true
|
|
270617
|
+
}
|
|
270618
|
+
];
|
|
270619
|
+
});
|
|
270620
|
+
}
|
|
270621
|
+
function secretsFrom(args) {
|
|
270622
|
+
const raw = Array.isArray(args.secrets_schema) ? args.secrets_schema : [];
|
|
270623
|
+
return raw.flatMap((s) => {
|
|
270624
|
+
const item = s;
|
|
270625
|
+
const name = str2(item?.secretName) ?? str2(item?.name);
|
|
270626
|
+
return name ? [{ name, description: str2(item.description) }] : [];
|
|
270627
|
+
});
|
|
270628
|
+
}
|
|
270629
|
+
function permissionKey(row) {
|
|
270630
|
+
switch (row.type) {
|
|
270631
|
+
case "entity":
|
|
270632
|
+
return row.entity_name ? `entity:${row.entity_name}` : null;
|
|
270633
|
+
case "backend_function":
|
|
270634
|
+
return row.function_name ? `backend_function:${row.function_name}` : null;
|
|
270635
|
+
case "app_user_connector":
|
|
270636
|
+
return row.connector_id ? `app_user_connector:${row.connector_id}` : null;
|
|
270637
|
+
default:
|
|
270638
|
+
return null;
|
|
270639
|
+
}
|
|
270640
|
+
}
|
|
270641
|
+
function permissionsFrom(args) {
|
|
270642
|
+
const raw = Array.isArray(args.requested_permissions) ? args.requested_permissions : [];
|
|
270643
|
+
return raw.flatMap((r) => {
|
|
270644
|
+
const row = r;
|
|
270645
|
+
const key = permissionKey(row);
|
|
270646
|
+
if (!key)
|
|
270647
|
+
return [];
|
|
270648
|
+
const ops = Array.isArray(row.allowed_operations) ? ` (${row.allowed_operations.join(", ")})` : "";
|
|
270649
|
+
const target = str2(row.entity_name) ?? str2(row.function_name) ?? str2(row.connector_name) ?? key;
|
|
270650
|
+
return [
|
|
270651
|
+
{ key, label: `${row.type}: ${target}${ops}`, reason: str2(row.reason) }
|
|
270652
|
+
];
|
|
270653
|
+
});
|
|
270654
|
+
}
|
|
270655
|
+
function guardFrom(results) {
|
|
270656
|
+
const value = typeof results === "string" ? (() => {
|
|
270657
|
+
try {
|
|
270658
|
+
return JSON.parse(results);
|
|
270659
|
+
} catch {
|
|
270660
|
+
return null;
|
|
270661
|
+
}
|
|
270662
|
+
})() : results;
|
|
270663
|
+
if (!value || typeof value !== "object")
|
|
270664
|
+
return null;
|
|
270665
|
+
const g = value;
|
|
270666
|
+
if (!str2(g.guard))
|
|
270667
|
+
return null;
|
|
270668
|
+
return { title: `${g.guard}: needs your approval`, detail: str2(g.reason) };
|
|
270669
|
+
}
|
|
270670
|
+
function humanize(tool) {
|
|
270671
|
+
return tool.replace(/_/g, " ");
|
|
270672
|
+
}
|
|
270673
|
+
function pendingInputs(messages) {
|
|
270674
|
+
const out = [];
|
|
270675
|
+
for (const message of messages) {
|
|
270676
|
+
for (const call of message.tool_calls ?? []) {
|
|
270677
|
+
if (call.status !== "waiting_for_user_input")
|
|
270678
|
+
continue;
|
|
270679
|
+
const args = parseArgs(call.arguments_string);
|
|
270680
|
+
const base = {
|
|
270681
|
+
toolCallId: call.id,
|
|
270682
|
+
messageId: message.id,
|
|
270683
|
+
tool: call.name
|
|
270684
|
+
};
|
|
270685
|
+
const summary = str2(args.summary);
|
|
270686
|
+
if (CHOICE_TOOLS.has(call.name)) {
|
|
270687
|
+
out.push({
|
|
270688
|
+
...base,
|
|
270689
|
+
kind: "choice",
|
|
270690
|
+
title: summary ?? "The agent has a few questions",
|
|
270691
|
+
questions: questionsFrom(args)
|
|
270692
|
+
});
|
|
270693
|
+
} else if (SECRET_TOOLS.has(call.name)) {
|
|
270694
|
+
out.push({
|
|
270695
|
+
...base,
|
|
270696
|
+
kind: "secrets",
|
|
270697
|
+
title: summary ?? "The agent needs secrets",
|
|
270698
|
+
secrets: secretsFrom(args)
|
|
270699
|
+
});
|
|
270700
|
+
} else if (PERMISSION_TOOLS.has(call.name)) {
|
|
270701
|
+
out.push({
|
|
270702
|
+
...base,
|
|
270703
|
+
kind: "permissions",
|
|
270704
|
+
title: summary ?? "Grant the app's agent these permissions?",
|
|
270705
|
+
detail: str2(args.reason),
|
|
270706
|
+
permissions: permissionsFrom(args)
|
|
270707
|
+
});
|
|
270708
|
+
} else if (LIST_CHOICE_TOOLS[call.name]) {
|
|
270709
|
+
const spec = LIST_CHOICE_TOOLS[call.name];
|
|
270710
|
+
const raw = Array.isArray(args[spec.key]) ? args[spec.key] : [];
|
|
270711
|
+
const options = raw.flatMap((o) => {
|
|
270712
|
+
const label = typeof o === "string" ? o : str2(o?.label);
|
|
270713
|
+
return label ? [{ label }] : [];
|
|
270714
|
+
});
|
|
270715
|
+
out.push({
|
|
270716
|
+
...base,
|
|
270717
|
+
kind: "choice",
|
|
270718
|
+
title: summary ?? spec.question,
|
|
270719
|
+
detail: str2(args.reason),
|
|
270720
|
+
questions: [{ question: spec.question, options, multiSelect: false }],
|
|
270721
|
+
answerKey: spec.answer
|
|
270722
|
+
});
|
|
270723
|
+
} else if (BROWSER_TOOLS.has(call.name)) {
|
|
270724
|
+
const integration = str2(args.integration_type);
|
|
270725
|
+
out.push({
|
|
270726
|
+
...base,
|
|
270727
|
+
kind: "browser",
|
|
270728
|
+
title: summary ?? (call.name === "connect_github_account" ? "Connect your GitHub account" : integration ? `Authorize ${integration}` : humanize(call.name)),
|
|
270729
|
+
detail: str2(args.reason),
|
|
270730
|
+
browser: call.name === "connect_github_account" ? { flow: "github" } : {
|
|
270731
|
+
flow: "connector",
|
|
270732
|
+
integrationType: integration,
|
|
270733
|
+
connectorId: str2(args.connector_id),
|
|
270734
|
+
scopes: Array.isArray(args.scopes) ? args.scopes.filter((x) => typeof x === "string") : undefined,
|
|
270735
|
+
forceReconnect: args.force_reconnect === true
|
|
270736
|
+
}
|
|
270737
|
+
});
|
|
270738
|
+
} else if (call.waiting_on?.kind === "choice" || call.waiting_on?.kind === "input") {
|
|
270739
|
+
out.push({
|
|
270740
|
+
...base,
|
|
270741
|
+
kind: "unknown",
|
|
270742
|
+
title: summary ?? humanize(call.name),
|
|
270743
|
+
detail: str2(args.reason)
|
|
270744
|
+
});
|
|
270745
|
+
} else {
|
|
270746
|
+
const guard = guardFrom(call.results);
|
|
270747
|
+
const integration = str2(args.integration_type);
|
|
270748
|
+
out.push({
|
|
270749
|
+
...base,
|
|
270750
|
+
kind: "approval",
|
|
270751
|
+
title: guard?.title ?? (integration ? `Enable ${integration}?` : summary ?? `${humanize(call.name)}?`),
|
|
270752
|
+
detail: guard?.detail ?? (integration ? summary : undefined)
|
|
270753
|
+
});
|
|
270754
|
+
}
|
|
270755
|
+
}
|
|
270756
|
+
}
|
|
270757
|
+
return out;
|
|
270758
|
+
}
|
|
270759
|
+
function choiceAnswers(questions, selections, answerKey) {
|
|
270760
|
+
if (answerKey) {
|
|
270761
|
+
const first = selections[0];
|
|
270762
|
+
return { [answerKey]: first?.labels[0] ?? first?.customText ?? "" };
|
|
270763
|
+
}
|
|
270764
|
+
const answers = questions.flatMap((q, index) => {
|
|
270765
|
+
const sel = selections[index];
|
|
270766
|
+
if (!sel || sel.labels.length === 0 && !sel.customText)
|
|
270767
|
+
return [];
|
|
270768
|
+
const answer = { question_index: index };
|
|
270769
|
+
if (q.multiSelect) {
|
|
270770
|
+
if (sel.labels.length)
|
|
270771
|
+
answer.selected_labels = sel.labels;
|
|
270772
|
+
} else if (sel.labels[0]) {
|
|
270773
|
+
answer.selected_label = sel.labels[0];
|
|
270774
|
+
}
|
|
270775
|
+
if (sel.customText)
|
|
270776
|
+
answer.custom_text = sel.customText;
|
|
270777
|
+
return [answer];
|
|
270778
|
+
});
|
|
270779
|
+
return { answers };
|
|
270780
|
+
}
|
|
270781
|
+
|
|
270567
270782
|
// src/cli/commands/builder/shared.ts
|
|
270568
270783
|
var APP_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
270569
270784
|
var NAME_STOPWORDS = new Set("a an the and or of for with to in on that this its it my our your me".split(" "));
|
|
@@ -270663,6 +270878,126 @@ async function assertBuilderApp(appId) {
|
|
|
270663
270878
|
}
|
|
270664
270879
|
return state;
|
|
270665
270880
|
}
|
|
270881
|
+
function pendingSummary(pending) {
|
|
270882
|
+
return pending.map((p) => ({
|
|
270883
|
+
id: p.toolCallId,
|
|
270884
|
+
kind: p.kind,
|
|
270885
|
+
tool: p.tool,
|
|
270886
|
+
title: p.title,
|
|
270887
|
+
...p.detail ? { detail: p.detail } : {},
|
|
270888
|
+
...p.questions ? { questions: p.questions } : {},
|
|
270889
|
+
...p.answerKey ? { answer_key: p.answerKey } : {},
|
|
270890
|
+
...p.secrets ? { secrets: p.secrets.map((x) => x.name) } : {},
|
|
270891
|
+
...p.permissions ? { permissions: p.permissions } : {},
|
|
270892
|
+
...p.browser ? { browser: p.browser } : {}
|
|
270893
|
+
}));
|
|
270894
|
+
}
|
|
270895
|
+
function hasAnswer(f) {
|
|
270896
|
+
return Boolean(f.approve || f.reject || f.skip || f.choose?.length || f.other || f.grant || f.secret?.length || f.input);
|
|
270897
|
+
}
|
|
270898
|
+
async function secretValue(spec, readStdin) {
|
|
270899
|
+
const eq = spec.indexOf("=");
|
|
270900
|
+
if (eq <= 0) {
|
|
270901
|
+
throw new InvalidInputError(`--secret expects NAME=env:VAR, NAME=file:PATH or NAME=- (got "${spec}").`);
|
|
270902
|
+
}
|
|
270903
|
+
const name = spec.slice(0, eq);
|
|
270904
|
+
const source = spec.slice(eq + 1);
|
|
270905
|
+
if (source === "-")
|
|
270906
|
+
return [name, (await readStdin()).trim()];
|
|
270907
|
+
if (source.startsWith("env:")) {
|
|
270908
|
+
const v = process.env[source.slice(4)];
|
|
270909
|
+
if (!v) {
|
|
270910
|
+
throw new InvalidInputError(`--secret ${name}: environment variable ${source.slice(4)} is empty.`);
|
|
270911
|
+
}
|
|
270912
|
+
return [name, v];
|
|
270913
|
+
}
|
|
270914
|
+
if (source.startsWith("file:")) {
|
|
270915
|
+
return [name, (await readFile4(source.slice(5), "utf8")).trim()];
|
|
270916
|
+
}
|
|
270917
|
+
throw new InvalidInputError(`--secret ${name}: pass the value as env:VAR, file:PATH or - (stdin), never as plain text.`);
|
|
270918
|
+
}
|
|
270919
|
+
async function buildAnswer(pending, f, readStdin) {
|
|
270920
|
+
if (f.reject)
|
|
270921
|
+
return { action: "rejected", input: {} };
|
|
270922
|
+
if (f.input) {
|
|
270923
|
+
try {
|
|
270924
|
+
return {
|
|
270925
|
+
action: "approved",
|
|
270926
|
+
input: JSON.parse(f.input)
|
|
270927
|
+
};
|
|
270928
|
+
} catch {
|
|
270929
|
+
throw new InvalidInputError("--input must be a JSON object.");
|
|
270930
|
+
}
|
|
270931
|
+
}
|
|
270932
|
+
switch (pending.kind) {
|
|
270933
|
+
case "choice": {
|
|
270934
|
+
if (f.skip)
|
|
270935
|
+
return { action: "approved", input: { answers: [] } };
|
|
270936
|
+
const questions = pending.questions ?? [];
|
|
270937
|
+
if (!f.choose?.length && !f.other) {
|
|
270938
|
+
throw new InvalidInputError("This is a question: answer with --choose <label> per question (comma-separate for multi-select), --other <text>, or --skip.");
|
|
270939
|
+
}
|
|
270940
|
+
const selections = questions.map((q, i) => {
|
|
270941
|
+
const raw = f.choose?.[i];
|
|
270942
|
+
const labels = raw ? raw.split(",").map((x) => x.trim()).filter(Boolean) : [];
|
|
270943
|
+
for (const l of labels) {
|
|
270944
|
+
if (!q.options.some((o) => o.label === l)) {
|
|
270945
|
+
throw new InvalidInputError(`"${l}" is not an option for "${q.question}". Options: ${q.options.map((o) => o.label).join(", ")}.`);
|
|
270946
|
+
}
|
|
270947
|
+
}
|
|
270948
|
+
return {
|
|
270949
|
+
labels,
|
|
270950
|
+
...i === questions.length - 1 && f.other ? { customText: f.other } : {}
|
|
270951
|
+
};
|
|
270952
|
+
});
|
|
270953
|
+
return {
|
|
270954
|
+
action: "approved",
|
|
270955
|
+
input: choiceAnswers(questions, selections, pending.answerKey)
|
|
270956
|
+
};
|
|
270957
|
+
}
|
|
270958
|
+
case "permissions": {
|
|
270959
|
+
if (!f.approve && !f.grant) {
|
|
270960
|
+
throw new InvalidInputError("This asks for permissions: --grant key1,key2 (or --approve for all, --reject).");
|
|
270961
|
+
}
|
|
270962
|
+
const all = (pending.permissions ?? []).map((p) => p.key);
|
|
270963
|
+
const keys = f.grant ? f.grant.split(",").map((x) => x.trim()).filter(Boolean) : all;
|
|
270964
|
+
for (const k of keys) {
|
|
270965
|
+
if (!all.includes(k)) {
|
|
270966
|
+
throw new InvalidInputError(`Unknown permission key "${k}". Keys: ${all.join(", ")}.`);
|
|
270967
|
+
}
|
|
270968
|
+
}
|
|
270969
|
+
return { action: "approved", input: { approved_permission_keys: keys } };
|
|
270970
|
+
}
|
|
270971
|
+
case "secrets": {
|
|
270972
|
+
const names = (pending.secrets ?? []).map((x) => x.name);
|
|
270973
|
+
if (!f.secret?.length) {
|
|
270974
|
+
throw new InvalidInputError(`This asks for secrets: --secret NAME=env:VAR for each of ${names.join(", ")}.`);
|
|
270975
|
+
}
|
|
270976
|
+
const values = {};
|
|
270977
|
+
for (const spec of f.secret) {
|
|
270978
|
+
const [name, value] = await secretValue(spec, readStdin);
|
|
270979
|
+
if (!names.includes(name)) {
|
|
270980
|
+
throw new InvalidInputError(`"${name}" is not one of the requested secrets: ${names.join(", ")}.`);
|
|
270981
|
+
}
|
|
270982
|
+
values[name] = value;
|
|
270983
|
+
}
|
|
270984
|
+
const missing = names.filter((n) => !(n in values));
|
|
270985
|
+
if (missing.length) {
|
|
270986
|
+
throw new InvalidInputError(`Missing --secret for: ${missing.join(", ")}.`);
|
|
270987
|
+
}
|
|
270988
|
+
return { action: "approved", input: { secrets: values } };
|
|
270989
|
+
}
|
|
270990
|
+
case "browser":
|
|
270991
|
+
throw new InvalidInputError("This step needs a browser: finish the authorization in the editor (or run `base44 code`, which opens the link and waits), then answer with --approve.");
|
|
270992
|
+
case "unknown":
|
|
270993
|
+
throw new InvalidInputError("This question needs the editor — answer it there, or --reject.");
|
|
270994
|
+
default:
|
|
270995
|
+
if (!f.approve) {
|
|
270996
|
+
throw new InvalidInputError("This is an approval: --approve or --reject.");
|
|
270997
|
+
}
|
|
270998
|
+
return { action: "approved", input: {} };
|
|
270999
|
+
}
|
|
271000
|
+
}
|
|
270666
271001
|
function nextStepsLines(app) {
|
|
270667
271002
|
const cd = app.here ? "" : `cd ${app.dirName} && `;
|
|
270668
271003
|
return [
|
|
@@ -270817,7 +271152,8 @@ function diffConversation(state, messages) {
|
|
|
270817
271152
|
kind: "waiting",
|
|
270818
271153
|
id: tool.id,
|
|
270819
271154
|
name: tool.name,
|
|
270820
|
-
label: labelTense(meta.label, "running")
|
|
271155
|
+
label: labelTense(meta.label, "running"),
|
|
271156
|
+
pending: pendingInputs([message]).find((p) => p.toolCallId === tool.id)
|
|
270821
271157
|
});
|
|
270822
271158
|
}
|
|
270823
271159
|
if (TOOL_SETTLED.has(status) && !progress.settledTools.has(tool.id)) {
|
|
@@ -270920,70 +271256,157 @@ function ndjsonWriter() {
|
|
|
270920
271256
|
return (record) => process.stdout.write(`${JSON.stringify(record)}
|
|
270921
271257
|
`);
|
|
270922
271258
|
}
|
|
271259
|
+
async function readStdin2() {
|
|
271260
|
+
const chunks = [];
|
|
271261
|
+
for await (const chunk of process.stdin)
|
|
271262
|
+
chunks.push(chunk);
|
|
271263
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
271264
|
+
}
|
|
271265
|
+
function turnResult(turn, pending) {
|
|
271266
|
+
if (turn.queued)
|
|
271267
|
+
return { queued: true };
|
|
271268
|
+
const base = {
|
|
271269
|
+
status: pending.length ? "waiting" : turn.status?.state ?? "ready",
|
|
271270
|
+
error_source: turn.status?.error_source ?? null,
|
|
271271
|
+
reply: lastAssistantReply(turn) ?? null
|
|
271272
|
+
};
|
|
271273
|
+
return pending.length ? { ...base, pending: pendingSummary(pending) } : base;
|
|
271274
|
+
}
|
|
271275
|
+
async function applyPolicy(pending, options, branchId, onEvent) {
|
|
271276
|
+
let current = pending;
|
|
271277
|
+
for (let round = 0;round < 10 && current.length; round++) {
|
|
271278
|
+
const target = current.find((p) => options.autoApprove && (p.kind === "approval" || p.kind === "permissions") || options.skipQuestions && p.kind === "choice");
|
|
271279
|
+
if (!target)
|
|
271280
|
+
break;
|
|
271281
|
+
const input = target.kind === "permissions" ? {
|
|
271282
|
+
approved_permission_keys: (target.permissions ?? []).map((p) => p.key)
|
|
271283
|
+
} : target.kind === "choice" ? { answers: [] } : {};
|
|
271284
|
+
await streamConversationDuring(() => answerToolCall({
|
|
271285
|
+
toolCallId: target.toolCallId,
|
|
271286
|
+
messageId: target.messageId,
|
|
271287
|
+
action: "approved",
|
|
271288
|
+
input
|
|
271289
|
+
}, branchId), onEvent, { branchId });
|
|
271290
|
+
current = pendingInputs(await getFullConversation(30, branchId));
|
|
271291
|
+
}
|
|
271292
|
+
return current;
|
|
271293
|
+
}
|
|
270923
271294
|
async function sendAction(ctx, message, options) {
|
|
270924
271295
|
if (options.streamJson && ctx.jsonMode) {
|
|
270925
271296
|
throw new InvalidInputError("--stream-json and --json are exclusive.");
|
|
270926
271297
|
}
|
|
271298
|
+
const answering = hasAnswer(options);
|
|
271299
|
+
if (answering && message) {
|
|
271300
|
+
throw new InvalidInputError("Either send a message or answer the pending question (--approve / --choose / …), not both.");
|
|
271301
|
+
}
|
|
271302
|
+
if (!answering && !message) {
|
|
271303
|
+
throw new InvalidInputError('Send a message ("<message>") or answer what the agent asked (--approve, --reject, --choose, --grant, --secret, --skip, --input).');
|
|
271304
|
+
}
|
|
270927
271305
|
if (ctx.app)
|
|
270928
271306
|
await assertBuilderApp(ctx.app.id);
|
|
270929
271307
|
const branchId = await resolveBranchId(ctx);
|
|
271308
|
+
const pendingBefore = pendingInputs(await getFullConversation(30, branchId).catch(() => []));
|
|
271309
|
+
let start;
|
|
271310
|
+
if (answering) {
|
|
271311
|
+
if (pendingBefore.length === 0) {
|
|
271312
|
+
throw new InvalidInputError("Nothing is waiting for an answer — send a message instead.");
|
|
271313
|
+
}
|
|
271314
|
+
const target = options.id ? pendingBefore.find((p) => p.toolCallId === options.id) : pendingBefore.length === 1 ? pendingBefore[0] : undefined;
|
|
271315
|
+
if (!target) {
|
|
271316
|
+
throw new InvalidInputError(options.id ? `No pending call with id ${options.id}. Pending: ${pendingBefore.map((p) => p.toolCallId).join(", ")}.` : `Several calls are waiting — pick one with --id: ${pendingBefore.map((p) => `${p.toolCallId} (${p.kind}: ${p.title})`).join("; ")}.`);
|
|
271317
|
+
}
|
|
271318
|
+
const answer = await buildAnswer(target, options, readStdin2);
|
|
271319
|
+
start = () => answerToolCall({
|
|
271320
|
+
toolCallId: target.toolCallId,
|
|
271321
|
+
messageId: target.messageId,
|
|
271322
|
+
action: answer.action,
|
|
271323
|
+
input: answer.input
|
|
271324
|
+
}, branchId);
|
|
271325
|
+
} else {
|
|
271326
|
+
if (pendingBefore.length) {
|
|
271327
|
+
const record = {
|
|
271328
|
+
status: "waiting",
|
|
271329
|
+
pending: pendingSummary(pendingBefore)
|
|
271330
|
+
};
|
|
271331
|
+
if (options.streamJson) {
|
|
271332
|
+
ndjsonWriter()({ type: "result", ...record });
|
|
271333
|
+
return {};
|
|
271334
|
+
}
|
|
271335
|
+
if (ctx.jsonMode)
|
|
271336
|
+
return { stdout: `${JSON.stringify(record)}
|
|
271337
|
+
` };
|
|
271338
|
+
throw new InvalidInputError(`The agent is waiting on you before it can take a message: ${pendingBefore.map((p) => `${p.title} (${p.kind})`).join("; ")}. Answer with --approve / --choose / --grant / --secret, or --reject.`);
|
|
271339
|
+
}
|
|
271340
|
+
const text = message;
|
|
271341
|
+
start = () => sendTurn(text, branchId);
|
|
271342
|
+
}
|
|
271343
|
+
const finish = async (turn, onEvent) => {
|
|
271344
|
+
let pending = turn.queued ? [] : pendingInputs(await getFullConversation(30, branchId).catch(() => []));
|
|
271345
|
+
if (pending.length && (options.autoApprove || options.skipQuestions)) {
|
|
271346
|
+
pending = await applyPolicy(pending, options, branchId, onEvent);
|
|
271347
|
+
}
|
|
271348
|
+
return turnResult(turn, pending);
|
|
271349
|
+
};
|
|
270930
271350
|
if (options.streamJson) {
|
|
270931
271351
|
const write = ndjsonWriter();
|
|
270932
|
-
const
|
|
270933
|
-
|
|
270934
|
-
|
|
270935
|
-
|
|
270936
|
-
status: turn.status?.state ?? "ready",
|
|
270937
|
-
error_source: turn.status?.error_source ?? null,
|
|
270938
|
-
reply: lastAssistantReply(turn) ?? null
|
|
270939
|
-
});
|
|
271352
|
+
const onEvent = ({ kind, ...event }) => write({ type: kind, ...event });
|
|
271353
|
+
const turn = await streamConversationDuring(start, onEvent, { branchId });
|
|
271354
|
+
const result = await finish(turn, onEvent);
|
|
271355
|
+
write({ type: "result", queued: result.queued === true, ...result });
|
|
270940
271356
|
return {};
|
|
270941
271357
|
}
|
|
270942
271358
|
if (ctx.jsonMode) {
|
|
270943
|
-
const turn = await ctx.runTask("Agent working (a turn can take minutes)",
|
|
270944
|
-
if (turn.queued)
|
|
270945
|
-
return { stdout: `${JSON.stringify({ queued: true })}
|
|
270946
|
-
` };
|
|
271359
|
+
const turn = await ctx.runTask("Agent working (a turn can take minutes)", start);
|
|
270947
271360
|
return {
|
|
270948
|
-
stdout: `${JSON.stringify({
|
|
270949
|
-
|
|
270950
|
-
|
|
270951
|
-
reply: lastAssistantReply(turn) ?? null
|
|
270952
|
-
})}
|
|
271361
|
+
stdout: `${JSON.stringify(await finish(turn, () => {
|
|
271362
|
+
return;
|
|
271363
|
+
}))}
|
|
270953
271364
|
`
|
|
270954
271365
|
};
|
|
270955
271366
|
}
|
|
270956
271367
|
const stream = createTurnStream(process.stdout.isTTY === true, undefined, {
|
|
270957
271368
|
verbose: options.verbose
|
|
270958
271369
|
});
|
|
270959
|
-
let
|
|
271370
|
+
let result;
|
|
270960
271371
|
try {
|
|
270961
|
-
turn = await streamConversationDuring(
|
|
271372
|
+
const turn = await streamConversationDuring(start, stream.onEvent, {
|
|
271373
|
+
branchId
|
|
271374
|
+
});
|
|
271375
|
+
result = await finish(turn, stream.onEvent);
|
|
270962
271376
|
} finally {
|
|
270963
271377
|
stream.stop();
|
|
270964
271378
|
}
|
|
270965
|
-
if (
|
|
271379
|
+
if (result.queued === true) {
|
|
270966
271380
|
return {
|
|
270967
271381
|
outroMessage: "The agent is busy with an earlier message — yours was queued and runs next."
|
|
270968
271382
|
};
|
|
270969
271383
|
}
|
|
270970
|
-
if (
|
|
271384
|
+
if (result.status === "waiting") {
|
|
271385
|
+
for (const p of result.pending) {
|
|
271386
|
+
ctx.log.message(` ⏸ ${p.title} (${p.kind})`);
|
|
271387
|
+
}
|
|
271388
|
+
return {
|
|
271389
|
+
outroMessage: "The agent is waiting on you. Answer with `base44 builder send --approve` (or --choose, --grant, --secret, --reject), or open `base44 code`."
|
|
271390
|
+
};
|
|
271391
|
+
}
|
|
271392
|
+
if (result.status === "error") {
|
|
270971
271393
|
return {
|
|
270972
|
-
outroMessage: `Turn failed (${
|
|
271394
|
+
outroMessage: result.error_source === "paywall" ? "The workspace is out of credits — nothing ran." : `Turn failed (${result.error_source ?? "unknown"}) — see the editor for details.`
|
|
270973
271395
|
};
|
|
270974
271396
|
}
|
|
270975
271397
|
return { outroMessage: "Turn finished." };
|
|
270976
271398
|
}
|
|
271399
|
+
var collect = (v, acc = []) => [...acc, v];
|
|
270977
271400
|
function getSendCommand() {
|
|
270978
271401
|
const command = new Base44Command("send", { supportsBranch: true });
|
|
270979
|
-
command.description(
|
|
271402
|
+
command.description('Send the agent one message and stream the turn until it finishes — or answer what it asked (--approve, --choose, …). A result with status "waiting" lists what the agent needs; the next send answers it.').argument("[message]", "What you want the agent to do").option("--approve", "Approve the pending call (permissions: grant all)").option("--reject", "Reject the pending call").option("--skip", "Skip the pending questions; the agent decides").option("--choose <label>", "Answer a question by option label; repeat per question, comma-separate for multi-select", collect).option("--other <text>", "Free-text answer for the last question").option("--grant <keys>", "Permission keys to grant, comma-separated").option("--secret <NAME=source>", "A requested secret from env:VAR, file:PATH or - (stdin); repeat per secret", collect).option("--input <json>", "Raw extra_user_input for the pending call").option("--id <tool-call-id>", "Which pending call to answer when several wait").option("--auto-approve", "Policy: approve approval-kind pauses (never secrets or browser steps)").option("--skip-questions", "Policy: skip clarifying questions; the agent decides").option("--verbose", "Show every tool result in full (no folding)").option("--stream-json", "Emit each stream event as a JSON line as it happens, then a final result line").action(sendAction);
|
|
270980
271403
|
return command;
|
|
270981
271404
|
}
|
|
270982
271405
|
|
|
270983
271406
|
// src/cli/commands/builder/new.ts
|
|
270984
271407
|
var POLL_TIMEOUT_MS = 20 * 60000;
|
|
270985
271408
|
var MODES = ["direct", "fork", "copy"];
|
|
270986
|
-
async function
|
|
271409
|
+
async function readStdin3() {
|
|
270987
271410
|
const chunks = [];
|
|
270988
271411
|
for await (const chunk of process.stdin)
|
|
270989
271412
|
chunks.push(chunk);
|
|
@@ -271002,7 +271425,7 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271002
271425
|
if (options.wixClientId && !options.wixInstance) {
|
|
271003
271426
|
throw new InvalidInputError("--wix-client-id applies only with --wix-instance.");
|
|
271004
271427
|
}
|
|
271005
|
-
const signedInstance = options.wixInstance ? (options.wixInstance === "-" ? await
|
|
271428
|
+
const signedInstance = options.wixInstance ? (options.wixInstance === "-" ? await readStdin3() : options.wixInstance).trim() : undefined;
|
|
271006
271429
|
if (options.wixInstance && !signedInstance) {
|
|
271007
271430
|
throw new InvalidInputError("--wix-instance is empty.");
|
|
271008
271431
|
}
|
|
@@ -271055,6 +271478,7 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271055
271478
|
}
|
|
271056
271479
|
let finalState;
|
|
271057
271480
|
let previewUrl;
|
|
271481
|
+
let pending = [];
|
|
271058
271482
|
const startedAt = Date.now();
|
|
271059
271483
|
if (prompt) {
|
|
271060
271484
|
const branchId = await resolveActiveBranchId().catch(() => {
|
|
@@ -271073,6 +271497,20 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271073
271497
|
stream.onEvent(event);
|
|
271074
271498
|
}, { branchId, timeoutMs: POLL_TIMEOUT_MS });
|
|
271075
271499
|
finalState = settled === "timeout" ? "processing" : (await getAppState(app.id)).status?.state ?? "ready";
|
|
271500
|
+
if (settled === "settled") {
|
|
271501
|
+
pending = pendingInputs(await getFullConversation(30, branchId).catch(() => []));
|
|
271502
|
+
if (pending.length && (options.autoApprove || options.skipQuestions)) {
|
|
271503
|
+
pending = await applyPolicy(pending, options, branchId, (event) => {
|
|
271504
|
+
if (ndjson) {
|
|
271505
|
+
const { kind, ...rest } = event;
|
|
271506
|
+
ndjson({ type: kind, ...rest });
|
|
271507
|
+
} else if (!jsonMode)
|
|
271508
|
+
stream.onEvent(event);
|
|
271509
|
+
});
|
|
271510
|
+
}
|
|
271511
|
+
if (pending.length)
|
|
271512
|
+
finalState = "waiting";
|
|
271513
|
+
}
|
|
271076
271514
|
if (finalState === "ready") {
|
|
271077
271515
|
previewUrl = await getPreviewUrl().catch(() => {
|
|
271078
271516
|
return;
|
|
@@ -271087,7 +271525,8 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271087
271525
|
type: "result",
|
|
271088
271526
|
id: app.id,
|
|
271089
271527
|
preview_url: previewUrl ?? null,
|
|
271090
|
-
status: finalState ?? "created"
|
|
271528
|
+
status: finalState ?? "created",
|
|
271529
|
+
...pending.length ? { pending: pendingSummary(pending) } : {}
|
|
271091
271530
|
});
|
|
271092
271531
|
return {};
|
|
271093
271532
|
}
|
|
@@ -271101,6 +271540,7 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271101
271540
|
dir: app.dirName,
|
|
271102
271541
|
path: app.targetDir,
|
|
271103
271542
|
status: finalState ?? "created",
|
|
271543
|
+
...pending.length ? { pending: pendingSummary(pending) } : {},
|
|
271104
271544
|
...app.clientCreationId ? { client_creation_id: app.clientCreationId } : {}
|
|
271105
271545
|
})}
|
|
271106
271546
|
`
|
|
@@ -271110,6 +271550,13 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271110
271550
|
log.message(`preview ${previewUrl}`);
|
|
271111
271551
|
for (const line of nextStepsLines(app))
|
|
271112
271552
|
log.message(line);
|
|
271553
|
+
if (finalState === "waiting") {
|
|
271554
|
+
for (const p of pending)
|
|
271555
|
+
log.message(` ⏸ ${p.title} (${p.kind})`);
|
|
271556
|
+
return {
|
|
271557
|
+
outroMessage: "The agent is waiting on you. Answer with `base44 builder send --approve` (or --choose, --grant, --secret), or open `base44 code`."
|
|
271558
|
+
};
|
|
271559
|
+
}
|
|
271113
271560
|
if (finalState === "error") {
|
|
271114
271561
|
return {
|
|
271115
271562
|
outroMessage: `The first build reported an error — open the editor for details.`
|
|
@@ -271126,29 +271573,43 @@ async function newAction({ log, runTask, jsonMode }, prompt, options) {
|
|
|
271126
271573
|
}
|
|
271127
271574
|
function getNewCommand() {
|
|
271128
271575
|
const command = new Base44Command("new", { requireAppContext: false });
|
|
271129
|
-
command.description("Create an app and start building: from a prompt (the Base44 template), or over an existing GitHub repo with --import").argument("[prompt]", "What to build; the first agent turn starts immediately").option("--import <repo>", "Build over an existing GitHub repository instead of the template").option("--mode <mode>", "How to import: direct, fork, or copy (default: direct)").option("--name <name>", "Directory and app name (invented when omitted)").option("--path <dir>", "Directory to link (default: the current directory when empty, else ./<name>)").option("--repo-name <name>", "Name for the new GitHub repo when forking/copying").option("--from-branch <name>", "Import a specific branch of the repo").addOption(new Option2("--wix-instance <token>", 'Create through the Wix route with this signed instance (the Wix connector is connected before the first turn); "-" reads the token from stdin').env("BASE44_WIX_INSTANCE")).option("--wix-client-id <id>", "The companion OAuth app's client id, when the Wix launch has one").option("--verbose", "Show every tool result in full (no folding)").option("--stream-json", "Emit each stream event as a JSON line as it happens, then a final result line").action(newAction);
|
|
271576
|
+
command.description("Create an app and start building: from a prompt (the Base44 template), or over an existing GitHub repo with --import").argument("[prompt]", "What to build; the first agent turn starts immediately").option("--import <repo>", "Build over an existing GitHub repository instead of the template").option("--mode <mode>", "How to import: direct, fork, or copy (default: direct)").option("--name <name>", "Directory and app name (invented when omitted)").option("--path <dir>", "Directory to link (default: the current directory when empty, else ./<name>)").option("--repo-name <name>", "Name for the new GitHub repo when forking/copying").option("--from-branch <name>", "Import a specific branch of the repo").addOption(new Option2("--wix-instance <token>", 'Create through the Wix route with this signed instance (the Wix connector is connected before the first turn); "-" reads the token from stdin').env("BASE44_WIX_INSTANCE")).option("--wix-client-id <id>", "The companion OAuth app's client id, when the Wix launch has one").option("--auto-approve", "Policy: approve approval-kind pauses in the first build (never secrets or browser steps)").option("--skip-questions", "Policy: skip clarifying questions; the agent decides").option("--verbose", "Show every tool result in full (no folding)").option("--stream-json", "Emit each stream event as a JSON line as it happens, then a final result line").action(newAction);
|
|
271130
271577
|
return command;
|
|
271131
271578
|
}
|
|
271132
271579
|
|
|
271133
271580
|
// src/cli/commands/builder/status.ts
|
|
271134
271581
|
async function statusAction(ctx) {
|
|
271135
271582
|
const id = ctx.app?.id;
|
|
271136
|
-
const
|
|
271137
|
-
const
|
|
271583
|
+
const branchId = await resolveBranchId(ctx);
|
|
271584
|
+
const [app, messages] = await ctx.runTask("Reading app status", () => Promise.all([
|
|
271585
|
+
getAppState(id),
|
|
271586
|
+
getFullConversation(30, branchId).catch(() => [])
|
|
271587
|
+
]));
|
|
271588
|
+
const pending = pendingInputs(messages);
|
|
271589
|
+
const state = pending.length ? "waiting" : app.status?.state ?? "ready";
|
|
271138
271590
|
if (ctx.jsonMode) {
|
|
271139
271591
|
return {
|
|
271140
|
-
stdout: `${JSON.stringify({
|
|
271592
|
+
stdout: `${JSON.stringify({
|
|
271593
|
+
id: app.id,
|
|
271594
|
+
state,
|
|
271595
|
+
message: app.status?.message ?? null,
|
|
271596
|
+
...pending.length ? { pending: pendingSummary(pending) } : {}
|
|
271597
|
+
})}
|
|
271141
271598
|
`
|
|
271142
271599
|
};
|
|
271143
271600
|
}
|
|
271144
271601
|
ctx.log.message(`State: ${state}`);
|
|
271145
271602
|
if (app.status?.message)
|
|
271146
271603
|
ctx.log.message(`Note: ${app.status.message}`);
|
|
271147
|
-
|
|
271604
|
+
for (const p of pending)
|
|
271605
|
+
ctx.log.message(` ⏸ ${p.title} (${p.kind})`);
|
|
271606
|
+
return {
|
|
271607
|
+
outroMessage: pending.length ? "The agent is waiting on you — `base44 builder send --approve` (or --choose, --grant, --secret) answers it." : "Status read."
|
|
271608
|
+
};
|
|
271148
271609
|
}
|
|
271149
271610
|
function getStatusCommand() {
|
|
271150
|
-
const command = new Base44Command("status");
|
|
271151
|
-
command.description("Show whether the app is building, ready, or
|
|
271611
|
+
const command = new Base44Command("status", { supportsBranch: true });
|
|
271612
|
+
command.description("Show whether the app is building, ready, errored — or waiting on you, and for what").action(statusAction);
|
|
271152
271613
|
return command;
|
|
271153
271614
|
}
|
|
271154
271615
|
|
|
@@ -276132,6 +276593,612 @@ function TextInput({ value: originalValue, placeholder = "", focus = true, mask,
|
|
|
276132
276593
|
}
|
|
276133
276594
|
var build_default = TextInput;
|
|
276134
276595
|
|
|
276596
|
+
// ../../node_modules/open/index.js
|
|
276597
|
+
import process30 from "node:process";
|
|
276598
|
+
import path16 from "node:path";
|
|
276599
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
276600
|
+
import childProcess3 from "node:child_process";
|
|
276601
|
+
import fs20, { constants as fsConstants2 } from "node:fs/promises";
|
|
276602
|
+
|
|
276603
|
+
// ../../node_modules/wsl-utils/index.js
|
|
276604
|
+
import { promisify as promisify6 } from "node:util";
|
|
276605
|
+
import childProcess2 from "node:child_process";
|
|
276606
|
+
import fs19, { constants as fsConstants } from "node:fs/promises";
|
|
276607
|
+
|
|
276608
|
+
// ../../node_modules/is-wsl/index.js
|
|
276609
|
+
import process24 from "node:process";
|
|
276610
|
+
import os4 from "node:os";
|
|
276611
|
+
import fs18 from "node:fs";
|
|
276612
|
+
|
|
276613
|
+
// ../../node_modules/is-inside-container/index.js
|
|
276614
|
+
import fs17 from "node:fs";
|
|
276615
|
+
|
|
276616
|
+
// ../../node_modules/is-docker/index.js
|
|
276617
|
+
import fs16 from "node:fs";
|
|
276618
|
+
var isDockerCached;
|
|
276619
|
+
function hasDockerEnv() {
|
|
276620
|
+
try {
|
|
276621
|
+
fs16.statSync("/.dockerenv");
|
|
276622
|
+
return true;
|
|
276623
|
+
} catch {
|
|
276624
|
+
return false;
|
|
276625
|
+
}
|
|
276626
|
+
}
|
|
276627
|
+
function hasDockerCGroup() {
|
|
276628
|
+
try {
|
|
276629
|
+
return fs16.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
276630
|
+
} catch {
|
|
276631
|
+
return false;
|
|
276632
|
+
}
|
|
276633
|
+
}
|
|
276634
|
+
function isDocker() {
|
|
276635
|
+
if (isDockerCached === undefined) {
|
|
276636
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
276637
|
+
}
|
|
276638
|
+
return isDockerCached;
|
|
276639
|
+
}
|
|
276640
|
+
|
|
276641
|
+
// ../../node_modules/is-inside-container/index.js
|
|
276642
|
+
var cachedResult;
|
|
276643
|
+
var hasContainerEnv = () => {
|
|
276644
|
+
try {
|
|
276645
|
+
fs17.statSync("/run/.containerenv");
|
|
276646
|
+
return true;
|
|
276647
|
+
} catch {
|
|
276648
|
+
return false;
|
|
276649
|
+
}
|
|
276650
|
+
};
|
|
276651
|
+
function isInsideContainer() {
|
|
276652
|
+
if (cachedResult === undefined) {
|
|
276653
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
276654
|
+
}
|
|
276655
|
+
return cachedResult;
|
|
276656
|
+
}
|
|
276657
|
+
|
|
276658
|
+
// ../../node_modules/is-wsl/index.js
|
|
276659
|
+
var isWsl = () => {
|
|
276660
|
+
if (process24.platform !== "linux") {
|
|
276661
|
+
return false;
|
|
276662
|
+
}
|
|
276663
|
+
if (os4.release().toLowerCase().includes("microsoft")) {
|
|
276664
|
+
if (isInsideContainer()) {
|
|
276665
|
+
return false;
|
|
276666
|
+
}
|
|
276667
|
+
return true;
|
|
276668
|
+
}
|
|
276669
|
+
try {
|
|
276670
|
+
return fs18.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
276671
|
+
} catch {
|
|
276672
|
+
return false;
|
|
276673
|
+
}
|
|
276674
|
+
};
|
|
276675
|
+
var is_wsl_default = process24.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
276676
|
+
|
|
276677
|
+
// ../../node_modules/powershell-utils/index.js
|
|
276678
|
+
import process25 from "node:process";
|
|
276679
|
+
import { Buffer as Buffer7 } from "node:buffer";
|
|
276680
|
+
import { promisify as promisify5 } from "node:util";
|
|
276681
|
+
import childProcess from "node:child_process";
|
|
276682
|
+
var execFile = promisify5(childProcess.execFile);
|
|
276683
|
+
var powerShellPath = () => `${process25.env.SYSTEMROOT || process25.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
276684
|
+
var executePowerShell = async (command, options = {}) => {
|
|
276685
|
+
const {
|
|
276686
|
+
powerShellPath: psPath,
|
|
276687
|
+
...execFileOptions
|
|
276688
|
+
} = options;
|
|
276689
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
276690
|
+
return execFile(psPath ?? powerShellPath(), [
|
|
276691
|
+
...executePowerShell.argumentsPrefix,
|
|
276692
|
+
encodedCommand
|
|
276693
|
+
], {
|
|
276694
|
+
encoding: "utf8",
|
|
276695
|
+
...execFileOptions
|
|
276696
|
+
});
|
|
276697
|
+
};
|
|
276698
|
+
executePowerShell.argumentsPrefix = [
|
|
276699
|
+
"-NoProfile",
|
|
276700
|
+
"-NonInteractive",
|
|
276701
|
+
"-ExecutionPolicy",
|
|
276702
|
+
"Bypass",
|
|
276703
|
+
"-EncodedCommand"
|
|
276704
|
+
];
|
|
276705
|
+
executePowerShell.encodeCommand = (command) => Buffer7.from(command, "utf16le").toString("base64");
|
|
276706
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
276707
|
+
|
|
276708
|
+
// ../../node_modules/wsl-utils/utilities.js
|
|
276709
|
+
function parseMountPointFromConfig(content) {
|
|
276710
|
+
for (const line of content.split(`
|
|
276711
|
+
`)) {
|
|
276712
|
+
if (/^\s*#/.test(line)) {
|
|
276713
|
+
continue;
|
|
276714
|
+
}
|
|
276715
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
276716
|
+
if (!match) {
|
|
276717
|
+
continue;
|
|
276718
|
+
}
|
|
276719
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
276720
|
+
}
|
|
276721
|
+
}
|
|
276722
|
+
|
|
276723
|
+
// ../../node_modules/wsl-utils/index.js
|
|
276724
|
+
var execFile2 = promisify6(childProcess2.execFile);
|
|
276725
|
+
var wslDrivesMountPoint = (() => {
|
|
276726
|
+
const defaultMountPoint = "/mnt/";
|
|
276727
|
+
let mountPoint;
|
|
276728
|
+
return async function() {
|
|
276729
|
+
if (mountPoint) {
|
|
276730
|
+
return mountPoint;
|
|
276731
|
+
}
|
|
276732
|
+
const configFilePath = "/etc/wsl.conf";
|
|
276733
|
+
let isConfigFileExists = false;
|
|
276734
|
+
try {
|
|
276735
|
+
await fs19.access(configFilePath, fsConstants.F_OK);
|
|
276736
|
+
isConfigFileExists = true;
|
|
276737
|
+
} catch {}
|
|
276738
|
+
if (!isConfigFileExists) {
|
|
276739
|
+
return defaultMountPoint;
|
|
276740
|
+
}
|
|
276741
|
+
const configContent = await fs19.readFile(configFilePath, { encoding: "utf8" });
|
|
276742
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
276743
|
+
if (parsedMountPoint === undefined) {
|
|
276744
|
+
return defaultMountPoint;
|
|
276745
|
+
}
|
|
276746
|
+
mountPoint = parsedMountPoint;
|
|
276747
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
276748
|
+
return mountPoint;
|
|
276749
|
+
};
|
|
276750
|
+
})();
|
|
276751
|
+
var powerShellPathFromWsl = async () => {
|
|
276752
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
276753
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
276754
|
+
};
|
|
276755
|
+
var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
276756
|
+
var canAccessPowerShellPromise;
|
|
276757
|
+
var canAccessPowerShell = async () => {
|
|
276758
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
276759
|
+
try {
|
|
276760
|
+
const psPath = await powerShellPath2();
|
|
276761
|
+
await fs19.access(psPath, fsConstants.X_OK);
|
|
276762
|
+
return true;
|
|
276763
|
+
} catch {
|
|
276764
|
+
return false;
|
|
276765
|
+
}
|
|
276766
|
+
})();
|
|
276767
|
+
return canAccessPowerShellPromise;
|
|
276768
|
+
};
|
|
276769
|
+
var wslDefaultBrowser = async () => {
|
|
276770
|
+
const psPath = await powerShellPath2();
|
|
276771
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
276772
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
276773
|
+
return stdout.trim();
|
|
276774
|
+
};
|
|
276775
|
+
var convertWslPathToWindows = async (path) => {
|
|
276776
|
+
if (/^[a-z]+:\/\//i.test(path)) {
|
|
276777
|
+
return path;
|
|
276778
|
+
}
|
|
276779
|
+
try {
|
|
276780
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
276781
|
+
return stdout.trim();
|
|
276782
|
+
} catch {
|
|
276783
|
+
return path;
|
|
276784
|
+
}
|
|
276785
|
+
};
|
|
276786
|
+
|
|
276787
|
+
// ../../node_modules/define-lazy-prop/index.js
|
|
276788
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
276789
|
+
const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
276790
|
+
Object.defineProperty(object, propertyName, {
|
|
276791
|
+
configurable: true,
|
|
276792
|
+
enumerable: true,
|
|
276793
|
+
get() {
|
|
276794
|
+
const result = valueGetter();
|
|
276795
|
+
define2(result);
|
|
276796
|
+
return result;
|
|
276797
|
+
},
|
|
276798
|
+
set(value) {
|
|
276799
|
+
define2(value);
|
|
276800
|
+
}
|
|
276801
|
+
});
|
|
276802
|
+
return object;
|
|
276803
|
+
}
|
|
276804
|
+
|
|
276805
|
+
// ../../node_modules/default-browser/index.js
|
|
276806
|
+
import { promisify as promisify10 } from "node:util";
|
|
276807
|
+
import process28 from "node:process";
|
|
276808
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
276809
|
+
|
|
276810
|
+
// ../../node_modules/default-browser-id/index.js
|
|
276811
|
+
import { promisify as promisify7 } from "node:util";
|
|
276812
|
+
import process26 from "node:process";
|
|
276813
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
276814
|
+
var execFileAsync = promisify7(execFile3);
|
|
276815
|
+
async function defaultBrowserId() {
|
|
276816
|
+
if (process26.platform !== "darwin") {
|
|
276817
|
+
throw new Error("macOS only");
|
|
276818
|
+
}
|
|
276819
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
276820
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
276821
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
276822
|
+
if (browserId === "com.apple.safari") {
|
|
276823
|
+
return "com.apple.Safari";
|
|
276824
|
+
}
|
|
276825
|
+
return browserId;
|
|
276826
|
+
}
|
|
276827
|
+
|
|
276828
|
+
// ../../node_modules/run-applescript/index.js
|
|
276829
|
+
import process27 from "node:process";
|
|
276830
|
+
import { promisify as promisify8 } from "node:util";
|
|
276831
|
+
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
276832
|
+
var execFileAsync2 = promisify8(execFile4);
|
|
276833
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
276834
|
+
if (process27.platform !== "darwin") {
|
|
276835
|
+
throw new Error("macOS only");
|
|
276836
|
+
}
|
|
276837
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
276838
|
+
const execOptions = {};
|
|
276839
|
+
if (signal) {
|
|
276840
|
+
execOptions.signal = signal;
|
|
276841
|
+
}
|
|
276842
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
276843
|
+
return stdout.trim();
|
|
276844
|
+
}
|
|
276845
|
+
|
|
276846
|
+
// ../../node_modules/bundle-name/index.js
|
|
276847
|
+
async function bundleName(bundleId) {
|
|
276848
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
276849
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
276850
|
+
}
|
|
276851
|
+
|
|
276852
|
+
// ../../node_modules/default-browser/windows.js
|
|
276853
|
+
import { promisify as promisify9 } from "node:util";
|
|
276854
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
276855
|
+
var execFileAsync3 = promisify9(execFile5);
|
|
276856
|
+
var windowsBrowserProgIds = {
|
|
276857
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
276858
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
276859
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
276860
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
276861
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
276862
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
276863
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
276864
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
276865
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
276866
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
276867
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
276868
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
276869
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
276870
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
276871
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
276872
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
276873
|
+
};
|
|
276874
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
276875
|
+
|
|
276876
|
+
class UnknownBrowserError extends Error {
|
|
276877
|
+
}
|
|
276878
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
276879
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
276880
|
+
"QUERY",
|
|
276881
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
276882
|
+
"/v",
|
|
276883
|
+
"ProgId"
|
|
276884
|
+
]);
|
|
276885
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
276886
|
+
if (!match) {
|
|
276887
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
276888
|
+
}
|
|
276889
|
+
const { id } = match.groups;
|
|
276890
|
+
const dotIndex = id.lastIndexOf(".");
|
|
276891
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
276892
|
+
const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex);
|
|
276893
|
+
const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex);
|
|
276894
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
276895
|
+
}
|
|
276896
|
+
|
|
276897
|
+
// ../../node_modules/default-browser/index.js
|
|
276898
|
+
var execFileAsync4 = promisify10(execFile6);
|
|
276899
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
276900
|
+
async function defaultBrowser2() {
|
|
276901
|
+
if (process28.platform === "darwin") {
|
|
276902
|
+
const id = await defaultBrowserId();
|
|
276903
|
+
const name = await bundleName(id);
|
|
276904
|
+
return { name, id };
|
|
276905
|
+
}
|
|
276906
|
+
if (process28.platform === "linux") {
|
|
276907
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
276908
|
+
const id = stdout.trim();
|
|
276909
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
276910
|
+
return { name, id };
|
|
276911
|
+
}
|
|
276912
|
+
if (process28.platform === "win32") {
|
|
276913
|
+
return defaultBrowser();
|
|
276914
|
+
}
|
|
276915
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
276916
|
+
}
|
|
276917
|
+
|
|
276918
|
+
// ../../node_modules/is-in-ssh/index.js
|
|
276919
|
+
import process29 from "node:process";
|
|
276920
|
+
var isInSsh = Boolean(process29.env.SSH_CONNECTION || process29.env.SSH_CLIENT || process29.env.SSH_TTY);
|
|
276921
|
+
var is_in_ssh_default = isInSsh;
|
|
276922
|
+
|
|
276923
|
+
// ../../node_modules/open/index.js
|
|
276924
|
+
var fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
276925
|
+
var __dirname2 = import.meta.url ? path16.dirname(fileURLToPath4(import.meta.url)) : "";
|
|
276926
|
+
var localXdgOpenPath = path16.join(__dirname2, "xdg-open");
|
|
276927
|
+
var { platform: platform7, arch } = process30;
|
|
276928
|
+
var tryEachApp = async (apps, opener) => {
|
|
276929
|
+
if (apps.length === 0) {
|
|
276930
|
+
return;
|
|
276931
|
+
}
|
|
276932
|
+
const errors = [];
|
|
276933
|
+
for (const app of apps) {
|
|
276934
|
+
try {
|
|
276935
|
+
return await opener(app);
|
|
276936
|
+
} catch (error) {
|
|
276937
|
+
errors.push(error);
|
|
276938
|
+
}
|
|
276939
|
+
}
|
|
276940
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
276941
|
+
};
|
|
276942
|
+
var baseOpen = async (options) => {
|
|
276943
|
+
options = {
|
|
276944
|
+
wait: false,
|
|
276945
|
+
background: false,
|
|
276946
|
+
newInstance: false,
|
|
276947
|
+
allowNonzeroExitCode: false,
|
|
276948
|
+
...options
|
|
276949
|
+
};
|
|
276950
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
276951
|
+
delete options[fallbackAttemptSymbol];
|
|
276952
|
+
if (Array.isArray(options.app)) {
|
|
276953
|
+
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
276954
|
+
...options,
|
|
276955
|
+
app: singleApp,
|
|
276956
|
+
[fallbackAttemptSymbol]: true
|
|
276957
|
+
}));
|
|
276958
|
+
}
|
|
276959
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
276960
|
+
appArguments = [...appArguments];
|
|
276961
|
+
if (Array.isArray(app)) {
|
|
276962
|
+
return tryEachApp(app, (appName) => baseOpen({
|
|
276963
|
+
...options,
|
|
276964
|
+
app: {
|
|
276965
|
+
name: appName,
|
|
276966
|
+
arguments: appArguments
|
|
276967
|
+
},
|
|
276968
|
+
[fallbackAttemptSymbol]: true
|
|
276969
|
+
}));
|
|
276970
|
+
}
|
|
276971
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
276972
|
+
const ids = {
|
|
276973
|
+
"com.google.chrome": "chrome",
|
|
276974
|
+
"google-chrome.desktop": "chrome",
|
|
276975
|
+
"com.brave.browser": "brave",
|
|
276976
|
+
"org.mozilla.firefox": "firefox",
|
|
276977
|
+
"firefox.desktop": "firefox",
|
|
276978
|
+
"com.microsoft.msedge": "edge",
|
|
276979
|
+
"com.microsoft.edge": "edge",
|
|
276980
|
+
"com.microsoft.edgemac": "edge",
|
|
276981
|
+
"microsoft-edge.desktop": "edge",
|
|
276982
|
+
"com.apple.safari": "safari"
|
|
276983
|
+
};
|
|
276984
|
+
const flags = {
|
|
276985
|
+
chrome: "--incognito",
|
|
276986
|
+
brave: "--incognito",
|
|
276987
|
+
firefox: "--private-window",
|
|
276988
|
+
edge: "--inPrivate"
|
|
276989
|
+
};
|
|
276990
|
+
let browser;
|
|
276991
|
+
if (is_wsl_default) {
|
|
276992
|
+
const progId = await wslDefaultBrowser();
|
|
276993
|
+
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
276994
|
+
browser = browserInfo ?? {};
|
|
276995
|
+
} else {
|
|
276996
|
+
browser = await defaultBrowser2();
|
|
276997
|
+
}
|
|
276998
|
+
if (browser.id in ids) {
|
|
276999
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
277000
|
+
if (app === "browserPrivate") {
|
|
277001
|
+
if (browserName === "safari") {
|
|
277002
|
+
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
277003
|
+
}
|
|
277004
|
+
appArguments.push(flags[browserName]);
|
|
277005
|
+
}
|
|
277006
|
+
return baseOpen({
|
|
277007
|
+
...options,
|
|
277008
|
+
app: {
|
|
277009
|
+
name: apps[browserName],
|
|
277010
|
+
arguments: appArguments
|
|
277011
|
+
}
|
|
277012
|
+
});
|
|
277013
|
+
}
|
|
277014
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
277015
|
+
}
|
|
277016
|
+
let command;
|
|
277017
|
+
const cliArguments = [];
|
|
277018
|
+
const childProcessOptions = {};
|
|
277019
|
+
let shouldUseWindowsInWsl = false;
|
|
277020
|
+
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
277021
|
+
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
277022
|
+
}
|
|
277023
|
+
if (platform7 === "darwin") {
|
|
277024
|
+
command = "open";
|
|
277025
|
+
if (options.wait) {
|
|
277026
|
+
cliArguments.push("--wait-apps");
|
|
277027
|
+
}
|
|
277028
|
+
if (options.background) {
|
|
277029
|
+
cliArguments.push("--background");
|
|
277030
|
+
}
|
|
277031
|
+
if (options.newInstance) {
|
|
277032
|
+
cliArguments.push("--new");
|
|
277033
|
+
}
|
|
277034
|
+
if (app) {
|
|
277035
|
+
cliArguments.push("-a", app);
|
|
277036
|
+
}
|
|
277037
|
+
} else if (platform7 === "win32" || shouldUseWindowsInWsl) {
|
|
277038
|
+
command = await powerShellPath2();
|
|
277039
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
277040
|
+
if (!is_wsl_default) {
|
|
277041
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
277042
|
+
}
|
|
277043
|
+
if (is_wsl_default && options.target) {
|
|
277044
|
+
options.target = await convertWslPathToWindows(options.target);
|
|
277045
|
+
}
|
|
277046
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
277047
|
+
if (options.wait) {
|
|
277048
|
+
encodedArguments.push("-Wait");
|
|
277049
|
+
}
|
|
277050
|
+
if (app) {
|
|
277051
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
277052
|
+
if (options.target) {
|
|
277053
|
+
appArguments.push(options.target);
|
|
277054
|
+
}
|
|
277055
|
+
} else if (options.target) {
|
|
277056
|
+
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
277057
|
+
}
|
|
277058
|
+
if (appArguments.length > 0) {
|
|
277059
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
277060
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
277061
|
+
}
|
|
277062
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
277063
|
+
if (!options.wait) {
|
|
277064
|
+
childProcessOptions.stdio = "ignore";
|
|
277065
|
+
}
|
|
277066
|
+
} else {
|
|
277067
|
+
if (app) {
|
|
277068
|
+
command = app;
|
|
277069
|
+
} else {
|
|
277070
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
277071
|
+
let exeLocalXdgOpen = false;
|
|
277072
|
+
try {
|
|
277073
|
+
await fs20.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
277074
|
+
exeLocalXdgOpen = true;
|
|
277075
|
+
} catch {}
|
|
277076
|
+
const useSystemXdgOpen = process30.versions.electron ?? (platform7 === "android" || isBundled || !exeLocalXdgOpen);
|
|
277077
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
277078
|
+
}
|
|
277079
|
+
if (appArguments.length > 0) {
|
|
277080
|
+
cliArguments.push(...appArguments);
|
|
277081
|
+
}
|
|
277082
|
+
if (!options.wait) {
|
|
277083
|
+
childProcessOptions.stdio = "ignore";
|
|
277084
|
+
childProcessOptions.detached = true;
|
|
277085
|
+
}
|
|
277086
|
+
}
|
|
277087
|
+
if (platform7 === "darwin" && appArguments.length > 0) {
|
|
277088
|
+
cliArguments.push("--args", ...appArguments);
|
|
277089
|
+
}
|
|
277090
|
+
if (options.target) {
|
|
277091
|
+
cliArguments.push(options.target);
|
|
277092
|
+
}
|
|
277093
|
+
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
277094
|
+
if (options.wait) {
|
|
277095
|
+
return new Promise((resolve, reject) => {
|
|
277096
|
+
subprocess.once("error", reject);
|
|
277097
|
+
subprocess.once("close", (exitCode) => {
|
|
277098
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
277099
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
277100
|
+
return;
|
|
277101
|
+
}
|
|
277102
|
+
resolve(subprocess);
|
|
277103
|
+
});
|
|
277104
|
+
});
|
|
277105
|
+
}
|
|
277106
|
+
if (isFallbackAttempt) {
|
|
277107
|
+
return new Promise((resolve, reject) => {
|
|
277108
|
+
subprocess.once("error", reject);
|
|
277109
|
+
subprocess.once("spawn", () => {
|
|
277110
|
+
subprocess.once("close", (exitCode) => {
|
|
277111
|
+
subprocess.off("error", reject);
|
|
277112
|
+
if (exitCode !== 0) {
|
|
277113
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
277114
|
+
return;
|
|
277115
|
+
}
|
|
277116
|
+
subprocess.unref();
|
|
277117
|
+
resolve(subprocess);
|
|
277118
|
+
});
|
|
277119
|
+
});
|
|
277120
|
+
});
|
|
277121
|
+
}
|
|
277122
|
+
subprocess.unref();
|
|
277123
|
+
return new Promise((resolve, reject) => {
|
|
277124
|
+
subprocess.once("error", reject);
|
|
277125
|
+
subprocess.once("spawn", () => {
|
|
277126
|
+
subprocess.off("error", reject);
|
|
277127
|
+
resolve(subprocess);
|
|
277128
|
+
});
|
|
277129
|
+
});
|
|
277130
|
+
};
|
|
277131
|
+
var open = (target, options) => {
|
|
277132
|
+
if (typeof target !== "string") {
|
|
277133
|
+
throw new TypeError("Expected a `target`");
|
|
277134
|
+
}
|
|
277135
|
+
return baseOpen({
|
|
277136
|
+
...options,
|
|
277137
|
+
target
|
|
277138
|
+
});
|
|
277139
|
+
};
|
|
277140
|
+
function detectArchBinary(binary) {
|
|
277141
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
277142
|
+
return binary;
|
|
277143
|
+
}
|
|
277144
|
+
const { [arch]: archBinary } = binary;
|
|
277145
|
+
if (!archBinary) {
|
|
277146
|
+
throw new Error(`${arch} is not supported`);
|
|
277147
|
+
}
|
|
277148
|
+
return archBinary;
|
|
277149
|
+
}
|
|
277150
|
+
function detectPlatformBinary({ [platform7]: platformBinary }, { wsl } = {}) {
|
|
277151
|
+
if (wsl && is_wsl_default) {
|
|
277152
|
+
return detectArchBinary(wsl);
|
|
277153
|
+
}
|
|
277154
|
+
if (!platformBinary) {
|
|
277155
|
+
throw new Error(`${platform7} is not supported`);
|
|
277156
|
+
}
|
|
277157
|
+
return detectArchBinary(platformBinary);
|
|
277158
|
+
}
|
|
277159
|
+
var apps = {
|
|
277160
|
+
browser: "browser",
|
|
277161
|
+
browserPrivate: "browserPrivate"
|
|
277162
|
+
};
|
|
277163
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
277164
|
+
darwin: "google chrome",
|
|
277165
|
+
win32: "chrome",
|
|
277166
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
277167
|
+
}, {
|
|
277168
|
+
wsl: {
|
|
277169
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
277170
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
277171
|
+
}
|
|
277172
|
+
}));
|
|
277173
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
277174
|
+
darwin: "brave browser",
|
|
277175
|
+
win32: "brave",
|
|
277176
|
+
linux: ["brave-browser", "brave"]
|
|
277177
|
+
}, {
|
|
277178
|
+
wsl: {
|
|
277179
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
277180
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
277181
|
+
}
|
|
277182
|
+
}));
|
|
277183
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
277184
|
+
darwin: "firefox",
|
|
277185
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
277186
|
+
linux: "firefox"
|
|
277187
|
+
}, {
|
|
277188
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
277189
|
+
}));
|
|
277190
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
277191
|
+
darwin: "microsoft edge",
|
|
277192
|
+
win32: "msedge",
|
|
277193
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
277194
|
+
}, {
|
|
277195
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
277196
|
+
}));
|
|
277197
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
277198
|
+
darwin: "Safari"
|
|
277199
|
+
}));
|
|
277200
|
+
var open_default = open;
|
|
277201
|
+
|
|
276135
277202
|
// src/cli/commands/code/session.tsx
|
|
276136
277203
|
var import_react23 = __toESM(require_react(), 1);
|
|
276137
277204
|
|
|
@@ -276321,180 +277388,6 @@ function createPasteFriendlyStdin(real) {
|
|
|
276321
277388
|
return proxy;
|
|
276322
277389
|
}
|
|
276323
277390
|
|
|
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) {
|
|
276340
|
-
try {
|
|
276341
|
-
const parsed = JSON.parse(raw ?? "");
|
|
276342
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
276343
|
-
} catch {
|
|
276344
|
-
return {};
|
|
276345
|
-
}
|
|
276346
|
-
}
|
|
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;
|
|
276389
|
-
}
|
|
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
|
-
}
|
|
276475
|
-
}
|
|
276476
|
-
}
|
|
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];
|
|
276494
|
-
});
|
|
276495
|
-
return { answers };
|
|
276496
|
-
}
|
|
276497
|
-
|
|
276498
277391
|
// src/cli/commands/code/pending-card.ts
|
|
276499
277392
|
function openCard(pending) {
|
|
276500
277393
|
return {
|
|
@@ -276504,7 +277397,8 @@ function openCard(pending) {
|
|
|
276504
277397
|
selections: (pending.questions ?? []).map(() => ({ labels: [] })),
|
|
276505
277398
|
granted: new Set((pending.permissions ?? []).map((p) => p.key)),
|
|
276506
277399
|
typing: pending.kind === "secrets" ? "secret" : null,
|
|
276507
|
-
secretValues: {}
|
|
277400
|
+
secretValues: {},
|
|
277401
|
+
...pending.kind === "browser" ? { browser: { status: "idle" } } : {}
|
|
276508
277402
|
};
|
|
276509
277403
|
}
|
|
276510
277404
|
var done = (action, input = {}) => ({ state: null, submit: { action, input } });
|
|
@@ -276519,7 +277413,7 @@ function advanceChoice(state) {
|
|
|
276519
277413
|
state: { ...state, step: state.step + 1, cursor: 0, typing: null }
|
|
276520
277414
|
};
|
|
276521
277415
|
}
|
|
276522
|
-
return done("approved", choiceAnswers(questions, state.selections));
|
|
277416
|
+
return done("approved", choiceAnswers(questions, state.selections, state.pending.answerKey));
|
|
276523
277417
|
}
|
|
276524
277418
|
function choiceKey(state, key) {
|
|
276525
277419
|
const question = state.pending.questions?.[state.step];
|
|
@@ -276612,6 +277506,33 @@ function cardKey(state, key) {
|
|
|
276612
277506
|
return choiceKey(state, key);
|
|
276613
277507
|
case "permissions":
|
|
276614
277508
|
return permissionsKey(state, key);
|
|
277509
|
+
case "browser": {
|
|
277510
|
+
const status = state.browser?.status ?? "idle";
|
|
277511
|
+
if (key === "n")
|
|
277512
|
+
return done("rejected");
|
|
277513
|
+
if (key === "escape")
|
|
277514
|
+
return later;
|
|
277515
|
+
if (key === "y" || key === "enter") {
|
|
277516
|
+
if (status === "active")
|
|
277517
|
+
return done("approved");
|
|
277518
|
+
if (status !== "waiting") {
|
|
277519
|
+
return {
|
|
277520
|
+
state: {
|
|
277521
|
+
...state,
|
|
277522
|
+
browser: { ...state.browser, status: "waiting" }
|
|
277523
|
+
},
|
|
277524
|
+
startBrowser: true
|
|
277525
|
+
};
|
|
277526
|
+
}
|
|
277527
|
+
}
|
|
277528
|
+
return { state };
|
|
277529
|
+
}
|
|
277530
|
+
case "unknown":
|
|
277531
|
+
if (key === "n")
|
|
277532
|
+
return done("rejected");
|
|
277533
|
+
if (key === "escape")
|
|
277534
|
+
return later;
|
|
277535
|
+
return { state };
|
|
276615
277536
|
default:
|
|
276616
277537
|
if (key === "y" || key === "enter")
|
|
276617
277538
|
return done("approved");
|
|
@@ -276622,6 +277543,12 @@ function cardKey(state, key) {
|
|
|
276622
277543
|
return { state };
|
|
276623
277544
|
}
|
|
276624
277545
|
}
|
|
277546
|
+
function browserUpdate(state, update) {
|
|
277547
|
+
return {
|
|
277548
|
+
...state,
|
|
277549
|
+
browser: { url: update.url ?? state.browser?.url, status: update.status }
|
|
277550
|
+
};
|
|
277551
|
+
}
|
|
276625
277552
|
function cardText(state, text) {
|
|
276626
277553
|
const value = text.trim();
|
|
276627
277554
|
if (state.typing === "custom") {
|
|
@@ -276697,11 +277624,48 @@ function cardLines(state) {
|
|
|
276697
277624
|
source_default.dim(" type the value below (hidden) · Enter next · Esc later")
|
|
276698
277625
|
];
|
|
276699
277626
|
}
|
|
276700
|
-
case "browser":
|
|
277627
|
+
case "browser": {
|
|
277628
|
+
const b = state.browser ?? { status: "idle" };
|
|
277629
|
+
const link = b.url ? [` ${source_default.cyan(b.url)}`] : [];
|
|
277630
|
+
switch (b.status) {
|
|
277631
|
+
case "waiting":
|
|
277632
|
+
return [
|
|
277633
|
+
...head,
|
|
277634
|
+
source_default.dim(" opened in your browser — or use the link:"),
|
|
277635
|
+
...link,
|
|
277636
|
+
source_default.dim(" waiting for the authorization to complete… · n reject · Esc later")
|
|
277637
|
+
];
|
|
277638
|
+
case "active":
|
|
277639
|
+
return [
|
|
277640
|
+
...head,
|
|
277641
|
+
source_default.green(" ✓ connected"),
|
|
277642
|
+
source_default.dim(" y continue · n reject")
|
|
277643
|
+
];
|
|
277644
|
+
case "failed":
|
|
277645
|
+
return [
|
|
277646
|
+
...head,
|
|
277647
|
+
source_default.red(" ✗ authorization failed"),
|
|
277648
|
+
source_default.dim(" y try again · n reject · Esc later")
|
|
277649
|
+
];
|
|
277650
|
+
case "timeout":
|
|
277651
|
+
return [
|
|
277652
|
+
...head,
|
|
277653
|
+
source_default.yellow(" ⏱ no response yet"),
|
|
277654
|
+
...link,
|
|
277655
|
+
source_default.dim(" y try again · n reject · Esc later")
|
|
277656
|
+
];
|
|
277657
|
+
default:
|
|
277658
|
+
return [
|
|
277659
|
+
...head,
|
|
277660
|
+
source_default.dim(" y open the authorization link · n reject · Esc later")
|
|
277661
|
+
];
|
|
277662
|
+
}
|
|
277663
|
+
}
|
|
277664
|
+
case "unknown":
|
|
276701
277665
|
return [
|
|
276702
277666
|
...head,
|
|
276703
|
-
source_default.
|
|
276704
|
-
source_default.dim("
|
|
277667
|
+
source_default.yellow(" this question needs the editor — answer it there and the session continues"),
|
|
277668
|
+
source_default.dim(" n reject · Esc later")
|
|
276705
277669
|
];
|
|
276706
277670
|
default:
|
|
276707
277671
|
return [...head, source_default.dim(" y approve · n reject · Esc later")];
|
|
@@ -276849,7 +277813,7 @@ function createSessionEngine(options) {
|
|
|
276849
277813
|
lastTurnMs = durationMs;
|
|
276850
277814
|
const ok = !turn.backendStatus?.startsWith("error");
|
|
276851
277815
|
lastTurnOk = ok;
|
|
276852
|
-
options.onLine(ok ? source_default.dim(`— turn finished · ${formatDuration2(durationMs)}`) : source_default.red(`— turn failed (${turn.backendStatus ?? "unknown"}) · ${formatDuration2(durationMs)}`));
|
|
277816
|
+
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)}`));
|
|
276853
277817
|
const info = {
|
|
276854
277818
|
turnIndex: settledCount++,
|
|
276855
277819
|
ok,
|
|
@@ -276920,6 +277884,58 @@ function createSessionEngine(options) {
|
|
|
276920
277884
|
};
|
|
276921
277885
|
}
|
|
276922
277886
|
|
|
277887
|
+
// src/core/resources/apps/connections.ts
|
|
277888
|
+
var InitiateSchema = object({
|
|
277889
|
+
redirect_url: string2().nullish(),
|
|
277890
|
+
connection_id: string2().nullish(),
|
|
277891
|
+
integration_type: string2().nullish()
|
|
277892
|
+
});
|
|
277893
|
+
async function startConnectorOAuth(options) {
|
|
277894
|
+
let response;
|
|
277895
|
+
try {
|
|
277896
|
+
response = await getAppClient().post("external-auth/initiate", {
|
|
277897
|
+
json: {
|
|
277898
|
+
integration_type: options.integrationType,
|
|
277899
|
+
scopes: options.scopes ?? null,
|
|
277900
|
+
connector_id: options.connectorId ?? null,
|
|
277901
|
+
force_reconnect: options.forceReconnect === true
|
|
277902
|
+
}
|
|
277903
|
+
});
|
|
277904
|
+
} catch (error) {
|
|
277905
|
+
throw await ApiError.fromHttpError(error, "starting connector authorization");
|
|
277906
|
+
}
|
|
277907
|
+
const parsed = InitiateSchema.parse(await response.json());
|
|
277908
|
+
if (!parsed.redirect_url || !parsed.connection_id) {
|
|
277909
|
+
throw new ApiError("The connector did not return an authorization link.");
|
|
277910
|
+
}
|
|
277911
|
+
return {
|
|
277912
|
+
url: parsed.redirect_url,
|
|
277913
|
+
connectionId: parsed.connection_id,
|
|
277914
|
+
integrationType: parsed.integration_type ?? options.integrationType
|
|
277915
|
+
};
|
|
277916
|
+
}
|
|
277917
|
+
async function waitForConnectorOAuth(started, options = {}) {
|
|
277918
|
+
const deadline = Date.now() + (options.timeoutMs ?? 10 * 60000);
|
|
277919
|
+
const interval = options.intervalMs ?? 3000;
|
|
277920
|
+
while (Date.now() < deadline && !options.signal?.aborted) {
|
|
277921
|
+
const status = await getOAuthStatus(started.integrationType, started.connectionId).catch(() => null);
|
|
277922
|
+
if (status?.status === "ACTIVE" || status?.status === "FAILED") {
|
|
277923
|
+
return status.status;
|
|
277924
|
+
}
|
|
277925
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
277926
|
+
}
|
|
277927
|
+
return "PENDING";
|
|
277928
|
+
}
|
|
277929
|
+
var GithubStatusSchema = object({ connected: boolean2() });
|
|
277930
|
+
async function githubConnected() {
|
|
277931
|
+
try {
|
|
277932
|
+
const response = await base44Client.get("api/github/oauth/status");
|
|
277933
|
+
return GithubStatusSchema.parse(await response.json()).connected;
|
|
277934
|
+
} catch {
|
|
277935
|
+
return false;
|
|
277936
|
+
}
|
|
277937
|
+
}
|
|
277938
|
+
|
|
276923
277939
|
// src/cli/commands/code/session.tsx
|
|
276924
277940
|
var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
276925
277941
|
var FRAMES2 = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
@@ -277030,14 +278046,67 @@ function SessionView({ engine, footer, subscribe }) {
|
|
|
277030
278046
|
emit(source_default.red(` /model: ${error instanceof Error ? error.message : String(error)}`));
|
|
277031
278047
|
}
|
|
277032
278048
|
};
|
|
278049
|
+
const browserRunRef = import_react23.useRef(null);
|
|
278050
|
+
const runBrowserStep = async (state) => {
|
|
278051
|
+
browserRunRef.current?.abort();
|
|
278052
|
+
const run = new AbortController;
|
|
278053
|
+
browserRunRef.current = run;
|
|
278054
|
+
const step = state.pending.browser;
|
|
278055
|
+
try {
|
|
278056
|
+
let url;
|
|
278057
|
+
let wait;
|
|
278058
|
+
if (step?.flow === "github") {
|
|
278059
|
+
url = await startGithubReauth();
|
|
278060
|
+
wait = async () => {
|
|
278061
|
+
const deadline = Date.now() + 10 * 60000;
|
|
278062
|
+
while (Date.now() < deadline && !run.signal.aborted) {
|
|
278063
|
+
if (await githubConnected())
|
|
278064
|
+
return "ACTIVE";
|
|
278065
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
278066
|
+
}
|
|
278067
|
+
return "PENDING";
|
|
278068
|
+
};
|
|
278069
|
+
} else {
|
|
278070
|
+
const started = await startConnectorOAuth({
|
|
278071
|
+
integrationType: step?.integrationType ?? "",
|
|
278072
|
+
scopes: step?.scopes,
|
|
278073
|
+
connectorId: step?.connectorId,
|
|
278074
|
+
forceReconnect: step?.forceReconnect
|
|
278075
|
+
});
|
|
278076
|
+
url = started.url;
|
|
278077
|
+
wait = () => waitForConnectorOAuth(started, { signal: run.signal });
|
|
278078
|
+
}
|
|
278079
|
+
setCard((c) => c ? browserUpdate(c, { url, status: "waiting" }) : c);
|
|
278080
|
+
emit(source_default.dim(` authorization link: ${url}`));
|
|
278081
|
+
await open_default(url).catch(() => {
|
|
278082
|
+
return;
|
|
278083
|
+
});
|
|
278084
|
+
const outcome = await wait();
|
|
278085
|
+
if (run.signal.aborted)
|
|
278086
|
+
return;
|
|
278087
|
+
setCard((c) => c ? browserUpdate(c, {
|
|
278088
|
+
status: outcome === "ACTIVE" ? "active" : outcome === "FAILED" ? "failed" : "timeout"
|
|
278089
|
+
}) : c);
|
|
278090
|
+
} catch (error) {
|
|
278091
|
+
if (run.signal.aborted)
|
|
278092
|
+
return;
|
|
278093
|
+
emit(source_default.red(` authorization failed to start: ${error instanceof Error ? error.message : String(error)}`));
|
|
278094
|
+
setCard((c) => c ? browserUpdate(c, { status: "failed" }) : c);
|
|
278095
|
+
}
|
|
278096
|
+
};
|
|
277033
278097
|
const applyCard = (outcome) => {
|
|
277034
278098
|
if (outcome.submit && card) {
|
|
278099
|
+
browserRunRef.current?.abort();
|
|
277035
278100
|
engine.answer(card.pending, outcome.submit.action, outcome.submit.input);
|
|
277036
278101
|
}
|
|
277037
278102
|
if (outcome.dismissed && card) {
|
|
278103
|
+
browserRunRef.current?.abort();
|
|
277038
278104
|
dismissedRef.current.add(card.pending.toolCallId);
|
|
277039
278105
|
}
|
|
277040
278106
|
setCard(outcome.state);
|
|
278107
|
+
if (outcome.startBrowser && outcome.state) {
|
|
278108
|
+
runBrowserStep(outcome.state);
|
|
278109
|
+
}
|
|
277041
278110
|
};
|
|
277042
278111
|
const pending = engine.status().pending;
|
|
277043
278112
|
import_react23.useEffect(() => {
|
|
@@ -277577,612 +278646,6 @@ function getCodeCommand() {
|
|
|
277577
278646
|
return command;
|
|
277578
278647
|
}
|
|
277579
278648
|
|
|
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
|
-
}
|
|
277617
|
-
}
|
|
277618
|
-
function isDocker() {
|
|
277619
|
-
if (isDockerCached === undefined) {
|
|
277620
|
-
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
277621
|
-
}
|
|
277622
|
-
return isDockerCached;
|
|
277623
|
-
}
|
|
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();
|
|
277638
|
-
}
|
|
277639
|
-
return cachedResult;
|
|
277640
|
-
}
|
|
277641
|
-
|
|
277642
|
-
// ../../node_modules/is-wsl/index.js
|
|
277643
|
-
var isWsl = () => {
|
|
277644
|
-
if (process24.platform !== "linux") {
|
|
277645
|
-
return false;
|
|
277646
|
-
}
|
|
277647
|
-
if (os4.release().toLowerCase().includes("microsoft")) {
|
|
277648
|
-
if (isInsideContainer()) {
|
|
277649
|
-
return false;
|
|
277650
|
-
}
|
|
277651
|
-
return true;
|
|
277652
|
-
}
|
|
277653
|
-
try {
|
|
277654
|
-
return fs18.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
277655
|
-
} catch {
|
|
277656
|
-
return false;
|
|
277657
|
-
}
|
|
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;
|
|
277702
|
-
}
|
|
277703
|
-
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
277704
|
-
}
|
|
277705
|
-
}
|
|
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;
|
|
277715
|
-
}
|
|
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;
|
|
277724
|
-
}
|
|
277725
|
-
const configContent = await fs19.readFile(configFilePath, { encoding: "utf8" });
|
|
277726
|
-
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
277727
|
-
if (parsedMountPoint === undefined) {
|
|
277728
|
-
return defaultMountPoint;
|
|
277729
|
-
}
|
|
277730
|
-
mountPoint = parsedMountPoint;
|
|
277731
|
-
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
277732
|
-
return mountPoint;
|
|
277733
|
-
};
|
|
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 () => {
|
|
277743
|
-
try {
|
|
277744
|
-
const psPath = await powerShellPath2();
|
|
277745
|
-
await fs19.access(psPath, fsConstants.X_OK);
|
|
277746
|
-
return true;
|
|
277747
|
-
} catch {
|
|
277748
|
-
return false;
|
|
277749
|
-
}
|
|
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;
|
|
277781
|
-
},
|
|
277782
|
-
set(value) {
|
|
277783
|
-
define2(value);
|
|
277784
|
-
}
|
|
277785
|
-
});
|
|
277786
|
-
return object;
|
|
277787
|
-
}
|
|
277788
|
-
|
|
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");
|
|
277802
|
-
}
|
|
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";
|
|
277808
|
-
}
|
|
277809
|
-
return browserId;
|
|
277810
|
-
}
|
|
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");
|
|
277820
|
-
}
|
|
277821
|
-
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
277822
|
-
const execOptions = {};
|
|
277823
|
-
if (signal) {
|
|
277824
|
-
execOptions.signal = signal;
|
|
277825
|
-
}
|
|
277826
|
-
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
277827
|
-
return stdout.trim();
|
|
277828
|
-
}
|
|
277829
|
-
|
|
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")`);
|
|
277834
|
-
}
|
|
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 {
|
|
277861
|
-
}
|
|
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)}`);
|
|
277872
|
-
}
|
|
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 };
|
|
277879
|
-
}
|
|
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();
|
|
277898
|
-
}
|
|
277899
|
-
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
277900
|
-
}
|
|
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) {
|
|
277918
|
-
try {
|
|
277919
|
-
return await opener(app);
|
|
277920
|
-
} catch (error) {
|
|
277921
|
-
errors.push(error);
|
|
277922
|
-
}
|
|
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
|
-
};
|
|
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();
|
|
277981
|
-
}
|
|
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]);
|
|
277989
|
-
}
|
|
277990
|
-
return baseOpen({
|
|
277991
|
-
...options,
|
|
277992
|
-
app: {
|
|
277993
|
-
name: apps[browserName],
|
|
277994
|
-
arguments: appArguments
|
|
277995
|
-
}
|
|
277996
|
-
});
|
|
277997
|
-
}
|
|
277998
|
-
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
277999
|
-
}
|
|
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();
|
|
278006
|
-
}
|
|
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");
|
|
278017
|
-
}
|
|
278018
|
-
if (app) {
|
|
278019
|
-
cliArguments.push("-a", app);
|
|
278020
|
-
}
|
|
278021
|
-
} else if (platform7 === "win32" || shouldUseWindowsInWsl) {
|
|
278022
|
-
command = await powerShellPath2();
|
|
278023
|
-
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
278024
|
-
if (!is_wsl_default) {
|
|
278025
|
-
childProcessOptions.windowsVerbatimArguments = true;
|
|
278026
|
-
}
|
|
278027
|
-
if (is_wsl_default && options.target) {
|
|
278028
|
-
options.target = await convertWslPathToWindows(options.target);
|
|
278029
|
-
}
|
|
278030
|
-
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
278031
|
-
if (options.wait) {
|
|
278032
|
-
encodedArguments.push("-Wait");
|
|
278033
|
-
}
|
|
278034
|
-
if (app) {
|
|
278035
|
-
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
278036
|
-
if (options.target) {
|
|
278037
|
-
appArguments.push(options.target);
|
|
278038
|
-
}
|
|
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);
|
|
278065
|
-
}
|
|
278066
|
-
if (!options.wait) {
|
|
278067
|
-
childProcessOptions.stdio = "ignore";
|
|
278068
|
-
childProcessOptions.detached = true;
|
|
278069
|
-
}
|
|
278070
|
-
}
|
|
278071
|
-
if (platform7 === "darwin" && appArguments.length > 0) {
|
|
278072
|
-
cliArguments.push("--args", ...appArguments);
|
|
278073
|
-
}
|
|
278074
|
-
if (options.target) {
|
|
278075
|
-
cliArguments.push(options.target);
|
|
278076
|
-
}
|
|
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);
|
|
278087
|
-
});
|
|
278088
|
-
});
|
|
278089
|
-
}
|
|
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
|
-
});
|
|
278104
|
-
});
|
|
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);
|
|
278112
|
-
});
|
|
278113
|
-
});
|
|
278114
|
-
};
|
|
278115
|
-
var open = (target, options) => {
|
|
278116
|
-
if (typeof target !== "string") {
|
|
278117
|
-
throw new TypeError("Expected a `target`");
|
|
278118
|
-
}
|
|
278119
|
-
return baseOpen({
|
|
278120
|
-
...options,
|
|
278121
|
-
target
|
|
278122
|
-
});
|
|
278123
|
-
};
|
|
278124
|
-
function detectArchBinary(binary) {
|
|
278125
|
-
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
278126
|
-
return binary;
|
|
278127
|
-
}
|
|
278128
|
-
const { [arch]: archBinary } = binary;
|
|
278129
|
-
if (!archBinary) {
|
|
278130
|
-
throw new Error(`${arch} is not supported`);
|
|
278131
|
-
}
|
|
278132
|
-
return archBinary;
|
|
278133
|
-
}
|
|
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);
|
|
278142
|
-
}
|
|
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
|
-
|
|
278186
278649
|
// src/cli/commands/connectors/oauth-prompt.ts
|
|
278187
278650
|
var POLL_INTERVAL_MS = 2000;
|
|
278188
278651
|
var POLL_TIMEOUT_MS2 = 2 * 60 * 1000;
|
|
@@ -279950,7 +280413,7 @@ async function callTool(appId, tool, payload, schema, context, timeout = 60000)
|
|
|
279950
280413
|
function listDirectory(appId, params) {
|
|
279951
280414
|
return callTool(appId, "list_directory", { ...params }, ListDirectoryResponseSchema, "listing directory");
|
|
279952
280415
|
}
|
|
279953
|
-
function
|
|
280416
|
+
function readFile5(appId, params) {
|
|
279954
280417
|
return callTool(appId, "read_file", { ...params }, ReadFileResponseSchema, "reading file");
|
|
279955
280418
|
}
|
|
279956
280419
|
function writeFile3(appId, params) {
|
|
@@ -280105,7 +280568,7 @@ async function readFileAction({ runTask, branchId }, paths, options) {
|
|
|
280105
280568
|
const { id: appId } = getAppContext();
|
|
280106
280569
|
const offset = parsePositiveInt(options.offset, "--offset");
|
|
280107
280570
|
const limit = parsePositiveInt(options.limit, "--limit");
|
|
280108
|
-
const result = await runTask("Reading file", () =>
|
|
280571
|
+
const result = await runTask("Reading file", () => readFile5(appId, { paths, offset, limit, branch_id: branchId }));
|
|
280109
280572
|
return { outroMessage: "Read file", stdout: toJsonStdout(result) };
|
|
280110
280573
|
}
|
|
280111
280574
|
function getSandboxReadFileCommand() {
|
|
@@ -284956,7 +285419,7 @@ async function runScript(options) {
|
|
|
284956
285419
|
}
|
|
284957
285420
|
}
|
|
284958
285421
|
// src/cli/commands/exec.ts
|
|
284959
|
-
function
|
|
285422
|
+
function readStdin4() {
|
|
284960
285423
|
return new Promise((resolve, reject) => {
|
|
284961
285424
|
let data = "";
|
|
284962
285425
|
process.stdin.setEncoding("utf-8");
|
|
@@ -285000,7 +285463,7 @@ async function execAction({ app, isNonInteractive }, options) {
|
|
|
285000
285463
|
if (!isNonInteractive) {
|
|
285001
285464
|
throw noInputError;
|
|
285002
285465
|
}
|
|
285003
|
-
const code = await
|
|
285466
|
+
const code = await readStdin4();
|
|
285004
285467
|
if (!code.trim()) {
|
|
285005
285468
|
throw noInputError;
|
|
285006
285469
|
}
|
|
@@ -289242,4 +289705,4 @@ export {
|
|
|
289242
289705
|
runCLI
|
|
289243
289706
|
};
|
|
289244
289707
|
|
|
289245
|
-
//# debugId=
|
|
289708
|
+
//# debugId=4BE509CB064A95FF64756E2164756E21
|