wildcrane-runner 0.6.45 → 0.6.47

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.
@@ -1 +1 @@
1
- {"name":"wildcrane","version":"0.11.39","akbContract":10,"type":"module","private":true}
1
+ {"name":"wildcrane","version":"0.11.41","akbContract":11,"type":"module","private":true}
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.45 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.47 — 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;
package/dist/launcher.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.45 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.47 — 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;
@@ -26889,8 +26889,8 @@ function saveAlphaUpdates(value) {
26889
26889
  }
26890
26890
 
26891
26891
  // src/protocol.ts
26892
- var VERSION = true ? "0.6.45" : "0.0.0";
26893
- var AKB_VERSION = true ? "0.11.39" : "0.0.0";
26892
+ var VERSION = true ? "0.6.47" : "0.0.0";
26893
+ var AKB_VERSION = true ? "0.11.41" : "0.0.0";
26894
26894
  var EXIT_REFUSED = 10;
26895
26895
  var EXIT_OUTDATED = 11;
26896
26896
  var EXIT_UPDATE = 12;
@@ -27747,8 +27747,11 @@ import path16 from "node:path";
27747
27747
  import fs12 from "node:fs";
27748
27748
  import path14 from "node:path";
27749
27749
 
27750
+ // ../cli/src/lib/shared/file-limits.ts
27751
+ var BOARD_FILE_LIMIT = 10 * 1024 * 1024;
27752
+ var ASSET_FILE_LIMIT = 100 * 1024 * 1024;
27753
+
27750
27754
  // ../cli/src/lib/shared/board-files.ts
27751
- var BOARD_FILE_LIMIT = 256 * 1024;
27752
27755
  var studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
27753
27756
  var studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
27754
27757
 
@@ -28048,7 +28051,7 @@ function readTranslations(raw) {
28048
28051
  }
28049
28052
  return out;
28050
28053
  }
28051
- function memoryPaths(raw) {
28054
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
28052
28055
  if (raw === void 0) return [];
28053
28056
  const block = map(raw);
28054
28057
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
@@ -28060,7 +28063,7 @@ function memoryPaths(raw) {
28060
28063
  }
28061
28064
  const paths = [...new Set(list.map((v) => v.trim()))];
28062
28065
  const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
28063
- if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`memory/agents/<name>/\``;
28066
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
28064
28067
  return paths;
28065
28068
  }
28066
28069
  var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str(v)).filter(Boolean))];
@@ -28139,6 +28142,8 @@ function parseStudioFile(id, source, from) {
28139
28142
  if (!agent || scheduled.some((s) => s.agent === agent)) continue;
28140
28143
  scheduled.push({ agent, ...text(row.cadence) ? { cadence: text(row.cadence) } : {} });
28141
28144
  }
28145
+ const workspace = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
28146
+ if (typeof workspace === "string") return { problem: `${from}: declares ${workspace}` };
28142
28147
  const names2 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said]) => [lang, text(said)]).filter(([, said]) => said));
28143
28148
  return {
28144
28149
  def: {
@@ -28152,6 +28157,7 @@ function parseStudioFile(id, source, from) {
28152
28157
  previews,
28153
28158
  land,
28154
28159
  scheduled,
28160
+ ...workspace.length ? { memoryFiles: { workspace } } : {},
28155
28161
  rules: body.trim()
28156
28162
  }
28157
28163
  };
@@ -28164,6 +28170,8 @@ import path8 from "node:path";
28164
28170
  // ../cli/src/lib/shared/studio-files.ts
28165
28171
  var STUDIO_FILE = "STUDIO.md";
28166
28172
  var MCP_FILE = "mcp.json";
28173
+ var CARD_TEMPLATE_FILE = "CARD.md";
28174
+ var SHARED_DIR = "shared/";
28167
28175
  var VERSION_FILE = "version.json";
28168
28176
  var KB = 1024;
28169
28177
  var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
@@ -28173,6 +28181,10 @@ var landsOf = (def) => ({ lands: def.land.some((h) => !h.off) });
28173
28181
  var SEGMENT = /^[\w.-]+$/;
28174
28182
  var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
28175
28183
  var bytes = (text3) => new TextEncoder().encode(text3).length;
28184
+ var isSharedFile = (file2) => {
28185
+ const parts = file2.split("/");
28186
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
28187
+ };
28176
28188
  function folderPath(file2, top) {
28177
28189
  const parts = file2.split("/");
28178
28190
  if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
@@ -28228,7 +28240,7 @@ function inspect(value, official) {
28228
28240
  if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
28229
28241
  total += size;
28230
28242
  if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
28231
- if (file2 === STUDIO_FILE) continue;
28243
+ if (file2 === STUDIO_FILE || file2 === CARD_TEMPLATE_FILE) continue;
28232
28244
  if (official && file2 === MCP_FILE) {
28233
28245
  const problem = mcpProblem(text3);
28234
28246
  if (problem) fail(file2, problem);
@@ -28240,9 +28252,10 @@ function inspect(value, official) {
28240
28252
  else skills.add(file2.split("/")[1]);
28241
28253
  continue;
28242
28254
  }
28255
+ if (isSharedFile(file2)) continue;
28243
28256
  const at = folderPath(file2, "agents");
28244
28257
  if (!at) {
28245
- fail(file2, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
28258
+ fail(file2, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
28246
28259
  continue;
28247
28260
  }
28248
28261
  if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
@@ -28314,7 +28327,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
28314
28327
  const dir = path9.join(studiosDir, folder);
28315
28328
  const files = {};
28316
28329
  for (const f of filesOf(dir).sort()) {
28317
- if (f === STUDIO_FILE || f === MCP_FILE || f.startsWith("skills/") || isAboutFile(f)) files[f] = readStudioFile(dir, f);
28330
+ if (f === STUDIO_FILE || f === CARD_TEMPLATE_FILE || f === MCP_FILE || f.startsWith("skills/") || f.startsWith(SHARED_DIR) || isAboutFile(f)) files[f] = readStudioFile(dir, f);
28318
28331
  }
28319
28332
  const read2 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
28320
28333
  Object.entries(agentFiles).flatMap(([name, own2]) => Object.entries(own2).map(([f, t2]) => [`agents/${name}/${f}`, t2]))
@@ -30461,8 +30474,8 @@ function createTail(log) {
30461
30474
  // ../cli/package.json
30462
30475
  var package_default = {
30463
30476
  name: "wildcrane",
30464
- version: "0.11.39",
30465
- akbContract: 10,
30477
+ version: "0.11.41",
30478
+ akbContract: 11,
30466
30479
  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.",
30467
30480
  keywords: [
30468
30481
  "kanban",
package/dist/plugin.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.45 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.47 — 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;
@@ -73760,8 +73760,8 @@ function machineId() {
73760
73760
  var machineName = () => os2.hostname().replace(/\.local$/, "");
73761
73761
 
73762
73762
  // src/protocol.ts
73763
- var VERSION = true ? "0.6.45" : "0.0.0";
73764
- var AKB_VERSION = true ? "0.11.39" : "0.0.0";
73763
+ var VERSION = true ? "0.6.47" : "0.0.0";
73764
+ var AKB_VERSION = true ? "0.11.41" : "0.0.0";
73765
73765
  var EXIT_REFUSED = 10;
73766
73766
  var EXIT_OUTDATED = 11;
73767
73767
  var EXIT_UPDATE = 12;
@@ -73905,8 +73905,11 @@ import path13 from "node:path";
73905
73905
  import fs9 from "node:fs";
73906
73906
  import path11 from "node:path";
73907
73907
 
73908
+ // ../cli/src/lib/shared/file-limits.ts
73909
+ var BOARD_FILE_LIMIT = 10 * 1024 * 1024;
73910
+ var ASSET_FILE_LIMIT = 100 * 1024 * 1024;
73911
+
73908
73912
  // ../cli/src/lib/shared/board-files.ts
73909
- var BOARD_FILE_LIMIT = 256 * 1024;
73910
73913
  var studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
73911
73914
  var studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
73912
73915
 
@@ -74206,7 +74209,7 @@ function readTranslations(raw) {
74206
74209
  }
74207
74210
  return out;
74208
74211
  }
74209
- function memoryPaths(raw) {
74212
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
74210
74213
  if (raw === void 0) return [];
74211
74214
  const block = map(raw);
74212
74215
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
@@ -74218,7 +74221,7 @@ function memoryPaths(raw) {
74218
74221
  }
74219
74222
  const paths = [...new Set(list.map((v) => v.trim()))];
74220
74223
  const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
74221
- if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`memory/agents/<name>/\``;
74224
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
74222
74225
  return paths;
74223
74226
  }
74224
74227
  var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str(v)).filter(Boolean))];
@@ -74297,6 +74300,8 @@ function parseStudioFile(id, source, from) {
74297
74300
  if (!agent || scheduled.some((s) => s.agent === agent)) continue;
74298
74301
  scheduled.push({ agent, ...text(row.cadence) ? { cadence: text(row.cadence) } : {} });
74299
74302
  }
74303
+ const workspace = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
74304
+ if (typeof workspace === "string") return { problem: `${from}: declares ${workspace}` };
74300
74305
  const names2 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said]) => [lang, text(said)]).filter(([, said]) => said));
74301
74306
  return {
74302
74307
  def: {
@@ -74310,6 +74315,7 @@ function parseStudioFile(id, source, from) {
74310
74315
  previews,
74311
74316
  land,
74312
74317
  scheduled,
74318
+ ...workspace.length ? { memoryFiles: { workspace } } : {},
74313
74319
  rules: body.trim()
74314
74320
  }
74315
74321
  };
@@ -74322,6 +74328,8 @@ import path5 from "node:path";
74322
74328
  // ../cli/src/lib/shared/studio-files.ts
74323
74329
  var STUDIO_FILE = "STUDIO.md";
74324
74330
  var MCP_FILE = "mcp.json";
74331
+ var CARD_TEMPLATE_FILE = "CARD.md";
74332
+ var SHARED_DIR = "shared/";
74325
74333
  var VERSION_FILE = "version.json";
74326
74334
  var KB = 1024;
74327
74335
  var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
@@ -74331,6 +74339,10 @@ var landsOf = (def) => ({ lands: def.land.some((h) => !h.off) });
74331
74339
  var SEGMENT = /^[\w.-]+$/;
74332
74340
  var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
74333
74341
  var bytes = (text4) => new TextEncoder().encode(text4).length;
74342
+ var isSharedFile = (file2) => {
74343
+ const parts = file2.split("/");
74344
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
74345
+ };
74334
74346
  function folderPath(file2, top) {
74335
74347
  const parts = file2.split("/");
74336
74348
  if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
@@ -74386,7 +74398,7 @@ function inspect(value, official) {
74386
74398
  if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
74387
74399
  total += size;
74388
74400
  if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
74389
- if (file2 === STUDIO_FILE) continue;
74401
+ if (file2 === STUDIO_FILE || file2 === CARD_TEMPLATE_FILE) continue;
74390
74402
  if (official && file2 === MCP_FILE) {
74391
74403
  const problem = mcpProblem(text4);
74392
74404
  if (problem) fail(file2, problem);
@@ -74398,9 +74410,10 @@ function inspect(value, official) {
74398
74410
  else skills.add(file2.split("/")[1]);
74399
74411
  continue;
74400
74412
  }
74413
+ if (isSharedFile(file2)) continue;
74401
74414
  const at = folderPath(file2, "agents");
74402
74415
  if (!at) {
74403
- fail(file2, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
74416
+ fail(file2, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
74404
74417
  continue;
74405
74418
  }
74406
74419
  if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
@@ -74472,7 +74485,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
74472
74485
  const dir = path6.join(studiosDir, folder);
74473
74486
  const files = {};
74474
74487
  for (const f of filesOf(dir).sort()) {
74475
- if (f === STUDIO_FILE || f === MCP_FILE || f.startsWith("skills/") || isAboutFile(f)) files[f] = readStudioFile(dir, f);
74488
+ if (f === STUDIO_FILE || f === CARD_TEMPLATE_FILE || f === MCP_FILE || f.startsWith("skills/") || f.startsWith(SHARED_DIR) || isAboutFile(f)) files[f] = readStudioFile(dir, f);
74476
74489
  }
74477
74490
  const read2 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
74478
74491
  Object.entries(agentFiles).flatMap(([name, own3]) => Object.entries(own3).map(([f, t2]) => [`agents/${name}/${f}`, t2]))
@@ -77044,8 +77057,8 @@ function createTail(log) {
77044
77057
  // ../cli/package.json
77045
77058
  var package_default = {
77046
77059
  name: "wildcrane",
77047
- version: "0.11.39",
77048
- akbContract: 10,
77060
+ version: "0.11.41",
77061
+ akbContract: 11,
77049
77062
  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.",
77050
77063
  keywords: [
77051
77064
  "kanban",
package/dist/runner.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.45 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.47 — 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;
@@ -111406,9 +111406,9 @@ function status(line) {
111406
111406
  }
111407
111407
 
111408
111408
  // src/protocol.ts
111409
- var VERSION = true ? "0.6.45" : "0.0.0";
111410
- var AKB_VERSION = true ? "0.11.39" : "0.0.0";
111411
- var AKB_CONTRACT = true ? 10 : 0;
111409
+ var VERSION = true ? "0.6.47" : "0.0.0";
111410
+ var AKB_VERSION = true ? "0.11.41" : "0.0.0";
111411
+ var AKB_CONTRACT = true ? 11 : 0;
111412
111412
  var EXIT_REFUSED = 10;
111413
111413
  var EXIT_OUTDATED = 11;
111414
111414
  var EXIT_UPDATE = 12;
@@ -113053,8 +113053,8 @@ function createTail(log) {
113053
113053
  // ../cli/package.json
113054
113054
  var package_default = {
113055
113055
  name: "wildcrane",
113056
- version: "0.11.39",
113057
- akbContract: 10,
113056
+ version: "0.11.41",
113057
+ akbContract: 11,
113058
113058
  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.",
113059
113059
  keywords: [
113060
113060
  "kanban",
@@ -115346,6 +115346,7 @@ __export(api_exports, {
115346
115346
  answerDiff: () => answerDiff,
115347
115347
  claimJob: () => claimJob,
115348
115348
  commitBoard: () => commitBoard,
115349
+ completeUpload: () => completeUpload,
115349
115350
  createArtifact: () => createArtifact,
115350
115351
  createProject: () => createProject,
115351
115352
  createUpload: () => createUpload,
@@ -115578,6 +115579,7 @@ var readArtifact = (artifact) => request("GET", `/v1/artifacts/${q(artifact)}`);
115578
115579
  var readVersion = (artifact, version) => request("GET", `/v1/artifacts/${q(artifact)}/versions/${version}`);
115579
115580
  var createArtifact = (task, name, type) => request("POST", `/v1/tasks/${q(task)}/artifacts`, { type, name });
115580
115581
  var createUpload = (artifact, contentType, size) => request("POST", `/v1/artifacts/${q(artifact)}/uploads`, { content_type: contentType, size });
115582
+ var completeUpload = (url) => request("POST", url);
115581
115583
  var createVersion = (artifact, upload2) => request("POST", `/v1/artifacts/${q(artifact)}/versions`, { upload: upload2 });
115582
115584
  var readRejections = (workspace) => request("GET", `/v1/rejections?workspace=${q(workspace)}`);
115583
115585
  var markReviewed = (tasks, triage) => request("POST", "/v1/rejections/reviewed", { tasks, triage });
@@ -116382,11 +116384,14 @@ import path25 from "node:path";
116382
116384
  import fs20 from "node:fs";
116383
116385
  import path24 from "node:path";
116384
116386
 
116387
+ // ../cli/src/lib/shared/file-limits.ts
116388
+ var BOARD_FILE_LIMIT = 10 * 1024 * 1024;
116389
+ var ASSET_FILE_LIMIT = 100 * 1024 * 1024;
116390
+
116385
116391
  // ../cli/src/lib/shared/board-files.ts
116386
116392
  var ROOTS = ["todo/", ".archive/", "memory/", "studios/", "triage/", "assets/", "rules/"];
116387
116393
  var SETTINGS = ["modules.md", "config.md"];
116388
116394
  var isSettingsPath = (path51) => SETTINGS.includes(path51) || /^rules\/(?:studios\/)?[^/]+\.md$/.test(path51);
116389
- var BOARD_FILE_LIMIT = 256 * 1024;
116390
116395
  function isBoardPath(path51) {
116391
116396
  if (!path51 || path51.length > 500 || path51.startsWith("/") || path51.includes("\\") || path51.includes("\0")) return false;
116392
116397
  if (path51.split("/").some((part) => !part || part === "." || part === "..")) return false;
@@ -116394,7 +116399,7 @@ function isBoardPath(path51) {
116394
116399
  if (path51.startsWith("studios/")) return true;
116395
116400
  if (SETTINGS.includes(path51)) return true;
116396
116401
  if (path51.startsWith("rules/")) return isSettingsPath(path51);
116397
- if (path51.startsWith("assets/")) return path51.endsWith(".json");
116402
+ if (path51.startsWith("assets/")) return taskOfAssets(path51) !== null;
116398
116403
  return ROOTS.some((root2) => path51.startsWith(root2)) && path51.endsWith(".md");
116399
116404
  }
116400
116405
  var CARD = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]*\.md$/;
@@ -116405,6 +116410,7 @@ function numberOfCard(path51) {
116405
116410
  }
116406
116411
  var cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
116407
116412
  var assetsFile = (task) => `assets/${task}.json`;
116413
+ var taskOfAssets = (path51) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path51)?.[1] ?? null;
116408
116414
  var studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
116409
116415
  var studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
116410
116416
  var BUILDER = "wf_builtin_studio_builder";
@@ -116734,7 +116740,7 @@ function readTranslations(raw) {
116734
116740
  }
116735
116741
  return out;
116736
116742
  }
116737
- function memoryPaths(raw) {
116743
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
116738
116744
  if (raw === void 0) return [];
116739
116745
  const block = map(raw);
116740
116746
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
@@ -116746,7 +116752,7 @@ function memoryPaths(raw) {
116746
116752
  }
116747
116753
  const paths = [...new Set(list.map((v) => v.trim()))];
116748
116754
  const outside = paths.find((p2) => p2.startsWith("/") || p2.includes("\\") || p2.split("/").some((part) => part === ".." || part === "."));
116749
- if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`memory/agents/<name>/\``;
116755
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
116750
116756
  return paths;
116751
116757
  }
116752
116758
  var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str3(v)).filter(Boolean))];
@@ -116825,6 +116831,8 @@ function parseStudioFile(id, source, from) {
116825
116831
  if (!agent || scheduled.some((s) => s.agent === agent)) continue;
116826
116832
  scheduled.push({ agent, ...text2(row.cadence) ? { cadence: text2(row.cadence) } : {} });
116827
116833
  }
116834
+ const workspace = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
116835
+ if (typeof workspace === "string") return { problem: `${from}: declares ${workspace}` };
116828
116836
  const names2 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said]) => [lang, text2(said)]).filter(([, said]) => said));
116829
116837
  return {
116830
116838
  def: {
@@ -116838,6 +116846,7 @@ function parseStudioFile(id, source, from) {
116838
116846
  previews,
116839
116847
  land,
116840
116848
  scheduled,
116849
+ ...workspace.length ? { memoryFiles: { workspace } } : {},
116841
116850
  rules: body.trim()
116842
116851
  }
116843
116852
  };
@@ -116850,6 +116859,8 @@ import path20 from "node:path";
116850
116859
  // ../cli/src/lib/shared/studio-files.ts
116851
116860
  var STUDIO_FILE = "STUDIO.md";
116852
116861
  var MCP_FILE = "mcp.json";
116862
+ var CARD_TEMPLATE_FILE = "CARD.md";
116863
+ var SHARED_DIR = "shared/";
116853
116864
  var VERSION_FILE = "version.json";
116854
116865
  var KB = 1024;
116855
116866
  var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
@@ -116859,6 +116870,10 @@ var landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
116859
116870
  var SEGMENT = /^[\w.-]+$/;
116860
116871
  var isAboutFile = (file3) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file3) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file3);
116861
116872
  var bytes = (text3) => new TextEncoder().encode(text3).length;
116873
+ var isSharedFile = (file3) => {
116874
+ const parts = file3.split("/");
116875
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p2) => SEGMENT.test(p2) && p2 !== "." && p2 !== "..");
116876
+ };
116862
116877
  function folderPath(file3, top) {
116863
116878
  const parts = file3.split("/");
116864
116879
  if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
@@ -116914,7 +116929,7 @@ function inspect(value, official) {
116914
116929
  if (size > FILE_LIMITS.file) return fail(file3, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
116915
116930
  total += size;
116916
116931
  if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
116917
- if (file3 === STUDIO_FILE) continue;
116932
+ if (file3 === STUDIO_FILE || file3 === CARD_TEMPLATE_FILE) continue;
116918
116933
  if (official && file3 === MCP_FILE) {
116919
116934
  const problem = mcpProblem(text3);
116920
116935
  if (problem) fail(file3, problem);
@@ -116926,9 +116941,10 @@ function inspect(value, official) {
116926
116941
  else skills.add(file3.split("/")[1]);
116927
116942
  continue;
116928
116943
  }
116944
+ if (isSharedFile(file3)) continue;
116929
116945
  const at2 = folderPath(file3, "agents");
116930
116946
  if (!at2) {
116931
- fail(file3, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
116947
+ fail(file3, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
116932
116948
  continue;
116933
116949
  }
116934
116950
  if (!folders2.has(at2[0])) folders2.set(at2[0], /* @__PURE__ */ new Map());
@@ -117000,7 +117016,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
117000
117016
  const dir = path21.join(studiosDir, folder);
117001
117017
  const files = {};
117002
117018
  for (const f2 of filesOf(dir).sort()) {
117003
- if (f2 === STUDIO_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
117019
+ if (f2 === STUDIO_FILE || f2 === CARD_TEMPLATE_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || f2.startsWith(SHARED_DIR) || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
117004
117020
  }
117005
117021
  const read4 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
117006
117022
  Object.entries(agentFiles).flatMap(([name, own2]) => Object.entries(own2).map(([f2, t2]) => [`agents/${name}/${f2}`, t2]))
@@ -118474,7 +118490,10 @@ function sharedMemory(board) {
118474
118490
  }
118475
118491
  take(folder, text3, false);
118476
118492
  }
118477
- const matches = [...declared].flatMap(([agent, paths]) => paths.map((p2) => matcher(`agents/${agent}/${p2}`)));
118493
+ const matches = [
118494
+ ...[...declared].flatMap(([agent, paths]) => paths.map((p2) => matcher(`agents/${agent}/${p2}`))),
118495
+ ...cloudFlows().flatMap((f2) => (f2.def.memoryFiles?.workspace ?? []).map((p2) => matcher(`studios/${f2.def.id}/${p2}`)))
118496
+ ];
118478
118497
  return (name) => matches.some((m) => m(name));
118479
118498
  }
118480
118499
  function matcher(entry) {
@@ -118780,14 +118799,23 @@ function assetsOf(text3) {
118780
118799
  return {};
118781
118800
  }
118782
118801
  }
118802
+ function taskAssetFiles(ws) {
118803
+ if (!ws.number) return [];
118804
+ const state = stateDir(ws);
118805
+ const roots = [
118806
+ path34.join(ws.board, "assets", String(ws.number)),
118807
+ ...state ? ["assets", "mockups"].map((folder) => path34.join(state, folder, String(ws.number))) : []
118808
+ ];
118809
+ return roots.filter((root2) => fs30.lstatSync(root2, { throwIfNoEntry: false })?.isDirectory()).flatMap((root2) => filesUnder(root2).filter((p2) => !p2.split("/").some((part) => part.startsWith(".") || part === "node_modules")).map((p2) => path34.join(root2, p2)));
118810
+ }
118783
118811
  var assetsText = (assets) => `${JSON.stringify(assets, null, 2)}
118784
118812
  `;
118785
118813
  function pull(ws, machineId2) {
118786
118814
  return inFolder(ws.cwd, async () => {
118787
118815
  const sent = await sendBoard(boardFolder(ws), machineId2);
118788
118816
  if (!sent.ok) {
118789
- const refused2 = sent.tasks ? sent.tasks[ws.cloudTask ?? ""] : sent;
118790
- if (refused2) return { ok: false, error: `This computer's board changes could not be sent: ${refused2.error}`, ...refused2.offline ? {} : { code: "version_conflict" } };
118817
+ const refused2 = sent.tasks ? sent.tasks[ws.cloudTask ?? ""] : { ...sent, blocking: true };
118818
+ if (refused2 && refused2.blocking !== false) return { ok: false, error: `This computer's board changes could not be sent: ${refused2.error}`, ...refused2.offline ? {} : { code: "version_conflict" } };
118791
118819
  }
118792
118820
  return readCloud(ws);
118793
118821
  });
@@ -118898,9 +118926,13 @@ async function pullAssets(ws, record, assets) {
118898
118926
  record.number = ws.number;
118899
118927
  }
118900
118928
  const file3 = cardFile(ws);
118901
- const out = {};
118929
+ const out = Object.fromEntries((record.pendingAssets ?? []).flatMap((key) => record.assets[key] ? [[key, record.assets[key]]] : []));
118902
118930
  for (const [name, ref] of Object.entries(assets)) {
118903
118931
  const held4 = record.assets[name];
118932
+ if (record.pendingAssets?.includes(name) && held4) {
118933
+ out[name] = held4;
118934
+ continue;
118935
+ }
118904
118936
  if (ref.error && !ref.version) {
118905
118937
  if (held4?.artifact === ref.artifact) out[name] = held4;
118906
118938
  continue;
@@ -119021,12 +119053,23 @@ function undrawn(ws, reason) {
119021
119053
  async function uploadAsset(artifact, { bytes: bytes2, type }) {
119022
119054
  const upload2 = await createUpload(artifact, type, Math.max(bytes2.length, 1));
119023
119055
  if (!upload2.ok) return upload2;
119024
- const put = await upload(`/v1/uploads/${encodeURIComponent(upload2.value.id)}`, bytes2, type);
119025
- if (!put.ok) return put;
119056
+ const { id, url, parts } = upload2.value;
119057
+ if (parts) {
119058
+ for (let part = 1; part <= parts.count; part++) {
119059
+ const put = await upload(parts.url.replace("{part}", String(part)), bytes2.subarray((part - 1) * parts.size, part * parts.size), type);
119060
+ if (!put.ok) return put;
119061
+ }
119062
+ const done = await completeUpload(url ?? `/v1/uploads/${encodeURIComponent(id)}/complete`);
119063
+ if (!done.ok) return done;
119064
+ } else {
119065
+ const put = await upload(url ?? `/v1/uploads/${encodeURIComponent(id)}`, bytes2, type);
119066
+ if (!put.ok) return put;
119067
+ }
119026
119068
  const version = await createVersion(artifact, upload2.value.id);
119027
119069
  return version.ok ? { ok: true, value: version.value.version } : version;
119028
119070
  }
119029
119071
  async function pushAssets(ws, record, before) {
119072
+ const errors = [];
119030
119073
  if (ws.cloudTask && ws.number) {
119031
119074
  record.task = ws.cloudTask;
119032
119075
  record.number = ws.number;
@@ -119034,7 +119077,7 @@ async function pushAssets(ws, record, before) {
119034
119077
  }
119035
119078
  const file3 = cardFile(ws);
119036
119079
  const body = readText(file3);
119037
- if (body === null) return { ok: true, value: void 0 };
119080
+ if (body === null) return { ok: true, value: { errors } };
119038
119081
  const refs = {};
119039
119082
  const canonical = (target) => {
119040
119083
  const real = (file4) => fs30.existsSync(file4) ? fs30.realpathSync(file4) : path34.dirname(file4) === file4 ? file4 : path34.join(real(path34.dirname(file4)), path34.basename(file4));
@@ -119074,6 +119117,7 @@ async function pushAssets(ws, record, before) {
119074
119117
  let why2 = node.error ?? [...node.dependencies.values()].map((key) => refs[key]?.error).find(Boolean);
119075
119118
  if (!why2 && node.file) {
119076
119119
  try {
119120
+ if (fs30.statSync(node.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
119077
119121
  out = await sentOf(node.file, kind);
119078
119122
  } catch (error) {
119079
119123
  why2 = renderError(error);
@@ -119144,10 +119188,86 @@ async function pushAssets(ws, record, before) {
119144
119188
  entry = { ...entry, localHash: localHash ?? void 0, dependencies: [...node.dependencies.values()] };
119145
119189
  for (const alias of node.aliases) {
119146
119190
  record.assets[alias] = entry;
119191
+ record.pendingAssets = record.pendingAssets?.filter((key) => key !== alias);
119147
119192
  refs[alias] = { artifact: entry.artifact, version: entry.version };
119148
119193
  }
119149
119194
  writeRecord(ws, record);
119150
119195
  }
119196
+ for (const file4 of taskAssetFiles(ws)) {
119197
+ const key = canonical(file4);
119198
+ if (refs[key]) continue;
119199
+ assetPath(ws, key, cardFile(ws));
119200
+ const sendFile = async () => {
119201
+ const previous = record.assets[key];
119202
+ const size = fs30.statSync(file4).size;
119203
+ if (size > ASSET_FILE_LIMIT) return { ok: false, code: "too_large", error: `${key}: This asset is over 100 MiB.` };
119204
+ const digest2 = crypto5.createHash("sha256");
119205
+ for await (const chunk of fs30.createReadStream(file4)) digest2.update(chunk);
119206
+ const hash = digest2.digest("hex");
119207
+ let entry = previous;
119208
+ if (!entry?.version || entry.kind !== "asset" || entry.hash !== hash) {
119209
+ if (!ws.cloudTask) return { ok: true, value: void 0 };
119210
+ let artifact = entry?.kind === "asset" ? entry.artifact : void 0;
119211
+ if (!artifact) {
119212
+ const made = await createArtifact(ws.cloudTask, key.slice(0, 200), "asset");
119213
+ if (!made.ok) return { ...made, error: `${key}: ${made.error}` };
119214
+ artifact = made.value.id;
119215
+ record.assets[key] = { artifact, kind: "asset", version: 0, hash: "" };
119216
+ writeRecord(ws, record);
119217
+ }
119218
+ const type = TYPES[path34.extname(file4).toLowerCase()] ?? "application/octet-stream";
119219
+ const upload2 = await createUpload(artifact, type, Math.max(size, 1));
119220
+ if (!upload2.ok) return { ...upload2, error: `${key}: ${upload2.error}` };
119221
+ const route = `/v1/uploads/${encodeURIComponent(upload2.value.id)}`;
119222
+ if (upload2.value.parts) {
119223
+ const { count: count2, size: partSize, url: partUrl } = upload2.value.parts;
119224
+ const source = await fs30.promises.open(file4, "r");
119225
+ try {
119226
+ for (let part = 1; part <= count2; part++) {
119227
+ const bytes2 = Buffer.alloc(Math.min(partSize, size - (part - 1) * partSize));
119228
+ let offset = 0;
119229
+ while (offset < bytes2.length) {
119230
+ const read4 = await source.read(bytes2, offset, bytes2.length - offset, (part - 1) * partSize + offset);
119231
+ if (!read4.bytesRead) throw new Error(`${key}: file changed during upload`);
119232
+ offset += read4.bytesRead;
119233
+ }
119234
+ const put = await upload(partUrl.replace("{part}", String(part)), bytes2, type);
119235
+ if (!put.ok) return { ...put, error: `${key}: ${put.error}` };
119236
+ }
119237
+ } finally {
119238
+ await source.close();
119239
+ }
119240
+ const completed = await completeUpload(upload2.value.url ?? `${route}/complete`);
119241
+ if (!completed.ok) return { ...completed, error: `${key}: ${completed.error}` };
119242
+ } else {
119243
+ const put = await upload(upload2.value.url ?? route, fs30.readFileSync(file4), type);
119244
+ if (!put.ok) return { ...put, error: `${key}: ${put.error}` };
119245
+ }
119246
+ const sent2 = await createVersion(artifact, upload2.value.id);
119247
+ if (!sent2.ok) return { ...sent2, error: `${key}: ${sent2.error}` };
119248
+ entry = { artifact, version: sent2.value.version, hash, localHash: hash, kind: "asset" };
119249
+ }
119250
+ record.assets[key] = entry;
119251
+ refs[key] = { artifact: entry.artifact, version: entry.version };
119252
+ record.pendingAssets = record.pendingAssets?.filter((p2) => p2 !== key);
119253
+ writeRecord(ws, record);
119254
+ return { ok: true, value: void 0 };
119255
+ };
119256
+ let sent;
119257
+ try {
119258
+ sent = await sendFile();
119259
+ } catch (error) {
119260
+ sent = { ok: false, error: `${key}: ${renderError(error)}` };
119261
+ }
119262
+ if (!sent.ok) {
119263
+ if (sent.code && !["too_large", "payload_too_large", "storage_limit", "storage_limit_reached"].includes(sent.code)) return sent;
119264
+ record.pendingAssets = [.../* @__PURE__ */ new Set([...record.pendingAssets ?? [], key])];
119265
+ writeRecord(ws, record);
119266
+ errors.push({ error: sent.error, ...sent.code ? {} : { offline: true } });
119267
+ console.error(`runner: asset upload pending: ${sent.error}`);
119268
+ if (before[key]) refs[key] = before[key];
119269
+ }
119270
+ }
119151
119271
  } catch (error) {
119152
119272
  return { ok: false, code: "bad_request", error: error instanceof Error ? error.message : String(error) };
119153
119273
  }
@@ -119155,7 +119275,7 @@ async function pushAssets(ws, record, before) {
119155
119275
  if (Object.keys(refs).length || fs30.existsSync(list)) {
119156
119276
  if (JSON.stringify(assetsOf(readText(list))) !== JSON.stringify(refs)) write(list, assetsText(refs));
119157
119277
  }
119158
- return { ok: true, value: void 0 };
119278
+ return { ok: true, value: { errors } };
119159
119279
  }
119160
119280
  function resetSorted(ws) {
119161
119281
  for (const sub of ["dismissed", "archived"]) fs30.rmSync(path34.join(ws.board, "triage", sub), { recursive: true, force: true });
@@ -119221,12 +119341,16 @@ async function send2(ws, job) {
119221
119341
  const deferredCards = /* @__PURE__ */ new Set();
119222
119342
  const deferredLists = /* @__PURE__ */ new Set();
119223
119343
  const assetErrors = {};
119344
+ const processed = /* @__PURE__ */ new Set();
119224
119345
  for (const item of tasks) {
119346
+ processed.add(item.folder.task);
119225
119347
  const card = path34.relative(ws.board, cardFile(item.folder)).split(path34.sep).join("/");
119226
119348
  const archived = boardSync && card.startsWith(".archive/") && base.files[rootOf(ws) + card];
119227
119349
  if (!archived) {
119228
119350
  const assets = await pushAssets(item.folder, item.record, assetsOf(assetsListOf(item.folder, base)));
119229
119351
  if (assets.ok) {
119352
+ const error = assets.value.errors[0];
119353
+ if (error) assetErrors[item.folder.task] = { ...error, blocking: false };
119230
119354
  writeRecord(item.folder, item.record);
119231
119355
  continue;
119232
119356
  }
@@ -119240,7 +119364,7 @@ async function send2(ws, job) {
119240
119364
  }
119241
119365
  proposeItems(ws, base);
119242
119366
  const shared = sharedMemory(ws.board);
119243
- const deferred = new Set(boardSync ? [] : base.deferred);
119367
+ const deferred = new Set((base.deferred ?? []).filter((p2) => !boardSync && !tasks.some((item) => processed.has(item.folder.task) && !deferredCards.has(item.folder.number) && (p2 === assetsFile(item.folder.task) || numberOfCard(p2) === item.folder.number))));
119244
119368
  const defer = (p2) => {
119245
119369
  if (!boardSync) return deferred.has(p2);
119246
119370
  if (!deferredLists.has(p2) && !deferredCards.has(numberOfCard(p2) ?? 0)) return false;
@@ -119248,14 +119372,14 @@ async function send2(ws, job) {
119248
119372
  return true;
119249
119373
  };
119250
119374
  const success = (changed) => {
119251
- const refreshDeferred = boardSync && (deferred.size !== (base.deferred?.length ?? 0) || base.deferred?.some((p2) => !deferred.has(p2)));
119252
- const pendingAssets = Object.keys(assetErrors);
119253
- const refreshPending = boardSync && JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
119375
+ const refreshDeferred = deferred.size !== (base.deferred?.length ?? 0) || base.deferred?.some((p2) => !deferred.has(p2));
119376
+ const pendingAssets = [.../* @__PURE__ */ new Set([...(base.pendingAssets ?? []).filter((task) => !processed.has(task)), ...Object.keys(assetErrors)])];
119377
+ const refreshPending = JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
119254
119378
  if (refreshDeferred) base.deferred = [...deferred];
119255
119379
  if (refreshPending) base.pendingAssets = pendingAssets;
119256
119380
  if (changed || refreshDeferred || refreshPending) writeBase(ws, base);
119257
119381
  const firstError = Object.values(assetErrors)[0];
119258
- if (firstError) return { ok: false, conflict: false, ...firstError, tasks: assetErrors };
119382
+ if (firstError && boardSync) return { ok: false, conflict: false, ...firstError, tasks: assetErrors };
119259
119383
  return { ok: true, changed };
119260
119384
  };
119261
119385
  const local = localFiles(ws, base);