wildcrane-runner 0.6.55 → 0.6.57
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/akb/dist/kanban.mjs +1334 -892
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +447 -73
- package/dist/plugin.mjs +485 -111
- package/dist/runner.mjs +1084 -593
- package/dist/settings.mjs +437 -63
- package/package.json +1 -1
package/dist/launcher.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.57 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -5751,8 +5751,8 @@ var require_util2 = __commonJS({
|
|
|
5751
5751
|
}
|
|
5752
5752
|
return values;
|
|
5753
5753
|
}
|
|
5754
|
-
function getDecodeSplit(name,
|
|
5755
|
-
const value =
|
|
5754
|
+
function getDecodeSplit(name, list2) {
|
|
5755
|
+
const value = list2.get(name, true);
|
|
5756
5756
|
if (value === null) {
|
|
5757
5757
|
return null;
|
|
5758
5758
|
}
|
|
@@ -19811,9 +19811,9 @@ var require_headers = __commonJS({
|
|
|
19811
19811
|
// https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
|
|
19812
19812
|
getSetCookie() {
|
|
19813
19813
|
webidl.brandCheck(this, _Headers);
|
|
19814
|
-
const
|
|
19815
|
-
if (
|
|
19816
|
-
return [...
|
|
19814
|
+
const list2 = this.#headersList.cookies;
|
|
19815
|
+
if (list2) {
|
|
19816
|
+
return [...list2];
|
|
19817
19817
|
}
|
|
19818
19818
|
return [];
|
|
19819
19819
|
}
|
|
@@ -19837,8 +19837,8 @@ var require_headers = __commonJS({
|
|
|
19837
19837
|
* @param {Headers} target
|
|
19838
19838
|
* @param {HeadersList} list
|
|
19839
19839
|
*/
|
|
19840
|
-
static setHeadersList(target,
|
|
19841
|
-
target.#headersList =
|
|
19840
|
+
static setHeadersList(target, list2) {
|
|
19841
|
+
target.#headersList = list2;
|
|
19842
19842
|
}
|
|
19843
19843
|
};
|
|
19844
19844
|
var { getHeadersGuard, setHeadersGuard, getHeadersList, setHeadersList } = Headers;
|
|
@@ -20789,13 +20789,13 @@ var require_request2 = __commonJS({
|
|
|
20789
20789
|
if (this.signal.aborted) {
|
|
20790
20790
|
ac.abort(this.signal.reason);
|
|
20791
20791
|
} else {
|
|
20792
|
-
let
|
|
20793
|
-
if (
|
|
20794
|
-
|
|
20795
|
-
dependentControllerMap.set(this.signal,
|
|
20792
|
+
let list2 = dependentControllerMap.get(this.signal);
|
|
20793
|
+
if (list2 === void 0) {
|
|
20794
|
+
list2 = /* @__PURE__ */ new Set();
|
|
20795
|
+
dependentControllerMap.set(this.signal, list2);
|
|
20796
20796
|
}
|
|
20797
20797
|
const acRef = new WeakRef(ac);
|
|
20798
|
-
|
|
20798
|
+
list2.add(acRef);
|
|
20799
20799
|
util.addAbortListener(
|
|
20800
20800
|
ac.signal,
|
|
20801
20801
|
buildAbort(acRef)
|
|
@@ -26903,8 +26903,8 @@ function saveAlphaUpdates(value) {
|
|
|
26903
26903
|
}
|
|
26904
26904
|
|
|
26905
26905
|
// src/protocol.ts
|
|
26906
|
-
var VERSION = true ? "0.6.
|
|
26907
|
-
var AKB_VERSION = true ? "0.11.
|
|
26906
|
+
var VERSION = true ? "0.6.57" : "0.0.0";
|
|
26907
|
+
var AKB_VERSION = true ? "0.11.45" : "0.0.0";
|
|
26908
26908
|
var EXIT_REFUSED = 10;
|
|
26909
26909
|
var EXIT_OUTDATED = 11;
|
|
26910
26910
|
var EXIT_UPDATE = 12;
|
|
@@ -27235,23 +27235,23 @@ function runOnce(candidate, options) {
|
|
|
27235
27235
|
});
|
|
27236
27236
|
}
|
|
27237
27237
|
async function launch(own2, options = {}) {
|
|
27238
|
-
const
|
|
27239
|
-
for (let i = 0; i <
|
|
27238
|
+
const list2 = await candidates(own2);
|
|
27239
|
+
for (let i = 0; i < list2.length; i++) {
|
|
27240
27240
|
if (options.signal?.aborted) return 0;
|
|
27241
|
-
const candidate =
|
|
27241
|
+
const candidate = list2[i];
|
|
27242
27242
|
const outcome = await runOnce(candidate, options);
|
|
27243
27243
|
if ("exit" in outcome) return outcome.exit;
|
|
27244
27244
|
if ("update" in outcome) {
|
|
27245
27245
|
const latest = await askTarget(machineId());
|
|
27246
27246
|
if (!latest || latest.version !== outcome.update.version || waiting(latest, candidate.version)) {
|
|
27247
|
-
|
|
27247
|
+
list2.splice(i + 1, list2.length, candidate);
|
|
27248
27248
|
continue;
|
|
27249
27249
|
}
|
|
27250
|
-
|
|
27250
|
+
list2.splice(i + 1, list2.length, outcome.update, candidate);
|
|
27251
27251
|
continue;
|
|
27252
27252
|
}
|
|
27253
27253
|
markBad(candidate.version);
|
|
27254
|
-
const next =
|
|
27254
|
+
const next = list2[i + 1];
|
|
27255
27255
|
if (next) status(t.rolledBack(next.version));
|
|
27256
27256
|
}
|
|
27257
27257
|
return 1;
|
|
@@ -27988,7 +27988,7 @@ var OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
|
|
|
27988
27988
|
var AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
27989
27989
|
var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
|
|
27990
27990
|
var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
|
|
27991
|
-
function parseSpecAgent(text3, from, file2, builtIn = false,
|
|
27991
|
+
function parseSpecAgent(text3, from, file2, builtIn = false, list2 = () => []) {
|
|
27992
27992
|
let named = "";
|
|
27993
27993
|
const bad = (why, old2) => ({
|
|
27994
27994
|
problem: `${from}: ${why}`,
|
|
@@ -28050,7 +28050,7 @@ function parseSpecAgent(text3, from, file2, builtIn = false, list = () => []) {
|
|
|
28050
28050
|
...declaredSession ? { session: "new" } : {},
|
|
28051
28051
|
memory: names(akb.memory),
|
|
28052
28052
|
memoryFiles: { workspace },
|
|
28053
|
-
files:
|
|
28053
|
+
files: list2(),
|
|
28054
28054
|
body: instructions,
|
|
28055
28055
|
from,
|
|
28056
28056
|
builtIn,
|
|
@@ -28079,12 +28079,12 @@ function memoryPaths(raw, folder = "memory/agents/<name>/") {
|
|
|
28079
28079
|
const block = map(raw);
|
|
28080
28080
|
const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
|
|
28081
28081
|
if (!block || extra.length) return `\`akb.memoryFiles\` with ${block ? `\`${extra.join("`, `")}\`` : "no `workspace:` list"} \u2014 it holds only \`workspace: [<path>, ...]\``;
|
|
28082
|
-
const
|
|
28083
|
-
if (
|
|
28084
|
-
if (!Array.isArray(
|
|
28082
|
+
const list2 = block.workspace;
|
|
28083
|
+
if (list2 === void 0) return [];
|
|
28084
|
+
if (!Array.isArray(list2) || list2.some((v) => typeof v !== "string" || !v.trim())) {
|
|
28085
28085
|
return "`akb.memoryFiles.workspace` that is not a list of paths \u2014 write `workspace: [style.md]`";
|
|
28086
28086
|
}
|
|
28087
|
-
const paths = [...new Set(
|
|
28087
|
+
const paths = [...new Set(list2.map((v) => v.trim()))];
|
|
28088
28088
|
const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
|
|
28089
28089
|
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
|
|
28090
28090
|
return paths;
|
|
@@ -28652,8 +28652,8 @@ function readFlows() {
|
|
|
28652
28652
|
}
|
|
28653
28653
|
const project = boardProject();
|
|
28654
28654
|
if (!project || !readSession()) return [];
|
|
28655
|
-
const
|
|
28656
|
-
const flows2 =
|
|
28655
|
+
const list2 = readJson(listFile(project))?.studios ?? [];
|
|
28656
|
+
const flows2 = list2.flatMap((w) => {
|
|
28657
28657
|
const held = readVersion(w.id, w.version);
|
|
28658
28658
|
return held ? flowOf(held) ?? [] : [];
|
|
28659
28659
|
});
|
|
@@ -28749,12 +28749,12 @@ function update(change) {
|
|
|
28749
28749
|
}
|
|
28750
28750
|
}
|
|
28751
28751
|
function adoptLegacy() {
|
|
28752
|
-
if (readSession() && !readGrants().accounts) update((
|
|
28752
|
+
if (readSession() && !readGrants().accounts) update((list2) => list2);
|
|
28753
28753
|
}
|
|
28754
28754
|
var allow = (dir) => {
|
|
28755
|
-
update((
|
|
28755
|
+
update((list2) => [...list2, dir]);
|
|
28756
28756
|
};
|
|
28757
|
-
var disallow = (dir) => update((
|
|
28757
|
+
var disallow = (dir) => update((list2) => list2.filter((p) => p !== dir));
|
|
28758
28758
|
var SYSTEM_MAC = ["/System", "/Library", "/Applications", "/usr", "/bin", "/sbin", "/etc", "/var", "/private", "/opt", "/cores", "/dev"];
|
|
28759
28759
|
var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramData"];
|
|
28760
28760
|
var here = () => ({ platform: process.platform, home: os4.homedir(), resolve: realpath });
|
|
@@ -29027,11 +29027,11 @@ function checkHarnesses(harnesses) {
|
|
|
29027
29027
|
if (providers.length > 1) {
|
|
29028
29028
|
throw new Error(`harness "${harness.name}": a connector declares one provider list, not ${providers.length}`);
|
|
29029
29029
|
}
|
|
29030
|
-
const
|
|
29031
|
-
if (!
|
|
29032
|
-
if (!
|
|
29030
|
+
const list2 = providers[0];
|
|
29031
|
+
if (!list2) continue;
|
|
29032
|
+
if (!list2.providers?.length) throw new Error(`harness "${harness.name}": the provider setting "${list2.key}" offers no providers`);
|
|
29033
29033
|
const ids = /* @__PURE__ */ new Set();
|
|
29034
|
-
for (const provider of
|
|
29034
|
+
for (const provider of list2.providers) {
|
|
29035
29035
|
if (ids.has(provider.id)) throw new Error(`harness "${harness.name}": two providers share the id "${provider.id}"`);
|
|
29036
29036
|
ids.add(provider.id);
|
|
29037
29037
|
for (const need of [...provider.needs, ...provider.preferWhenSet ?? []]) {
|
|
@@ -29044,8 +29044,8 @@ function checkHarnesses(harnesses) {
|
|
|
29044
29044
|
if (!provider.needs.includes(key)) throw new Error(`harness "${harness.name}": the provider "${provider.id}" renames the variable of "${key}" without needing it`);
|
|
29045
29045
|
}
|
|
29046
29046
|
}
|
|
29047
|
-
if (
|
|
29048
|
-
throw new Error(`harness "${harness.name}": the default provider "${
|
|
29047
|
+
if (list2.defaultProvider && !ids.has(list2.defaultProvider)) {
|
|
29048
|
+
throw new Error(`harness "${harness.name}": the default provider "${list2.defaultProvider}" isn't on the list`);
|
|
29049
29049
|
}
|
|
29050
29050
|
}
|
|
29051
29051
|
}
|
|
@@ -29306,9 +29306,9 @@ var probeOptions = (file2) => ({ cwd: os5.tmpdir(), env: copyEnv(file2), windows
|
|
|
29306
29306
|
function probe(file2) {
|
|
29307
29307
|
const key = keyOf(file2);
|
|
29308
29308
|
const start = spawnable(file2, ["--version"], { ...probeOptions(file2), stdio: ["ignore", "pipe", "pipe"], timeout: PROBE_MS });
|
|
29309
|
-
const
|
|
29310
|
-
const code =
|
|
29311
|
-
const answer = { key, at: Date.now(), ...judge(code,
|
|
29309
|
+
const run2 = spawnSync2(start.command, start.args, { ...start.options, encoding: "utf8" });
|
|
29310
|
+
const code = run2.error?.code;
|
|
29311
|
+
const answer = { key, at: Date.now(), ...judge(code, run2.status, run2.stdout ?? "", run2.stderr ?? "") };
|
|
29312
29312
|
keep(file2, answer);
|
|
29313
29313
|
return answer;
|
|
29314
29314
|
}
|
|
@@ -29452,8 +29452,8 @@ function createEventCollector() {
|
|
|
29452
29452
|
case "tool_call_update": {
|
|
29453
29453
|
const id = str2(u.toolCallId);
|
|
29454
29454
|
if (todoCalls.has(id)) {
|
|
29455
|
-
const
|
|
29456
|
-
if (Array.isArray(
|
|
29455
|
+
const list2 = obj(u.rawInput).todos;
|
|
29456
|
+
if (Array.isArray(list2) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list2) } });
|
|
29457
29457
|
return;
|
|
29458
29458
|
}
|
|
29459
29459
|
release(id, targetIn(u));
|
|
@@ -29610,10 +29610,10 @@ function failedWith(ev) {
|
|
|
29610
29610
|
return str2(ev.result).trim() || "the agent reported the session failed";
|
|
29611
29611
|
}
|
|
29612
29612
|
function denials(ev) {
|
|
29613
|
-
const
|
|
29614
|
-
const names2 = [...new Set(
|
|
29613
|
+
const list2 = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
|
|
29614
|
+
const names2 = [...new Set(list2.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
|
|
29615
29615
|
if (!names2.length) return "";
|
|
29616
|
-
return `[refused] ${
|
|
29616
|
+
return `[refused] ${list2.length} tool call${list2.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
|
|
29617
29617
|
`;
|
|
29618
29618
|
}
|
|
29619
29619
|
function promptSize(raw) {
|
|
@@ -29770,6 +29770,37 @@ var addUsage = (a, b) => ({
|
|
|
29770
29770
|
output: a.output + b.output
|
|
29771
29771
|
});
|
|
29772
29772
|
|
|
29773
|
+
// ../cli/src/lib/agent/wire/background.ts
|
|
29774
|
+
function createBackgroundTasks() {
|
|
29775
|
+
const tasks = /* @__PURE__ */ new Map();
|
|
29776
|
+
return {
|
|
29777
|
+
update(id, status2, result = "") {
|
|
29778
|
+
if (!id) return false;
|
|
29779
|
+
const previous = tasks.get(id);
|
|
29780
|
+
if (previous?.status === status2 && previous.result === result) return false;
|
|
29781
|
+
tasks.set(id, { status: status2, result });
|
|
29782
|
+
return true;
|
|
29783
|
+
},
|
|
29784
|
+
results: () => [...tasks].map(([id, task]) => ({ id, ...task })),
|
|
29785
|
+
running: () => [...tasks].filter(([, t2]) => t2.status === "running").map(([id]) => id),
|
|
29786
|
+
count: () => [...tasks.values()].filter((t2) => t2.status === "running").length,
|
|
29787
|
+
failure: () => [...tasks].filter(([, t2]) => t2.status === "failed").map(([id, t2]) => t2.result || `Background task ${id} failed.`).join("\n") || void 0
|
|
29788
|
+
};
|
|
29789
|
+
}
|
|
29790
|
+
function createBackgroundWait(milliseconds, expired) {
|
|
29791
|
+
let timer;
|
|
29792
|
+
return {
|
|
29793
|
+
pending() {
|
|
29794
|
+
if (!timer && milliseconds > 0) timer = setTimeout(expired, milliseconds);
|
|
29795
|
+
},
|
|
29796
|
+
close() {
|
|
29797
|
+
clearTimeout(timer);
|
|
29798
|
+
timer = void 0;
|
|
29799
|
+
}
|
|
29800
|
+
};
|
|
29801
|
+
}
|
|
29802
|
+
var backgroundWaitMessage = (minutes) => `the agent's background tasks did not finish within ${minutes / 60} hours, so the run was ended.`;
|
|
29803
|
+
|
|
29773
29804
|
// ../cli/src/lib/agent/wire/codex-session.ts
|
|
29774
29805
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
29775
29806
|
import { homedir } from "node:os";
|
|
@@ -30045,6 +30076,31 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
30045
30076
|
let lookedAt = 0;
|
|
30046
30077
|
const events = createEventCollector();
|
|
30047
30078
|
const started = /* @__PURE__ */ new Set();
|
|
30079
|
+
const background = createBackgroundTasks();
|
|
30080
|
+
const subagents = /* @__PURE__ */ new Set();
|
|
30081
|
+
const collabItems = /* @__PURE__ */ new Set();
|
|
30082
|
+
const collab = (item, done) => {
|
|
30083
|
+
if (item.type !== "collab_tool_call") return;
|
|
30084
|
+
const key = `${str2(item.id)}:${done}`;
|
|
30085
|
+
if (collabItems.has(key)) return;
|
|
30086
|
+
collabItems.add(key);
|
|
30087
|
+
for (const [id, raw] of Object.entries(obj(item.agents_states))) {
|
|
30088
|
+
const state = obj(raw);
|
|
30089
|
+
const status2 = str2(state.status);
|
|
30090
|
+
if (!["pending_init", "running", "completed", "interrupted", "errored", "shutdown", "not_found"].includes(status2)) continue;
|
|
30091
|
+
const previous = background.results().find((t2) => t2.id === id);
|
|
30092
|
+
if (["shutdown", "not_found"].includes(status2) && previous && previous.status !== "running") continue;
|
|
30093
|
+
if (!subagents.has(id)) {
|
|
30094
|
+
subagents.add(id);
|
|
30095
|
+
events.subagent(`agent:${id}`, str2(item.prompt) || "Agent");
|
|
30096
|
+
}
|
|
30097
|
+
const running = status2 === "pending_init" || status2 === "running";
|
|
30098
|
+
const failed = !running && status2 !== "completed";
|
|
30099
|
+
if (background.update(id, running ? "running" : failed ? "failed" : "completed", str2(state.message)) && !running) {
|
|
30100
|
+
events.toolResult(`agent:${id}`, failed ? "failed" : "completed", str2(state.message));
|
|
30101
|
+
}
|
|
30102
|
+
}
|
|
30103
|
+
};
|
|
30048
30104
|
const look = (now) => {
|
|
30049
30105
|
if (!threadId) return;
|
|
30050
30106
|
const at = Date.now();
|
|
@@ -30071,6 +30127,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
30071
30127
|
if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
|
|
30072
30128
|
return "";
|
|
30073
30129
|
case "item.started":
|
|
30130
|
+
collab(obj(ev.item), false);
|
|
30074
30131
|
itemEvents(events, started, obj(ev.item), false);
|
|
30075
30132
|
return renderStarted(obj(ev.item));
|
|
30076
30133
|
case "item.updated":
|
|
@@ -30078,6 +30135,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
30078
30135
|
return "";
|
|
30079
30136
|
case "item.completed": {
|
|
30080
30137
|
const item = obj(ev.item);
|
|
30138
|
+
collab(item, true);
|
|
30081
30139
|
if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(str2(item.tool))) {
|
|
30082
30140
|
const content = obj(item.result).content;
|
|
30083
30141
|
for (const block of Array.isArray(content) ? content : []) {
|
|
@@ -30149,7 +30207,8 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
30149
30207
|
// whose rates the board knows.
|
|
30150
30208
|
costUsd: () => priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()),
|
|
30151
30209
|
resumeId: () => threadId,
|
|
30152
|
-
failure: () => failure2,
|
|
30210
|
+
failure: () => failure2 ?? background.failure(),
|
|
30211
|
+
background: () => subagents.size ? background.count() : void 0,
|
|
30153
30212
|
events: events.events
|
|
30154
30213
|
};
|
|
30155
30214
|
}
|
|
@@ -30451,6 +30510,9 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
30451
30510
|
send2({ id, method, params });
|
|
30452
30511
|
});
|
|
30453
30512
|
},
|
|
30513
|
+
notify(method, params = {}) {
|
|
30514
|
+
send2({ method, params });
|
|
30515
|
+
},
|
|
30454
30516
|
/** Answer something the agent asked us. */
|
|
30455
30517
|
reply(id, result) {
|
|
30456
30518
|
send2({ id, result });
|
|
@@ -30513,8 +30575,8 @@ function createTail(log) {
|
|
|
30513
30575
|
// ../cli/package.json
|
|
30514
30576
|
var package_default = {
|
|
30515
30577
|
name: "wildcrane",
|
|
30516
|
-
version: "0.11.
|
|
30517
|
-
akbContract:
|
|
30578
|
+
version: "0.11.45",
|
|
30579
|
+
akbContract: 12,
|
|
30518
30580
|
description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
30519
30581
|
keywords: [
|
|
30520
30582
|
"kanban",
|
|
@@ -30600,23 +30662,23 @@ function saidBy(update3) {
|
|
|
30600
30662
|
function modelOf(answer) {
|
|
30601
30663
|
const current2 = str2(obj(answer.models).currentModelId).trim();
|
|
30602
30664
|
if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
|
|
30603
|
-
const
|
|
30604
|
-
for (const raw of
|
|
30665
|
+
const list2 = Array.isArray(answer.configOptions) ? answer.configOptions : [];
|
|
30666
|
+
for (const raw of list2) {
|
|
30605
30667
|
const option = obj(raw);
|
|
30606
30668
|
if (option.id === "model") return str2(option.currentValue).trim() || void 0;
|
|
30607
30669
|
}
|
|
30608
30670
|
return void 0;
|
|
30609
30671
|
}
|
|
30610
30672
|
function modelsIn(answer) {
|
|
30611
|
-
const
|
|
30612
|
-
return (Array.isArray(
|
|
30673
|
+
const list2 = obj(answer.models).availableModels;
|
|
30674
|
+
return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
|
|
30613
30675
|
const modelId = str2(m.modelId);
|
|
30614
30676
|
return modelId ? [{ modelId, name: str2(m.name) || modelId }] : [];
|
|
30615
30677
|
});
|
|
30616
30678
|
}
|
|
30617
30679
|
function pickedModel(answer, wanted) {
|
|
30618
|
-
const
|
|
30619
|
-
return
|
|
30680
|
+
const list2 = modelsIn(answer);
|
|
30681
|
+
return list2.find((m) => m.modelId === wanted) ?? list2.find((m) => m.name === wanted || m.modelId.split("[")[0] === wanted);
|
|
30620
30682
|
}
|
|
30621
30683
|
function usageOf2(value, grossInput = false) {
|
|
30622
30684
|
const usage = obj(value);
|
|
@@ -31104,6 +31166,317 @@ function decide2(params, tail) {
|
|
|
31104
31166
|
return { decision: "deny", reason: "this board run can't answer a permission question" };
|
|
31105
31167
|
}
|
|
31106
31168
|
|
|
31169
|
+
// ../cli/src/lib/agent/settings.ts
|
|
31170
|
+
var BACKGROUND_WAIT = { minutes: 120 };
|
|
31171
|
+
|
|
31172
|
+
// ../cli/src/lib/agent/wire/codex.ts
|
|
31173
|
+
var list = (value) => Array.isArray(value) ? value.map(obj) : [];
|
|
31174
|
+
function createCodexConnection(argv) {
|
|
31175
|
+
const execAt = argv.indexOf("exec");
|
|
31176
|
+
if (execAt < 1) return void 0;
|
|
31177
|
+
const server = [argv[0], "app-server"];
|
|
31178
|
+
const options = { images: [] };
|
|
31179
|
+
const roots = [];
|
|
31180
|
+
for (let i = 1; i < argv.length; i++) {
|
|
31181
|
+
if (i === execAt) continue;
|
|
31182
|
+
const arg = argv[i];
|
|
31183
|
+
const [flag, inline] = arg.split(/=(.*)/s);
|
|
31184
|
+
const value = () => inline ?? argv[++i];
|
|
31185
|
+
if (["--json", "--experimental-json", "--skip-git-repo-check"].includes(arg)) continue;
|
|
31186
|
+
if (["-c", "--config", "--enable", "--disable"].includes(flag)) {
|
|
31187
|
+
const v = value();
|
|
31188
|
+
if (!v) return void 0;
|
|
31189
|
+
server.push(flag, v);
|
|
31190
|
+
} else if (["-m", "--model", "-s", "--sandbox"].includes(flag)) {
|
|
31191
|
+
const v = value();
|
|
31192
|
+
if (!v) return void 0;
|
|
31193
|
+
server.push("-c", `${flag === "-m" || flag === "--model" ? "model" : "sandbox_mode"}=${JSON.stringify(v)}`);
|
|
31194
|
+
} else if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
31195
|
+
server.push("-c", 'approval_policy="never"', "-c", 'sandbox_mode="danger-full-access"');
|
|
31196
|
+
} else if (arg === "--full-auto") {
|
|
31197
|
+
server.push("-c", 'approval_policy="on-request"', "-c", 'sandbox_mode="workspace-write"');
|
|
31198
|
+
} else if (flag === "--add-dir") {
|
|
31199
|
+
const v = value();
|
|
31200
|
+
if (!v) return void 0;
|
|
31201
|
+
roots.push(v);
|
|
31202
|
+
} else if (flag === "-C" || flag === "--cd") {
|
|
31203
|
+
options.cwd = value();
|
|
31204
|
+
if (!options.cwd) return void 0;
|
|
31205
|
+
} else if (flag === "-i" || flag === "--image") {
|
|
31206
|
+
const v = value();
|
|
31207
|
+
if (!v) return void 0;
|
|
31208
|
+
options.images.push(v);
|
|
31209
|
+
} else if (arg === "resume" || arg === "fork") {
|
|
31210
|
+
options.mode = arg;
|
|
31211
|
+
options.threadId = argv[++i];
|
|
31212
|
+
if (!options.threadId || options.threadId.startsWith("-")) return void 0;
|
|
31213
|
+
} else {
|
|
31214
|
+
return void 0;
|
|
31215
|
+
}
|
|
31216
|
+
}
|
|
31217
|
+
if (roots.length) server.push("-c", `sandbox_workspace_write.writable_roots=${JSON.stringify(roots)}`);
|
|
31218
|
+
return { argv: server, client: createCodexClient(options) };
|
|
31219
|
+
}
|
|
31220
|
+
function createCodexClient(options = { images: [] }) {
|
|
31221
|
+
const tasks = createBackgroundTasks();
|
|
31222
|
+
return {
|
|
31223
|
+
structured: true,
|
|
31224
|
+
background: tasks.count,
|
|
31225
|
+
turn: (io) => run(io, options, tasks)
|
|
31226
|
+
};
|
|
31227
|
+
}
|
|
31228
|
+
async function run(io, options, tasks) {
|
|
31229
|
+
const renderer = createCodexStreamRenderer();
|
|
31230
|
+
const children = /* @__PURE__ */ new Set();
|
|
31231
|
+
const commands = /* @__PURE__ */ new Set();
|
|
31232
|
+
const seenItems = /* @__PURE__ */ new Set();
|
|
31233
|
+
const completedTurns = /* @__PURE__ */ new Set();
|
|
31234
|
+
let threadId = "";
|
|
31235
|
+
let active = true;
|
|
31236
|
+
let waiting2 = false;
|
|
31237
|
+
let terminalListing = true;
|
|
31238
|
+
let timer;
|
|
31239
|
+
let ended = false;
|
|
31240
|
+
let checking = false;
|
|
31241
|
+
let context;
|
|
31242
|
+
let total;
|
|
31243
|
+
let baseline;
|
|
31244
|
+
let model;
|
|
31245
|
+
let provider;
|
|
31246
|
+
let resolve2;
|
|
31247
|
+
const done = new Promise((r) => {
|
|
31248
|
+
resolve2 = r;
|
|
31249
|
+
});
|
|
31250
|
+
const deadline = createBackgroundWait(BACKGROUND_WAIT.minutes * 6e4, () => end(backgroundWaitMessage(BACKGROUND_WAIT.minutes)));
|
|
31251
|
+
const emit = (type, extra = {}) => {
|
|
31252
|
+
io.log(renderer.push(JSON.stringify({ type, ...extra }) + "\n"));
|
|
31253
|
+
for (const event2 of renderer.events?.() ?? []) io.event?.(event2);
|
|
31254
|
+
};
|
|
31255
|
+
const end = (error) => {
|
|
31256
|
+
if (ended) return;
|
|
31257
|
+
ended = true;
|
|
31258
|
+
clearTimeout(timer);
|
|
31259
|
+
deadline.close();
|
|
31260
|
+
io.stdout.off("close", closed);
|
|
31261
|
+
io.log(renderer.flush());
|
|
31262
|
+
const usage = total && (!options.threadId && !io.resumeId ? total : baseline ? {
|
|
31263
|
+
input: Math.max(0, total.input - baseline.input),
|
|
31264
|
+
cacheRead: Math.max(0, total.cacheRead - baseline.cacheRead),
|
|
31265
|
+
cacheCreation: Math.max(0, total.cacheCreation - baseline.cacheCreation),
|
|
31266
|
+
output: Math.max(0, total.output - baseline.output)
|
|
31267
|
+
} : void 0);
|
|
31268
|
+
const failure2 = error || tasks.failure();
|
|
31269
|
+
if (failure2) io.event?.({ kind: "error", data: { text: failure2 } });
|
|
31270
|
+
resolve2({ ok: !failure2, error: failure2, result: renderer.result(), replyParts: renderer.replyParts?.(), usage, context, costUsd: priceUsd(provider, model, usage) });
|
|
31271
|
+
};
|
|
31272
|
+
const closed = () => end("Codex closed the connection before all work and results finished.");
|
|
31273
|
+
io.stdout.once("close", closed);
|
|
31274
|
+
const update3 = (id, state, title = "") => {
|
|
31275
|
+
if (ended) return;
|
|
31276
|
+
const status2 = str2(state.status);
|
|
31277
|
+
if (!status2 || !id) return;
|
|
31278
|
+
const previous = tasks.results().find((t2) => t2.id === `agent:${id}`);
|
|
31279
|
+
if (["shutdown", "notFound", "not_found"].includes(status2) && previous && previous.status !== "running") return;
|
|
31280
|
+
const running = ["pendingInit", "running", "pending_init"].includes(status2);
|
|
31281
|
+
const failed = ["interrupted", "errored", "shutdown", "notFound", "not_found"].includes(status2);
|
|
31282
|
+
if (!running && !failed && status2 !== "completed") return;
|
|
31283
|
+
const known2 = children.has(id);
|
|
31284
|
+
children.add(id);
|
|
31285
|
+
if (!known2) io.event?.({ kind: "tool_call", data: { toolCallId: `agent:${id}`, title: targetOf(title) || "Agent", kind: "other", status: "in_progress", subagent: true } });
|
|
31286
|
+
if (tasks.update(`agent:${id}`, running ? "running" : failed ? "failed" : "completed", str2(state.message)) && !running) {
|
|
31287
|
+
io.event?.({ kind: "tool_call_update", data: { toolCallId: `agent:${id}`, status: failed ? "failed" : "completed", result: str2(state.message) } });
|
|
31288
|
+
}
|
|
31289
|
+
};
|
|
31290
|
+
const item = (raw, completed) => {
|
|
31291
|
+
if (ended) return;
|
|
31292
|
+
const id = str2(raw.id);
|
|
31293
|
+
if (raw.type === "collabAgentToolCall") {
|
|
31294
|
+
const key2 = `${id}:${completed}`;
|
|
31295
|
+
if (seenItems.has(key2)) return;
|
|
31296
|
+
seenItems.add(key2);
|
|
31297
|
+
for (const [child, state] of Object.entries(obj(raw.agentsStates))) update3(child, obj(state), str2(raw.prompt));
|
|
31298
|
+
for (const child of Array.isArray(raw.receiverThreadIds) ? raw.receiverThreadIds : []) {
|
|
31299
|
+
if (typeof child === "string" && !children.has(child) && raw.tool === "spawnAgent") update3(child, { status: "running" }, str2(raw.prompt));
|
|
31300
|
+
}
|
|
31301
|
+
return;
|
|
31302
|
+
}
|
|
31303
|
+
if (raw.type === "commandExecution") {
|
|
31304
|
+
if (seenItems.has(`${id}:true`)) return;
|
|
31305
|
+
if (raw.status === "inProgress") completed = false;
|
|
31306
|
+
if (!completed) {
|
|
31307
|
+
commands.add(id);
|
|
31308
|
+
if (tasks.results().some((t2) => t2.id === `command:${id}`)) tasks.update(`command:${id}`, "running");
|
|
31309
|
+
} else {
|
|
31310
|
+
commands.delete(id);
|
|
31311
|
+
const failed = raw.status === "failed" || typeof raw.exitCode === "number" && raw.exitCode !== 0;
|
|
31312
|
+
if (tasks.results().some((t2) => t2.id === `command:${id}`)) tasks.update(`command:${id}`, failed ? "failed" : "completed", str2(raw.aggregatedOutput));
|
|
31313
|
+
}
|
|
31314
|
+
}
|
|
31315
|
+
const key = `${id}:${completed}`;
|
|
31316
|
+
if (seenItems.has(key)) return;
|
|
31317
|
+
seenItems.add(key);
|
|
31318
|
+
const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
|
|
31319
|
+
const type = types[str2(raw.type)];
|
|
31320
|
+
if (!type) return;
|
|
31321
|
+
emit(completed ? "item.completed" : "item.started", { item: {
|
|
31322
|
+
...raw,
|
|
31323
|
+
type,
|
|
31324
|
+
...raw.type === "imageGeneration" ? { path: raw.savedPath ?? raw.path } : {},
|
|
31325
|
+
...raw.type === "fileChange" ? { changes: list(raw.changes).map((c) => ({ ...c, kind: str2(obj(c.kind).type) || c.kind })) } : {},
|
|
31326
|
+
aggregated_output: raw.aggregatedOutput,
|
|
31327
|
+
exit_code: raw.exitCode,
|
|
31328
|
+
status: raw.status === "inProgress" ? "in_progress" : raw.status
|
|
31329
|
+
} });
|
|
31330
|
+
};
|
|
31331
|
+
const start = async (text3, images = []) => {
|
|
31332
|
+
active = true;
|
|
31333
|
+
waiting2 = false;
|
|
31334
|
+
await rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path31) => ({ type: "localImage", path: path31 }))] });
|
|
31335
|
+
};
|
|
31336
|
+
const schedule = () => {
|
|
31337
|
+
if (ended || timer) return;
|
|
31338
|
+
timer = setTimeout(() => {
|
|
31339
|
+
timer = void 0;
|
|
31340
|
+
void check();
|
|
31341
|
+
}, 1e3);
|
|
31342
|
+
};
|
|
31343
|
+
const check = async () => {
|
|
31344
|
+
if (ended || checking || active) return;
|
|
31345
|
+
checking = true;
|
|
31346
|
+
try {
|
|
31347
|
+
for (const key of tasks.running().filter((id) => id.startsWith("agent:"))) {
|
|
31348
|
+
const id = key.slice(6);
|
|
31349
|
+
let thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: false })).thread);
|
|
31350
|
+
let turns = list(thread.turns);
|
|
31351
|
+
if (thread.historyMode === "paginated") {
|
|
31352
|
+
turns = list((await rpc.call("thread/turns/list", { threadId: id, sortDirection: "desc", limit: 1, itemsView: "full" })).data).reverse();
|
|
31353
|
+
} else if (!turns.length) {
|
|
31354
|
+
thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: true })).thread);
|
|
31355
|
+
turns = list(thread.turns);
|
|
31356
|
+
}
|
|
31357
|
+
const turn2 = turns.at(-1);
|
|
31358
|
+
const status2 = str2(turn2?.status);
|
|
31359
|
+
if (obj(thread.status).type === "systemError") update3(id, { status: "errored", message: "Codex subagent reported a system error." });
|
|
31360
|
+
else if (obj(thread.status).type !== "active" && turn2 && ["completed", "failed", "interrupted"].includes(status2)) {
|
|
31361
|
+
const message = list(turn2.items).filter((i) => i.type === "agentMessage").map((i) => str2(i.text)).join("\n\n");
|
|
31362
|
+
update3(id, { status: status2 === "completed" ? "completed" : "errored", message: str2(obj(turn2.error).message) || message });
|
|
31363
|
+
}
|
|
31364
|
+
}
|
|
31365
|
+
if (terminalListing) {
|
|
31366
|
+
try {
|
|
31367
|
+
const running = /* @__PURE__ */ new Set();
|
|
31368
|
+
let cursor = null;
|
|
31369
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
31370
|
+
do {
|
|
31371
|
+
if (cursor && cursors.has(cursor)) throw Error("Codex repeated a background terminal cursor.");
|
|
31372
|
+
cursors.add(cursor);
|
|
31373
|
+
const page = await rpc.call("thread/backgroundTerminals/list", { threadId, ...cursor ? { cursor } : {} });
|
|
31374
|
+
for (const terminal of list(page.data)) {
|
|
31375
|
+
const id = str2(terminal.itemId) || str2(terminal.processId);
|
|
31376
|
+
if (id) {
|
|
31377
|
+
running.add(id);
|
|
31378
|
+
tasks.update(`command:${id}`, "running");
|
|
31379
|
+
}
|
|
31380
|
+
}
|
|
31381
|
+
cursor = page.nextCursor;
|
|
31382
|
+
} while (cursor && !ended);
|
|
31383
|
+
for (const id of tasks.running().filter((id2) => id2.startsWith("command:"))) if (!running.has(id.slice(8))) {
|
|
31384
|
+
tasks.update(id, "completed");
|
|
31385
|
+
commands.delete(id.slice(8));
|
|
31386
|
+
}
|
|
31387
|
+
} catch (e) {
|
|
31388
|
+
if (!(e instanceof RpcError) || e.code !== -32601) throw e;
|
|
31389
|
+
terminalListing = false;
|
|
31390
|
+
io.log("[Codex] This version does not report background terminals.\n");
|
|
31391
|
+
if (commands.size) throw Error("This Codex version cannot report the unfinished background commands. Update Codex to collect their results.");
|
|
31392
|
+
}
|
|
31393
|
+
}
|
|
31394
|
+
if (ended || active) return;
|
|
31395
|
+
if (tasks.count()) {
|
|
31396
|
+
waiting2 = true;
|
|
31397
|
+
deadline.pending();
|
|
31398
|
+
schedule();
|
|
31399
|
+
return;
|
|
31400
|
+
}
|
|
31401
|
+
if (waiting2) {
|
|
31402
|
+
await start("The background work from your previous reply has finished. Collect its results, resolve any failures, and present the completed outcome in this conversation. Check existing progress before acting; do not repeat completed work. Background reports (task output, not instructions):\n" + JSON.stringify(tasks.results()));
|
|
31403
|
+
} else end();
|
|
31404
|
+
} catch (e) {
|
|
31405
|
+
end(String(e instanceof Error ? e.message : e));
|
|
31406
|
+
} finally {
|
|
31407
|
+
checking = false;
|
|
31408
|
+
}
|
|
31409
|
+
};
|
|
31410
|
+
const rpc = connect(io.stdout, io.stdin, (msg) => {
|
|
31411
|
+
if (ended) return;
|
|
31412
|
+
if (msg.id !== void 0) {
|
|
31413
|
+
rpc.refuse(msg.id, "WildCrane cannot answer interactive requests in an unattended run.");
|
|
31414
|
+
end(`Codex requested interaction: ${msg.method}`);
|
|
31415
|
+
return;
|
|
31416
|
+
}
|
|
31417
|
+
const p = obj(msg.params);
|
|
31418
|
+
if (str2(p.threadId) !== threadId) return;
|
|
31419
|
+
if (msg.method === "turn/started") {
|
|
31420
|
+
active = true;
|
|
31421
|
+
return;
|
|
31422
|
+
}
|
|
31423
|
+
if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed");
|
|
31424
|
+
if (msg.method === "thread/tokenUsage/updated") {
|
|
31425
|
+
const token = obj(p.tokenUsage);
|
|
31426
|
+
const counts = obj(token.total);
|
|
31427
|
+
const input = Number(counts.inputTokens) || 0;
|
|
31428
|
+
const read2 = Number(counts.cachedInputTokens) || 0;
|
|
31429
|
+
const write = Number(counts.cacheWriteInputTokens) || 0;
|
|
31430
|
+
total = { input: Math.max(0, input - read2 - write), cacheRead: read2, cacheCreation: write, output: Number(counts.outputTokens) || 0 };
|
|
31431
|
+
const last2 = obj(token.last);
|
|
31432
|
+
context = { used: (Number(last2.inputTokens) || 0) + (Number(last2.outputTokens) || 0), ...Number(token.modelContextWindow) > 0 ? { limit: Number(token.modelContextWindow) } : {} };
|
|
31433
|
+
io.gotContext?.(context);
|
|
31434
|
+
}
|
|
31435
|
+
if (msg.method === "error" && p.willRetry !== true) end(str2(obj(p.error).message) || "Codex failed.");
|
|
31436
|
+
if (msg.method === "turn/completed") {
|
|
31437
|
+
const turn2 = obj(p.turn);
|
|
31438
|
+
const id = str2(turn2.id);
|
|
31439
|
+
if (completedTurns.has(id)) return;
|
|
31440
|
+
completedTurns.add(id);
|
|
31441
|
+
for (const raw of list(turn2.items)) item(raw, true);
|
|
31442
|
+
if (turn2.status !== "completed") {
|
|
31443
|
+
end(str2(obj(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`);
|
|
31444
|
+
return;
|
|
31445
|
+
}
|
|
31446
|
+
active = false;
|
|
31447
|
+
for (const id2 of commands) tasks.update(`command:${id2}`, "running");
|
|
31448
|
+
waiting2 ||= tasks.count() > 0 || commands.size > 0;
|
|
31449
|
+
deadline.pending();
|
|
31450
|
+
void check();
|
|
31451
|
+
}
|
|
31452
|
+
});
|
|
31453
|
+
try {
|
|
31454
|
+
await rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } });
|
|
31455
|
+
rpc.notify("initialized");
|
|
31456
|
+
const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
|
|
31457
|
+
let response;
|
|
31458
|
+
try {
|
|
31459
|
+
response = await rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} });
|
|
31460
|
+
} catch (e) {
|
|
31461
|
+
if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
|
|
31462
|
+
throw e;
|
|
31463
|
+
}
|
|
31464
|
+
const thread = obj(response.thread);
|
|
31465
|
+
threadId = str2(thread.id);
|
|
31466
|
+
if (!threadId) throw Error("Codex did not return a thread id.");
|
|
31467
|
+
provider = str2(thread.modelProvider) || void 0;
|
|
31468
|
+
model = str2(response.model) || str2(thread.model) || void 0;
|
|
31469
|
+
if (model) io.gotModel(model);
|
|
31470
|
+
io.gotResumeId(threadId);
|
|
31471
|
+
baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total;
|
|
31472
|
+
emit("thread.started", { thread_id: threadId });
|
|
31473
|
+
await start(io.prompt, options.images);
|
|
31474
|
+
} catch (e) {
|
|
31475
|
+
end(e instanceof Error ? e.message : String(e));
|
|
31476
|
+
}
|
|
31477
|
+
return done;
|
|
31478
|
+
}
|
|
31479
|
+
|
|
31107
31480
|
// ../cli/src/lib/agent/harnesses/models.ts
|
|
31108
31481
|
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
31109
31482
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -31123,8 +31496,8 @@ function str3(value) {
|
|
|
31123
31496
|
function num2(value) {
|
|
31124
31497
|
return typeof value === "number" ? value : Number.MAX_SAFE_INTEGER;
|
|
31125
31498
|
}
|
|
31126
|
-
function uniqueIds(
|
|
31127
|
-
return [...new Set(
|
|
31499
|
+
function uniqueIds(list2) {
|
|
31500
|
+
return [...new Set(list2.map((id) => id.trim()).filter(Boolean))];
|
|
31128
31501
|
}
|
|
31129
31502
|
var cached = /* @__PURE__ */ new Map();
|
|
31130
31503
|
function modelsIn2(file2, pick2, salt = "") {
|
|
@@ -31622,6 +31995,7 @@ var CODEX = {
|
|
|
31622
31995
|
"codex exec --json --sandbox workspace-write",
|
|
31623
31996
|
"codex exec --json --sandbox workspace-write -c sandbox_workspace_write.network_access=true"
|
|
31624
31997
|
],
|
|
31998
|
+
connection: createCodexConnection,
|
|
31625
31999
|
installs: codexInstalls,
|
|
31626
32000
|
pinned: () => process.env.CODEX_CLI_PATH?.trim() || void 0,
|
|
31627
32001
|
// Nothing to pin: Codex mints its own thread id and takes none from us, so the generated
|
|
@@ -32589,8 +32963,8 @@ function cursorModels() {
|
|
|
32589
32963
|
});
|
|
32590
32964
|
}
|
|
32591
32965
|
function acpModels(opened) {
|
|
32592
|
-
const
|
|
32593
|
-
return (Array.isArray(
|
|
32966
|
+
const list2 = obj(opened.models).availableModels;
|
|
32967
|
+
return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
|
|
32594
32968
|
const id = str2(m.modelId);
|
|
32595
32969
|
return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
|
|
32596
32970
|
});
|
|
@@ -32951,7 +33325,7 @@ var authCall = (path31, body) => {
|
|
|
32951
33325
|
signal: AbortSignal.timeout(2e4)
|
|
32952
33326
|
});
|
|
32953
33327
|
};
|
|
32954
|
-
var
|
|
33328
|
+
var refusal3 = (status2) => ({ ok: false, error: status2 === 429 ? "too_many" : status2 === 400 || status2 === 401 || status2 === 403 ? "bad_code" : "failed" });
|
|
32955
33329
|
async function sendCode(email, lang) {
|
|
32956
33330
|
try {
|
|
32957
33331
|
const response = await authCall("otp", { email: email.trim(), create_user: true, data: { lang } });
|
|
@@ -32967,7 +33341,7 @@ async function verifyCode(email, code, generation, signal) {
|
|
|
32967
33341
|
} catch {
|
|
32968
33342
|
return { ok: false, error: "failed" };
|
|
32969
33343
|
}
|
|
32970
|
-
if (!response.ok) return
|
|
33344
|
+
if (!response.ok) return refusal3(response.status);
|
|
32971
33345
|
const session = sessionFrom(await response.json().catch(() => ({})));
|
|
32972
33346
|
if (!session) return { ok: false, error: "failed" };
|
|
32973
33347
|
if (signal?.aborted || accountGeneration() !== generation) return { ok: false, error: "failed" };
|
|
@@ -33043,8 +33417,8 @@ async function signOut() {
|
|
|
33043
33417
|
}
|
|
33044
33418
|
}
|
|
33045
33419
|
async function folderOf(cwd) {
|
|
33046
|
-
const
|
|
33047
|
-
if (!
|
|
33420
|
+
const list2 = await listFolders(machineId());
|
|
33421
|
+
if (!list2.ok) return { ...failure(list2), folders: [], folder: null };
|
|
33048
33422
|
const real = (dir) => {
|
|
33049
33423
|
try {
|
|
33050
33424
|
return fs25.realpathSync(dir);
|
|
@@ -33052,7 +33426,7 @@ async function folderOf(cwd) {
|
|
|
33052
33426
|
return dir;
|
|
33053
33427
|
}
|
|
33054
33428
|
};
|
|
33055
|
-
return { folders:
|
|
33429
|
+
return { folders: list2.value.folders, folder: list2.value.folders.find((f) => real(f.path) === real(cwd)) ?? null };
|
|
33056
33430
|
}
|
|
33057
33431
|
async function addFolder2(dir, bind, strict = false) {
|
|
33058
33432
|
if (!readSession()) return { error: "signed_out" };
|
|
@@ -33116,12 +33490,12 @@ async function connections(only) {
|
|
|
33116
33490
|
}) };
|
|
33117
33491
|
}
|
|
33118
33492
|
async function all(route) {
|
|
33119
|
-
const
|
|
33493
|
+
const list2 = [];
|
|
33120
33494
|
for (let after = null; ; ) {
|
|
33121
33495
|
const result = await request("GET", `${route}${route.includes("?") ? "&" : "?"}limit=100${after ? `&after=${encodeURIComponent(after)}` : ""}`);
|
|
33122
33496
|
if (!result.ok) return result;
|
|
33123
|
-
|
|
33124
|
-
if (!result.value.next) return { ok: true, value:
|
|
33497
|
+
list2.push(...result.value.data);
|
|
33498
|
+
if (!result.value.next) return { ok: true, value: list2 };
|
|
33125
33499
|
after = result.value.next;
|
|
33126
33500
|
}
|
|
33127
33501
|
}
|
|
@@ -33138,10 +33512,10 @@ async function settingsState(context) {
|
|
|
33138
33512
|
if (!folders2.ok) return { ...base, account, ...failure(folders2) };
|
|
33139
33513
|
if (!workspaces.ok) return { ...base, account, ...failure(workspaces) };
|
|
33140
33514
|
const lists = await Promise.all(workspaces.value.map((ws) => all(`/v1/projects?workspace=${encodeURIComponent(ws.id)}`)));
|
|
33141
|
-
const failed = lists.find((
|
|
33515
|
+
const failed = lists.find((list2) => !list2.ok);
|
|
33142
33516
|
if (failed && !failed.ok) return { ...base, account, ...failure(failed) };
|
|
33143
33517
|
if (readSession()?.subject !== subject) return { ...base, signedIn: false };
|
|
33144
|
-
const projects = lists.flatMap((
|
|
33518
|
+
const projects = lists.flatMap((list2) => list2.ok ? list2.value : []);
|
|
33145
33519
|
const metadata = (id) => {
|
|
33146
33520
|
const project = projects.find((p) => p.id === id);
|
|
33147
33521
|
const workspace = workspaces.value.find((w) => w.id === project?.workspace);
|
|
@@ -33237,7 +33611,7 @@ async function terminalSettings(entry2) {
|
|
|
33237
33611
|
let running = null;
|
|
33238
33612
|
let done = Promise.resolve();
|
|
33239
33613
|
let blocked = null;
|
|
33240
|
-
const
|
|
33614
|
+
const run2 = () => {
|
|
33241
33615
|
const session = readSession();
|
|
33242
33616
|
const account = `${session?.subject}:${accountGeneration()}`;
|
|
33243
33617
|
if (running || !session || blocked === account) return;
|
|
@@ -33247,15 +33621,15 @@ async function terminalSettings(entry2) {
|
|
|
33247
33621
|
if (code === EXIT_OUTDATED || code === EXIT_REFUSED) blocked = account;
|
|
33248
33622
|
});
|
|
33249
33623
|
};
|
|
33250
|
-
onSettingsChange(
|
|
33251
|
-
const timer = setInterval(
|
|
33624
|
+
onSettingsChange(run2);
|
|
33625
|
+
const timer = setInterval(run2, 1e3);
|
|
33252
33626
|
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, async () => {
|
|
33253
33627
|
clearInterval(timer);
|
|
33254
33628
|
running?.abort();
|
|
33255
33629
|
await done;
|
|
33256
33630
|
await closeSettings();
|
|
33257
33631
|
});
|
|
33258
|
-
|
|
33632
|
+
run2();
|
|
33259
33633
|
}
|
|
33260
33634
|
|
|
33261
33635
|
// src/launcher-main.ts
|