wildcrane-runner 0.6.26 → 0.6.27
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 +9 -0
- package/dist/akb/dist/kanban.mjs +1379 -824
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +515 -421
- package/dist/runner.mjs +598 -290
- package/package.json +1 -1
package/dist/runner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.27 — 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;
|
|
@@ -34205,13 +34205,13 @@ var require_react_dom_server_node_production = __commonJS({
|
|
|
34205
34205
|
var target = currentView;
|
|
34206
34206
|
0 < writtenBytes && (target = currentView.subarray(writtenBytes));
|
|
34207
34207
|
target = textEncoder.encodeInto(chunk, target);
|
|
34208
|
-
var
|
|
34208
|
+
var read3 = target.read;
|
|
34209
34209
|
writtenBytes += target.written;
|
|
34210
|
-
|
|
34210
|
+
read3 < chunk.length && (writeToDestination(
|
|
34211
34211
|
destination,
|
|
34212
34212
|
currentView.subarray(0, writtenBytes)
|
|
34213
34213
|
), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
|
|
34214
|
-
chunk.slice(
|
|
34214
|
+
chunk.slice(read3),
|
|
34215
34215
|
currentView
|
|
34216
34216
|
).written);
|
|
34217
34217
|
4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
|
|
@@ -47961,13 +47961,13 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
47961
47961
|
var target = currentView;
|
|
47962
47962
|
0 < writtenBytes && (target = currentView.subarray(writtenBytes));
|
|
47963
47963
|
target = textEncoder.encodeInto(chunk, target);
|
|
47964
|
-
var
|
|
47964
|
+
var read3 = target.read;
|
|
47965
47965
|
writtenBytes += target.written;
|
|
47966
|
-
|
|
47966
|
+
read3 < chunk.length && (writeToDestination(
|
|
47967
47967
|
destination,
|
|
47968
47968
|
currentView.subarray(0, writtenBytes)
|
|
47969
47969
|
), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
|
|
47970
|
-
chunk.slice(
|
|
47970
|
+
chunk.slice(read3),
|
|
47971
47971
|
currentView
|
|
47972
47972
|
).written);
|
|
47973
47973
|
4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
|
|
@@ -85861,6 +85861,32 @@ var init_tailwindcss = __esm({
|
|
|
85861
85861
|
}
|
|
85862
85862
|
});
|
|
85863
85863
|
|
|
85864
|
+
// ../cli/src/lib/dress-page.ts
|
|
85865
|
+
import fs28 from "node:fs";
|
|
85866
|
+
import path32 from "node:path";
|
|
85867
|
+
function dressPage(file2) {
|
|
85868
|
+
const folder = path32.dirname(file2);
|
|
85869
|
+
const html = fs28.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
85870
|
+
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
85871
|
+
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
85872
|
+
const at3 = path32.resolve(folder, href);
|
|
85873
|
+
if (!at3.startsWith(folder + path32.sep) || !fs28.existsSync(at3)) return tag;
|
|
85874
|
+
const css = fs28.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path32.relative(folder, path32.resolve(path32.dirname(at3), src)).split(path32.sep).join("/")}${quote2})`);
|
|
85875
|
+
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
85876
|
+
});
|
|
85877
|
+
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
85878
|
+
return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
|
|
85879
|
+
}
|
|
85880
|
+
var CSP, head, referenceText;
|
|
85881
|
+
var init_dress_page = __esm({
|
|
85882
|
+
"../cli/src/lib/dress-page.ts"() {
|
|
85883
|
+
"use strict";
|
|
85884
|
+
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
85885
|
+
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
85886
|
+
referenceText = (file2) => /\.html$/i.test(file2) ? dressPage(file2) : fs28.readFileSync(file2, "utf8");
|
|
85887
|
+
}
|
|
85888
|
+
});
|
|
85889
|
+
|
|
85864
85890
|
// ../cli/node_modules/react-icons/lib/iconsManifest.mjs
|
|
85865
85891
|
var init_iconsManifest = __esm({
|
|
85866
85892
|
"../cli/node_modules/react-icons/lib/iconsManifest.mjs"() {
|
|
@@ -110840,8 +110866,8 @@ var init_dist = __esm({
|
|
|
110840
110866
|
});
|
|
110841
110867
|
|
|
110842
110868
|
// ../cli/src/lib/draw-mockup.ts
|
|
110843
|
-
import
|
|
110844
|
-
import
|
|
110869
|
+
import fs29 from "node:fs";
|
|
110870
|
+
import path33 from "node:path";
|
|
110845
110871
|
import vm from "node:vm";
|
|
110846
110872
|
async function loadPackage(id) {
|
|
110847
110873
|
if (id === "react") return import_react3.default;
|
|
@@ -110854,22 +110880,22 @@ async function loadPackage(id) {
|
|
|
110854
110880
|
return { __esModule: true, ...await load() };
|
|
110855
110881
|
}
|
|
110856
110882
|
function resolveFile(id, from, folder) {
|
|
110857
|
-
const at2 =
|
|
110858
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
110859
|
-
const tries =
|
|
110860
|
-
const file2 = tries.find((f2) =>
|
|
110883
|
+
const at2 = path33.resolve(path33.dirname(from), id);
|
|
110884
|
+
if (at2 !== folder && !at2.startsWith(folder + path33.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
110885
|
+
const tries = path33.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path33.join(at2, `index${e2}`))];
|
|
110886
|
+
const file2 = tries.find((f2) => fs29.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
110861
110887
|
if (!file2) throw new Error(`no such file: ${id}`);
|
|
110862
110888
|
return file2;
|
|
110863
110889
|
}
|
|
110864
110890
|
async function readGraph(entry) {
|
|
110865
|
-
const folder =
|
|
110891
|
+
const folder = path33.dirname(entry);
|
|
110866
110892
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
110867
110893
|
const walk = async (file2) => {
|
|
110868
110894
|
if (graph.code.has(file2)) return;
|
|
110869
110895
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
110870
110896
|
let location = file2;
|
|
110871
110897
|
try {
|
|
110872
|
-
const js = (0, import_sucrase.transform)(
|
|
110898
|
+
const js = (0, import_sucrase.transform)(fs29.readFileSync(file2, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file2 }).code;
|
|
110873
110899
|
graph.code.set(file2, js);
|
|
110874
110900
|
const link = /* @__PURE__ */ new Map();
|
|
110875
110901
|
graph.links.set(file2, link);
|
|
@@ -110883,7 +110909,7 @@ async function readGraph(entry) {
|
|
|
110883
110909
|
const target = resolveFile(id, file2, folder);
|
|
110884
110910
|
link.set(id, target);
|
|
110885
110911
|
if (!target.endsWith(".css")) await walk(target);
|
|
110886
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
110912
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs29.readFileSync(target, "utf8") });
|
|
110887
110913
|
}
|
|
110888
110914
|
} catch (error) {
|
|
110889
110915
|
throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -110900,29 +110926,17 @@ function run(script, context, name, deadline, lineOffset = 0) {
|
|
|
110900
110926
|
async function tailwindFor(markup, sheets) {
|
|
110901
110927
|
const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
110902
110928
|
const compiler = await rc(source, {
|
|
110903
|
-
base: sheets.length ?
|
|
110929
|
+
base: sheets.length ? path33.dirname(sheets[0].path) : "/",
|
|
110904
110930
|
loadStylesheet: async (id, from) => {
|
|
110905
110931
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
110906
110932
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
110907
|
-
const at2 =
|
|
110908
|
-
return { path: at2, base:
|
|
110933
|
+
const at2 = path33.resolve(from, id);
|
|
110934
|
+
return { path: at2, base: path33.dirname(at2), content: fs29.readFileSync(at2, "utf8") };
|
|
110909
110935
|
}
|
|
110910
110936
|
});
|
|
110911
110937
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
110912
110938
|
return compiler.build(classes.filter(Boolean));
|
|
110913
110939
|
}
|
|
110914
|
-
function dressPage(file2) {
|
|
110915
|
-
const folder = path32.dirname(file2);
|
|
110916
|
-
const html = fs28.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
110917
|
-
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
110918
|
-
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
110919
|
-
const at3 = path32.resolve(folder, href);
|
|
110920
|
-
if (!at3.startsWith(folder + path32.sep) || !fs28.existsSync(at3)) return tag;
|
|
110921
|
-
return `<style>${fs28.readFileSync(at3, "utf8").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
110922
|
-
});
|
|
110923
|
-
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
110924
|
-
return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
|
|
110925
|
-
}
|
|
110926
110940
|
async function drawMockup(entry) {
|
|
110927
110941
|
if (entry.toLowerCase().endsWith(".html")) return dressPage(entry);
|
|
110928
110942
|
const graph = await readGraph(entry);
|
|
@@ -110969,7 +110983,7 @@ ${graph.code.get(file2)}
|
|
|
110969
110983
|
const css = (await tailwindFor(markup, graph.sheets)).replace(/<\/style/gi, "<\\/style");
|
|
110970
110984
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
110971
110985
|
}
|
|
110972
|
-
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES
|
|
110986
|
+
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES;
|
|
110973
110987
|
var init_draw_mockup = __esm({
|
|
110974
110988
|
"../cli/src/lib/draw-mockup.ts"() {
|
|
110975
110989
|
"use strict";
|
|
@@ -110979,6 +110993,7 @@ var init_draw_mockup = __esm({
|
|
|
110979
110993
|
import_sucrase = __toESM(require_dist2(), 1);
|
|
110980
110994
|
init_lib();
|
|
110981
110995
|
init_tailwindcss();
|
|
110996
|
+
init_dress_page();
|
|
110982
110997
|
DRAW_MS = 5e3;
|
|
110983
110998
|
MAX_FILES = 60;
|
|
110984
110999
|
CODE_EXTS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
@@ -111021,8 +111036,6 @@ var init_draw_mockup = __esm({
|
|
|
111021
111036
|
"tailwind-merge": () => Promise.resolve().then(() => (init_bundle_mjs(), bundle_mjs_exports)),
|
|
111022
111037
|
"class-variance-authority": () => Promise.resolve().then(() => (init_dist(), dist_exports))
|
|
111023
111038
|
};
|
|
111024
|
-
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; media-src data:; font-src data:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
111025
|
-
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
111026
111039
|
}
|
|
111027
111040
|
});
|
|
111028
111041
|
|
|
@@ -111225,12 +111238,12 @@ var import_undici = __toESM(require_undici(), 1);
|
|
|
111225
111238
|
// ../cli/src/lib/agent/proxy.ts
|
|
111226
111239
|
import { execFileSync } from "node:child_process";
|
|
111227
111240
|
var PROXY_KEYS = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"];
|
|
111228
|
-
function withSystemProxy(env2 = process.env, platform = process.platform,
|
|
111241
|
+
function withSystemProxy(env2 = process.env, platform = process.platform, read3 = () => execFileSync("/usr/sbin/scutil", ["--proxy"], { encoding: "utf8", timeout: 1e3, stdio: ["ignore", "pipe", "ignore"] })) {
|
|
111229
111242
|
const out = { ...env2 };
|
|
111230
111243
|
if (platform !== "darwin" || PROXY_KEYS.some((key) => env2[key] !== void 0)) return out;
|
|
111231
111244
|
let raw;
|
|
111232
111245
|
try {
|
|
111233
|
-
raw =
|
|
111246
|
+
raw = read3();
|
|
111234
111247
|
} catch {
|
|
111235
111248
|
return out;
|
|
111236
111249
|
}
|
|
@@ -111272,8 +111285,8 @@ function hostProxy() {
|
|
|
111272
111285
|
[...PROXY_KEYS, "NO_PROXY", "no_proxy"].flatMap((key) => process.env[key] === void 0 ? [] : [[key, process.env[key]]])
|
|
111273
111286
|
);
|
|
111274
111287
|
}
|
|
111275
|
-
function followProxy(
|
|
111276
|
-
current =
|
|
111288
|
+
function followProxy(read3) {
|
|
111289
|
+
current = read3 ? withSystemProxy(hostProxy(), process.platform, read3) : withSystemProxy(hostProxy());
|
|
111277
111290
|
const httpProxy = current.HTTP_PROXY || current.http_proxy || current.ALL_PROXY || current.all_proxy || void 0;
|
|
111278
111291
|
const route = {
|
|
111279
111292
|
httpProxy,
|
|
@@ -111336,13 +111349,13 @@ var ZH = {
|
|
|
111336
111349
|
signIn: (url) => `\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u767B\u5F55 WildCrane\uFF1A
|
|
111337
111350
|
${url}`,
|
|
111338
111351
|
signedIn: () => "\u5DF2\u767B\u5F55",
|
|
111339
|
-
signInFailed: (
|
|
111352
|
+
signInFailed: (why2) => `\u767B\u5F55\u672A\u5B8C\u6210\uFF1A${why2}`,
|
|
111340
111353
|
connected: (machine) => `\u5DF2\u8FDE\u63A5\uFF08${machine}\uFF09\uFF0C\u7B49\u5F85\u4EFB\u52A1`,
|
|
111341
111354
|
running: (count2) => `\u6B63\u5728\u8FD0\u884C ${count2} \u4E2A\u4EFB\u52A1`,
|
|
111342
111355
|
reconnecting: () => "\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE\u2026",
|
|
111343
111356
|
elsewhere: (machine) => `\u4F60\u7684 Runner \u5DF2\u5728\u300C${machine}\u300D\u4E0A\u8FDE\u63A5\u3002\u8BF7\u5148\u5728\u90A3\u53F0\u7535\u8111\u4E0A\u9000\u51FA\uFF0C\u518D\u5728\u8FD9\u91CC\u542F\u52A8\u3002`,
|
|
111344
111357
|
outdated: () => "\u6B64\u7248\u672C\u5DF2\u8FC7\u65E7\uFF0C\u8BF7\u91CD\u542F\u4EE5\u66F4\u65B0\u3002",
|
|
111345
|
-
refused: (
|
|
111358
|
+
refused: (why2) => `WildCrane \u62D2\u7EDD\u4E86\u8FDE\u63A5\uFF1A${why2}`,
|
|
111346
111359
|
updated: (version) => `\u5DF2\u66F4\u65B0\u5230 ${version}`,
|
|
111347
111360
|
rolledBack: (version) => `\u65B0\u7248\u672C\u672A\u80FD\u542F\u52A8\uFF0C\u5DF2\u9000\u56DE ${version}`,
|
|
111348
111361
|
nodeTooOld: (range) => `\u65B0\u7248\u672C\u9700\u8981 Node ${range}\uFF0C\u8BF7\u5347\u7EA7 Node\u3002\u672C\u6B21\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D\u7248\u672C\u3002`,
|
|
@@ -111356,13 +111369,13 @@ var EN = {
|
|
|
111356
111369
|
signIn: (url) => `Sign in to WildCrane in your browser:
|
|
111357
111370
|
${url}`,
|
|
111358
111371
|
signedIn: () => "Signed in",
|
|
111359
|
-
signInFailed: (
|
|
111372
|
+
signInFailed: (why2) => `Sign-in did not finish: ${why2}`,
|
|
111360
111373
|
connected: (machine) => `Connected (${machine}) \u2014 waiting for tasks`,
|
|
111361
111374
|
running: (count2) => `Running ${count2} ${count2 === 1 ? "task" : "tasks"}`,
|
|
111362
111375
|
reconnecting: () => "Disconnected \u2014 reconnecting\u2026",
|
|
111363
111376
|
elsewhere: (machine) => `Your Runner is already connected on "${machine}". Quit it there first, then start it here.`,
|
|
111364
111377
|
outdated: () => "This version is out of date. Restart to update.",
|
|
111365
|
-
refused: (
|
|
111378
|
+
refused: (why2) => `WildCrane refused the connection: ${why2}`,
|
|
111366
111379
|
updated: (version) => `Updated to ${version}`,
|
|
111367
111380
|
rolledBack: (version) => `The new version did not start \u2014 back on ${version}`,
|
|
111368
111381
|
nodeTooOld: (range) => `The new version needs Node ${range}. Update Node; running the current version for now.`,
|
|
@@ -111387,8 +111400,8 @@ function status(line) {
|
|
|
111387
111400
|
}
|
|
111388
111401
|
|
|
111389
111402
|
// src/protocol.ts
|
|
111390
|
-
var VERSION = true ? "0.6.
|
|
111391
|
-
var AKB_VERSION = true ? "0.11.
|
|
111403
|
+
var VERSION = true ? "0.6.27" : "0.0.0";
|
|
111404
|
+
var AKB_VERSION = true ? "0.11.24" : "0.0.0";
|
|
111392
111405
|
var AKB_CONTRACT = true ? 7 : 0;
|
|
111393
111406
|
var EXIT_REFUSED = 10;
|
|
111394
111407
|
var EXIT_OUTDATED = 11;
|
|
@@ -112715,9 +112728,9 @@ function toolCalls(row) {
|
|
|
112715
112728
|
}).join("");
|
|
112716
112729
|
}
|
|
112717
112730
|
function retry(row) {
|
|
112718
|
-
const
|
|
112731
|
+
const why2 = str(row.error_message) || str(row.error_name) || "the provider failed";
|
|
112719
112732
|
const attempt = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
|
|
112720
|
-
return `[retry ${attempt}] ${
|
|
112733
|
+
return `[retry ${attempt}] ${why2}
|
|
112721
112734
|
`;
|
|
112722
112735
|
}
|
|
112723
112736
|
var LOOK_EVERY_MS2 = 3e3;
|
|
@@ -112807,10 +112820,10 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
112807
112820
|
} catch {
|
|
112808
112821
|
}
|
|
112809
112822
|
};
|
|
112810
|
-
const closed = (
|
|
112823
|
+
const closed = (why2) => {
|
|
112811
112824
|
if (gone) return;
|
|
112812
|
-
gone =
|
|
112813
|
-
for (const { fail } of waiting.values()) fail(new Error(
|
|
112825
|
+
gone = why2;
|
|
112826
|
+
for (const { fail } of waiting.values()) fail(new Error(why2));
|
|
112814
112827
|
waiting.clear();
|
|
112815
112828
|
};
|
|
112816
112829
|
stdout.on("data", (chunk) => {
|
|
@@ -112913,7 +112926,7 @@ function createTail(log) {
|
|
|
112913
112926
|
// ../cli/package.json
|
|
112914
112927
|
var package_default = {
|
|
112915
112928
|
name: "wildcrane",
|
|
112916
|
-
version: "0.11.
|
|
112929
|
+
version: "0.11.24",
|
|
112917
112930
|
akbContract: 7,
|
|
112918
112931
|
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.",
|
|
112919
112932
|
keywords: [
|
|
@@ -113160,12 +113173,12 @@ async function oneTurn(io, options) {
|
|
|
113160
113173
|
const usage = usageOf2(done.usage) ?? usageOf2(spent, true);
|
|
113161
113174
|
costUsd ??= ticksUsd(spent.costUsdTicks);
|
|
113162
113175
|
if (stopReason && stopReason !== "end_turn") {
|
|
113163
|
-
const
|
|
113164
|
-
io.log(`[error] ${
|
|
113176
|
+
const why2 = STOPPED[stopReason] ?? `the agent stopped: ${stopReason}`;
|
|
113177
|
+
io.log(`[error] ${why2}
|
|
113165
113178
|
`);
|
|
113166
|
-
events.error(
|
|
113179
|
+
events.error(why2);
|
|
113167
113180
|
emit();
|
|
113168
|
-
return { ok: false, result, error:
|
|
113181
|
+
return { ok: false, result, error: why2, usage, context, costUsd };
|
|
113169
113182
|
}
|
|
113170
113183
|
emit();
|
|
113171
113184
|
return { ok: true, result, usage, context, costUsd };
|
|
@@ -113195,8 +113208,8 @@ function update(raw, tail, gotCost, gotContext) {
|
|
|
113195
113208
|
}
|
|
113196
113209
|
case "tool_call_update": {
|
|
113197
113210
|
if (change.status !== "failed") return;
|
|
113198
|
-
const
|
|
113199
|
-
tail.line(`[error] ${str(change.title) || "that tool call"} failed${
|
|
113211
|
+
const why2 = saidBy(change);
|
|
113212
|
+
tail.line(`[error] ${str(change.title) || "that tool call"} failed${why2 ? `: ${why2}` : ""}`);
|
|
113200
113213
|
return;
|
|
113201
113214
|
}
|
|
113202
113215
|
case "usage_update": {
|
|
@@ -113292,8 +113305,8 @@ function createParts(tail) {
|
|
|
113292
113305
|
tail.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
|
|
113293
113306
|
}
|
|
113294
113307
|
if (str(state.status) === "error") {
|
|
113295
|
-
const
|
|
113296
|
-
tail.line(`[error] ${title} failed${
|
|
113308
|
+
const why2 = str(state.error).trim();
|
|
113309
|
+
tail.line(`[error] ${title} failed${why2 ? `: ${why2}` : ""}`);
|
|
113297
113310
|
}
|
|
113298
113311
|
},
|
|
113299
113312
|
/** A piece of one part, as `part.delta` sends it. */
|
|
@@ -113326,8 +113339,8 @@ function createParts(tail) {
|
|
|
113326
113339
|
toolUpdate(payload) {
|
|
113327
113340
|
if (str(payload.kind) !== "error") return;
|
|
113328
113341
|
const name = named2.get(str(payload.toolCallId)) ?? "tool";
|
|
113329
|
-
const
|
|
113330
|
-
tail.line(`[error] ${name} failed${
|
|
113342
|
+
const why2 = str(obj(payload.error).message).split("\n")[0].trim();
|
|
113343
|
+
tail.line(`[error] ${name} failed${why2 ? `: ${why2.slice(0, 200)}` : ""}`);
|
|
113331
113344
|
}
|
|
113332
113345
|
};
|
|
113333
113346
|
}
|
|
@@ -113342,10 +113355,10 @@ var RUNTIME_PREFERENCES = {
|
|
|
113342
113355
|
modelContextBudgetStrategy: "preflight-v1"
|
|
113343
113356
|
};
|
|
113344
113357
|
var MISSING_KEY = /missing an API key/i;
|
|
113345
|
-
function stopped(io,
|
|
113346
|
-
io.log(`[error] ${
|
|
113358
|
+
function stopped(io, why2) {
|
|
113359
|
+
io.log(`[error] ${why2}
|
|
113347
113360
|
`);
|
|
113348
|
-
if (MISSING_KEY.test(
|
|
113361
|
+
if (MISSING_KEY.test(why2)) {
|
|
113349
113362
|
io.log("[board] paste a Z.AI or BigModel Coding Plan key into ZCode's key box in Configuration.\n");
|
|
113350
113363
|
}
|
|
113351
113364
|
}
|
|
@@ -113435,9 +113448,9 @@ async function oneTurn2(io, options) {
|
|
|
113435
113448
|
const usage = done.usage ?? await tokensOf(rpc, sessionId);
|
|
113436
113449
|
const context = await contextOf(rpc, sessionId);
|
|
113437
113450
|
if (!done.ok) {
|
|
113438
|
-
const
|
|
113439
|
-
stopped(io,
|
|
113440
|
-
return { ok: false, result, error:
|
|
113451
|
+
const why2 = done.error ?? "the agent stopped without saying why";
|
|
113452
|
+
stopped(io, why2);
|
|
113453
|
+
return { ok: false, result, error: why2, usage, context };
|
|
113441
113454
|
}
|
|
113442
113455
|
return { ok: true, result, usage, context };
|
|
113443
113456
|
} catch (e2) {
|
|
@@ -113456,8 +113469,8 @@ async function tokensOf(rpc, sessionId) {
|
|
|
113456
113469
|
}
|
|
113457
113470
|
async function contextOf(rpc, sessionId) {
|
|
113458
113471
|
try {
|
|
113459
|
-
const
|
|
113460
|
-
const state = obj(
|
|
113472
|
+
const read3 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
|
|
113473
|
+
const state = obj(read3.projection);
|
|
113461
113474
|
const used = num(state.contextUsed);
|
|
113462
113475
|
const limit = num(state.contextWindow);
|
|
113463
113476
|
return used > 0 ? { used, limit: limit > 0 ? limit : void 0 } : void 0;
|
|
@@ -116057,9 +116070,9 @@ async function askDueAgents(machineId2, now = Date.now()) {
|
|
|
116057
116070
|
if (!folders2.ok) return false;
|
|
116058
116071
|
let started = false;
|
|
116059
116072
|
for (const { project } of folders2.value.folders) {
|
|
116060
|
-
const
|
|
116061
|
-
if (!
|
|
116062
|
-
for (const agent of
|
|
116073
|
+
const read3 = await readAgents(machineId2, project);
|
|
116074
|
+
if (!read3.ok) continue;
|
|
116075
|
+
for (const agent of read3.value.agents.filter((a2) => agentDue(a2, now))) {
|
|
116063
116076
|
const asked = await requestAgent(machineId2, project, agent.name, agent.workflow ?? null, agent.lastSuccess);
|
|
116064
116077
|
if (!asked.ok) console.error(`runner: ${agent.name} was not started on ${project}: ${asked.error}`);
|
|
116065
116078
|
else if (asked.value.job) started = true;
|
|
@@ -116406,6 +116419,19 @@ var parse = (v) => {
|
|
|
116406
116419
|
function compare(a2, b2) {
|
|
116407
116420
|
const [x2, y2] = [parse(a2) ?? [0, 0, 0], parse(b2) ?? [0, 0, 0]];
|
|
116408
116421
|
for (let i = 0; i < 3; i++) if (x2[i] !== y2[i]) return x2[i] - y2[i];
|
|
116422
|
+
const pre = (v) => /^v?\d+\.\d+\.\d+-([^+]+)/.exec(v)?.[1]?.split(".");
|
|
116423
|
+
const ap = pre(a2), bp = pre(b2);
|
|
116424
|
+
if (!ap || !bp) return ap ? -1 : bp ? 1 : 0;
|
|
116425
|
+
for (let i = 0; i < Math.max(ap.length, bp.length); i++) {
|
|
116426
|
+
const av = ap[i], bv = bp[i];
|
|
116427
|
+
if (av === bv) continue;
|
|
116428
|
+
if (av === void 0) return -1;
|
|
116429
|
+
if (bv === void 0) return 1;
|
|
116430
|
+
const an2 = /^\d+$/.test(av), bn2 = /^\d+$/.test(bv);
|
|
116431
|
+
if (an2 && bn2) return Number(av) - Number(bv);
|
|
116432
|
+
if (an2 !== bn2) return an2 ? -1 : 1;
|
|
116433
|
+
return av < bv ? -1 : 1;
|
|
116434
|
+
}
|
|
116409
116435
|
return 0;
|
|
116410
116436
|
}
|
|
116411
116437
|
function satisfies(version, range) {
|
|
@@ -116614,11 +116640,11 @@ function keepCloudChat(task, messages) {
|
|
|
116614
116640
|
fs19.writeFileSync(file2, lines.map((l2) => `${JSON.stringify(l2)}
|
|
116615
116641
|
`).join(""));
|
|
116616
116642
|
}
|
|
116617
|
-
async function keepDecisions(task,
|
|
116643
|
+
async function keepDecisions(task, read3) {
|
|
116618
116644
|
const comments = [];
|
|
116619
116645
|
let after = null;
|
|
116620
116646
|
do {
|
|
116621
|
-
const page = await
|
|
116647
|
+
const page = await read3(task, after);
|
|
116622
116648
|
if (!page.ok) return;
|
|
116623
116649
|
for (const d2 of page.value.data) {
|
|
116624
116650
|
if (d2.comment.trim()) comments.push({ id: d2.id, role: "user", text: d2.comment, at: Date.parse(d2.created_at) || Date.now() });
|
|
@@ -116737,8 +116763,161 @@ function cardFront(body) {
|
|
|
116737
116763
|
return out;
|
|
116738
116764
|
}
|
|
116739
116765
|
|
|
116740
|
-
// ../artifact-sdk/src/
|
|
116766
|
+
// ../artifact-sdk/src/builtin/compare.json
|
|
116767
|
+
var compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare"] },\n { "json": "/b", "types": ["storyboard", "compare"] },\n { "json": "/shots", "types": ["storyboard", "compare"] }\n ]\n}\n';
|
|
116768
|
+
|
|
116769
|
+
// ../artifact-sdk/src/builtin/html.json
|
|
116770
|
+
var html_default = `{
|
|
116771
|
+
"name": "html",
|
|
116772
|
+
"title": { "en": "Page", "zh": "\u9875\u9762" },
|
|
116773
|
+
"types": ["html"],
|
|
116774
|
+
"references": [
|
|
116775
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
116776
|
+
{ "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
116777
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
|
|
116778
|
+
{ "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
116779
|
+
{ "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
|
|
116780
|
+
]
|
|
116781
|
+
}
|
|
116782
|
+
`;
|
|
116783
|
+
|
|
116784
|
+
// ../artifact-sdk/src/builtin/image.json
|
|
116785
|
+
var image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
|
|
116786
|
+
|
|
116787
|
+
// ../artifact-sdk/src/builtin/markdown.json
|
|
116788
|
+
var markdown_default = '{ "name": "markdown", "title": { "en": "Document", "zh": "\u6587\u6863" }, "types": ["markdown"] }\n';
|
|
116789
|
+
|
|
116790
|
+
// ../artifact-sdk/src/builtin/storyboard.json
|
|
116791
|
+
var storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src" },\n { "json": "/slides/*/preview/src" },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
116792
|
+
|
|
116793
|
+
// ../artifact-sdk/src/builtin/video.json
|
|
116794
|
+
var video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
116795
|
+
|
|
116796
|
+
// ../artifact-sdk/src/builtin/workflow.json
|
|
116797
|
+
var workflow_default = '{\n "name": "workflow",\n "title": { "en": "Workflow", "zh": "\u5DE5\u4F5C\u6D41" },\n "types": ["workflow"],\n "schema": {\n "type": "object",\n "required": ["rounds", "land", "scheduled"],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": { "type": "object", "required": ["agent", "title"], "properties": { "agent": { "type": "string" }, "title": { "type": "object", "required": ["en"] } } }\n }\n },\n "land": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } },\n "scheduled": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } }\n }\n }\n}\n';
|
|
116798
|
+
|
|
116799
|
+
// ../artifact-sdk/src/builtin/index.ts
|
|
116800
|
+
var read = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
116801
|
+
var builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, workflow_default].map(read);
|
|
116802
|
+
|
|
116803
|
+
// ../artifact-sdk/src/internal/schema.ts
|
|
116804
|
+
var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
116805
|
+
function typeOk(type, v) {
|
|
116806
|
+
const types = Array.isArray(type) ? type : [type];
|
|
116807
|
+
return types.some(
|
|
116808
|
+
(t2) => t2 === "null" ? v === null : t2 === "array" ? Array.isArray(v) : t2 === "object" ? isObj(v) : t2 === "integer" ? Number.isInteger(v) : t2 === "number" ? typeof v === "number" && Number.isFinite(v) : typeof v === t2
|
|
116809
|
+
);
|
|
116810
|
+
}
|
|
116811
|
+
function schemaProblem(schema, value, at2 = "") {
|
|
116812
|
+
if (!isObj(schema)) return null;
|
|
116813
|
+
const s = schema;
|
|
116814
|
+
const here = at2 || "/";
|
|
116815
|
+
if (s.type !== void 0 && !typeOk(s.type, value)) return here;
|
|
116816
|
+
if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
|
|
116817
|
+
if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
|
|
116818
|
+
if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
|
|
116819
|
+
if (typeof value === "string") {
|
|
116820
|
+
if (typeof s.minLength === "number" && value.length < s.minLength) return here;
|
|
116821
|
+
if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
|
|
116822
|
+
if (typeof s.pattern === "string") {
|
|
116823
|
+
try {
|
|
116824
|
+
if (!new RegExp(s.pattern, "u").test(value)) return here;
|
|
116825
|
+
} catch {
|
|
116826
|
+
}
|
|
116827
|
+
}
|
|
116828
|
+
}
|
|
116829
|
+
if (typeof value === "number") {
|
|
116830
|
+
if (typeof s.minimum === "number" && value < s.minimum) return here;
|
|
116831
|
+
if (typeof s.maximum === "number" && value > s.maximum) return here;
|
|
116832
|
+
}
|
|
116833
|
+
if (Array.isArray(value)) {
|
|
116834
|
+
if (typeof s.minItems === "number" && value.length < s.minItems) return here;
|
|
116835
|
+
if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
|
|
116836
|
+
if (isObj(s.items)) {
|
|
116837
|
+
for (let i = 0; i < value.length; i++) {
|
|
116838
|
+
const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
|
|
116839
|
+
if (bad) return bad;
|
|
116840
|
+
}
|
|
116841
|
+
}
|
|
116842
|
+
}
|
|
116843
|
+
if (isObj(value)) {
|
|
116844
|
+
const props = isObj(s.properties) ? s.properties : {};
|
|
116845
|
+
if (Array.isArray(s.required)) {
|
|
116846
|
+
for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
|
|
116847
|
+
}
|
|
116848
|
+
for (const [k2, v] of Object.entries(value)) {
|
|
116849
|
+
if (k2 in props) {
|
|
116850
|
+
const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
|
|
116851
|
+
if (bad) return bad;
|
|
116852
|
+
} else if (s.additionalProperties === false) return `${at2}/${k2}`;
|
|
116853
|
+
else if (isObj(s.additionalProperties)) {
|
|
116854
|
+
const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
|
|
116855
|
+
if (bad) return bad;
|
|
116856
|
+
}
|
|
116857
|
+
}
|
|
116858
|
+
}
|
|
116859
|
+
return null;
|
|
116860
|
+
}
|
|
116861
|
+
|
|
116862
|
+
// ../artifact-sdk/src/internal/manifest.ts
|
|
116863
|
+
var BUILTINS = builtin_default;
|
|
116864
|
+
var manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
|
|
116865
|
+
function typeOf(data, types) {
|
|
116866
|
+
for (const type of types) if (!schemaProblem(manifestOf(type)?.schema, data)) return { type };
|
|
116867
|
+
if (types.length !== 1) return { type: null };
|
|
116868
|
+
return { type: types[0], problem: `does not match ${types[0]} at ${schemaProblem(manifestOf(types[0])?.schema, data)}` };
|
|
116869
|
+
}
|
|
116741
116870
|
var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
116871
|
+
var remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
|
|
116872
|
+
function mapJson(node, keys, at2, visit) {
|
|
116873
|
+
if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
|
|
116874
|
+
const [key, ...rest] = keys;
|
|
116875
|
+
if (Array.isArray(node)) {
|
|
116876
|
+
if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
|
|
116877
|
+
const i = Number(key);
|
|
116878
|
+
return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
|
|
116879
|
+
}
|
|
116880
|
+
if (!isObject(node)) return node;
|
|
116881
|
+
const out = { ...node };
|
|
116882
|
+
for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
|
|
116883
|
+
return out;
|
|
116884
|
+
}
|
|
116885
|
+
function mapText(text4, rule, visit) {
|
|
116886
|
+
let out = "";
|
|
116887
|
+
let last2 = 0;
|
|
116888
|
+
for (const m of text4.matchAll(new RegExp(rule.text, "gid"))) {
|
|
116889
|
+
const span = m.indices?.[1];
|
|
116890
|
+
if (!span || m[1] === void 0) continue;
|
|
116891
|
+
const line = text4.slice(0, span[0]).split("\n").length;
|
|
116892
|
+
const one = (src) => remote(src) ? src : visit(src, line);
|
|
116893
|
+
const value = rule.list ? m[1].split(rule.list).map((part) => part.replace(/^(\s*)(\S+)/, (_2, space, src) => space + one(src))).join(rule.list) : one(m[1]);
|
|
116894
|
+
out += text4.slice(last2, span[0]) + value;
|
|
116895
|
+
last2 = span[1];
|
|
116896
|
+
}
|
|
116897
|
+
return out + text4.slice(last2);
|
|
116898
|
+
}
|
|
116899
|
+
function mapReferences(manifest, content, map2) {
|
|
116900
|
+
for (const rule of manifest?.references ?? []) {
|
|
116901
|
+
const types = rule.types ?? [];
|
|
116902
|
+
if ("json" in rule) {
|
|
116903
|
+
if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
|
|
116904
|
+
} else if (typeof content === "string") {
|
|
116905
|
+
content = mapText(content, rule, (src, line) => map2(src, { src, types, text: true, line }));
|
|
116906
|
+
}
|
|
116907
|
+
}
|
|
116908
|
+
return content;
|
|
116909
|
+
}
|
|
116910
|
+
function referencesOf(manifest, content) {
|
|
116911
|
+
const found = [];
|
|
116912
|
+
mapReferences(manifest, content, (src, ref) => (found.push(ref), src));
|
|
116913
|
+
return found;
|
|
116914
|
+
}
|
|
116915
|
+
|
|
116916
|
+
// ../artifact-sdk/src/internal/references.ts
|
|
116917
|
+
var STORYBOARD = ["storyboard"];
|
|
116918
|
+
var WORKFLOW = ["workflow"];
|
|
116919
|
+
var COMPARE = ["storyboard", "compare"];
|
|
116920
|
+
var isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
116742
116921
|
function bodyReferences(body) {
|
|
116743
116922
|
const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
|
|
116744
116923
|
let fence = "";
|
|
@@ -116759,12 +116938,12 @@ function bodyReferences(body) {
|
|
|
116759
116938
|
}
|
|
116760
116939
|
const kept4 = inTag || !/^(?: {4}|\t)/.test(line);
|
|
116761
116940
|
visible.push(kept4 ? line : "");
|
|
116762
|
-
if (kept4 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard)\b/.test(line)) inTag = true;
|
|
116941
|
+
if (kept4 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b/.test(line)) inTag = true;
|
|
116763
116942
|
if (line.includes("/>")) inTag = false;
|
|
116764
116943
|
}
|
|
116765
116944
|
const text4 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
|
|
116766
|
-
const tag = /<(Asset|Mockup|Compare|Storyboard)\b([^<>]*?)\/>/g;
|
|
116767
|
-
const blocks = text4.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
116945
|
+
const tag = /<(Asset|Mockup|Compare|Storyboard|Workflow)\b([^<>]*?)\/>/g;
|
|
116946
|
+
const blocks = text4.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
116768
116947
|
for (const block of blocks) {
|
|
116769
116948
|
const tags = [...block[0].matchAll(tag)];
|
|
116770
116949
|
for (const m of tags) {
|
|
@@ -116772,14 +116951,14 @@ function bodyReferences(body) {
|
|
|
116772
116951
|
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
116773
116952
|
if (m[1] === "Compare") {
|
|
116774
116953
|
if (!a2.a || !a2.b) continue;
|
|
116775
|
-
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2],
|
|
116954
|
+
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: COMPARE });
|
|
116776
116955
|
} else if (a2.src) {
|
|
116777
|
-
out.push({ src: a2.src,
|
|
116956
|
+
out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : [] });
|
|
116778
116957
|
if (a2.variants) {
|
|
116779
116958
|
try {
|
|
116780
116959
|
const v = JSON.parse(a2.variants);
|
|
116781
|
-
if (
|
|
116782
|
-
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src,
|
|
116960
|
+
if (isObject2(v)) {
|
|
116961
|
+
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: [] });
|
|
116783
116962
|
}
|
|
116784
116963
|
} catch {
|
|
116785
116964
|
}
|
|
@@ -116787,36 +116966,9 @@ function bodyReferences(body) {
|
|
|
116787
116966
|
}
|
|
116788
116967
|
}
|
|
116789
116968
|
}
|
|
116790
|
-
for (const m of text4.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1],
|
|
116969
|
+
for (const m of text4.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
|
|
116791
116970
|
return out;
|
|
116792
116971
|
}
|
|
116793
|
-
function mapReferences(data, kind, map2) {
|
|
116794
|
-
const c2 = structuredClone(data);
|
|
116795
|
-
if (!isObject(c2)) return c2;
|
|
116796
|
-
const field = (obj3, key, purpose = "asset") => {
|
|
116797
|
-
if (typeof obj3[key] === "string" && obj3[key]) obj3[key] = map2(obj3[key], purpose);
|
|
116798
|
-
};
|
|
116799
|
-
if (kind === "compare") for (const key of ["a", "b", "shots"]) field(c2, key, "compare");
|
|
116800
|
-
if (kind === "storyboard") {
|
|
116801
|
-
if (Array.isArray(c2.shots)) for (const shot of c2.shots) {
|
|
116802
|
-
if (isObject(shot) && Array.isArray(shot.frames)) {
|
|
116803
|
-
for (const frame2 of shot.frames) if (isObject(frame2)) field(frame2, "src");
|
|
116804
|
-
}
|
|
116805
|
-
}
|
|
116806
|
-
if (Array.isArray(c2.slides)) {
|
|
116807
|
-
for (const slide of c2.slides) if (isObject(slide)) {
|
|
116808
|
-
if (isObject(slide.preview)) field(slide.preview, "src");
|
|
116809
|
-
if (Array.isArray(slide.assets)) slide.assets = slide.assets.map((src) => typeof src === "string" ? map2(src, "asset") : src);
|
|
116810
|
-
}
|
|
116811
|
-
}
|
|
116812
|
-
}
|
|
116813
|
-
return c2;
|
|
116814
|
-
}
|
|
116815
|
-
function jsonKind(data, purpose) {
|
|
116816
|
-
if (!isObject(data)) return "asset";
|
|
116817
|
-
if (purpose !== "asset" && typeof data.a === "string" && typeof data.b === "string") return "compare";
|
|
116818
|
-
return purpose !== "asset" && (Array.isArray(data.shots) || Array.isArray(data.slides)) ? "storyboard" : "asset";
|
|
116819
|
-
}
|
|
116820
116972
|
var TYPES = {
|
|
116821
116973
|
".png": "image/png",
|
|
116822
116974
|
".jpg": "image/jpeg",
|
|
@@ -116835,7 +116987,12 @@ var TYPES = {
|
|
|
116835
116987
|
".wav": "audio/wav",
|
|
116836
116988
|
".m4a": "audio/mp4",
|
|
116837
116989
|
".json": "application/json",
|
|
116838
|
-
".txt": "text/plain"
|
|
116990
|
+
".txt": "text/plain",
|
|
116991
|
+
".otf": "font/otf",
|
|
116992
|
+
".ttf": "font/ttf",
|
|
116993
|
+
".woff": "font/woff",
|
|
116994
|
+
".woff2": "font/woff2",
|
|
116995
|
+
".css": "text/css"
|
|
116839
116996
|
};
|
|
116840
116997
|
function kindOf(ext) {
|
|
116841
116998
|
if (ext === ".tsx" || ext === ".html") return "html";
|
|
@@ -116846,66 +117003,84 @@ function kindOf(ext) {
|
|
|
116846
117003
|
}
|
|
116847
117004
|
|
|
116848
117005
|
// ../artifact-sdk/src/internal/collect.ts
|
|
117006
|
+
var extOf = (file2) => /\.[^./\\]+$/.exec(file2)?.[0].toLowerCase() ?? "";
|
|
117007
|
+
var why = (error) => error instanceof Error ? error.message : String(error);
|
|
117008
|
+
var kindAt = (src, types) => extOf(src) === ".json" ? types[0] ?? "asset" : kindOf(extOf(src));
|
|
116849
117009
|
function collect(body, card, host) {
|
|
116850
117010
|
const nodes = /* @__PURE__ */ new Map();
|
|
116851
117011
|
const active = /* @__PURE__ */ new Set();
|
|
116852
117012
|
const out = [];
|
|
116853
|
-
const visit = (src,
|
|
117013
|
+
const visit = (src, types, owner) => {
|
|
117014
|
+
const path49 = src.replace(/[?#].*$/, "");
|
|
116854
117015
|
let resolved2;
|
|
116855
117016
|
try {
|
|
116856
|
-
resolved2 = host.resolve(
|
|
117017
|
+
resolved2 = host.resolve(path49, owner);
|
|
116857
117018
|
} catch (error) {
|
|
116858
|
-
|
|
117019
|
+
if (owner !== card) return { key: null, error: why(error) };
|
|
117020
|
+
if (!nodes.has(src)) {
|
|
117021
|
+
const node2 = { key: src, file: null, kind: kindAt(path49, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
117022
|
+
nodes.set(src, node2);
|
|
117023
|
+
out.push(node2);
|
|
117024
|
+
}
|
|
117025
|
+
return { key: src, error: nodes.get(src).error };
|
|
116859
117026
|
}
|
|
116860
|
-
if (!resolved2) return null;
|
|
117027
|
+
if (!resolved2) return { key: null };
|
|
116861
117028
|
const { key, file: file2 } = resolved2;
|
|
116862
117029
|
if (active.has(key)) throw new Error(`${owner}: ${src}: \u8D44\u6E90\u4F9D\u8D56\u5FAA\u73AF`);
|
|
117030
|
+
const json = !!file2 && extOf(file2) === ".json";
|
|
116863
117031
|
const held4 = nodes.get(key);
|
|
116864
117032
|
if (held4) {
|
|
116865
117033
|
if (owner === card) held4.aliases.add(src);
|
|
116866
|
-
if (
|
|
117034
|
+
if (held4.error || !json || !types.length || held4.kind !== "asset") return { key, error: held4.error };
|
|
116867
117035
|
out.splice(out.indexOf(held4), 1);
|
|
116868
117036
|
}
|
|
116869
|
-
const node =
|
|
117037
|
+
const node = { key, file: file2, kind: "asset", problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: held4?.aliases ?? /* @__PURE__ */ new Set([key]) };
|
|
116870
117038
|
if (owner === card) node.aliases.add(src);
|
|
116871
117039
|
nodes.set(key, node);
|
|
116872
117040
|
active.add(key);
|
|
116873
|
-
|
|
116874
|
-
|
|
116875
|
-
|
|
116876
|
-
}
|
|
116877
|
-
|
|
116878
|
-
|
|
116879
|
-
|
|
116880
|
-
|
|
116881
|
-
|
|
116882
|
-
|
|
116883
|
-
|
|
116884
|
-
|
|
116885
|
-
|
|
116886
|
-
|
|
116887
|
-
|
|
116888
|
-
|
|
117041
|
+
const child = (ref, from) => {
|
|
117042
|
+
const found = visit(ref.src, ref.types, from);
|
|
117043
|
+
if (found.key) node.dependencies.set(ref.src, found.key);
|
|
117044
|
+
else if (found.error) node.problems.push({ src: ref.src, ..."line" in ref ? { line: ref.line } : {}, ..."at" in ref ? { at: ref.at } : {}, message: found.error });
|
|
117045
|
+
node.error ??= found.error;
|
|
117046
|
+
};
|
|
117047
|
+
if (file2) {
|
|
117048
|
+
if (json) {
|
|
117049
|
+
try {
|
|
117050
|
+
node.data = JSON.parse(host.read(file2));
|
|
117051
|
+
const typed = typeOf(node.data, types);
|
|
117052
|
+
node.kind = typed.type ?? "asset";
|
|
117053
|
+
if (typed.problem) node.problems.push({ src: file2, message: `${typed.problem}: ${file2}` });
|
|
117054
|
+
} catch {
|
|
117055
|
+
node.problems.push({ src: file2, message: `not valid JSON: ${file2}` });
|
|
117056
|
+
}
|
|
117057
|
+
} else {
|
|
117058
|
+
node.kind = kindOf(extOf(file2));
|
|
117059
|
+
try {
|
|
117060
|
+
if (manifestOf(node.kind)?.references) node.data = host.read(file2);
|
|
117061
|
+
} catch (error) {
|
|
117062
|
+
node.problems.push({ src: file2, message: why(error) });
|
|
117063
|
+
}
|
|
116889
117064
|
}
|
|
117065
|
+
node.error = node.problems[0]?.message;
|
|
117066
|
+
if (!node.error) for (const ref of referencesOf(manifestOf(node.kind), node.data)) child(ref, file2);
|
|
117067
|
+
} else {
|
|
117068
|
+
for (const ref of host.retained(key)) child(ref, card);
|
|
116890
117069
|
}
|
|
116891
117070
|
active.delete(key);
|
|
116892
117071
|
out.push(node);
|
|
116893
|
-
return key;
|
|
117072
|
+
return { key, error: node.error };
|
|
116894
117073
|
};
|
|
116895
|
-
for (const ref of bodyReferences(body)) visit(ref.src, ref.
|
|
117074
|
+
for (const ref of bodyReferences(body)) visit(ref.src, ref.types, card);
|
|
116896
117075
|
const sorted = [];
|
|
116897
117076
|
const done = /* @__PURE__ */ new Set();
|
|
116898
|
-
const sorting = /* @__PURE__ */ new Set();
|
|
116899
117077
|
const order = (node) => {
|
|
116900
117078
|
if (done.has(node.key)) return;
|
|
116901
|
-
|
|
116902
|
-
sorting.add(node.key);
|
|
117079
|
+
done.add(node.key);
|
|
116903
117080
|
for (const key of node.dependencies.values()) {
|
|
116904
117081
|
const child = nodes.get(key);
|
|
116905
117082
|
if (child) order(child);
|
|
116906
117083
|
}
|
|
116907
|
-
sorting.delete(node.key);
|
|
116908
|
-
done.add(node.key);
|
|
116909
117084
|
sorted.push(node);
|
|
116910
117085
|
};
|
|
116911
117086
|
for (const node of out) order(node);
|
|
@@ -117182,6 +117357,87 @@ import fs20 from "node:fs";
|
|
|
117182
117357
|
import path24 from "node:path";
|
|
117183
117358
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
117184
117359
|
|
|
117360
|
+
// ../cli/src/lib/agents/icon.ts
|
|
117361
|
+
var ICON_NAMES = [
|
|
117362
|
+
"file",
|
|
117363
|
+
"text",
|
|
117364
|
+
"article",
|
|
117365
|
+
"outline",
|
|
117366
|
+
"script",
|
|
117367
|
+
"prompt",
|
|
117368
|
+
"email",
|
|
117369
|
+
"image",
|
|
117370
|
+
"post-image",
|
|
117371
|
+
"social-image",
|
|
117372
|
+
"cover",
|
|
117373
|
+
"carousel",
|
|
117374
|
+
"carousel-outline",
|
|
117375
|
+
"slides",
|
|
117376
|
+
"wireframe",
|
|
117377
|
+
"screen",
|
|
117378
|
+
"video",
|
|
117379
|
+
"storyboard",
|
|
117380
|
+
"template",
|
|
117381
|
+
"shots",
|
|
117382
|
+
"api",
|
|
117383
|
+
"schema",
|
|
117384
|
+
"compare",
|
|
117385
|
+
"stack",
|
|
117386
|
+
"workflow",
|
|
117387
|
+
"code",
|
|
117388
|
+
"checklist",
|
|
117389
|
+
"card",
|
|
117390
|
+
"plan",
|
|
117391
|
+
"proposal",
|
|
117392
|
+
"dismissed",
|
|
117393
|
+
"inbox",
|
|
117394
|
+
"notebook",
|
|
117395
|
+
"squeeze",
|
|
117396
|
+
"folder",
|
|
117397
|
+
"reply",
|
|
117398
|
+
"feedback",
|
|
117399
|
+
"software",
|
|
117400
|
+
"product-video",
|
|
117401
|
+
"social-post",
|
|
117402
|
+
"blog",
|
|
117403
|
+
"deck",
|
|
117404
|
+
"video-clone",
|
|
117405
|
+
"workflow-kit"
|
|
117406
|
+
];
|
|
117407
|
+
var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
117408
|
+
var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
117409
|
+
var isColor = (v) => ICON_COLORS.includes(v);
|
|
117410
|
+
function readIcon(raw) {
|
|
117411
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
117412
|
+
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
117413
|
+
if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
|
|
117414
|
+
const parts = [];
|
|
117415
|
+
for (const [i, item] of raw.entries()) {
|
|
117416
|
+
const at2 = `part ${i + 1}`;
|
|
117417
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
117418
|
+
const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
|
|
117419
|
+
if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
117420
|
+
if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
|
|
117421
|
+
const part = { d: d2.trim() };
|
|
117422
|
+
for (const [key, value] of [["f", f2], ["s", s]]) {
|
|
117423
|
+
if (value === void 0) continue;
|
|
117424
|
+
if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
|
|
117425
|
+
part[key] = value;
|
|
117426
|
+
}
|
|
117427
|
+
if (o3 !== void 0) {
|
|
117428
|
+
if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
|
|
117429
|
+
part.o = true;
|
|
117430
|
+
}
|
|
117431
|
+
if (w2 !== void 0) {
|
|
117432
|
+
const width = typeof w2 === "string" ? Number(w2) : NaN;
|
|
117433
|
+
if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
|
|
117434
|
+
part.w = width;
|
|
117435
|
+
}
|
|
117436
|
+
parts.push(part);
|
|
117437
|
+
}
|
|
117438
|
+
return parts;
|
|
117439
|
+
}
|
|
117440
|
+
|
|
117185
117441
|
// ../cli/src/lib/agents/yaml.ts
|
|
117186
117442
|
function stripComment(value) {
|
|
117187
117443
|
let from = 0;
|
|
@@ -117293,8 +117549,8 @@ var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
|
|
|
117293
117549
|
var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
|
|
117294
117550
|
function parseSpecAgent(text4, from, file2, builtIn = false, list = () => []) {
|
|
117295
117551
|
let named2 = "";
|
|
117296
|
-
const bad = (
|
|
117297
|
-
problem: `${from}: ${
|
|
117552
|
+
const bad = (why2, old2) => ({
|
|
117553
|
+
problem: `${from}: ${why2}`,
|
|
117298
117554
|
...named2 ? { name: named2 } : {},
|
|
117299
117555
|
...old2 ? { old: old2 } : {}
|
|
117300
117556
|
});
|
|
@@ -117329,6 +117585,12 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list = () => []) {
|
|
|
117329
117585
|
if (!Array.isArray(components) || components.some((value) => typeof value !== "string" || !value.trim())) {
|
|
117330
117586
|
return bad(`\`${name}\` declares \`akb.components\` that is not a list of component IDs`);
|
|
117331
117587
|
}
|
|
117588
|
+
const icon = readIcon(akb.icon);
|
|
117589
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
117590
|
+
return bad(
|
|
117591
|
+
`\`${name}\` declares an \`akb.icon\` where ${icon.problem} \u2014 use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
117592
|
+
);
|
|
117593
|
+
}
|
|
117332
117594
|
const workspace = memoryPaths(akb.memoryFiles);
|
|
117333
117595
|
if (typeof workspace === "string") return bad(`\`${name}\` declares ${workspace}`);
|
|
117334
117596
|
const instructions = body.trim();
|
|
@@ -117340,6 +117602,7 @@ function parseSpecAgent(text4, from, file2, builtIn = false, list = () => []) {
|
|
|
117340
117602
|
...when ? { when } : {},
|
|
117341
117603
|
after,
|
|
117342
117604
|
components: [...new Set(components.map((value) => value.trim()))],
|
|
117605
|
+
...icon ? { icon } : {},
|
|
117343
117606
|
i18n: readTranslations(akb.i18n),
|
|
117344
117607
|
...declaredReads ? { reads: declaredReads } : {},
|
|
117345
117608
|
...declaredSession ? { session: "new" } : {},
|
|
@@ -117439,6 +117702,12 @@ function parseWorkflowFile(id, source, from) {
|
|
|
117439
117702
|
problem: `${from}: \`${old.join("`, `")}\` ${old.length > 1 ? "are" : "is"} no longer read \u2014 list the agents under \`previews\`, \`land\` and \`scheduled\` instead (\`akb guide write-agent\`), or ask the Workflow builder to rewrite it`
|
|
117440
117703
|
};
|
|
117441
117704
|
}
|
|
117705
|
+
const icon = readIcon(raw.icon);
|
|
117706
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
117707
|
+
return {
|
|
117708
|
+
problem: `${from}: its \`icon\` is wrong \u2014 ${icon.problem}; use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
117709
|
+
};
|
|
117710
|
+
}
|
|
117442
117711
|
const previews = readPreviews(raw.previews);
|
|
117443
117712
|
if (typeof previews === "string") return { problem: `${from}: ${previews}` };
|
|
117444
117713
|
const land = readGroup(raw.land);
|
|
@@ -117463,6 +117732,7 @@ function parseWorkflowFile(id, source, from) {
|
|
|
117463
117732
|
description: text2(raw.description),
|
|
117464
117733
|
when: text2(raw.when),
|
|
117465
117734
|
needsArtifact: text2(raw.needsArtifact) === "true",
|
|
117735
|
+
...icon ? { icon } : {},
|
|
117466
117736
|
previews,
|
|
117467
117737
|
land,
|
|
117468
117738
|
scheduled,
|
|
@@ -117487,13 +117757,13 @@ function folderPath(file2, top) {
|
|
|
117487
117757
|
return [parts[1], parts.slice(2).join("/")];
|
|
117488
117758
|
}
|
|
117489
117759
|
function mcpProblem(text4) {
|
|
117490
|
-
let
|
|
117760
|
+
let read3;
|
|
117491
117761
|
try {
|
|
117492
|
-
|
|
117762
|
+
read3 = JSON.parse(text4);
|
|
117493
117763
|
} catch {
|
|
117494
117764
|
return "is not JSON";
|
|
117495
117765
|
}
|
|
117496
|
-
const servers =
|
|
117766
|
+
const servers = read3?.mcpServers;
|
|
117497
117767
|
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
117498
117768
|
for (const [name, server] of Object.entries(servers)) {
|
|
117499
117769
|
const { command, args, ...rest } = server ?? {};
|
|
@@ -117540,9 +117810,9 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
117540
117810
|
}
|
|
117541
117811
|
const source = value[WORKFLOW_FILE];
|
|
117542
117812
|
if (source === void 0) return fail(WORKFLOW_FILE, "is missing");
|
|
117543
|
-
const
|
|
117544
|
-
if ("problem" in
|
|
117545
|
-
const def =
|
|
117813
|
+
const read3 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
|
|
117814
|
+
if ("problem" in read3) return fail(WORKFLOW_FILE, read3.problem.replace(`${WORKFLOW_FILE}: `, ""));
|
|
117815
|
+
const def = read3.def;
|
|
117546
117816
|
const agents = /* @__PURE__ */ new Map();
|
|
117547
117817
|
for (const [name, own] of folders2) {
|
|
117548
117818
|
const from = `agents/${name}/AGENT.md`;
|
|
@@ -117558,8 +117828,8 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
117558
117828
|
...def.land.filter((h3) => !LAND_ROLES.includes(h3.agent)).map((h3) => [h3.agent, "it lands with"]),
|
|
117559
117829
|
...def.scheduled.map((s) => [s.agent, "it schedules"])
|
|
117560
117830
|
];
|
|
117561
|
-
for (const [name,
|
|
117562
|
-
if (!agents.has(name)) return fail(WORKFLOW_FILE, `${
|
|
117831
|
+
for (const [name, why2] of named2) {
|
|
117832
|
+
if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
|
|
117563
117833
|
}
|
|
117564
117834
|
return { ok: true, def, files: value };
|
|
117565
117835
|
}
|
|
@@ -117582,8 +117852,8 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
117582
117852
|
return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs20.readFileSync(path24.join(dir, f2), "utf8")]))];
|
|
117583
117853
|
}));
|
|
117584
117854
|
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
117585
|
-
const
|
|
117586
|
-
if ("problem" in
|
|
117855
|
+
const read3 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
117856
|
+
if ("problem" in read3) throw new Error(read3.problem);
|
|
117587
117857
|
}
|
|
117588
117858
|
const workflowsDir = path24.join(root2, "workflows");
|
|
117589
117859
|
return dirs(workflowsDir).map((folder) => {
|
|
@@ -117592,10 +117862,10 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
117592
117862
|
for (const f2 of filesOf(dir).sort()) {
|
|
117593
117863
|
if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/")) files[f2] = fs20.readFileSync(path24.join(dir, f2), "utf8");
|
|
117594
117864
|
}
|
|
117595
|
-
const
|
|
117865
|
+
const read3 = checkWorkflowFiles({ [WORKFLOW_FILE]: files[WORKFLOW_FILE], ...Object.fromEntries(
|
|
117596
117866
|
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t2]) => [`agents/${name}/${f2}`, t2]))
|
|
117597
117867
|
) });
|
|
117598
|
-
if (!
|
|
117868
|
+
if (!read3.ok && !loose) throw new Error(`official/workflows/${folder}: ${read3.file}: ${read3.reason}`);
|
|
117599
117869
|
const parsed = parseWorkflowFile(folder, files[WORKFLOW_FILE] ?? "", WORKFLOW_FILE);
|
|
117600
117870
|
if ("problem" in parsed) throw new Error(parsed.problem);
|
|
117601
117871
|
const def = parsed.def;
|
|
@@ -117701,14 +117971,14 @@ function currentTurn() {
|
|
|
117701
117971
|
function forgetFileMemos() {
|
|
117702
117972
|
turn++;
|
|
117703
117973
|
}
|
|
117704
|
-
function memoByFiles(paths,
|
|
117974
|
+
function memoByFiles(paths, read3) {
|
|
117705
117975
|
let last2 = null;
|
|
117706
117976
|
return () => {
|
|
117707
117977
|
const now = currentTurn();
|
|
117708
117978
|
if (last2?.turn !== now) {
|
|
117709
117979
|
const seen = stamp(paths());
|
|
117710
117980
|
if (last2?.stamp === seen) last2.turn = now;
|
|
117711
|
-
else last2 = { stamp: seen, turn: now, value:
|
|
117981
|
+
else last2 = { stamp: seen, turn: now, value: read3() };
|
|
117712
117982
|
}
|
|
117713
117983
|
return copy(last2.value);
|
|
117714
117984
|
};
|
|
@@ -117749,9 +118019,9 @@ var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
|
117749
118019
|
var devFolder = () => process.env[DEV]?.trim() || "";
|
|
117750
118020
|
var flowOf = (held4) => {
|
|
117751
118021
|
const id = workflowName(held4.id);
|
|
117752
|
-
const
|
|
117753
|
-
if ("problem" in
|
|
117754
|
-
return { def:
|
|
118022
|
+
const read3 = parseWorkflowFile(id, held4.files["WORKFLOW.md"] ?? "", `the \`${id}\` workflow`);
|
|
118023
|
+
if ("problem" in read3) return null;
|
|
118024
|
+
return { def: read3.def, cloudId: held4.id, version: held4.version, builtIn: held4.id.startsWith("wf_builtin_"), files: held4.files };
|
|
117755
118025
|
};
|
|
117756
118026
|
function readFlows() {
|
|
117757
118027
|
const dev = devFolder();
|
|
@@ -117799,10 +118069,6 @@ function cloudAgentFiles() {
|
|
|
117799
118069
|
return { files, official };
|
|
117800
118070
|
}
|
|
117801
118071
|
|
|
117802
|
-
// ../cli/src/lib/preview-validation.ts
|
|
117803
|
-
import fs29 from "node:fs";
|
|
117804
|
-
import path33 from "node:path";
|
|
117805
|
-
|
|
117806
118072
|
// ../cli/src/lib/agent/launch.ts
|
|
117807
118073
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
117808
118074
|
var SELF = fileURLToPath3(import.meta.url);
|
|
@@ -118163,12 +118429,12 @@ function readAnswers(raw) {
|
|
|
118163
118429
|
if (!Array.isArray(raw)) return void 0;
|
|
118164
118430
|
const answers3 = raw.flatMap((entry) => {
|
|
118165
118431
|
if (!entry || entry.outcome !== "changed" && entry.outcome !== "unchanged") return [];
|
|
118166
|
-
const
|
|
118167
|
-
if (!
|
|
118432
|
+
const why2 = text3(entry.why);
|
|
118433
|
+
if (!why2) return [];
|
|
118168
118434
|
return [
|
|
118169
118435
|
{
|
|
118170
118436
|
outcome: entry.outcome,
|
|
118171
|
-
why,
|
|
118437
|
+
why: why2,
|
|
118172
118438
|
at: typeof entry.at === "number" ? entry.at : 0,
|
|
118173
118439
|
actedAt: typeof entry.actedAt === "number" ? entry.actedAt : void 0
|
|
118174
118440
|
}
|
|
@@ -118370,16 +118636,16 @@ function readCatalog() {
|
|
|
118370
118636
|
const agents = [];
|
|
118371
118637
|
const problems = [];
|
|
118372
118638
|
const refused = [];
|
|
118373
|
-
const take = (
|
|
118374
|
-
if ("problem" in
|
|
118375
|
-
if (!
|
|
118376
|
-
if (!
|
|
118377
|
-
const { file: file2, name: name2, old } =
|
|
118378
|
-
const cause =
|
|
118639
|
+
const take = (read3, folder) => {
|
|
118640
|
+
if ("problem" in read3) {
|
|
118641
|
+
if (!read3.missing) problems.push(read3.problem);
|
|
118642
|
+
if (!read3.file) return;
|
|
118643
|
+
const { file: file2, name: name2, old } = read3;
|
|
118644
|
+
const cause = read3.missing ? "noFile" : old ? "oldKeys" : "file";
|
|
118379
118645
|
refused.push({ folder, file: file2, cause, ...name2 ? { name: name2 } : {}, ...old ? { keys: old.keys } : {} });
|
|
118380
118646
|
return;
|
|
118381
118647
|
}
|
|
118382
|
-
const { name, from, builtIn } =
|
|
118648
|
+
const { name, from, builtIn } = read3.agent;
|
|
118383
118649
|
const refuse = (cause, problem) => {
|
|
118384
118650
|
problems.push(problem);
|
|
118385
118651
|
if (!builtIn) refused.push({ folder, name, file: from, cause });
|
|
@@ -118403,14 +118669,14 @@ function readCatalog() {
|
|
|
118403
118669
|
`${from}: its folder is \`${folder}\` but it calls itself \`${name}\`. An agent is asked for by its folder name \u2014 make the two match.`
|
|
118404
118670
|
);
|
|
118405
118671
|
}
|
|
118406
|
-
agents.push(
|
|
118672
|
+
agents.push(read3.agent);
|
|
118407
118673
|
};
|
|
118408
118674
|
for (const folder of bundledFolders()) take(readBundled(folder), folder);
|
|
118409
118675
|
for (const folder of projectFolders(AGENTS)) {
|
|
118410
|
-
const
|
|
118411
|
-
take(
|
|
118412
|
-
if ("agent" in
|
|
118413
|
-
problems.push(`${
|
|
118676
|
+
const read3 = readProject2(AGENTS, folder);
|
|
118677
|
+
take(read3, folder);
|
|
118678
|
+
if ("agent" in read3 && read3.agent.from.endsWith(LEGACY_AGENT_FILE)) {
|
|
118679
|
+
problems.push(`${read3.agent.from}: rename it to ${AGENT_FILE}`);
|
|
118414
118680
|
}
|
|
118415
118681
|
}
|
|
118416
118682
|
for (const folder of projectFolders(LEGACY_AGENTS)) {
|
|
@@ -118520,10 +118786,10 @@ function readProject2(root2, folder) {
|
|
|
118520
118786
|
const missing = rel(path29.join(dir, AGENT_FILE));
|
|
118521
118787
|
if (!found) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
118522
118788
|
const from = rel(path29.join(dir, found.name));
|
|
118523
|
-
const
|
|
118524
|
-
if ("problem" in
|
|
118525
|
-
if ("agent" in
|
|
118526
|
-
return
|
|
118789
|
+
const read3 = parseSpecAgent(found.text, from, file2, false, () => ownFiles(walkFolder(dir, "")));
|
|
118790
|
+
if ("problem" in read3) return { ...read3, file: from };
|
|
118791
|
+
if ("agent" in read3) Object.assign(read3.agent, { dir, text: found.text });
|
|
118792
|
+
return read3;
|
|
118527
118793
|
}
|
|
118528
118794
|
|
|
118529
118795
|
// ../cli/src/lib/question-block.ts
|
|
@@ -118786,12 +119052,12 @@ function readFolder(id, problems) {
|
|
|
118786
119052
|
problems.push(`${rel(fileOf(id))} is missing`);
|
|
118787
119053
|
return null;
|
|
118788
119054
|
}
|
|
118789
|
-
const
|
|
118790
|
-
if ("problem" in
|
|
118791
|
-
problems.push(
|
|
119055
|
+
const read3 = parseWorkflowFile(id, source, rel(fileOf(id)));
|
|
119056
|
+
if ("problem" in read3) {
|
|
119057
|
+
problems.push(read3.problem);
|
|
118792
119058
|
return null;
|
|
118793
119059
|
}
|
|
118794
|
-
return
|
|
119060
|
+
return read3.def;
|
|
118795
119061
|
}
|
|
118796
119062
|
function boardWorkflowDefs() {
|
|
118797
119063
|
const problems = [];
|
|
@@ -118971,6 +119237,9 @@ var attr = (name) => new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`);
|
|
|
118971
119237
|
var SRC_ATTR = attr("src");
|
|
118972
119238
|
var LABEL_ATTR = attr("label");
|
|
118973
119239
|
|
|
119240
|
+
// ../cli/src/lib/preview-files.ts
|
|
119241
|
+
init_dress_page();
|
|
119242
|
+
|
|
118974
119243
|
// ../cli/src/lib/preview-validation.ts
|
|
118975
119244
|
function renderError(error) {
|
|
118976
119245
|
if (!error || typeof error !== "object") return String(error);
|
|
@@ -118979,19 +119248,9 @@ function renderError(error) {
|
|
|
118979
119248
|
const reason = message ?? String(error);
|
|
118980
119249
|
return location && !reason.includes(location) ? `${reason} (${location})` : reason;
|
|
118981
119250
|
}
|
|
118982
|
-
|
|
118983
|
-
|
|
118984
|
-
|
|
118985
|
-
for (const file2 of files) entries.set(fs29.existsSync(file2) ? fs29.realpathSync(file2) : path33.resolve(file2), path33.resolve(file2));
|
|
118986
|
-
for (const file2 of entries.values()) {
|
|
118987
|
-
try {
|
|
118988
|
-
await drawMockup(file2);
|
|
118989
|
-
} catch (error) {
|
|
118990
|
-
errors.push({ file: file2, line: 1, rule: "preview-render", message: renderError(error) });
|
|
118991
|
-
}
|
|
118992
|
-
}
|
|
118993
|
-
return errors;
|
|
118994
|
-
}
|
|
119251
|
+
|
|
119252
|
+
// src/task-folder.ts
|
|
119253
|
+
init_dress_page();
|
|
118995
119254
|
|
|
118996
119255
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
118997
119256
|
import fs30 from "node:fs";
|
|
@@ -119000,8 +119259,8 @@ function sharedMemory(board) {
|
|
|
119000
119259
|
const declared = /* @__PURE__ */ new Map();
|
|
119001
119260
|
const take = (folder, text4, builtIn) => {
|
|
119002
119261
|
if (text4 === null || declared.has(folder)) return;
|
|
119003
|
-
const
|
|
119004
|
-
if ("agent" in
|
|
119262
|
+
const read3 = parseSpecAgent(text4, folder, () => null, builtIn);
|
|
119263
|
+
if ("agent" in read3 && read3.agent.name === folder) declared.set(folder, read3.agent.memoryFiles.workspace);
|
|
119005
119264
|
};
|
|
119006
119265
|
for (const [key, text4] of Object.entries(shippedAgentFiles())) {
|
|
119007
119266
|
const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
|
|
@@ -119204,7 +119463,14 @@ function viewOf(ws, base, shared) {
|
|
|
119204
119463
|
}
|
|
119205
119464
|
function assetFiles(ws, list) {
|
|
119206
119465
|
const card = cardFile(ws);
|
|
119207
|
-
|
|
119466
|
+
const at2 = (name) => {
|
|
119467
|
+
try {
|
|
119468
|
+
return assetPath(ws, name, card);
|
|
119469
|
+
} catch {
|
|
119470
|
+
return null;
|
|
119471
|
+
}
|
|
119472
|
+
};
|
|
119473
|
+
return new Set(Object.keys(assetsOf(list)).map(at2).filter((f2) => !!f2).map((f2) => path35.relative(ws.board, f2).split(path35.sep).join("/")));
|
|
119208
119474
|
}
|
|
119209
119475
|
var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
|
|
119210
119476
|
var localFiles = (ws, base) => {
|
|
@@ -119252,15 +119518,15 @@ async function workflowFiles(ws) {
|
|
|
119252
119518
|
const pin = readPin(ws.cloudTask);
|
|
119253
119519
|
const held4 = pin && readVersion2(pin.workflow, pin.version);
|
|
119254
119520
|
if (held4) return { ok: true, value: held4.files };
|
|
119255
|
-
const
|
|
119256
|
-
if (!
|
|
119257
|
-
savePin(ws.cloudTask, { id:
|
|
119258
|
-
return { ok: true, value:
|
|
119521
|
+
const read4 = await readTaskWorkflow(ws.cloudTask);
|
|
119522
|
+
if (!read4.ok) return read4;
|
|
119523
|
+
savePin(ws.cloudTask, { id: read4.value.workflow, version: read4.value.version, name: read4.value.name ?? read4.value.workflow, files: read4.value.files });
|
|
119524
|
+
return { ok: true, value: read4.value.files };
|
|
119259
119525
|
}
|
|
119260
|
-
const
|
|
119261
|
-
if (!
|
|
119262
|
-
saveVersion({ id: workflow, version:
|
|
119263
|
-
return { ok: true, value:
|
|
119526
|
+
const read3 = await readWorkflow(workflow);
|
|
119527
|
+
if (!read3.ok) return read3;
|
|
119528
|
+
saveVersion({ id: workflow, version: read3.value.version, name: read3.value.name ?? workflow, files: read3.value.files });
|
|
119529
|
+
return { ok: true, value: read3.value.files };
|
|
119264
119530
|
}
|
|
119265
119531
|
async function pullWorkflow(ws, record) {
|
|
119266
119532
|
if (ws.workflow) {
|
|
@@ -119300,14 +119566,14 @@ function pullDraftAgents(ws, record) {
|
|
|
119300
119566
|
}
|
|
119301
119567
|
function assetPath(ws, name, owner) {
|
|
119302
119568
|
if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
|
|
119303
|
-
if (path35.isAbsolute(name)) throw new Error(
|
|
119569
|
+
if (path35.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
|
|
119304
119570
|
const held4 = /^\.(assets|mockups)\//.exec(name);
|
|
119305
119571
|
const state = stateDir(ws);
|
|
119306
119572
|
const root2 = held4 && state ? path35.join(state, held4[1]) : ws.board;
|
|
119307
119573
|
const file2 = held4 && state ? path35.resolve(root2, name.slice(held4[0].length)) : path35.resolve(path35.dirname(owner), name);
|
|
119308
119574
|
const roots = [ws.board, ...state ? ["assets", "mockups"].map((folder) => path35.join(state, folder, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
119309
119575
|
const inside = (file3, root3) => file3.startsWith(root3 + path35.sep);
|
|
119310
|
-
if (!roots.some((root3) => inside(file2, root3))) throw new Error(
|
|
119576
|
+
if (!roots.some((root3) => inside(file2, root3))) throw new Error(`outside the board: ${name}`);
|
|
119311
119577
|
let existing = file2;
|
|
119312
119578
|
while (!fs31.existsSync(existing) && path35.dirname(existing) !== existing) existing = path35.dirname(existing);
|
|
119313
119579
|
const real = fs31.realpathSync(existing);
|
|
@@ -119315,7 +119581,7 @@ function assetPath(ws, name, owner) {
|
|
|
119315
119581
|
while (stateParent && !fs31.existsSync(stateParent) && path35.dirname(stateParent) !== stateParent) stateParent = path35.dirname(stateParent);
|
|
119316
119582
|
const realState = state && stateParent ? path35.resolve(fs31.realpathSync(stateParent), path35.relative(stateParent, state)) : null;
|
|
119317
119583
|
const realRoots = [fs31.realpathSync(ws.board), ...realState ? ["assets", "mockups"].map((folder) => path35.join(realState, folder, ...ws.number ? [String(ws.number)] : [])) : []];
|
|
119318
|
-
if (!realRoots.some((root3) => real === root3 || inside(real, root3))) throw new Error(
|
|
119584
|
+
if (!realRoots.some((root3) => real === root3 || inside(real, root3))) throw new Error(`link outside the board: ${name}`);
|
|
119319
119585
|
return file2;
|
|
119320
119586
|
}
|
|
119321
119587
|
function cardAssetsDir(ws, id) {
|
|
@@ -119353,12 +119619,12 @@ var readHead = (ws) => readBase(ws).head_seq;
|
|
|
119353
119619
|
var pullChanges = (ws) => inFolder(ws.cwd, async () => {
|
|
119354
119620
|
const base = readBase(ws);
|
|
119355
119621
|
if (base.head_seq === null) return { ok: true, value: void 0 };
|
|
119356
|
-
const
|
|
119357
|
-
if (!
|
|
119622
|
+
const read3 = await readBoard(ws.project, base.head_seq);
|
|
119623
|
+
if (!read3.ok) return read3;
|
|
119358
119624
|
const shared = sharedMemory(ws.board);
|
|
119359
119625
|
const root2 = rootOf(ws);
|
|
119360
119626
|
let skipped = false;
|
|
119361
|
-
for (const f2 of
|
|
119627
|
+
for (const f2 of read3.value.files) {
|
|
119362
119628
|
const p2 = f2.path.startsWith(root2) ? f2.path.slice(root2.length) : f2.path;
|
|
119363
119629
|
const isShared = p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length));
|
|
119364
119630
|
if (kept3(p2) && isShared === !f2.path.startsWith(root2)) {
|
|
@@ -119374,7 +119640,7 @@ var pullChanges = (ws) => inFolder(ws.cwd, async () => {
|
|
|
119374
119640
|
if (f2.content === null) delete base.files[f2.path];
|
|
119375
119641
|
else base.files[f2.path] = { seq: f2.seq, content: f2.content };
|
|
119376
119642
|
}
|
|
119377
|
-
if (!skipped) base.head_seq =
|
|
119643
|
+
if (!skipped) base.head_seq = read3.value.head_seq;
|
|
119378
119644
|
writeBase(ws, base);
|
|
119379
119645
|
writeIndex(ws.board);
|
|
119380
119646
|
return { ok: true, value: void 0 };
|
|
@@ -119388,14 +119654,14 @@ async function readCloud(ws) {
|
|
|
119388
119654
|
if (!project.ok) return project;
|
|
119389
119655
|
base.workspace = project.value.workspace ?? null;
|
|
119390
119656
|
}
|
|
119391
|
-
const
|
|
119392
|
-
if (!
|
|
119657
|
+
const read3 = await readBoard(ws.project, base.head_seq);
|
|
119658
|
+
if (!read3.ok) return read3;
|
|
119393
119659
|
if (base.head_seq === null) base.files = {};
|
|
119394
|
-
for (const f2 of
|
|
119660
|
+
for (const f2 of read3.value.files) {
|
|
119395
119661
|
if (f2.content === null) delete base.files[f2.path];
|
|
119396
119662
|
else base.files[f2.path] = { seq: f2.seq, content: f2.content };
|
|
119397
119663
|
}
|
|
119398
|
-
base.head_seq =
|
|
119664
|
+
base.head_seq = read3.value.head_seq;
|
|
119399
119665
|
base.project = ws.project;
|
|
119400
119666
|
writeBase(ws, base);
|
|
119401
119667
|
const reset = (view2) => {
|
|
@@ -119457,9 +119723,13 @@ async function pullAssets(ws, record, assets) {
|
|
|
119457
119723
|
const file2 = cardFile(ws);
|
|
119458
119724
|
const out = {};
|
|
119459
119725
|
for (const [name, ref] of Object.entries(assets)) {
|
|
119726
|
+
const held4 = record.assets[name];
|
|
119727
|
+
if (ref.error && !ref.version) {
|
|
119728
|
+
if (held4?.artifact === ref.artifact) out[name] = held4;
|
|
119729
|
+
continue;
|
|
119730
|
+
}
|
|
119460
119731
|
const target = assetPath(ws, name, file2);
|
|
119461
119732
|
if (!target) continue;
|
|
119462
|
-
const held4 = record.assets[name];
|
|
119463
119733
|
let kind = held4?.artifact === ref.artifact ? held4.kind : void 0;
|
|
119464
119734
|
let version = ref.version;
|
|
119465
119735
|
const localHash = hashFile(target);
|
|
@@ -119483,29 +119753,34 @@ async function pullAssets(ws, record, assets) {
|
|
|
119483
119753
|
if (!bytes2.ok) return bytes2;
|
|
119484
119754
|
let local = bytes2.value;
|
|
119485
119755
|
const dependencies = [];
|
|
119486
|
-
|
|
119487
|
-
|
|
119488
|
-
|
|
119489
|
-
|
|
119490
|
-
|
|
119491
|
-
|
|
119492
|
-
|
|
119493
|
-
|
|
119494
|
-
|
|
119495
|
-
|
|
119496
|
-
if (!name2) return src;
|
|
119497
|
-
const child = assetPath(ws, name2, file2);
|
|
119498
|
-
if (!child) return src;
|
|
119499
|
-
dependencies.push(name2);
|
|
119500
|
-
const restored2 = /^\.(assets|mockups)\//.test(name2) ? name2 : path35.relative(path35.dirname(target), child).split(path35.sep).join("/");
|
|
119501
|
-
if (restored2 !== src) changed = true;
|
|
119502
|
-
return restored2;
|
|
119503
|
-
};
|
|
119504
|
-
const restored = mapReferences(data, kind, restore);
|
|
119505
|
-
if (changed) local = Buffer.from(JSON.stringify(restored));
|
|
119756
|
+
const manifest = manifestOf(kind);
|
|
119757
|
+
let data;
|
|
119758
|
+
if (manifest?.references) {
|
|
119759
|
+
data = Buffer.from(local).toString();
|
|
119760
|
+
if (manifest.references.some((r2) => "json" in r2)) {
|
|
119761
|
+
try {
|
|
119762
|
+
data = JSON.parse(data);
|
|
119763
|
+
} catch {
|
|
119764
|
+
data = void 0;
|
|
119765
|
+
}
|
|
119506
119766
|
}
|
|
119507
119767
|
}
|
|
119508
|
-
if (
|
|
119768
|
+
if (data !== void 0) {
|
|
119769
|
+
let changed = false;
|
|
119770
|
+
const restored = mapReferences(manifest, data, (src, found) => {
|
|
119771
|
+
const name2 = Object.entries(assets).find(([, r2]) => r2.artifact === src)?.[0];
|
|
119772
|
+
if (!name2) return src;
|
|
119773
|
+
const child = assetPath(ws, name2, file2);
|
|
119774
|
+
if (!child) return src;
|
|
119775
|
+
dependencies.push(name2);
|
|
119776
|
+
const back = !found.text && /^\.(assets|mockups)\//.test(name2) ? name2 : path35.relative(path35.dirname(target), child).split(path35.sep).join("/");
|
|
119777
|
+
if (back !== src) changed = true;
|
|
119778
|
+
return back;
|
|
119779
|
+
});
|
|
119780
|
+
if (changed) local = Buffer.from(typeof restored === "string" ? restored : JSON.stringify(restored));
|
|
119781
|
+
}
|
|
119782
|
+
const json = data !== void 0 && typeof data !== "string";
|
|
119783
|
+
if (held4?.artifact === ref.artifact && held4.version === version && !held4.localHash && json) {
|
|
119509
119784
|
const source = readText(target);
|
|
119510
119785
|
if (source !== null) {
|
|
119511
119786
|
let same = false;
|
|
@@ -119521,7 +119796,8 @@ async function pullAssets(ws, record, assets) {
|
|
|
119521
119796
|
}
|
|
119522
119797
|
}
|
|
119523
119798
|
write(target, local);
|
|
119524
|
-
|
|
119799
|
+
const hash = hashOf2(typeof data === "string" ? local : bytes2.value);
|
|
119800
|
+
out[name] = { ...held4, kind, dependencies: [...new Set(dependencies)], artifact: ref.artifact, version, hash, localHash: hashOf2(local) };
|
|
119525
119801
|
}
|
|
119526
119802
|
record.assets = out;
|
|
119527
119803
|
return { ok: true, value: void 0 };
|
|
@@ -119540,6 +119816,14 @@ async function sentOf(file2) {
|
|
|
119540
119816
|
const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file2);
|
|
119541
119817
|
return { bytes: Buffer.from(page), type: "text/html", kind };
|
|
119542
119818
|
}
|
|
119819
|
+
var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path35.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
|
|
119820
|
+
function undrawn(ws, reason) {
|
|
119821
|
+
const state = stateDir(ws);
|
|
119822
|
+
for (const [root2, shown] of [...state ? [[path35.join(state, "assets"), ".assets"], [path35.join(state, "mockups"), ".mockups"]] : [], [ws.board, ""]]) {
|
|
119823
|
+
reason = reason.split(`file://${root2}${path35.sep}`).join(shown && `${shown}/`).split(`${root2}${path35.sep}`).join(shown && `${shown}/`);
|
|
119824
|
+
}
|
|
119825
|
+
return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
|
|
119826
|
+
}
|
|
119543
119827
|
async function uploadAsset(artifact, { bytes: bytes2, type }) {
|
|
119544
119828
|
const upload2 = await createUpload(artifact, type, Math.max(bytes2.length, 1));
|
|
119545
119829
|
if (!upload2.ok) return upload2;
|
|
@@ -119559,7 +119843,7 @@ async function pushAssets(ws, record, before) {
|
|
|
119559
119843
|
if (body === null) return { ok: true, value: void 0 };
|
|
119560
119844
|
const refs = {};
|
|
119561
119845
|
const canonical = (target) => {
|
|
119562
|
-
const real = (file3) => fs31.existsSync(file3) ? fs31.realpathSync(file3) : file3;
|
|
119846
|
+
const real = (file3) => fs31.existsSync(file3) ? fs31.realpathSync(file3) : path35.dirname(file3) === file3 ? file3 : path35.join(real(path35.dirname(file3)), path35.basename(file3));
|
|
119563
119847
|
target = real(target);
|
|
119564
119848
|
const state = stateDir(ws);
|
|
119565
119849
|
for (const folder of ["assets", "mockups"]) {
|
|
@@ -119578,23 +119862,49 @@ async function pushAssets(ws, record, before) {
|
|
|
119578
119862
|
const key = owner === file2 && before[src] ? src : canonical(target);
|
|
119579
119863
|
if (!fs31.statSync(target, { throwIfNoEntry: false })?.isFile()) {
|
|
119580
119864
|
if (before[key]) return { key, file: null };
|
|
119581
|
-
throw new Error(
|
|
119865
|
+
throw new Error(`file not found: ${target}`);
|
|
119582
119866
|
}
|
|
119583
119867
|
return { key: canonical(fs31.realpathSync(target)), file: target };
|
|
119584
119868
|
},
|
|
119585
|
-
|
|
119869
|
+
read: referenceText,
|
|
119586
119870
|
retained: (key) => (record.assets[key]?.dependencies ?? []).map((src) => {
|
|
119587
119871
|
const kind = record.assets[src]?.kind;
|
|
119588
|
-
return { src,
|
|
119872
|
+
return { src, types: kind ? [kind] : [] };
|
|
119589
119873
|
})
|
|
119590
119874
|
});
|
|
119591
|
-
const errors = await validateScreens(graph.flatMap((node) => node.file && kindOf(path35.extname(node.file).toLowerCase()) === "html" ? [node.file] : []));
|
|
119592
|
-
if (errors.length) return { ok: false, code: "bad_request", error: errors.map((e2) => `${e2.file}: ${e2.message}`).join("\n") };
|
|
119593
119875
|
for (const node of graph) {
|
|
119594
119876
|
const previous = [...node.aliases].map((key) => record.assets[key]).find(Boolean);
|
|
119595
119877
|
const old = [...node.aliases].map((key) => before[key]).find(Boolean);
|
|
119596
|
-
|
|
119597
|
-
|
|
119878
|
+
const kind = node.kind;
|
|
119879
|
+
let out;
|
|
119880
|
+
let why2 = node.error ?? [...node.dependencies.values()].map((key) => refs[key]?.error).find(Boolean);
|
|
119881
|
+
if (!why2 && node.file) {
|
|
119882
|
+
try {
|
|
119883
|
+
out = await sentOf(node.file);
|
|
119884
|
+
} catch (error) {
|
|
119885
|
+
why2 = renderError(error);
|
|
119886
|
+
}
|
|
119887
|
+
}
|
|
119888
|
+
if (why2) {
|
|
119889
|
+
let pin = old ? { artifact: old.artifact, ...old.version ? { version: old.version } : {} } : previous?.version ? { artifact: previous.artifact, version: previous.version } : null;
|
|
119890
|
+
if (!pin) {
|
|
119891
|
+
if (!ws.cloudTask) continue;
|
|
119892
|
+
let artifact = previous?.artifact;
|
|
119893
|
+
if (!artifact) {
|
|
119894
|
+
const made = await createArtifact(ws.cloudTask, node.key.slice(0, 200), kind);
|
|
119895
|
+
if (!made.ok) return { ...made, error: `${node.key}: ${made.error}` };
|
|
119896
|
+
artifact = made.value.id;
|
|
119897
|
+
for (const alias of node.aliases) record.assets[alias] = { artifact, kind, version: 0, hash: "" };
|
|
119898
|
+
writeRecord(ws, record);
|
|
119899
|
+
}
|
|
119900
|
+
pin = { artifact };
|
|
119901
|
+
}
|
|
119902
|
+
for (const alias of node.aliases) refs[alias] = { ...pin, error: undrawn(ws, why2) };
|
|
119903
|
+
continue;
|
|
119904
|
+
}
|
|
119905
|
+
if (!node.file || !out) {
|
|
119906
|
+
if (old?.error && !old.version) for (const alias of node.aliases) refs[alias] = old;
|
|
119907
|
+
else if (old) {
|
|
119598
119908
|
let version = old.version ?? (previous?.artifact === old.artifact ? previous.version : void 0);
|
|
119599
119909
|
if (version === void 0) {
|
|
119600
119910
|
const art = await readArtifact(old.artifact);
|
|
@@ -119605,30 +119915,25 @@ async function pushAssets(ws, record, before) {
|
|
|
119605
119915
|
}
|
|
119606
119916
|
continue;
|
|
119607
119917
|
}
|
|
119608
|
-
const kind = node.kind === "asset" ? kindOf(path35.extname(node.file).toLowerCase()) : node.kind;
|
|
119609
119918
|
if (previous && previous.kind !== kind) {
|
|
119610
119919
|
const artifact = await readArtifact(previous.artifact);
|
|
119611
119920
|
if (!artifact.ok) return artifact;
|
|
119612
119921
|
if (!artifact.value.type) return { ok: false, code: "bad_request", error: `${node.key}: \u8D44\u6E90\u7C7B\u578B\u7F3A\u5931` };
|
|
119613
119922
|
previous.kind = artifact.value.type;
|
|
119614
119923
|
}
|
|
119615
|
-
|
|
119616
|
-
|
|
119617
|
-
|
|
119618
|
-
|
|
119619
|
-
throw new Error(`${node.file}: ${renderError(error)}`);
|
|
119620
|
-
}
|
|
119621
|
-
if (node.kind !== "asset") {
|
|
119622
|
-
const data = mapReferences(node.data, node.kind, (src) => {
|
|
119924
|
+
const manifest = manifestOf(kind);
|
|
119925
|
+
const json = !!manifest?.references && node.data !== void 0 && typeof node.data !== "string";
|
|
119926
|
+
if (manifest?.references && node.data !== void 0) {
|
|
119927
|
+
const map2 = (src) => {
|
|
119623
119928
|
const key = node.dependencies.get(src);
|
|
119624
119929
|
return key ? refs[key]?.artifact ?? src : src;
|
|
119625
|
-
}
|
|
119626
|
-
out = { kind
|
|
119930
|
+
};
|
|
119931
|
+
out = json ? { kind, type: "application/json", bytes: Buffer.from(JSON.stringify(mapReferences(manifest, node.data, map2))) } : { ...out, bytes: Buffer.from(mapReferences(manifest, Buffer.from(out.bytes).toString(), map2)) };
|
|
119627
119932
|
}
|
|
119628
119933
|
const hash = hashOf2(out.bytes);
|
|
119629
119934
|
let entry = previous;
|
|
119630
119935
|
const localHash = hashFile(node.file);
|
|
119631
|
-
const restored =
|
|
119936
|
+
const restored = json || out.kind === "html" && previous?.hash === localHash;
|
|
119632
119937
|
const unchanged = restored && previous && (previous.kind ?? out.kind) === out.kind && localHash === (previous.localHash ?? previous.hash) && [...node.dependencies.values()].every((key) => refs[key]?.artifact === before[key]?.artifact);
|
|
119633
119938
|
if (!entry || !unchanged && entry.hash !== hash || entry.kind && entry.kind !== out.kind) {
|
|
119634
119939
|
if (!ws.cloudTask) continue;
|
|
@@ -119766,18 +120071,18 @@ async function send2(ws, job) {
|
|
|
119766
120071
|
for (const p2 of local) {
|
|
119767
120072
|
if (defer(p2) || owed(p2)) continue;
|
|
119768
120073
|
const content = fs31.readFileSync(path35.join(ws.board, p2), "utf8");
|
|
119769
|
-
const
|
|
119770
|
-
localOf.set(
|
|
119771
|
-
const held4 = base.files[
|
|
120074
|
+
const remote2 = remoteOf(ws, shared, p2);
|
|
120075
|
+
localOf.set(remote2, p2);
|
|
120076
|
+
const held4 = base.files[remote2];
|
|
119772
120077
|
if (held4?.content === content) continue;
|
|
119773
120078
|
if (Buffer.byteLength(content) > BOARD_FILE_LIMIT) return fail(`${p2} is over ${BOARD_FILE_LIMIT / 1024} KB; keep large files as assets.`, false, "too_large");
|
|
119774
|
-
changes.push({ path:
|
|
120079
|
+
changes.push({ path: remote2, content, base_seq: held4?.seq ?? 0 });
|
|
119775
120080
|
}
|
|
119776
120081
|
for (const p2 of viewOf(ws, base, shared).keys()) {
|
|
119777
|
-
const
|
|
119778
|
-
if (!defer(p2) && kept3(p2) && !localOf.has(
|
|
119779
|
-
localOf.set(
|
|
119780
|
-
changes.push({ path:
|
|
120082
|
+
const remote2 = remoteOf(ws, shared, p2);
|
|
120083
|
+
if (!defer(p2) && kept3(p2) && !localOf.has(remote2) && base.files[remote2]) {
|
|
120084
|
+
localOf.set(remote2, p2);
|
|
120085
|
+
changes.push({ path: remote2, content: null, base_seq: base.files[remote2].seq });
|
|
119781
120086
|
}
|
|
119782
120087
|
}
|
|
119783
120088
|
const memory = rootOf(ws) + MEMORY2;
|
|
@@ -119840,8 +120145,8 @@ function watchBoards(machineId2, ms, lookMs = LOOK_MS, pullMs = PULL_MS, busyMs
|
|
|
119840
120145
|
if (closed) return;
|
|
119841
120146
|
if (busy(ws.cwd)) return void afterJob.add(ws.cwd);
|
|
119842
120147
|
afterJob.delete(ws.cwd);
|
|
119843
|
-
const
|
|
119844
|
-
if (!
|
|
120148
|
+
const read3 = await pullChanges(ws);
|
|
120149
|
+
if (!read3.ok && read3.code) console.error(`runner: the board in ${ws.cwd} was not read: ${read3.error}`);
|
|
119845
120150
|
};
|
|
119846
120151
|
const send3 = async (ws) => {
|
|
119847
120152
|
const sent = await pushBoard(ws, machineId2);
|
|
@@ -120278,7 +120583,7 @@ import { spawnSync as spawnSync5 } from "node:child_process";
|
|
|
120278
120583
|
import fs37 from "node:fs";
|
|
120279
120584
|
import path40 from "node:path";
|
|
120280
120585
|
var MARKER_LINE = /^# ai4kanban commit guard\b/m;
|
|
120281
|
-
var
|
|
120586
|
+
var read2 = (file2) => {
|
|
120282
120587
|
try {
|
|
120283
120588
|
return fs37.readFileSync(file2, "utf8");
|
|
120284
120589
|
} catch {
|
|
@@ -120299,7 +120604,7 @@ function installCommitHook(root2, _board) {
|
|
|
120299
120604
|
if (!dir) return {};
|
|
120300
120605
|
const file2 = path40.join(dir, "pre-commit");
|
|
120301
120606
|
if (fs37.lstatSync(file2, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
|
|
120302
|
-
const source =
|
|
120607
|
+
const source = read2(file2);
|
|
120303
120608
|
if (source && MARKER_LINE.test(source)) fs37.unlinkSync(file2);
|
|
120304
120609
|
return {};
|
|
120305
120610
|
}
|
|
@@ -120311,15 +120616,15 @@ var isBuilder = (ws) => ws.workflow === BUILDER;
|
|
|
120311
120616
|
var draftDir = (ws) => path41.join(ws.board, "workflows", draftFolder(ws.task));
|
|
120312
120617
|
var draftLine = (ws) => `<!-- workflow folder: ${path41.relative(ws.cwd, draftDir(ws)).split(path41.sep).join("/")}/ -->`;
|
|
120313
120618
|
var skeleton = (name) => ["---", `name: ${/\s#/.test(name) ? JSON.stringify(name) : yamlScalar(name)}`, "needsArtifact: false", "---", ""].join("\n");
|
|
120314
|
-
async function placeDraft(ws,
|
|
120619
|
+
async function placeDraft(ws, read3) {
|
|
120315
120620
|
const dir = draftDir(ws);
|
|
120316
120621
|
if (fs38.existsSync(path41.join(dir, WORKFLOW_FILE))) return { ok: true, value: void 0 };
|
|
120317
|
-
const task = await
|
|
120622
|
+
const task = await read3.readTask(ws.task);
|
|
120318
120623
|
if (!task.ok) return task;
|
|
120319
120624
|
let files = { [WORKFLOW_FILE]: skeleton(task.value.title.trim() || "Untitled") };
|
|
120320
120625
|
const changes = task.value.context?.workflow;
|
|
120321
120626
|
if (changes) {
|
|
120322
|
-
const held4 = await
|
|
120627
|
+
const held4 = await read3.readWorkflow(changes);
|
|
120323
120628
|
if (!held4.ok) return held4;
|
|
120324
120629
|
files = held4.value.files;
|
|
120325
120630
|
}
|
|
@@ -120343,9 +120648,9 @@ async function builtWorkflow(ws, akb) {
|
|
|
120343
120648
|
} catch {
|
|
120344
120649
|
return fail(`workflows/${id}/${WORKFLOW_FILE} is missing.`);
|
|
120345
120650
|
}
|
|
120346
|
-
const
|
|
120347
|
-
if ("problem" in
|
|
120348
|
-
const names2 = named(
|
|
120651
|
+
const read3 = parseWorkflowFile(id, source, `workflows/${id}/${WORKFLOW_FILE}`);
|
|
120652
|
+
if ("problem" in read3) return fail(read3.problem);
|
|
120653
|
+
const names2 = named(read3.def);
|
|
120349
120654
|
fs38.rmSync(path41.join(dir, "agents"), { recursive: true, force: true });
|
|
120350
120655
|
for (const name of names2) {
|
|
120351
120656
|
const from = path41.join(ws.board, "agents", name);
|
|
@@ -120587,13 +120892,13 @@ async function runReview(job, ws, tasks, deps, io) {
|
|
|
120587
120892
|
async function reviewRejections(job, ws, deps, io) {
|
|
120588
120893
|
const workspace = workspaceOf(ws);
|
|
120589
120894
|
if (!workspace) return { runs: [] };
|
|
120590
|
-
const
|
|
120591
|
-
if (!
|
|
120592
|
-
if (!
|
|
120895
|
+
const read3 = await deps.api.readRejections(workspace);
|
|
120896
|
+
if (!read3.ok) return { runs: [], failure: read3.error };
|
|
120897
|
+
if (!read3.value.tasks.length && !read3.value.triage.length) return { runs: [] };
|
|
120593
120898
|
const since = Date.now();
|
|
120594
120899
|
const akb = boardAkb(job, ws, deps, io);
|
|
120595
120900
|
return withBoard(ws, async (push2) => {
|
|
120596
|
-
const laid = layOut(ws.board,
|
|
120901
|
+
const laid = layOut(ws.board, read3.value);
|
|
120597
120902
|
const ran = await akb(["review-dismissals", "--follow", "--events", "--json"], true);
|
|
120598
120903
|
clearLaid(ws.board);
|
|
120599
120904
|
resetSorted(ws);
|
|
@@ -120612,12 +120917,12 @@ async function learnRejections(job, ws, deps, io) {
|
|
|
120612
120917
|
return runs;
|
|
120613
120918
|
}
|
|
120614
120919
|
async function scheduledEnv(ws, deps) {
|
|
120615
|
-
const
|
|
120616
|
-
if (!
|
|
120617
|
-
console.error(`runner: scheduled agents not read: ${
|
|
120920
|
+
const read3 = await deps.api.readAgents(deps.machineId, ws.project);
|
|
120921
|
+
if (!read3.ok) {
|
|
120922
|
+
console.error(`runner: scheduled agents not read: ${read3.error}`);
|
|
120618
120923
|
return {};
|
|
120619
120924
|
}
|
|
120620
|
-
const names2 =
|
|
120925
|
+
const names2 = read3.value.agents.filter((a2) => a2.workflow).map((a2) => a2.name);
|
|
120621
120926
|
return { [SCHEDULED_AGENTS_ENV]: [...new Set(names2)].join(",") };
|
|
120622
120927
|
}
|
|
120623
120928
|
async function runAgent(job, ws, deps, io) {
|
|
@@ -122257,10 +122562,13 @@ function report(job, run2, turn2) {
|
|
|
122257
122562
|
var cutShort = (said, text4) => ({ ...said, reply: said.reply || text4 || void 0, stopped: true });
|
|
122258
122563
|
function folderLines(ws) {
|
|
122259
122564
|
if (!ws) return "";
|
|
122565
|
+
const undrawn2 = undrawnPreviews(ws);
|
|
122260
122566
|
return `
|
|
122261
122567
|
|
|
122262
122568
|
Task card: ${cardFile(ws)}
|
|
122263
|
-
Memory: ${ws.board}/memory
|
|
122569
|
+
Memory: ${ws.board}/memory` + (undrawn2.length ? `
|
|
122570
|
+
Previews that cannot be drawn:
|
|
122571
|
+
${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
|
|
122264
122572
|
}
|
|
122265
122573
|
|
|
122266
122574
|
// src/presence.ts
|