wildcrane-runner 0.6.78 → 0.6.80
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/README.md +5 -1
- package/dist/akb/dist/kanban.mjs +92 -142
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +1082 -680
- package/dist/{codex-service-main.mjs → codex-retained.mjs} +402 -2499
- package/dist/flow-worker-main.mjs +403 -428
- package/dist/launcher.mjs +849 -813
- package/dist/plugin.mjs +1115 -1079
- package/dist/runner.mjs +1091 -921
- package/dist/settings.mjs +1042 -1006
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.80 — 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;
|
|
@@ -9863,7 +9863,7 @@ var require_agent = __commonJS({
|
|
|
9863
9863
|
function defaultFactory(origin, opts) {
|
|
9864
9864
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
|
9865
9865
|
}
|
|
9866
|
-
var
|
|
9866
|
+
var Agent2 = class extends DispatcherBase {
|
|
9867
9867
|
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect2, tls, ...options } = {}) {
|
|
9868
9868
|
if (typeof factory !== "function") {
|
|
9869
9869
|
throw new InvalidArgumentError("factory must be a function.");
|
|
@@ -9975,7 +9975,7 @@ var require_agent = __commonJS({
|
|
|
9975
9975
|
return allClientStats;
|
|
9976
9976
|
}
|
|
9977
9977
|
};
|
|
9978
|
-
module.exports =
|
|
9978
|
+
module.exports = Agent2;
|
|
9979
9979
|
}
|
|
9980
9980
|
});
|
|
9981
9981
|
|
|
@@ -10681,7 +10681,7 @@ var require_proxy_agent = __commonJS({
|
|
|
10681
10681
|
"node_modules/undici/lib/dispatcher/proxy-agent.js"(exports, module) {
|
|
10682
10682
|
"use strict";
|
|
10683
10683
|
var { kProxy, kClose, kDestroy, kDispatch } = require_symbols();
|
|
10684
|
-
var
|
|
10684
|
+
var Agent2 = require_agent();
|
|
10685
10685
|
var Pool = require_pool();
|
|
10686
10686
|
var DispatcherBase = require_dispatcher_base();
|
|
10687
10687
|
var { InvalidArgumentError, RequestAbortedError, SecureProxyConnectionError } = require_errors();
|
|
@@ -10812,7 +10812,7 @@ var require_proxy_agent = __commonJS({
|
|
|
10812
10812
|
} else {
|
|
10813
10813
|
this[kClient] = clientFactory(url, { connect: connect2 });
|
|
10814
10814
|
}
|
|
10815
|
-
this[kAgent] = new
|
|
10815
|
+
this[kAgent] = new Agent2({
|
|
10816
10816
|
...opts,
|
|
10817
10817
|
factory,
|
|
10818
10818
|
connect: async (opts2, callback) => {
|
|
@@ -10940,7 +10940,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
10940
10940
|
var DispatcherBase = require_dispatcher_base();
|
|
10941
10941
|
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
|
|
10942
10942
|
var ProxyAgent = require_proxy_agent();
|
|
10943
|
-
var
|
|
10943
|
+
var Agent2 = require_agent();
|
|
10944
10944
|
var DEFAULT_PORTS = {
|
|
10945
10945
|
"http:": 80,
|
|
10946
10946
|
"https:": 443
|
|
@@ -10953,7 +10953,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
10953
10953
|
super();
|
|
10954
10954
|
this.#opts = opts;
|
|
10955
10955
|
const { httpProxy, httpsProxy, noProxy, ...agentOpts } = opts;
|
|
10956
|
-
this[kNoProxyAgent] = new
|
|
10956
|
+
this[kNoProxyAgent] = new Agent2(agentOpts);
|
|
10957
10957
|
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
|
|
10958
10958
|
if (HTTP_PROXY) {
|
|
10959
10959
|
this[kHttpProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTP_PROXY });
|
|
@@ -13702,7 +13702,7 @@ var require_mock_agent = __commonJS({
|
|
|
13702
13702
|
"node_modules/undici/lib/mock/mock-agent.js"(exports, module) {
|
|
13703
13703
|
"use strict";
|
|
13704
13704
|
var { kClients } = require_symbols();
|
|
13705
|
-
var
|
|
13705
|
+
var Agent2 = require_agent();
|
|
13706
13706
|
var {
|
|
13707
13707
|
kAgent,
|
|
13708
13708
|
kMockAgentSet,
|
|
@@ -13740,7 +13740,7 @@ var require_mock_agent = __commonJS({
|
|
|
13740
13740
|
if (opts?.agent && typeof opts.agent.dispatch !== "function") {
|
|
13741
13741
|
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
13742
13742
|
}
|
|
13743
|
-
const agent = opts?.agent ? opts.agent : new
|
|
13743
|
+
const agent = opts?.agent ? opts.agent : new Agent2(opts);
|
|
13744
13744
|
this[kAgent] = agent;
|
|
13745
13745
|
this[kClients] = agent[kClients];
|
|
13746
13746
|
this[kOptions] = mockOptions;
|
|
@@ -14347,7 +14347,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
14347
14347
|
var require_snapshot_agent = __commonJS({
|
|
14348
14348
|
"node_modules/undici/lib/mock/snapshot-agent.js"(exports, module) {
|
|
14349
14349
|
"use strict";
|
|
14350
|
-
var
|
|
14350
|
+
var Agent2 = require_agent();
|
|
14351
14351
|
var MockAgent = require_mock_agent();
|
|
14352
14352
|
var { SnapshotRecorder } = require_snapshot_recorder();
|
|
14353
14353
|
var WrapHandler = require_wrap_handler();
|
|
@@ -14398,7 +14398,7 @@ var require_snapshot_agent = __commonJS({
|
|
|
14398
14398
|
});
|
|
14399
14399
|
this[kSnapshotLoaded] = false;
|
|
14400
14400
|
if (this[kSnapshotMode] === "record" || this[kSnapshotMode] === "update" || this[kSnapshotMode] === "playback" && opts.excludeUrls && opts.excludeUrls.length > 0) {
|
|
14401
|
-
this[kRealAgent] = new
|
|
14401
|
+
this[kRealAgent] = new Agent2(opts);
|
|
14402
14402
|
}
|
|
14403
14403
|
if ((this[kSnapshotMode] === "playback" || this[kSnapshotMode] === "update") && this[kSnapshotPath]) {
|
|
14404
14404
|
this.loadSnapshots().catch(() => {
|
|
@@ -14637,9 +14637,9 @@ var require_global2 = __commonJS({
|
|
|
14637
14637
|
var globalDispatcher = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.2");
|
|
14638
14638
|
var legacyGlobalDispatcher = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
14639
14639
|
var { InvalidArgumentError } = require_errors();
|
|
14640
|
-
var
|
|
14640
|
+
var Agent2 = require_agent();
|
|
14641
14641
|
if (getGlobalDispatcher() === void 0) {
|
|
14642
|
-
setGlobalDispatcher2(new
|
|
14642
|
+
setGlobalDispatcher2(new Agent2());
|
|
14643
14643
|
}
|
|
14644
14644
|
function setGlobalDispatcher2(agent) {
|
|
14645
14645
|
if (!agent || typeof agent.dispatch !== "function") {
|
|
@@ -24896,7 +24896,7 @@ var require_websocket = __commonJS({
|
|
|
24896
24896
|
}
|
|
24897
24897
|
return null;
|
|
24898
24898
|
}
|
|
24899
|
-
var
|
|
24899
|
+
var WebSocket3 = class _WebSocket extends EventTarget {
|
|
24900
24900
|
#events = {
|
|
24901
24901
|
open: null,
|
|
24902
24902
|
error: null,
|
|
@@ -25264,13 +25264,13 @@ var require_websocket = __commonJS({
|
|
|
25264
25264
|
}
|
|
25265
25265
|
}
|
|
25266
25266
|
};
|
|
25267
|
-
var { ping } =
|
|
25268
|
-
Reflect.deleteProperty(
|
|
25269
|
-
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25273
|
-
Object.defineProperties(
|
|
25267
|
+
var { ping } = WebSocket3;
|
|
25268
|
+
Reflect.deleteProperty(WebSocket3, "ping");
|
|
25269
|
+
WebSocket3.CONNECTING = WebSocket3.prototype.CONNECTING = states.CONNECTING;
|
|
25270
|
+
WebSocket3.OPEN = WebSocket3.prototype.OPEN = states.OPEN;
|
|
25271
|
+
WebSocket3.CLOSING = WebSocket3.prototype.CLOSING = states.CLOSING;
|
|
25272
|
+
WebSocket3.CLOSED = WebSocket3.prototype.CLOSED = states.CLOSED;
|
|
25273
|
+
Object.defineProperties(WebSocket3.prototype, {
|
|
25274
25274
|
CONNECTING: staticPropertyDescriptors,
|
|
25275
25275
|
OPEN: staticPropertyDescriptors,
|
|
25276
25276
|
CLOSING: staticPropertyDescriptors,
|
|
@@ -25294,7 +25294,7 @@ var require_websocket = __commonJS({
|
|
|
25294
25294
|
configurable: true
|
|
25295
25295
|
}
|
|
25296
25296
|
});
|
|
25297
|
-
Object.defineProperties(
|
|
25297
|
+
Object.defineProperties(WebSocket3, {
|
|
25298
25298
|
CONNECTING: staticPropertyDescriptors,
|
|
25299
25299
|
OPEN: staticPropertyDescriptors,
|
|
25300
25300
|
CLOSING: staticPropertyDescriptors,
|
|
@@ -25343,7 +25343,7 @@ var require_websocket = __commonJS({
|
|
|
25343
25343
|
return webidl.converters.USVString(V3);
|
|
25344
25344
|
};
|
|
25345
25345
|
module.exports = {
|
|
25346
|
-
WebSocket:
|
|
25346
|
+
WebSocket: WebSocket3,
|
|
25347
25347
|
ping
|
|
25348
25348
|
};
|
|
25349
25349
|
}
|
|
@@ -26496,7 +26496,7 @@ var require_undici = __commonJS({
|
|
|
26496
26496
|
var Pool = require_pool();
|
|
26497
26497
|
var BalancedPool = require_balanced_pool();
|
|
26498
26498
|
var RoundRobinPool = require_round_robin_pool();
|
|
26499
|
-
var
|
|
26499
|
+
var Agent2 = require_agent();
|
|
26500
26500
|
var ProxyAgent = require_proxy_agent();
|
|
26501
26501
|
var Socks5ProxyAgent = require_socks5_proxy_agent();
|
|
26502
26502
|
var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
|
|
@@ -26523,7 +26523,7 @@ var require_undici = __commonJS({
|
|
|
26523
26523
|
module.exports.Pool = Pool;
|
|
26524
26524
|
module.exports.BalancedPool = BalancedPool;
|
|
26525
26525
|
module.exports.RoundRobinPool = RoundRobinPool;
|
|
26526
|
-
module.exports.Agent =
|
|
26526
|
+
module.exports.Agent = Agent2;
|
|
26527
26527
|
module.exports.ProxyAgent = ProxyAgent;
|
|
26528
26528
|
module.exports.Socks5ProxyAgent = Socks5ProxyAgent;
|
|
26529
26529
|
module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
|
|
@@ -26644,8 +26644,8 @@ ${captureLines}` : capture.stack;
|
|
|
26644
26644
|
module.exports.parseMIMEType = parseMIMEType;
|
|
26645
26645
|
module.exports.serializeAMimeType = serializeAMimeType;
|
|
26646
26646
|
var { CloseEvent, ErrorEvent, MessageEvent } = require_events();
|
|
26647
|
-
var { WebSocket:
|
|
26648
|
-
module.exports.WebSocket =
|
|
26647
|
+
var { WebSocket: WebSocket3, ping } = require_websocket();
|
|
26648
|
+
module.exports.WebSocket = WebSocket3;
|
|
26649
26649
|
module.exports.CloseEvent = CloseEvent;
|
|
26650
26650
|
module.exports.ErrorEvent = ErrorEvent;
|
|
26651
26651
|
module.exports.MessageEvent = MessageEvent;
|
|
@@ -111818,6 +111818,173 @@ import path8 from "node:path";
|
|
|
111818
111818
|
// src/settings-control.ts
|
|
111819
111819
|
import fs6 from "node:fs";
|
|
111820
111820
|
import path7 from "node:path";
|
|
111821
|
+
|
|
111822
|
+
// src/codex-native.ts
|
|
111823
|
+
var import_undici2 = __toESM(require_undici(), 1);
|
|
111824
|
+
|
|
111825
|
+
// ../cli/src/lib/shared/conversation.ts
|
|
111826
|
+
var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
|
|
111827
|
+
var CONVERSATION_PHASES = ["preparing", "initialized", "ready", "submitted", "started"];
|
|
111828
|
+
function bounded(work, ms, reason) {
|
|
111829
|
+
return new Promise((resolve2, reject) => {
|
|
111830
|
+
const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
|
|
111831
|
+
work.then((value) => {
|
|
111832
|
+
clearTimeout(timer);
|
|
111833
|
+
resolve2(value);
|
|
111834
|
+
}, (error) => {
|
|
111835
|
+
clearTimeout(timer);
|
|
111836
|
+
reject(error);
|
|
111837
|
+
});
|
|
111838
|
+
});
|
|
111839
|
+
}
|
|
111840
|
+
|
|
111841
|
+
// ../cli/src/lib/agent/connection-process.ts
|
|
111842
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
111843
|
+
function connectionIdentity(pid) {
|
|
111844
|
+
const result = process.platform === "win32" ? spawnSync2("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CreationDate.ToUniversalTime().ToString('o')`], { encoding: "utf8", timeout: 2e3, windowsHide: true }) : spawnSync2("ps", ["-p", String(pid), "-o", "lstart="], { encoding: "utf8", timeout: 2e3, env: { ...process.env, LC_ALL: "C" } });
|
|
111845
|
+
return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
|
|
111846
|
+
}
|
|
111847
|
+
function connectionStopped(root2) {
|
|
111848
|
+
if (!root2) return true;
|
|
111849
|
+
if (!pidAlive(root2.pid)) return true;
|
|
111850
|
+
const identity = connectionIdentity(root2.pid);
|
|
111851
|
+
return !!root2.identity && !!identity && identity !== root2.identity;
|
|
111852
|
+
}
|
|
111853
|
+
function endConnection(child, grace = 12e3) {
|
|
111854
|
+
child.stdin?.end();
|
|
111855
|
+
child.kill("SIGTERM");
|
|
111856
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), grace);
|
|
111857
|
+
timer.unref();
|
|
111858
|
+
child.once("close", () => clearTimeout(timer));
|
|
111859
|
+
}
|
|
111860
|
+
async function stopConnection(root2, timeout) {
|
|
111861
|
+
if (connectionStopped(root2)) return true;
|
|
111862
|
+
if (!root2?.identity || connectionIdentity(root2.pid) !== root2.identity) return false;
|
|
111863
|
+
try {
|
|
111864
|
+
process.kill(root2.pid, "SIGTERM");
|
|
111865
|
+
} catch {
|
|
111866
|
+
}
|
|
111867
|
+
const until = Date.now() + timeout;
|
|
111868
|
+
while (!connectionStopped(root2)) {
|
|
111869
|
+
if (Date.now() >= until) {
|
|
111870
|
+
if (connectionIdentity(root2.pid) === root2.identity) try {
|
|
111871
|
+
process.kill(root2.pid, "SIGKILL");
|
|
111872
|
+
} catch {
|
|
111873
|
+
}
|
|
111874
|
+
return connectionStopped(root2);
|
|
111875
|
+
}
|
|
111876
|
+
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
111877
|
+
}
|
|
111878
|
+
return true;
|
|
111879
|
+
}
|
|
111880
|
+
|
|
111881
|
+
// ../cli/src/lib/agent/wire/json.ts
|
|
111882
|
+
function obj(value) {
|
|
111883
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
111884
|
+
}
|
|
111885
|
+
function str(value) {
|
|
111886
|
+
return typeof value === "string" ? value : "";
|
|
111887
|
+
}
|
|
111888
|
+
function num(value) {
|
|
111889
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
111890
|
+
}
|
|
111891
|
+
function hint(raw) {
|
|
111892
|
+
const line = raw.split("\n")[0].trim();
|
|
111893
|
+
if (!line) return "";
|
|
111894
|
+
return `(${line.length > 96 ? `${line.slice(0, 93)}\u2026` : line})`;
|
|
111895
|
+
}
|
|
111896
|
+
function argHint(input, keys) {
|
|
111897
|
+
const args2 = obj(input);
|
|
111898
|
+
for (const key of keys) {
|
|
111899
|
+
const value = str(args2[key]);
|
|
111900
|
+
if (value.trim()) return hint(value);
|
|
111901
|
+
}
|
|
111902
|
+
return "";
|
|
111903
|
+
}
|
|
111904
|
+
|
|
111905
|
+
// ../cli/src/lib/agent/wire/rpc.ts
|
|
111906
|
+
var RpcError = class extends Error {
|
|
111907
|
+
constructor(message, code) {
|
|
111908
|
+
super(message);
|
|
111909
|
+
this.code = code;
|
|
111910
|
+
this.name = "RpcError";
|
|
111911
|
+
}
|
|
111912
|
+
code;
|
|
111913
|
+
};
|
|
111914
|
+
function connect(stdout, stdin, onCall, dialect = {}) {
|
|
111915
|
+
let buf = "";
|
|
111916
|
+
let nextId = 1;
|
|
111917
|
+
let gone;
|
|
111918
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
111919
|
+
const send3 = (msg) => {
|
|
111920
|
+
if (gone) return;
|
|
111921
|
+
try {
|
|
111922
|
+
stdin.write(`${JSON.stringify(dialect.jsonrpc ? { jsonrpc: "2.0", ...msg } : msg)}
|
|
111923
|
+
`);
|
|
111924
|
+
} catch {
|
|
111925
|
+
}
|
|
111926
|
+
};
|
|
111927
|
+
const closed = (why2) => {
|
|
111928
|
+
if (gone) return;
|
|
111929
|
+
gone = why2;
|
|
111930
|
+
for (const { fail } of waiting.values()) fail(new Error(why2));
|
|
111931
|
+
waiting.clear();
|
|
111932
|
+
};
|
|
111933
|
+
stdout.on("data", (chunk) => {
|
|
111934
|
+
buf += chunk.toString();
|
|
111935
|
+
const lines = buf.split("\n");
|
|
111936
|
+
buf = lines.pop() ?? "";
|
|
111937
|
+
for (const line of lines) {
|
|
111938
|
+
if (!line.trim()) continue;
|
|
111939
|
+
let msg;
|
|
111940
|
+
try {
|
|
111941
|
+
msg = JSON.parse(line);
|
|
111942
|
+
} catch {
|
|
111943
|
+
continue;
|
|
111944
|
+
}
|
|
111945
|
+
if (msg.method) {
|
|
111946
|
+
onCall(msg);
|
|
111947
|
+
continue;
|
|
111948
|
+
}
|
|
111949
|
+
if (msg.id === void 0) continue;
|
|
111950
|
+
const pending = waiting.get(String(msg.id));
|
|
111951
|
+
if (!pending) continue;
|
|
111952
|
+
waiting.delete(String(msg.id));
|
|
111953
|
+
if (msg.error) {
|
|
111954
|
+
const said = [str(msg.error.message), str(obj(msg.error.data).message)].filter(Boolean).join(": ");
|
|
111955
|
+
pending.fail(new RpcError(said || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code));
|
|
111956
|
+
} else pending.ok(obj(msg.result));
|
|
111957
|
+
}
|
|
111958
|
+
});
|
|
111959
|
+
stdout.on("close", () => closed("the agent closed the connection"));
|
|
111960
|
+
stdout.on("error", (err) => closed(String(err)));
|
|
111961
|
+
stdin.on("error", (err) => closed(String(err)));
|
|
111962
|
+
return {
|
|
111963
|
+
/** Ask the agent something. Rejects with the agent's own words when it says no. */
|
|
111964
|
+
call(method, params) {
|
|
111965
|
+
if (gone) return Promise.reject(new Error(gone));
|
|
111966
|
+
const id = dialect.stringIds ? String(nextId++) : nextId++;
|
|
111967
|
+
return new Promise((ok, fail) => {
|
|
111968
|
+
waiting.set(String(id), { ok, fail });
|
|
111969
|
+
send3({ id, method, params });
|
|
111970
|
+
});
|
|
111971
|
+
},
|
|
111972
|
+
notify(method, params = {}) {
|
|
111973
|
+
send3({ method, params });
|
|
111974
|
+
},
|
|
111975
|
+
/** Answer something the agent asked us. */
|
|
111976
|
+
reply(id, result) {
|
|
111977
|
+
send3({ id, result });
|
|
111978
|
+
},
|
|
111979
|
+
/** Say we can't. Sent for anything we never offered to do, so the agent gets an answer
|
|
111980
|
+
* rather than waiting on one forever. */
|
|
111981
|
+
refuse(id, message) {
|
|
111982
|
+
send3({ id, error: { code: -32601, message } });
|
|
111983
|
+
}
|
|
111984
|
+
};
|
|
111985
|
+
}
|
|
111986
|
+
|
|
111987
|
+
// src/settings-control.ts
|
|
111821
111988
|
var directory = () => path7.join(runnerHome(), "executors");
|
|
111822
111989
|
var epochFile = () => path7.join(runnerHome(), "account-generation");
|
|
111823
111990
|
function accountGeneration() {
|
|
@@ -111914,7 +112081,7 @@ async function studioSnapshot(workspace, catalog, list3) {
|
|
|
111914
112081
|
}
|
|
111915
112082
|
|
|
111916
112083
|
// src/protocol.ts
|
|
111917
|
-
var AKB_VERSION = true ? "0.11.
|
|
112084
|
+
var AKB_VERSION = true ? "0.11.64" : "0.0.0";
|
|
111918
112085
|
var AKB_CONTRACT = true ? 17 : 0;
|
|
111919
112086
|
|
|
111920
112087
|
// src/secrets.ts
|
|
@@ -112400,11 +112567,11 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list3 = () => []) {
|
|
|
112400
112567
|
const { meta, body } = splitFrontmatter(text4);
|
|
112401
112568
|
if (meta === null) return bad("no `---` frontmatter, so it declares no name or description");
|
|
112402
112569
|
const front = parseYamlBlock(meta);
|
|
112403
|
-
const name =
|
|
112570
|
+
const name = str2(front.name);
|
|
112404
112571
|
if (!name) return bad("its frontmatter has no `name`");
|
|
112405
112572
|
if (!AGENT_NAME.test(name)) return bad(`"${name}" is not a usable agent name \u2014 use lower-case words joined by "-"`);
|
|
112406
112573
|
named = name;
|
|
112407
|
-
const description =
|
|
112574
|
+
const description = str2(front.description);
|
|
112408
112575
|
if (!description) return bad(`\`${name}\` has no \`description\`, which says what it does`);
|
|
112409
112576
|
const akb = map(front.akb) ?? {};
|
|
112410
112577
|
const old = OLD_ROLE_KEYS.filter((key) => akb[key] !== void 0);
|
|
@@ -112414,13 +112581,13 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list3 = () => []) {
|
|
|
112414
112581
|
{ keys: old }
|
|
112415
112582
|
);
|
|
112416
112583
|
}
|
|
112417
|
-
const declaredReads =
|
|
112584
|
+
const declaredReads = str2(akb.reads);
|
|
112418
112585
|
if (declaredReads && !isScheduleReads(declaredReads)) {
|
|
112419
112586
|
return bad(`\`${name}\` declares \`akb.reads: ${declaredReads}\` \u2014 it is \`${SCHEDULE_READS.join("` or `")}\``);
|
|
112420
112587
|
}
|
|
112421
|
-
const when =
|
|
112588
|
+
const when = str2(akb.when);
|
|
112422
112589
|
const after = names(akb.after);
|
|
112423
|
-
const declaredSession =
|
|
112590
|
+
const declaredSession = str2(akb.session);
|
|
112424
112591
|
if (declaredSession && declaredSession !== "new") {
|
|
112425
112592
|
return bad(`\`${name}\` declares \`akb.session: ${declaredSession}\` \u2014 use \`new\` to recommend a separate session, or omit the preference`);
|
|
112426
112593
|
}
|
|
@@ -112430,14 +112597,14 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list3 = () => []) {
|
|
|
112430
112597
|
stages = [];
|
|
112431
112598
|
for (const value of akb.stages) {
|
|
112432
112599
|
const row = map(value);
|
|
112433
|
-
const id =
|
|
112600
|
+
const id = str2(row?.id);
|
|
112434
112601
|
const title = map(row?.title);
|
|
112435
|
-
const instructions2 =
|
|
112602
|
+
const instructions2 = str2(row?.instructions);
|
|
112436
112603
|
if (!row || Object.keys(row).some((key) => !["id", "title", "instructions", "when"].includes(key)) || !AGENT_NAME.test(id) || stages.some((stage) => stage.id === id)) return bad("`akb.stages` needs unique stage IDs and only id, title, instructions and optional when");
|
|
112437
|
-
if (!title || !
|
|
112604
|
+
if (!title || !str2(title.en) || Object.values(title).some((text5) => typeof text5 !== "string" || !text5.trim())) return bad(`stage ${id} needs a title map with en`);
|
|
112438
112605
|
if (!instructions2.endsWith(".md") || instructions2.startsWith("/") || instructions2.includes("\\") || instructions2.split("/").some((part) => !part || part === ".." || part === ".") || !file2(instructions2)?.trim()) return bad(`stage ${id} needs an existing agent-relative instructions file`);
|
|
112439
|
-
if (row.when !== void 0 && !
|
|
112440
|
-
stages.push({ id, title: Object.fromEntries(Object.entries(title).map(([lang, text5]) => [lang,
|
|
112606
|
+
if (row.when !== void 0 && !str2(row.when)) return bad(`stage ${id} needs nonempty when text, or omit when for a required stage`);
|
|
112607
|
+
stages.push({ id, title: Object.fromEntries(Object.entries(title).map(([lang, text5]) => [lang, str2(text5)])), instructions: instructions2, ...str2(row.when) ? { when: str2(row.when) } : {} });
|
|
112441
112608
|
}
|
|
112442
112609
|
}
|
|
112443
112610
|
const components = akb.components === void 0 ? ["Asset"] : akb.components;
|
|
@@ -112485,9 +112652,9 @@ function readTranslations(raw) {
|
|
|
112485
112652
|
const said = map(value);
|
|
112486
112653
|
if (!said) continue;
|
|
112487
112654
|
const lines = {
|
|
112488
|
-
...
|
|
112489
|
-
...
|
|
112490
|
-
...
|
|
112655
|
+
...str2(said.title) ? { title: str2(said.title) } : {},
|
|
112656
|
+
...str2(said.description) ? { description: str2(said.description) } : {},
|
|
112657
|
+
...str2(said.when) ? { when: str2(said.when) } : {}
|
|
112491
112658
|
};
|
|
112492
112659
|
if (Object.keys(lines).length) out[tag] = lines;
|
|
112493
112660
|
}
|
|
@@ -112508,8 +112675,8 @@ function memoryPaths(raw, folder = "memory/agents/<name>/") {
|
|
|
112508
112675
|
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
|
|
112509
112676
|
return paths;
|
|
112510
112677
|
}
|
|
112511
|
-
var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) =>
|
|
112512
|
-
var
|
|
112678
|
+
var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str2(v)).filter(Boolean))];
|
|
112679
|
+
var str2 = (value) => typeof value === "string" ? value.trim() : "";
|
|
112513
112680
|
var map = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
112514
112681
|
|
|
112515
112682
|
// ../cli/src/lib/agent/studio-def.ts
|
|
@@ -113056,46 +113223,6 @@ function busy(dir) {
|
|
|
113056
113223
|
}
|
|
113057
113224
|
var kept = (dir) => busy(dir) || unsent(dir) || paused(dir);
|
|
113058
113225
|
|
|
113059
|
-
// ../cli/src/lib/agent/connection-process.ts
|
|
113060
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
113061
|
-
function connectionIdentity(pid) {
|
|
113062
|
-
const result = process.platform === "win32" ? spawnSync2("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CreationDate.ToUniversalTime().ToString('o')`], { encoding: "utf8", timeout: 2e3, windowsHide: true }) : spawnSync2("ps", ["-p", String(pid), "-o", "lstart="], { encoding: "utf8", timeout: 2e3, env: { ...process.env, LC_ALL: "C" } });
|
|
113063
|
-
return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
|
|
113064
|
-
}
|
|
113065
|
-
function connectionStopped(root2) {
|
|
113066
|
-
if (!root2) return true;
|
|
113067
|
-
if (!pidAlive(root2.pid)) return true;
|
|
113068
|
-
const identity = connectionIdentity(root2.pid);
|
|
113069
|
-
return !!root2.identity && !!identity && identity !== root2.identity;
|
|
113070
|
-
}
|
|
113071
|
-
function endConnection(child, grace = 12e3) {
|
|
113072
|
-
child.stdin?.end();
|
|
113073
|
-
child.kill("SIGTERM");
|
|
113074
|
-
const timer = setTimeout(() => child.kill("SIGKILL"), grace);
|
|
113075
|
-
timer.unref();
|
|
113076
|
-
child.once("close", () => clearTimeout(timer));
|
|
113077
|
-
}
|
|
113078
|
-
async function stopConnection(root2, timeout) {
|
|
113079
|
-
if (connectionStopped(root2)) return true;
|
|
113080
|
-
if (!root2?.identity || connectionIdentity(root2.pid) !== root2.identity) return false;
|
|
113081
|
-
try {
|
|
113082
|
-
process.kill(root2.pid, "SIGTERM");
|
|
113083
|
-
} catch {
|
|
113084
|
-
}
|
|
113085
|
-
const until = Date.now() + timeout;
|
|
113086
|
-
while (!connectionStopped(root2)) {
|
|
113087
|
-
if (Date.now() >= until) {
|
|
113088
|
-
if (connectionIdentity(root2.pid) === root2.identity) try {
|
|
113089
|
-
process.kill(root2.pid, "SIGKILL");
|
|
113090
|
-
} catch {
|
|
113091
|
-
}
|
|
113092
|
-
return connectionStopped(root2);
|
|
113093
|
-
}
|
|
113094
|
-
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
113095
|
-
}
|
|
113096
|
-
return true;
|
|
113097
|
-
}
|
|
113098
|
-
|
|
113099
113226
|
// src/preview-bridge.ts
|
|
113100
113227
|
import http from "node:http";
|
|
113101
113228
|
import crypto3 from "node:crypto";
|
|
@@ -115178,34 +115305,10 @@ function parseFrontmatter(text4) {
|
|
|
115178
115305
|
return { meta, body: lines.slice(i + 1).join("\n") };
|
|
115179
115306
|
}
|
|
115180
115307
|
|
|
115181
|
-
// ../cli/src/lib/agent/wire/json.ts
|
|
115182
|
-
function obj(value) {
|
|
115183
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
115184
|
-
}
|
|
115185
|
-
function str2(value) {
|
|
115186
|
-
return typeof value === "string" ? value : "";
|
|
115187
|
-
}
|
|
115188
|
-
function num(value) {
|
|
115189
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
115190
|
-
}
|
|
115191
|
-
function hint(raw) {
|
|
115192
|
-
const line = raw.split("\n")[0].trim();
|
|
115193
|
-
if (!line) return "";
|
|
115194
|
-
return `(${line.length > 96 ? `${line.slice(0, 93)}\u2026` : line})`;
|
|
115195
|
-
}
|
|
115196
|
-
function argHint(input, keys) {
|
|
115197
|
-
const args2 = obj(input);
|
|
115198
|
-
for (const key of keys) {
|
|
115199
|
-
const value = str2(args2[key]);
|
|
115200
|
-
if (value.trim()) return hint(value);
|
|
115201
|
-
}
|
|
115202
|
-
return "";
|
|
115203
|
-
}
|
|
115204
|
-
|
|
115205
115308
|
// ../cli/src/lib/agent/wire/events.ts
|
|
115206
115309
|
var EVENT_KINDS = ["message", "tool_call", "tool_call_update", "plan", "error", "log", "context", "phase"];
|
|
115207
115310
|
var TOOL_KINDS = ["read", "edit", "delete", "move", "search", "execute", "fetch", "other"];
|
|
115208
|
-
var toolKind = (v) => TOOL_KINDS.includes(
|
|
115311
|
+
var toolKind = (v) => TOOL_KINDS.includes(str(v)) ? v : "other";
|
|
115209
115312
|
function targetOf(raw) {
|
|
115210
115313
|
const line = raw.split("\n")[0].trim();
|
|
115211
115314
|
if (!line) return void 0;
|
|
@@ -115215,28 +115318,28 @@ function contentText(raw) {
|
|
|
115215
115318
|
const parts = Array.isArray(raw) ? raw : [];
|
|
115216
115319
|
return parts.map((p2) => {
|
|
115217
115320
|
const part = obj(p2);
|
|
115218
|
-
if (part.type === "diff") return
|
|
115219
|
-
return
|
|
115321
|
+
if (part.type === "diff") return str(part.path);
|
|
115322
|
+
return str(obj(part.content).text) || str(part.text);
|
|
115220
115323
|
}).filter((t) => t.trim()).join("\n");
|
|
115221
115324
|
}
|
|
115222
115325
|
function statusOf(raw) {
|
|
115223
|
-
const s =
|
|
115326
|
+
const s = str(raw).toLowerCase();
|
|
115224
115327
|
if (s.includes("progress")) return "in_progress";
|
|
115225
115328
|
if (/complete|done|cancel/.test(s)) return "completed";
|
|
115226
115329
|
return "pending";
|
|
115227
115330
|
}
|
|
115228
115331
|
function entriesOf(raw) {
|
|
115229
115332
|
return (Array.isArray(raw) ? raw : []).map(obj).flatMap((e2) => {
|
|
115230
|
-
const content =
|
|
115333
|
+
const content = str(e2.content).trim();
|
|
115231
115334
|
if (!content) return [];
|
|
115232
|
-
return [{ content, status: statusOf(e2.status), ...
|
|
115335
|
+
return [{ content, status: statusOf(e2.status), ...str(e2.priority) ? { priority: str(e2.priority) } : {} }];
|
|
115233
115336
|
});
|
|
115234
115337
|
}
|
|
115235
|
-
var isTodoCall = (u2) =>
|
|
115236
|
-
var inputTarget = (input) =>
|
|
115338
|
+
var isTodoCall = (u2) => str(u2.title) === "todowrite" || str(obj(u2.rawInput)._toolName) === "updateTodos";
|
|
115339
|
+
var inputTarget = (input) => str(input.command) || str(input.path) || str(input.filePath);
|
|
115237
115340
|
var targetIn = (u2) => {
|
|
115238
115341
|
const locations = Array.isArray(u2.locations) ? u2.locations : [];
|
|
115239
|
-
return targetOf(inputTarget(obj(u2.rawInput)) ||
|
|
115342
|
+
return targetOf(inputTarget(obj(u2.rawInput)) || str(obj(locations[0]).path) || "");
|
|
115240
115343
|
};
|
|
115241
115344
|
function createEventCollector() {
|
|
115242
115345
|
let queue = [];
|
|
@@ -115259,29 +115362,29 @@ function createEventCollector() {
|
|
|
115259
115362
|
update(raw) {
|
|
115260
115363
|
const u2 = obj(raw);
|
|
115261
115364
|
if (u2.sessionUpdate === "agent_message_chunk") {
|
|
115262
|
-
said +=
|
|
115365
|
+
said += str(obj(u2.content).text);
|
|
115263
115366
|
return;
|
|
115264
115367
|
}
|
|
115265
|
-
if (!["tool_call", "tool_call_update", "plan"].includes(
|
|
115368
|
+
if (!["tool_call", "tool_call_update", "plan"].includes(str(u2.sessionUpdate))) return;
|
|
115266
115369
|
close();
|
|
115267
115370
|
switch (u2.sessionUpdate) {
|
|
115268
115371
|
case "tool_call": {
|
|
115269
|
-
const id =
|
|
115372
|
+
const id = str(u2.toolCallId);
|
|
115270
115373
|
if (isTodoCall(u2)) {
|
|
115271
115374
|
todoCalls.add(id);
|
|
115272
115375
|
return;
|
|
115273
115376
|
}
|
|
115274
115377
|
const target = targetIn(u2);
|
|
115275
|
-
const data = { toolCallId: id, title:
|
|
115378
|
+
const data = { toolCallId: id, title: str(u2.title) || "tool", kind: toolKind(u2.kind), status: str(u2.status) || "pending", ...target ? { target } : {} };
|
|
115276
115379
|
if (u2.rawInput !== void 0 && !inputTarget(obj(u2.rawInput))) held5.set(id, data);
|
|
115277
115380
|
else queue.push({ kind: "tool_call", data });
|
|
115278
115381
|
return;
|
|
115279
115382
|
}
|
|
115280
115383
|
case "tool_call_update": {
|
|
115281
|
-
const id =
|
|
115384
|
+
const id = str(u2.toolCallId);
|
|
115282
115385
|
if (todoCalls.has(id)) {
|
|
115283
115386
|
const list3 = obj(u2.rawInput).todos;
|
|
115284
|
-
if (Array.isArray(list3) && !
|
|
115387
|
+
if (Array.isArray(list3) && !str(obj(u2.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list3) } });
|
|
115285
115388
|
return;
|
|
115286
115389
|
}
|
|
115287
115390
|
release2(id, targetIn(u2));
|
|
@@ -115289,7 +115392,7 @@ function createEventCollector() {
|
|
|
115289
115392
|
if (!u2.status && !result) return;
|
|
115290
115393
|
queue.push({
|
|
115291
115394
|
kind: "tool_call_update",
|
|
115292
|
-
data: { toolCallId:
|
|
115395
|
+
data: { toolCallId: str(u2.toolCallId), status: str(u2.status) || "in_progress", ...result ? { result } : {} }
|
|
115293
115396
|
});
|
|
115294
115397
|
return;
|
|
115295
115398
|
}
|
|
@@ -115326,7 +115429,7 @@ function createEventCollector() {
|
|
|
115326
115429
|
close();
|
|
115327
115430
|
const items = (Array.isArray(raw) ? raw : []).map(obj).flatMap((e2) => {
|
|
115328
115431
|
const [entry] = entriesOf([e2]);
|
|
115329
|
-
return entry ? [{ ...entry, id:
|
|
115432
|
+
return entry ? [{ ...entry, id: str(e2.id) }] : [];
|
|
115330
115433
|
});
|
|
115331
115434
|
const next = merge ? [...todos] : [];
|
|
115332
115435
|
for (const item of items) {
|
|
@@ -115360,7 +115463,7 @@ function createEventCollector() {
|
|
|
115360
115463
|
}
|
|
115361
115464
|
function asEvent(value) {
|
|
115362
115465
|
const e2 = obj(value);
|
|
115363
|
-
if (!EVENT_KINDS.includes(
|
|
115466
|
+
if (!EVENT_KINDS.includes(str(e2.kind))) return void 0;
|
|
115364
115467
|
if (!e2.data || typeof e2.data !== "object" || Array.isArray(e2.data)) return void 0;
|
|
115365
115468
|
return e2;
|
|
115366
115469
|
}
|
|
@@ -115409,12 +115512,12 @@ var TOOL_KINDS2 = {
|
|
|
115409
115512
|
var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task"]);
|
|
115410
115513
|
function targetOf2(input) {
|
|
115411
115514
|
const args2 = obj(input);
|
|
115412
|
-
for (const key of ARG_KEYS) if (
|
|
115515
|
+
for (const key of ARG_KEYS) if (str(args2[key]).trim()) return str(args2[key]);
|
|
115413
115516
|
return "";
|
|
115414
115517
|
}
|
|
115415
115518
|
function resultText(raw) {
|
|
115416
115519
|
if (typeof raw === "string") return raw;
|
|
115417
|
-
return (Array.isArray(raw) ? raw : []).map((b2) =>
|
|
115520
|
+
return (Array.isArray(raw) ? raw : []).map((b2) => str(obj(b2).text)).filter(Boolean).join("\n");
|
|
115418
115521
|
}
|
|
115419
115522
|
function eventModel(ev) {
|
|
115420
115523
|
if (ev.type === "system" && ev.subtype === "init" && typeof ev.model === "string") {
|
|
@@ -115437,15 +115540,15 @@ var USER_FIXES = [
|
|
|
115437
115540
|
[/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
|
|
115438
115541
|
];
|
|
115439
115542
|
function failedWith(ev) {
|
|
115440
|
-
const errors = Array.isArray(ev.errors) ? ev.errors.map(
|
|
115543
|
+
const errors = Array.isArray(ev.errors) ? ev.errors.map(str).filter(Boolean) : [];
|
|
115441
115544
|
if (errors.length) return errors.join("; ");
|
|
115442
|
-
const named =
|
|
115545
|
+
const named = str(ev.subtype) || str(ev.terminal_reason);
|
|
115443
115546
|
if (named && named !== "error" && named !== "success") return named;
|
|
115444
|
-
return
|
|
115547
|
+
return str(ev.result).trim() || "the agent reported the session failed";
|
|
115445
115548
|
}
|
|
115446
115549
|
function denials(ev) {
|
|
115447
115550
|
const list3 = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
|
|
115448
|
-
const names2 = [...new Set(list3.map((raw) =>
|
|
115551
|
+
const names2 = [...new Set(list3.map((raw) => str(obj(raw).tool_name)).filter(Boolean))];
|
|
115449
115552
|
if (!names2.length) return "";
|
|
115450
115553
|
return `[refused] ${list3.length} tool call${list3.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
|
|
115451
115554
|
`;
|
|
@@ -115491,7 +115594,7 @@ function createStreamRenderer() {
|
|
|
115491
115594
|
`;
|
|
115492
115595
|
}
|
|
115493
115596
|
if (model === void 0) model = eventModel(ev);
|
|
115494
|
-
if (
|
|
115597
|
+
if (str(ev.parent_tool_use_id)) return "";
|
|
115495
115598
|
switch (ev.type) {
|
|
115496
115599
|
case "assistant": {
|
|
115497
115600
|
const msg = ev.message;
|
|
@@ -115511,14 +115614,14 @@ function createStreamRenderer() {
|
|
|
115511
115614
|
`);
|
|
115512
115615
|
if (SUBAGENT_TOOLS.has(b2.name)) {
|
|
115513
115616
|
const input = obj(b2.input);
|
|
115514
|
-
subagents.set(
|
|
115515
|
-
if (input.run_in_background === true) detached.add(
|
|
115516
|
-
events.subagent(
|
|
115617
|
+
subagents.set(str(b2.id), false);
|
|
115618
|
+
if (input.run_in_background === true) detached.add(str(b2.id));
|
|
115619
|
+
events.subagent(str(b2.id), str(input.description) || str(input.subagent_type) || b2.name);
|
|
115517
115620
|
} else if (b2.name === "TodoWrite") {
|
|
115518
|
-
plans.add(
|
|
115621
|
+
plans.add(str(b2.id));
|
|
115519
115622
|
events.plan(obj(b2.input).todos);
|
|
115520
115623
|
} else {
|
|
115521
|
-
events.toolCall(
|
|
115624
|
+
events.toolCall(str(b2.id), b2.name, TOOL_KINDS2[b2.name] ?? "other", targetOf2(b2.input));
|
|
115522
115625
|
}
|
|
115523
115626
|
}
|
|
115524
115627
|
}
|
|
@@ -115528,12 +115631,12 @@ function createStreamRenderer() {
|
|
|
115528
115631
|
const content = obj(ev.message).content;
|
|
115529
115632
|
for (const raw of Array.isArray(content) ? content : []) {
|
|
115530
115633
|
const b2 = obj(raw);
|
|
115531
|
-
if (b2.type !== "tool_result" || plans.has(
|
|
115532
|
-
if (subagents.has(
|
|
115533
|
-
if (!detached.has(
|
|
115634
|
+
if (b2.type !== "tool_result" || plans.has(str(b2.tool_use_id))) continue;
|
|
115635
|
+
if (subagents.has(str(b2.tool_use_id))) {
|
|
115636
|
+
if (!detached.has(str(b2.tool_use_id))) endSubagent(str(b2.tool_use_id), b2.is_error === true ? "failed" : "completed");
|
|
115534
115637
|
continue;
|
|
115535
115638
|
}
|
|
115536
|
-
events.toolResult(
|
|
115639
|
+
events.toolResult(str(b2.tool_use_id), b2.is_error === true ? "failed" : "completed", resultText(b2.content));
|
|
115537
115640
|
}
|
|
115538
115641
|
return "";
|
|
115539
115642
|
}
|
|
@@ -115559,12 +115662,12 @@ function createStreamRenderer() {
|
|
|
115559
115662
|
}
|
|
115560
115663
|
case "system":
|
|
115561
115664
|
if (ev.subtype === "background_tasks_changed" && Array.isArray(ev.tasks)) background = ev.tasks.length;
|
|
115562
|
-
if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(
|
|
115563
|
-
if (ev.subtype === "task_notification" && subagents.has(
|
|
115564
|
-
endSubagent(
|
|
115665
|
+
if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(str(ev.task_id));
|
|
115666
|
+
if (ev.subtype === "task_notification" && subagents.has(str(ev.tool_use_id))) {
|
|
115667
|
+
endSubagent(str(ev.tool_use_id), str(ev.status) === "completed" ? "completed" : "failed");
|
|
115565
115668
|
}
|
|
115566
|
-
if (ev.subtype === "task_notification" && backgrounded.has(
|
|
115567
|
-
return `\u23FA ${
|
|
115669
|
+
if (ev.subtype === "task_notification" && backgrounded.has(str(ev.task_id)) && str(ev.summary)) {
|
|
115670
|
+
return `\u23FA ${str(ev.summary)}
|
|
115568
115671
|
`;
|
|
115569
115672
|
}
|
|
115570
115673
|
return "";
|
|
@@ -115844,13 +115947,13 @@ var imageSafeText = (text4) => text4.replace(/data:image\/[a-z0-9.+-]+;base64,[A
|
|
|
115844
115947
|
function renderStarted(item) {
|
|
115845
115948
|
switch (item.type) {
|
|
115846
115949
|
case "command_execution":
|
|
115847
|
-
return `\u23FA Command${hint(
|
|
115950
|
+
return `\u23FA Command${hint(str(item.command))}
|
|
115848
115951
|
`;
|
|
115849
115952
|
case "mcp_tool_call":
|
|
115850
|
-
return `\u23FA ${
|
|
115953
|
+
return `\u23FA ${str(item.server)}.${str(item.tool)}
|
|
115851
115954
|
`;
|
|
115852
115955
|
case "web_search":
|
|
115853
|
-
return `\u23FA WebSearch${hint(
|
|
115956
|
+
return `\u23FA WebSearch${hint(str(item.query))}
|
|
115854
115957
|
`;
|
|
115855
115958
|
default:
|
|
115856
115959
|
return "";
|
|
@@ -115859,7 +115962,7 @@ function renderStarted(item) {
|
|
|
115859
115962
|
function renderCompleted(item) {
|
|
115860
115963
|
switch (item.type) {
|
|
115861
115964
|
case "agent_message": {
|
|
115862
|
-
const said = imageSafeText(
|
|
115965
|
+
const said = imageSafeText(str(item.text)).trim();
|
|
115863
115966
|
return said ? `${said}
|
|
115864
115967
|
|
|
115865
115968
|
` : "";
|
|
@@ -115868,17 +115971,17 @@ function renderCompleted(item) {
|
|
|
115868
115971
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
115869
115972
|
return changes.map((raw) => {
|
|
115870
115973
|
const change = obj(raw);
|
|
115871
|
-
const path47 =
|
|
115872
|
-
return path47 ? `\u23FA ${
|
|
115974
|
+
const path47 = str(change.path);
|
|
115975
|
+
return path47 ? `\u23FA ${str(change.kind) || "change"}(${path47})
|
|
115873
115976
|
` : "";
|
|
115874
115977
|
}).join("");
|
|
115875
115978
|
}
|
|
115876
115979
|
case "error":
|
|
115877
|
-
return `[error] ${
|
|
115980
|
+
return `[error] ${str(item.message)}
|
|
115878
115981
|
`;
|
|
115879
115982
|
case "mcp_tool_call": {
|
|
115880
|
-
const error =
|
|
115881
|
-
return error ? `[MCP ${
|
|
115983
|
+
const error = str(obj(item.error).message);
|
|
115984
|
+
return error ? `[MCP ${str(item.server)}.${str(item.tool)}] ${error}
|
|
115882
115985
|
` : "";
|
|
115883
115986
|
}
|
|
115884
115987
|
default:
|
|
@@ -115893,47 +115996,47 @@ function unwrapShell(command) {
|
|
|
115893
115996
|
function callOf(item) {
|
|
115894
115997
|
switch (item.type) {
|
|
115895
115998
|
case "command_execution":
|
|
115896
|
-
return { title: "Command", target: unwrapShell(
|
|
115999
|
+
return { title: "Command", target: unwrapShell(str(item.command)) };
|
|
115897
116000
|
case "mcp_tool_call":
|
|
115898
|
-
return { title: `${
|
|
116001
|
+
return { title: `${str(item.server)}.${str(item.tool)}`, target: "" };
|
|
115899
116002
|
case "web_search":
|
|
115900
|
-
return { title: "WebSearch", target:
|
|
116003
|
+
return { title: "WebSearch", target: str(item.query) };
|
|
115901
116004
|
default: {
|
|
115902
|
-
const changes = (Array.isArray(item.changes) ? item.changes : []).map((c2) =>
|
|
116005
|
+
const changes = (Array.isArray(item.changes) ? item.changes : []).map((c2) => str(obj(c2).path)).filter(Boolean);
|
|
115903
116006
|
return { title: "Edit", target: changes.join(", ") };
|
|
115904
116007
|
}
|
|
115905
116008
|
}
|
|
115906
116009
|
}
|
|
115907
116010
|
function callResult(item) {
|
|
115908
|
-
if (item.type === "command_execution") return
|
|
116011
|
+
if (item.type === "command_execution") return str(item.aggregated_output);
|
|
115909
116012
|
if (item.type === "mcp_tool_call") {
|
|
115910
|
-
const error =
|
|
116013
|
+
const error = str(obj(item.error).message);
|
|
115911
116014
|
if (error) return error;
|
|
115912
116015
|
const content = obj(item.result).content;
|
|
115913
|
-
return (Array.isArray(content) ? content : []).map((b2) => imageSafeText(
|
|
116016
|
+
return (Array.isArray(content) ? content : []).map((b2) => imageSafeText(str(obj(b2).text))).filter(Boolean).join("\n");
|
|
115914
116017
|
}
|
|
115915
116018
|
if (item.type === "file_change") {
|
|
115916
|
-
return (Array.isArray(item.changes) ? item.changes : []).map((c2) => `${
|
|
116019
|
+
return (Array.isArray(item.changes) ? item.changes : []).map((c2) => `${str(obj(c2).kind) || "change"} ${str(obj(c2).path)}`).join("\n");
|
|
115917
116020
|
}
|
|
115918
116021
|
return "";
|
|
115919
116022
|
}
|
|
115920
116023
|
function itemEvents(events, started, item, done) {
|
|
115921
|
-
const id =
|
|
116024
|
+
const id = str(item.id);
|
|
115922
116025
|
if (item.type === "agent_message") {
|
|
115923
|
-
if (done) events.message(imageSafeText(
|
|
116026
|
+
if (done) events.message(imageSafeText(str(item.text)));
|
|
115924
116027
|
return;
|
|
115925
116028
|
}
|
|
115926
116029
|
if (item.type === "todo_list") {
|
|
115927
116030
|
const items = Array.isArray(item.items) ? item.items : [];
|
|
115928
|
-
events.plan(items.map(obj).map((t) => ({ content:
|
|
116031
|
+
events.plan(items.map(obj).map((t) => ({ content: str(t.text), status: t.completed === true ? "completed" : "pending" })));
|
|
115929
116032
|
return;
|
|
115930
116033
|
}
|
|
115931
116034
|
if (item.type === "error") {
|
|
115932
|
-
if (done) events.log(`${
|
|
116035
|
+
if (done) events.log(`${str(item.message)}
|
|
115933
116036
|
`);
|
|
115934
116037
|
return;
|
|
115935
116038
|
}
|
|
115936
|
-
const kind = CALLS[
|
|
116039
|
+
const kind = CALLS[str(item.type)];
|
|
115937
116040
|
if (!kind) return;
|
|
115938
116041
|
if (!started.has(id)) {
|
|
115939
116042
|
started.add(id);
|
|
@@ -115962,23 +116065,23 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
115962
116065
|
const collabItems = /* @__PURE__ */ new Set();
|
|
115963
116066
|
const collab = (item, done) => {
|
|
115964
116067
|
if (item.type !== "collab_tool_call") return;
|
|
115965
|
-
const key = `${
|
|
116068
|
+
const key = `${str(item.id)}:${done}`;
|
|
115966
116069
|
if (collabItems.has(key)) return;
|
|
115967
116070
|
collabItems.add(key);
|
|
115968
116071
|
for (const [id, raw] of Object.entries(obj(item.agents_states))) {
|
|
115969
116072
|
const state = obj(raw);
|
|
115970
|
-
const status =
|
|
116073
|
+
const status = str(state.status);
|
|
115971
116074
|
if (!["pending_init", "running", "completed", "interrupted", "errored", "shutdown", "not_found"].includes(status)) continue;
|
|
115972
116075
|
const previous = background.results().find((t) => t.id === id);
|
|
115973
116076
|
if (["shutdown", "not_found"].includes(status) && previous && previous.status !== "running") continue;
|
|
115974
116077
|
if (!subagents.has(id)) {
|
|
115975
116078
|
subagents.add(id);
|
|
115976
|
-
events.subagent(`agent:${id}`,
|
|
116079
|
+
events.subagent(`agent:${id}`, str(item.prompt) || "Agent");
|
|
115977
116080
|
}
|
|
115978
116081
|
const running = status === "pending_init" || status === "running";
|
|
115979
116082
|
const failed = !running && status !== "completed";
|
|
115980
|
-
if (background.update(id, running ? "running" : failed ? "failed" : "completed",
|
|
115981
|
-
events.toolResult(`agent:${id}`, failed ? "failed" : "completed",
|
|
116083
|
+
if (background.update(id, running ? "running" : failed ? "failed" : "completed", str(state.message)) && !running) {
|
|
116084
|
+
events.toolResult(`agent:${id}`, failed ? "failed" : "completed", str(state.message));
|
|
115982
116085
|
}
|
|
115983
116086
|
}
|
|
115984
116087
|
};
|
|
@@ -116005,7 +116108,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
116005
116108
|
`;
|
|
116006
116109
|
switch (ev.type) {
|
|
116007
116110
|
case "thread.started":
|
|
116008
|
-
if (!threadId) threadId =
|
|
116111
|
+
if (!threadId) threadId = str(ev.thread_id).trim() || void 0;
|
|
116009
116112
|
return "";
|
|
116010
116113
|
case "item.started":
|
|
116011
116114
|
collab(obj(ev.item), false);
|
|
@@ -116017,22 +116120,22 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
116017
116120
|
case "item.completed": {
|
|
116018
116121
|
const item = obj(ev.item);
|
|
116019
116122
|
collab(item, true);
|
|
116020
|
-
if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(
|
|
116123
|
+
if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(str(item.tool))) {
|
|
116021
116124
|
const content = obj(item.result).content;
|
|
116022
116125
|
for (const block of Array.isArray(content) ? content : []) {
|
|
116023
116126
|
const b2 = obj(block);
|
|
116024
116127
|
const audience = obj(b2.annotations).audience;
|
|
116025
116128
|
if (Array.isArray(audience) && !audience.includes("user")) continue;
|
|
116026
|
-
if (b2.type === "resource_link" &&
|
|
116027
|
-
pictures2.push({ type: "image", path:
|
|
116129
|
+
if (b2.type === "resource_link" && str(b2.uri).startsWith("file:") && /^image\/(png|jpeg|gif|webp)$/.test(str(b2.mimeType)) && pictures2.length < 100) {
|
|
116130
|
+
pictures2.push({ type: "image", path: str(b2.uri), mime: str(b2.mimeType), registered: true });
|
|
116028
116131
|
}
|
|
116029
|
-
if (b2.type === "image" && pictures2.length < 100) pictures2.push(
|
|
116132
|
+
if (b2.type === "image" && pictures2.length < 100) pictures2.push(str(b2.data).length <= 14e7 ? { type: "image", data: str(b2.data), mime: str(b2.mimeType) } : { type: "image" });
|
|
116030
116133
|
}
|
|
116031
116134
|
}
|
|
116032
116135
|
if (item.type === "image_generation" && typeof item.path === "string") pictures2.push({ type: "image", path: item.path, registered: true });
|
|
116033
116136
|
itemEvents(events, started, item, true);
|
|
116034
116137
|
if (item.type === "agent_message") {
|
|
116035
|
-
const said =
|
|
116138
|
+
const said = str(item.text).trim();
|
|
116036
116139
|
if (said || pictures2.length) final = said;
|
|
116037
116140
|
}
|
|
116038
116141
|
return renderCompleted(item);
|
|
@@ -116043,14 +116146,14 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
116043
116146
|
return "";
|
|
116044
116147
|
// 最终失败保留;连接提示只在没有后续成功完成时才作为失败。
|
|
116045
116148
|
case "turn.failed": {
|
|
116046
|
-
const said =
|
|
116149
|
+
const said = str(obj(ev.error).message) || failure || "Codex \u6267\u884C\u5931\u8D25";
|
|
116047
116150
|
failure = said;
|
|
116048
116151
|
events.error(said);
|
|
116049
116152
|
return `[error] ${said}
|
|
116050
116153
|
`;
|
|
116051
116154
|
}
|
|
116052
116155
|
case "error": {
|
|
116053
|
-
const said =
|
|
116156
|
+
const said = str(ev.message);
|
|
116054
116157
|
failure = said || failure;
|
|
116055
116158
|
events.log(`[Codex] ${said}
|
|
116056
116159
|
`);
|
|
@@ -116140,14 +116243,14 @@ function readIndex() {
|
|
|
116140
116243
|
} catch {
|
|
116141
116244
|
continue;
|
|
116142
116245
|
}
|
|
116143
|
-
const sessionId =
|
|
116246
|
+
const sessionId = str(record.sessionId).trim();
|
|
116144
116247
|
if (!sessionId) continue;
|
|
116145
116248
|
if (record.deleted === true) {
|
|
116146
116249
|
entries.delete(sessionId);
|
|
116147
116250
|
continue;
|
|
116148
116251
|
}
|
|
116149
|
-
const sessionDir =
|
|
116150
|
-
const workDir =
|
|
116252
|
+
const sessionDir = str(record.sessionDir).trim();
|
|
116253
|
+
const workDir = str(record.workDir).trim();
|
|
116151
116254
|
if (sessionDir && workDir) entries.set(sessionId, { sessionId, sessionDir, workDir });
|
|
116152
116255
|
}
|
|
116153
116256
|
return entries;
|
|
@@ -116203,7 +116306,7 @@ function readKimiRunFacts(sessionId) {
|
|
|
116203
116306
|
continue;
|
|
116204
116307
|
}
|
|
116205
116308
|
if (record.type !== "usage.record") continue;
|
|
116206
|
-
model ??=
|
|
116309
|
+
model ??= str(record.model).trim() || void 0;
|
|
116207
116310
|
const usage = obj(record.usage);
|
|
116208
116311
|
total.input += num(usage.inputOther);
|
|
116209
116312
|
total.cacheCreation += num(usage.inputCacheCreation);
|
|
@@ -116227,7 +116330,7 @@ function readKimiRunFacts(sessionId) {
|
|
|
116227
116330
|
// ../cli/src/lib/agent/wire/kimi-stream.ts
|
|
116228
116331
|
var ARG_KEYS2 = ["command", "path", "pattern", "query", "url", "prompt", "prompt_template", "description"];
|
|
116229
116332
|
function callArgs(raw) {
|
|
116230
|
-
const text4 =
|
|
116333
|
+
const text4 = str(raw);
|
|
116231
116334
|
if (!text4.trim()) return {};
|
|
116232
116335
|
try {
|
|
116233
116336
|
return JSON.parse(text4);
|
|
@@ -116248,13 +116351,13 @@ function toolCalls(row) {
|
|
|
116248
116351
|
return calls.map((raw) => {
|
|
116249
116352
|
const call2 = obj(raw);
|
|
116250
116353
|
const fn2 = obj(call2.function);
|
|
116251
|
-
const name =
|
|
116354
|
+
const name = str(fn2.name) || "tool";
|
|
116252
116355
|
return `\u23FA ${name}${argHint(callArgs(fn2.arguments), ARG_KEYS2)}
|
|
116253
116356
|
`;
|
|
116254
116357
|
}).join("");
|
|
116255
116358
|
}
|
|
116256
116359
|
function retry(row) {
|
|
116257
|
-
const why2 =
|
|
116360
|
+
const why2 = str(row.error_message) || str(row.error_name) || "the provider failed";
|
|
116258
116361
|
const attempt = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
|
|
116259
116362
|
return `[retry ${attempt}] ${why2}
|
|
116260
116363
|
`;
|
|
@@ -116283,18 +116386,18 @@ function createKimiStreamRenderer(cwd, resumeId) {
|
|
|
116283
116386
|
`;
|
|
116284
116387
|
switch (row.role) {
|
|
116285
116388
|
case "assistant": {
|
|
116286
|
-
const said =
|
|
116389
|
+
const said = str(row.content).trim();
|
|
116287
116390
|
if (said) final = said;
|
|
116288
116391
|
if (said) events.message(said);
|
|
116289
116392
|
for (const raw of Array.isArray(row.tool_calls) ? row.tool_calls : []) {
|
|
116290
116393
|
const call2 = obj(raw);
|
|
116291
|
-
const name =
|
|
116394
|
+
const name = str(obj(call2.function).name) || "tool";
|
|
116292
116395
|
const args2 = obj(callArgs(obj(call2.function).arguments));
|
|
116293
116396
|
if (name === "Agent") {
|
|
116294
|
-
subagents.add(
|
|
116295
|
-
events.subagent(
|
|
116397
|
+
subagents.add(str(call2.id));
|
|
116398
|
+
events.subagent(str(call2.id), str(args2.description) || name);
|
|
116296
116399
|
} else {
|
|
116297
|
-
events.toolCall(
|
|
116400
|
+
events.toolCall(str(call2.id), name, kindOf2(name), ARG_KEYS2.map((k2) => str(args2[k2])).find((v) => v.trim()));
|
|
116298
116401
|
}
|
|
116299
116402
|
}
|
|
116300
116403
|
return `${said ? `${said}
|
|
@@ -116302,11 +116405,11 @@ function createKimiStreamRenderer(cwd, resumeId) {
|
|
|
116302
116405
|
` : ""}${toolCalls(row)}`;
|
|
116303
116406
|
}
|
|
116304
116407
|
case "meta":
|
|
116305
|
-
if (row.type === "session.resume_hint") sessionId ??=
|
|
116408
|
+
if (row.type === "session.resume_hint") sessionId ??= str(row.session_id).trim() || void 0;
|
|
116306
116409
|
return row.type === "turn.step.retrying" ? retry(row) : "";
|
|
116307
116410
|
case "tool": {
|
|
116308
|
-
const id =
|
|
116309
|
-
const text4 =
|
|
116411
|
+
const id = str(row.tool_call_id);
|
|
116412
|
+
const text4 = str(row.content);
|
|
116310
116413
|
if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(text4) ? "completed" : "failed", "");
|
|
116311
116414
|
else events.toolResult(id, "completed", text4);
|
|
116312
116415
|
return "";
|
|
@@ -116371,107 +116474,9 @@ function saveAcpCost(file2, cost) {
|
|
|
116371
116474
|
}
|
|
116372
116475
|
}
|
|
116373
116476
|
|
|
116374
|
-
// ../cli/src/lib/shared/conversation.ts
|
|
116375
|
-
var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
|
|
116376
|
-
var CONVERSATION_PHASES = ["preparing", "initialized", "ready", "submitted", "started"];
|
|
116377
|
-
function bounded(work, ms, reason) {
|
|
116378
|
-
return new Promise((resolve2, reject) => {
|
|
116379
|
-
const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
|
|
116380
|
-
work.then((value) => {
|
|
116381
|
-
clearTimeout(timer);
|
|
116382
|
-
resolve2(value);
|
|
116383
|
-
}, (error) => {
|
|
116384
|
-
clearTimeout(timer);
|
|
116385
|
-
reject(error);
|
|
116386
|
-
});
|
|
116387
|
-
});
|
|
116388
|
-
}
|
|
116389
|
-
|
|
116390
116477
|
// ../cli/src/lib/agent/wire/acp.ts
|
|
116391
116478
|
import fs23 from "node:fs";
|
|
116392
116479
|
|
|
116393
|
-
// ../cli/src/lib/agent/wire/rpc.ts
|
|
116394
|
-
var RpcError = class extends Error {
|
|
116395
|
-
constructor(message, code) {
|
|
116396
|
-
super(message);
|
|
116397
|
-
this.code = code;
|
|
116398
|
-
this.name = "RpcError";
|
|
116399
|
-
}
|
|
116400
|
-
code;
|
|
116401
|
-
};
|
|
116402
|
-
function connect(stdout, stdin, onCall, dialect = {}) {
|
|
116403
|
-
let buf = "";
|
|
116404
|
-
let nextId = 1;
|
|
116405
|
-
let gone;
|
|
116406
|
-
const waiting = /* @__PURE__ */ new Map();
|
|
116407
|
-
const send3 = (msg) => {
|
|
116408
|
-
if (gone) return;
|
|
116409
|
-
try {
|
|
116410
|
-
stdin.write(`${JSON.stringify(dialect.jsonrpc ? { jsonrpc: "2.0", ...msg } : msg)}
|
|
116411
|
-
`);
|
|
116412
|
-
} catch {
|
|
116413
|
-
}
|
|
116414
|
-
};
|
|
116415
|
-
const closed = (why2) => {
|
|
116416
|
-
if (gone) return;
|
|
116417
|
-
gone = why2;
|
|
116418
|
-
for (const { fail } of waiting.values()) fail(new Error(why2));
|
|
116419
|
-
waiting.clear();
|
|
116420
|
-
};
|
|
116421
|
-
stdout.on("data", (chunk) => {
|
|
116422
|
-
buf += chunk.toString();
|
|
116423
|
-
const lines = buf.split("\n");
|
|
116424
|
-
buf = lines.pop() ?? "";
|
|
116425
|
-
for (const line of lines) {
|
|
116426
|
-
if (!line.trim()) continue;
|
|
116427
|
-
let msg;
|
|
116428
|
-
try {
|
|
116429
|
-
msg = JSON.parse(line);
|
|
116430
|
-
} catch {
|
|
116431
|
-
continue;
|
|
116432
|
-
}
|
|
116433
|
-
if (msg.method) {
|
|
116434
|
-
onCall(msg);
|
|
116435
|
-
continue;
|
|
116436
|
-
}
|
|
116437
|
-
if (msg.id === void 0) continue;
|
|
116438
|
-
const pending = waiting.get(String(msg.id));
|
|
116439
|
-
if (!pending) continue;
|
|
116440
|
-
waiting.delete(String(msg.id));
|
|
116441
|
-
if (msg.error) {
|
|
116442
|
-
const said = [str2(msg.error.message), str2(obj(msg.error.data).message)].filter(Boolean).join(": ");
|
|
116443
|
-
pending.fail(new RpcError(said || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code));
|
|
116444
|
-
} else pending.ok(obj(msg.result));
|
|
116445
|
-
}
|
|
116446
|
-
});
|
|
116447
|
-
stdout.on("close", () => closed("the agent closed the connection"));
|
|
116448
|
-
stdout.on("error", (err) => closed(String(err)));
|
|
116449
|
-
stdin.on("error", (err) => closed(String(err)));
|
|
116450
|
-
return {
|
|
116451
|
-
/** Ask the agent something. Rejects with the agent's own words when it says no. */
|
|
116452
|
-
call(method, params) {
|
|
116453
|
-
if (gone) return Promise.reject(new Error(gone));
|
|
116454
|
-
const id = dialect.stringIds ? String(nextId++) : nextId++;
|
|
116455
|
-
return new Promise((ok, fail) => {
|
|
116456
|
-
waiting.set(String(id), { ok, fail });
|
|
116457
|
-
send3({ id, method, params });
|
|
116458
|
-
});
|
|
116459
|
-
},
|
|
116460
|
-
notify(method, params = {}) {
|
|
116461
|
-
send3({ method, params });
|
|
116462
|
-
},
|
|
116463
|
-
/** Answer something the agent asked us. */
|
|
116464
|
-
reply(id, result) {
|
|
116465
|
-
send3({ id, result });
|
|
116466
|
-
},
|
|
116467
|
-
/** Say we can't. Sent for anything we never offered to do, so the agent gets an answer
|
|
116468
|
-
* rather than waiting on one forever. */
|
|
116469
|
-
refuse(id, message) {
|
|
116470
|
-
send3({ id, error: { code: -32601, message } });
|
|
116471
|
-
}
|
|
116472
|
-
};
|
|
116473
|
-
}
|
|
116474
|
-
|
|
116475
116480
|
// ../cli/src/lib/agent/wire/tail.ts
|
|
116476
116481
|
function createTail(log) {
|
|
116477
116482
|
let mode = "none";
|
|
@@ -116522,7 +116527,7 @@ function createTail(log) {
|
|
|
116522
116527
|
// ../cli/package.json
|
|
116523
116528
|
var package_default = {
|
|
116524
116529
|
name: "wildcrane",
|
|
116525
|
-
version: "0.11.
|
|
116530
|
+
version: "0.11.64",
|
|
116526
116531
|
akbContract: 17,
|
|
116527
116532
|
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.",
|
|
116528
116533
|
keywords: [
|
|
@@ -116594,33 +116599,33 @@ var CLIENT_CAPABILITIES = {
|
|
|
116594
116599
|
};
|
|
116595
116600
|
function whereHint(update2, title) {
|
|
116596
116601
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
116597
|
-
const path47 =
|
|
116602
|
+
const path47 = str(obj(locations[0]).path);
|
|
116598
116603
|
return path47 && !title.includes(path47) ? hint(path47) : "";
|
|
116599
116604
|
}
|
|
116600
116605
|
function saidBy(update2) {
|
|
116601
116606
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
116602
116607
|
for (const raw of content) {
|
|
116603
116608
|
const part = obj(raw);
|
|
116604
|
-
const text4 =
|
|
116609
|
+
const text4 = str(obj(part.content).text) || str(part.text);
|
|
116605
116610
|
if (text4.trim()) return text4.trim();
|
|
116606
116611
|
}
|
|
116607
116612
|
return "";
|
|
116608
116613
|
}
|
|
116609
116614
|
function modelOf(answer) {
|
|
116610
|
-
const current2 =
|
|
116615
|
+
const current2 = str(obj(answer.models).currentModelId).trim();
|
|
116611
116616
|
if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
|
|
116612
116617
|
const list3 = Array.isArray(answer.configOptions) ? answer.configOptions : [];
|
|
116613
116618
|
for (const raw of list3) {
|
|
116614
116619
|
const option = obj(raw);
|
|
116615
|
-
if (option.id === "model") return
|
|
116620
|
+
if (option.id === "model") return str(option.currentValue).trim() || void 0;
|
|
116616
116621
|
}
|
|
116617
116622
|
return void 0;
|
|
116618
116623
|
}
|
|
116619
116624
|
function modelsIn(answer) {
|
|
116620
116625
|
const list3 = obj(answer.models).availableModels;
|
|
116621
116626
|
return (Array.isArray(list3) ? list3 : []).map(obj).flatMap((m) => {
|
|
116622
|
-
const modelId =
|
|
116623
|
-
return modelId ? [{ modelId, name:
|
|
116627
|
+
const modelId = str(m.modelId);
|
|
116628
|
+
return modelId ? [{ modelId, name: str(m.name) || modelId }] : [];
|
|
116624
116629
|
});
|
|
116625
116630
|
}
|
|
116626
116631
|
function pickedModel(answer, wanted) {
|
|
@@ -116649,7 +116654,7 @@ function sessionGone(e2) {
|
|
|
116649
116654
|
var RESTARTED = "[board] that conversation is gone \u2014 the task was restarted in a new session\n";
|
|
116650
116655
|
async function newSession(rpc, cwd, mcpServers) {
|
|
116651
116656
|
const opened = await rpc.call("session/new", { cwd, mcpServers });
|
|
116652
|
-
const sessionId =
|
|
116657
|
+
const sessionId = str(opened.sessionId);
|
|
116653
116658
|
if (!sessionId) throw new Error("the agent opened a session without giving it an id");
|
|
116654
116659
|
return { opened, sessionId };
|
|
116655
116660
|
}
|
|
@@ -116670,7 +116675,7 @@ function mcpServersIn(file2) {
|
|
|
116670
116675
|
const s = obj(raw);
|
|
116671
116676
|
return {
|
|
116672
116677
|
name,
|
|
116673
|
-
command:
|
|
116678
|
+
command: str(s.command),
|
|
116674
116679
|
args: Array.isArray(s.args) ? s.args.map(String) : [],
|
|
116675
116680
|
env: Object.entries(obj(s.env)).map(([key, value]) => ({ name: key, value: String(value) }))
|
|
116676
116681
|
};
|
|
@@ -116708,7 +116713,7 @@ async function oneTurn(io, options) {
|
|
|
116708
116713
|
});
|
|
116709
116714
|
}
|
|
116710
116715
|
if (live && (!obj(msg.params).sessionId || obj(msg.params).sessionId === currentSession)) {
|
|
116711
|
-
const kind =
|
|
116716
|
+
const kind = str(obj(obj(msg.params).update).sessionUpdate);
|
|
116712
116717
|
if (!started && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
|
|
116713
116718
|
started = true;
|
|
116714
116719
|
phase("started");
|
|
@@ -116794,7 +116799,7 @@ async function oneTurn(io, options) {
|
|
|
116794
116799
|
});
|
|
116795
116800
|
const result = tail.end();
|
|
116796
116801
|
events.end();
|
|
116797
|
-
const stopReason =
|
|
116802
|
+
const stopReason = str(done.stopReason);
|
|
116798
116803
|
const spent = obj(obj(done._meta).usage);
|
|
116799
116804
|
const usage = usageOf2(done.usage) ?? usageOf2(spent, true);
|
|
116800
116805
|
saveAcpCost(acpCostFile(options.tool ?? "acp", io.cwd, sessionId), costUsd);
|
|
@@ -116824,20 +116829,20 @@ function update(raw, tail, gotCost, gotContext) {
|
|
|
116824
116829
|
const change = obj(raw);
|
|
116825
116830
|
switch (change.sessionUpdate) {
|
|
116826
116831
|
case "agent_message_chunk":
|
|
116827
|
-
tail.text(
|
|
116832
|
+
tail.text(str(obj(change.content).text));
|
|
116828
116833
|
return;
|
|
116829
116834
|
case "agent_thought_chunk":
|
|
116830
|
-
tail.thought(
|
|
116835
|
+
tail.thought(str(obj(change.content).text));
|
|
116831
116836
|
return;
|
|
116832
116837
|
case "tool_call": {
|
|
116833
|
-
const title =
|
|
116838
|
+
const title = str(change.title) || str(change.name) || "tool";
|
|
116834
116839
|
tail.line(`\u23FA ${title}${whereHint(change, title)}`);
|
|
116835
116840
|
return;
|
|
116836
116841
|
}
|
|
116837
116842
|
case "tool_call_update": {
|
|
116838
116843
|
if (change.status !== "failed") return;
|
|
116839
116844
|
const why2 = saidBy(change);
|
|
116840
|
-
tail.line(`[error] ${
|
|
116845
|
+
tail.line(`[error] ${str(change.title) || "that tool call"} failed${why2 ? `: ${why2}` : ""}`);
|
|
116841
116846
|
return;
|
|
116842
116847
|
}
|
|
116843
116848
|
case "usage_update": {
|
|
@@ -116846,7 +116851,7 @@ function update(raw, tail, gotCost, gotContext) {
|
|
|
116846
116851
|
if (used > 0) gotContext({ used, ...size > 0 ? { limit: size } : {} });
|
|
116847
116852
|
const cost = obj(change.cost);
|
|
116848
116853
|
const amount = cost.amount;
|
|
116849
|
-
if (
|
|
116854
|
+
if (str(cost.currency).toUpperCase() === "USD" && typeof amount === "number" && Number.isFinite(amount) && amount >= 0) {
|
|
116850
116855
|
gotCost(amount);
|
|
116851
116856
|
}
|
|
116852
116857
|
return;
|
|
@@ -116857,8 +116862,8 @@ function update(raw, tail, gotCost, gotContext) {
|
|
|
116857
116862
|
}
|
|
116858
116863
|
function decide(params, tail, events) {
|
|
116859
116864
|
const options = Array.isArray(params.options) ? params.options : [];
|
|
116860
|
-
const no = options.map(obj).find((option) =>
|
|
116861
|
-
const title =
|
|
116865
|
+
const no = options.map(obj).find((option) => str(option.kind).startsWith("reject"));
|
|
116866
|
+
const title = str(obj(params.toolCall).title) || "that";
|
|
116862
116867
|
const said = `[refused] ${title} \u2014 a run reaches no further than this project`;
|
|
116863
116868
|
tail.line(said);
|
|
116864
116869
|
events.log(`${said}
|
|
@@ -116872,7 +116877,7 @@ import path24 from "node:path";
|
|
|
116872
116877
|
function whereHint2(input, title) {
|
|
116873
116878
|
const named = obj(input);
|
|
116874
116879
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
116875
|
-
const value =
|
|
116880
|
+
const value = str(named[key]).trim();
|
|
116876
116881
|
if (value && !title.includes(value)) return hint(value);
|
|
116877
116882
|
}
|
|
116878
116883
|
return "";
|
|
@@ -116896,9 +116901,9 @@ var STOPPED2 = {
|
|
|
116896
116901
|
};
|
|
116897
116902
|
function modelOf2(ref) {
|
|
116898
116903
|
const model = obj(ref);
|
|
116899
|
-
const id =
|
|
116904
|
+
const id = str(model.modelId);
|
|
116900
116905
|
if (!id) return "";
|
|
116901
|
-
const provider =
|
|
116906
|
+
const provider = str(model.providerId);
|
|
116902
116907
|
return provider ? `${provider}/${id}` : id;
|
|
116903
116908
|
}
|
|
116904
116909
|
function createParts(tail) {
|
|
@@ -116917,32 +116922,32 @@ function createParts(tail) {
|
|
|
116917
116922
|
/** A whole part, as `part.started` or `part.upserted` sends it. */
|
|
116918
116923
|
upsert(raw) {
|
|
116919
116924
|
const part = obj(raw);
|
|
116920
|
-
const type =
|
|
116921
|
-
const partId =
|
|
116925
|
+
const type = str(part.type);
|
|
116926
|
+
const partId = str(part.partId);
|
|
116922
116927
|
if (type === "text" || type === "reasoning" || type === "thought") {
|
|
116923
|
-
if (partId) say(partId, type,
|
|
116924
|
-
else tail.text(
|
|
116928
|
+
if (partId) say(partId, type, str(part.text));
|
|
116929
|
+
else tail.text(str(part.text));
|
|
116925
116930
|
return;
|
|
116926
116931
|
}
|
|
116927
116932
|
if (type !== "tool") return;
|
|
116928
116933
|
const state = obj(part.state);
|
|
116929
|
-
const callId =
|
|
116930
|
-
const title =
|
|
116934
|
+
const callId = str(part.callId) || partId;
|
|
116935
|
+
const title = str(state.title) || str(part.tool) || "tool";
|
|
116931
116936
|
if (callId && !tools.has(callId)) {
|
|
116932
116937
|
tools.add(callId);
|
|
116933
116938
|
tail.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
|
|
116934
116939
|
}
|
|
116935
|
-
if (
|
|
116936
|
-
const why2 =
|
|
116940
|
+
if (str(state.status) === "error") {
|
|
116941
|
+
const why2 = str(state.error).trim();
|
|
116937
116942
|
tail.line(`[error] ${title} failed${why2 ? `: ${why2}` : ""}`);
|
|
116938
116943
|
}
|
|
116939
116944
|
},
|
|
116940
116945
|
/** A piece of one part, as `part.delta` sends it. */
|
|
116941
116946
|
delta(event2) {
|
|
116942
|
-
const field =
|
|
116947
|
+
const field = str(event2.field) || "text";
|
|
116943
116948
|
if (field !== "text" && field !== "reasoning") return;
|
|
116944
|
-
const partId =
|
|
116945
|
-
const delta =
|
|
116949
|
+
const partId = str(event2.partId);
|
|
116950
|
+
const delta = str(event2.delta);
|
|
116946
116951
|
if (!delta) return;
|
|
116947
116952
|
written.set(partId, (written.get(partId) ?? "") + delta);
|
|
116948
116953
|
if (field === "reasoning") tail.thought(delta);
|
|
@@ -116950,12 +116955,12 @@ function createParts(tail) {
|
|
|
116950
116955
|
},
|
|
116951
116956
|
/** A piece of the turn, as `model.streaming` sends it. */
|
|
116952
116957
|
streaming(payload) {
|
|
116953
|
-
const kind =
|
|
116954
|
-
if (kind === "text_delta") return tail.text(
|
|
116955
|
-
if (kind === "reasoning_delta") return tail.thought(
|
|
116958
|
+
const kind = str(payload.kind);
|
|
116959
|
+
if (kind === "text_delta") return tail.text(str(payload.delta));
|
|
116960
|
+
if (kind === "reasoning_delta") return tail.thought(str(payload.delta));
|
|
116956
116961
|
if (kind !== "tool_call") return;
|
|
116957
|
-
const callId =
|
|
116958
|
-
const name =
|
|
116962
|
+
const callId = str(payload.toolCallId);
|
|
116963
|
+
const name = str(payload.toolName) || "tool";
|
|
116959
116964
|
named.set(callId, name);
|
|
116960
116965
|
if (callId && tools.has(callId)) return;
|
|
116961
116966
|
tools.add(callId);
|
|
@@ -116965,9 +116970,9 @@ function createParts(tail) {
|
|
|
116965
116970
|
* `batch` are progress on a call that already has its line; only `error` is worth a
|
|
116966
116971
|
* second one. */
|
|
116967
116972
|
toolUpdate(payload) {
|
|
116968
|
-
if (
|
|
116969
|
-
const name = named.get(
|
|
116970
|
-
const why2 =
|
|
116973
|
+
if (str(payload.kind) !== "error") return;
|
|
116974
|
+
const name = named.get(str(payload.toolCallId)) ?? "tool";
|
|
116975
|
+
const why2 = str(obj(payload.error).message).split("\n")[0].trim();
|
|
116971
116976
|
tail.line(`[error] ${name} failed${why2 ? `: ${why2.slice(0, 200)}` : ""}`);
|
|
116972
116977
|
}
|
|
116973
116978
|
};
|
|
@@ -117005,7 +117010,7 @@ async function oneTurn2(io, options) {
|
|
|
117005
117010
|
(msg) => {
|
|
117006
117011
|
if (msg.method === "session/event") {
|
|
117007
117012
|
const envelope = obj(msg.params);
|
|
117008
|
-
if (
|
|
117013
|
+
if (str(envelope.sessionId) === sessionId) event(envelope, parts, tail, live, ended2);
|
|
117009
117014
|
return;
|
|
117010
117015
|
}
|
|
117011
117016
|
if (msg.id === void 0) return;
|
|
@@ -117052,13 +117057,13 @@ async function oneTurn2(io, options) {
|
|
|
117052
117057
|
// The session's name is the board's business, not a model call of its own.
|
|
117053
117058
|
titleGenerationEnabled: false
|
|
117054
117059
|
});
|
|
117055
|
-
sessionId =
|
|
117060
|
+
sessionId = str(obj(opened.session).sessionId);
|
|
117056
117061
|
if (!sessionId) throw new Error("the agent opened a session without giving it an id");
|
|
117057
117062
|
io.gotResumeId(sessionId);
|
|
117058
117063
|
}
|
|
117059
117064
|
let model = modelOf2(obj(opened.session).model);
|
|
117060
117065
|
if (options.model) {
|
|
117061
|
-
const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId:
|
|
117066
|
+
const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId: str(obj(obj(opened.session).model).providerId) || "zai", modelId: options.model };
|
|
117062
117067
|
await rpc.call("session/setModel", { sessionId, model: wanted });
|
|
117063
117068
|
model = modelOf2(wanted);
|
|
117064
117069
|
}
|
|
@@ -117109,7 +117114,7 @@ async function contextOf(rpc, sessionId) {
|
|
|
117109
117114
|
}
|
|
117110
117115
|
function event(envelope, parts, tail, live, ended2) {
|
|
117111
117116
|
const payload = obj(envelope.payload);
|
|
117112
|
-
switch (
|
|
117117
|
+
switch (str(envelope.type)) {
|
|
117113
117118
|
case "part.started":
|
|
117114
117119
|
case "part.upserted":
|
|
117115
117120
|
if (live) parts.upsert(payload.part);
|
|
@@ -117125,23 +117130,23 @@ function event(envelope, parts, tail, live, ended2) {
|
|
|
117125
117130
|
return;
|
|
117126
117131
|
case "turn.completed": {
|
|
117127
117132
|
const usage = usageOf3(obj(payload.usage));
|
|
117128
|
-
const response =
|
|
117129
|
-
const how =
|
|
117133
|
+
const response = str(payload.response);
|
|
117134
|
+
const how = str(payload.resultType) || "success";
|
|
117130
117135
|
if (how === "success") return ended2({ ok: true, response, usage });
|
|
117131
117136
|
return ended2({ ok: false, error: STOPPED2[how] ?? `the agent stopped: ${how}`, response, usage });
|
|
117132
117137
|
}
|
|
117133
117138
|
case "turn.failed": {
|
|
117134
117139
|
const error = obj(payload.error);
|
|
117135
|
-
return ended2({ ok: false, error:
|
|
117140
|
+
return ended2({ ok: false, error: str(error.message) || "the turn failed" });
|
|
117136
117141
|
}
|
|
117137
117142
|
case "session.closed":
|
|
117138
|
-
return ended2({ ok: false, error:
|
|
117143
|
+
return ended2({ ok: false, error: str(payload.reason) || "the agent closed the session" });
|
|
117139
117144
|
default:
|
|
117140
117145
|
return;
|
|
117141
117146
|
}
|
|
117142
117147
|
}
|
|
117143
117148
|
function decide2(params, tail) {
|
|
117144
|
-
const tool =
|
|
117149
|
+
const tool = str(params.toolName) || "that";
|
|
117145
117150
|
tail.line(`[refused] ${tool} \u2014 your own ZCode rules ask before this one, and a run has nobody to ask`);
|
|
117146
117151
|
return { decision: "deny", reason: "this board run can't answer a permission question" };
|
|
117147
117152
|
}
|
|
@@ -117218,7 +117223,7 @@ function readReceipt(text4, work, execution) {
|
|
|
117218
117223
|
const expected = new Set(work.map((w2) => w2.id));
|
|
117219
117224
|
return value.items.map((raw) => {
|
|
117220
117225
|
const item = obj(raw);
|
|
117221
|
-
const id =
|
|
117226
|
+
const id = str(item.id), outcome = str(item.outcome);
|
|
117222
117227
|
if (!expected.delete(id) || !["collected", "stopped", "await", "keep", "unconfirmed"].includes(outcome) || typeof item.service !== "boolean" || typeof item.detail !== "string") throw Error("Codex cleanup receipt contains an invalid or duplicate entry.");
|
|
117223
117228
|
return { id, outcome, service: item.service, detail: summary(item.detail) };
|
|
117224
117229
|
});
|
|
@@ -117237,20 +117242,20 @@ function codexWork() {
|
|
|
117237
117242
|
const agent = (threadId, raw) => {
|
|
117238
117243
|
const id = `agent:${threadId}`;
|
|
117239
117244
|
const previous = entries.get(id);
|
|
117240
|
-
const status =
|
|
117245
|
+
const status = str(raw.status);
|
|
117241
117246
|
if (["shutdown", "notFound", "not_found"].includes(status) && previous && previous.status !== "running") return;
|
|
117242
117247
|
const state = ["pendingInit", "running", "pending_init"].includes(status) ? "running" : status === "completed" ? "completed" : ["interrupted", "shutdown"].includes(status) ? "interrupted" : ["errored", "notFound", "not_found"].includes(status) ? "failed" : void 0;
|
|
117243
117248
|
if (!state) return;
|
|
117244
|
-
entries.set(id, { ...previous, id, threadId, kind: "agent", status: state, result: summary(
|
|
117249
|
+
entries.set(id, { ...previous, id, threadId, kind: "agent", status: state, result: summary(str(raw.message)) });
|
|
117245
117250
|
};
|
|
117246
117251
|
const observe = (threadId, raw) => {
|
|
117247
117252
|
if (!own(threadId)) return;
|
|
117248
117253
|
if (raw.type === "subAgentActivity") {
|
|
117249
|
-
const child =
|
|
117254
|
+
const child = str(raw.agentThreadId);
|
|
117250
117255
|
if (raw.kind === "started" && child && child !== root2 && !children.has(child)) {
|
|
117251
117256
|
children.add(child);
|
|
117252
117257
|
agent(child, { status: "running" });
|
|
117253
|
-
entries.get(`agent:${child}`).agentPath =
|
|
117258
|
+
entries.get(`agent:${child}`).agentPath = str(raw.agentPath);
|
|
117254
117259
|
}
|
|
117255
117260
|
return;
|
|
117256
117261
|
}
|
|
@@ -117266,8 +117271,8 @@ function codexWork() {
|
|
|
117266
117271
|
}
|
|
117267
117272
|
for (const [id2, state] of Object.entries(obj(raw.agentsStates))) if (children.has(id2)) agent(id2, obj(state));
|
|
117268
117273
|
}
|
|
117269
|
-
if (raw.type !== "commandExecution" || !
|
|
117270
|
-
const id = terminalKey(threadId,
|
|
117274
|
+
if (raw.type !== "commandExecution" || !str(raw.id)) return;
|
|
117275
|
+
const id = terminalKey(threadId, str(raw.id));
|
|
117271
117276
|
const previous = entries.get(id);
|
|
117272
117277
|
const running = raw.status === "inProgress";
|
|
117273
117278
|
if (running && previous?.exitCode !== void 0) return;
|
|
@@ -117277,11 +117282,11 @@ function codexWork() {
|
|
|
117277
117282
|
id,
|
|
117278
117283
|
threadId,
|
|
117279
117284
|
kind: "terminal",
|
|
117280
|
-
itemId:
|
|
117281
|
-
processId:
|
|
117282
|
-
command: summary(
|
|
117285
|
+
itemId: str(raw.id),
|
|
117286
|
+
processId: str(raw.processId) || previous?.processId,
|
|
117287
|
+
command: summary(str(raw.command) || previous?.command || "", 600),
|
|
117283
117288
|
status: running ? "running" : exitCode !== void 0 ? exitCode === 0 ? "completed" : "failed" : "unknown",
|
|
117284
|
-
result: summary(
|
|
117289
|
+
result: summary(str(raw.aggregatedOutput) || previous?.result || ""),
|
|
117285
117290
|
exitCode
|
|
117286
117291
|
});
|
|
117287
117292
|
};
|
|
@@ -117297,11 +117302,11 @@ function codexWork() {
|
|
|
117297
117302
|
const turn2 = turns2[0];
|
|
117298
117303
|
for (const item of list(turn2?.items)) observe(threadId, item);
|
|
117299
117304
|
if (threadId !== root2) {
|
|
117300
|
-
const status =
|
|
117305
|
+
const status = str(turn2?.status);
|
|
117301
117306
|
if (obj(thread.status).type === "systemError") agent(threadId, { status: "errored", message: "Codex subagent reported a system error." });
|
|
117302
117307
|
else if (obj(thread.status).type !== "active" && ["completed", "failed", "interrupted"].includes(status)) {
|
|
117303
|
-
const message = list(turn2?.items).filter((i) => i.type === "agentMessage").map((i) =>
|
|
117304
|
-
agent(threadId, { status: status === "failed" ? "errored" : status, message:
|
|
117308
|
+
const message = list(turn2?.items).filter((i) => i.type === "agentMessage").map((i) => str(i.text)).join("\n\n");
|
|
117309
|
+
agent(threadId, { status: status === "failed" ? "errored" : status, message: str(obj(turn2?.error).message) || message });
|
|
117305
117310
|
}
|
|
117306
117311
|
}
|
|
117307
117312
|
return thread;
|
|
@@ -117337,7 +117342,7 @@ function codexWork() {
|
|
|
117337
117342
|
cursors.add(cursor);
|
|
117338
117343
|
const page = await rpc.call("thread/backgroundTerminals/list", { threadId, ...cursor ? { cursor } : {} });
|
|
117339
117344
|
for (const terminal of list(page.data)) {
|
|
117340
|
-
const itemId =
|
|
117345
|
+
const itemId = str(terminal.itemId), processId = str(terminal.processId);
|
|
117341
117346
|
if (!itemId || !processId) throw Error("Codex returned a background terminal without its complete handles.");
|
|
117342
117347
|
const id = terminalKey(threadId, itemId);
|
|
117343
117348
|
present.add(id);
|
|
@@ -117350,7 +117355,7 @@ function codexWork() {
|
|
|
117350
117355
|
itemId,
|
|
117351
117356
|
processId,
|
|
117352
117357
|
...typeof terminal.osPid === "number" ? { osPid: terminal.osPid } : {},
|
|
117353
|
-
command: summary(
|
|
117358
|
+
command: summary(str(terminal.command) || previous?.command || "", 600),
|
|
117354
117359
|
status: "running",
|
|
117355
117360
|
result: previous?.result ?? ""
|
|
117356
117361
|
});
|
|
@@ -117535,28 +117540,28 @@ async function run2(io, options, count2) {
|
|
|
117535
117540
|
};
|
|
117536
117541
|
const item = (raw, completed, proof = true) => {
|
|
117537
117542
|
if (ended2) return;
|
|
117538
|
-
const id =
|
|
117539
|
-
if (["collabAgentToolCall", "subAgentActivity"].includes(
|
|
117543
|
+
const id = str(raw.id);
|
|
117544
|
+
if (["collabAgentToolCall", "subAgentActivity"].includes(str(raw.type))) {
|
|
117540
117545
|
if (proof) began();
|
|
117541
117546
|
childUpdates();
|
|
117542
117547
|
return;
|
|
117543
117548
|
}
|
|
117544
117549
|
if (settlement && raw.type === "agentMessage") {
|
|
117545
|
-
if (completed && (!raw.phase || raw.phase === "final_answer")) settlement.text =
|
|
117550
|
+
if (completed && (!raw.phase || raw.phase === "final_answer")) settlement.text = str(raw.text);
|
|
117546
117551
|
return;
|
|
117547
117552
|
}
|
|
117548
117553
|
const key = `${id}:${completed}`;
|
|
117549
117554
|
if (seenItems.has(key)) return;
|
|
117550
117555
|
seenItems.add(key);
|
|
117551
117556
|
const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
|
|
117552
|
-
const type = types[
|
|
117557
|
+
const type = types[str(raw.type)];
|
|
117553
117558
|
if (!type) return;
|
|
117554
117559
|
if (proof) began();
|
|
117555
117560
|
emit(completed ? "item.completed" : "item.started", { item: {
|
|
117556
117561
|
...raw,
|
|
117557
117562
|
type,
|
|
117558
117563
|
...raw.type === "imageGeneration" ? { path: raw.savedPath ?? raw.path } : {},
|
|
117559
|
-
...raw.type === "fileChange" ? { changes: list2(raw.changes).map((c2) => ({ ...c2, kind:
|
|
117564
|
+
...raw.type === "fileChange" ? { changes: list2(raw.changes).map((c2) => ({ ...c2, kind: str(obj(c2.kind).type) || c2.kind })) } : {},
|
|
117560
117565
|
aggregated_output: raw.aggregatedOutput,
|
|
117561
117566
|
exit_code: raw.exitCode,
|
|
117562
117567
|
status: raw.status === "inProgress" ? "in_progress" : raw.status
|
|
@@ -117694,9 +117699,9 @@ async function run2(io, options, count2) {
|
|
|
117694
117699
|
return;
|
|
117695
117700
|
}
|
|
117696
117701
|
const p2 = obj(msg.params);
|
|
117697
|
-
const source2 =
|
|
117702
|
+
const source2 = str(p2.threadId);
|
|
117698
117703
|
if (!work.own(source2)) return;
|
|
117699
|
-
if (settlement && (msg.method === "item/commandExecution/terminalInteraction" || msg.method === "item/started" && ["commandExecution", "collabAgentToolCall", "subAgentActivity", "mcpToolCall"].includes(
|
|
117704
|
+
if (settlement && (msg.method === "item/commandExecution/terminalInteraction" || msg.method === "item/started" && ["commandExecution", "collabAgentToolCall", "subAgentActivity", "mcpToolCall"].includes(str(obj(p2.item).type)))) settlement.operated = true;
|
|
117700
117705
|
if (msg.method === "item/started" || msg.method === "item/completed") {
|
|
117701
117706
|
work.observe(source2, obj(p2.item));
|
|
117702
117707
|
if (source2 === threadId && obj(p2.item).type !== "agentMessage") item(obj(p2.item), msg.method === "item/completed", false);
|
|
@@ -117705,7 +117710,7 @@ async function run2(io, options, count2) {
|
|
|
117705
117710
|
childUpdates();
|
|
117706
117711
|
return;
|
|
117707
117712
|
}
|
|
117708
|
-
const turnId =
|
|
117713
|
+
const turnId = str(p2.turnId) || str(obj(p2.turn).id);
|
|
117709
117714
|
if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
|
|
117710
117715
|
if (msg.method === "turn/started") {
|
|
117711
117716
|
if (!submitted || completedTurns.has(turnId)) return;
|
|
@@ -117737,10 +117742,10 @@ async function run2(io, options, count2) {
|
|
|
117737
117742
|
context = { used: (Number(last.inputTokens) || 0) + (Number(last.outputTokens) || 0), ...Number(token.modelContextWindow) > 0 ? { limit: Number(token.modelContextWindow) } : {} };
|
|
117738
117743
|
io.gotContext?.(context);
|
|
117739
117744
|
}
|
|
117740
|
-
if (msg.method === "error" && p2.willRetry !== true) end(
|
|
117745
|
+
if (msg.method === "error" && p2.willRetry !== true) end(str(obj(p2.error).message) || "Codex failed.");
|
|
117741
117746
|
if (msg.method === "turn/completed") {
|
|
117742
117747
|
const turn2 = obj(p2.turn);
|
|
117743
|
-
const id =
|
|
117748
|
+
const id = str(turn2.id);
|
|
117744
117749
|
if (completedTurns.has(id)) return;
|
|
117745
117750
|
completedTurns.add(id);
|
|
117746
117751
|
for (const raw of list2(turn2.items)) {
|
|
@@ -117748,7 +117753,7 @@ async function run2(io, options, count2) {
|
|
|
117748
117753
|
item(raw, true);
|
|
117749
117754
|
}
|
|
117750
117755
|
if (turn2.status !== "completed") {
|
|
117751
|
-
end(
|
|
117756
|
+
end(str(obj(turn2.error).message) || `Codex turn ${str(turn2.status)}.`);
|
|
117752
117757
|
return;
|
|
117753
117758
|
}
|
|
117754
117759
|
active = false;
|
|
@@ -117766,7 +117771,7 @@ async function run2(io, options, count2) {
|
|
|
117766
117771
|
phase("preparing");
|
|
117767
117772
|
const initialized = await bounded(rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), preparingUntil - Date.now(), "Codex initialize timed out.");
|
|
117768
117773
|
host = obj(initialized.wildcrane);
|
|
117769
|
-
if (host.instance) cleanup.instance =
|
|
117774
|
+
if (host.instance) cleanup.instance = str(host.instance);
|
|
117770
117775
|
phase("initialized");
|
|
117771
117776
|
rpc.notify("initialized");
|
|
117772
117777
|
const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
|
|
@@ -117778,12 +117783,12 @@ async function run2(io, options, count2) {
|
|
|
117778
117783
|
throw e2;
|
|
117779
117784
|
}
|
|
117780
117785
|
const thread = obj(response.thread);
|
|
117781
|
-
for (const turn2 of list2(thread.turns)) historicalTurns.add(
|
|
117782
|
-
threadId =
|
|
117786
|
+
for (const turn2 of list2(thread.turns)) historicalTurns.add(str(turn2.id));
|
|
117787
|
+
threadId = str(thread.id);
|
|
117783
117788
|
if (!threadId) throw Error("Codex did not return a thread id.");
|
|
117784
|
-
work.root(threadId, list2(response.retainedThreads).map((t) =>
|
|
117785
|
-
provider =
|
|
117786
|
-
model =
|
|
117789
|
+
work.root(threadId, list2(response.retainedThreads).map((t) => str(t.id)));
|
|
117790
|
+
provider = str(thread.modelProvider) || void 0;
|
|
117791
|
+
model = str(response.model) || str(thread.model) || void 0;
|
|
117787
117792
|
if (model) io.gotModel(model);
|
|
117788
117793
|
io.gotResumeId(threadId);
|
|
117789
117794
|
baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total ?? (!options.threadId && !io.resumeId ? ZERO_USAGE : void 0);
|
|
@@ -117938,7 +117943,6 @@ function quoteArg(arg) {
|
|
|
117938
117943
|
import { createHash as createHash3 } from "node:crypto";
|
|
117939
117944
|
import fs25 from "node:fs";
|
|
117940
117945
|
import path26 from "node:path";
|
|
117941
|
-
var SKILL_SENTENCE = "Use the kanban skill";
|
|
117942
117946
|
function namesFlag(argv, flags) {
|
|
117943
117947
|
return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
|
|
117944
117948
|
}
|
|
@@ -118380,22 +118384,22 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
118380
118384
|
`;
|
|
118381
118385
|
}
|
|
118382
118386
|
if (e2.event === "init") {
|
|
118383
|
-
const got =
|
|
118387
|
+
const got = str(e2.conversation_id);
|
|
118384
118388
|
if (expectedSession && got !== expectedSession) {
|
|
118385
118389
|
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.");
|
|
118386
118390
|
return "";
|
|
118387
118391
|
}
|
|
118388
118392
|
session = got || session;
|
|
118389
|
-
model =
|
|
118393
|
+
model = str(obj(e2.init).model) || model;
|
|
118390
118394
|
return "";
|
|
118391
118395
|
}
|
|
118392
118396
|
if (e2.event === "step_update") {
|
|
118393
118397
|
const step = obj(e2.step_update);
|
|
118394
|
-
if (expectedSession &&
|
|
118395
|
-
session =
|
|
118398
|
+
if (expectedSession && str(step.conversation_id) !== expectedSession) return "";
|
|
118399
|
+
session = str(step.conversation_id) || session;
|
|
118396
118400
|
const id = String(step.step_index ?? "");
|
|
118397
118401
|
if (step.step_type === "agent_response") {
|
|
118398
|
-
const text4 =
|
|
118402
|
+
const text4 = str(step.text_delta);
|
|
118399
118403
|
if (text4) events.update({ sessionUpdate: "agent_message_chunk", content: { text: text4 } });
|
|
118400
118404
|
const index = num(step.step_index);
|
|
118401
118405
|
if (step.state === "DONE" && step.usage && !counted.has(index)) {
|
|
@@ -118407,9 +118411,9 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
118407
118411
|
}
|
|
118408
118412
|
if (step.step_type === "tool") {
|
|
118409
118413
|
const tool = obj(step.tool_info);
|
|
118410
|
-
const name =
|
|
118414
|
+
const name = str(tool.name) || str(step.tool_name) || "tool";
|
|
118411
118415
|
const p2 = obj(tool.parameters);
|
|
118412
|
-
const target =
|
|
118416
|
+
const target = str(p2.CommandLine) || str(p2.Path) || str(p2.TargetFile) || str(p2.AbsolutePath) || str(p2.Query);
|
|
118413
118417
|
let out = "";
|
|
118414
118418
|
if (!calls.has(id)) {
|
|
118415
118419
|
calls.add(id);
|
|
@@ -118419,11 +118423,11 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
118419
118423
|
`;
|
|
118420
118424
|
}
|
|
118421
118425
|
const error = obj(tool.error);
|
|
118422
|
-
const reason =
|
|
118426
|
+
const reason = str(error.message) || str(error.type);
|
|
118423
118427
|
if (reason && /permission|denied|soft.den/i.test(reason)) fail(reason);
|
|
118424
|
-
if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(
|
|
118428
|
+
if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str(step.state)) && !closed.has(id)) {
|
|
118425
118429
|
closed.add(id);
|
|
118426
|
-
events.toolResult(id, reason || step.state !== "DONE" ? "failed" : "completed",
|
|
118430
|
+
events.toolResult(id, reason || step.state !== "DONE" ? "failed" : "completed", str(tool.output) || reason);
|
|
118427
118431
|
}
|
|
118428
118432
|
return out;
|
|
118429
118433
|
}
|
|
@@ -118431,12 +118435,12 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
118431
118435
|
}
|
|
118432
118436
|
if (e2.event === "result") {
|
|
118433
118437
|
const result = obj(e2.result);
|
|
118434
|
-
if (expectedSession &&
|
|
118438
|
+
if (expectedSession && str(result.conversation_id) && result.conversation_id !== expectedSession) {
|
|
118435
118439
|
fail(translating() ? "Antigravity \u672A\u7EED\u63A5\u6307\u5B9A\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u539F\u4F1A\u8BDD\u540E\u91CD\u8BD5\u3002" : "Antigravity did not resume the requested conversation.");
|
|
118436
118440
|
terminal = true;
|
|
118437
118441
|
return "";
|
|
118438
118442
|
}
|
|
118439
|
-
session =
|
|
118443
|
+
session = str(result.conversation_id) || session;
|
|
118440
118444
|
terminal = true;
|
|
118441
118445
|
final = typeof result.response === "string" ? result.response : void 0;
|
|
118442
118446
|
const total = usageOf4(result.usage);
|
|
@@ -118444,8 +118448,8 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
118444
118448
|
previous = total;
|
|
118445
118449
|
if (!Object.values(used).some((n) => n > 0)) used = void 0;
|
|
118446
118450
|
if (Array.isArray(result.denied_actions) && result.denied_actions.length) fail(translating() ? "Antigravity \u6743\u9650\u62D2\u7EDD\uFF0C\u8BF7\u68C0\u67E5\u6743\u9650\u89C4\u5219\u540E\u91CD\u8BD5\u3002" : "Antigravity permission denied. Check permission rules, then retry.");
|
|
118447
|
-
if (typeof result.response !== "string" || result.status !== "SUCCESS" ||
|
|
118448
|
-
fail(
|
|
118451
|
+
if (typeof result.response !== "string" || result.status !== "SUCCESS" || str(result.error) || result.finished_reason && result.finished_reason !== "completed" && result.finished_reason !== "success") {
|
|
118452
|
+
fail(str(result.error) || `Antigravity: ${str(result.status) || "missing status"}`);
|
|
118449
118453
|
}
|
|
118450
118454
|
events.end();
|
|
118451
118455
|
turnUsage = zero();
|
|
@@ -118543,7 +118547,6 @@ ${rule}
|
|
|
118543
118547
|
adoptsSessionId: false,
|
|
118544
118548
|
savesSessionAtOpen: false,
|
|
118545
118549
|
stopsOnRateLimit: false,
|
|
118546
|
-
skillCall: SKILL_SENTENCE,
|
|
118547
118550
|
// `models` is read-only. Only explicit authentication errors mean signed out.
|
|
118548
118551
|
login: {
|
|
118549
118552
|
args: ["models"],
|
|
@@ -118941,8 +118944,6 @@ var CLAUDE_CODE = {
|
|
|
118941
118944
|
savesSessionAtOpen: false,
|
|
118942
118945
|
// Its own Read tool opens an image file, so a path in the message is the whole of it.
|
|
118943
118946
|
images: { as: "message" },
|
|
118944
|
-
// Claude Code loads a skill from its slash name.
|
|
118945
|
-
skillCall: "/kanban",
|
|
118946
118947
|
// `claude auth status` prints one JSON object saying whether it is signed in and how. Its
|
|
118947
118948
|
// `loggedIn` flag is read, not its exit code: this one does set the code, and two of the
|
|
118948
118949
|
// other three leave it at 0 in both states, so the output is the rule everywhere.
|
|
@@ -119301,10 +119302,6 @@ var CODEX = {
|
|
|
119301
119302
|
// tokens it would swallow the prompt that follows it as a second file — Codex would then
|
|
119302
119303
|
// read the prompt from a stdin the board never opens and send an empty turn.
|
|
119303
119304
|
images: { as: "args", args: (file2) => [`--image=${file2}`] },
|
|
119304
|
-
// Codex ignores a slash name — it reads as plain chat text — and triggers a skill from a
|
|
119305
|
-
// `$` name. The install already writes the skill to `.agents/skills/kanban/`, which is
|
|
119306
|
-
// where Codex looks.
|
|
119307
|
-
skillCall: "$kanban",
|
|
119308
119305
|
// `codex login status` prints one line and nothing else: "Logged in using ChatGPT" —
|
|
119309
119306
|
// or an API key, which is why the reading stops at the first two words — and "Not logged
|
|
119310
119307
|
// in".
|
|
@@ -119365,7 +119362,6 @@ var CURSOR = {
|
|
|
119365
119362
|
savesSessionAtOpen: false,
|
|
119366
119363
|
// Its own file reading opens a picture from a path written into the words.
|
|
119367
119364
|
images: { as: "message" },
|
|
119368
|
-
skillCall: SKILL_SENTENCE,
|
|
119369
119365
|
// `cursor-agent status` exits 0 whether or not anybody is signed in, so its output is the
|
|
119370
119366
|
// whole of the answer.
|
|
119371
119367
|
login: {
|
|
@@ -119477,9 +119473,6 @@ ${text4}` } };
|
|
|
119477
119473
|
// And it has written that session down before it answers: killed right after
|
|
119478
119474
|
// `session/new`, dsh-acp reopens the id from a fresh command about half a second later.
|
|
119479
119475
|
savesSessionAtOpen: true,
|
|
119480
|
-
// dsh has no slash or `$` skill syntax a headless run can use, so the prompt asks for the
|
|
119481
|
-
// skill in a sentence. It reads `.agents/skills/`, the folder an install already writes.
|
|
119482
|
-
skillCall: SKILL_SENTENCE,
|
|
119483
119476
|
// No login probe: dsh has no login to probe. Its own command offers `web` and `plugin` and
|
|
119484
119477
|
// nothing else — a run signs with the key in `$DSH_HOME`'s settings, or with the box above
|
|
119485
119478
|
// — so there is no CLI sign-in for a logged-out reading to be about.
|
|
@@ -119586,10 +119579,6 @@ var GROK = {
|
|
|
119586
119579
|
// And it has written that session down before it answers: killed the instant
|
|
119587
119580
|
// `session/new` returns, grok reopens the id from a fresh command.
|
|
119588
119581
|
savesSessionAtOpen: true,
|
|
119589
|
-
// Grok lists its skills as slash names, but a slash typed into an ACP `session/prompt` is
|
|
119590
|
-
// not the same thing as one typed into its TUI, and the sentence is proved: asked this
|
|
119591
|
-
// way, grok found `.agents/skills/kanban/SKILL.md` in the project and read it.
|
|
119592
|
-
skillCall: SKILL_SENTENCE,
|
|
119593
119582
|
installs: () => [...process.env.GROK_BIN_DIR ? [join4(process.env.GROK_BIN_DIR, "grok")] : [], home2(".grok", "bin", "grok")],
|
|
119594
119583
|
install: "curl -fsSL https://x.ai/cli/install.sh | bash"
|
|
119595
119584
|
};
|
|
@@ -119788,13 +119777,6 @@ ${text4}
|
|
|
119788
119777
|
// Kimi names its own session, and prints the id as its closing row.
|
|
119789
119778
|
adoptsSessionId: false,
|
|
119790
119779
|
savesSessionAtOpen: false,
|
|
119791
|
-
// Kimi does have a slash name for a skill — `/skill:kanban` — but whether one typed into
|
|
119792
|
-
// a `-p` prompt is read as a command or as plain chat text is unprobed. The sentence
|
|
119793
|
-
// works either way, because Kimi's model picks a skill from its description on its own.
|
|
119794
|
-
//
|
|
119795
|
-
// PROBE: if `/skill:kanban` triggers the skill from a `-p` prompt, this becomes that and
|
|
119796
|
-
// the connector stops showing a "Direct skill call" gap.
|
|
119797
|
-
skillCall: SKILL_SENTENCE,
|
|
119798
119780
|
// No login probe, so Kimi is never called logged out. `kimi login` is the way in, but
|
|
119799
119781
|
// nothing was found that PRINTS whether that login is there, and `kimi` was not on the
|
|
119800
119782
|
// machine this was written on to read one off — and a reading nobody has seen is exactly
|
|
@@ -119878,9 +119860,6 @@ var OPENCODE = {
|
|
|
119878
119860
|
savesSessionAtOpen: true,
|
|
119879
119861
|
// Its own file reading opens a picture from a path written into the words.
|
|
119880
119862
|
images: { as: "message" },
|
|
119881
|
-
// No slash or `$` skill syntax in a sent message, so the prompt asks for the skill in a
|
|
119882
|
-
// sentence. It scans `.agents/skills/` and `.claude/skills/`, where an install writes.
|
|
119883
|
-
skillCall: SKILL_SENTENCE,
|
|
119884
119863
|
// No login probe: OpenCode's free models need no sign-in, so a machine with no saved
|
|
119885
119864
|
// credential is not logged out.
|
|
119886
119865
|
installs: () => [...process.env.OPENCODE_INSTALL_DIR ? [join6(process.env.OPENCODE_INSTALL_DIR, "opencode")] : [], home2(".opencode", "bin", "opencode")],
|
|
@@ -119978,10 +119957,6 @@ var ZCODE = {
|
|
|
119978
119957
|
// answers "Session not found" ten seconds after the id came back. So a ZCode run that
|
|
119979
119958
|
// dies before its first turn has nothing to go back to.
|
|
119980
119959
|
savesSessionAtOpen: false,
|
|
119981
|
-
// ZCode's slash and `$` names are its terminal UI's, not something a sent prompt
|
|
119982
|
-
// triggers, so the prompt asks for the skill in a sentence. It reads `.agents/skills/`,
|
|
119983
|
-
// the folder an install already writes, and finds the board's rules there by itself.
|
|
119984
|
-
skillCall: SKILL_SENTENCE,
|
|
119985
119960
|
// No login probe: a ZCode run signs with the Coding Plan key above and never with a
|
|
119986
119961
|
// `zcode login`, whose credential the command's own config never points at (#282). Its
|
|
119987
119962
|
// CLI's login decides nothing here, so there is nothing to warn about.
|
|
@@ -120277,8 +120252,8 @@ function cursorModels() {
|
|
|
120277
120252
|
function acpModels(opened) {
|
|
120278
120253
|
const list3 = obj(opened.models).availableModels;
|
|
120279
120254
|
return (Array.isArray(list3) ? list3 : []).map(obj).flatMap((m) => {
|
|
120280
|
-
const id =
|
|
120281
|
-
return id && id !== "default[]" ? [{ id, name:
|
|
120255
|
+
const id = str(m.modelId);
|
|
120256
|
+
return id && id !== "default[]" ? [{ id, name: str(m.name) || id }] : [];
|
|
120282
120257
|
});
|
|
120283
120258
|
}
|
|
120284
120259
|
function output(command, args2) {
|
|
@@ -120325,7 +120300,7 @@ function claudeModels(dir) {
|
|
|
120325
120300
|
try {
|
|
120326
120301
|
const data = obj(JSON.parse(fs31.readFileSync(path34.join(dir, f2), "utf8")));
|
|
120327
120302
|
const catalog = obj(data.catalog);
|
|
120328
|
-
const surface =
|
|
120303
|
+
const surface = str(catalog.surface);
|
|
120329
120304
|
return surface === "cc" || surface === "ccd" ? [{ surface, at: Number(data.fetchedAt) || 0, config: obj(catalog.config) }] : [];
|
|
120330
120305
|
} catch {
|
|
120331
120306
|
return [];
|
|
@@ -120336,11 +120311,11 @@ function claudeModels(dir) {
|
|
|
120336
120311
|
const aliases = obj(newest2.config.provider_alias_targets);
|
|
120337
120312
|
const models = Array.isArray(newest2.config.models) ? newest2.config.models : [];
|
|
120338
120313
|
return models.map(obj).flatMap((m) => {
|
|
120339
|
-
const id =
|
|
120314
|
+
const id = str(m.id);
|
|
120340
120315
|
if (!id || m.section !== "main") return [];
|
|
120341
|
-
const family =
|
|
120342
|
-
const alias = family &&
|
|
120343
|
-
return [{ id: alias || id, name:
|
|
120316
|
+
const family = str(obj(m.runtime).family);
|
|
120317
|
+
const alias = family && str(obj(aliases[family]).default) === id ? family : "";
|
|
120318
|
+
return [{ id: alias || id, name: str(m.short_name) || str(m.name) || id }];
|
|
120344
120319
|
});
|
|
120345
120320
|
}
|
|
120346
120321
|
function probeLogin(binary, harness) {
|
|
@@ -120995,7 +120970,7 @@ ${pictures(job, ws, ws.number)}`);
|
|
|
120995
120970
|
return { ok: true, report: { card: card2 } };
|
|
120996
120971
|
}
|
|
120997
120972
|
function carryArgs(verb) {
|
|
120998
|
-
if (!["refine", "resolve", "revise"
|
|
120973
|
+
if (!["refine", "resolve", "revise"].includes(verb)) return [];
|
|
120999
120974
|
const transcript = writeTranscript(job, path37.join(ws.board, ".sync", `${ws.task}.discussion`));
|
|
121000
120975
|
return [
|
|
121001
120976
|
...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
|