wildcrane-runner 0.6.55 → 0.6.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +1334 -892
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +447 -73
- package/dist/plugin.mjs +485 -111
- package/dist/runner.mjs +1084 -593
- package/dist/settings.mjs +437 -63
- package/package.json +1 -1
package/dist/plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.57 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -7237,8 +7237,8 @@ var require_dist = __commonJS({
|
|
|
7237
7237
|
return ajv;
|
|
7238
7238
|
}
|
|
7239
7239
|
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
|
7240
|
-
const
|
|
7241
|
-
addFormats(ajv,
|
|
7240
|
+
const list2 = opts.formats || formats_1.formatNames;
|
|
7241
|
+
addFormats(ajv, list2, formats, exportName);
|
|
7242
7242
|
if (opts.keywords)
|
|
7243
7243
|
(0, limit_1.default)(ajv);
|
|
7244
7244
|
return ajv;
|
|
@@ -7250,11 +7250,11 @@ var require_dist = __commonJS({
|
|
|
7250
7250
|
throw new Error(`Unknown format "${name}"`);
|
|
7251
7251
|
return f;
|
|
7252
7252
|
};
|
|
7253
|
-
function addFormats(ajv,
|
|
7253
|
+
function addFormats(ajv, list2, fs28, exportName) {
|
|
7254
7254
|
var _a3;
|
|
7255
7255
|
var _b;
|
|
7256
7256
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
7257
|
-
for (const f of
|
|
7257
|
+
for (const f of list2)
|
|
7258
7258
|
ajv.addFormat(f, fs28[f]);
|
|
7259
7259
|
}
|
|
7260
7260
|
module.exports = exports = formatsPlugin;
|
|
@@ -26047,8 +26047,8 @@ var require_json_schema_processors = __commonJS({
|
|
|
26047
26047
|
function aggregateChecks2(schema) {
|
|
26048
26048
|
const agg = {};
|
|
26049
26049
|
const def = schema._zod.def;
|
|
26050
|
-
const
|
|
26051
|
-
for (const ch of
|
|
26050
|
+
const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
26051
|
+
for (const ch of list2)
|
|
26052
26052
|
contributors2[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
26053
26053
|
const bag = schema._zod.bag;
|
|
26054
26054
|
if (bag.minimum !== void 0)
|
|
@@ -29912,7 +29912,7 @@ var require_visit = __commonJS({
|
|
|
29912
29912
|
return h ? h(node2, rewritten) : node2;
|
|
29913
29913
|
};
|
|
29914
29914
|
const cache = /* @__PURE__ */ new Map();
|
|
29915
|
-
function
|
|
29915
|
+
function run3(s) {
|
|
29916
29916
|
const cached3 = cache.get(s);
|
|
29917
29917
|
if (cached3 === RESOLVING) {
|
|
29918
29918
|
return new schemas.$ZodLazy({
|
|
@@ -29938,21 +29938,21 @@ var require_visit = __commonJS({
|
|
|
29938
29938
|
let changed = false;
|
|
29939
29939
|
const newShape = {};
|
|
29940
29940
|
for (const k of keys) {
|
|
29941
|
-
const mapped =
|
|
29941
|
+
const mapped = run3(oldShape[k]);
|
|
29942
29942
|
if (mapped !== oldShape[k])
|
|
29943
29943
|
changed = true;
|
|
29944
29944
|
newShape[k] = mapped;
|
|
29945
29945
|
}
|
|
29946
29946
|
let newCatchall = def.catchall;
|
|
29947
29947
|
if (def.catchall) {
|
|
29948
|
-
newCatchall =
|
|
29948
|
+
newCatchall = run3(def.catchall);
|
|
29949
29949
|
if (newCatchall !== def.catchall)
|
|
29950
29950
|
changed = true;
|
|
29951
29951
|
}
|
|
29952
29952
|
return changed ? (0, util_js_1.clone)(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
|
|
29953
29953
|
}
|
|
29954
29954
|
case "array": {
|
|
29955
|
-
const mapped =
|
|
29955
|
+
const mapped = run3(def.element);
|
|
29956
29956
|
return mapped === def.element ? s : (0, util_js_1.clone)(s, { ...def, element: mapped });
|
|
29957
29957
|
}
|
|
29958
29958
|
case "tuple": {
|
|
@@ -29960,14 +29960,14 @@ var require_visit = __commonJS({
|
|
|
29960
29960
|
let changed = false;
|
|
29961
29961
|
const newItems = [];
|
|
29962
29962
|
for (const item of oldItems) {
|
|
29963
|
-
const mapped =
|
|
29963
|
+
const mapped = run3(item);
|
|
29964
29964
|
if (mapped !== item)
|
|
29965
29965
|
changed = true;
|
|
29966
29966
|
newItems.push(mapped);
|
|
29967
29967
|
}
|
|
29968
29968
|
let newRest = def.rest;
|
|
29969
29969
|
if (def.rest) {
|
|
29970
|
-
newRest =
|
|
29970
|
+
newRest = run3(def.rest);
|
|
29971
29971
|
if (newRest !== def.rest)
|
|
29972
29972
|
changed = true;
|
|
29973
29973
|
}
|
|
@@ -29975,12 +29975,12 @@ var require_visit = __commonJS({
|
|
|
29975
29975
|
}
|
|
29976
29976
|
case "record":
|
|
29977
29977
|
case "map": {
|
|
29978
|
-
const newKey =
|
|
29979
|
-
const newVal =
|
|
29978
|
+
const newKey = run3(def.keyType);
|
|
29979
|
+
const newVal = run3(def.valueType);
|
|
29980
29980
|
return newKey === def.keyType && newVal === def.valueType ? s : (0, util_js_1.clone)(s, { ...def, keyType: newKey, valueType: newVal });
|
|
29981
29981
|
}
|
|
29982
29982
|
case "set": {
|
|
29983
|
-
const newVal =
|
|
29983
|
+
const newVal = run3(def.valueType);
|
|
29984
29984
|
return newVal === def.valueType ? s : (0, util_js_1.clone)(s, { ...def, valueType: newVal });
|
|
29985
29985
|
}
|
|
29986
29986
|
case "union": {
|
|
@@ -29988,7 +29988,7 @@ var require_visit = __commonJS({
|
|
|
29988
29988
|
let changed = false;
|
|
29989
29989
|
const newOptions = [];
|
|
29990
29990
|
for (const opt of oldOptions) {
|
|
29991
|
-
const mapped =
|
|
29991
|
+
const mapped = run3(opt);
|
|
29992
29992
|
if (mapped !== opt)
|
|
29993
29993
|
changed = true;
|
|
29994
29994
|
newOptions.push(mapped);
|
|
@@ -29996,8 +29996,8 @@ var require_visit = __commonJS({
|
|
|
29996
29996
|
return changed ? (0, util_js_1.clone)(s, { ...def, options: newOptions }) : s;
|
|
29997
29997
|
}
|
|
29998
29998
|
case "intersection": {
|
|
29999
|
-
const newLeft =
|
|
30000
|
-
const newRight =
|
|
29999
|
+
const newLeft = run3(def.left);
|
|
30000
|
+
const newRight = run3(def.right);
|
|
30001
30001
|
return newLeft === def.left && newRight === def.right ? s : (0, util_js_1.clone)(s, { ...def, left: newLeft, right: newRight });
|
|
30002
30002
|
}
|
|
30003
30003
|
case "optional":
|
|
@@ -30009,23 +30009,23 @@ var require_visit = __commonJS({
|
|
|
30009
30009
|
case "nonoptional":
|
|
30010
30010
|
case "promise":
|
|
30011
30011
|
case "success": {
|
|
30012
|
-
const newInner =
|
|
30012
|
+
const newInner = run3(def.innerType);
|
|
30013
30013
|
return newInner === def.innerType ? s : (0, util_js_1.clone)(s, { ...def, innerType: newInner });
|
|
30014
30014
|
}
|
|
30015
30015
|
case "pipe": {
|
|
30016
|
-
const newIn =
|
|
30017
|
-
const newOut =
|
|
30016
|
+
const newIn = run3(def.in);
|
|
30017
|
+
const newOut = run3(def.out);
|
|
30018
30018
|
return newIn === def.in && newOut === def.out ? s : (0, util_js_1.clone)(s, { ...def, in: newIn, out: newOut });
|
|
30019
30019
|
}
|
|
30020
30020
|
case "function": {
|
|
30021
|
-
const newInput =
|
|
30022
|
-
const newOutput =
|
|
30021
|
+
const newInput = run3(def.input);
|
|
30022
|
+
const newOutput = run3(def.output);
|
|
30023
30023
|
return newInput === def.input && newOutput === def.output ? s : (0, util_js_1.clone)(s, { ...def, input: newInput, output: newOutput });
|
|
30024
30024
|
}
|
|
30025
30025
|
case "lazy": {
|
|
30026
30026
|
const original = def.getter;
|
|
30027
30027
|
const { _cachedInner, ...rest } = def;
|
|
30028
|
-
return (0, util_js_1.clone)(s, { ...rest, getter: () =>
|
|
30028
|
+
return (0, util_js_1.clone)(s, { ...rest, getter: () => run3(original()) });
|
|
30029
30029
|
}
|
|
30030
30030
|
// A leaf by choice: `parts` are regex fragments, not data positions.
|
|
30031
30031
|
case "template_literal":
|
|
@@ -30056,7 +30056,7 @@ var require_visit = __commonJS({
|
|
|
30056
30056
|
}
|
|
30057
30057
|
}
|
|
30058
30058
|
}
|
|
30059
|
-
return
|
|
30059
|
+
return run3(schema);
|
|
30060
30060
|
}
|
|
30061
30061
|
(function() {
|
|
30062
30062
|
var keys = Object.getOwnPropertyNames(exports);
|
|
@@ -36237,8 +36237,8 @@ var require_util4 = __commonJS({
|
|
|
36237
36237
|
}
|
|
36238
36238
|
return values;
|
|
36239
36239
|
}
|
|
36240
|
-
function getDecodeSplit(name,
|
|
36241
|
-
const value =
|
|
36240
|
+
function getDecodeSplit(name, list2) {
|
|
36241
|
+
const value = list2.get(name, true);
|
|
36242
36242
|
if (value === null) {
|
|
36243
36243
|
return null;
|
|
36244
36244
|
}
|
|
@@ -50297,9 +50297,9 @@ var require_headers = __commonJS({
|
|
|
50297
50297
|
// https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
|
|
50298
50298
|
getSetCookie() {
|
|
50299
50299
|
webidl.brandCheck(this, _Headers);
|
|
50300
|
-
const
|
|
50301
|
-
if (
|
|
50302
|
-
return [...
|
|
50300
|
+
const list2 = this.#headersList.cookies;
|
|
50301
|
+
if (list2) {
|
|
50302
|
+
return [...list2];
|
|
50303
50303
|
}
|
|
50304
50304
|
return [];
|
|
50305
50305
|
}
|
|
@@ -50323,8 +50323,8 @@ var require_headers = __commonJS({
|
|
|
50323
50323
|
* @param {Headers} target
|
|
50324
50324
|
* @param {HeadersList} list
|
|
50325
50325
|
*/
|
|
50326
|
-
static setHeadersList(target,
|
|
50327
|
-
target.#headersList =
|
|
50326
|
+
static setHeadersList(target, list2) {
|
|
50327
|
+
target.#headersList = list2;
|
|
50328
50328
|
}
|
|
50329
50329
|
};
|
|
50330
50330
|
var { getHeadersGuard, setHeadersGuard, getHeadersList, setHeadersList } = Headers;
|
|
@@ -51275,13 +51275,13 @@ var require_request2 = __commonJS({
|
|
|
51275
51275
|
if (this.signal.aborted) {
|
|
51276
51276
|
ac.abort(this.signal.reason);
|
|
51277
51277
|
} else {
|
|
51278
|
-
let
|
|
51279
|
-
if (
|
|
51280
|
-
|
|
51281
|
-
dependentControllerMap.set(this.signal,
|
|
51278
|
+
let list2 = dependentControllerMap.get(this.signal);
|
|
51279
|
+
if (list2 === void 0) {
|
|
51280
|
+
list2 = /* @__PURE__ */ new Set();
|
|
51281
|
+
dependentControllerMap.set(this.signal, list2);
|
|
51282
51282
|
}
|
|
51283
51283
|
const acRef = new WeakRef(ac);
|
|
51284
|
-
|
|
51284
|
+
list2.add(acRef);
|
|
51285
51285
|
util2.addAbortListener(
|
|
51286
51286
|
ac.signal,
|
|
51287
51287
|
buildAbort(acRef)
|
|
@@ -65971,8 +65971,8 @@ var contributors = {
|
|
|
65971
65971
|
function aggregateChecks(schema) {
|
|
65972
65972
|
const agg = {};
|
|
65973
65973
|
const def = schema._zod.def;
|
|
65974
|
-
const
|
|
65975
|
-
for (const ch of
|
|
65974
|
+
const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
65975
|
+
for (const ch of list2)
|
|
65976
65976
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
65977
65977
|
const bag = schema._zod.bag;
|
|
65978
65978
|
if (bag.minimum !== void 0)
|
|
@@ -73774,8 +73774,8 @@ function machineId() {
|
|
|
73774
73774
|
var machineName = () => os3.hostname().replace(/\.local$/, "");
|
|
73775
73775
|
|
|
73776
73776
|
// src/protocol.ts
|
|
73777
|
-
var VERSION = true ? "0.6.
|
|
73778
|
-
var AKB_VERSION = true ? "0.11.
|
|
73777
|
+
var VERSION = true ? "0.6.57" : "0.0.0";
|
|
73778
|
+
var AKB_VERSION = true ? "0.11.45" : "0.0.0";
|
|
73779
73779
|
var EXIT_REFUSED = 10;
|
|
73780
73780
|
var EXIT_OUTDATED = 11;
|
|
73781
73781
|
var EXIT_UPDATE = 12;
|
|
@@ -74137,7 +74137,7 @@ var OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
|
|
|
74137
74137
|
var AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
74138
74138
|
var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
|
|
74139
74139
|
var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
|
|
74140
|
-
function parseSpecAgent(text4, from, file2, builtIn = false,
|
|
74140
|
+
function parseSpecAgent(text4, from, file2, builtIn = false, list2 = () => []) {
|
|
74141
74141
|
let named = "";
|
|
74142
74142
|
const bad = (why, old2) => ({
|
|
74143
74143
|
problem: `${from}: ${why}`,
|
|
@@ -74199,7 +74199,7 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list = () => []) {
|
|
|
74199
74199
|
...declaredSession ? { session: "new" } : {},
|
|
74200
74200
|
memory: names(akb.memory),
|
|
74201
74201
|
memoryFiles: { workspace },
|
|
74202
|
-
files:
|
|
74202
|
+
files: list2(),
|
|
74203
74203
|
body: instructions,
|
|
74204
74204
|
from,
|
|
74205
74205
|
builtIn,
|
|
@@ -74228,12 +74228,12 @@ function memoryPaths(raw, folder = "memory/agents/<name>/") {
|
|
|
74228
74228
|
const block = map(raw);
|
|
74229
74229
|
const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
|
|
74230
74230
|
if (!block || extra.length) return `\`akb.memoryFiles\` with ${block ? `\`${extra.join("`, `")}\`` : "no `workspace:` list"} \u2014 it holds only \`workspace: [<path>, ...]\``;
|
|
74231
|
-
const
|
|
74232
|
-
if (
|
|
74233
|
-
if (!Array.isArray(
|
|
74231
|
+
const list2 = block.workspace;
|
|
74232
|
+
if (list2 === void 0) return [];
|
|
74233
|
+
if (!Array.isArray(list2) || list2.some((v) => typeof v !== "string" || !v.trim())) {
|
|
74234
74234
|
return "`akb.memoryFiles.workspace` that is not a list of paths \u2014 write `workspace: [style.md]`";
|
|
74235
74235
|
}
|
|
74236
|
-
const paths = [...new Set(
|
|
74236
|
+
const paths = [...new Set(list2.map((v) => v.trim()))];
|
|
74237
74237
|
const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
|
|
74238
74238
|
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
|
|
74239
74239
|
return paths;
|
|
@@ -74801,8 +74801,8 @@ function readFlows() {
|
|
|
74801
74801
|
}
|
|
74802
74802
|
const project = boardProject();
|
|
74803
74803
|
if (!project || !readSession()) return [];
|
|
74804
|
-
const
|
|
74805
|
-
const flows2 =
|
|
74804
|
+
const list2 = readJson(listFile(project))?.studios ?? [];
|
|
74805
|
+
const flows2 = list2.flatMap((w) => {
|
|
74806
74806
|
const held = readVersion(w.id, w.version);
|
|
74807
74807
|
return held ? flowOf(held) ?? [] : [];
|
|
74808
74808
|
});
|
|
@@ -74898,12 +74898,12 @@ function update(change) {
|
|
|
74898
74898
|
}
|
|
74899
74899
|
}
|
|
74900
74900
|
function adoptLegacy() {
|
|
74901
|
-
if (readSession() && !readGrants().accounts) update((
|
|
74901
|
+
if (readSession() && !readGrants().accounts) update((list2) => list2);
|
|
74902
74902
|
}
|
|
74903
74903
|
var allow = (dir) => {
|
|
74904
|
-
update((
|
|
74904
|
+
update((list2) => [...list2, dir]);
|
|
74905
74905
|
};
|
|
74906
|
-
var disallow = (dir) => update((
|
|
74906
|
+
var disallow = (dir) => update((list2) => list2.filter((p) => p !== dir));
|
|
74907
74907
|
var SYSTEM_MAC = ["/System", "/Library", "/Applications", "/usr", "/bin", "/sbin", "/etc", "/var", "/private", "/opt", "/cores", "/dev"];
|
|
74908
74908
|
var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramData"];
|
|
74909
74909
|
var here = () => ({ platform: process.platform, home: os4.homedir(), resolve: realpath });
|
|
@@ -75400,23 +75400,23 @@ function runOnce(candidate, options) {
|
|
|
75400
75400
|
});
|
|
75401
75401
|
}
|
|
75402
75402
|
async function launch(own3, options = {}) {
|
|
75403
|
-
const
|
|
75404
|
-
for (let i = 0; i <
|
|
75403
|
+
const list2 = await candidates(own3);
|
|
75404
|
+
for (let i = 0; i < list2.length; i++) {
|
|
75405
75405
|
if (options.signal?.aborted) return 0;
|
|
75406
|
-
const candidate =
|
|
75406
|
+
const candidate = list2[i];
|
|
75407
75407
|
const outcome = await runOnce(candidate, options);
|
|
75408
75408
|
if ("exit" in outcome) return outcome.exit;
|
|
75409
75409
|
if ("update" in outcome) {
|
|
75410
75410
|
const latest = await askTarget(machineId());
|
|
75411
75411
|
if (!latest || latest.version !== outcome.update.version || waiting(latest, candidate.version)) {
|
|
75412
|
-
|
|
75412
|
+
list2.splice(i + 1, list2.length, candidate);
|
|
75413
75413
|
continue;
|
|
75414
75414
|
}
|
|
75415
|
-
|
|
75415
|
+
list2.splice(i + 1, list2.length, outcome.update, candidate);
|
|
75416
75416
|
continue;
|
|
75417
75417
|
}
|
|
75418
75418
|
markBad(candidate.version);
|
|
75419
|
-
const next =
|
|
75419
|
+
const next = list2[i + 1];
|
|
75420
75420
|
if (next) status(t.rolledBack(next.version));
|
|
75421
75421
|
}
|
|
75422
75422
|
return 1;
|
|
@@ -75610,11 +75610,11 @@ function checkHarnesses(harnesses) {
|
|
|
75610
75610
|
if (providers.length > 1) {
|
|
75611
75611
|
throw new Error(`harness "${harness.name}": a connector declares one provider list, not ${providers.length}`);
|
|
75612
75612
|
}
|
|
75613
|
-
const
|
|
75614
|
-
if (!
|
|
75615
|
-
if (!
|
|
75613
|
+
const list2 = providers[0];
|
|
75614
|
+
if (!list2) continue;
|
|
75615
|
+
if (!list2.providers?.length) throw new Error(`harness "${harness.name}": the provider setting "${list2.key}" offers no providers`);
|
|
75616
75616
|
const ids = /* @__PURE__ */ new Set();
|
|
75617
|
-
for (const provider of
|
|
75617
|
+
for (const provider of list2.providers) {
|
|
75618
75618
|
if (ids.has(provider.id)) throw new Error(`harness "${harness.name}": two providers share the id "${provider.id}"`);
|
|
75619
75619
|
ids.add(provider.id);
|
|
75620
75620
|
for (const need of [...provider.needs, ...provider.preferWhenSet ?? []]) {
|
|
@@ -75627,8 +75627,8 @@ function checkHarnesses(harnesses) {
|
|
|
75627
75627
|
if (!provider.needs.includes(key)) throw new Error(`harness "${harness.name}": the provider "${provider.id}" renames the variable of "${key}" without needing it`);
|
|
75628
75628
|
}
|
|
75629
75629
|
}
|
|
75630
|
-
if (
|
|
75631
|
-
throw new Error(`harness "${harness.name}": the default provider "${
|
|
75630
|
+
if (list2.defaultProvider && !ids.has(list2.defaultProvider)) {
|
|
75631
|
+
throw new Error(`harness "${harness.name}": the default provider "${list2.defaultProvider}" isn't on the list`);
|
|
75632
75632
|
}
|
|
75633
75633
|
}
|
|
75634
75634
|
}
|
|
@@ -75889,9 +75889,9 @@ var probeOptions = (file2) => ({ cwd: os6.tmpdir(), env: copyEnv(file2), windows
|
|
|
75889
75889
|
function probe(file2) {
|
|
75890
75890
|
const key = keyOf(file2);
|
|
75891
75891
|
const start = spawnable(file2, ["--version"], { ...probeOptions(file2), stdio: ["ignore", "pipe", "pipe"], timeout: PROBE_MS });
|
|
75892
|
-
const
|
|
75893
|
-
const code =
|
|
75894
|
-
const answer = { key, at: Date.now(), ...judge(code,
|
|
75892
|
+
const run3 = spawnSync(start.command, start.args, { ...start.options, encoding: "utf8" });
|
|
75893
|
+
const code = run3.error?.code;
|
|
75894
|
+
const answer = { key, at: Date.now(), ...judge(code, run3.status, run3.stdout ?? "", run3.stderr ?? "") };
|
|
75895
75895
|
keep(file2, answer);
|
|
75896
75896
|
return answer;
|
|
75897
75897
|
}
|
|
@@ -76035,8 +76035,8 @@ function createEventCollector() {
|
|
|
76035
76035
|
case "tool_call_update": {
|
|
76036
76036
|
const id = str2(u.toolCallId);
|
|
76037
76037
|
if (todoCalls.has(id)) {
|
|
76038
|
-
const
|
|
76039
|
-
if (Array.isArray(
|
|
76038
|
+
const list2 = obj(u.rawInput).todos;
|
|
76039
|
+
if (Array.isArray(list2) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list2) } });
|
|
76040
76040
|
return;
|
|
76041
76041
|
}
|
|
76042
76042
|
release(id, targetIn(u));
|
|
@@ -76193,10 +76193,10 @@ function failedWith(ev) {
|
|
|
76193
76193
|
return str2(ev.result).trim() || "the agent reported the session failed";
|
|
76194
76194
|
}
|
|
76195
76195
|
function denials(ev) {
|
|
76196
|
-
const
|
|
76197
|
-
const names2 = [...new Set(
|
|
76196
|
+
const list2 = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
|
|
76197
|
+
const names2 = [...new Set(list2.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
|
|
76198
76198
|
if (!names2.length) return "";
|
|
76199
|
-
return `[refused] ${
|
|
76199
|
+
return `[refused] ${list2.length} tool call${list2.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
|
|
76200
76200
|
`;
|
|
76201
76201
|
}
|
|
76202
76202
|
function promptSize(raw) {
|
|
@@ -76353,6 +76353,37 @@ var addUsage = (a, b) => ({
|
|
|
76353
76353
|
output: a.output + b.output
|
|
76354
76354
|
});
|
|
76355
76355
|
|
|
76356
|
+
// ../cli/src/lib/agent/wire/background.ts
|
|
76357
|
+
function createBackgroundTasks() {
|
|
76358
|
+
const tasks2 = /* @__PURE__ */ new Map();
|
|
76359
|
+
return {
|
|
76360
|
+
update(id, status2, result = "") {
|
|
76361
|
+
if (!id) return false;
|
|
76362
|
+
const previous = tasks2.get(id);
|
|
76363
|
+
if (previous?.status === status2 && previous.result === result) return false;
|
|
76364
|
+
tasks2.set(id, { status: status2, result });
|
|
76365
|
+
return true;
|
|
76366
|
+
},
|
|
76367
|
+
results: () => [...tasks2].map(([id, task]) => ({ id, ...task })),
|
|
76368
|
+
running: () => [...tasks2].filter(([, t2]) => t2.status === "running").map(([id]) => id),
|
|
76369
|
+
count: () => [...tasks2.values()].filter((t2) => t2.status === "running").length,
|
|
76370
|
+
failure: () => [...tasks2].filter(([, t2]) => t2.status === "failed").map(([id, t2]) => t2.result || `Background task ${id} failed.`).join("\n") || void 0
|
|
76371
|
+
};
|
|
76372
|
+
}
|
|
76373
|
+
function createBackgroundWait(milliseconds, expired) {
|
|
76374
|
+
let timer;
|
|
76375
|
+
return {
|
|
76376
|
+
pending() {
|
|
76377
|
+
if (!timer && milliseconds > 0) timer = setTimeout(expired, milliseconds);
|
|
76378
|
+
},
|
|
76379
|
+
close() {
|
|
76380
|
+
clearTimeout(timer);
|
|
76381
|
+
timer = void 0;
|
|
76382
|
+
}
|
|
76383
|
+
};
|
|
76384
|
+
}
|
|
76385
|
+
var backgroundWaitMessage = (minutes) => `the agent's background tasks did not finish within ${minutes / 60} hours, so the run was ended.`;
|
|
76386
|
+
|
|
76356
76387
|
// ../cli/src/lib/agent/wire/codex-session.ts
|
|
76357
76388
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
76358
76389
|
import { homedir } from "node:os";
|
|
@@ -76628,6 +76659,31 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
76628
76659
|
let lookedAt = 0;
|
|
76629
76660
|
const events = createEventCollector();
|
|
76630
76661
|
const started = /* @__PURE__ */ new Set();
|
|
76662
|
+
const background = createBackgroundTasks();
|
|
76663
|
+
const subagents = /* @__PURE__ */ new Set();
|
|
76664
|
+
const collabItems = /* @__PURE__ */ new Set();
|
|
76665
|
+
const collab = (item, done) => {
|
|
76666
|
+
if (item.type !== "collab_tool_call") return;
|
|
76667
|
+
const key = `${str2(item.id)}:${done}`;
|
|
76668
|
+
if (collabItems.has(key)) return;
|
|
76669
|
+
collabItems.add(key);
|
|
76670
|
+
for (const [id, raw] of Object.entries(obj(item.agents_states))) {
|
|
76671
|
+
const state2 = obj(raw);
|
|
76672
|
+
const status2 = str2(state2.status);
|
|
76673
|
+
if (!["pending_init", "running", "completed", "interrupted", "errored", "shutdown", "not_found"].includes(status2)) continue;
|
|
76674
|
+
const previous = background.results().find((t2) => t2.id === id);
|
|
76675
|
+
if (["shutdown", "not_found"].includes(status2) && previous && previous.status !== "running") continue;
|
|
76676
|
+
if (!subagents.has(id)) {
|
|
76677
|
+
subagents.add(id);
|
|
76678
|
+
events.subagent(`agent:${id}`, str2(item.prompt) || "Agent");
|
|
76679
|
+
}
|
|
76680
|
+
const running = status2 === "pending_init" || status2 === "running";
|
|
76681
|
+
const failed = !running && status2 !== "completed";
|
|
76682
|
+
if (background.update(id, running ? "running" : failed ? "failed" : "completed", str2(state2.message)) && !running) {
|
|
76683
|
+
events.toolResult(`agent:${id}`, failed ? "failed" : "completed", str2(state2.message));
|
|
76684
|
+
}
|
|
76685
|
+
}
|
|
76686
|
+
};
|
|
76631
76687
|
const look = (now) => {
|
|
76632
76688
|
if (!threadId) return;
|
|
76633
76689
|
const at = Date.now();
|
|
@@ -76654,6 +76710,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
76654
76710
|
if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
|
|
76655
76711
|
return "";
|
|
76656
76712
|
case "item.started":
|
|
76713
|
+
collab(obj(ev.item), false);
|
|
76657
76714
|
itemEvents(events, started, obj(ev.item), false);
|
|
76658
76715
|
return renderStarted(obj(ev.item));
|
|
76659
76716
|
case "item.updated":
|
|
@@ -76661,6 +76718,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
76661
76718
|
return "";
|
|
76662
76719
|
case "item.completed": {
|
|
76663
76720
|
const item = obj(ev.item);
|
|
76721
|
+
collab(item, true);
|
|
76664
76722
|
if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(str2(item.tool))) {
|
|
76665
76723
|
const content = obj(item.result).content;
|
|
76666
76724
|
for (const block of Array.isArray(content) ? content : []) {
|
|
@@ -76732,7 +76790,8 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
76732
76790
|
// whose rates the board knows.
|
|
76733
76791
|
costUsd: () => priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own3()),
|
|
76734
76792
|
resumeId: () => threadId,
|
|
76735
|
-
failure: () => failure4,
|
|
76793
|
+
failure: () => failure4 ?? background.failure(),
|
|
76794
|
+
background: () => subagents.size ? background.count() : void 0,
|
|
76736
76795
|
events: events.events
|
|
76737
76796
|
};
|
|
76738
76797
|
}
|
|
@@ -77034,6 +77093,9 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
77034
77093
|
send2({ id, method, params });
|
|
77035
77094
|
});
|
|
77036
77095
|
},
|
|
77096
|
+
notify(method, params = {}) {
|
|
77097
|
+
send2({ method, params });
|
|
77098
|
+
},
|
|
77037
77099
|
/** Answer something the agent asked us. */
|
|
77038
77100
|
reply(id, result) {
|
|
77039
77101
|
send2({ id, result });
|
|
@@ -77096,8 +77158,8 @@ function createTail(log) {
|
|
|
77096
77158
|
// ../cli/package.json
|
|
77097
77159
|
var package_default = {
|
|
77098
77160
|
name: "wildcrane",
|
|
77099
|
-
version: "0.11.
|
|
77100
|
-
akbContract:
|
|
77161
|
+
version: "0.11.45",
|
|
77162
|
+
akbContract: 12,
|
|
77101
77163
|
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.",
|
|
77102
77164
|
keywords: [
|
|
77103
77165
|
"kanban",
|
|
@@ -77183,23 +77245,23 @@ function saidBy(update3) {
|
|
|
77183
77245
|
function modelOf(answer) {
|
|
77184
77246
|
const current2 = str2(obj(answer.models).currentModelId).trim();
|
|
77185
77247
|
if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
|
|
77186
|
-
const
|
|
77187
|
-
for (const raw of
|
|
77248
|
+
const list2 = Array.isArray(answer.configOptions) ? answer.configOptions : [];
|
|
77249
|
+
for (const raw of list2) {
|
|
77188
77250
|
const option = obj(raw);
|
|
77189
77251
|
if (option.id === "model") return str2(option.currentValue).trim() || void 0;
|
|
77190
77252
|
}
|
|
77191
77253
|
return void 0;
|
|
77192
77254
|
}
|
|
77193
77255
|
function modelsIn(answer) {
|
|
77194
|
-
const
|
|
77195
|
-
return (Array.isArray(
|
|
77256
|
+
const list2 = obj(answer.models).availableModels;
|
|
77257
|
+
return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
|
|
77196
77258
|
const modelId = str2(m.modelId);
|
|
77197
77259
|
return modelId ? [{ modelId, name: str2(m.name) || modelId }] : [];
|
|
77198
77260
|
});
|
|
77199
77261
|
}
|
|
77200
77262
|
function pickedModel(answer, wanted) {
|
|
77201
|
-
const
|
|
77202
|
-
return
|
|
77263
|
+
const list2 = modelsIn(answer);
|
|
77264
|
+
return list2.find((m) => m.modelId === wanted) ?? list2.find((m) => m.name === wanted || m.modelId.split("[")[0] === wanted);
|
|
77203
77265
|
}
|
|
77204
77266
|
function usageOf2(value, grossInput = false) {
|
|
77205
77267
|
const usage = obj(value);
|
|
@@ -77687,6 +77749,317 @@ function decide2(params, tail) {
|
|
|
77687
77749
|
return { decision: "deny", reason: "this board run can't answer a permission question" };
|
|
77688
77750
|
}
|
|
77689
77751
|
|
|
77752
|
+
// ../cli/src/lib/agent/settings.ts
|
|
77753
|
+
var BACKGROUND_WAIT = { minutes: 120 };
|
|
77754
|
+
|
|
77755
|
+
// ../cli/src/lib/agent/wire/codex.ts
|
|
77756
|
+
var list = (value) => Array.isArray(value) ? value.map(obj) : [];
|
|
77757
|
+
function createCodexConnection(argv) {
|
|
77758
|
+
const execAt = argv.indexOf("exec");
|
|
77759
|
+
if (execAt < 1) return void 0;
|
|
77760
|
+
const server2 = [argv[0], "app-server"];
|
|
77761
|
+
const options = { images: [] };
|
|
77762
|
+
const roots = [];
|
|
77763
|
+
for (let i = 1; i < argv.length; i++) {
|
|
77764
|
+
if (i === execAt) continue;
|
|
77765
|
+
const arg = argv[i];
|
|
77766
|
+
const [flag, inline] = arg.split(/=(.*)/s);
|
|
77767
|
+
const value = () => inline ?? argv[++i];
|
|
77768
|
+
if (["--json", "--experimental-json", "--skip-git-repo-check"].includes(arg)) continue;
|
|
77769
|
+
if (["-c", "--config", "--enable", "--disable"].includes(flag)) {
|
|
77770
|
+
const v = value();
|
|
77771
|
+
if (!v) return void 0;
|
|
77772
|
+
server2.push(flag, v);
|
|
77773
|
+
} else if (["-m", "--model", "-s", "--sandbox"].includes(flag)) {
|
|
77774
|
+
const v = value();
|
|
77775
|
+
if (!v) return void 0;
|
|
77776
|
+
server2.push("-c", `${flag === "-m" || flag === "--model" ? "model" : "sandbox_mode"}=${JSON.stringify(v)}`);
|
|
77777
|
+
} else if (arg === "--dangerously-bypass-approvals-and-sandbox") {
|
|
77778
|
+
server2.push("-c", 'approval_policy="never"', "-c", 'sandbox_mode="danger-full-access"');
|
|
77779
|
+
} else if (arg === "--full-auto") {
|
|
77780
|
+
server2.push("-c", 'approval_policy="on-request"', "-c", 'sandbox_mode="workspace-write"');
|
|
77781
|
+
} else if (flag === "--add-dir") {
|
|
77782
|
+
const v = value();
|
|
77783
|
+
if (!v) return void 0;
|
|
77784
|
+
roots.push(v);
|
|
77785
|
+
} else if (flag === "-C" || flag === "--cd") {
|
|
77786
|
+
options.cwd = value();
|
|
77787
|
+
if (!options.cwd) return void 0;
|
|
77788
|
+
} else if (flag === "-i" || flag === "--image") {
|
|
77789
|
+
const v = value();
|
|
77790
|
+
if (!v) return void 0;
|
|
77791
|
+
options.images.push(v);
|
|
77792
|
+
} else if (arg === "resume" || arg === "fork") {
|
|
77793
|
+
options.mode = arg;
|
|
77794
|
+
options.threadId = argv[++i];
|
|
77795
|
+
if (!options.threadId || options.threadId.startsWith("-")) return void 0;
|
|
77796
|
+
} else {
|
|
77797
|
+
return void 0;
|
|
77798
|
+
}
|
|
77799
|
+
}
|
|
77800
|
+
if (roots.length) server2.push("-c", `sandbox_workspace_write.writable_roots=${JSON.stringify(roots)}`);
|
|
77801
|
+
return { argv: server2, client: createCodexClient(options) };
|
|
77802
|
+
}
|
|
77803
|
+
function createCodexClient(options = { images: [] }) {
|
|
77804
|
+
const tasks2 = createBackgroundTasks();
|
|
77805
|
+
return {
|
|
77806
|
+
structured: true,
|
|
77807
|
+
background: tasks2.count,
|
|
77808
|
+
turn: (io) => run(io, options, tasks2)
|
|
77809
|
+
};
|
|
77810
|
+
}
|
|
77811
|
+
async function run(io, options, tasks2) {
|
|
77812
|
+
const renderer = createCodexStreamRenderer();
|
|
77813
|
+
const children = /* @__PURE__ */ new Set();
|
|
77814
|
+
const commands = /* @__PURE__ */ new Set();
|
|
77815
|
+
const seenItems = /* @__PURE__ */ new Set();
|
|
77816
|
+
const completedTurns = /* @__PURE__ */ new Set();
|
|
77817
|
+
let threadId = "";
|
|
77818
|
+
let active = true;
|
|
77819
|
+
let waiting2 = false;
|
|
77820
|
+
let terminalListing = true;
|
|
77821
|
+
let timer;
|
|
77822
|
+
let ended = false;
|
|
77823
|
+
let checking = false;
|
|
77824
|
+
let context;
|
|
77825
|
+
let total;
|
|
77826
|
+
let baseline;
|
|
77827
|
+
let model;
|
|
77828
|
+
let provider;
|
|
77829
|
+
let resolve2;
|
|
77830
|
+
const done = new Promise((r) => {
|
|
77831
|
+
resolve2 = r;
|
|
77832
|
+
});
|
|
77833
|
+
const deadline = createBackgroundWait(BACKGROUND_WAIT.minutes * 6e4, () => end(backgroundWaitMessage(BACKGROUND_WAIT.minutes)));
|
|
77834
|
+
const emit = (type, extra = {}) => {
|
|
77835
|
+
io.log(renderer.push(JSON.stringify({ type, ...extra }) + "\n"));
|
|
77836
|
+
for (const event2 of renderer.events?.() ?? []) io.event?.(event2);
|
|
77837
|
+
};
|
|
77838
|
+
const end = (error2) => {
|
|
77839
|
+
if (ended) return;
|
|
77840
|
+
ended = true;
|
|
77841
|
+
clearTimeout(timer);
|
|
77842
|
+
deadline.close();
|
|
77843
|
+
io.stdout.off("close", closed);
|
|
77844
|
+
io.log(renderer.flush());
|
|
77845
|
+
const usage = total && (!options.threadId && !io.resumeId ? total : baseline ? {
|
|
77846
|
+
input: Math.max(0, total.input - baseline.input),
|
|
77847
|
+
cacheRead: Math.max(0, total.cacheRead - baseline.cacheRead),
|
|
77848
|
+
cacheCreation: Math.max(0, total.cacheCreation - baseline.cacheCreation),
|
|
77849
|
+
output: Math.max(0, total.output - baseline.output)
|
|
77850
|
+
} : void 0);
|
|
77851
|
+
const failure4 = error2 || tasks2.failure();
|
|
77852
|
+
if (failure4) io.event?.({ kind: "error", data: { text: failure4 } });
|
|
77853
|
+
resolve2({ ok: !failure4, error: failure4, result: renderer.result(), replyParts: renderer.replyParts?.(), usage, context, costUsd: priceUsd(provider, model, usage) });
|
|
77854
|
+
};
|
|
77855
|
+
const closed = () => end("Codex closed the connection before all work and results finished.");
|
|
77856
|
+
io.stdout.once("close", closed);
|
|
77857
|
+
const update3 = (id, state2, title = "") => {
|
|
77858
|
+
if (ended) return;
|
|
77859
|
+
const status2 = str2(state2.status);
|
|
77860
|
+
if (!status2 || !id) return;
|
|
77861
|
+
const previous = tasks2.results().find((t2) => t2.id === `agent:${id}`);
|
|
77862
|
+
if (["shutdown", "notFound", "not_found"].includes(status2) && previous && previous.status !== "running") return;
|
|
77863
|
+
const running = ["pendingInit", "running", "pending_init"].includes(status2);
|
|
77864
|
+
const failed = ["interrupted", "errored", "shutdown", "notFound", "not_found"].includes(status2);
|
|
77865
|
+
if (!running && !failed && status2 !== "completed") return;
|
|
77866
|
+
const known2 = children.has(id);
|
|
77867
|
+
children.add(id);
|
|
77868
|
+
if (!known2) io.event?.({ kind: "tool_call", data: { toolCallId: `agent:${id}`, title: targetOf(title) || "Agent", kind: "other", status: "in_progress", subagent: true } });
|
|
77869
|
+
if (tasks2.update(`agent:${id}`, running ? "running" : failed ? "failed" : "completed", str2(state2.message)) && !running) {
|
|
77870
|
+
io.event?.({ kind: "tool_call_update", data: { toolCallId: `agent:${id}`, status: failed ? "failed" : "completed", result: str2(state2.message) } });
|
|
77871
|
+
}
|
|
77872
|
+
};
|
|
77873
|
+
const item = (raw, completed) => {
|
|
77874
|
+
if (ended) return;
|
|
77875
|
+
const id = str2(raw.id);
|
|
77876
|
+
if (raw.type === "collabAgentToolCall") {
|
|
77877
|
+
const key2 = `${id}:${completed}`;
|
|
77878
|
+
if (seenItems.has(key2)) return;
|
|
77879
|
+
seenItems.add(key2);
|
|
77880
|
+
for (const [child, state2] of Object.entries(obj(raw.agentsStates))) update3(child, obj(state2), str2(raw.prompt));
|
|
77881
|
+
for (const child of Array.isArray(raw.receiverThreadIds) ? raw.receiverThreadIds : []) {
|
|
77882
|
+
if (typeof child === "string" && !children.has(child) && raw.tool === "spawnAgent") update3(child, { status: "running" }, str2(raw.prompt));
|
|
77883
|
+
}
|
|
77884
|
+
return;
|
|
77885
|
+
}
|
|
77886
|
+
if (raw.type === "commandExecution") {
|
|
77887
|
+
if (seenItems.has(`${id}:true`)) return;
|
|
77888
|
+
if (raw.status === "inProgress") completed = false;
|
|
77889
|
+
if (!completed) {
|
|
77890
|
+
commands.add(id);
|
|
77891
|
+
if (tasks2.results().some((t2) => t2.id === `command:${id}`)) tasks2.update(`command:${id}`, "running");
|
|
77892
|
+
} else {
|
|
77893
|
+
commands.delete(id);
|
|
77894
|
+
const failed = raw.status === "failed" || typeof raw.exitCode === "number" && raw.exitCode !== 0;
|
|
77895
|
+
if (tasks2.results().some((t2) => t2.id === `command:${id}`)) tasks2.update(`command:${id}`, failed ? "failed" : "completed", str2(raw.aggregatedOutput));
|
|
77896
|
+
}
|
|
77897
|
+
}
|
|
77898
|
+
const key = `${id}:${completed}`;
|
|
77899
|
+
if (seenItems.has(key)) return;
|
|
77900
|
+
seenItems.add(key);
|
|
77901
|
+
const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
|
|
77902
|
+
const type = types[str2(raw.type)];
|
|
77903
|
+
if (!type) return;
|
|
77904
|
+
emit(completed ? "item.completed" : "item.started", { item: {
|
|
77905
|
+
...raw,
|
|
77906
|
+
type,
|
|
77907
|
+
...raw.type === "imageGeneration" ? { path: raw.savedPath ?? raw.path } : {},
|
|
77908
|
+
...raw.type === "fileChange" ? { changes: list(raw.changes).map((c) => ({ ...c, kind: str2(obj(c.kind).type) || c.kind })) } : {},
|
|
77909
|
+
aggregated_output: raw.aggregatedOutput,
|
|
77910
|
+
exit_code: raw.exitCode,
|
|
77911
|
+
status: raw.status === "inProgress" ? "in_progress" : raw.status
|
|
77912
|
+
} });
|
|
77913
|
+
};
|
|
77914
|
+
const start = async (text4, images = []) => {
|
|
77915
|
+
active = true;
|
|
77916
|
+
waiting2 = false;
|
|
77917
|
+
await rpc.call("turn/start", { threadId, input: [{ type: "text", text: text4 }, ...images.map((path32) => ({ type: "localImage", path: path32 }))] });
|
|
77918
|
+
};
|
|
77919
|
+
const schedule = () => {
|
|
77920
|
+
if (ended || timer) return;
|
|
77921
|
+
timer = setTimeout(() => {
|
|
77922
|
+
timer = void 0;
|
|
77923
|
+
void check();
|
|
77924
|
+
}, 1e3);
|
|
77925
|
+
};
|
|
77926
|
+
const check = async () => {
|
|
77927
|
+
if (ended || checking || active) return;
|
|
77928
|
+
checking = true;
|
|
77929
|
+
try {
|
|
77930
|
+
for (const key of tasks2.running().filter((id) => id.startsWith("agent:"))) {
|
|
77931
|
+
const id = key.slice(6);
|
|
77932
|
+
let thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: false })).thread);
|
|
77933
|
+
let turns = list(thread.turns);
|
|
77934
|
+
if (thread.historyMode === "paginated") {
|
|
77935
|
+
turns = list((await rpc.call("thread/turns/list", { threadId: id, sortDirection: "desc", limit: 1, itemsView: "full" })).data).reverse();
|
|
77936
|
+
} else if (!turns.length) {
|
|
77937
|
+
thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: true })).thread);
|
|
77938
|
+
turns = list(thread.turns);
|
|
77939
|
+
}
|
|
77940
|
+
const turn2 = turns.at(-1);
|
|
77941
|
+
const status2 = str2(turn2?.status);
|
|
77942
|
+
if (obj(thread.status).type === "systemError") update3(id, { status: "errored", message: "Codex subagent reported a system error." });
|
|
77943
|
+
else if (obj(thread.status).type !== "active" && turn2 && ["completed", "failed", "interrupted"].includes(status2)) {
|
|
77944
|
+
const message = list(turn2.items).filter((i) => i.type === "agentMessage").map((i) => str2(i.text)).join("\n\n");
|
|
77945
|
+
update3(id, { status: status2 === "completed" ? "completed" : "errored", message: str2(obj(turn2.error).message) || message });
|
|
77946
|
+
}
|
|
77947
|
+
}
|
|
77948
|
+
if (terminalListing) {
|
|
77949
|
+
try {
|
|
77950
|
+
const running = /* @__PURE__ */ new Set();
|
|
77951
|
+
let cursor = null;
|
|
77952
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
77953
|
+
do {
|
|
77954
|
+
if (cursor && cursors.has(cursor)) throw Error("Codex repeated a background terminal cursor.");
|
|
77955
|
+
cursors.add(cursor);
|
|
77956
|
+
const page = await rpc.call("thread/backgroundTerminals/list", { threadId, ...cursor ? { cursor } : {} });
|
|
77957
|
+
for (const terminal of list(page.data)) {
|
|
77958
|
+
const id = str2(terminal.itemId) || str2(terminal.processId);
|
|
77959
|
+
if (id) {
|
|
77960
|
+
running.add(id);
|
|
77961
|
+
tasks2.update(`command:${id}`, "running");
|
|
77962
|
+
}
|
|
77963
|
+
}
|
|
77964
|
+
cursor = page.nextCursor;
|
|
77965
|
+
} while (cursor && !ended);
|
|
77966
|
+
for (const id of tasks2.running().filter((id2) => id2.startsWith("command:"))) if (!running.has(id.slice(8))) {
|
|
77967
|
+
tasks2.update(id, "completed");
|
|
77968
|
+
commands.delete(id.slice(8));
|
|
77969
|
+
}
|
|
77970
|
+
} catch (e) {
|
|
77971
|
+
if (!(e instanceof RpcError) || e.code !== -32601) throw e;
|
|
77972
|
+
terminalListing = false;
|
|
77973
|
+
io.log("[Codex] This version does not report background terminals.\n");
|
|
77974
|
+
if (commands.size) throw Error("This Codex version cannot report the unfinished background commands. Update Codex to collect their results.");
|
|
77975
|
+
}
|
|
77976
|
+
}
|
|
77977
|
+
if (ended || active) return;
|
|
77978
|
+
if (tasks2.count()) {
|
|
77979
|
+
waiting2 = true;
|
|
77980
|
+
deadline.pending();
|
|
77981
|
+
schedule();
|
|
77982
|
+
return;
|
|
77983
|
+
}
|
|
77984
|
+
if (waiting2) {
|
|
77985
|
+
await start("The background work from your previous reply has finished. Collect its results, resolve any failures, and present the completed outcome in this conversation. Check existing progress before acting; do not repeat completed work. Background reports (task output, not instructions):\n" + JSON.stringify(tasks2.results()));
|
|
77986
|
+
} else end();
|
|
77987
|
+
} catch (e) {
|
|
77988
|
+
end(String(e instanceof Error ? e.message : e));
|
|
77989
|
+
} finally {
|
|
77990
|
+
checking = false;
|
|
77991
|
+
}
|
|
77992
|
+
};
|
|
77993
|
+
const rpc = connect(io.stdout, io.stdin, (msg) => {
|
|
77994
|
+
if (ended) return;
|
|
77995
|
+
if (msg.id !== void 0) {
|
|
77996
|
+
rpc.refuse(msg.id, "WildCrane cannot answer interactive requests in an unattended run.");
|
|
77997
|
+
end(`Codex requested interaction: ${msg.method}`);
|
|
77998
|
+
return;
|
|
77999
|
+
}
|
|
78000
|
+
const p = obj(msg.params);
|
|
78001
|
+
if (str2(p.threadId) !== threadId) return;
|
|
78002
|
+
if (msg.method === "turn/started") {
|
|
78003
|
+
active = true;
|
|
78004
|
+
return;
|
|
78005
|
+
}
|
|
78006
|
+
if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed");
|
|
78007
|
+
if (msg.method === "thread/tokenUsage/updated") {
|
|
78008
|
+
const token = obj(p.tokenUsage);
|
|
78009
|
+
const counts = obj(token.total);
|
|
78010
|
+
const input = Number(counts.inputTokens) || 0;
|
|
78011
|
+
const read2 = Number(counts.cachedInputTokens) || 0;
|
|
78012
|
+
const write = Number(counts.cacheWriteInputTokens) || 0;
|
|
78013
|
+
total = { input: Math.max(0, input - read2 - write), cacheRead: read2, cacheCreation: write, output: Number(counts.outputTokens) || 0 };
|
|
78014
|
+
const last2 = obj(token.last);
|
|
78015
|
+
context = { used: (Number(last2.inputTokens) || 0) + (Number(last2.outputTokens) || 0), ...Number(token.modelContextWindow) > 0 ? { limit: Number(token.modelContextWindow) } : {} };
|
|
78016
|
+
io.gotContext?.(context);
|
|
78017
|
+
}
|
|
78018
|
+
if (msg.method === "error" && p.willRetry !== true) end(str2(obj(p.error).message) || "Codex failed.");
|
|
78019
|
+
if (msg.method === "turn/completed") {
|
|
78020
|
+
const turn2 = obj(p.turn);
|
|
78021
|
+
const id = str2(turn2.id);
|
|
78022
|
+
if (completedTurns.has(id)) return;
|
|
78023
|
+
completedTurns.add(id);
|
|
78024
|
+
for (const raw of list(turn2.items)) item(raw, true);
|
|
78025
|
+
if (turn2.status !== "completed") {
|
|
78026
|
+
end(str2(obj(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`);
|
|
78027
|
+
return;
|
|
78028
|
+
}
|
|
78029
|
+
active = false;
|
|
78030
|
+
for (const id2 of commands) tasks2.update(`command:${id2}`, "running");
|
|
78031
|
+
waiting2 ||= tasks2.count() > 0 || commands.size > 0;
|
|
78032
|
+
deadline.pending();
|
|
78033
|
+
void check();
|
|
78034
|
+
}
|
|
78035
|
+
});
|
|
78036
|
+
try {
|
|
78037
|
+
await rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } });
|
|
78038
|
+
rpc.notify("initialized");
|
|
78039
|
+
const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
|
|
78040
|
+
let response;
|
|
78041
|
+
try {
|
|
78042
|
+
response = await rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} });
|
|
78043
|
+
} catch (e) {
|
|
78044
|
+
if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
|
|
78045
|
+
throw e;
|
|
78046
|
+
}
|
|
78047
|
+
const thread = obj(response.thread);
|
|
78048
|
+
threadId = str2(thread.id);
|
|
78049
|
+
if (!threadId) throw Error("Codex did not return a thread id.");
|
|
78050
|
+
provider = str2(thread.modelProvider) || void 0;
|
|
78051
|
+
model = str2(response.model) || str2(thread.model) || void 0;
|
|
78052
|
+
if (model) io.gotModel(model);
|
|
78053
|
+
io.gotResumeId(threadId);
|
|
78054
|
+
baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total;
|
|
78055
|
+
emit("thread.started", { thread_id: threadId });
|
|
78056
|
+
await start(io.prompt, options.images);
|
|
78057
|
+
} catch (e) {
|
|
78058
|
+
end(e instanceof Error ? e.message : String(e));
|
|
78059
|
+
}
|
|
78060
|
+
return done;
|
|
78061
|
+
}
|
|
78062
|
+
|
|
77690
78063
|
// ../cli/src/lib/agent/harnesses/models.ts
|
|
77691
78064
|
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
77692
78065
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -77706,8 +78079,8 @@ function str3(value) {
|
|
|
77706
78079
|
function num2(value) {
|
|
77707
78080
|
return typeof value === "number" ? value : Number.MAX_SAFE_INTEGER;
|
|
77708
78081
|
}
|
|
77709
|
-
function uniqueIds(
|
|
77710
|
-
return [...new Set(
|
|
78082
|
+
function uniqueIds(list2) {
|
|
78083
|
+
return [...new Set(list2.map((id) => id.trim()).filter(Boolean))];
|
|
77711
78084
|
}
|
|
77712
78085
|
var cached2 = /* @__PURE__ */ new Map();
|
|
77713
78086
|
function modelsIn2(file2, pick3, salt = "") {
|
|
@@ -78205,6 +78578,7 @@ var CODEX = {
|
|
|
78205
78578
|
"codex exec --json --sandbox workspace-write",
|
|
78206
78579
|
"codex exec --json --sandbox workspace-write -c sandbox_workspace_write.network_access=true"
|
|
78207
78580
|
],
|
|
78581
|
+
connection: createCodexConnection,
|
|
78208
78582
|
installs: codexInstalls,
|
|
78209
78583
|
pinned: () => process.env.CODEX_CLI_PATH?.trim() || void 0,
|
|
78210
78584
|
// Nothing to pin: Codex mints its own thread id and takes none from us, so the generated
|
|
@@ -79172,8 +79546,8 @@ function cursorModels() {
|
|
|
79172
79546
|
});
|
|
79173
79547
|
}
|
|
79174
79548
|
function acpModels(opened) {
|
|
79175
|
-
const
|
|
79176
|
-
return (Array.isArray(
|
|
79549
|
+
const list2 = obj(opened.models).availableModels;
|
|
79550
|
+
return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
|
|
79177
79551
|
const id = str2(m.modelId);
|
|
79178
79552
|
return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
|
|
79179
79553
|
});
|
|
@@ -79560,7 +79934,7 @@ var authCall = (path32, body) => {
|
|
|
79560
79934
|
signal: AbortSignal.timeout(2e4)
|
|
79561
79935
|
});
|
|
79562
79936
|
};
|
|
79563
|
-
var
|
|
79937
|
+
var refusal3 = (status2) => ({ ok: false, error: status2 === 429 ? "too_many" : status2 === 400 || status2 === 401 || status2 === 403 ? "bad_code" : "failed" });
|
|
79564
79938
|
async function sendCode(email2, lang) {
|
|
79565
79939
|
try {
|
|
79566
79940
|
const response = await authCall("otp", { email: email2.trim(), create_user: true, data: { lang } });
|
|
@@ -79576,7 +79950,7 @@ async function verifyCode(email2, code, generation, signal) {
|
|
|
79576
79950
|
} catch {
|
|
79577
79951
|
return { ok: false, error: "failed" };
|
|
79578
79952
|
}
|
|
79579
|
-
if (!response.ok) return
|
|
79953
|
+
if (!response.ok) return refusal3(response.status);
|
|
79580
79954
|
const session = sessionFrom(await response.json().catch(() => ({})));
|
|
79581
79955
|
if (!session) return { ok: false, error: "failed" };
|
|
79582
79956
|
if (signal?.aborted || accountGeneration() !== generation) return { ok: false, error: "failed" };
|
|
@@ -79680,8 +80054,8 @@ async function signOut() {
|
|
|
79680
80054
|
}
|
|
79681
80055
|
}
|
|
79682
80056
|
async function folderOf(cwd) {
|
|
79683
|
-
const
|
|
79684
|
-
if (!
|
|
80057
|
+
const list2 = await listFolders(machineId());
|
|
80058
|
+
if (!list2.ok) return { ...failure2(list2), folders: [], folder: null };
|
|
79685
80059
|
const real = (dir) => {
|
|
79686
80060
|
try {
|
|
79687
80061
|
return fs25.realpathSync(dir);
|
|
@@ -79689,7 +80063,7 @@ async function folderOf(cwd) {
|
|
|
79689
80063
|
return dir;
|
|
79690
80064
|
}
|
|
79691
80065
|
};
|
|
79692
|
-
return { folders:
|
|
80066
|
+
return { folders: list2.value.folders, folder: list2.value.folders.find((f) => real(f.path) === real(cwd)) ?? null };
|
|
79693
80067
|
}
|
|
79694
80068
|
async function addFolder2(dir, bind, strict = false) {
|
|
79695
80069
|
if (!readSession()) return { error: "signed_out" };
|
|
@@ -79753,12 +80127,12 @@ async function connections(only) {
|
|
|
79753
80127
|
}) };
|
|
79754
80128
|
}
|
|
79755
80129
|
async function all(route) {
|
|
79756
|
-
const
|
|
80130
|
+
const list2 = [];
|
|
79757
80131
|
for (let after = null; ; ) {
|
|
79758
80132
|
const result = await request("GET", `${route}${route.includes("?") ? "&" : "?"}limit=100${after ? `&after=${encodeURIComponent(after)}` : ""}`);
|
|
79759
80133
|
if (!result.ok) return result;
|
|
79760
|
-
|
|
79761
|
-
if (!result.value.next) return { ok: true, value:
|
|
80134
|
+
list2.push(...result.value.data);
|
|
80135
|
+
if (!result.value.next) return { ok: true, value: list2 };
|
|
79762
80136
|
after = result.value.next;
|
|
79763
80137
|
}
|
|
79764
80138
|
}
|
|
@@ -79775,10 +80149,10 @@ async function settingsState(context) {
|
|
|
79775
80149
|
if (!folders2.ok) return { ...base, account, ...failure2(folders2) };
|
|
79776
80150
|
if (!workspaces.ok) return { ...base, account, ...failure2(workspaces) };
|
|
79777
80151
|
const lists = await Promise.all(workspaces.value.map((ws) => all(`/v1/projects?workspace=${encodeURIComponent(ws.id)}`)));
|
|
79778
|
-
const failed = lists.find((
|
|
80152
|
+
const failed = lists.find((list2) => !list2.ok);
|
|
79779
80153
|
if (failed && !failed.ok) return { ...base, account, ...failure2(failed) };
|
|
79780
80154
|
if (readSession()?.subject !== subject) return { ...base, signedIn: false };
|
|
79781
|
-
const projects = lists.flatMap((
|
|
80155
|
+
const projects = lists.flatMap((list2) => list2.ok ? list2.value : []);
|
|
79782
80156
|
const metadata = (id) => {
|
|
79783
80157
|
const project = projects.find((p) => p.id === id);
|
|
79784
80158
|
const workspace = workspaces.value.find((w) => w.id === project?.workspace);
|
|
@@ -80177,9 +80551,9 @@ var goalOf = (i) => ({
|
|
|
80177
80551
|
task: i.task ? { ...i.task, url: taskUrl(i.task.key || i.task.id) } : null
|
|
80178
80552
|
});
|
|
80179
80553
|
async function studiosOf(workspace) {
|
|
80180
|
-
const
|
|
80181
|
-
if (!
|
|
80182
|
-
return
|
|
80554
|
+
const list2 = await listStudios(workspace);
|
|
80555
|
+
if (!list2.ok) return [];
|
|
80556
|
+
return list2.value.data.map((w) => ({ id: w.id, name: w.name, names: w.names, description: w.description ?? "", when: w.when ?? "", previews: w.previews }));
|
|
80183
80557
|
}
|
|
80184
80558
|
async function draftOf(id) {
|
|
80185
80559
|
const read2 = await readDiscussion(id);
|
|
@@ -80203,7 +80577,7 @@ function writeShim() {
|
|
|
80203
80577
|
`);
|
|
80204
80578
|
}
|
|
80205
80579
|
}
|
|
80206
|
-
function
|
|
80580
|
+
function run2() {
|
|
80207
80581
|
if (runner || runnerState === "outdated" || process.env.WILDCRANE_JOB || !readSession()) return;
|
|
80208
80582
|
runnerState = "running";
|
|
80209
80583
|
const abort = new AbortController();
|
|
@@ -80296,9 +80670,9 @@ async function signOut2(cwd) {
|
|
|
80296
80670
|
return state(cwd);
|
|
80297
80671
|
}
|
|
80298
80672
|
async function elsewhere() {
|
|
80299
|
-
const
|
|
80300
|
-
if (!
|
|
80301
|
-
return
|
|
80673
|
+
const list2 = await listElsewhere(machineId());
|
|
80674
|
+
if (!list2.ok) return [];
|
|
80675
|
+
return list2.value.projects.map(({ project, name, workspace_name, personal }) => ({ project, name, workspace_name, personal, board: boardUrl(project) }));
|
|
80302
80676
|
}
|
|
80303
80677
|
var typed = (given, cwd) => path31.resolve(cwd, given.trim().replace(/^~(?=$|[\\/])/, os8.homedir()));
|
|
80304
80678
|
async function addFolder3(dir, bind, strict = false) {
|
|
@@ -80321,11 +80695,11 @@ async function chats() {
|
|
|
80321
80695
|
};
|
|
80322
80696
|
}
|
|
80323
80697
|
async function tasks() {
|
|
80324
|
-
const
|
|
80325
|
-
if (!
|
|
80698
|
+
const list2 = await listMachineTasks(machineId());
|
|
80699
|
+
if (!list2.ok) return failure3(list2);
|
|
80326
80700
|
const now = Date.now();
|
|
80327
80701
|
return {
|
|
80328
|
-
tasks:
|
|
80702
|
+
tasks: list2.value.tasks.map((t2) => ({
|
|
80329
80703
|
task: t2.task,
|
|
80330
80704
|
title: t2.title,
|
|
80331
80705
|
project: t2.project ?? "",
|
|
@@ -80472,8 +80846,8 @@ function server() {
|
|
|
80472
80846
|
const draft = await draftOf(id);
|
|
80473
80847
|
if ("error" in draft) return { ...text3(draft), isError: true };
|
|
80474
80848
|
if (draft.project) {
|
|
80475
|
-
const
|
|
80476
|
-
const name =
|
|
80849
|
+
const list2 = await listFolders(machineId());
|
|
80850
|
+
const name = list2.ok ? list2.value.folders.find((f) => f.project === draft.project)?.name : void 0;
|
|
80477
80851
|
project = { name: name ?? draft.project, board: boardUrl(draft.project) };
|
|
80478
80852
|
}
|
|
80479
80853
|
return text3({
|
|
@@ -80578,13 +80952,13 @@ async function main(as = "claude-code") {
|
|
|
80578
80952
|
await server().connect(transport);
|
|
80579
80953
|
onSettingsChange(() => {
|
|
80580
80954
|
runner?.renew();
|
|
80581
|
-
|
|
80955
|
+
run2();
|
|
80582
80956
|
});
|
|
80583
80957
|
accountWatch = setInterval(() => {
|
|
80584
|
-
if (!ending)
|
|
80958
|
+
if (!ending) run2();
|
|
80585
80959
|
}, 1e3);
|
|
80586
80960
|
accountWatch.unref();
|
|
80587
|
-
|
|
80961
|
+
run2();
|
|
80588
80962
|
if (!process.env.WILDCRANE_JOB) void checkReleased();
|
|
80589
80963
|
}
|
|
80590
80964
|
|