wildcrane-runner 0.6.67 → 0.6.68
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 +28 -32
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +27974 -4
- package/dist/codex-service-main.mjs +29297 -0
- package/dist/flow-worker-main.mjs +744 -587
- package/dist/launcher.mjs +239 -241
- package/dist/plugin.mjs +326 -328
- package/dist/runner.mjs +686 -685
- package/dist/settings.mjs +300 -300
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.68 — 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;
|
|
@@ -26683,16 +26683,16 @@ ${captureLines}` : capture.stack;
|
|
|
26683
26683
|
});
|
|
26684
26684
|
|
|
26685
26685
|
// ../cli/src/lib/dress-page.ts
|
|
26686
|
-
import
|
|
26687
|
-
import
|
|
26686
|
+
import fs16 from "node:fs";
|
|
26687
|
+
import path17 from "node:path";
|
|
26688
26688
|
function dressPage(file2) {
|
|
26689
|
-
const folder =
|
|
26690
|
-
const html =
|
|
26689
|
+
const folder = path17.dirname(file2);
|
|
26690
|
+
const html = fs16.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
26691
26691
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
26692
26692
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
26693
|
-
const at3 =
|
|
26694
|
-
if (!at3.startsWith(folder +
|
|
26695
|
-
const css =
|
|
26693
|
+
const at3 = path17.resolve(folder, href);
|
|
26694
|
+
if (!at3.startsWith(folder + path17.sep) || !fs16.existsSync(at3)) return tag;
|
|
26695
|
+
const css = fs16.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path17.relative(folder, path17.resolve(path17.dirname(at3), src)).split(path17.sep).join("/")}${quote2})`);
|
|
26696
26696
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
26697
26697
|
});
|
|
26698
26698
|
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -26704,7 +26704,7 @@ var init_dress_page = __esm({
|
|
|
26704
26704
|
"use strict";
|
|
26705
26705
|
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
26706
26706
|
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
26707
|
-
referenceText = (file2) => /\.html$/i.test(file2) ? dressPage(file2) :
|
|
26707
|
+
referenceText = (file2) => /\.html$/i.test(file2) ? dressPage(file2) : fs16.readFileSync(file2, "utf8");
|
|
26708
26708
|
}
|
|
26709
26709
|
});
|
|
26710
26710
|
|
|
@@ -27323,14 +27323,14 @@ var require_react_development = __commonJS({
|
|
|
27323
27323
|
componentName = this.props.ref;
|
|
27324
27324
|
return void 0 !== componentName ? componentName : null;
|
|
27325
27325
|
}
|
|
27326
|
-
function ReactElement(type, key, props,
|
|
27326
|
+
function ReactElement(type, key, props, owner2, debugStack, debugTask) {
|
|
27327
27327
|
var refProp = props.ref;
|
|
27328
27328
|
type = {
|
|
27329
27329
|
$$typeof: REACT_ELEMENT_TYPE,
|
|
27330
27330
|
type,
|
|
27331
27331
|
key,
|
|
27332
27332
|
props,
|
|
27333
|
-
_owner:
|
|
27333
|
+
_owner: owner2
|
|
27334
27334
|
};
|
|
27335
27335
|
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
27336
27336
|
enumerable: false,
|
|
@@ -27901,7 +27901,7 @@ var require_react_development = __commonJS({
|
|
|
27901
27901
|
throw Error(
|
|
27902
27902
|
"The argument must be a React element, but you passed " + element + "."
|
|
27903
27903
|
);
|
|
27904
|
-
var props = assign({}, element.props), key = element.key,
|
|
27904
|
+
var props = assign({}, element.props), key = element.key, owner2 = element._owner;
|
|
27905
27905
|
if (null != config) {
|
|
27906
27906
|
var JSCompiler_inline_result;
|
|
27907
27907
|
a: {
|
|
@@ -27914,7 +27914,7 @@ var require_react_development = __commonJS({
|
|
|
27914
27914
|
}
|
|
27915
27915
|
JSCompiler_inline_result = void 0 !== config.ref;
|
|
27916
27916
|
}
|
|
27917
|
-
JSCompiler_inline_result && (
|
|
27917
|
+
JSCompiler_inline_result && (owner2 = getOwner());
|
|
27918
27918
|
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
|
27919
27919
|
for (propName in config)
|
|
27920
27920
|
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
@@ -27931,7 +27931,7 @@ var require_react_development = __commonJS({
|
|
|
27931
27931
|
element.type,
|
|
27932
27932
|
key,
|
|
27933
27933
|
props,
|
|
27934
|
-
|
|
27934
|
+
owner2,
|
|
27935
27935
|
element._debugStack,
|
|
27936
27936
|
element._debugTask
|
|
27937
27937
|
);
|
|
@@ -28320,14 +28320,14 @@ var require_react_jsx_runtime_development = __commonJS({
|
|
|
28320
28320
|
componentName = this.props.ref;
|
|
28321
28321
|
return void 0 !== componentName ? componentName : null;
|
|
28322
28322
|
}
|
|
28323
|
-
function ReactElement(type, key, props,
|
|
28323
|
+
function ReactElement(type, key, props, owner2, debugStack, debugTask) {
|
|
28324
28324
|
var refProp = props.ref;
|
|
28325
28325
|
type = {
|
|
28326
28326
|
$$typeof: REACT_ELEMENT_TYPE,
|
|
28327
28327
|
type,
|
|
28328
28328
|
key,
|
|
28329
28329
|
props,
|
|
28330
|
-
_owner:
|
|
28330
|
+
_owner: owner2
|
|
28331
28331
|
};
|
|
28332
28332
|
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
28333
28333
|
enumerable: false,
|
|
@@ -44085,13 +44085,13 @@ var require_react_dom_server_legacy_node_development = __commonJS({
|
|
|
44085
44085
|
if ("object" === typeof node && null !== node)
|
|
44086
44086
|
switch (node.$$typeof) {
|
|
44087
44087
|
case REACT_ELEMENT_TYPE:
|
|
44088
|
-
var type = node.type,
|
|
44088
|
+
var type = node.type, owner2 = node._owner, stack = node._debugStack;
|
|
44089
44089
|
pushServerComponentStack(task, node._debugInfo);
|
|
44090
44090
|
task.debugTask = node._debugTask;
|
|
44091
44091
|
task.componentStack = {
|
|
44092
44092
|
parent: task.componentStack,
|
|
44093
44093
|
type,
|
|
44094
|
-
owner,
|
|
44094
|
+
owner: owner2,
|
|
44095
44095
|
stack
|
|
44096
44096
|
};
|
|
44097
44097
|
break;
|
|
@@ -51797,13 +51797,13 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
51797
51797
|
if ("object" === typeof node && null !== node)
|
|
51798
51798
|
switch (node.$$typeof) {
|
|
51799
51799
|
case REACT_ELEMENT_TYPE:
|
|
51800
|
-
var type = node.type,
|
|
51800
|
+
var type = node.type, owner2 = node._owner, stack = node._debugStack;
|
|
51801
51801
|
pushServerComponentStack(task, node._debugInfo);
|
|
51802
51802
|
task.debugTask = node._debugTask;
|
|
51803
51803
|
task.componentStack = {
|
|
51804
51804
|
parent: task.componentStack,
|
|
51805
51805
|
type,
|
|
51806
|
-
owner,
|
|
51806
|
+
owner: owner2,
|
|
51807
51807
|
stack
|
|
51808
51808
|
};
|
|
51809
51809
|
break;
|
|
@@ -110866,8 +110866,8 @@ var init_dist = __esm({
|
|
|
110866
110866
|
});
|
|
110867
110867
|
|
|
110868
110868
|
// ../cli/src/lib/draw-mockup.ts
|
|
110869
|
-
import
|
|
110870
|
-
import
|
|
110869
|
+
import fs19 from "node:fs";
|
|
110870
|
+
import path20 from "node:path";
|
|
110871
110871
|
import vm from "node:vm";
|
|
110872
110872
|
async function loadPackage(id) {
|
|
110873
110873
|
if (id === "react") return import_react3.default;
|
|
@@ -110880,22 +110880,22 @@ async function loadPackage(id) {
|
|
|
110880
110880
|
return { __esModule: true, ...await load() };
|
|
110881
110881
|
}
|
|
110882
110882
|
function resolveFile(id, from, folder) {
|
|
110883
|
-
const at2 =
|
|
110884
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
110885
|
-
const tries =
|
|
110886
|
-
const file2 = tries.find((f2) =>
|
|
110883
|
+
const at2 = path20.resolve(path20.dirname(from), id);
|
|
110884
|
+
if (at2 !== folder && !at2.startsWith(folder + path20.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
110885
|
+
const tries = path20.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path20.join(at2, `index${e2}`))];
|
|
110886
|
+
const file2 = tries.find((f2) => fs19.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
110887
110887
|
if (!file2) throw new Error(`no such file: ${id}`);
|
|
110888
110888
|
return file2;
|
|
110889
110889
|
}
|
|
110890
110890
|
async function readGraph(entry) {
|
|
110891
|
-
const folder =
|
|
110891
|
+
const folder = path20.dirname(entry);
|
|
110892
110892
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
110893
110893
|
const walk = async (file2) => {
|
|
110894
110894
|
if (graph.code.has(file2)) return;
|
|
110895
110895
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
110896
110896
|
let location = file2;
|
|
110897
110897
|
try {
|
|
110898
|
-
const js = (0, import_sucrase.transform)(
|
|
110898
|
+
const js = (0, import_sucrase.transform)(fs19.readFileSync(file2, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file2 }).code;
|
|
110899
110899
|
graph.code.set(file2, js);
|
|
110900
110900
|
const link = /* @__PURE__ */ new Map();
|
|
110901
110901
|
graph.links.set(file2, link);
|
|
@@ -110909,7 +110909,7 @@ async function readGraph(entry) {
|
|
|
110909
110909
|
const target = resolveFile(id, file2, folder);
|
|
110910
110910
|
link.set(id, target);
|
|
110911
110911
|
if (!target.endsWith(".css")) await walk(target);
|
|
110912
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
110912
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs19.readFileSync(target, "utf8") });
|
|
110913
110913
|
}
|
|
110914
110914
|
} catch (error) {
|
|
110915
110915
|
throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -110926,12 +110926,12 @@ function run(script, context, name, deadline, lineOffset = 0) {
|
|
|
110926
110926
|
async function tailwindFor(markup, sheets) {
|
|
110927
110927
|
const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
110928
110928
|
const compiler = await rc(source, {
|
|
110929
|
-
base: sheets.length ?
|
|
110929
|
+
base: sheets.length ? path20.dirname(sheets[0].path) : "/",
|
|
110930
110930
|
loadStylesheet: async (id, from) => {
|
|
110931
110931
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
110932
110932
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
110933
|
-
const at2 =
|
|
110934
|
-
return { path: at2, base:
|
|
110933
|
+
const at2 = path20.resolve(from, id);
|
|
110934
|
+
return { path: at2, base: path20.dirname(at2), content: fs19.readFileSync(at2, "utf8") };
|
|
110935
110935
|
}
|
|
110936
110936
|
});
|
|
110937
110937
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -111714,8 +111714,8 @@ function tryLock(dir) {
|
|
|
111714
111714
|
}
|
|
111715
111715
|
if (entries.length) {
|
|
111716
111716
|
if (entries.length !== 1 || !/^\d+-[a-f0-9-]{36}$/.test(entries[0])) return void 0;
|
|
111717
|
-
const
|
|
111718
|
-
if (pidAlive(
|
|
111717
|
+
const owner2 = Number(entries[0].split("-")[0]);
|
|
111718
|
+
if (pidAlive(owner2)) return void 0;
|
|
111719
111719
|
}
|
|
111720
111720
|
if (!removeClaim(dir, entries[0])) return void 0;
|
|
111721
111721
|
}
|
|
@@ -111789,57 +111789,118 @@ __export(api_exports, {
|
|
|
111789
111789
|
});
|
|
111790
111790
|
|
|
111791
111791
|
// src/goals.ts
|
|
111792
|
+
import fs7 from "node:fs";
|
|
111793
|
+
import path8 from "node:path";
|
|
111794
|
+
|
|
111795
|
+
// src/settings-control.ts
|
|
111792
111796
|
import fs6 from "node:fs";
|
|
111793
111797
|
import path7 from "node:path";
|
|
111798
|
+
var directory = () => path7.join(runnerHome(), "executors");
|
|
111799
|
+
var epochFile = () => path7.join(runnerHome(), "account-generation");
|
|
111800
|
+
function accountGeneration() {
|
|
111801
|
+
try {
|
|
111802
|
+
return fs6.readFileSync(epochFile(), "utf8");
|
|
111803
|
+
} catch {
|
|
111804
|
+
return "";
|
|
111805
|
+
}
|
|
111806
|
+
}
|
|
111807
|
+
function executorRecord() {
|
|
111808
|
+
fs6.mkdirSync(directory(), { recursive: true, mode: 448 });
|
|
111809
|
+
const file2 = path7.join(directory(), `${process.pid}.json`);
|
|
111810
|
+
fs6.writeFileSync(file2, "{}", { mode: 384 });
|
|
111811
|
+
return () => fs6.rmSync(file2, { force: true });
|
|
111812
|
+
}
|
|
111813
|
+
|
|
111814
|
+
// src/goals.ts
|
|
111794
111815
|
function goalsOf(held5) {
|
|
111795
111816
|
if (held5.goals !== void 0 && held5.ideas !== void 0 && JSON.stringify(held5.goals) !== JSON.stringify(held5.ideas)) throw new Error("goals and ideas do not match.");
|
|
111796
111817
|
const goals = held5.goals ?? held5.ideas;
|
|
111797
111818
|
if (!Array.isArray(goals)) throw new Error("The goals array is missing or invalid.");
|
|
111798
111819
|
return goals;
|
|
111799
111820
|
}
|
|
111800
|
-
var goalsFileOf = (job) =>
|
|
111801
|
-
async function writeGoals(job, list2) {
|
|
111821
|
+
var goalsFileOf = (job) => path8.join(runnerHome(), "ideas", `${job.id}.json`);
|
|
111822
|
+
async function writeGoals(job, list2, preserveGoals = false) {
|
|
111802
111823
|
let goals;
|
|
111803
111824
|
try {
|
|
111804
|
-
goals = goalsOf(job.discussion);
|
|
111825
|
+
goals = preserveGoals && fs7.existsSync(goalsFileOf(job)) ? goalsOf(JSON.parse(fs7.readFileSync(goalsFileOf(job), "utf8"))) : goalsOf(job.discussion);
|
|
111805
111826
|
} catch (e2) {
|
|
111806
111827
|
return { error: String(e2) };
|
|
111807
111828
|
}
|
|
111808
|
-
|
|
111809
|
-
|
|
111810
|
-
|
|
111811
|
-
|
|
111812
|
-
|
|
111813
|
-
|
|
111814
|
-
after = page.value.next;
|
|
111815
|
-
} while (after);
|
|
111829
|
+
let studios;
|
|
111830
|
+
try {
|
|
111831
|
+
studios = await studioSnapshot(job.discussion.workspace, job.discussion.catalog, list2);
|
|
111832
|
+
} catch (e2) {
|
|
111833
|
+
return { error: e2 instanceof Error ? e2.message : String(e2) };
|
|
111834
|
+
}
|
|
111816
111835
|
const file2 = goalsFileOf(job);
|
|
111817
|
-
|
|
111818
|
-
|
|
111836
|
+
fs7.mkdirSync(path8.dirname(file2), { recursive: true });
|
|
111837
|
+
fs7.writeFileSync(file2, `${JSON.stringify({ workspace: job.discussion.workspace, studios, ideas: goals }, null, 2)}
|
|
111819
111838
|
`);
|
|
111820
111839
|
return { file: file2 };
|
|
111821
111840
|
}
|
|
111822
111841
|
function readGoals(file2) {
|
|
111823
111842
|
try {
|
|
111824
|
-
return goalsOf(JSON.parse(
|
|
111843
|
+
return goalsOf(JSON.parse(fs7.readFileSync(file2, "utf8")));
|
|
111825
111844
|
} catch {
|
|
111826
111845
|
return void 0;
|
|
111827
111846
|
} finally {
|
|
111828
|
-
|
|
111847
|
+
fs7.rmSync(file2, { force: true });
|
|
111848
|
+
}
|
|
111849
|
+
}
|
|
111850
|
+
var owner = "";
|
|
111851
|
+
var snapshots = /* @__PURE__ */ new Map();
|
|
111852
|
+
function clearStudioSnapshots() {
|
|
111853
|
+
owner = "";
|
|
111854
|
+
snapshots.clear();
|
|
111855
|
+
}
|
|
111856
|
+
async function studioSnapshot(workspace, catalog, list2) {
|
|
111857
|
+
const account = `${readSession()?.subject ?? ""}:${accountGeneration()}`;
|
|
111858
|
+
if (owner !== account) {
|
|
111859
|
+
clearStudioSnapshots();
|
|
111860
|
+
owner = account;
|
|
111861
|
+
}
|
|
111862
|
+
const reusable = catalog?.account === readSession()?.subject && !!catalog?.version;
|
|
111863
|
+
const key = reusable ? JSON.stringify([account, workspace, catalog.version]) : null;
|
|
111864
|
+
if (key && snapshots.has(key)) return snapshots.get(key);
|
|
111865
|
+
const load = async () => {
|
|
111866
|
+
const studios = [];
|
|
111867
|
+
let after = null;
|
|
111868
|
+
const seen = /* @__PURE__ */ new Set();
|
|
111869
|
+
do {
|
|
111870
|
+
const page = await list2(workspace, after);
|
|
111871
|
+
if (!page.ok) throw new Error(page.error);
|
|
111872
|
+
if (account !== `${readSession()?.subject ?? ""}:${accountGeneration()}`) throw new Error("Account changed while reading studios.");
|
|
111873
|
+
if (catalog?.version && page.value.catalogVersion && page.value.catalogVersion !== catalog.version) throw new Error("Studios changed while reading the catalog. Try again.");
|
|
111874
|
+
if (key && !page.value.catalogVersion) snapshots.delete(key);
|
|
111875
|
+
for (const w2 of page.value.data) studios.push({ ...w2, name: w2.names ? `${w2.names.en} / ${w2.names.zh}` : w2.name });
|
|
111876
|
+
after = page.value.next;
|
|
111877
|
+
if (after && seen.has(after)) throw new Error("The studio catalog did not finish.");
|
|
111878
|
+
if (after) seen.add(after);
|
|
111879
|
+
} while (after);
|
|
111880
|
+
return studios;
|
|
111881
|
+
};
|
|
111882
|
+
const loading = load();
|
|
111883
|
+
if (key) {
|
|
111884
|
+
if (snapshots.size >= 16) snapshots.delete(snapshots.keys().next().value);
|
|
111885
|
+
snapshots.set(key, loading);
|
|
111886
|
+
void loading.catch(() => {
|
|
111887
|
+
if (snapshots.get(key) === loading) snapshots.delete(key);
|
|
111888
|
+
});
|
|
111829
111889
|
}
|
|
111890
|
+
return loading;
|
|
111830
111891
|
}
|
|
111831
111892
|
|
|
111832
111893
|
// src/protocol.ts
|
|
111833
|
-
var AKB_VERSION = true ? "0.11.
|
|
111894
|
+
var AKB_VERSION = true ? "0.11.54" : "0.0.0";
|
|
111834
111895
|
var AKB_CONTRACT = true ? 15 : 0;
|
|
111835
111896
|
|
|
111836
111897
|
// src/secrets.ts
|
|
111837
|
-
import
|
|
111838
|
-
import
|
|
111839
|
-
var file = () =>
|
|
111898
|
+
import fs8 from "node:fs";
|
|
111899
|
+
import path9 from "node:path";
|
|
111900
|
+
var file = () => path9.join(runnerHome(), "secrets.json");
|
|
111840
111901
|
function readAll() {
|
|
111841
111902
|
try {
|
|
111842
|
-
const held5 = JSON.parse(
|
|
111903
|
+
const held5 = JSON.parse(fs8.readFileSync(file(), "utf8"));
|
|
111843
111904
|
return held5 && typeof held5 === "object" ? held5 : {};
|
|
111844
111905
|
} catch {
|
|
111845
111906
|
return {};
|
|
@@ -111855,11 +111916,11 @@ function keepSecrets(runtime, given) {
|
|
|
111855
111916
|
}
|
|
111856
111917
|
if (Object.keys(held5).length) all[runtime] = held5;
|
|
111857
111918
|
else delete all[runtime];
|
|
111858
|
-
|
|
111919
|
+
fs8.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
|
|
111859
111920
|
const temp = `${file()}.${process.pid}.tmp`;
|
|
111860
|
-
|
|
111921
|
+
fs8.writeFileSync(temp, `${JSON.stringify(all)}
|
|
111861
111922
|
`, { mode: 384 });
|
|
111862
|
-
|
|
111923
|
+
fs8.renameSync(temp, file());
|
|
111863
111924
|
}
|
|
111864
111925
|
var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id, keys]) => [id, Object.keys(keys)]));
|
|
111865
111926
|
|
|
@@ -112022,12 +112083,12 @@ var previewOperation = (machineId, job, agent, fields) => request("POST", `/v1/r
|
|
|
112022
112083
|
|
|
112023
112084
|
// src/cache.ts
|
|
112024
112085
|
import crypto2 from "node:crypto";
|
|
112025
|
-
import
|
|
112026
|
-
import
|
|
112086
|
+
import fs15 from "node:fs";
|
|
112087
|
+
import path16 from "node:path";
|
|
112027
112088
|
|
|
112028
112089
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
112029
|
-
import
|
|
112030
|
-
import
|
|
112090
|
+
import fs13 from "node:fs";
|
|
112091
|
+
import path14 from "node:path";
|
|
112031
112092
|
|
|
112032
112093
|
// ../cli/src/lib/shared/file-limits.ts
|
|
112033
112094
|
var BOARD_FILE_LIMIT = 10 * 1024 * 1024;
|
|
@@ -112080,8 +112141,8 @@ function cardFront(body) {
|
|
|
112080
112141
|
|
|
112081
112142
|
// ../official/pack.ts
|
|
112082
112143
|
import crypto from "node:crypto";
|
|
112083
|
-
import
|
|
112084
|
-
import
|
|
112144
|
+
import fs10 from "node:fs";
|
|
112145
|
+
import path11 from "node:path";
|
|
112085
112146
|
import { fileURLToPath } from "node:url";
|
|
112086
112147
|
|
|
112087
112148
|
// ../cli/src/lib/agents/icon.ts
|
|
@@ -112522,8 +112583,8 @@ function parseStudioFile(id, source, from) {
|
|
|
112522
112583
|
}
|
|
112523
112584
|
|
|
112524
112585
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
112525
|
-
import
|
|
112526
|
-
import
|
|
112586
|
+
import fs9 from "node:fs";
|
|
112587
|
+
import path10 from "node:path";
|
|
112527
112588
|
|
|
112528
112589
|
// ../cli/src/lib/shared/studio-files.ts
|
|
112529
112590
|
var STUDIO_FILE = "STUDIO.md";
|
|
@@ -112658,34 +112719,34 @@ function inspect(value, official) {
|
|
|
112658
112719
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
112659
112720
|
var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
112660
112721
|
function filesOf(dir, base = dir) {
|
|
112661
|
-
return
|
|
112662
|
-
const full =
|
|
112663
|
-
return e2.isDirectory() ? filesOf(full, base) : [
|
|
112722
|
+
return fs9.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
|
|
112723
|
+
const full = path10.join(dir, e2.name);
|
|
112724
|
+
return e2.isDirectory() ? filesOf(full, base) : [path10.relative(base, full).split(path10.sep).join("/")];
|
|
112664
112725
|
});
|
|
112665
112726
|
}
|
|
112666
112727
|
function readStudioFile(dir, file2) {
|
|
112667
|
-
const full =
|
|
112668
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[
|
|
112728
|
+
const full = path10.join(dir, file2);
|
|
112729
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path10.extname(file2)]};base64,${fs9.readFileSync(full).toString("base64")}` : fs9.readFileSync(full, "utf8");
|
|
112669
112730
|
}
|
|
112670
112731
|
var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readStudioFile(dir, f2)]));
|
|
112671
112732
|
|
|
112672
112733
|
// ../official/pack.ts
|
|
112673
|
-
var OFFICIAL =
|
|
112674
|
-
var dirs = (dir) =>
|
|
112734
|
+
var OFFICIAL = path11.dirname(fileURLToPath(import.meta.url));
|
|
112735
|
+
var dirs = (dir) => fs10.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
112675
112736
|
var hashOf = (files) => crypto.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
112676
112737
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
112677
|
-
const agentsDir =
|
|
112738
|
+
const agentsDir = path11.join(root2, "agents");
|
|
112678
112739
|
const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
|
|
112679
|
-
const dir =
|
|
112740
|
+
const dir = path11.join(agentsDir, name);
|
|
112680
112741
|
return [name, readStudioFolder(dir)];
|
|
112681
112742
|
}));
|
|
112682
112743
|
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
112683
112744
|
const read4 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
112684
112745
|
if ("problem" in read4) throw new Error(read4.problem);
|
|
112685
112746
|
}
|
|
112686
|
-
const studiosDir =
|
|
112747
|
+
const studiosDir = path11.join(root2, "studios");
|
|
112687
112748
|
return dirs(studiosDir).map((folder) => {
|
|
112688
|
-
const dir =
|
|
112749
|
+
const dir = path11.join(studiosDir, folder);
|
|
112689
112750
|
const files = {};
|
|
112690
112751
|
for (const f2 of filesOf(dir).sort()) {
|
|
112691
112752
|
if (f2 === STUDIO_FILE || f2 === CARD_TEMPLATE_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || f2.startsWith(SHARED_DIR) || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
|
|
@@ -112717,23 +112778,23 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
112717
112778
|
}
|
|
112718
112779
|
|
|
112719
112780
|
// ../cli/src/lib/cloud/tasks.ts
|
|
112720
|
-
import
|
|
112721
|
-
import
|
|
112781
|
+
import fs11 from "node:fs";
|
|
112782
|
+
import path12 from "node:path";
|
|
112722
112783
|
var TASK_ENV = "AI4KANBAN_TASK";
|
|
112723
112784
|
function workspaceTask() {
|
|
112724
112785
|
const id = process.env[TASK_ENV];
|
|
112725
112786
|
return id && id.trim() ? id.trim() : null;
|
|
112726
112787
|
}
|
|
112727
112788
|
function runnerProject(board) {
|
|
112728
|
-
if (
|
|
112729
|
-
const linked = linkedProject(board,
|
|
112789
|
+
if (path12.basename(board) !== "kanban" || path12.basename(path12.dirname(board)) !== ".akb") return null;
|
|
112790
|
+
const linked = linkedProject(board, path12.dirname(path12.dirname(board)));
|
|
112730
112791
|
return linked.ok ? linked.value : null;
|
|
112731
112792
|
}
|
|
112732
112793
|
function linkedProject(board, root2) {
|
|
112733
|
-
const file2 =
|
|
112734
|
-
if (!
|
|
112794
|
+
const file2 = path12.join(root2, ".akb", "base.json");
|
|
112795
|
+
if (!fs11.existsSync(file2)) return { ok: true, value: null };
|
|
112735
112796
|
try {
|
|
112736
|
-
const base = JSON.parse(
|
|
112797
|
+
const base = JSON.parse(fs11.readFileSync(file2, "utf8"));
|
|
112737
112798
|
if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
|
|
112738
112799
|
const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
|
|
112739
112800
|
if (typeof base.project === "string") projects.add(base.project);
|
|
@@ -112745,14 +112806,14 @@ function linkedProject(board, root2) {
|
|
|
112745
112806
|
}
|
|
112746
112807
|
|
|
112747
112808
|
// ../cli/src/lib/file-memo.ts
|
|
112748
|
-
import
|
|
112749
|
-
import
|
|
112809
|
+
import fs12 from "node:fs";
|
|
112810
|
+
import path13 from "node:path";
|
|
112750
112811
|
function stamp(paths) {
|
|
112751
112812
|
const parts = [];
|
|
112752
112813
|
const visit = (p2) => {
|
|
112753
112814
|
let st2;
|
|
112754
112815
|
try {
|
|
112755
|
-
st2 =
|
|
112816
|
+
st2 = fs12.statSync(p2, { bigint: true });
|
|
112756
112817
|
} catch {
|
|
112757
112818
|
parts.push(`${p2}:-`);
|
|
112758
112819
|
return;
|
|
@@ -112764,11 +112825,11 @@ function stamp(paths) {
|
|
|
112764
112825
|
parts.push(`${p2}/`);
|
|
112765
112826
|
let names2;
|
|
112766
112827
|
try {
|
|
112767
|
-
names2 =
|
|
112828
|
+
names2 = fs12.readdirSync(p2).sort();
|
|
112768
112829
|
} catch {
|
|
112769
112830
|
return;
|
|
112770
112831
|
}
|
|
112771
|
-
for (const name of names2) if (name !== "node_modules" && name !== ".git") visit(
|
|
112832
|
+
for (const name of names2) if (name !== "node_modules" && name !== ".git") visit(path13.join(p2, name));
|
|
112772
112833
|
};
|
|
112773
112834
|
for (const p2 of paths) visit(p2);
|
|
112774
112835
|
return parts.join("\n");
|
|
@@ -112811,29 +112872,29 @@ function memoByFiles(paths, read4) {
|
|
|
112811
112872
|
|
|
112812
112873
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
112813
112874
|
var DEV = "AI4KANBAN_STUDIOS";
|
|
112814
|
-
var root = () =>
|
|
112875
|
+
var root = () => path14.join(machineHome(), "studios");
|
|
112815
112876
|
var safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
112816
|
-
var versionFile = (id, version) =>
|
|
112817
|
-
var listFile = (project) =>
|
|
112818
|
-
var pinFile = (task) =>
|
|
112877
|
+
var versionFile = (id, version) => path14.join(root(), "versions", `${safe(id)}@${version}.json`);
|
|
112878
|
+
var listFile = (project) => path14.join(root(), "lists", `${safe(project)}.json`);
|
|
112879
|
+
var pinFile = (task) => path14.join(root(), "tasks", `${safe(task)}.json`);
|
|
112819
112880
|
function readJson(file2) {
|
|
112820
112881
|
try {
|
|
112821
|
-
return JSON.parse(
|
|
112882
|
+
return JSON.parse(fs13.readFileSync(file2, "utf8"));
|
|
112822
112883
|
} catch {
|
|
112823
112884
|
return null;
|
|
112824
112885
|
}
|
|
112825
112886
|
}
|
|
112826
112887
|
function writeJson(file2, value) {
|
|
112827
|
-
|
|
112888
|
+
fs13.mkdirSync(path14.dirname(file2), { recursive: true });
|
|
112828
112889
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
112829
|
-
|
|
112890
|
+
fs13.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
112830
112891
|
`);
|
|
112831
|
-
|
|
112892
|
+
fs13.renameSync(tmp, file2);
|
|
112832
112893
|
}
|
|
112833
112894
|
var readVersion2 = (id, version) => readJson(versionFile(id, version));
|
|
112834
112895
|
function saveVersion(held5) {
|
|
112835
112896
|
const file2 = versionFile(held5.id, held5.version);
|
|
112836
|
-
if (!
|
|
112897
|
+
if (!fs13.existsSync(file2)) writeJson(file2, { id: held5.id, version: held5.version, name: held5.name, names: held5.names, files: held5.files });
|
|
112837
112898
|
}
|
|
112838
112899
|
function savePin(task, held5) {
|
|
112839
112900
|
saveVersion(held5);
|
|
@@ -112878,14 +112939,14 @@ var cloudFlows = () => flows();
|
|
|
112878
112939
|
function cloudAgentFiles() {
|
|
112879
112940
|
const files = {};
|
|
112880
112941
|
const official = /* @__PURE__ */ new Set();
|
|
112881
|
-
const
|
|
112942
|
+
const owner2 = /* @__PURE__ */ new Map();
|
|
112882
112943
|
for (const flow of cloudFlows()) {
|
|
112883
112944
|
for (const [name, text3] of Object.entries(flow.files)) {
|
|
112884
112945
|
const at2 = /^agents\/([^/]+)\/(.+)$/.exec(name);
|
|
112885
112946
|
if (!at2) continue;
|
|
112886
112947
|
const [, agent, rest] = at2;
|
|
112887
|
-
if (
|
|
112888
|
-
|
|
112948
|
+
if (owner2.has(agent) && owner2.get(agent) !== flow.cloudId) continue;
|
|
112949
|
+
owner2.set(agent, flow.cloudId);
|
|
112889
112950
|
if (flow.builtIn) official.add(agent);
|
|
112890
112951
|
files[`${agent}/${rest}`] = text3;
|
|
112891
112952
|
}
|
|
@@ -112894,19 +112955,19 @@ function cloudAgentFiles() {
|
|
|
112894
112955
|
}
|
|
112895
112956
|
|
|
112896
112957
|
// src/folders.ts
|
|
112897
|
-
import
|
|
112898
|
-
import
|
|
112899
|
-
var projectsFile = () =>
|
|
112958
|
+
import fs14 from "node:fs";
|
|
112959
|
+
import path15 from "node:path";
|
|
112960
|
+
var projectsFile = () => path15.join(runnerHome(), "projects.json");
|
|
112900
112961
|
function realpath(p2) {
|
|
112901
112962
|
try {
|
|
112902
|
-
return
|
|
112963
|
+
return fs14.realpathSync(p2);
|
|
112903
112964
|
} catch {
|
|
112904
112965
|
return null;
|
|
112905
112966
|
}
|
|
112906
112967
|
}
|
|
112907
112968
|
function readGrants() {
|
|
112908
112969
|
try {
|
|
112909
|
-
const held5 = JSON.parse(
|
|
112970
|
+
const held5 = JSON.parse(fs14.readFileSync(projectsFile(), "utf8"));
|
|
112910
112971
|
if (!Array.isArray(held5.projects)) throw new Error("invalid_projects");
|
|
112911
112972
|
return held5;
|
|
112912
112973
|
} catch (error) {
|
|
@@ -112922,33 +112983,33 @@ function listOf(held5) {
|
|
|
112922
112983
|
function allowedProjects() {
|
|
112923
112984
|
return listOf(readGrants()).flatMap((p2) => {
|
|
112924
112985
|
const real = realpath(p2);
|
|
112925
|
-
return real &&
|
|
112986
|
+
return real && fs14.statSync(real).isDirectory() ? [real] : [];
|
|
112926
112987
|
});
|
|
112927
112988
|
}
|
|
112928
112989
|
|
|
112929
112990
|
// src/cache.ts
|
|
112930
112991
|
var IDLE_MS = 7 * 24 * 60 * 6e4;
|
|
112931
112992
|
var SWEEP_MS = 24 * 60 * 6e4;
|
|
112932
|
-
var akbDir = (dir) =>
|
|
112933
|
-
var usedFile = (dir) =>
|
|
112934
|
-
var unsentFile = (dir) =>
|
|
112993
|
+
var akbDir = (dir) => path16.join(dir, ".akb");
|
|
112994
|
+
var usedFile = (dir) => path16.join(akbDir(dir), "used.json");
|
|
112995
|
+
var unsentFile = (dir) => path16.join(akbDir(dir), "unsent");
|
|
112935
112996
|
function markUsed(dir, at2 = Date.now()) {
|
|
112936
|
-
|
|
112937
|
-
|
|
112997
|
+
fs15.mkdirSync(akbDir(dir), { recursive: true });
|
|
112998
|
+
fs15.writeFileSync(usedFile(dir), `${JSON.stringify({ at: at2 })}
|
|
112938
112999
|
`);
|
|
112939
113000
|
}
|
|
112940
|
-
var unsent = (dir) =>
|
|
113001
|
+
var unsent = (dir) => fs15.existsSync(unsentFile(dir));
|
|
112941
113002
|
function markUnsent(dir, unsent2) {
|
|
112942
|
-
if (!unsent2) return void
|
|
112943
|
-
|
|
112944
|
-
|
|
113003
|
+
if (!unsent2) return void fs15.rmSync(unsentFile(dir), { force: true });
|
|
113004
|
+
fs15.mkdirSync(akbDir(dir), { recursive: true });
|
|
113005
|
+
fs15.writeFileSync(unsentFile(dir), "");
|
|
112945
113006
|
}
|
|
112946
113007
|
var holds = /* @__PURE__ */ new Map();
|
|
112947
|
-
var holdsDir = () =>
|
|
112948
|
-
var holdFile = (dir) =>
|
|
113008
|
+
var holdsDir = () => path16.join(runnerHome(), "holds");
|
|
113009
|
+
var holdFile = (dir) => path16.join(holdsDir(), `${crypto2.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
|
|
112949
113010
|
function hold(dir) {
|
|
112950
|
-
|
|
112951
|
-
|
|
113011
|
+
fs15.mkdirSync(holdsDir(), { recursive: true, mode: 448 });
|
|
113012
|
+
fs15.writeFileSync(holdFile(dir), "", { mode: 384 });
|
|
112952
113013
|
holds.set(dir, (holds.get(dir) ?? 0) + 1);
|
|
112953
113014
|
let held5 = true;
|
|
112954
113015
|
return () => {
|
|
@@ -112958,14 +113019,14 @@ function hold(dir) {
|
|
|
112958
113019
|
if (left) holds.set(dir, left);
|
|
112959
113020
|
else {
|
|
112960
113021
|
holds.delete(dir);
|
|
112961
|
-
|
|
113022
|
+
fs15.rmSync(holdFile(dir), { force: true });
|
|
112962
113023
|
}
|
|
112963
113024
|
};
|
|
112964
113025
|
}
|
|
112965
113026
|
function paused(dir) {
|
|
112966
113027
|
try {
|
|
112967
|
-
const file2 =
|
|
112968
|
-
const held5 = JSON.parse(
|
|
113028
|
+
const file2 = path16.join(projectStateDir(path16.join(akbDir(dir), "kanban")), SESSIONS_FILE);
|
|
113029
|
+
const held5 = JSON.parse(fs15.readFileSync(file2, "utf8"));
|
|
112969
113030
|
return (held5.deliveries ?? []).some((d2) => d2.status === "active");
|
|
112970
113031
|
} catch {
|
|
112971
113032
|
return false;
|
|
@@ -112973,14 +113034,14 @@ function paused(dir) {
|
|
|
112973
113034
|
}
|
|
112974
113035
|
function busy(dir) {
|
|
112975
113036
|
if (holds.has(dir)) return true;
|
|
112976
|
-
const prefix =
|
|
113037
|
+
const prefix = path16.basename(holdFile(dir)).split(".")[0] + ".";
|
|
112977
113038
|
try {
|
|
112978
|
-
return
|
|
113039
|
+
return fs15.readdirSync(holdsDir()).filter((file2) => file2.startsWith(prefix)).some((file2) => {
|
|
112979
113040
|
try {
|
|
112980
113041
|
process.kill(Number(file2.split(".")[1]), 0);
|
|
112981
113042
|
return true;
|
|
112982
113043
|
} catch {
|
|
112983
|
-
|
|
113044
|
+
fs15.rmSync(path16.join(holdsDir(), file2), { force: true });
|
|
112984
113045
|
return false;
|
|
112985
113046
|
}
|
|
112986
113047
|
});
|
|
@@ -113313,13 +113374,13 @@ function collect(body, card, host) {
|
|
|
113313
113374
|
const nodes = /* @__PURE__ */ new Map();
|
|
113314
113375
|
const active = /* @__PURE__ */ new Set();
|
|
113315
113376
|
const out = [];
|
|
113316
|
-
const visit = (src, types,
|
|
113377
|
+
const visit = (src, types, owner2) => {
|
|
113317
113378
|
const path47 = src.replace(/[?#].*$/, "");
|
|
113318
113379
|
let resolved;
|
|
113319
113380
|
try {
|
|
113320
|
-
resolved = host.resolve(path47,
|
|
113381
|
+
resolved = host.resolve(path47, owner2);
|
|
113321
113382
|
} catch (error) {
|
|
113322
|
-
if (
|
|
113383
|
+
if (owner2 !== card) return { key: null, error: why(error) };
|
|
113323
113384
|
if (!nodes.has(src)) {
|
|
113324
113385
|
const node2 = { key: src, file: null, kind: kindAt(path47, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
113325
113386
|
nodes.set(src, node2);
|
|
@@ -113329,16 +113390,16 @@ function collect(body, card, host) {
|
|
|
113329
113390
|
}
|
|
113330
113391
|
if (!resolved) return { key: null };
|
|
113331
113392
|
const { key, file: file2 } = resolved;
|
|
113332
|
-
if (active.has(key)) throw new Error(`${
|
|
113393
|
+
if (active.has(key)) throw new Error(`${owner2}: ${src}: \u8D44\u6E90\u4F9D\u8D56\u5FAA\u73AF`);
|
|
113333
113394
|
const json = !!file2 && extOf(file2) === ".json";
|
|
113334
113395
|
const held5 = nodes.get(key);
|
|
113335
113396
|
if (held5) {
|
|
113336
|
-
if (
|
|
113397
|
+
if (owner2 === card) held5.aliases.add(src);
|
|
113337
113398
|
if (held5.error || !json || !types.length || held5.kind !== "asset") return { key, error: held5.error };
|
|
113338
113399
|
out.splice(out.indexOf(held5), 1);
|
|
113339
113400
|
}
|
|
113340
113401
|
const node = { key, file: file2, kind: "asset", problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: held5?.aliases ?? /* @__PURE__ */ new Set([key]) };
|
|
113341
|
-
if (
|
|
113402
|
+
if (owner2 === card) node.aliases.add(src);
|
|
113342
113403
|
nodes.set(key, node);
|
|
113343
113404
|
active.add(key);
|
|
113344
113405
|
const child = (ref, from) => {
|
|
@@ -113392,8 +113453,8 @@ function collect(body, card, host) {
|
|
|
113392
113453
|
|
|
113393
113454
|
// src/task-folder.ts
|
|
113394
113455
|
import crypto4 from "node:crypto";
|
|
113395
|
-
import
|
|
113396
|
-
import
|
|
113456
|
+
import fs20 from "node:fs";
|
|
113457
|
+
import path21 from "node:path";
|
|
113397
113458
|
import { isDeepStrictEqual } from "node:util";
|
|
113398
113459
|
|
|
113399
113460
|
// node_modules/node-diff3/dist/diff3.mjs
|
|
@@ -113642,8 +113703,8 @@ init_dress_page();
|
|
|
113642
113703
|
|
|
113643
113704
|
// src/kanban-skill.ts
|
|
113644
113705
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
113645
|
-
import
|
|
113646
|
-
import
|
|
113706
|
+
import fs17 from "node:fs";
|
|
113707
|
+
import path18 from "node:path";
|
|
113647
113708
|
|
|
113648
113709
|
// ../skill/SKILL.md
|
|
113649
113710
|
var SKILL_default = '---\nname: kanban\ndescription: Manage the file-based task board with akb. Use for creating and planning tasks, revising or implementing cards, and managing background runs; also for "what\'s running".\n---\n\n# Kanban board\n\nThe board is worked only through `akb`. Find the command for the job in `akb help` and run\nit; never do its work by hand or from memory.\n\n- **`--print` does it here**: `akb raw card revise 12 --print "drop the export"` prints the whole\n flow for that card on this board; follow it to its closing steps. Without `--print` the\n same command starts a separate agent.\n- **Keys**: never read or write API keys; the user sets them with `akb raw agent set apiKey`.\n';
|
|
@@ -113657,24 +113718,24 @@ var CONTENT = `${SKILL_default.trimEnd()}
|
|
|
113657
113718
|
var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
|
|
113658
113719
|
function prepareKanbanSkill(root2) {
|
|
113659
113720
|
for (const folder of SKILL_FOLDERS) {
|
|
113660
|
-
const dir =
|
|
113661
|
-
const file2 =
|
|
113721
|
+
const dir = path18.join(root2, folder);
|
|
113722
|
+
const file2 = path18.join(dir, "SKILL.md");
|
|
113662
113723
|
try {
|
|
113663
113724
|
let linked = false;
|
|
113664
113725
|
let at2 = root2;
|
|
113665
113726
|
for (const name of `${folder}/SKILL.md`.split("/")) {
|
|
113666
|
-
at2 =
|
|
113667
|
-
if (
|
|
113727
|
+
at2 = path18.join(at2, name);
|
|
113728
|
+
if (fs17.lstatSync(at2, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
|
|
113668
113729
|
}
|
|
113669
|
-
const held5 =
|
|
113670
|
-
const exists =
|
|
113730
|
+
const held5 = fs17.existsSync(file2) ? fs17.readFileSync(file2, "utf8") : null;
|
|
113731
|
+
const exists = fs17.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
|
|
113671
113732
|
if (linked || exists && !MANAGED.test(held5 ?? "")) {
|
|
113672
113733
|
if (!held5?.trim()) throw new Error("\u7528\u6237\u81EA\u6709\u76EE\u5F55\u6216\u7B26\u53F7\u94FE\u63A5\u4E2D\u7F3A\u5C11\u53EF\u8BFB\u7684 SKILL.md");
|
|
113673
113734
|
continue;
|
|
113674
113735
|
}
|
|
113675
113736
|
if (held5 !== CONTENT) {
|
|
113676
|
-
|
|
113677
|
-
|
|
113737
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
113738
|
+
fs17.writeFileSync(file2, CONTENT);
|
|
113678
113739
|
}
|
|
113679
113740
|
} catch (e2) {
|
|
113680
113741
|
throw new Error(`\u65E0\u6CD5\u51C6\u5907 ${folder}\uFF1A${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
@@ -113687,16 +113748,16 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
|
|
|
113687
113748
|
if (inside2.status !== 0) return;
|
|
113688
113749
|
const missing = [".akb/", ...folders2.map((f2) => `${f2}/`)].filter((p2) => git2("check-ignore", "-q", p2).status !== 0);
|
|
113689
113750
|
if (!missing.length) return;
|
|
113690
|
-
const exclude =
|
|
113691
|
-
|
|
113692
|
-
const held5 =
|
|
113693
|
-
|
|
113751
|
+
const exclude = path18.resolve(dir, inside2.stdout.trim());
|
|
113752
|
+
fs17.mkdirSync(path18.dirname(exclude), { recursive: true });
|
|
113753
|
+
const held5 = fs17.existsSync(exclude) ? fs17.readFileSync(exclude, "utf8") : "";
|
|
113754
|
+
fs17.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
|
|
113694
113755
|
`);
|
|
113695
113756
|
}
|
|
113696
113757
|
|
|
113697
113758
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
113698
|
-
import
|
|
113699
|
-
import
|
|
113759
|
+
import fs18 from "node:fs";
|
|
113760
|
+
import path19 from "node:path";
|
|
113700
113761
|
|
|
113701
113762
|
// ../cli/src/lib/agents/bundled.ts
|
|
113702
113763
|
var shippedAgentFiles = () => cloudAgentFiles().files;
|
|
@@ -113710,7 +113771,7 @@ function sharedMemory(board) {
|
|
|
113710
113771
|
const read4 = parseSpecAgent(text3, folder, (relative) => {
|
|
113711
113772
|
if (builtIn) return shippedAgentFiles()[`${folder}/${relative}`] ?? null;
|
|
113712
113773
|
try {
|
|
113713
|
-
return
|
|
113774
|
+
return fs18.readFileSync(path19.join(board, "agents", folder, relative), "utf8");
|
|
113714
113775
|
} catch {
|
|
113715
113776
|
return null;
|
|
113716
113777
|
}
|
|
@@ -113721,16 +113782,16 @@ function sharedMemory(board) {
|
|
|
113721
113782
|
const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
|
|
113722
113783
|
if (at2) take(at2[1], text3, officialAgent(at2[1]));
|
|
113723
113784
|
}
|
|
113724
|
-
const root2 =
|
|
113785
|
+
const root2 = path19.join(board, "agents");
|
|
113725
113786
|
let folders2 = [];
|
|
113726
113787
|
try {
|
|
113727
|
-
folders2 =
|
|
113788
|
+
folders2 = fs18.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
|
|
113728
113789
|
} catch {
|
|
113729
113790
|
}
|
|
113730
113791
|
for (const folder of folders2.sort()) {
|
|
113731
113792
|
let text3 = null;
|
|
113732
113793
|
try {
|
|
113733
|
-
text3 =
|
|
113794
|
+
text3 = fs18.readFileSync(path19.join(root2, folder, "AGENT.md"), "utf8");
|
|
113734
113795
|
} catch {
|
|
113735
113796
|
}
|
|
113736
113797
|
take(folder, text3, false);
|
|
@@ -113790,16 +113851,16 @@ function openTaskFolder(job, projectDir) {
|
|
|
113790
113851
|
if (!projectDir) throw new Error(NO_FOLDER);
|
|
113791
113852
|
keepOutOfGit(projectDir);
|
|
113792
113853
|
markUsed(projectDir);
|
|
113793
|
-
const board =
|
|
113794
|
-
|
|
113854
|
+
const board = path21.join(projectDir, ".akb", "kanban");
|
|
113855
|
+
fs20.mkdirSync(board, { recursive: true });
|
|
113795
113856
|
return { task, cloudTask: task, board, cwd: projectDir, project: job.project, number: job.number ?? null, studio: job.studio ?? job.flow?.studio ?? null };
|
|
113796
113857
|
}
|
|
113797
113858
|
function openAgentFolder(job, projectDir) {
|
|
113798
113859
|
if (!job.project || !job.agent) throw new Error("This job names no project.");
|
|
113799
113860
|
keepOutOfGit(projectDir);
|
|
113800
113861
|
markUsed(projectDir);
|
|
113801
|
-
const board =
|
|
113802
|
-
|
|
113862
|
+
const board = path21.join(projectDir, ".akb", "kanban");
|
|
113863
|
+
fs20.mkdirSync(board, { recursive: true });
|
|
113803
113864
|
return {
|
|
113804
113865
|
task: `agent-${safe2(job.agent.studio ? `${job.agent.studio}-${job.agent.name}` : job.agent.name)}`,
|
|
113805
113866
|
cloudTask: job.agent.tasks?.[0]?.id ?? null,
|
|
@@ -113814,8 +113875,8 @@ function openDiscussionFolder(job, projectDir) {
|
|
|
113814
113875
|
if (!job.project) throw new Error("This job names no project.");
|
|
113815
113876
|
keepOutOfGit(projectDir);
|
|
113816
113877
|
markUsed(projectDir);
|
|
113817
|
-
const board =
|
|
113818
|
-
|
|
113878
|
+
const board = path21.join(projectDir, ".akb", "kanban");
|
|
113879
|
+
fs20.mkdirSync(board, { recursive: true });
|
|
113819
113880
|
return { task: "discussion", cloudTask: null, board, cwd: projectDir, project: job.project, number: null, studio: null };
|
|
113820
113881
|
}
|
|
113821
113882
|
var boardFolder = (ws) => ({ task: "board", cloudTask: null, board: ws.board, cwd: ws.cwd, project: ws.project, number: null, studio: null });
|
|
@@ -113840,37 +113901,37 @@ function inFolder(dir, work) {
|
|
|
113840
113901
|
}
|
|
113841
113902
|
var safe2 = (name) => name.replace(/[^\w.-]/g, "_") || "default";
|
|
113842
113903
|
var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
|
|
113843
|
-
var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ??
|
|
113904
|
+
var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path21.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
|
|
113844
113905
|
function findCard(board, number) {
|
|
113845
113906
|
const named = new RegExp(`^${number}-`);
|
|
113846
113907
|
const walk = (dir) => {
|
|
113847
113908
|
let entries;
|
|
113848
113909
|
try {
|
|
113849
|
-
entries =
|
|
113910
|
+
entries = fs20.readdirSync(dir, { withFileTypes: true });
|
|
113850
113911
|
} catch {
|
|
113851
113912
|
return null;
|
|
113852
113913
|
}
|
|
113853
113914
|
for (const e2 of entries) {
|
|
113854
113915
|
if (!named.test(e2.name)) continue;
|
|
113855
|
-
if (e2.isFile() && e2.name.endsWith(".md")) return
|
|
113856
|
-
const root2 =
|
|
113857
|
-
if (e2.isDirectory() &&
|
|
113916
|
+
if (e2.isFile() && e2.name.endsWith(".md")) return path21.join(dir, e2.name);
|
|
113917
|
+
const root2 = path21.join(dir, e2.name, "root.md");
|
|
113918
|
+
if (e2.isDirectory() && fs20.existsSync(root2)) return root2;
|
|
113858
113919
|
}
|
|
113859
113920
|
for (const e2 of entries) if (e2.isDirectory() && !e2.name.startsWith(".")) {
|
|
113860
|
-
const hit = walk(
|
|
113921
|
+
const hit = walk(path21.join(dir, e2.name));
|
|
113861
113922
|
if (hit) return hit;
|
|
113862
113923
|
}
|
|
113863
113924
|
return null;
|
|
113864
113925
|
};
|
|
113865
|
-
return walk(
|
|
113926
|
+
return walk(path21.join(board, "todo")) ?? walk(path21.join(board, ".archive"));
|
|
113866
113927
|
}
|
|
113867
113928
|
function akbCardOf(ws) {
|
|
113868
113929
|
return ws.number && findCard(ws.board, ws.number) ? ws.number : void 0;
|
|
113869
113930
|
}
|
|
113870
|
-
var recordFile = (ws) =>
|
|
113931
|
+
var recordFile = (ws) => path21.join(ws.board, ".sync", `${ws.task}.json`);
|
|
113871
113932
|
function readRecord(ws) {
|
|
113872
113933
|
try {
|
|
113873
|
-
return { ...EMPTY, ...JSON.parse(
|
|
113934
|
+
return { ...EMPTY, ...JSON.parse(fs20.readFileSync(recordFile(ws), "utf8")) };
|
|
113874
113935
|
} catch {
|
|
113875
113936
|
return structuredClone(EMPTY);
|
|
113876
113937
|
}
|
|
@@ -113881,8 +113942,8 @@ function writeRecord(ws, record) {
|
|
|
113881
113942
|
if (readText(recordFile(ws)) === content) return;
|
|
113882
113943
|
countSync("recordWrites");
|
|
113883
113944
|
if (syncDebug) countSync("recordBytes", Buffer.byteLength(content));
|
|
113884
|
-
|
|
113885
|
-
|
|
113945
|
+
fs20.mkdirSync(path21.dirname(recordFile(ws)), { recursive: true });
|
|
113946
|
+
fs20.writeFileSync(recordFile(ws), content);
|
|
113886
113947
|
}
|
|
113887
113948
|
async function cleanRecords(ws, base, removed = [], tasks) {
|
|
113888
113949
|
const retired = /* @__PURE__ */ new Set();
|
|
@@ -113890,11 +113951,11 @@ async function cleanRecords(ws, base, removed = [], tasks) {
|
|
|
113890
113951
|
const removedPaths = new Set(removed);
|
|
113891
113952
|
const numbers = new Set(Object.keys(base.files).filter((p2) => p2.startsWith(root2) && !removedPaths.has(p2)).map((p2) => numberOfCard(p2.slice(root2.length))));
|
|
113892
113953
|
const deleted = new Map(removed.filter((p2) => p2.startsWith(root2 + ".archive/")).map((p2) => [numberOfCard(p2.slice(root2.length)), p2.slice(root2.length)]));
|
|
113893
|
-
for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(
|
|
113954
|
+
for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path21.join(ws.board, ".sync"))) {
|
|
113894
113955
|
if (!name.endsWith(".json") || name.includes("/")) continue;
|
|
113895
113956
|
let record;
|
|
113896
113957
|
try {
|
|
113897
|
-
record = JSON.parse(
|
|
113958
|
+
record = JSON.parse(fs20.readFileSync(path21.join(ws.board, ".sync", name), "utf8"));
|
|
113898
113959
|
} catch {
|
|
113899
113960
|
continue;
|
|
113900
113961
|
}
|
|
@@ -113918,13 +113979,13 @@ async function cleanRecords(ws, base, removed = [], tasks) {
|
|
|
113918
113979
|
index.retiring.add(record.task);
|
|
113919
113980
|
if (card || kept(ws.cwd) || base.pendingAssets?.includes(record.task)) continue;
|
|
113920
113981
|
const list2 = assetsFile(record.task);
|
|
113921
|
-
const here = readText(
|
|
113982
|
+
const here = readText(path21.join(ws.board, list2));
|
|
113922
113983
|
if (here !== null && here !== (base.files[root2 + list2]?.content ?? null)) continue;
|
|
113923
113984
|
let changed = false;
|
|
113924
113985
|
for (const [name2, entry] of Object.entries(record.assets ?? {})) {
|
|
113925
113986
|
let file2;
|
|
113926
113987
|
try {
|
|
113927
|
-
file2 = assetPath(folder, name2, typeof record.deleted === "string" ?
|
|
113988
|
+
file2 = assetPath(folder, name2, typeof record.deleted === "string" ? path21.join(ws.board, record.deleted) : cardFile(folder));
|
|
113928
113989
|
} catch {
|
|
113929
113990
|
changed = true;
|
|
113930
113991
|
break;
|
|
@@ -113937,16 +113998,16 @@ async function cleanRecords(ws, base, removed = [], tasks) {
|
|
|
113937
113998
|
}
|
|
113938
113999
|
}
|
|
113939
114000
|
if (!changed) {
|
|
113940
|
-
|
|
114001
|
+
fs20.rmSync(recordFile(folder), { force: true });
|
|
113941
114002
|
forgetTask(index, record.task);
|
|
113942
114003
|
}
|
|
113943
114004
|
}
|
|
113944
114005
|
return retired;
|
|
113945
114006
|
}
|
|
113946
|
-
var baseFile = (ws) =>
|
|
114007
|
+
var baseFile = (ws) => path21.join(ws.cwd, ".akb", "base.json");
|
|
113947
114008
|
function readBase(ws) {
|
|
113948
114009
|
try {
|
|
113949
|
-
const base = JSON.parse(
|
|
114010
|
+
const base = JSON.parse(fs20.readFileSync(baseFile(ws), "utf8"));
|
|
113950
114011
|
if (base.layout === "workspace") return base;
|
|
113951
114012
|
} catch {
|
|
113952
114013
|
}
|
|
@@ -113954,25 +114015,25 @@ function readBase(ws) {
|
|
|
113954
114015
|
}
|
|
113955
114016
|
function writeBase(ws, base) {
|
|
113956
114017
|
const file2 = baseFile(ws);
|
|
113957
|
-
|
|
113958
|
-
|
|
113959
|
-
|
|
114018
|
+
fs20.mkdirSync(path21.dirname(file2), { recursive: true });
|
|
114019
|
+
fs20.writeFileSync(`${file2}.tmp`, JSON.stringify(base));
|
|
114020
|
+
fs20.renameSync(`${file2}.tmp`, file2);
|
|
113960
114021
|
}
|
|
113961
114022
|
var hashOf2 = (bytes2) => crypto4.createHash("sha256").update(bytes2).digest("hex");
|
|
113962
114023
|
function hashFile(file2) {
|
|
113963
114024
|
try {
|
|
113964
|
-
return hashOf2(
|
|
114025
|
+
return hashOf2(fs20.readFileSync(file2));
|
|
113965
114026
|
} catch {
|
|
113966
114027
|
return null;
|
|
113967
114028
|
}
|
|
113968
114029
|
}
|
|
113969
114030
|
function write(file2, bytes2) {
|
|
113970
|
-
|
|
113971
|
-
|
|
114031
|
+
fs20.mkdirSync(path21.dirname(file2), { recursive: true });
|
|
114032
|
+
fs20.writeFileSync(file2, bytes2);
|
|
113972
114033
|
}
|
|
113973
114034
|
function readText(file2) {
|
|
113974
114035
|
try {
|
|
113975
|
-
return
|
|
114036
|
+
return fs20.readFileSync(file2, "utf8");
|
|
113976
114037
|
} catch {
|
|
113977
114038
|
return null;
|
|
113978
114039
|
}
|
|
@@ -113980,14 +114041,14 @@ function readText(file2) {
|
|
|
113980
114041
|
function filesUnder(dir, base = dir) {
|
|
113981
114042
|
let entries;
|
|
113982
114043
|
try {
|
|
113983
|
-
entries =
|
|
114044
|
+
entries = fs20.readdirSync(dir, { withFileTypes: true });
|
|
113984
114045
|
} catch {
|
|
113985
114046
|
return [];
|
|
113986
114047
|
}
|
|
113987
114048
|
return entries.flatMap((e2) => {
|
|
113988
|
-
const full =
|
|
114049
|
+
const full = path21.join(dir, e2.name);
|
|
113989
114050
|
if (e2.isDirectory()) return filesUnder(full, base);
|
|
113990
|
-
return e2.isFile() ? [
|
|
114051
|
+
return e2.isFile() ? [path21.relative(base, full).split(path21.sep).join("/")] : [];
|
|
113991
114052
|
});
|
|
113992
114053
|
}
|
|
113993
114054
|
var kept2 = isBoardPath;
|
|
@@ -114010,18 +114071,18 @@ function assetFiles(ws, list2) {
|
|
|
114010
114071
|
return null;
|
|
114011
114072
|
}
|
|
114012
114073
|
};
|
|
114013
|
-
return new Set(Object.keys(assetsOf(list2)).map(at2).filter((f2) => !!f2).map((f2) =>
|
|
114074
|
+
return new Set(Object.keys(assetsOf(list2)).map(at2).filter((f2) => !!f2).map((f2) => path21.relative(ws.board, f2).split(path21.sep).join("/")));
|
|
114014
114075
|
}
|
|
114015
114076
|
var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
|
|
114016
114077
|
var localFiles = (ws, base) => {
|
|
114017
|
-
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(
|
|
114078
|
+
const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path21.join(ws.board, assetsFile(ws.task))))]);
|
|
114018
114079
|
return filesUnder(ws.board).filter((p2) => kept2(p2) && !assets.has(p2));
|
|
114019
114080
|
};
|
|
114020
114081
|
var SKILL_PATH = /^skills\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?:[\w.-]+\/)*[\w.-]+)$/;
|
|
114021
114082
|
function pullTools(ws, record, files) {
|
|
114022
114083
|
const held5 = record.tools?.skills ?? {};
|
|
114023
114084
|
const ours = new Set(Object.keys(held5).map((name) => name.split("/")[1]));
|
|
114024
|
-
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) =>
|
|
114085
|
+
const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs20.existsSync(path21.join(ws.cwd, root2, skill)));
|
|
114025
114086
|
const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
|
|
114026
114087
|
const skills = {};
|
|
114027
114088
|
for (const [name, text3] of Object.entries(files)) {
|
|
@@ -114029,7 +114090,7 @@ function pullTools(ws, record, files) {
|
|
|
114029
114090
|
if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
|
|
114030
114091
|
skills[name] = hashOf2(text3);
|
|
114031
114092
|
for (const root2 of SKILL_ROOTS) {
|
|
114032
|
-
const file2 =
|
|
114093
|
+
const file2 = path21.join(ws.cwd, root2, at2[1], at2[2]);
|
|
114033
114094
|
if (held5[name] !== skills[name] || hashFile(file2) !== skills[name]) write(file2, text3);
|
|
114034
114095
|
}
|
|
114035
114096
|
}
|
|
@@ -114038,8 +114099,8 @@ function pullTools(ws, record, files) {
|
|
|
114038
114099
|
const [, skill, rest] = SKILL_PATH.exec(name) ?? [];
|
|
114039
114100
|
if (!skill || !rest) continue;
|
|
114040
114101
|
for (const root2 of SKILL_ROOTS) {
|
|
114041
|
-
|
|
114042
|
-
if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`)))
|
|
114102
|
+
fs20.rmSync(path21.join(ws.cwd, root2, skill, rest), { force: true });
|
|
114103
|
+
if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs20.rmSync(path21.join(ws.cwd, root2, skill), { recursive: true, force: true });
|
|
114043
114104
|
}
|
|
114044
114105
|
}
|
|
114045
114106
|
const names2 = [...new Set(Object.keys(skills).map((name) => name.split("/")[1]))];
|
|
@@ -114076,46 +114137,46 @@ async function pullStudio(ws, record) {
|
|
|
114076
114137
|
if (files.ok) pullTools(ws, record, files.value);
|
|
114077
114138
|
}
|
|
114078
114139
|
dropPlacedAgents(ws);
|
|
114079
|
-
for (const name of Object.keys(record.agents ?? {}))
|
|
114140
|
+
for (const name of Object.keys(record.agents ?? {})) fs20.rmSync(path21.join(ws.board, name), { force: true });
|
|
114080
114141
|
record.agents = {};
|
|
114081
114142
|
return { ok: true, value: void 0 };
|
|
114082
114143
|
}
|
|
114083
|
-
var agentsRecord = (ws) =>
|
|
114144
|
+
var agentsRecord = (ws) => path21.join(ws.board, ".sync", "agents.json");
|
|
114084
114145
|
function readPlaced(ws) {
|
|
114085
114146
|
try {
|
|
114086
|
-
return JSON.parse(
|
|
114147
|
+
return JSON.parse(fs20.readFileSync(agentsRecord(ws), "utf8"));
|
|
114087
114148
|
} catch {
|
|
114088
114149
|
return {};
|
|
114089
114150
|
}
|
|
114090
114151
|
}
|
|
114091
114152
|
function dropPlacedAgents(ws) {
|
|
114092
114153
|
const placed = readPlaced(ws);
|
|
114093
|
-
for (const name of Object.keys(placed)) if (hashFile(
|
|
114094
|
-
|
|
114154
|
+
for (const name of Object.keys(placed)) if (hashFile(path21.join(ws.board, name)) === placed[name]) fs20.rmSync(path21.join(ws.board, name), { force: true });
|
|
114155
|
+
fs20.rmSync(agentsRecord(ws), { force: true });
|
|
114095
114156
|
}
|
|
114096
|
-
function assetPath(ws, name,
|
|
114157
|
+
function assetPath(ws, name, owner2) {
|
|
114097
114158
|
if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
|
|
114098
|
-
if (
|
|
114159
|
+
if (path21.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
|
|
114099
114160
|
const held5 = /^\.(assets|mockups)\//.exec(name);
|
|
114100
114161
|
const state = stateDir(ws);
|
|
114101
|
-
const root2 = held5 && state ?
|
|
114102
|
-
const file2 = held5 && state ?
|
|
114103
|
-
const roots = [ws.board, ...state ? ["assets", "mockups"].map((folder) =>
|
|
114104
|
-
const inside2 = (file3, root3) => file3.startsWith(root3 +
|
|
114162
|
+
const root2 = held5 && state ? path21.join(state, held5[1]) : ws.board;
|
|
114163
|
+
const file2 = held5 && state ? path21.resolve(root2, name.slice(held5[0].length)) : path21.resolve(path21.dirname(owner2), name);
|
|
114164
|
+
const roots = [ws.board, ...state ? ["assets", "mockups"].map((folder) => path21.join(state, folder, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
114165
|
+
const inside2 = (file3, root3) => file3.startsWith(root3 + path21.sep);
|
|
114105
114166
|
if (!roots.some((root3) => inside2(file2, root3))) throw new Error(`outside the board: ${name}`);
|
|
114106
114167
|
let existing = file2;
|
|
114107
|
-
while (!
|
|
114108
|
-
const real =
|
|
114168
|
+
while (!fs20.existsSync(existing) && path21.dirname(existing) !== existing) existing = path21.dirname(existing);
|
|
114169
|
+
const real = path21.join(fs20.realpathSync(existing), path21.relative(existing, file2));
|
|
114109
114170
|
let stateParent = state;
|
|
114110
|
-
while (stateParent && !
|
|
114111
|
-
const realState = state && stateParent ?
|
|
114112
|
-
const realRoots = [
|
|
114171
|
+
while (stateParent && !fs20.existsSync(stateParent) && path21.dirname(stateParent) !== stateParent) stateParent = path21.dirname(stateParent);
|
|
114172
|
+
const realState = state && stateParent ? path21.resolve(fs20.realpathSync(stateParent), path21.relative(stateParent, state)) : null;
|
|
114173
|
+
const realRoots = [fs20.realpathSync(ws.board), ...realState ? ["assets", "mockups"].map((folder) => path21.join(realState, folder, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
114113
114174
|
if (!realRoots.some((root3) => real === root3 || inside2(real, root3))) throw new Error(`link outside the board: ${name}`);
|
|
114114
114175
|
return file2;
|
|
114115
114176
|
}
|
|
114116
114177
|
function cardAssetsDir(ws, id) {
|
|
114117
114178
|
const state = stateDir(ws);
|
|
114118
|
-
return state &&
|
|
114179
|
+
return state && path21.join(state, "assets", String(id));
|
|
114119
114180
|
}
|
|
114120
114181
|
function stateDir(ws) {
|
|
114121
114182
|
try {
|
|
@@ -114154,7 +114215,7 @@ async function readCloud(ws) {
|
|
|
114154
114215
|
const base = readBase(ws);
|
|
114155
114216
|
const previous = { ...base.files };
|
|
114156
114217
|
const known2 = new Set(Object.keys(base.files));
|
|
114157
|
-
const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(
|
|
114218
|
+
const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path21.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
|
|
114158
114219
|
if (base.workspace === void 0) {
|
|
114159
114220
|
const project = await readProject(ws.project);
|
|
114160
114221
|
if (!project.ok) return project;
|
|
@@ -114170,20 +114231,20 @@ async function readCloud(ws) {
|
|
|
114170
114231
|
const removed = [...known2].filter((p2) => !base.files[p2]);
|
|
114171
114232
|
for (const p2 of removed) {
|
|
114172
114233
|
const local = p2.startsWith(rootOf(ws)) ? p2.slice(rootOf(ws).length) : p2;
|
|
114173
|
-
if (local.startsWith(".archive/") && readText(
|
|
114234
|
+
if (local.startsWith(".archive/") && readText(path21.join(ws.board, local)) !== null && readText(path21.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
|
|
114174
114235
|
}
|
|
114175
114236
|
base.head_seq = read4.value.head_seq;
|
|
114176
114237
|
base.project = ws.project;
|
|
114177
114238
|
writeBase(ws, base);
|
|
114178
114239
|
const reset = (view2) => {
|
|
114179
114240
|
for (const [p2, content] of view2) {
|
|
114180
|
-
const file2 =
|
|
114241
|
+
const file2 = path21.join(ws.board, p2);
|
|
114181
114242
|
if (!keepDraft.has(p2) && kept2(p2) && readText(file2) !== content) write(file2, content);
|
|
114182
114243
|
}
|
|
114183
114244
|
};
|
|
114184
114245
|
const view = viewOf(ws, base, sharedMemory(ws.board));
|
|
114185
114246
|
const first = (p2) => isSettingsPath(p2) && !known2.has(rootOf(ws) + p2);
|
|
114186
|
-
for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2))
|
|
114247
|
+
for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs20.rmSync(path21.join(ws.board, p2), { force: true });
|
|
114187
114248
|
reset(view);
|
|
114188
114249
|
const retired = await cleanRecords(ws, base, removed);
|
|
114189
114250
|
if (retired.has(ws.task)) {
|
|
@@ -114201,18 +114262,18 @@ async function readCloud(ws) {
|
|
|
114201
114262
|
return { ok: true, value: void 0 };
|
|
114202
114263
|
}
|
|
114203
114264
|
function writeIndex(board) {
|
|
114204
|
-
const todo =
|
|
114265
|
+
const todo = path21.join(board, "todo");
|
|
114205
114266
|
const cards = [];
|
|
114206
114267
|
let entries = [];
|
|
114207
114268
|
try {
|
|
114208
|
-
entries =
|
|
114269
|
+
entries = fs20.readdirSync(todo, { withFileTypes: true });
|
|
114209
114270
|
} catch {
|
|
114210
114271
|
}
|
|
114211
114272
|
for (const e2 of entries) {
|
|
114212
114273
|
const id = /^(\d+)-/.exec(e2.name)?.[1];
|
|
114213
114274
|
if (!id) continue;
|
|
114214
114275
|
const link = e2.isDirectory() ? `${e2.name}/root.md` : e2.name.endsWith(".md") ? e2.name : null;
|
|
114215
|
-
const text4 = link && readText(
|
|
114276
|
+
const text4 = link && readText(path21.join(todo, link));
|
|
114216
114277
|
if (text4 === null || !link) continue;
|
|
114217
114278
|
cards.push({ id: Number(id), title: cardFront(text4).title ?? e2.name.replace(/\.md$/, ""), link });
|
|
114218
114279
|
}
|
|
@@ -114227,7 +114288,7 @@ the number at the front of a filename is the task id.
|
|
|
114227
114288
|
|
|
114228
114289
|
${list2}
|
|
114229
114290
|
`;
|
|
114230
|
-
if (readText(
|
|
114291
|
+
if (readText(path21.join(todo, "README.md")) !== text3) write(path21.join(todo, "README.md"), text3);
|
|
114231
114292
|
}
|
|
114232
114293
|
var workspaceOf = (ws) => readBase(ws).workspace ?? null;
|
|
114233
114294
|
async function pullAssets(ws, record, assets) {
|
|
@@ -114306,7 +114367,7 @@ async function pullAssets(ws, record, assets) {
|
|
|
114306
114367
|
}
|
|
114307
114368
|
if (!child) return src;
|
|
114308
114369
|
dependencies.push(name2);
|
|
114309
|
-
const back = !found.text && /^\.(assets|mockups)\//.test(name2) ? name2 :
|
|
114370
|
+
const back = !found.text && /^\.(assets|mockups)\//.test(name2) ? name2 : path21.relative(path21.dirname(target), child).split(path21.sep).join("/");
|
|
114310
114371
|
if (back !== src) changed = true;
|
|
114311
114372
|
return back;
|
|
114312
114373
|
});
|
|
@@ -114343,16 +114404,16 @@ async function readAsset(artifact, version) {
|
|
|
114343
114404
|
return { ok: true, value: Buffer.from(typeof content === "string" ? content : JSON.stringify(content)) };
|
|
114344
114405
|
}
|
|
114345
114406
|
async function sentOf(file2, kind) {
|
|
114346
|
-
const ext =
|
|
114347
|
-
if (kind !== "html") return { bytes:
|
|
114407
|
+
const ext = path21.extname(file2).toLowerCase();
|
|
114408
|
+
if (kind !== "html") return { bytes: fs20.readFileSync(file2), type: kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext] ?? "application/octet-stream", kind };
|
|
114348
114409
|
const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file2);
|
|
114349
114410
|
return { bytes: Buffer.from(page), type: "text/html", kind };
|
|
114350
114411
|
}
|
|
114351
|
-
var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(
|
|
114412
|
+
var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path21.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
|
|
114352
114413
|
function undrawn(ws, reason) {
|
|
114353
114414
|
const state = stateDir(ws);
|
|
114354
|
-
for (const [root2, shown] of [...state ? [[
|
|
114355
|
-
reason = reason.split(`file://${root2}${
|
|
114415
|
+
for (const [root2, shown] of [...state ? [[path21.join(state, "assets"), ".assets"], [path21.join(state, "mockups"), ".mockups"]] : [], [ws.board, ""]]) {
|
|
114416
|
+
reason = reason.split(`file://${root2}${path21.sep}`).join(shown && `${shown}/`).split(`${root2}${path21.sep}`).join(shown && `${shown}/`);
|
|
114356
114417
|
}
|
|
114357
114418
|
return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
|
|
114358
114419
|
}
|
|
@@ -114387,28 +114448,28 @@ async function pushAssets(ws, record, before) {
|
|
|
114387
114448
|
if (body === null) return { ok: true, value: void 0 };
|
|
114388
114449
|
const refs = {};
|
|
114389
114450
|
const canonical = (target) => {
|
|
114390
|
-
const real = (file3) =>
|
|
114451
|
+
const real = (file3) => fs20.existsSync(file3) ? fs20.realpathSync(file3) : path21.dirname(file3) === file3 ? file3 : path21.join(real(path21.dirname(file3)), path21.basename(file3));
|
|
114391
114452
|
target = real(target);
|
|
114392
114453
|
const state = stateDir(ws);
|
|
114393
114454
|
for (const folder of ["assets", "mockups"]) {
|
|
114394
|
-
const root2 = state && real(
|
|
114395
|
-
if (root2 && target.startsWith(root2 +
|
|
114455
|
+
const root2 = state && real(path21.join(state, folder));
|
|
114456
|
+
if (root2 && target.startsWith(root2 + path21.sep)) return `.${folder}/${path21.relative(root2, target).split(path21.sep).join("/")}`;
|
|
114396
114457
|
}
|
|
114397
|
-
return
|
|
114458
|
+
return path21.relative(real(path21.dirname(file2)), target).split(path21.sep).join("/");
|
|
114398
114459
|
};
|
|
114399
114460
|
try {
|
|
114400
114461
|
const graph = collect(body, file2, {
|
|
114401
|
-
resolve: (src,
|
|
114462
|
+
resolve: (src, owner2) => {
|
|
114402
114463
|
const id = Object.entries(before).find(([, ref]) => ref.artifact === src);
|
|
114403
114464
|
if (id) return { key: id[0], file: null };
|
|
114404
|
-
const target = assetPath(ws, src,
|
|
114465
|
+
const target = assetPath(ws, src, owner2);
|
|
114405
114466
|
if (!target) return null;
|
|
114406
|
-
const key =
|
|
114407
|
-
if (!
|
|
114467
|
+
const key = owner2 === file2 && before[src] ? src : canonical(target);
|
|
114468
|
+
if (!fs20.statSync(target, { throwIfNoEntry: false })?.isFile()) {
|
|
114408
114469
|
if (before[key]) return { key, file: null };
|
|
114409
114470
|
throw new Error(`file not found: ${target}`);
|
|
114410
114471
|
}
|
|
114411
|
-
return { key: canonical(
|
|
114472
|
+
return { key: canonical(fs20.realpathSync(target)), file: target };
|
|
114412
114473
|
},
|
|
114413
114474
|
read: referenceText,
|
|
114414
114475
|
retained: (key) => (record.assets[key]?.dependencies ?? []).map((src) => {
|
|
@@ -114424,7 +114485,7 @@ async function pushAssets(ws, record, before) {
|
|
|
114424
114485
|
let why2 = node.error ?? [...node.dependencies.values()].map((key) => refs[key]?.error).find(Boolean);
|
|
114425
114486
|
if (!why2 && node.file) {
|
|
114426
114487
|
try {
|
|
114427
|
-
if (
|
|
114488
|
+
if (fs20.statSync(node.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
|
|
114428
114489
|
out = await sentOf(node.file, kind);
|
|
114429
114490
|
} catch (error) {
|
|
114430
114491
|
why2 = renderError(error);
|
|
@@ -114482,7 +114543,7 @@ async function pushAssets(ws, record, before) {
|
|
|
114482
114543
|
const unchanged = restored && previous && (previous.kind ?? out.kind) === out.kind && localHash === (previous.localHash ?? previous.hash) && [...node.dependencies.values()].every((key) => refs[key]?.artifact === before[key]?.artifact);
|
|
114483
114544
|
if (!entry || !unchanged && entry.hash !== hash || entry.kind && entry.kind !== out.kind) {
|
|
114484
114545
|
if (!ws.cloudTask) continue;
|
|
114485
|
-
let artifact = previous && (previous.kind ?? kindOf(
|
|
114546
|
+
let artifact = previous && (previous.kind ?? kindOf(path21.extname(node.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
|
|
114486
114547
|
if (!artifact) {
|
|
114487
114548
|
const made = await createArtifact(ws.cloudTask, node.key.slice(0, 200), out.kind);
|
|
114488
114549
|
if (!made.ok) return { ...made, error: `${node.key}: ${made.error}` };
|
|
@@ -114508,25 +114569,25 @@ async function pushAssets(ws, record, before) {
|
|
|
114508
114569
|
} catch (error) {
|
|
114509
114570
|
return { ok: false, code: "bad_request", error: error instanceof Error ? error.message : String(error) };
|
|
114510
114571
|
}
|
|
114511
|
-
const list2 =
|
|
114512
|
-
if (Object.keys(refs).length ||
|
|
114572
|
+
const list2 = path21.join(ws.board, assetsFile(ws.task));
|
|
114573
|
+
if (Object.keys(refs).length || fs20.existsSync(list2)) {
|
|
114513
114574
|
if (!isDeepStrictEqual(assetsOf(readText(list2)), refs)) write(list2, assetsText(refs));
|
|
114514
114575
|
}
|
|
114515
114576
|
logSync("assets.end", { project: ws.project, task: ws.task, ms: Math.round(performance.now() - started) });
|
|
114516
114577
|
return { ok: true, value: void 0 };
|
|
114517
114578
|
}
|
|
114518
114579
|
function resetSorted(ws) {
|
|
114519
|
-
for (const sub of ["dismissed", "archived"])
|
|
114580
|
+
for (const sub of ["dismissed", "archived"]) fs20.rmSync(path21.join(ws.board, "triage", sub), { recursive: true, force: true });
|
|
114520
114581
|
for (const [p2, content] of viewOf(ws, readBase(ws), sharedMemory(ws.board))) {
|
|
114521
|
-
if (/^triage\/(?:dismissed|archived)\//.test(p2)) write(
|
|
114582
|
+
if (/^triage\/(?:dismissed|archived)\//.test(p2)) write(path21.join(ws.board, p2), content);
|
|
114522
114583
|
}
|
|
114523
114584
|
}
|
|
114524
114585
|
function proposeItems(ws, base, paths) {
|
|
114525
114586
|
const root2 = rootOf(ws);
|
|
114526
114587
|
for (const p2 of paths ?? localFiles(ws, base)) {
|
|
114527
114588
|
if (itemAt(p2)?.state !== "open" || base.files[root2 + p2]) continue;
|
|
114528
|
-
const file2 =
|
|
114529
|
-
const content =
|
|
114589
|
+
const file2 = path21.join(ws.board, p2);
|
|
114590
|
+
const content = fs20.readFileSync(file2, "utf8");
|
|
114530
114591
|
const said = (key) => new RegExp(`^${key}:`, "m").test(content.split(/\n---/)[0] ?? "");
|
|
114531
114592
|
const fields = {
|
|
114532
114593
|
...ws.cloudTask && !said("source_task") ? { source_task: ws.cloudTask } : {},
|
|
@@ -114564,11 +114625,11 @@ async function sendMarked(ws, job, paths) {
|
|
|
114564
114625
|
return pushed;
|
|
114565
114626
|
}
|
|
114566
114627
|
var boardIdentity = (ws) => {
|
|
114567
|
-
const stat =
|
|
114628
|
+
const stat = fs20.statSync(ws.board);
|
|
114568
114629
|
return `${stat.dev}:${stat.ino}:${stat.birthtimeMs}`;
|
|
114569
114630
|
};
|
|
114570
114631
|
function rememberDirectories(directories, file2) {
|
|
114571
|
-
for (let dir =
|
|
114632
|
+
for (let dir = path21.posix.dirname(file2); dir !== "." && dir !== "/"; dir = path21.posix.dirname(dir)) directories.add(dir);
|
|
114572
114633
|
}
|
|
114573
114634
|
function newIndex(ws) {
|
|
114574
114635
|
const directories = /* @__PURE__ */ new Set();
|
|
@@ -114597,7 +114658,7 @@ function forgetTask(index, task) {
|
|
|
114597
114658
|
}
|
|
114598
114659
|
function indexTask(ws, record, card = cardFile(ws)) {
|
|
114599
114660
|
if (!ws.cloudTask || !ws.number) return;
|
|
114600
|
-
const paths = /* @__PURE__ */ new Set([card,
|
|
114661
|
+
const paths = /* @__PURE__ */ new Set([card, path21.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
|
|
114601
114662
|
for (const name of Object.keys(record.assets)) {
|
|
114602
114663
|
try {
|
|
114603
114664
|
const file2 = assetPath(ws, name, card);
|
|
@@ -114606,7 +114667,7 @@ function indexTask(ws, record, card = cardFile(ws)) {
|
|
|
114606
114667
|
}
|
|
114607
114668
|
}
|
|
114608
114669
|
for (const file2 of [...paths]) {
|
|
114609
|
-
for (let dir =
|
|
114670
|
+
for (let dir = path21.dirname(file2); dir.startsWith(ws.cwd + path21.sep); dir = path21.dirname(dir)) paths.add(dir);
|
|
114610
114671
|
}
|
|
114611
114672
|
const index = syncIndex(ws) ?? newIndex(ws);
|
|
114612
114673
|
for (const file2 of index.tasks.get(ws.task)?.paths ?? []) {
|
|
@@ -114626,7 +114687,7 @@ function affectedTasks(ws, paths) {
|
|
|
114626
114687
|
const index = syncIndex(ws);
|
|
114627
114688
|
const tasks = new Set(index?.retiring);
|
|
114628
114689
|
for (const p2 of paths) {
|
|
114629
|
-
for (const task2 of index?.files.get(
|
|
114690
|
+
for (const task2 of index?.files.get(path21.resolve(ws.board, p2)) ?? []) tasks.add(task2);
|
|
114630
114691
|
const task = /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
|
|
114631
114692
|
if (task) tasks.add(task);
|
|
114632
114693
|
}
|
|
@@ -114643,13 +114704,13 @@ async function send2(ws, job, paths) {
|
|
|
114643
114704
|
const retired = await cleanRecords(ws, base, [], names2 ?? void 0);
|
|
114644
114705
|
if (retired.has(ws.task)) record.deleted = true;
|
|
114645
114706
|
const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
|
|
114646
|
-
...filesUnder(
|
|
114707
|
+
...filesUnder(path21.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
|
|
114647
114708
|
...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
|
|
114648
114709
|
])];
|
|
114649
114710
|
const tasks = ws.cloudTask ? [{ folder: ws, record }] : records.flatMap((name) => {
|
|
114650
114711
|
let held5;
|
|
114651
114712
|
try {
|
|
114652
|
-
held5 = JSON.parse(
|
|
114713
|
+
held5 = JSON.parse(fs20.readFileSync(path21.join(ws.board, ".sync", name), "utf8"));
|
|
114653
114714
|
} catch {
|
|
114654
114715
|
const known2 = syncIndex(ws)?.tasks.get(name.replace(/\.json$/, ""));
|
|
114655
114716
|
if (!known2) return [];
|
|
@@ -114667,7 +114728,7 @@ async function send2(ws, job, paths) {
|
|
|
114667
114728
|
const assetErrors = {};
|
|
114668
114729
|
const processed = /* @__PURE__ */ new Set();
|
|
114669
114730
|
const cards = !selected && !ws.cloudTask ? new Map(
|
|
114670
|
-
[".archive", "todo"].flatMap((dir) => filesUnder(
|
|
114731
|
+
[".archive", "todo"].flatMap((dir) => filesUnder(path21.join(ws.board, dir), ws.board)).flatMap((p2) => {
|
|
114671
114732
|
const number = numberOfCard(p2);
|
|
114672
114733
|
return number ? [[number, p2]] : [];
|
|
114673
114734
|
})
|
|
@@ -114675,8 +114736,8 @@ async function send2(ws, job, paths) {
|
|
|
114675
114736
|
for (const item of tasks) {
|
|
114676
114737
|
processed.add(item.folder.task);
|
|
114677
114738
|
if (processed.size === 1 || processed.size % 25 === 0) logSync("board.progress", { project: ws.project, processed: processed.size, total: tasks.length });
|
|
114678
|
-
const card = cards?.get(item.folder.number) ??
|
|
114679
|
-
indexTask(item.folder, item.record,
|
|
114739
|
+
const card = cards?.get(item.folder.number) ?? path21.relative(ws.board, cardFile(item.folder)).split(path21.sep).join("/");
|
|
114740
|
+
indexTask(item.folder, item.record, path21.join(ws.board, card));
|
|
114680
114741
|
selected?.add(card);
|
|
114681
114742
|
const before = assetsOf(assetsListOf(item.folder, base));
|
|
114682
114743
|
const newer = Object.entries(before).some(([name, ref]) => {
|
|
@@ -114685,13 +114746,13 @@ async function send2(ws, job, paths) {
|
|
|
114685
114746
|
});
|
|
114686
114747
|
const clean = () => Object.entries(item.record.assets).every(([name, entry]) => {
|
|
114687
114748
|
try {
|
|
114688
|
-
const file2 = assetPath(item.folder, name,
|
|
114749
|
+
const file2 = assetPath(item.folder, name, path21.join(ws.board, card));
|
|
114689
114750
|
return !file2 || hashFile(file2) === (entry.localHash ?? entry.hash);
|
|
114690
114751
|
} catch {
|
|
114691
114752
|
return false;
|
|
114692
114753
|
}
|
|
114693
114754
|
});
|
|
114694
|
-
const archived = !selected && boardSync && card.startsWith(".archive/") && readText(
|
|
114755
|
+
const archived = !selected && boardSync && card.startsWith(".archive/") && readText(path21.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
|
|
114695
114756
|
if (!archived && !item.record.deleted) {
|
|
114696
114757
|
const refreshed = newer && clean() ? await pullAssets(item.folder, item.record, before) : { ok: true, value: void 0 };
|
|
114697
114758
|
const assets = refreshed.ok ? await pushAssets(item.folder, item.record, before) : refreshed;
|
|
@@ -114711,10 +114772,10 @@ async function send2(ws, job, paths) {
|
|
|
114711
114772
|
}
|
|
114712
114773
|
if (!ws.cloudTask) syncIndex(ws).ready = true;
|
|
114713
114774
|
const scoped = selected && [...new Set([...selected].flatMap((p2) => {
|
|
114714
|
-
if (!isBoardPath(p2) && !
|
|
114715
|
-
const file2 =
|
|
114716
|
-
return
|
|
114717
|
-
}))].filter((p2) =>
|
|
114775
|
+
if (!isBoardPath(p2) && !fs20.statSync(path21.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
114776
|
+
const file2 = path21.join(ws.board, p2);
|
|
114777
|
+
return fs20.statSync(file2, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file2, ws.board).filter(kept2) : kept2(p2) ? [p2] : [];
|
|
114778
|
+
}))].filter((p2) => fs20.statSync(path21.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
|
|
114718
114779
|
for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
|
|
114719
114780
|
proposeItems(ws, base, scoped);
|
|
114720
114781
|
const shared = sharedMemory(ws.board);
|
|
@@ -114749,7 +114810,7 @@ async function send2(ws, job, paths) {
|
|
|
114749
114810
|
for (const p2 of local) {
|
|
114750
114811
|
if (defer(p2) || owed(p2)) continue;
|
|
114751
114812
|
if (selected && tasks.some((item) => assetFiles(item.folder, assetsListOf(item.folder, base)).has(p2))) continue;
|
|
114752
|
-
const content =
|
|
114813
|
+
const content = fs20.readFileSync(path21.join(ws.board, p2), "utf8");
|
|
114753
114814
|
const remote2 = remoteOf(ws, shared, p2);
|
|
114754
114815
|
localOf.set(remote2, p2);
|
|
114755
114816
|
const held5 = base.files[remote2];
|
|
@@ -114759,7 +114820,7 @@ async function send2(ws, job, paths) {
|
|
|
114759
114820
|
}
|
|
114760
114821
|
const previous = selected ? new Set([...selected].flatMap((p2) => {
|
|
114761
114822
|
if (base.files[remoteOf(ws, shared, p2)]) return [p2];
|
|
114762
|
-
if (!syncIndex(ws)?.directories.has(p2) && !
|
|
114823
|
+
if (!syncIndex(ws)?.directories.has(p2) && !fs20.statSync(path21.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
|
|
114763
114824
|
return [...viewOf(ws, base, shared).keys()].filter((file2) => file2.startsWith(p2 + "/"));
|
|
114764
114825
|
})) : viewOf(ws, base, shared).keys();
|
|
114765
114826
|
for (const p2 of previous) {
|
|
@@ -114794,7 +114855,7 @@ async function send2(ws, job, paths) {
|
|
|
114794
114855
|
deferred.add(assetsFile(item.folder.task));
|
|
114795
114856
|
}
|
|
114796
114857
|
} else {
|
|
114797
|
-
|
|
114858
|
+
fs20.rmSync(path21.join(ws.board, p2), { force: true });
|
|
114798
114859
|
writeIndex(ws.board);
|
|
114799
114860
|
}
|
|
114800
114861
|
writeBase(ws, base);
|
|
@@ -114806,8 +114867,8 @@ async function send2(ws, job, paths) {
|
|
|
114806
114867
|
const merged = itemAt(p2) ? { content: theirs.content } : mergeFile(base.files[theirs.path]?.content ?? null, changes[at2].content, theirs.content);
|
|
114807
114868
|
logSync("merge.end", { project: ws.project, path: p2, ms: Math.round(performance.now() - started) });
|
|
114808
114869
|
changes[at2] = { path: theirs.path, content: merged.content, base_seq: theirs.seq };
|
|
114809
|
-
if (merged.content === null)
|
|
114810
|
-
else write(
|
|
114870
|
+
if (merged.content === null) fs20.rmSync(path21.join(ws.board, p2), { force: true });
|
|
114871
|
+
else write(path21.join(ws.board, p2), merged.content);
|
|
114811
114872
|
}
|
|
114812
114873
|
if (!changes.length) return success(false);
|
|
114813
114874
|
sent = await commitBoard(ws.project, job.id, job.machineId, changes);
|
|
@@ -114822,8 +114883,8 @@ async function send2(ws, job, paths) {
|
|
|
114822
114883
|
}
|
|
114823
114884
|
|
|
114824
114885
|
// ../cli/src/lib/machine/settings.ts
|
|
114825
|
-
import
|
|
114826
|
-
import
|
|
114886
|
+
import fs21 from "node:fs";
|
|
114887
|
+
import path22 from "node:path";
|
|
114827
114888
|
|
|
114828
114889
|
// ../cli/src/lib/machine/types.ts
|
|
114829
114890
|
var LANGUAGES = ["en", "zh"];
|
|
@@ -114833,11 +114894,11 @@ function isLanguage(value) {
|
|
|
114833
114894
|
}
|
|
114834
114895
|
|
|
114835
114896
|
// ../cli/src/lib/machine/settings.ts
|
|
114836
|
-
var settingsFile = () =>
|
|
114897
|
+
var settingsFile = () => path22.join(machineHome(), "settings.json");
|
|
114837
114898
|
function heldSettings() {
|
|
114838
114899
|
let text3;
|
|
114839
114900
|
try {
|
|
114840
|
-
text3 =
|
|
114901
|
+
text3 = fs21.readFileSync(settingsFile(), "utf8");
|
|
114841
114902
|
} catch (err) {
|
|
114842
114903
|
if (err.code === "ENOENT") return { unreadable: false, values: {} };
|
|
114843
114904
|
return { unreadable: true, values: {} };
|
|
@@ -114896,8 +114957,8 @@ ${input.languageLine}`;
|
|
|
114896
114957
|
}
|
|
114897
114958
|
|
|
114898
114959
|
// src/flow.ts
|
|
114899
|
-
import
|
|
114900
|
-
import
|
|
114960
|
+
import fs34 from "node:fs";
|
|
114961
|
+
import path37 from "node:path";
|
|
114901
114962
|
|
|
114902
114963
|
// ../cli/src/lib/agent/types.ts
|
|
114903
114964
|
var NOT_COMPLETED = "The delivery has not recorded completion.";
|
|
@@ -116209,16 +116270,16 @@ function createKimiStreamRenderer(cwd, resumeId) {
|
|
|
116209
116270
|
}
|
|
116210
116271
|
|
|
116211
116272
|
// ../cli/src/lib/agent/wire/acp-cost.ts
|
|
116212
|
-
import
|
|
116213
|
-
import
|
|
116273
|
+
import fs22 from "node:fs";
|
|
116274
|
+
import path23 from "node:path";
|
|
116214
116275
|
import { createHash } from "node:crypto";
|
|
116215
116276
|
function acpCostFile(tool, cwd, session) {
|
|
116216
116277
|
const key = createHash("sha256").update(JSON.stringify([tool, cwd, session])).digest("hex");
|
|
116217
|
-
return
|
|
116278
|
+
return path23.join(machineHome(), "usage", "acp", `${key}.json`);
|
|
116218
116279
|
}
|
|
116219
116280
|
function readAcpCost(file2) {
|
|
116220
116281
|
try {
|
|
116221
|
-
const n = JSON.parse(
|
|
116282
|
+
const n = JSON.parse(fs22.readFileSync(file2, "utf8"));
|
|
116222
116283
|
return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
116223
116284
|
} catch {
|
|
116224
116285
|
return void 0;
|
|
@@ -116227,16 +116288,17 @@ function readAcpCost(file2) {
|
|
|
116227
116288
|
function saveAcpCost(file2, cost) {
|
|
116228
116289
|
if (cost === void 0) return;
|
|
116229
116290
|
try {
|
|
116230
|
-
|
|
116291
|
+
fs22.mkdirSync(path23.dirname(file2), { recursive: true, mode: 448 });
|
|
116231
116292
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
116232
|
-
|
|
116233
|
-
|
|
116293
|
+
fs22.writeFileSync(tmp, JSON.stringify(cost), { mode: 384 });
|
|
116294
|
+
fs22.renameSync(tmp, file2);
|
|
116234
116295
|
} catch {
|
|
116235
116296
|
}
|
|
116236
116297
|
}
|
|
116237
116298
|
|
|
116238
116299
|
// ../cli/src/lib/shared/conversation.ts
|
|
116239
116300
|
var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
|
|
116301
|
+
var CONVERSATION_PHASES = ["preparing", "initialized", "ready", "submitted", "started"];
|
|
116240
116302
|
function bounded(work, ms, reason) {
|
|
116241
116303
|
return new Promise((resolve2, reject) => {
|
|
116242
116304
|
const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
|
|
@@ -116251,7 +116313,7 @@ function bounded(work, ms, reason) {
|
|
|
116251
116313
|
}
|
|
116252
116314
|
|
|
116253
116315
|
// ../cli/src/lib/agent/wire/acp.ts
|
|
116254
|
-
import
|
|
116316
|
+
import fs23 from "node:fs";
|
|
116255
116317
|
|
|
116256
116318
|
// ../cli/src/lib/agent/wire/rpc.ts
|
|
116257
116319
|
var RpcError = class extends Error {
|
|
@@ -116385,7 +116447,7 @@ function createTail(log) {
|
|
|
116385
116447
|
// ../cli/package.json
|
|
116386
116448
|
var package_default = {
|
|
116387
116449
|
name: "wildcrane",
|
|
116388
|
-
version: "0.11.
|
|
116450
|
+
version: "0.11.54",
|
|
116389
116451
|
akbContract: 15,
|
|
116390
116452
|
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.",
|
|
116391
116453
|
keywords: [
|
|
@@ -116528,7 +116590,7 @@ var STOPPED = {
|
|
|
116528
116590
|
cancelled: "the turn was cancelled"
|
|
116529
116591
|
};
|
|
116530
116592
|
function mcpServersIn(file2) {
|
|
116531
|
-
const servers = obj(obj(JSON.parse(
|
|
116593
|
+
const servers = obj(obj(JSON.parse(fs23.readFileSync(file2, "utf8"))).mcpServers);
|
|
116532
116594
|
return Object.entries(servers).map(([name, raw]) => {
|
|
116533
116595
|
const s = obj(raw);
|
|
116534
116596
|
return {
|
|
@@ -116731,7 +116793,7 @@ function decide(params, tail, events) {
|
|
|
116731
116793
|
}
|
|
116732
116794
|
|
|
116733
116795
|
// ../cli/src/lib/agent/wire/zcode.ts
|
|
116734
|
-
import
|
|
116796
|
+
import path24 from "node:path";
|
|
116735
116797
|
function whereHint2(input, title) {
|
|
116736
116798
|
const named = obj(input);
|
|
116737
116799
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
@@ -116897,7 +116959,7 @@ async function oneTurn2(io, options) {
|
|
|
116897
116959
|
{ stringIds: true }
|
|
116898
116960
|
);
|
|
116899
116961
|
try {
|
|
116900
|
-
const workspacePath =
|
|
116962
|
+
const workspacePath = path24.resolve(io.cwd);
|
|
116901
116963
|
const workspace = { workspacePath, workspaceKey: workspacePath };
|
|
116902
116964
|
let opened;
|
|
116903
116965
|
if (io.resumeId) {
|
|
@@ -117137,7 +117199,7 @@ async function run2(io, options, tasks) {
|
|
|
117137
117199
|
if (failure) io.event?.({ kind: "error", data: { text: failure } });
|
|
117138
117200
|
resolve2({ ok: !failure, error: failure, result: renderer.result(), replyParts: renderer.replyParts?.(), usage: combinedUsage, context, costUsd, costIncomplete: child.costIncomplete || cost === void 0 && child.costUsd !== void 0 || void 0 });
|
|
117139
117201
|
};
|
|
117140
|
-
const closed = () => end("Codex closed
|
|
117202
|
+
const closed = () => end("Codex connection closed before all work and results finished.");
|
|
117141
117203
|
io.stdout.once("close", closed);
|
|
117142
117204
|
const update2 = (id, state, title = "") => {
|
|
117143
117205
|
if (ended2) return;
|
|
@@ -117392,43 +117454,43 @@ function reviewOf(meta) {
|
|
|
117392
117454
|
|
|
117393
117455
|
// src/akb.ts
|
|
117394
117456
|
import { spawn } from "node:child_process";
|
|
117395
|
-
import
|
|
117396
|
-
import
|
|
117457
|
+
import fs24 from "node:fs";
|
|
117458
|
+
import path25 from "node:path";
|
|
117397
117459
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
117398
|
-
var akbHome = () =>
|
|
117460
|
+
var akbHome = () => path25.join(runnerHome(), "bin", "akb");
|
|
117399
117461
|
var BUNDLED_SHIM = `bundled-${AKB_VERSION}`;
|
|
117400
|
-
var HERE =
|
|
117462
|
+
var HERE = path25.dirname(fileURLToPath2(import.meta.url));
|
|
117401
117463
|
function akbArgs(entry, dist = HERE) {
|
|
117402
|
-
const preload =
|
|
117403
|
-
return
|
|
117464
|
+
const preload = path25.join(dist, "akb-proxy.mjs");
|
|
117465
|
+
return fs24.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry] : [entry];
|
|
117404
117466
|
}
|
|
117405
117467
|
var bundledAkb = (dist = HERE) => ({
|
|
117406
117468
|
command: process.execPath,
|
|
117407
|
-
args: akbArgs(
|
|
117469
|
+
args: akbArgs(path25.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
|
|
117408
117470
|
version: AKB_VERSION,
|
|
117409
|
-
shim:
|
|
117471
|
+
shim: path25.join(akbHome(), BUNDLED_SHIM)
|
|
117410
117472
|
});
|
|
117411
117473
|
var quote = (s) => /^[\w./:@=-]+$/.test(s) ? s : `"${s}"`;
|
|
117412
117474
|
function shimDir(akb) {
|
|
117413
117475
|
const dir = akb.shim;
|
|
117414
117476
|
const line = [akb.command, ...akb.args].map(quote).join(" ");
|
|
117415
|
-
const [file2, text3] = process.platform === "win32" ? [
|
|
117416
|
-
`] : [
|
|
117477
|
+
const [file2, text3] = process.platform === "win32" ? [path25.join(dir, "akb.cmd"), `@${line} %*\r
|
|
117478
|
+
`] : [path25.join(dir, "akb"), `#!/bin/sh
|
|
117417
117479
|
exec ${line} "$@"
|
|
117418
117480
|
`];
|
|
117419
117481
|
if (process.platform === "win32") {
|
|
117420
|
-
|
|
117482
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
117421
117483
|
const shellLine = [akb.command, ...akb.args].map((s) => `'${s.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`).join(" ");
|
|
117422
|
-
|
|
117484
|
+
fs24.writeFileSync(path25.join(dir, "akb"), `#!/bin/sh
|
|
117423
117485
|
exec ${shellLine} "$@"
|
|
117424
117486
|
`, { mode: 493 });
|
|
117425
117487
|
}
|
|
117426
117488
|
try {
|
|
117427
|
-
if (
|
|
117489
|
+
if (fs24.readFileSync(file2, "utf8") === text3) return dir;
|
|
117428
117490
|
} catch {
|
|
117429
117491
|
}
|
|
117430
|
-
|
|
117431
|
-
|
|
117492
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
117493
|
+
fs24.writeFileSync(file2, text3, { mode: 493 });
|
|
117432
117494
|
return dir;
|
|
117433
117495
|
}
|
|
117434
117496
|
function akbEnv(akb, board, task, language, base = process.env) {
|
|
@@ -117436,7 +117498,7 @@ function akbEnv(akb, board, task, language, base = process.env) {
|
|
|
117436
117498
|
const dropped = ["AI4KANBAN_PREVIEW_BRIDGE", "AI4KANBAN_REPLY_APPROVAL", "AI4KANBAN_BOARD", "AI4KANBAN_TASK", "AI4KANBAN_EXECUTION", LANGUAGE_ENV, LANGUAGE_LINE_ENV, SCHEDULED_AGENTS_ENV, SESSION_COST_ENV];
|
|
117437
117499
|
for (const [k2, v] of Object.entries({ ...proxyEnv(), ...base })) if (!k2.startsWith("KANBAN_") && !dropped.includes(k2)) env2[k2] = v;
|
|
117438
117500
|
const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
|
|
117439
|
-
env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(
|
|
117501
|
+
env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(path25.delimiter);
|
|
117440
117502
|
if (Object.keys(proxyEnv()).some((k2) => !/^no_proxy$/i.test(k2)) && env2.NODE_USE_ENV_PROXY === void 0) env2.NODE_USE_ENV_PROXY = "1";
|
|
117441
117503
|
env2[HOST_PROXY_ENV] = JSON.stringify(hostProxy());
|
|
117442
117504
|
env2.AI4KANBAN_COMMAND = "akb";
|
|
@@ -117520,8 +117582,8 @@ function quoteArg(arg) {
|
|
|
117520
117582
|
|
|
117521
117583
|
// ../cli/src/lib/agent/harnesses/types.ts
|
|
117522
117584
|
import { createHash as createHash2 } from "node:crypto";
|
|
117523
|
-
import
|
|
117524
|
-
import
|
|
117585
|
+
import fs25 from "node:fs";
|
|
117586
|
+
import path26 from "node:path";
|
|
117525
117587
|
var SKILL_SENTENCE = "Use the kanban skill";
|
|
117526
117588
|
function namesFlag(argv, flags) {
|
|
117527
117589
|
return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
|
|
@@ -117544,34 +117606,34 @@ var MCP_CONFIG = {
|
|
|
117544
117606
|
};
|
|
117545
117607
|
function machineFile(name, text3) {
|
|
117546
117608
|
const suffix = createHash2("sha256").update(text3).digest("hex").slice(0, 16);
|
|
117547
|
-
const file2 =
|
|
117609
|
+
const file2 = path26.join(machineHome(), "prompts", `${path26.parse(name).name}-${suffix}${path26.extname(name)}`);
|
|
117548
117610
|
try {
|
|
117549
|
-
if (
|
|
117611
|
+
if (fs25.readFileSync(file2, "utf8") === text3) return file2;
|
|
117550
117612
|
} catch {
|
|
117551
117613
|
}
|
|
117552
|
-
|
|
117553
|
-
|
|
117614
|
+
fs25.mkdirSync(path26.dirname(file2), { recursive: true });
|
|
117615
|
+
fs25.writeFileSync(file2, text3);
|
|
117554
117616
|
return file2;
|
|
117555
117617
|
}
|
|
117556
117618
|
|
|
117557
117619
|
// src/runtimes.ts
|
|
117558
117620
|
import { spawn as spawn3 } from "node:child_process";
|
|
117559
117621
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
117560
|
-
import
|
|
117622
|
+
import fs31 from "node:fs";
|
|
117561
117623
|
import os5 from "node:os";
|
|
117562
|
-
import
|
|
117624
|
+
import path34 from "node:path";
|
|
117563
117625
|
|
|
117564
117626
|
// ../cli/src/lib/agent/harnesses/antigravity.ts
|
|
117565
|
-
import
|
|
117566
|
-
import
|
|
117627
|
+
import fs28 from "node:fs";
|
|
117628
|
+
import path29 from "node:path";
|
|
117567
117629
|
import { createHash as createHash3 } from "node:crypto";
|
|
117568
117630
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
117569
117631
|
|
|
117570
117632
|
// ../cli/src/lib/agent/locate.ts
|
|
117571
117633
|
import { spawn as spawn2, spawnSync as spawnSync3 } from "node:child_process";
|
|
117572
|
-
import
|
|
117634
|
+
import fs27 from "node:fs";
|
|
117573
117635
|
import os4 from "node:os";
|
|
117574
|
-
import
|
|
117636
|
+
import path28 from "node:path";
|
|
117575
117637
|
|
|
117576
117638
|
// ../cli/src/lib/agent/installed.ts
|
|
117577
117639
|
var WINDOWS2 = process.platform === "win32";
|
|
@@ -117580,8 +117642,8 @@ function commandBinary(command) {
|
|
|
117580
117642
|
}
|
|
117581
117643
|
|
|
117582
117644
|
// ../cli/src/lib/agent/spawnable.ts
|
|
117583
|
-
import
|
|
117584
|
-
import
|
|
117645
|
+
import fs26 from "node:fs";
|
|
117646
|
+
import path27 from "node:path";
|
|
117585
117647
|
var META = /([()\][%!^"`<>&|;, *?])/g;
|
|
117586
117648
|
function cmdArg(arg) {
|
|
117587
117649
|
const quoted = `"${arg.replace(/\r?\n|\r/g, " ").replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1")}"`;
|
|
@@ -117591,21 +117653,21 @@ function cmdLine(file2, args2) {
|
|
|
117591
117653
|
return `"${[file2.replace(META, "^$1"), ...args2.map(cmdArg)].join(" ")}"`;
|
|
117592
117654
|
}
|
|
117593
117655
|
function shimTarget(text3, file2) {
|
|
117594
|
-
const dir =
|
|
117656
|
+
const dir = path27.win32.dirname(file2);
|
|
117595
117657
|
const found = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(text3);
|
|
117596
117658
|
if (!found || !/\\node\.exe"/i.test(text3)) return null;
|
|
117597
|
-
const script =
|
|
117598
|
-
const local =
|
|
117659
|
+
const script = path27.win32.resolve(dir, found[1].replace(/\//g, "\\"));
|
|
117660
|
+
const local = path27.win32.join(dir, "node.exe");
|
|
117599
117661
|
const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(text3)?.[1];
|
|
117600
|
-
return { script, node:
|
|
117662
|
+
return { script, node: fs26.existsSync(local) ? local : "node", env: nodePath ? { NODE_PATH: nodePath } : {} };
|
|
117601
117663
|
}
|
|
117602
117664
|
function onWindowsPath(name, env2) {
|
|
117603
117665
|
const exts = (env2.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
117604
117666
|
const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
|
|
117605
117667
|
for (const dir of (env2[key] ?? "").split(";").filter(Boolean)) {
|
|
117606
117668
|
for (const ext of exts) {
|
|
117607
|
-
const file2 =
|
|
117608
|
-
if (
|
|
117669
|
+
const file2 = path27.win32.join(dir, `${name}${ext.toLowerCase()}`);
|
|
117670
|
+
if (fs26.existsSync(file2)) return file2;
|
|
117609
117671
|
}
|
|
117610
117672
|
}
|
|
117611
117673
|
return void 0;
|
|
@@ -117613,13 +117675,13 @@ function onWindowsPath(name, env2) {
|
|
|
117613
117675
|
function spawnable(command, args2, options = {}, platform = process.platform) {
|
|
117614
117676
|
if (platform !== "win32") return { command, args: args2, options };
|
|
117615
117677
|
const env2 = options.env ?? process.env;
|
|
117616
|
-
const file2 =
|
|
117617
|
-
const ext =
|
|
117678
|
+
const file2 = path27.extname(command) || /[\\/]/.test(command) ? command : onWindowsPath(command, env2) ?? command;
|
|
117679
|
+
const ext = path27.extname(file2).toLowerCase();
|
|
117618
117680
|
const hidden = { ...options, windowsHide: true, shell: false };
|
|
117619
117681
|
if (ext !== ".cmd" && ext !== ".bat") return { command: file2, args: args2, options: hidden };
|
|
117620
117682
|
let text3 = "";
|
|
117621
117683
|
try {
|
|
117622
|
-
text3 =
|
|
117684
|
+
text3 = fs26.readFileSync(file2, "utf8");
|
|
117623
117685
|
} catch {
|
|
117624
117686
|
}
|
|
117625
117687
|
const shim = shimTarget(text3, file2);
|
|
@@ -117683,7 +117745,7 @@ function pick(copies) {
|
|
|
117683
117745
|
}
|
|
117684
117746
|
function folders(parent) {
|
|
117685
117747
|
try {
|
|
117686
|
-
return
|
|
117748
|
+
return fs27.readdirSync(parent, { withFileTypes: true }).filter((one) => one.isDirectory()).map((one) => one.name);
|
|
117687
117749
|
} catch {
|
|
117688
117750
|
return [];
|
|
117689
117751
|
}
|
|
@@ -117702,29 +117764,29 @@ function byVersion(names2) {
|
|
|
117702
117764
|
function latestIn(parent, tail = "") {
|
|
117703
117765
|
let names2;
|
|
117704
117766
|
try {
|
|
117705
|
-
names2 =
|
|
117767
|
+
names2 = fs27.readdirSync(parent);
|
|
117706
117768
|
} catch {
|
|
117707
117769
|
return [];
|
|
117708
117770
|
}
|
|
117709
|
-
return byVersion(names2.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) =>
|
|
117771
|
+
return byVersion(names2.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) => path28.join(parent, name, tail));
|
|
117710
117772
|
}
|
|
117711
117773
|
var env = (name) => process.env[name]?.trim() ?? "";
|
|
117712
117774
|
function commonDirs() {
|
|
117713
117775
|
const home4 = os4.homedir();
|
|
117714
|
-
const under = (...parts) =>
|
|
117715
|
-
const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) =>
|
|
117776
|
+
const under = (...parts) => path28.join(home4, ...parts);
|
|
117777
|
+
const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) => path28.join(root2, version, ...tail)) : [];
|
|
117716
117778
|
if (WINDOWS3) {
|
|
117717
117779
|
const [app, local, data, programs] = [env("APPDATA"), env("LOCALAPPDATA"), env("ProgramData"), env("ProgramFiles")];
|
|
117718
117780
|
return [
|
|
117719
117781
|
under(".local", "bin"),
|
|
117720
117782
|
under(".bun", "bin"),
|
|
117721
117783
|
under("scoop", "shims"),
|
|
117722
|
-
...app ? [
|
|
117723
|
-
...local ? [
|
|
117724
|
-
...data ? [
|
|
117725
|
-
...programs ? [
|
|
117784
|
+
...app ? [path28.join(app, "npm")] : [],
|
|
117785
|
+
...local ? [path28.join(local, "pnpm"), path28.join(local, "Volta", "bin"), path28.join(local, "Microsoft", "WinGet", "Links")] : [],
|
|
117786
|
+
...data ? [path28.join(data, "chocolatey", "bin")] : [],
|
|
117787
|
+
...programs ? [path28.join(programs, "nodejs")] : [],
|
|
117726
117788
|
...nodes(env("NVM_HOME")),
|
|
117727
|
-
...app ? nodes(
|
|
117789
|
+
...app ? nodes(path28.join(app, "fnm", "node-versions"), ["installation"]) : []
|
|
117728
117790
|
];
|
|
117729
117791
|
}
|
|
117730
117792
|
const support = process.platform === "darwin" ? under("Library", "Application Support") : under(".local", "share");
|
|
@@ -117741,10 +117803,10 @@ function commonDirs() {
|
|
|
117741
117803
|
...env("PNPM_HOME") ? [env("PNPM_HOME")] : [],
|
|
117742
117804
|
under("Library", "pnpm"),
|
|
117743
117805
|
under(".local", "share", "pnpm"),
|
|
117744
|
-
|
|
117745
|
-
...nodes(
|
|
117746
|
-
...nodes(
|
|
117747
|
-
...nodes(
|
|
117806
|
+
path28.join(env("VOLTA_HOME") || under(".volta"), "bin"),
|
|
117807
|
+
...nodes(path28.join(env("NVM_DIR") || under(".nvm"), "versions", "node"), ["bin"]),
|
|
117808
|
+
...nodes(path28.join(env("FNM_DIR") || path28.join(support, "fnm"), "node-versions"), ["installation", "bin"]),
|
|
117809
|
+
...nodes(path28.join(env("ASDF_DATA_DIR") || under(".asdf"), "installs", "nodejs"), ["bin"]),
|
|
117748
117810
|
...nodes(under(".local", "share", "mise", "installs", "node"), ["bin"]),
|
|
117749
117811
|
...nodes(under(".nodenv", "versions"), ["bin"]),
|
|
117750
117812
|
...nodes("/usr/local/n/versions/node", ["bin"])
|
|
@@ -117752,11 +117814,11 @@ function commonDirs() {
|
|
|
117752
117814
|
}
|
|
117753
117815
|
function onPath(binary) {
|
|
117754
117816
|
const names2 = WINDOWS3 ? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((ext) => `${binary}${ext.toLowerCase()}`) : [binary];
|
|
117755
|
-
return (process.env.PATH ?? "").split(
|
|
117817
|
+
return (process.env.PATH ?? "").split(path28.delimiter).filter(Boolean).flatMap((dir) => names2.map((name) => path28.join(dir, name)));
|
|
117756
117818
|
}
|
|
117757
117819
|
var isFile = (file2) => {
|
|
117758
117820
|
try {
|
|
117759
|
-
return
|
|
117821
|
+
return fs27.statSync(file2).isFile();
|
|
117760
117822
|
} catch {
|
|
117761
117823
|
return false;
|
|
117762
117824
|
}
|
|
@@ -117765,24 +117827,24 @@ function copyFiles(harness) {
|
|
|
117765
117827
|
const pinned = harness.pinned?.();
|
|
117766
117828
|
if (pinned && isFile(pinned)) return [{ file: pinned, entry: false }];
|
|
117767
117829
|
const binary = commandBinary(harness.command);
|
|
117768
|
-
const exe = (file2) => WINDOWS3 && !
|
|
117830
|
+
const exe = (file2) => WINDOWS3 && !path28.extname(file2) ? [`${file2}.exe`, `${file2}.cmd`] : [file2];
|
|
117769
117831
|
const path_ = onPath(binary).filter(isFile);
|
|
117770
|
-
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) =>
|
|
117832
|
+
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) => path28.join(dir, binary))];
|
|
117771
117833
|
const others = elsewhere.flatMap(exe).filter(isFile);
|
|
117772
117834
|
const seen = /* @__PURE__ */ new Set();
|
|
117773
117835
|
return [...path_, ...others].flatMap((file2, i) => {
|
|
117774
|
-
const real =
|
|
117836
|
+
const real = fs27.realpathSync.native(file2);
|
|
117775
117837
|
if (seen.has(real)) return [];
|
|
117776
117838
|
seen.add(real);
|
|
117777
117839
|
return [{ file: file2, entry: i === 0 && path_.length > 0 }];
|
|
117778
117840
|
});
|
|
117779
117841
|
}
|
|
117780
117842
|
var answers;
|
|
117781
|
-
var answersFile = () =>
|
|
117843
|
+
var answersFile = () => path28.join(machineHome(), "agent-copies.json");
|
|
117782
117844
|
function kept3() {
|
|
117783
117845
|
if (answers) return answers;
|
|
117784
117846
|
try {
|
|
117785
|
-
answers = JSON.parse(
|
|
117847
|
+
answers = JSON.parse(fs27.readFileSync(answersFile(), "utf8"));
|
|
117786
117848
|
} catch {
|
|
117787
117849
|
answers = {};
|
|
117788
117850
|
}
|
|
@@ -117791,16 +117853,16 @@ function kept3() {
|
|
|
117791
117853
|
function keep(file2, answer) {
|
|
117792
117854
|
kept3()[file2] = answer;
|
|
117793
117855
|
try {
|
|
117794
|
-
|
|
117856
|
+
fs27.mkdirSync(machineHome(), { recursive: true });
|
|
117795
117857
|
const staged = `${answersFile()}.${process.pid}`;
|
|
117796
|
-
|
|
117797
|
-
|
|
117858
|
+
fs27.writeFileSync(staged, JSON.stringify(answers));
|
|
117859
|
+
fs27.renameSync(staged, answersFile());
|
|
117798
117860
|
} catch {
|
|
117799
117861
|
}
|
|
117800
117862
|
}
|
|
117801
117863
|
function keyOf(file2) {
|
|
117802
|
-
const real =
|
|
117803
|
-
const stat =
|
|
117864
|
+
const real = fs27.realpathSync.native(file2);
|
|
117865
|
+
const stat = fs27.statSync(real);
|
|
117804
117866
|
return `${real}|${stat.size}|${stat.mtimeMs}`;
|
|
117805
117867
|
}
|
|
117806
117868
|
function known(file2, maxAge) {
|
|
@@ -117813,8 +117875,8 @@ function judge(code, status, stdout, stderr) {
|
|
|
117813
117875
|
return { starts: true, version: status === 0 ? versionIn(stdout) ?? versionIn(stderr) : null };
|
|
117814
117876
|
}
|
|
117815
117877
|
function copyEnv(file2, given = process.env) {
|
|
117816
|
-
if (!
|
|
117817
|
-
return { ...given, PATH: [
|
|
117878
|
+
if (!path28.isAbsolute(file2)) return given;
|
|
117879
|
+
return { ...given, PATH: [path28.dirname(file2), given.PATH].filter(Boolean).join(path28.delimiter) };
|
|
117818
117880
|
}
|
|
117819
117881
|
var probeOptions = (file2) => ({ cwd: os4.tmpdir(), env: copyEnv(file2), windowsHide: true, shell: false });
|
|
117820
117882
|
function probe(file2) {
|
|
@@ -118071,7 +118133,7 @@ function antigravityModels(output2) {
|
|
|
118071
118133
|
}
|
|
118072
118134
|
function args(argv, resume) {
|
|
118073
118135
|
if (namesFlag(argv, ["--continue", "-c", "--conversation", "--remote-agent"])) throw new Error(translating() ? "\u8BF7\u901A\u8FC7 WildCrane \u9009\u62E9 Antigravity \u4F1A\u8BDD\uFF0C\u4E0D\u8981\u5728\u989D\u5916\u53C2\u6570\u4E2D\u6307\u5B9A\u4F1A\u8BDD\u6216\u8FDC\u7A0B\u6267\u884C\u3002" : "Antigravity: select a session through WildCrane, not extra arguments.");
|
|
118074
|
-
if (resume && (!/^[a-f0-9-]{36}$/i.test(resume) || !
|
|
118136
|
+
if (resume && (!/^[a-f0-9-]{36}$/i.test(resume) || !fs28.existsSync(home2(".gemini", "antigravity-cli", "conversations", `${resume}.db`)))) throw new Error(translating() ? "Antigravity \u4F1A\u8BDD\u4E0D\u5B58\u5728\u3002\u8BF7\u5728\u672C\u673A\u6062\u590D\u539F\u4F1A\u8BDD\u540E\u7EED\u63A5\u3002" : "Antigravity session not found. Restore the original conversation on this computer before resuming.");
|
|
118075
118137
|
const extra = resume ? ["--conversation", resume] : [];
|
|
118076
118138
|
if (!namesFlag(argv, ["--output-format"])) extra.push("--output-format", "stream-json");
|
|
118077
118139
|
if (!namesFlag(argv, ["--dangerously-skip-permissions"])) extra.push("--dangerously-skip-permissions");
|
|
@@ -118112,10 +118174,10 @@ var ANTIGRAVITY = {
|
|
|
118112
118174
|
|
|
118113
118175
|
The task working directory is ${env2.PWD ?? process.cwd()}. Use it as the base for project files and commands. This additional workspace contains only language rules; do not write task output here.`;
|
|
118114
118176
|
const hash = createHash3("sha256").update(rule).digest("hex").slice(0, 16);
|
|
118115
|
-
const root2 =
|
|
118116
|
-
const file2 =
|
|
118117
|
-
|
|
118118
|
-
|
|
118177
|
+
const root2 = path29.join(machineHome(), "prompts", `antigravity-${hash}`);
|
|
118178
|
+
const file2 = path29.join(root2, ".agents", "rules", "language.md");
|
|
118179
|
+
fs28.mkdirSync(path29.dirname(file2), { recursive: true });
|
|
118180
|
+
fs28.writeFileSync(file2, `---
|
|
118119
118181
|
trigger: always_on
|
|
118120
118182
|
---
|
|
118121
118183
|
|
|
@@ -118218,7 +118280,7 @@ function checkHarnesses(harnesses) {
|
|
|
118218
118280
|
}
|
|
118219
118281
|
|
|
118220
118282
|
// ../cli/src/lib/agent/harnesses/claude-code.ts
|
|
118221
|
-
import
|
|
118283
|
+
import path30 from "node:path";
|
|
118222
118284
|
|
|
118223
118285
|
// ../cli/src/lib/agent/harnesses/transient.ts
|
|
118224
118286
|
var MANUAL = [
|
|
@@ -118277,15 +118339,15 @@ var userMessage = (prompt) => `${JSON.stringify({ type: "user", message: { role:
|
|
|
118277
118339
|
`;
|
|
118278
118340
|
function claudeOnWindows() {
|
|
118279
118341
|
const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
|
|
118280
|
-
const packages = local ?
|
|
118342
|
+
const packages = local ? path30.join(local, "Packages") : "";
|
|
118281
118343
|
const data = [
|
|
118282
|
-
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) =>
|
|
118283
|
-
...roaming ? [
|
|
118344
|
+
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path30.join(packages, name, "LocalCache", "Roaming", "Claude")),
|
|
118345
|
+
...roaming ? [path30.join(roaming, "Claude")] : []
|
|
118284
118346
|
];
|
|
118285
118347
|
return data.flatMap(
|
|
118286
|
-
(dir) => latestIn(
|
|
118287
|
-
|
|
118288
|
-
...folders(version).map((build) =>
|
|
118348
|
+
(dir) => latestIn(path30.join(dir, "claude-code")).flatMap((version) => [
|
|
118349
|
+
path30.join(version, "claude.exe"),
|
|
118350
|
+
...folders(version).map((build) => path30.join(version, build, "claude.exe"))
|
|
118289
118351
|
])
|
|
118290
118352
|
);
|
|
118291
118353
|
}
|
|
@@ -118543,15 +118605,15 @@ var CLAUDE_CODE = {
|
|
|
118543
118605
|
...latestIn(home2(".local", "share", "claude", "versions")),
|
|
118544
118606
|
// The copy Claude Desktop carries.
|
|
118545
118607
|
...process.platform === "win32" ? claudeOnWindows() : latestIn(home2("Library", "Application Support", "Claude", "claude-code")).flatMap(
|
|
118546
|
-
(version) => folders(version).map((build) =>
|
|
118608
|
+
(version) => folders(version).map((build) => path30.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
|
|
118547
118609
|
)
|
|
118548
118610
|
],
|
|
118549
118611
|
install: "npm install -g @anthropic-ai/claude-code"
|
|
118550
118612
|
};
|
|
118551
118613
|
|
|
118552
118614
|
// ../cli/src/lib/agent/harnesses/codex.ts
|
|
118553
|
-
import
|
|
118554
|
-
import
|
|
118615
|
+
import fs29 from "node:fs";
|
|
118616
|
+
import path31 from "node:path";
|
|
118555
118617
|
|
|
118556
118618
|
// ../cli/src/lib/agent/worktree.ts
|
|
118557
118619
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
@@ -118598,10 +118660,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
|
118598
118660
|
}
|
|
118599
118661
|
const flags = [...argv, ...extra];
|
|
118600
118662
|
const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
|
|
118601
|
-
if (workspaceWrite &&
|
|
118663
|
+
if (workspaceWrite && path31.resolve(cwd) !== path31.resolve(REPO_ROOT)) {
|
|
118602
118664
|
for (const dir of [KANBAN, AKB_DIR]) {
|
|
118603
|
-
const relative =
|
|
118604
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
118665
|
+
const relative = path31.relative(cwd, dir);
|
|
118666
|
+
if (relative === ".." || relative.startsWith(`..${path31.sep}`) || path31.isAbsolute(relative)) {
|
|
118605
118667
|
extra.push("--add-dir", dir);
|
|
118606
118668
|
}
|
|
118607
118669
|
}
|
|
@@ -118624,7 +118686,7 @@ function envRoot(name) {
|
|
|
118624
118686
|
}
|
|
118625
118687
|
function modified(file2) {
|
|
118626
118688
|
try {
|
|
118627
|
-
return
|
|
118689
|
+
return fs29.statSync(file2).mtimeMs;
|
|
118628
118690
|
} catch {
|
|
118629
118691
|
return 0;
|
|
118630
118692
|
}
|
|
@@ -118650,28 +118712,28 @@ function codexOnWindows() {
|
|
|
118650
118712
|
const local = envRoot("LOCALAPPDATA");
|
|
118651
118713
|
const profile = envRoot("USERPROFILE");
|
|
118652
118714
|
const programs = envRoot("ProgramFiles");
|
|
118653
|
-
const cache = local ?
|
|
118654
|
-
const releases = profile ?
|
|
118655
|
-
const packages = programs ?
|
|
118715
|
+
const cache = local ? path31.join(local, "OpenAI", "Codex", "bin") : "";
|
|
118716
|
+
const releases = profile ? path31.join(profile, ".codex", "packages", "standalone", "releases") : "";
|
|
118717
|
+
const packages = programs ? path31.join(programs, "WindowsApps") : "";
|
|
118656
118718
|
return [
|
|
118657
118719
|
// Desktop's relocated CLI cache: a folder per build hash, newest file first.
|
|
118658
|
-
...byNewest(folders(cache).map((name) =>
|
|
118720
|
+
...byNewest(folders(cache).map((name) => path31.join(cache, name, "codex.exe"))),
|
|
118659
118721
|
// The separate standalone launcher, at a path with nothing variable in it.
|
|
118660
|
-
...local ? [
|
|
118722
|
+
...local ? [path31.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
|
|
118661
118723
|
// That launcher's release payload: a folder per version and target.
|
|
118662
118724
|
...byVersion(folders(releases).filter(ourArch)).map(
|
|
118663
|
-
(name) =>
|
|
118725
|
+
(name) => path31.join(releases, name, "bin", "codex.exe")
|
|
118664
118726
|
),
|
|
118665
118727
|
// Desktop's own MSIX package.
|
|
118666
118728
|
...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
|
|
118667
|
-
(name) =>
|
|
118729
|
+
(name) => path31.join(packages, name, "app", "resources", "codex.exe")
|
|
118668
118730
|
)
|
|
118669
118731
|
];
|
|
118670
118732
|
}
|
|
118671
118733
|
function codexInstalls() {
|
|
118672
118734
|
const chosen = process.env.CODEX_INSTALL_DIR?.trim();
|
|
118673
118735
|
return [
|
|
118674
|
-
...chosen ? [
|
|
118736
|
+
...chosen ? [path31.join(chosen, "codex")] : [],
|
|
118675
118737
|
...process.platform === "win32" ? codexOnWindows() : [
|
|
118676
118738
|
// macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
|
|
118677
118739
|
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
|
|
@@ -118717,7 +118779,7 @@ var CODEX = {
|
|
|
118717
118779
|
systemPrompt(text3, argv) {
|
|
118718
118780
|
if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
|
|
118719
118781
|
try {
|
|
118720
|
-
const config =
|
|
118782
|
+
const config = fs29.readFileSync(path31.join(process.env.CODEX_HOME || home2(".codex"), "config.toml"), "utf8");
|
|
118721
118783
|
if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
|
|
118722
118784
|
} catch {
|
|
118723
118785
|
}
|
|
@@ -118963,24 +119025,24 @@ var CURSOR = {
|
|
|
118963
119025
|
};
|
|
118964
119026
|
|
|
118965
119027
|
// ../cli/src/lib/agent/harnesses/dsh.ts
|
|
118966
|
-
import
|
|
118967
|
-
import
|
|
119028
|
+
import fs30 from "node:fs";
|
|
119029
|
+
import path32 from "node:path";
|
|
118968
119030
|
function dshHome(argv) {
|
|
118969
119031
|
const binary = argv[0];
|
|
118970
119032
|
if (!binary) return void 0;
|
|
118971
|
-
const names2 = process.platform === "win32" && !
|
|
118972
|
-
const candidates = binary.includes("/") || binary.includes("\\") ? names2 : (process.env.PATH ?? "").split(
|
|
119033
|
+
const names2 = process.platform === "win32" && !path32.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
|
|
119034
|
+
const candidates = binary.includes("/") || binary.includes("\\") ? names2 : (process.env.PATH ?? "").split(path32.delimiter).filter(Boolean).flatMap((dir2) => names2.map((name) => path32.join(dir2, name)));
|
|
118973
119035
|
let dir;
|
|
118974
119036
|
try {
|
|
118975
|
-
const found = candidates.find((candidate) =>
|
|
119037
|
+
const found = candidates.find((candidate) => fs30.existsSync(candidate));
|
|
118976
119038
|
if (!found) return void 0;
|
|
118977
|
-
const script = /\.cmd$/i.test(found) ? shimTarget(
|
|
118978
|
-
dir =
|
|
119039
|
+
const script = /\.cmd$/i.test(found) ? shimTarget(fs30.readFileSync(found, "utf8"), found)?.script : void 0;
|
|
119040
|
+
dir = path32.dirname(fs30.realpathSync(script ?? found));
|
|
118979
119041
|
} catch {
|
|
118980
119042
|
return void 0;
|
|
118981
119043
|
}
|
|
118982
|
-
for (let up =
|
|
118983
|
-
if (
|
|
119044
|
+
for (let up = path32.dirname(dir); dir !== up; up = path32.dirname(dir)) {
|
|
119045
|
+
if (fs30.existsSync(path32.join(dir, "package.json"))) return dir;
|
|
118984
119046
|
dir = up;
|
|
118985
119047
|
}
|
|
118986
119048
|
return void 0;
|
|
@@ -119589,7 +119651,7 @@ var DEFAULT_HARNESS = HARNESSES[0];
|
|
|
119589
119651
|
checkHarnesses(HARNESSES);
|
|
119590
119652
|
|
|
119591
119653
|
// ../cli/src/lib/agent/run-settings.ts
|
|
119592
|
-
import
|
|
119654
|
+
import path33 from "node:path";
|
|
119593
119655
|
|
|
119594
119656
|
// ../cli/src/lib/agent/providers.ts
|
|
119595
119657
|
function providerSetting(settings) {
|
|
@@ -119692,7 +119754,7 @@ function languageEnv(given) {
|
|
|
119692
119754
|
try {
|
|
119693
119755
|
const config = JSON.parse(env2.OPENCODE_CONFIG_CONTENT ?? "{}");
|
|
119694
119756
|
if (Array.isArray(config.instructions)) {
|
|
119695
|
-
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" ||
|
|
119757
|
+
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" || path33.dirname(file2) !== path33.join(machineHome(), "prompts") || !/^opencode-language(?:-[a-f0-9]{16})?\.md$/.test(path33.basename(file2)));
|
|
119696
119758
|
env2.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
|
|
119697
119759
|
}
|
|
119698
119760
|
} catch {
|
|
@@ -119708,7 +119770,7 @@ function withSystemLanguage(harness, argv, env2, language) {
|
|
|
119708
119770
|
const note = language === "zh" ? "\u8BED\u8A00\u89C4\u5219\u672A\u80FD\u66F4\u65B0\uFF1A\u8FDE\u63A5\u5668\u3001\u5DF2\u6709\u4F1A\u8BDD\u6216\u81EA\u8BBE\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4E0D\u652F\u6301\u6CE8\u5165\u3002\u8BF7\u81EA\u884C\u53E6\u5F00\u652F\u6301\u7684\u4F1A\u8BDD\u4EE5\u91C7\u7528\u65B0\u89C4\u5219\u3002" : "Language rules could not be updated: the connector, existing session, or custom system prompt prevents injection. Open a supported new session to apply them.";
|
|
119709
119771
|
return { argv, env: env2, note };
|
|
119710
119772
|
}
|
|
119711
|
-
const at2 = /^node(?:\.exe)?$/.test(
|
|
119773
|
+
const at2 = /^node(?:\.exe)?$/.test(path33.basename(argv[0])) && argv[1] && !argv[1].startsWith("-") ? 2 : 1;
|
|
119712
119774
|
return { argv: [...argv.slice(0, at2), ...added?.args ?? [], ...argv.slice(at2)], env: { ...env2, ...added?.env } };
|
|
119713
119775
|
}
|
|
119714
119776
|
|
|
@@ -119820,14 +119882,14 @@ var listed = (harness) => async () => (harness.models?.() ?? []).map((id) => ({
|
|
|
119820
119882
|
var readModels = (name) => (MODELS[name] ?? listed(HARNESSES2[name]))().catch(() => []);
|
|
119821
119883
|
var MODELS = {
|
|
119822
119884
|
"claude-code": async () => {
|
|
119823
|
-
const cached2 = claudeModels(
|
|
119885
|
+
const cached2 = claudeModels(path34.join(process.env.CLAUDE_CONFIG_DIR || path34.join(os5.homedir(), ".claude"), "cache", "model-catalog"));
|
|
119824
119886
|
return cached2.length ? cached2 : [
|
|
119825
119887
|
{ id: "opus", name: "Opus" },
|
|
119826
119888
|
{ id: "sonnet", name: "Sonnet" },
|
|
119827
119889
|
{ id: "haiku", name: "Haiku" }
|
|
119828
119890
|
];
|
|
119829
119891
|
},
|
|
119830
|
-
codex: async () => codexModels(
|
|
119892
|
+
codex: async () => codexModels(path34.join(process.env.CODEX_HOME || path34.join(os5.homedir(), ".codex"), "models_cache.json")),
|
|
119831
119893
|
opencode: async () => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"])),
|
|
119832
119894
|
cursor: () => cursorModels(),
|
|
119833
119895
|
antigravity: async () => antigravityModels(await output(commandOf(HARNESSES2.antigravity)[0], ["models"]))
|
|
@@ -119887,7 +119949,7 @@ function output(command, args2) {
|
|
|
119887
119949
|
}
|
|
119888
119950
|
function codexModels(file2) {
|
|
119889
119951
|
try {
|
|
119890
|
-
const cache = JSON.parse(
|
|
119952
|
+
const cache = JSON.parse(fs31.readFileSync(file2, "utf8"));
|
|
119891
119953
|
if (!Array.isArray(cache.models)) return [];
|
|
119892
119954
|
return cache.models.flatMap(
|
|
119893
119955
|
(m) => m.visibility === "list" && typeof m.slug === "string" && m.slug ? [{ id: m.slug, name: typeof m.display_name === "string" && m.display_name ? m.display_name : m.slug }] : []
|
|
@@ -119899,13 +119961,13 @@ function codexModels(file2) {
|
|
|
119899
119961
|
function claudeModels(dir) {
|
|
119900
119962
|
let files;
|
|
119901
119963
|
try {
|
|
119902
|
-
files =
|
|
119964
|
+
files = fs31.readdirSync(dir).filter((f2) => f2.endsWith(".json"));
|
|
119903
119965
|
} catch {
|
|
119904
119966
|
return [];
|
|
119905
119967
|
}
|
|
119906
119968
|
const catalogs = files.flatMap((f2) => {
|
|
119907
119969
|
try {
|
|
119908
|
-
const data = obj(JSON.parse(
|
|
119970
|
+
const data = obj(JSON.parse(fs31.readFileSync(path34.join(dir, f2), "utf8")));
|
|
119909
119971
|
const catalog = obj(data.catalog);
|
|
119910
119972
|
const surface = str2(catalog.surface);
|
|
119911
119973
|
return surface === "cc" || surface === "ccd" ? [{ surface, at: Number(data.fetchedAt) || 0, config: obj(catalog.config) }] : [];
|
|
@@ -119951,8 +120013,8 @@ function probeLogin(binary, harness) {
|
|
|
119951
120013
|
}
|
|
119952
120014
|
|
|
119953
120015
|
// src/triage.ts
|
|
119954
|
-
import
|
|
119955
|
-
import
|
|
120016
|
+
import fs32 from "node:fs";
|
|
120017
|
+
import path35 from "node:path";
|
|
119956
120018
|
|
|
119957
120019
|
// ../cli/src/lib/signals/identity.ts
|
|
119958
120020
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -119966,8 +120028,8 @@ function slugify(s) {
|
|
|
119966
120028
|
}
|
|
119967
120029
|
|
|
119968
120030
|
// src/triage.ts
|
|
119969
|
-
var triageDir = (board) =>
|
|
119970
|
-
var rejectedDir = (board) =>
|
|
120031
|
+
var triageDir = (board) => path35.join(board, "triage");
|
|
120032
|
+
var rejectedDir = (board) => path35.join(board, ".archive", REJECTIONS_TO_REVIEW);
|
|
119971
120033
|
var SCRATCH = ["dismissed", "archived"];
|
|
119972
120034
|
var stamp2 = (at2) => formatStamp(at2 ? new Date(at2) : /* @__PURE__ */ new Date());
|
|
119973
120035
|
function slugOf(title) {
|
|
@@ -119976,7 +120038,7 @@ function slugOf(title) {
|
|
|
119976
120038
|
function freeName(dir, title) {
|
|
119977
120039
|
const stem = slugOf(title);
|
|
119978
120040
|
let name = `${stem}.md`;
|
|
119979
|
-
for (let n = 2;
|
|
120041
|
+
for (let n = 2; fs32.existsSync(path35.join(dir, name)); n++) name = `${stem}-${n}.md`;
|
|
119980
120042
|
return name;
|
|
119981
120043
|
}
|
|
119982
120044
|
function itemText(item, fields = {}) {
|
|
@@ -119996,17 +120058,17 @@ ${item.text.trim()}
|
|
|
119996
120058
|
`;
|
|
119997
120059
|
}
|
|
119998
120060
|
function writeItem(dir, item, fields = {}) {
|
|
119999
|
-
|
|
120061
|
+
fs32.mkdirSync(dir, { recursive: true });
|
|
120000
120062
|
const name = freeName(dir, item.title);
|
|
120001
|
-
|
|
120063
|
+
fs32.writeFileSync(path35.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields } : fields));
|
|
120002
120064
|
return name;
|
|
120003
120065
|
}
|
|
120004
120066
|
function layOut(board, rejections) {
|
|
120005
120067
|
clearLaid(board);
|
|
120006
120068
|
const dir = rejectedDir(board);
|
|
120007
|
-
|
|
120069
|
+
fs32.mkdirSync(dir, { recursive: true });
|
|
120008
120070
|
for (const t of rejections.tasks) {
|
|
120009
|
-
|
|
120071
|
+
fs32.writeFileSync(path35.join(dir, `${t.number}-${slugify(t.title)}.md`), [
|
|
120010
120072
|
"---",
|
|
120011
120073
|
`title: ${yamlScalar(t.title)}`,
|
|
120012
120074
|
"status: todo",
|
|
@@ -120021,25 +120083,25 @@ function layOut(board, rejections) {
|
|
|
120021
120083
|
].join("\n"));
|
|
120022
120084
|
}
|
|
120023
120085
|
for (const item of rejections.triage) {
|
|
120024
|
-
const sub =
|
|
120086
|
+
const sub = path35.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
|
|
120025
120087
|
const fields = item.state === "dismissed" ? { dismissed_at: stamp2(item.dismissed_at), dismissed_by: "user", ...item.dismissed_reason ? { dismissed_reason: item.dismissed_reason } : {} } : {};
|
|
120026
120088
|
writeItem(sub, item, fields);
|
|
120027
120089
|
}
|
|
120028
120090
|
return { tasks: rejections.tasks.map((t) => t.id), triage: rejections.triage.map((i) => i.id) };
|
|
120029
120091
|
}
|
|
120030
120092
|
function clearLaid(board) {
|
|
120031
|
-
|
|
120032
|
-
for (const sub of SCRATCH)
|
|
120093
|
+
fs32.rmSync(rejectedDir(board), { recursive: true, force: true });
|
|
120094
|
+
for (const sub of SCRATCH) fs32.rmSync(path35.join(triageDir(board), sub), { recursive: true, force: true });
|
|
120033
120095
|
}
|
|
120034
120096
|
|
|
120035
120097
|
// ../cli/src/lib/skill/hook.ts
|
|
120036
120098
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
120037
|
-
import
|
|
120038
|
-
import
|
|
120099
|
+
import fs33 from "node:fs";
|
|
120100
|
+
import path36 from "node:path";
|
|
120039
120101
|
var MARKER_LINE = /^# ai4kanban commit guard\b/m;
|
|
120040
120102
|
var read2 = (file2) => {
|
|
120041
120103
|
try {
|
|
120042
|
-
return
|
|
120104
|
+
return fs33.readFileSync(file2, "utf8");
|
|
120043
120105
|
} catch {
|
|
120044
120106
|
return null;
|
|
120045
120107
|
}
|
|
@@ -120051,15 +120113,15 @@ function hooksDir(root2) {
|
|
|
120051
120113
|
windowsHide: true
|
|
120052
120114
|
});
|
|
120053
120115
|
if (out.error || out.status !== 0 || !out.stdout.trim()) return null;
|
|
120054
|
-
return
|
|
120116
|
+
return path36.resolve(root2, out.stdout.trim());
|
|
120055
120117
|
}
|
|
120056
120118
|
function installCommitHook(root2, _board) {
|
|
120057
120119
|
const dir = hooksDir(root2);
|
|
120058
120120
|
if (!dir) return {};
|
|
120059
|
-
const file2 =
|
|
120060
|
-
if (
|
|
120121
|
+
const file2 = path36.join(dir, "pre-commit");
|
|
120122
|
+
if (fs33.lstatSync(file2, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
|
|
120061
120123
|
const source = read2(file2);
|
|
120062
|
-
if (source && MARKER_LINE.test(source))
|
|
120124
|
+
if (source && MARKER_LINE.test(source)) fs33.unlinkSync(file2);
|
|
120063
120125
|
return {};
|
|
120064
120126
|
}
|
|
120065
120127
|
|
|
@@ -120096,7 +120158,7 @@ function runtimeCosts(runs, job) {
|
|
|
120096
120158
|
}
|
|
120097
120159
|
function reviewOf2(file2) {
|
|
120098
120160
|
try {
|
|
120099
|
-
const meta = parseFrontmatter(
|
|
120161
|
+
const meta = parseFrontmatter(fs34.readFileSync(file2, "utf8")).meta;
|
|
120100
120162
|
return meta ? reviewOf(meta) : null;
|
|
120101
120163
|
} catch {
|
|
120102
120164
|
return null;
|
|
@@ -120104,15 +120166,15 @@ function reviewOf2(file2) {
|
|
|
120104
120166
|
}
|
|
120105
120167
|
function asks(file2) {
|
|
120106
120168
|
try {
|
|
120107
|
-
return (parseFrontmatter(
|
|
120169
|
+
return (parseFrontmatter(fs34.readFileSync(file2, "utf8")).meta?.questions ?? []).length > 0;
|
|
120108
120170
|
} catch {
|
|
120109
120171
|
return false;
|
|
120110
120172
|
}
|
|
120111
120173
|
}
|
|
120112
120174
|
function mcpConfig(servers, file2) {
|
|
120113
120175
|
if (!Object.keys(servers).length) return null;
|
|
120114
|
-
|
|
120115
|
-
|
|
120176
|
+
fs34.mkdirSync(path37.dirname(file2), { recursive: true });
|
|
120177
|
+
fs34.writeFileSync(file2, `${JSON.stringify({ mcpServers: servers }, null, 2)}
|
|
120116
120178
|
`);
|
|
120117
120179
|
return file2;
|
|
120118
120180
|
}
|
|
@@ -120146,7 +120208,7 @@ function deliveryEnding(ws, id, asked = false) {
|
|
|
120146
120208
|
if (!id) return null;
|
|
120147
120209
|
let held5;
|
|
120148
120210
|
try {
|
|
120149
|
-
held5 = JSON.parse(
|
|
120211
|
+
held5 = JSON.parse(fs34.readFileSync(path37.join(ws.board, "deliveries", `${path37.basename(id)}.json`), "utf8"));
|
|
120150
120212
|
} catch {
|
|
120151
120213
|
return null;
|
|
120152
120214
|
}
|
|
@@ -120158,16 +120220,16 @@ function deliveryEnding(ws, id, asked = false) {
|
|
|
120158
120220
|
return null;
|
|
120159
120221
|
}
|
|
120160
120222
|
function checkoutsOf(ws, id) {
|
|
120161
|
-
const dir =
|
|
120223
|
+
const dir = path37.join(ws.board, "deliveries");
|
|
120162
120224
|
let names2;
|
|
120163
120225
|
try {
|
|
120164
|
-
names2 =
|
|
120226
|
+
names2 = fs34.readdirSync(dir).filter((n) => n.endsWith(".json"));
|
|
120165
120227
|
} catch {
|
|
120166
120228
|
return [];
|
|
120167
120229
|
}
|
|
120168
120230
|
return names2.flatMap((n) => {
|
|
120169
120231
|
try {
|
|
120170
|
-
const held5 = JSON.parse(
|
|
120232
|
+
const held5 = JSON.parse(fs34.readFileSync(path37.join(dir, n), "utf8"));
|
|
120171
120233
|
return held5.cardId === id && held5.deliveryId ? [held5.deliveryId] : [];
|
|
120172
120234
|
} catch {
|
|
120173
120235
|
return [];
|
|
@@ -120181,7 +120243,7 @@ var RESUME_REFUSED = {
|
|
|
120181
120243
|
deliveryRunGoing: "\u4E0A\u6B21\u7684\u8FD0\u884C\u8FD8\u6CA1\u505C\u4E0B\uFF0C\u8BF7\u7A0D\u540E\u518D\u70B9\u300C\u7EED\u8DD1\u300D\u3002",
|
|
120182
120244
|
deliveryCardGone: "\u8FD9\u5F20\u5361\u5DF2\u4E0D\u5728\u770B\u677F\u4E0A\uFF0C\u6CA1\u6709\u53EF\u7EED\u8DD1\u7684\u5185\u5BB9\uFF0C\u8BF7\u70B9\u300C\u91CD\u65B0\u53D1\u8D77\u300D\u3002"
|
|
120183
120245
|
};
|
|
120184
|
-
var isArchived = (ws, id) =>
|
|
120246
|
+
var isArchived = (ws, id) => path37.relative(ws.board, findCard(ws.board, id) ?? ws.board).split(path37.sep)[0] === ".archive";
|
|
120185
120247
|
var refusal2 = (ran) => ran.last.replace(/^akb( raw)?: /, "").slice(0, 300) || "akb stopped with an error.";
|
|
120186
120248
|
var reasonOf = (text3) => (text3 ?? "").split("\n").map((l2) => l2.trim()).filter((l2) => l2 && !/^at\s/.test(l2)).join("\n").slice(0, 300) || void 0;
|
|
120187
120249
|
function logLines(show, event2) {
|
|
@@ -120251,7 +120313,7 @@ async function setUp(job, ws, deps, io) {
|
|
|
120251
120313
|
const runtime = job.runtime;
|
|
120252
120314
|
const missing = unavailable(runtime, await deps.runtimes());
|
|
120253
120315
|
if (missing) return missing;
|
|
120254
|
-
if (!
|
|
120316
|
+
if (!fs34.existsSync(path37.join(ws.board, "config.md"))) {
|
|
120255
120317
|
const init = await akb(["raw", "init"]);
|
|
120256
120318
|
if (init.code !== 0) return refusal2(init);
|
|
120257
120319
|
}
|
|
@@ -120268,7 +120330,7 @@ async function setUp(job, ws, deps, io) {
|
|
|
120268
120330
|
const used = await akb(["raw", "agent", "use", runtime]);
|
|
120269
120331
|
if (used.code !== 0) return refusal2(used);
|
|
120270
120332
|
const servers = mcpServersOf(ws);
|
|
120271
|
-
const mcpFile =
|
|
120333
|
+
const mcpFile = path37.join(ws.board, ".sync", `${ws.task}.mcp.json`);
|
|
120272
120334
|
const takes = new Set(settingKeys(runtime));
|
|
120273
120335
|
const given = job.settings ?? {};
|
|
120274
120336
|
const values = valuesOf(runtime, job.model, given, servers, mcpFile);
|
|
@@ -120391,19 +120453,19 @@ async function runAgent(job, ws, deps, io) {
|
|
|
120391
120453
|
}
|
|
120392
120454
|
function writeTranscript(job, dir) {
|
|
120393
120455
|
if (!job.transcript) return "";
|
|
120394
|
-
const file2 =
|
|
120395
|
-
|
|
120396
|
-
|
|
120456
|
+
const file2 = path37.join(dir, "discussion.md");
|
|
120457
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
120458
|
+
fs34.writeFileSync(file2, `${job.transcript}
|
|
120397
120459
|
`);
|
|
120398
120460
|
return file2;
|
|
120399
120461
|
}
|
|
120400
120462
|
function pictures(job, ws, id) {
|
|
120401
120463
|
const dir = cardAssetsDir(ws, id);
|
|
120402
120464
|
if (!job.attachments.length || !dir) return "";
|
|
120403
|
-
|
|
120465
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
120404
120466
|
return job.attachments.map((a2, i) => {
|
|
120405
|
-
const file2 = `${i + 1}-${
|
|
120406
|
-
|
|
120467
|
+
const file2 = `${i + 1}-${path37.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
|
|
120468
|
+
fs34.writeFileSync(path37.join(dir, file2), Buffer.from(a2.content, "base64"));
|
|
120407
120469
|
return `
|
|
120408
120470
|
<Asset src=".assets/${id}/${file2}" label="${a2.name.replace(/["<>]/g, "") || file2}" />
|
|
120409
120471
|
`;
|
|
@@ -120411,7 +120473,7 @@ function pictures(job, ws, id) {
|
|
|
120411
120473
|
}
|
|
120412
120474
|
function cardFlags(ws, fields) {
|
|
120413
120475
|
if (!fields) return [];
|
|
120414
|
-
const open = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(
|
|
120476
|
+
const open = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path37.join(ws.board, "todo") + path37.sep));
|
|
120415
120477
|
const lists = [["--modules", fields.modules ?? []], ["--related", open(fields.related)], ["--blocked-by", open(fields.blocked_by)]];
|
|
120416
120478
|
return [
|
|
120417
120479
|
...fields.priority ? ["--priority", fields.priority] : [],
|
|
@@ -120442,10 +120504,10 @@ async function runFlow(job, ws, deps, io) {
|
|
|
120442
120504
|
said = { title: task.value.title?.trim() ?? "", request: task.value.request?.trim() ?? "" };
|
|
120443
120505
|
}
|
|
120444
120506
|
const title = said.title || "Untitled";
|
|
120445
|
-
const body =
|
|
120446
|
-
|
|
120507
|
+
const body = path37.join(ws.board, ".sync", `${ws.task}.request.md`);
|
|
120508
|
+
fs34.mkdirSync(path37.dirname(body), { recursive: true });
|
|
120447
120509
|
if (!ws.number) return fail("This task has no number yet.");
|
|
120448
|
-
|
|
120510
|
+
fs34.writeFileSync(body, `${said.request || title}
|
|
120449
120511
|
${pictures(job, ws, ws.number)}`);
|
|
120450
120512
|
const created = await withBoard(ws, async (push2) => {
|
|
120451
120513
|
const card2 = made(await akb([
|
|
@@ -120462,7 +120524,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
120462
120524
|
...cardFlags(ws, flow.metadata),
|
|
120463
120525
|
"--json"
|
|
120464
120526
|
]));
|
|
120465
|
-
|
|
120527
|
+
fs34.rmSync(body, { force: true });
|
|
120466
120528
|
if (!card2.ok) return card2;
|
|
120467
120529
|
const sent = await push2({ id: job.id, machineId: deps.machineId });
|
|
120468
120530
|
if (!sent.ok) return { ok: false, error: sent.error };
|
|
@@ -120483,7 +120545,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
120483
120545
|
if (io.lost()) return fail("");
|
|
120484
120546
|
return await workOn(card);
|
|
120485
120547
|
} finally {
|
|
120486
|
-
|
|
120548
|
+
fs34.rmSync(path37.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
|
|
120487
120549
|
const left = working.get(key) - 1;
|
|
120488
120550
|
if (left) working.set(key, left);
|
|
120489
120551
|
else working.delete(key);
|
|
@@ -120528,7 +120590,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
120528
120590
|
const resolved = await akb(["raw", "card", "resolve", String(id2), "--follow", "--events", "--json", "--", text3], true);
|
|
120529
120591
|
if (io.lost()) return fail("");
|
|
120530
120592
|
const file2 = findCard(ws.board, id2);
|
|
120531
|
-
rejected = !!file2 &&
|
|
120593
|
+
rejected = !!file2 && path37.relative(ws.board, file2).split(path37.sep)[0] === ".archive" && parseFrontmatter(fs34.readFileSync(file2, "utf8")).meta?.rejected === true;
|
|
120532
120594
|
if (rejected) ran = resolved;
|
|
120533
120595
|
else if (resolved.code !== 0) note = text3;
|
|
120534
120596
|
}
|
|
@@ -120577,7 +120639,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
120577
120639
|
}
|
|
120578
120640
|
function carryArgs(verb) {
|
|
120579
120641
|
if (!["refine", "resolve", "revise", "implement"].includes(verb)) return [];
|
|
120580
|
-
const transcript = writeTranscript(job,
|
|
120642
|
+
const transcript = writeTranscript(job, path37.join(ws.board, ".sync", `${ws.task}.discussion`));
|
|
120581
120643
|
return [
|
|
120582
120644
|
...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
|
|
120583
120645
|
...transcript ? ["--transcript", transcript] : []
|
|
@@ -120596,8 +120658,8 @@ async function confirmFlowStopped(ws, job, deps) {
|
|
|
120596
120658
|
}
|
|
120597
120659
|
|
|
120598
120660
|
// src/recovery.ts
|
|
120599
|
-
import
|
|
120600
|
-
import
|
|
120661
|
+
import fs35 from "node:fs";
|
|
120662
|
+
import path38 from "node:path";
|
|
120601
120663
|
|
|
120602
120664
|
// ../cli/src/lib/agent/retry.ts
|
|
120603
120665
|
var RETRY_WINDOW_MS = 15 * 6e4;
|
|
@@ -120611,10 +120673,10 @@ function backoffMs(attempt, random = Math.random) {
|
|
|
120611
120673
|
|
|
120612
120674
|
// src/recovery.ts
|
|
120613
120675
|
var UNCERTAIN = "\u66F4\u65B0\u4E2D\u65AD\u65F6\u6709\u64CD\u4F5C\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u68C0\u67E5\u5DF2\u6709\u7ED3\u679C\u540E\u518D\u7EED\u8DD1\u3002";
|
|
120614
|
-
var fileOf = (id) =>
|
|
120676
|
+
var fileOf = (id) => path38.join(runnerHome(), "checkpoints", `${encodeURIComponent(id)}.json`);
|
|
120615
120677
|
function readCheckpoint(id) {
|
|
120616
120678
|
try {
|
|
120617
|
-
const held5 = JSON.parse(
|
|
120679
|
+
const held5 = JSON.parse(fs35.readFileSync(fileOf(id), "utf8"));
|
|
120618
120680
|
if (!held5 || !Array.isArray(held5.pending) || !held5.pending.every((id2) => typeof id2 === "string")) throw new Error("\u8FDB\u5EA6\u683C\u5F0F\u9519\u8BEF");
|
|
120619
120681
|
return held5;
|
|
120620
120682
|
} catch (e2) {
|
|
@@ -120624,12 +120686,12 @@ function readCheckpoint(id) {
|
|
|
120624
120686
|
}
|
|
120625
120687
|
function saveCheckpoint(id, checkpoint) {
|
|
120626
120688
|
const file2 = fileOf(id);
|
|
120627
|
-
|
|
120628
|
-
|
|
120629
|
-
|
|
120689
|
+
fs35.mkdirSync(path38.dirname(file2), { recursive: true, mode: 448 });
|
|
120690
|
+
fs35.writeFileSync(`${file2}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
|
|
120691
|
+
fs35.renameSync(`${file2}.tmp`, file2);
|
|
120630
120692
|
}
|
|
120631
120693
|
function clearCheckpoint(id) {
|
|
120632
|
-
|
|
120694
|
+
fs35.rmSync(fileOf(id), { force: true });
|
|
120633
120695
|
}
|
|
120634
120696
|
function checkpointEvent(checkpoint, event2) {
|
|
120635
120697
|
if (event2.kind === "phase" && event2.data.phase === "submitted") checkpoint.submitted = true;
|
|
@@ -120688,9 +120750,101 @@ function replySpent(checkpoint, runtime) {
|
|
|
120688
120750
|
};
|
|
120689
120751
|
}
|
|
120690
120752
|
|
|
120753
|
+
// src/conversation-progress.ts
|
|
120754
|
+
function conversationProgress(attempt, send3, valid, unconfirmed) {
|
|
120755
|
+
const state = { attempt, phases: {} };
|
|
120756
|
+
let pending = false;
|
|
120757
|
+
let cancelled = false;
|
|
120758
|
+
let running;
|
|
120759
|
+
let timer;
|
|
120760
|
+
let sentAt = 0;
|
|
120761
|
+
let finishing = false;
|
|
120762
|
+
let urgent = false;
|
|
120763
|
+
const flush = () => {
|
|
120764
|
+
clearTimeout(timer);
|
|
120765
|
+
timer = void 0;
|
|
120766
|
+
if (running || cancelled || !valid()) return;
|
|
120767
|
+
running = (async () => {
|
|
120768
|
+
while (pending && !cancelled && valid()) {
|
|
120769
|
+
if (!urgent && !finishing && performance.now() - sentAt < 5e3) {
|
|
120770
|
+
timer = setTimeout(flush, 5e3 - (performance.now() - sentAt));
|
|
120771
|
+
break;
|
|
120772
|
+
}
|
|
120773
|
+
pending = false;
|
|
120774
|
+
urgent = false;
|
|
120775
|
+
sentAt = performance.now();
|
|
120776
|
+
try {
|
|
120777
|
+
await send3({ ...state, phases: { ...state.phases } });
|
|
120778
|
+
} catch {
|
|
120779
|
+
if (!cancelled && valid()) unconfirmed();
|
|
120780
|
+
}
|
|
120781
|
+
}
|
|
120782
|
+
})().finally(() => {
|
|
120783
|
+
running = void 0;
|
|
120784
|
+
if (pending && !cancelled && valid()) timer ??= setTimeout(flush, urgent || finishing ? 0 : Math.max(0, 5e3 - (performance.now() - sentAt)));
|
|
120785
|
+
});
|
|
120786
|
+
};
|
|
120787
|
+
return {
|
|
120788
|
+
active: () => !cancelled && valid(),
|
|
120789
|
+
observe(event2, at2) {
|
|
120790
|
+
if (cancelled || !valid()) return;
|
|
120791
|
+
let immediate = false;
|
|
120792
|
+
if (event2.kind === "phase" && CONVERSATION_PHASES.includes(event2.data.phase)) {
|
|
120793
|
+
state.phases[event2.data.phase] ??= at2;
|
|
120794
|
+
const rank = CONVERSATION_PHASES.indexOf(event2.data.phase);
|
|
120795
|
+
if (rank > CONVERSATION_PHASES.indexOf(state.phase)) {
|
|
120796
|
+
state.phase = event2.data.phase;
|
|
120797
|
+
immediate = true;
|
|
120798
|
+
}
|
|
120799
|
+
}
|
|
120800
|
+
const content = ["message", "tool_call", "tool_call_update", "plan"].includes(event2.kind) || event2.kind === "phase" && !!event2.data.contentAt;
|
|
120801
|
+
if (content) {
|
|
120802
|
+
immediate ||= !state.firstContentAt;
|
|
120803
|
+
state.firstContentAt ??= at2;
|
|
120804
|
+
state.contentAt = at2;
|
|
120805
|
+
}
|
|
120806
|
+
if (!content && !immediate) return;
|
|
120807
|
+
urgent ||= immediate;
|
|
120808
|
+
pending = true;
|
|
120809
|
+
if (running) return;
|
|
120810
|
+
if (immediate || finishing) {
|
|
120811
|
+
clearTimeout(timer);
|
|
120812
|
+
timer = setTimeout(flush, 0);
|
|
120813
|
+
} else timer ??= setTimeout(flush, Math.max(0, 5e3 - (performance.now() - sentAt)));
|
|
120814
|
+
},
|
|
120815
|
+
async drain(ms) {
|
|
120816
|
+
finishing = true;
|
|
120817
|
+
const empty = async () => {
|
|
120818
|
+
while ((pending || running) && !cancelled && valid()) {
|
|
120819
|
+
flush();
|
|
120820
|
+
await running;
|
|
120821
|
+
}
|
|
120822
|
+
};
|
|
120823
|
+
let timeout;
|
|
120824
|
+
const done = await Promise.race([
|
|
120825
|
+
empty().then(() => true),
|
|
120826
|
+
new Promise((resolve2) => {
|
|
120827
|
+
timeout = setTimeout(() => resolve2(false), ms);
|
|
120828
|
+
})
|
|
120829
|
+
]);
|
|
120830
|
+
clearTimeout(timeout);
|
|
120831
|
+
if (!done) {
|
|
120832
|
+
unconfirmed();
|
|
120833
|
+
cancelled = true;
|
|
120834
|
+
pending = false;
|
|
120835
|
+
}
|
|
120836
|
+
},
|
|
120837
|
+
cancel() {
|
|
120838
|
+
cancelled = true;
|
|
120839
|
+
pending = false;
|
|
120840
|
+
clearTimeout(timer);
|
|
120841
|
+
}
|
|
120842
|
+
};
|
|
120843
|
+
}
|
|
120844
|
+
|
|
120691
120845
|
// src/reply-images.ts
|
|
120692
|
-
import
|
|
120693
|
-
import
|
|
120846
|
+
import fs36 from "node:fs";
|
|
120847
|
+
import path39 from "node:path";
|
|
120694
120848
|
import os6 from "node:os";
|
|
120695
120849
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
120696
120850
|
import { createHash as createHash5 } from "node:crypto";
|
|
@@ -120708,16 +120862,16 @@ function imageMime(bytes2) {
|
|
|
120708
120862
|
|
|
120709
120863
|
// src/reply-images.ts
|
|
120710
120864
|
var inside = (root2, file2) => {
|
|
120711
|
-
const p2 =
|
|
120712
|
-
return p2 !== ".." && !p2.startsWith(`..${
|
|
120865
|
+
const p2 = path39.relative(root2, file2);
|
|
120866
|
+
return p2 !== ".." && !p2.startsWith(`..${path39.sep}`) && !path39.isAbsolute(p2);
|
|
120713
120867
|
};
|
|
120714
120868
|
function collectReplyImages(parts, cwd) {
|
|
120715
120869
|
const files = /* @__PURE__ */ new Map();
|
|
120716
120870
|
const tools = [];
|
|
120717
120871
|
const output2 = [];
|
|
120718
|
-
const roots = [cwd,
|
|
120872
|
+
const roots = [cwd, path39.join(process.env.CODEX_HOME?.trim() || path39.join(os6.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
|
|
120719
120873
|
try {
|
|
120720
|
-
return [
|
|
120874
|
+
return [fs36.realpathSync(p2)];
|
|
120721
120875
|
} catch {
|
|
120722
120876
|
return [];
|
|
120723
120877
|
}
|
|
@@ -120725,17 +120879,17 @@ function collectReplyImages(parts, cwd) {
|
|
|
120725
120879
|
const registered = new Set(parts.flatMap((p2) => {
|
|
120726
120880
|
if (p2.type !== "image" || !p2.registered || !p2.path) return [];
|
|
120727
120881
|
try {
|
|
120728
|
-
const file2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) :
|
|
120729
|
-
if (!
|
|
120730
|
-
const real =
|
|
120731
|
-
const fd =
|
|
120882
|
+
const file2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path39.resolve(cwd, p2.path);
|
|
120883
|
+
if (!fs36.lstatSync(file2).isFile()) return [];
|
|
120884
|
+
const real = fs36.realpathSync(file2);
|
|
120885
|
+
const fd = fs36.openSync(real, fs36.constants.O_RDONLY | (fs36.constants.O_NOFOLLOW ?? 0));
|
|
120732
120886
|
try {
|
|
120733
|
-
const stat =
|
|
120887
|
+
const stat = fs36.fstatSync(fd);
|
|
120734
120888
|
if (!stat.isFile() || stat.size > ASSET_FILE_LIMIT) return [];
|
|
120735
|
-
const mime = imageMime(
|
|
120889
|
+
const mime = imageMime(fs36.readFileSync(fd));
|
|
120736
120890
|
return mime && (!p2.mime || p2.mime === mime) ? [real] : [];
|
|
120737
120891
|
} finally {
|
|
120738
|
-
|
|
120892
|
+
fs36.closeSync(fd);
|
|
120739
120893
|
}
|
|
120740
120894
|
} catch {
|
|
120741
120895
|
return [];
|
|
@@ -120751,16 +120905,16 @@ function collectReplyImages(parts, cwd) {
|
|
|
120751
120905
|
if (!p2.path) throw Error();
|
|
120752
120906
|
const source = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : decodeURIComponent(p2.path);
|
|
120753
120907
|
if (/^[a-z][a-z0-9+.-]*:/i.test(source) && !/^[A-Za-z]:[\\/]/.test(source)) throw Error();
|
|
120754
|
-
const real =
|
|
120908
|
+
const real = fs36.realpathSync(path39.resolve(cwd, source));
|
|
120755
120909
|
if (!/\.(png|jpe?g|gif|webp)$/i.test(source) && !registered.has(real)) throw Error();
|
|
120756
120910
|
if (!roots.some((root2) => inside(root2, real)) && !registered.has(real)) throw Error();
|
|
120757
|
-
const fd =
|
|
120911
|
+
const fd = fs36.openSync(real, fs36.constants.O_RDONLY | (fs36.constants.O_NOFOLLOW ?? 0));
|
|
120758
120912
|
try {
|
|
120759
|
-
const stat =
|
|
120913
|
+
const stat = fs36.fstatSync(fd);
|
|
120760
120914
|
if (!stat.isFile() || stat.size > ASSET_FILE_LIMIT) throw Error();
|
|
120761
|
-
bytes2 =
|
|
120915
|
+
bytes2 = fs36.readFileSync(fd);
|
|
120762
120916
|
} finally {
|
|
120763
|
-
|
|
120917
|
+
fs36.closeSync(fd);
|
|
120764
120918
|
}
|
|
120765
120919
|
}
|
|
120766
120920
|
return bytes2;
|
|
@@ -120846,8 +121000,8 @@ async function saveReplyImages(parts, cwd, upload2) {
|
|
|
120846
121000
|
// src/handoff.ts
|
|
120847
121001
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
120848
121002
|
import crypto5 from "node:crypto";
|
|
120849
|
-
import
|
|
120850
|
-
import
|
|
121003
|
+
import fs37 from "node:fs";
|
|
121004
|
+
import path40 from "node:path";
|
|
120851
121005
|
var gitRead = (cwd, args2) => {
|
|
120852
121006
|
try {
|
|
120853
121007
|
return execFileSync2("git", ["-C", cwd, ...args2], {
|
|
@@ -120864,8 +121018,8 @@ var digest = (value) => crypto5.createHash("sha256").update(value).digest("hex")
|
|
|
120864
121018
|
function authorizedFolder(folder) {
|
|
120865
121019
|
if (!folder) return null;
|
|
120866
121020
|
try {
|
|
120867
|
-
const real =
|
|
120868
|
-
return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 +
|
|
121021
|
+
const real = fs37.realpathSync(folder);
|
|
121022
|
+
return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path40.sep)) ? real : null;
|
|
120869
121023
|
} catch {
|
|
120870
121024
|
return null;
|
|
120871
121025
|
}
|
|
@@ -120875,9 +121029,9 @@ function progressFolder(job, folder) {
|
|
|
120875
121029
|
if (!token) return folder;
|
|
120876
121030
|
if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) return null;
|
|
120877
121031
|
try {
|
|
120878
|
-
const dir =
|
|
120879
|
-
if (!dir.startsWith(
|
|
120880
|
-
const marker = JSON.parse(
|
|
121032
|
+
const dir = fs37.realpathSync(path40.join(folder, ".akb", "handoffs", token));
|
|
121033
|
+
if (!dir.startsWith(fs37.realpathSync(folder) + path40.sep)) return null;
|
|
121034
|
+
const marker = JSON.parse(fs37.readFileSync(path40.join(dir, ".akb", "handoff.json"), "utf8"));
|
|
120881
121035
|
return marker.task === job.task && marker.isolation === token ? dir : null;
|
|
120882
121036
|
} catch {
|
|
120883
121037
|
return null;
|
|
@@ -120885,38 +121039,38 @@ function progressFolder(job, folder) {
|
|
|
120885
121039
|
}
|
|
120886
121040
|
function progressEvidence(job, folder) {
|
|
120887
121041
|
try {
|
|
120888
|
-
const board =
|
|
120889
|
-
const deliveries =
|
|
120890
|
-
const rows =
|
|
121042
|
+
const board = path40.join(folder, ".akb", "kanban");
|
|
121043
|
+
const deliveries = path40.join(board, "deliveries");
|
|
121044
|
+
const rows = fs37.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs37.readFileSync(path40.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
|
|
120891
121045
|
const row = rows[0];
|
|
120892
121046
|
if (!row?.deliveryId) return null;
|
|
120893
|
-
const tree =
|
|
120894
|
-
if (tree !==
|
|
121047
|
+
const tree = fs37.realpathSync(path40.resolve(folder, row.worktree ?? "."));
|
|
121048
|
+
if (tree !== fs37.realpathSync(folder) && !tree.startsWith(fs37.realpathSync(folder) + path40.sep)) return null;
|
|
120895
121049
|
const inventory = gitRead(tree, ["worktree", "list", "--porcelain"]);
|
|
120896
121050
|
const related = (inventory ?? "").split("\n\n").flatMap((entry) => {
|
|
120897
121051
|
const branch = /^branch refs\/heads\/(.+)$/m.exec(entry)?.[1];
|
|
120898
121052
|
const dir = /^worktree (.+)$/m.exec(entry)?.[1];
|
|
120899
|
-
return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(
|
|
121053
|
+
return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs37.realpathSync(folder) + path40.sep) ? [dir] : [];
|
|
120900
121054
|
});
|
|
120901
121055
|
const filesIn = (tree2) => {
|
|
120902
121056
|
const changed = [];
|
|
120903
121057
|
const walk = (dir, prefix = "") => {
|
|
120904
|
-
for (const entry of
|
|
121058
|
+
for (const entry of fs37.readdirSync(dir, { withFileTypes: true })) {
|
|
120905
121059
|
if ([".git", ".akb", "node_modules", ".claude", ".agents"].includes(entry.name)) continue;
|
|
120906
121060
|
const name = prefix + entry.name;
|
|
120907
|
-
if (entry.isDirectory()) walk(
|
|
121061
|
+
if (entry.isDirectory()) walk(path40.join(dir, entry.name), name + "/");
|
|
120908
121062
|
else changed.push(name);
|
|
120909
121063
|
}
|
|
120910
121064
|
};
|
|
120911
121065
|
walk(tree2);
|
|
120912
121066
|
changed.sort();
|
|
120913
121067
|
return changed.map((name) => {
|
|
120914
|
-
const file2 =
|
|
121068
|
+
const file2 = path40.join(tree2, name);
|
|
120915
121069
|
try {
|
|
120916
|
-
const stat =
|
|
120917
|
-
if (stat.isSymbolicLink()) return [name, "link", digest(
|
|
121070
|
+
const stat = fs37.lstatSync(file2);
|
|
121071
|
+
if (stat.isSymbolicLink()) return [name, "link", digest(fs37.readlinkSync(file2))];
|
|
120918
121072
|
if (!stat.isFile()) throw new Error("\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B");
|
|
120919
|
-
return [name, stat.mode & 511, digest(
|
|
121073
|
+
return [name, stat.mode & 511, digest(fs37.readFileSync(file2))];
|
|
120920
121074
|
} catch (e2) {
|
|
120921
121075
|
if (e2.code === "ENOENT") return [name, "deleted"];
|
|
120922
121076
|
throw e2;
|
|
@@ -120953,60 +121107,60 @@ function progressEvidence(job, folder) {
|
|
|
120953
121107
|
function restartFolder(job, folder) {
|
|
120954
121108
|
const token = job.handoff?.isolation ?? job.id;
|
|
120955
121109
|
if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) throw new Error("\u9694\u79BB\u76EE\u5F55\u7F16\u53F7\u65E0\u6548\u3002");
|
|
120956
|
-
const dir =
|
|
120957
|
-
const marker =
|
|
120958
|
-
for (const parent of [
|
|
120959
|
-
if (
|
|
121110
|
+
const dir = path40.join(folder, ".akb", "handoffs", token);
|
|
121111
|
+
const marker = path40.join(dir, ".akb", "handoff.json");
|
|
121112
|
+
for (const parent of [path40.join(folder, ".akb"), path40.dirname(dir), dir]) {
|
|
121113
|
+
if (fs37.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
|
|
120960
121114
|
}
|
|
120961
|
-
if (
|
|
121115
|
+
if (fs37.existsSync(dir)) {
|
|
120962
121116
|
if (job.handoff?.recovering) {
|
|
120963
121117
|
try {
|
|
120964
|
-
const saved = JSON.parse(
|
|
121118
|
+
const saved = JSON.parse(fs37.readFileSync(marker, "utf8"));
|
|
120965
121119
|
if (saved.task === job.task && saved.isolation === token) return dir;
|
|
120966
121120
|
} catch {
|
|
120967
121121
|
}
|
|
120968
121122
|
}
|
|
120969
121123
|
throw new Error("\u91CD\u542F\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u3002");
|
|
120970
121124
|
}
|
|
120971
|
-
|
|
120972
|
-
|
|
120973
|
-
for (const entry of
|
|
121125
|
+
fs37.mkdirSync(path40.dirname(dir), { recursive: true });
|
|
121126
|
+
fs37.mkdirSync(dir);
|
|
121127
|
+
for (const entry of fs37.readdirSync(folder)) {
|
|
120974
121128
|
if ([".akb", ".git", "node_modules", ".claude", ".agents"].includes(entry)) continue;
|
|
120975
|
-
|
|
121129
|
+
fs37.cpSync(path40.join(folder, entry), path40.join(dir, entry), { recursive: true, verbatimSymlinks: true });
|
|
120976
121130
|
}
|
|
120977
|
-
if (
|
|
120978
|
-
|
|
120979
|
-
|
|
121131
|
+
if (fs37.lstatSync(path40.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
|
|
121132
|
+
fs37.mkdirSync(path40.dirname(marker), { recursive: true });
|
|
121133
|
+
fs37.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
|
|
120980
121134
|
return dir;
|
|
120981
121135
|
}
|
|
120982
121136
|
|
|
120983
121137
|
// src/jobs.ts
|
|
120984
121138
|
import { spawn as spawn4 } from "node:child_process";
|
|
120985
|
-
import
|
|
120986
|
-
import
|
|
121139
|
+
import fs42 from "node:fs";
|
|
121140
|
+
import path45 from "node:path";
|
|
120987
121141
|
|
|
120988
121142
|
// ../cli/src/lib/agent/catalog.ts
|
|
120989
|
-
import
|
|
120990
|
-
import
|
|
121143
|
+
import fs38 from "node:fs";
|
|
121144
|
+
import path41 from "node:path";
|
|
120991
121145
|
var CATALOGUE = "https://models.dev/api.json";
|
|
120992
121146
|
var FRESH_FOR_MS = 24 * 60 * 6e4;
|
|
120993
121147
|
var ANSWER_BY_MS = 2e4;
|
|
120994
121148
|
function cacheFile() {
|
|
120995
|
-
return
|
|
121149
|
+
return path41.join(machineHome(), "models-dev.json");
|
|
120996
121150
|
}
|
|
120997
121151
|
var held3;
|
|
120998
121152
|
function readCache() {
|
|
120999
121153
|
const file2 = cacheFile();
|
|
121000
121154
|
let stamp3;
|
|
121001
121155
|
try {
|
|
121002
|
-
const stat =
|
|
121156
|
+
const stat = fs38.statSync(file2);
|
|
121003
121157
|
stamp3 = `${stat.mtimeMs}:${stat.size}`;
|
|
121004
121158
|
} catch {
|
|
121005
121159
|
return void 0;
|
|
121006
121160
|
}
|
|
121007
121161
|
if (held3?.stamp === stamp3) return held3.cached;
|
|
121008
121162
|
try {
|
|
121009
|
-
const data = JSON.parse(
|
|
121163
|
+
const data = JSON.parse(fs38.readFileSync(file2, "utf8"));
|
|
121010
121164
|
if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
|
|
121011
121165
|
const cached2 = {
|
|
121012
121166
|
fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
|
|
@@ -121045,8 +121199,8 @@ function refreshCatalog() {
|
|
|
121045
121199
|
const limits = limitsIn(await answer.json());
|
|
121046
121200
|
if (Object.keys(limits).length === 0) return;
|
|
121047
121201
|
const file2 = cacheFile();
|
|
121048
|
-
|
|
121049
|
-
|
|
121202
|
+
fs38.mkdirSync(path41.dirname(file2), { recursive: true });
|
|
121203
|
+
fs38.writeFileSync(file2, JSON.stringify({ fetchedAt: Date.now(), limits }));
|
|
121050
121204
|
} catch {
|
|
121051
121205
|
}
|
|
121052
121206
|
})();
|
|
@@ -121137,14 +121291,14 @@ async function replyApprovalBridge(task, number, approve) {
|
|
|
121137
121291
|
}
|
|
121138
121292
|
|
|
121139
121293
|
// src/akb-version.ts
|
|
121140
|
-
import
|
|
121141
|
-
import
|
|
121142
|
-
var stateFile = () =>
|
|
121143
|
-
var akbVersionDir = (version) =>
|
|
121144
|
-
var entryOf = (dir) =>
|
|
121294
|
+
import fs39 from "node:fs";
|
|
121295
|
+
import path42 from "node:path";
|
|
121296
|
+
var stateFile = () => path42.join(akbHome(), "state.json");
|
|
121297
|
+
var akbVersionDir = (version) => path42.join(akbHome(), version);
|
|
121298
|
+
var entryOf = (dir) => path42.join(dir, "bin", "ai4kanban.mjs");
|
|
121145
121299
|
function readAkbState() {
|
|
121146
121300
|
try {
|
|
121147
|
-
const held5 = JSON.parse(
|
|
121301
|
+
const held5 = JSON.parse(fs39.readFileSync(stateFile(), "utf8"));
|
|
121148
121302
|
return { current: held5.current ?? null, bad: held5.bad ?? [] };
|
|
121149
121303
|
} catch {
|
|
121150
121304
|
return { current: null, bad: [] };
|
|
@@ -121152,12 +121306,12 @@ function readAkbState() {
|
|
|
121152
121306
|
}
|
|
121153
121307
|
function contractOf(dir) {
|
|
121154
121308
|
try {
|
|
121155
|
-
return JSON.parse(
|
|
121309
|
+
return JSON.parse(fs39.readFileSync(path42.join(dir, "package.json"), "utf8")).akbContract ?? null;
|
|
121156
121310
|
} catch {
|
|
121157
121311
|
return null;
|
|
121158
121312
|
}
|
|
121159
121313
|
}
|
|
121160
|
-
var usable = (dir) =>
|
|
121314
|
+
var usable = (dir) => fs39.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
|
|
121161
121315
|
function currentAkb() {
|
|
121162
121316
|
const { current: current2 } = readAkbState();
|
|
121163
121317
|
if (!current2) return bundledAkb();
|
|
@@ -121165,32 +121319,32 @@ function currentAkb() {
|
|
|
121165
121319
|
if (!usable(dir)) return bundledAkb();
|
|
121166
121320
|
try {
|
|
121167
121321
|
const now = /* @__PURE__ */ new Date();
|
|
121168
|
-
|
|
121322
|
+
fs39.utimesSync(dir, now, now);
|
|
121169
121323
|
} catch {
|
|
121170
121324
|
}
|
|
121171
|
-
return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim:
|
|
121325
|
+
return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path42.join(dir, "shim") };
|
|
121172
121326
|
}
|
|
121173
121327
|
|
|
121174
121328
|
// src/chats.ts
|
|
121175
|
-
import
|
|
121176
|
-
import
|
|
121329
|
+
import fs41 from "node:fs";
|
|
121330
|
+
import path44 from "node:path";
|
|
121177
121331
|
|
|
121178
121332
|
// ../cli/src/lib/shared/chats.ts
|
|
121179
121333
|
var CHAT_KEEP_DAYS = 30;
|
|
121180
121334
|
|
|
121181
121335
|
// ../cli/src/lib/agent/task-chats.ts
|
|
121182
|
-
import
|
|
121183
|
-
import
|
|
121336
|
+
import fs40 from "node:fs";
|
|
121337
|
+
import path43 from "node:path";
|
|
121184
121338
|
var TASK = /^[\w-]{1,100}$/;
|
|
121185
|
-
var taskChatsDir = (home4 = machineHome()) =>
|
|
121339
|
+
var taskChatsDir = (home4 = machineHome()) => path43.join(home4, "chats");
|
|
121186
121340
|
function taskChatFile(task, home4) {
|
|
121187
121341
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
121188
|
-
return
|
|
121342
|
+
return path43.join(taskChatsDir(home4), `${task}.jsonl`);
|
|
121189
121343
|
}
|
|
121190
121344
|
function readTaskChat(task, home4) {
|
|
121191
121345
|
let text3;
|
|
121192
121346
|
try {
|
|
121193
|
-
text3 =
|
|
121347
|
+
text3 = fs40.readFileSync(taskChatFile(task, home4), "utf8");
|
|
121194
121348
|
} catch {
|
|
121195
121349
|
return [];
|
|
121196
121350
|
}
|
|
@@ -121210,18 +121364,18 @@ function readTaskChat(task, home4) {
|
|
|
121210
121364
|
var DAY_MS = 24 * 60 * 6e4;
|
|
121211
121365
|
var KEEP_MS2 = CHAT_KEEP_DAYS * DAY_MS;
|
|
121212
121366
|
var home3 = () => runnerHome();
|
|
121213
|
-
var reviewedFile = () =>
|
|
121367
|
+
var reviewedFile = () => path44.join(taskChatsDir(home3()), "reviewed.json");
|
|
121214
121368
|
function readReviewed() {
|
|
121215
121369
|
try {
|
|
121216
|
-
const held5 = JSON.parse(
|
|
121370
|
+
const held5 = JSON.parse(fs41.readFileSync(reviewedFile(), "utf8"));
|
|
121217
121371
|
return { checkedAt: Number(held5.checkedAt) || 0, tasks: held5.tasks ?? {} };
|
|
121218
121372
|
} catch {
|
|
121219
121373
|
return { checkedAt: 0, tasks: {} };
|
|
121220
121374
|
}
|
|
121221
121375
|
}
|
|
121222
121376
|
function writeReviewed(reviewed) {
|
|
121223
|
-
|
|
121224
|
-
|
|
121377
|
+
fs41.mkdirSync(path44.dirname(reviewedFile()), { recursive: true });
|
|
121378
|
+
fs41.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
|
|
121225
121379
|
`);
|
|
121226
121380
|
}
|
|
121227
121381
|
function keepChat(job, reply, at2 = Date.now()) {
|
|
@@ -121231,16 +121385,16 @@ function keepChat(job, reply, at2 = Date.now()) {
|
|
|
121231
121385
|
{ id: job.id, role: "agent", text: reply, at: at2, runtime: job.runtime, model: job.model ?? null }
|
|
121232
121386
|
];
|
|
121233
121387
|
const file2 = taskChatFile(job.task, home3());
|
|
121234
|
-
|
|
121235
|
-
|
|
121388
|
+
fs41.mkdirSync(path44.dirname(file2), { recursive: true });
|
|
121389
|
+
fs41.appendFileSync(file2, lines.map((l2) => `${JSON.stringify(l2)}
|
|
121236
121390
|
`).join(""));
|
|
121237
121391
|
}
|
|
121238
121392
|
function keepCloudChat(task, messages) {
|
|
121239
121393
|
const file2 = taskChatFile(task, home3());
|
|
121240
|
-
if (!messages.length) return
|
|
121394
|
+
if (!messages.length) return fs41.rmSync(file2, { force: true });
|
|
121241
121395
|
const lines = messages.map((m) => ({ id: m.id, role: m.role, text: m.body, at: Date.parse(m.created_at) || Date.now() }));
|
|
121242
|
-
|
|
121243
|
-
|
|
121396
|
+
fs41.mkdirSync(path44.dirname(file2), { recursive: true });
|
|
121397
|
+
fs41.writeFileSync(file2, lines.map((l2) => `${JSON.stringify(l2)}
|
|
121244
121398
|
`).join(""));
|
|
121245
121399
|
}
|
|
121246
121400
|
async function keepDecisions(task, read4) {
|
|
@@ -121258,8 +121412,8 @@ async function keepDecisions(task, read4) {
|
|
|
121258
121412
|
const ids = new Set(comments.map((c2) => c2.id));
|
|
121259
121413
|
const lines = [...readTaskChat(task, home3()).filter((l2) => !ids.has(l2.id)), ...comments].sort((a2, b2) => a2.at - b2.at);
|
|
121260
121414
|
const file2 = taskChatFile(task, home3());
|
|
121261
|
-
|
|
121262
|
-
|
|
121415
|
+
fs41.mkdirSync(path44.dirname(file2), { recursive: true });
|
|
121416
|
+
fs41.writeFileSync(file2, lines.map((l2) => `${JSON.stringify(l2)}
|
|
121263
121417
|
`).join(""));
|
|
121264
121418
|
}
|
|
121265
121419
|
var lastOf = (task) => readTaskChat(task, home3()).at(-1);
|
|
@@ -121339,32 +121493,32 @@ var defaultDeps = (machineId) => ({
|
|
|
121339
121493
|
akb: currentAkb,
|
|
121340
121494
|
runtimes: detectRuntimes
|
|
121341
121495
|
});
|
|
121342
|
-
var ownFolder = () =>
|
|
121496
|
+
var ownFolder = () => path45.join(runnerHome(), "work");
|
|
121343
121497
|
function folderFor(job) {
|
|
121344
121498
|
if (!job.projectDir) {
|
|
121345
|
-
const cwd =
|
|
121346
|
-
|
|
121499
|
+
const cwd = path45.join(ownFolder(), job.id);
|
|
121500
|
+
fs42.mkdirSync(cwd, { recursive: true });
|
|
121347
121501
|
return { cwd };
|
|
121348
121502
|
}
|
|
121349
121503
|
const real = realpath2(job.projectDir);
|
|
121350
|
-
if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 +
|
|
121504
|
+
if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path45.sep))) return { cwd: real };
|
|
121351
121505
|
return { refused: `This Runner is not allowed to work in ${job.projectDir}.` };
|
|
121352
121506
|
}
|
|
121353
121507
|
function realpath2(p2) {
|
|
121354
121508
|
try {
|
|
121355
|
-
return
|
|
121509
|
+
return fs42.realpathSync(p2);
|
|
121356
121510
|
} catch {
|
|
121357
121511
|
return null;
|
|
121358
121512
|
}
|
|
121359
121513
|
}
|
|
121360
|
-
var attachmentsOf = (job) =>
|
|
121514
|
+
var attachmentsOf = (job) => path45.join(runnerHome(), "attachments", job.id);
|
|
121361
121515
|
function writeAttachments(job) {
|
|
121362
121516
|
if (!job.attachments.length) return "";
|
|
121363
121517
|
const dir = attachmentsOf(job);
|
|
121364
|
-
|
|
121518
|
+
fs42.mkdirSync(dir, { recursive: true });
|
|
121365
121519
|
const files = job.attachments.map((a2) => {
|
|
121366
|
-
const file2 =
|
|
121367
|
-
|
|
121520
|
+
const file2 = path45.join(dir, path45.basename(a2.name));
|
|
121521
|
+
fs42.writeFileSync(file2, Buffer.from(a2.content, "base64"));
|
|
121368
121522
|
return file2;
|
|
121369
121523
|
});
|
|
121370
121524
|
return `
|
|
@@ -121401,6 +121555,8 @@ function toWire(events, first) {
|
|
|
121401
121555
|
var leaseNow = () => ({ at: Date.now(), monotonic: performance.now() });
|
|
121402
121556
|
function streamOut(deps, id, lease) {
|
|
121403
121557
|
const wire = [];
|
|
121558
|
+
let firstContent = false;
|
|
121559
|
+
let bufferedChars = 0;
|
|
121404
121560
|
let firstSeq = null;
|
|
121405
121561
|
let pending = [];
|
|
121406
121562
|
let size = 0;
|
|
@@ -121535,9 +121691,16 @@ function streamOut(deps, id, lease) {
|
|
|
121535
121691
|
const event2 = (e2) => {
|
|
121536
121692
|
if (!valid()) return;
|
|
121537
121693
|
if (e2.kind === "message") messages.push(e2.data.text);
|
|
121538
|
-
|
|
121539
|
-
|
|
121540
|
-
|
|
121694
|
+
const content = ["message", "tool_call", "tool_call_update", "plan"].includes(e2.kind) || e2.kind === "phase" && !!e2.data.contentAt;
|
|
121695
|
+
const immediate = e2.kind === "phase" || content && !firstContent;
|
|
121696
|
+
firstContent ||= content;
|
|
121697
|
+
const stamped = Object.assign({}, e2, { data: { ...e2.data, eventAt: "eventAt" in e2.data ? e2.data.eventAt : (/* @__PURE__ */ new Date()).toISOString() } });
|
|
121698
|
+
const chars = JSON.stringify(stamped).length;
|
|
121699
|
+
if (bufferedChars + chars > 16 * 1024 * 1024) return;
|
|
121700
|
+
bufferedChars += chars;
|
|
121701
|
+
pending.push(stamped);
|
|
121702
|
+
size += chars;
|
|
121703
|
+
if (immediate || log.watched && size >= FLUSH_CHARS) flush();
|
|
121541
121704
|
};
|
|
121542
121705
|
const flusher = setInterval(() => {
|
|
121543
121706
|
if (log.watched && pending.length && Date.now() - flushedAt >= deps.flushMs) flush();
|
|
@@ -121647,12 +121810,12 @@ async function runJob(id, deps, track = () => {
|
|
|
121647
121810
|
const releases = [];
|
|
121648
121811
|
try {
|
|
121649
121812
|
const akb = deps.akb();
|
|
121650
|
-
releases.push(hold(
|
|
121813
|
+
releases.push(hold(path45.dirname(akb.shim)));
|
|
121651
121814
|
releases.push(hold(akb.shim));
|
|
121652
121815
|
await runClaimed(job, { ...deps, akb }, track, (dir) => releases.push(hold(dir)), lease);
|
|
121653
121816
|
} finally {
|
|
121654
121817
|
for (const release2 of releases) release2();
|
|
121655
|
-
|
|
121818
|
+
fs42.rmSync(attachmentsOf(job), { recursive: true, force: true });
|
|
121656
121819
|
}
|
|
121657
121820
|
}
|
|
121658
121821
|
async function runClaimed(job, deps, track, keep2, lease, replyStream) {
|
|
@@ -121660,6 +121823,7 @@ async function runClaimed(job, deps, track, keep2, lease, replyStream) {
|
|
|
121660
121823
|
try {
|
|
121661
121824
|
await runClaimedStep(job, deps, track, keep2, lease, scope, replyStream);
|
|
121662
121825
|
} finally {
|
|
121826
|
+
scope.progress?.cancel();
|
|
121663
121827
|
scope.bridge?.close();
|
|
121664
121828
|
scope.preview?.close();
|
|
121665
121829
|
}
|
|
@@ -121809,7 +121973,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
|
|
|
121809
121973
|
discussed = board.board;
|
|
121810
121974
|
}
|
|
121811
121975
|
if (job.discussion) {
|
|
121812
|
-
const wrote =
|
|
121976
|
+
const wrote = await writeGoals({ ...job, discussion: job.discussion }, deps.api.listStudios, recovering);
|
|
121813
121977
|
if ("error" in wrote) throw new Error(wrote.error);
|
|
121814
121978
|
goalFile = wrote.file;
|
|
121815
121979
|
}
|
|
@@ -121856,9 +122020,20 @@ ${prompt}` : prompt;
|
|
|
121856
122020
|
if (deps.authorize && !await deps.authorize(job)) return finishClaimed("failed", "\u9879\u76EE\u76EE\u5F55\u6388\u6743\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u540E\u91CD\u8BD5\u3002");
|
|
121857
122021
|
if (!held4(deps, lease)) return;
|
|
121858
122022
|
if (reply) {
|
|
121859
|
-
|
|
121860
|
-
|
|
121861
|
-
|
|
122023
|
+
for (let check = 0; ; check++) {
|
|
122024
|
+
const requestedAt = leaseNow();
|
|
122025
|
+
const renewed = await deps.api.renewJob(deps.machineId, id);
|
|
122026
|
+
if (!renewed.ok || !renewed.value.renewed || !held4(deps, lease)) return;
|
|
122027
|
+
if (renewed.value.stop) return finishClaimed("stopped", "", { stopped: true });
|
|
122028
|
+
Object.assign(lease, requestedAt);
|
|
122029
|
+
if (!job.discussion || !renewed.value.catalog || renewed.value.catalog.version === job.discussion.catalog?.version && renewed.value.catalog.account === job.discussion.catalog.account) break;
|
|
122030
|
+
if (check >= 2) return finishClaimed("failed", "The studio catalog keeps changing. Try again.");
|
|
122031
|
+
job.discussion.catalog = renewed.value.catalog;
|
|
122032
|
+
const wrote = await writeGoals({ ...job, discussion: job.discussion }, deps.api.listStudios, true);
|
|
122033
|
+
if ("error" in wrote) return finishClaimed("failed", wrote.error);
|
|
122034
|
+
goalFile = wrote.file;
|
|
122035
|
+
if (deps.authorize && !await deps.authorize(job)) return finishClaimed("failed", "\u9879\u76EE\u76EE\u5F55\u6388\u6743\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u540E\u91CD\u8BD5\u3002");
|
|
122036
|
+
}
|
|
121862
122037
|
}
|
|
121863
122038
|
const stream = replyStream ?? streamOut(deps, id, lease);
|
|
121864
122039
|
if (run3?.startNote) stream.out(`${run3.startNote}
|
|
@@ -121879,24 +122054,23 @@ ${prompt}` : prompt;
|
|
|
121879
122054
|
return { ...rest, ...replySpent(checkpoint, job.runtime) };
|
|
121880
122055
|
};
|
|
121881
122056
|
let replyProgress = false;
|
|
121882
|
-
|
|
121883
|
-
|
|
122057
|
+
const account = readSession()?.subject;
|
|
122058
|
+
const generation = accountGeneration();
|
|
122059
|
+
const evidence = scope.progress = conversationProgress(checkpoint.retry?.attempt ?? 1, async (progress) => {
|
|
122060
|
+
const result = await deps.api.renewJob(deps.machineId, id, { ...progress, ...job.claim ? { claim: job.claim } : {} });
|
|
122061
|
+
if (!evidence.active()) return;
|
|
122062
|
+
if (!result.ok) throw new Error(result.error);
|
|
122063
|
+
if (!result.value.renewed) await stream.stop();
|
|
122064
|
+
else if (result.value.stop) stream.requestStop();
|
|
122065
|
+
}, () => reply && progressValid(), () => stream.out("[chat-progress] Evidence was not confirmed.\n"));
|
|
122066
|
+
const progressValid = () => !stream.asked() && !stream.lost() && readSession()?.subject === account && accountGeneration() === generation;
|
|
121884
122067
|
const subagents = trackSubagents();
|
|
121885
122068
|
const remember = (event2) => {
|
|
121886
122069
|
if (["message", "tool_call", "tool_call_update"].includes(event2.kind)) replyProgress = true;
|
|
121887
122070
|
if (stream.lost()) return;
|
|
121888
|
-
const
|
|
121889
|
-
|
|
121890
|
-
|
|
121891
|
-
const progress = { attempt: checkpoint.retry?.attempt ?? 1, ...event2.kind === "phase" ? { phase: event2.data.phase } : {}, ...content ? { contentAt: (/* @__PURE__ */ new Date()).toISOString() } : {} };
|
|
121892
|
-
evidence = evidence.then(async () => {
|
|
121893
|
-
if (stream.asked() || stream.lost()) return;
|
|
121894
|
-
const result = await deps.api.renewJob(deps.machineId, id, progress);
|
|
121895
|
-
if (result.ok && !result.value.renewed) await stream.stop();
|
|
121896
|
-
else if (result.ok && result.value.stop) stream.requestStop();
|
|
121897
|
-
}).catch(() => {
|
|
121898
|
-
});
|
|
121899
|
-
}
|
|
122071
|
+
const at2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
122072
|
+
event2 = Object.assign({}, event2, { data: { ...event2.data, eventAt: at2 } });
|
|
122073
|
+
evidence.observe(event2, at2);
|
|
121900
122074
|
subagents.event(event2);
|
|
121901
122075
|
checkpointEvent(checkpoint, event2);
|
|
121902
122076
|
const session = run3?.session();
|
|
@@ -121933,6 +122107,7 @@ ${prompt}` : prompt;
|
|
|
121933
122107
|
checkpoint.updating = true;
|
|
121934
122108
|
persist();
|
|
121935
122109
|
stream.event({ kind: "log", data: { text: "[chat-recovery] running" } });
|
|
122110
|
+
evidence.cancel();
|
|
121936
122111
|
await runClaimed({ ...job, manualRecovery: false, retryReplay: safe3 }, deps, track, keep2, lease, stream);
|
|
121937
122112
|
await stream.end();
|
|
121938
122113
|
return true;
|
|
@@ -122051,6 +122226,7 @@ ${prompt}` : prompt;
|
|
|
122051
122226
|
checkpoint.started = false;
|
|
122052
122227
|
if (checkpoint.retry) checkpoint.retry.attempt++;
|
|
122053
122228
|
persist();
|
|
122229
|
+
evidence.cancel();
|
|
122054
122230
|
await runClaimed({ ...job, resume: null, fork: false, sessionFallback: true }, deps, track, keep2, lease, stream);
|
|
122055
122231
|
await stream.end();
|
|
122056
122232
|
return;
|
|
@@ -122060,7 +122236,7 @@ ${prompt}` : prompt;
|
|
|
122060
122236
|
persist();
|
|
122061
122237
|
}
|
|
122062
122238
|
if (await retry2(end.ok ? void 0 : end.error)) return;
|
|
122063
|
-
await evidence;
|
|
122239
|
+
await evidence.drain(deps.endMs);
|
|
122064
122240
|
const stopped3 = await stopReply(id, deps.stopMs);
|
|
122065
122241
|
stop(child);
|
|
122066
122242
|
if (stream.asked() && (!stopped3 || !await stream.confirmed())) {
|
|
@@ -122316,8 +122492,8 @@ async function runTest(job, deps, lease) {
|
|
|
122316
122492
|
const report2 = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
|
|
122317
122493
|
if (!report2?.installed) return finish2("failed", "not_installed");
|
|
122318
122494
|
if (report2.loggedIn === false) return finish2("failed", "signed_out");
|
|
122319
|
-
const cwd =
|
|
122320
|
-
|
|
122495
|
+
const cwd = path45.join(ownFolder(), "test");
|
|
122496
|
+
fs42.mkdirSync(cwd, { recursive: true });
|
|
122321
122497
|
const run3 = deps.plan(job.runtime, job.prompt, cwd, null, job.model, settingsOf(job));
|
|
122322
122498
|
const startedAt = Date.now();
|
|
122323
122499
|
if (run3.converse) {
|
|
@@ -122405,32 +122581,13 @@ Previews that cannot be drawn:
|
|
|
122405
122581
|
${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
|
|
122406
122582
|
}
|
|
122407
122583
|
|
|
122408
|
-
// src/settings-control.ts
|
|
122409
|
-
import fs42 from "node:fs";
|
|
122410
|
-
import path45 from "node:path";
|
|
122411
|
-
var directory = () => path45.join(runnerHome(), "executors");
|
|
122412
|
-
var epochFile = () => path45.join(runnerHome(), "account-generation");
|
|
122413
|
-
function accountGeneration() {
|
|
122414
|
-
try {
|
|
122415
|
-
return fs42.readFileSync(epochFile(), "utf8");
|
|
122416
|
-
} catch {
|
|
122417
|
-
return "";
|
|
122418
|
-
}
|
|
122419
|
-
}
|
|
122420
|
-
function executorRecord() {
|
|
122421
|
-
fs42.mkdirSync(directory(), { recursive: true, mode: 448 });
|
|
122422
|
-
const file2 = path45.join(directory(), `${process.pid}.json`);
|
|
122423
|
-
fs42.writeFileSync(file2, "{}", { mode: 384 });
|
|
122424
|
-
return () => fs42.rmSync(file2, { force: true });
|
|
122425
|
-
}
|
|
122426
|
-
|
|
122427
122584
|
// src/flow-worker.ts
|
|
122428
122585
|
var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
|
|
122429
122586
|
var directory2 = () => path46.join(runnerHome(), "flow-workers");
|
|
122430
122587
|
var fileOf2 = (id) => path46.join(directory2(), `${encodeURIComponent(id)}.json`);
|
|
122431
122588
|
var stopFile = (id) => `${fileOf2(id)}.stop`;
|
|
122432
122589
|
var flowWorkerEntry = fileURLToPath4(new URL("./flow-worker-main.mjs", import.meta.url));
|
|
122433
|
-
var canKeepFlow = (job) => !!job.task && !!job.flow && ["create", "refine", "implement"].includes(job.flow.verb) && !job.agent && !job.review && !job.discussion && !job.test && !job.secret;
|
|
122590
|
+
var canKeepFlow = (job) => !!job.task && !!job.flow && ["create", "refine", "implement", "preview"].includes(job.flow.verb) && !job.agent && !job.review && !job.discussion && !job.test && !job.secret;
|
|
122434
122591
|
function read3(id) {
|
|
122435
122592
|
try {
|
|
122436
122593
|
return JSON.parse(fs43.readFileSync(fileOf2(id), "utf8"));
|