wildcrane-runner 0.6.81 → 0.6.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +1161 -1059
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +225 -225
- package/dist/codex-proxy.mjs +227 -227
- package/dist/codex-retained.mjs +225 -225
- package/dist/flow-worker-main.mjs +231 -231
- package/dist/launcher.mjs +229 -229
- package/dist/plugin.mjs +641 -641
- package/dist/runner.mjs +235 -235
- package/dist/settings.mjs +229 -229
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.66 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -451,13 +451,16 @@ __export(preview_stages_exports, {
|
|
|
451
451
|
previewBaseline: () => previewBaseline,
|
|
452
452
|
previewDisplay: () => previewDisplay,
|
|
453
453
|
previewReady: () => previewReady,
|
|
454
|
+
reportPreviewStage: () => reportPreviewStage,
|
|
454
455
|
resetPreviewSelection: () => resetPreviewSelection,
|
|
455
456
|
selectPreviewStages: () => selectPreviewStages,
|
|
456
|
-
submitPreviewStage: () => submitPreviewStage
|
|
457
|
+
submitPreviewStage: () => submitPreviewStage,
|
|
458
|
+
syncPreviewContent: () => syncPreviewContent
|
|
457
459
|
});
|
|
458
460
|
function selectPreviewStages(progress, ids) {
|
|
459
461
|
const wanted = new Set(ids);
|
|
460
462
|
if (!ids.length || wanted.size !== ids.length || ids.some((id) => !progress.definitions.some((stage) => stage.id === id))) throw Error("Choose a nonempty list of unique known stage IDs.");
|
|
463
|
+
if (progress.stages.some((stage) => stage.artifact || ["awaiting_confirmation", "confirmed"].includes(stage.status)) && JSON.stringify(progress.stages.map((stage) => stage.id)) !== JSON.stringify(ids)) throw Error("Wait for user approval before changing the selected stages.");
|
|
461
464
|
const chosen = ids.map((id) => progress.definitions.find((stage) => stage.id === id));
|
|
462
465
|
if (progress.stages.length) {
|
|
463
466
|
if (JSON.stringify(progress.stages.map((stage) => stage.id)) === JSON.stringify(ids)) return;
|
|
@@ -534,6 +537,7 @@ function choosePreviewRevision(progress, from, execution) {
|
|
|
534
537
|
const saved = progress.revisionBase ?? progress.stages;
|
|
535
538
|
const at2 = saved.findIndex((stage) => stage.id === from);
|
|
536
539
|
if (at2 < 0) throw Error("Unknown stage.");
|
|
540
|
+
if (saved.slice(0, at2).some((stage) => stage.status !== "confirmed")) throw Error("Wait for user approval before starting the next stage.");
|
|
537
541
|
progress.archivedSelections = [...progress.archivedSelections ?? [], structuredClone(saved)];
|
|
538
542
|
progress.stages = structuredClone(saved);
|
|
539
543
|
progress.generation++;
|
|
@@ -555,6 +559,39 @@ function resetPreviewSelection(progress) {
|
|
|
555
559
|
progress.displayedArtifact = null;
|
|
556
560
|
delete progress.revisionBase;
|
|
557
561
|
}
|
|
562
|
+
function syncPreviewContent(progress, body, assets) {
|
|
563
|
+
let stage = progress.stages.find((stage2) => stage2.id === progress.currentStageId);
|
|
564
|
+
if (stage?.status === "queued" && progress.displayedArtifact) stage = progress.stages.find((item) => item.id === progress.displayedArtifact.stageId);
|
|
565
|
+
if (!stage || !stage.artifact && !body.trim() && !Object.keys(assets).length) return;
|
|
566
|
+
if (stage.artifact?.body === body && JSON.stringify(stage.artifact.assets) === JSON.stringify(assets)) return;
|
|
567
|
+
const artifact = { stageId: stage.id, version: (stage.version ?? 0) + 1, body, assets: structuredClone(assets) };
|
|
568
|
+
stage.version = artifact.version;
|
|
569
|
+
stage.artifact = artifact;
|
|
570
|
+
stage.history = [...stage.history ?? [], artifact];
|
|
571
|
+
if (["confirmed", "ready", "awaiting_confirmation"].includes(stage.status)) stage.status = "running";
|
|
572
|
+
delete stage.confirmation;
|
|
573
|
+
const at2 = progress.stages.indexOf(stage);
|
|
574
|
+
if (progress.currentStageId !== stage.id) {
|
|
575
|
+
progress.currentStageId = stage.id;
|
|
576
|
+
progress.execution = null;
|
|
577
|
+
progress.generation++;
|
|
578
|
+
for (const next of progress.stages.slice(at2 + 1)) {
|
|
579
|
+
next.status = "stale";
|
|
580
|
+
delete next.confirmation;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
progress.displayedArtifact = artifact;
|
|
584
|
+
}
|
|
585
|
+
function reportPreviewStage(progress, stageId, status, execution) {
|
|
586
|
+
if (!progress.stages.length) selectPreviewStages(progress, [stageId]);
|
|
587
|
+
if (progress.currentStageId !== stageId) throw Error("Wait for user approval before starting the next stage.");
|
|
588
|
+
const baseline = previewBaseline(progress, stageId, execution);
|
|
589
|
+
const stage = progress.stages.find((stage2) => stage2.id === stageId);
|
|
590
|
+
if (status === "done") {
|
|
591
|
+
if (stage.status !== "confirmed") stage.status = progress.stages.at(-1)?.id === stageId ? "ready" : "awaiting_confirmation";
|
|
592
|
+
} else if (stage.status !== "confirmed") stage.status = "running";
|
|
593
|
+
return baseline;
|
|
594
|
+
}
|
|
558
595
|
var previewReady;
|
|
559
596
|
var init_preview_stages = __esm({
|
|
560
597
|
"../cli/src/lib/preview-stages.ts"() {
|
|
@@ -563,15 +600,780 @@ var init_preview_stages = __esm({
|
|
|
563
600
|
}
|
|
564
601
|
});
|
|
565
602
|
|
|
566
|
-
// ../
|
|
567
|
-
|
|
603
|
+
// ../artifact-sdk/src/internal/references.ts
|
|
604
|
+
function bodyReferences(body) {
|
|
605
|
+
const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
|
|
606
|
+
let fence = "";
|
|
607
|
+
let inTag = false;
|
|
608
|
+
const out = [];
|
|
609
|
+
const visible = [];
|
|
610
|
+
for (const line of lines) {
|
|
611
|
+
const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
612
|
+
if (fence) {
|
|
613
|
+
if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
|
|
614
|
+
visible.push("");
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
if (delimiter) {
|
|
618
|
+
fence = delimiter;
|
|
619
|
+
visible.push("");
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
|
|
623
|
+
visible.push(kept2 ? line : "");
|
|
624
|
+
if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Studio)\b/.test(line)) inTag = true;
|
|
625
|
+
if (line.includes("/>")) inTag = false;
|
|
626
|
+
}
|
|
627
|
+
const text6 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
|
|
628
|
+
const tag = /<(Asset|Mockup|Compare|Storyboard|Studio)\b([^<>]*?)\/>/g;
|
|
629
|
+
const blocks = text6.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Studio)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
630
|
+
for (const block of blocks) {
|
|
631
|
+
const tags = [...block[0].matchAll(tag)];
|
|
632
|
+
for (const m of tags) {
|
|
633
|
+
const a2 = {};
|
|
634
|
+
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
635
|
+
if (m[1] === "Compare") {
|
|
636
|
+
if (!a2.a || !a2.b) continue;
|
|
637
|
+
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: ARRANGED });
|
|
638
|
+
} else if (a2.src) {
|
|
639
|
+
out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Studio" ? STUDIO : m[1] === "Asset" ? ASSET : [] });
|
|
640
|
+
if (a2.variants) {
|
|
641
|
+
try {
|
|
642
|
+
const v = JSON.parse(a2.variants);
|
|
643
|
+
if (isObject(v)) {
|
|
644
|
+
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: m[1] === "Asset" ? ASSET : [] });
|
|
645
|
+
}
|
|
646
|
+
} catch {
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
for (const m of text6.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
|
|
653
|
+
return out;
|
|
654
|
+
}
|
|
655
|
+
function kindOf(ext) {
|
|
656
|
+
if (ext === ".tsx" || ext === ".html") return "html";
|
|
657
|
+
if (ext === ".md" || ext === ".mdx") return "markdown";
|
|
658
|
+
if (ext === ".tmx" || ext === ".tmj" || ext === ".tsj") return "tiled";
|
|
659
|
+
const type = TYPES[ext] ?? "";
|
|
660
|
+
if (type.startsWith("image/")) return "image";
|
|
661
|
+
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
662
|
+
}
|
|
663
|
+
var STORYBOARD, STUDIO, ARRANGED, ASSET, isObject, bodySources, TYPES;
|
|
664
|
+
var init_references = __esm({
|
|
665
|
+
"../artifact-sdk/src/internal/references.ts"() {
|
|
666
|
+
"use strict";
|
|
667
|
+
STORYBOARD = ["storyboard"];
|
|
668
|
+
STUDIO = ["studio"];
|
|
669
|
+
ARRANGED = ["storyboard", "compare", "spritesheet", "studio"];
|
|
670
|
+
ASSET = ["spritesheet", "asset"];
|
|
671
|
+
isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
672
|
+
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
673
|
+
TYPES = {
|
|
674
|
+
".png": "image/png",
|
|
675
|
+
".jpg": "image/jpeg",
|
|
676
|
+
".jpeg": "image/jpeg",
|
|
677
|
+
".gif": "image/gif",
|
|
678
|
+
".webp": "image/webp",
|
|
679
|
+
".svg": "image/svg+xml",
|
|
680
|
+
".mp4": "video/mp4",
|
|
681
|
+
".webm": "video/webm",
|
|
682
|
+
".mp3": "audio/mpeg",
|
|
683
|
+
".pdf": "application/pdf",
|
|
684
|
+
".html": "text/html",
|
|
685
|
+
".md": "text/markdown",
|
|
686
|
+
".mdx": "text/markdown",
|
|
687
|
+
".mov": "video/quicktime",
|
|
688
|
+
".wav": "audio/wav",
|
|
689
|
+
".m4a": "audio/mp4",
|
|
690
|
+
".json": "application/json",
|
|
691
|
+
".txt": "text/plain",
|
|
692
|
+
".otf": "font/otf",
|
|
693
|
+
".ttf": "font/ttf",
|
|
694
|
+
".woff": "font/woff",
|
|
695
|
+
".woff2": "font/woff2",
|
|
696
|
+
".css": "text/css",
|
|
697
|
+
".tmx": "application/xml",
|
|
698
|
+
".tmj": "application/json",
|
|
699
|
+
".tsj": "application/json"
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// ../artifact-sdk/src/builtin/compare.json
|
|
705
|
+
var compare_default;
|
|
706
|
+
var init_compare = __esm({
|
|
707
|
+
"../artifact-sdk/src/builtin/compare.json"() {
|
|
708
|
+
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", "spritesheet", "studio"] },\n { "json": "/b", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "studio"] }\n ]\n}\n';
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// ../artifact-sdk/src/builtin/html.json
|
|
713
|
+
var html_default;
|
|
714
|
+
var init_html = __esm({
|
|
715
|
+
"../artifact-sdk/src/builtin/html.json"() {
|
|
716
|
+
html_default = `{
|
|
717
|
+
"name": "html",
|
|
718
|
+
"title": { "en": "Page", "zh": "\u9875\u9762" },
|
|
719
|
+
"types": ["html"],
|
|
720
|
+
"references": [
|
|
721
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
722
|
+
{ "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
723
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
|
|
724
|
+
{ "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
725
|
+
{ "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
|
|
726
|
+
],
|
|
727
|
+
"skip": ["(?<=<script\\\\b[^<>]*>)[\\\\s\\\\S]*?(?=</script\\\\s*>|$)"]
|
|
728
|
+
}
|
|
729
|
+
`;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// ../artifact-sdk/src/builtin/image.json
|
|
734
|
+
var image_default;
|
|
735
|
+
var init_image = __esm({
|
|
736
|
+
"../artifact-sdk/src/builtin/image.json"() {
|
|
737
|
+
image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// ../artifact-sdk/src/builtin/markdown.json
|
|
742
|
+
var markdown_default;
|
|
743
|
+
var init_markdown = __esm({
|
|
744
|
+
"../artifact-sdk/src/builtin/markdown.json"() {
|
|
745
|
+
markdown_default = `{
|
|
746
|
+
"name": "markdown",
|
|
747
|
+
"title": { "en": "Document", "zh": "\u6587\u6863" },
|
|
748
|
+
"types": ["markdown"],
|
|
749
|
+
"references": [
|
|
750
|
+
{ "text": "!\\\\[[^\\\\]\\\\n]*\\\\]\\\\(\\\\s*<?([^\\\\s)>]+)>?(?:\\\\s+[\\"'][^\\"'\\\\n]*[\\"'])?\\\\s*\\\\)" },
|
|
751
|
+
{ "text": "<img\\\\b[^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" }
|
|
752
|
+
]
|
|
753
|
+
}
|
|
754
|
+
`;
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
// ../artifact-sdk/src/builtin/spritesheet.json
|
|
759
|
+
var spritesheet_default;
|
|
760
|
+
var init_spritesheet = __esm({
|
|
761
|
+
"../artifact-sdk/src/builtin/spritesheet.json"() {
|
|
762
|
+
spritesheet_default = '{\n "name": "spritesheet",\n "title": { "en": "Sprite animation", "zh": "\u7CBE\u7075\u52A8\u753B" },\n "types": ["spritesheet"],\n "schema": {\n "type": "object",\n "required": ["frames", "meta"],\n "properties": {\n "frames": {\n "anyOf": [\n { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["frame"] } },\n { "type": "object", "additionalProperties": { "type": "object", "required": ["frame"] } }\n ]\n },\n "meta": {\n "type": "object",\n "required": ["app", "image"],\n "properties": { "app": { "type": "string", "pattern": "codeandweb\\\\.com/texturepacker" }, "image": { "type": "string" } }\n }\n }\n },\n "references": [{ "json": "/meta/image" }]\n}\n';
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// ../artifact-sdk/src/builtin/storyboard.json
|
|
767
|
+
var storyboard_default;
|
|
768
|
+
var init_storyboard = __esm({
|
|
769
|
+
"../artifact-sdk/src/builtin/storyboard.json"() {
|
|
770
|
+
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", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/slides/*/preview/src", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
// ../artifact-sdk/src/builtin/tiled.json
|
|
775
|
+
var tiled_default;
|
|
776
|
+
var init_tiled = __esm({
|
|
777
|
+
"../artifact-sdk/src/builtin/tiled.json"() {
|
|
778
|
+
tiled_default = `{
|
|
779
|
+
"name": "tiled",
|
|
780
|
+
"title": { "en": "Tiled map", "zh": "Tiled \u5730\u56FE" },
|
|
781
|
+
"types": ["tiled"],
|
|
782
|
+
"references": [
|
|
783
|
+
{ "text": "<tileset\\\\b[^<>]*?\\\\ssource\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "types": ["tiled"] },
|
|
784
|
+
{ "text": "<image\\\\b[^<>]*?\\\\ssource\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
785
|
+
{ "text": "\\"source\\"\\\\s*:\\\\s*\\"([^\\"]+)\\"", "types": ["tiled"] },
|
|
786
|
+
{ "text": "\\"image\\"\\\\s*:\\\\s*\\"([^\\"]+)\\"" }
|
|
787
|
+
]
|
|
788
|
+
}
|
|
789
|
+
`;
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// ../artifact-sdk/src/builtin/video.json
|
|
794
|
+
var video_default;
|
|
795
|
+
var init_video = __esm({
|
|
796
|
+
"../artifact-sdk/src/builtin/video.json"() {
|
|
797
|
+
video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// ../artifact-sdk/src/builtin/studio.json
|
|
802
|
+
var studio_default;
|
|
803
|
+
var init_studio = __esm({
|
|
804
|
+
"../artifact-sdk/src/builtin/studio.json"() {
|
|
805
|
+
studio_default = '{\n "name": "studio",\n "title": {\n "en": "Studio",\n "zh": "\u5DE5\u4F5C\u53F0"\n },\n "types": [\n "studio"\n ],\n "schema": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "rounds",\n "land",\n "scheduled"\n ],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string"\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ]\n }\n }\n }\n }\n },\n "land": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "scheduled": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "version": {\n "enum": [\n 1\n ]\n }\n }\n },\n {\n "type": "object",\n "required": [\n "version",\n "base",\n "fingerprint",\n "agents",\n "files",\n "results"\n ],\n "properties": {\n "version": {\n "const": 2\n },\n "base": {\n "anyOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "required": [\n "id",\n "version",\n "fingerprint"\n ],\n "properties": {\n "id": {\n "type": "string",\n "minLength": 1\n },\n "version": {\n "type": "integer",\n "minimum": 1\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n ]\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n },\n "agents": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ],\n "properties": {\n "en": {\n "type": "string",\n "minLength": 1\n },\n "zh": {\n "type": "string"\n }\n }\n }\n }\n }\n },\n "files": {\n "type": "array",\n "maxItems": 1000,\n "items": {\n "type": "object",\n "required": [\n "path",\n "before",\n "after"\n ],\n "properties": {\n "path": {\n "type": "string",\n "minLength": 1\n },\n "before": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "after": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "diff": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n "results": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Asset"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "label",\n "items"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Set"\n },\n "label": {\n "type": "string"\n },\n "items": {\n "type": "array",\n "minItems": 1,\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "src"\n ],\n "properties": {\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "a",\n "b"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Compare"\n },\n "a": {\n "type": "string",\n "minLength": 1\n },\n "b": {\n "type": "string",\n "minLength": 1\n },\n "shots": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "a-label": {\n "type": "string"\n },\n "b-label": {\n "type": "string"\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Storyboard"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n }\n }\n }\n ]\n }\n }\n }\n }\n ]\n },\n "references": [\n {\n "json": "/files/*/before"\n },\n {\n "json": "/files/*/after"\n },\n {\n "json": "/files/*/diff"\n },\n {\n "json": "/results/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n }\n ]\n}\n';
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
// ../artifact-sdk/src/builtin/index.ts
|
|
810
|
+
var read, builtin_default;
|
|
811
|
+
var init_builtin = __esm({
|
|
812
|
+
"../artifact-sdk/src/builtin/index.ts"() {
|
|
813
|
+
"use strict";
|
|
814
|
+
init_compare();
|
|
815
|
+
init_html();
|
|
816
|
+
init_image();
|
|
817
|
+
init_markdown();
|
|
818
|
+
init_spritesheet();
|
|
819
|
+
init_storyboard();
|
|
820
|
+
init_tiled();
|
|
821
|
+
init_video();
|
|
822
|
+
init_studio();
|
|
823
|
+
read = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
824
|
+
builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, studio_default, tiled_default, spritesheet_default].map(read);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// ../artifact-sdk/src/internal/schema.ts
|
|
829
|
+
function typeOk(type, v) {
|
|
830
|
+
const types = Array.isArray(type) ? type : [type];
|
|
831
|
+
return types.some(
|
|
832
|
+
(t) => t === "null" ? v === null : t === "array" ? Array.isArray(v) : t === "object" ? isObj(v) : t === "integer" ? Number.isInteger(v) : t === "number" ? typeof v === "number" && Number.isFinite(v) : typeof v === t
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
function schemaProblem(schema, value, at2 = "") {
|
|
836
|
+
if (!isObj(schema)) return null;
|
|
837
|
+
const s = schema;
|
|
838
|
+
const here = at2 || "/";
|
|
839
|
+
if (s.type !== void 0 && !typeOk(s.type, value)) return here;
|
|
840
|
+
if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
|
|
841
|
+
if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
|
|
842
|
+
if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
|
|
843
|
+
if (typeof value === "string") {
|
|
844
|
+
if (typeof s.minLength === "number" && value.length < s.minLength) return here;
|
|
845
|
+
if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
|
|
846
|
+
if (typeof s.pattern === "string") {
|
|
847
|
+
try {
|
|
848
|
+
if (!new RegExp(s.pattern, "u").test(value)) return here;
|
|
849
|
+
} catch {
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if (typeof value === "number") {
|
|
854
|
+
if (typeof s.minimum === "number" && value < s.minimum) return here;
|
|
855
|
+
if (typeof s.maximum === "number" && value > s.maximum) return here;
|
|
856
|
+
}
|
|
857
|
+
if (Array.isArray(value)) {
|
|
858
|
+
if (typeof s.minItems === "number" && value.length < s.minItems) return here;
|
|
859
|
+
if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
|
|
860
|
+
if (isObj(s.items)) {
|
|
861
|
+
for (let i = 0; i < value.length; i++) {
|
|
862
|
+
const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
|
|
863
|
+
if (bad) return bad;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (isObj(value)) {
|
|
868
|
+
const props = isObj(s.properties) ? s.properties : {};
|
|
869
|
+
if (Array.isArray(s.required)) {
|
|
870
|
+
for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
|
|
871
|
+
}
|
|
872
|
+
for (const [k2, v] of Object.entries(value)) {
|
|
873
|
+
if (k2 in props) {
|
|
874
|
+
const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
|
|
875
|
+
if (bad) return bad;
|
|
876
|
+
} else if (s.additionalProperties === false) return `${at2}/${k2}`;
|
|
877
|
+
else if (isObj(s.additionalProperties)) {
|
|
878
|
+
const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
|
|
879
|
+
if (bad) return bad;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return null;
|
|
884
|
+
}
|
|
885
|
+
var isObj;
|
|
886
|
+
var init_schema = __esm({
|
|
887
|
+
"../artifact-sdk/src/internal/schema.ts"() {
|
|
888
|
+
"use strict";
|
|
889
|
+
isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
// ../artifact-sdk/src/internal/format/studio.ts
|
|
894
|
+
function resultProblem(value, agents) {
|
|
895
|
+
if (!Array.isArray(value) || value.length > 500) return "/results";
|
|
896
|
+
for (let i = 0; i < value.length; i++) {
|
|
897
|
+
const r2 = value[i];
|
|
898
|
+
if (!isObject(r2) || !text(r2.agent) || !agents.has(r2.agent) || !optionalText(r2, ["label"])) return `/results/${i}`;
|
|
899
|
+
const valid = r2.component === "Asset" ? asset(r2) : r2.component === "Set" ? typeof r2.label === "string" && Array.isArray(r2.items) && r2.items.length > 0 && r2.items.length <= 500 && r2.items.every(asset) : r2.component === "Compare" ? source(r2.a) && source(r2.b) && (r2.shots === void 0 || source(r2.shots)) && optionalText(r2, ["a-label", "b-label"]) : r2.component === "Storyboard" && source(r2.src);
|
|
900
|
+
if (!valid) return `/results/${i}`;
|
|
901
|
+
}
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
904
|
+
function reviewProblem(v) {
|
|
905
|
+
if (!isObject(v) || v.version !== 2) return "/version";
|
|
906
|
+
if (!text(v.fingerprint)) return "/fingerprint";
|
|
907
|
+
if (v.base !== null && !(isObject(v.base) && text(v.base.id) && Number.isInteger(v.base.version) && Number(v.base.version) > 0 && text(v.base.fingerprint))) return "/base";
|
|
908
|
+
if (!Array.isArray(v.agents) || v.agents.length > 500) return "/agents";
|
|
909
|
+
const agents = /* @__PURE__ */ new Set();
|
|
910
|
+
for (const a2 of v.agents) {
|
|
911
|
+
if (!isObject(a2) || !text(a2.agent) || !/^[a-z][a-z0-9-]*$/.test(a2.agent) || agents.has(a2.agent) || !isObject(a2.title) || !text(a2.title.en) || !optionalText(a2.title, ["zh"]) || !icon(a2.icon)) return "/agents";
|
|
912
|
+
agents.add(a2.agent);
|
|
913
|
+
}
|
|
914
|
+
if (!Array.isArray(v.files) || v.files.length > 1e3) return "/files";
|
|
915
|
+
const paths = /* @__PURE__ */ new Set();
|
|
916
|
+
for (const f2 of v.files) {
|
|
917
|
+
if (!isObject(f2) || !relativePath(f2.path) || paths.has(f2.path) || !(f2.before === null || source(f2.before)) || !(f2.after === null || source(f2.after)) || f2.before === null && f2.after === null || f2.diff !== void 0 && !source(f2.diff) || (f2.before === null || f2.after === null) && !f2.diff) return "/files";
|
|
918
|
+
if (f2.path.startsWith("agents/") && !agents.has(f2.path.split("/")[1])) return "/files";
|
|
919
|
+
paths.add(f2.path);
|
|
920
|
+
}
|
|
921
|
+
return resultProblem(v.results, agents);
|
|
922
|
+
}
|
|
923
|
+
var text, source, icon, relativePath, optionalText, asset, parseReview, isReview;
|
|
924
|
+
var init_studio2 = __esm({
|
|
925
|
+
"../artifact-sdk/src/internal/format/studio.ts"() {
|
|
926
|
+
"use strict";
|
|
927
|
+
init_references();
|
|
928
|
+
text = (v) => typeof v === "string" && v.length > 0;
|
|
929
|
+
source = (v) => text(v) && !/^(?:[a-z][\w+.-]*:|\/|#)|\\|[\u0000-\u001f]/i.test(v);
|
|
930
|
+
icon = (v) => v === void 0 || typeof v === "string" || Array.isArray(v) && v.length > 0 && v.length <= 12 && v.every((p2) => isObject(p2) && text(p2.d) && /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/.test(p2.d) && ["f", "s"].every((k2) => p2[k2] === void 0 || typeof p2[k2] === "string" && /^[kwcgopsmlry]$/.test(p2[k2])) && (p2.o === void 0 || p2.o === true) && (p2.w === void 0 || typeof p2.w === "number" && p2.w > 0 && p2.w <= 3));
|
|
931
|
+
relativePath = (v) => source(v) && v.split("/").every((p2) => p2 && p2 !== "." && p2 !== "..");
|
|
932
|
+
optionalText = (v, keys) => keys.every((k2) => v[k2] === void 0 || typeof v[k2] === "string");
|
|
933
|
+
asset = (v) => isObject(v) && source(v.src) && optionalText(v, ["label", "alt"]) && (v.alt === void 0 || !/[<>]/.test(v.alt)) && (v.device === void 0 || v.device === "desktop" || v.device === "mobile") && (v.loop === void 0 || typeof v.loop === "boolean") && (v.variants === void 0 || isObject(v.variants) && Object.values(v.variants).every(source));
|
|
934
|
+
parseReview = (v) => reviewProblem(v) ? null : v;
|
|
935
|
+
isReview = (v) => isObject(v) && v.version === 2;
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
// ../artifact-sdk/src/internal/manifest.ts
|
|
940
|
+
function typeOf(data, types) {
|
|
941
|
+
const problem = (type) => type === "studio" && isReview(data) ? reviewProblem(data) : schemaProblem(manifestOf(type)?.schema, data);
|
|
942
|
+
for (const type of types) if (!problem(type)) return { type };
|
|
943
|
+
if (types.length !== 1) return { type: null };
|
|
944
|
+
return { type: types[0], problem: `does not match ${types[0]} at ${problem(types[0])}` };
|
|
945
|
+
}
|
|
946
|
+
function mapJson(node, keys, at2, visit) {
|
|
947
|
+
if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
|
|
948
|
+
const [key, ...rest] = keys;
|
|
949
|
+
if (Array.isArray(node)) {
|
|
950
|
+
if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
|
|
951
|
+
const i = Number(key);
|
|
952
|
+
return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
|
|
953
|
+
}
|
|
954
|
+
if (!isObject2(node)) return node;
|
|
955
|
+
const out = { ...node };
|
|
956
|
+
for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
|
|
957
|
+
return out;
|
|
958
|
+
}
|
|
959
|
+
function mapText(text6, rule, skipped, visit, includeRemote) {
|
|
960
|
+
let out = "";
|
|
961
|
+
let last = 0;
|
|
962
|
+
for (const m of text6.matchAll(new RegExp(rule.text, "gid"))) {
|
|
963
|
+
const span = m.indices?.[1];
|
|
964
|
+
if (!span || m[1] === void 0 || skipped.some(([a2, b2]) => span[0] >= a2 && span[0] < b2)) continue;
|
|
965
|
+
const line = text6.slice(0, span[0]).split("\n").length;
|
|
966
|
+
const one = (src) => remote(src) && !includeRemote ? src : visit(src, line);
|
|
967
|
+
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]);
|
|
968
|
+
out += text6.slice(last, span[0]) + value;
|
|
969
|
+
last = span[1];
|
|
970
|
+
}
|
|
971
|
+
return out + text6.slice(last);
|
|
972
|
+
}
|
|
973
|
+
function mapReferences(manifest, content, map2, includeRemote = false) {
|
|
974
|
+
const skipped = (text6) => (manifest?.skip ?? []).flatMap((re3) => [...text6.matchAll(new RegExp(re3, "gi"))].map((m) => [m.index, m.index + m[0].length]));
|
|
975
|
+
for (const rule of manifest?.references ?? []) {
|
|
976
|
+
const types = rule.types ?? [];
|
|
977
|
+
if ("json" in rule) {
|
|
978
|
+
if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
|
|
979
|
+
} else if (typeof content === "string") {
|
|
980
|
+
content = mapText(content, rule, skipped(content), (src, line) => map2(src, { src, types, text: true, line }), includeRemote);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return content;
|
|
984
|
+
}
|
|
985
|
+
function referencesOf(manifest, content, includeRemote = false) {
|
|
986
|
+
const found2 = [];
|
|
987
|
+
mapReferences(manifest, content, (src, ref) => (found2.push(ref), src), includeRemote);
|
|
988
|
+
return found2;
|
|
989
|
+
}
|
|
990
|
+
var BUILTINS, manifestOf, isObject2, remote;
|
|
991
|
+
var init_manifest = __esm({
|
|
992
|
+
"../artifact-sdk/src/internal/manifest.ts"() {
|
|
993
|
+
"use strict";
|
|
994
|
+
init_builtin();
|
|
995
|
+
init_schema();
|
|
996
|
+
init_studio2();
|
|
997
|
+
BUILTINS = builtin_default;
|
|
998
|
+
manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
|
|
999
|
+
isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
1000
|
+
remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
// ../cli/src/lib/cloud/config.ts
|
|
1005
|
+
function cloudEndpoints() {
|
|
1006
|
+
return {
|
|
1007
|
+
supabaseUrl: trimSlash(process.env.AI4KANBAN_SUPABASE_URL || SUPABASE_URL),
|
|
1008
|
+
anonKey: process.env.AI4KANBAN_SUPABASE_ANON_KEY || SUPABASE_ANON_KEY,
|
|
1009
|
+
api: trimSlash(process.env.AI4KANBAN_CLOUD_URL || API_URL)
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
function cloudConfigured() {
|
|
1013
|
+
const { supabaseUrl, anonKey } = cloudEndpoints();
|
|
1014
|
+
return !!supabaseUrl && !!anonKey;
|
|
1015
|
+
}
|
|
1016
|
+
var SUPABASE_URL, SUPABASE_ANON_KEY, API_URL, trimSlash, NOT_CONFIGURED;
|
|
1017
|
+
var init_config = __esm({
|
|
1018
|
+
"../cli/src/lib/cloud/config.ts"() {
|
|
1019
|
+
"use strict";
|
|
1020
|
+
SUPABASE_URL = "https://yajrbpprmdvtkvjjfpbk.supabase.co";
|
|
1021
|
+
SUPABASE_ANON_KEY = "sb_publishable_ioUQ23BTtoj8NKqndp0Jrw_omVR3m4n";
|
|
1022
|
+
API_URL = "https://api.ai4kanban.dev";
|
|
1023
|
+
trimSlash = (url) => url.replace(/\/+$/, "");
|
|
1024
|
+
NOT_CONFIGURED = "This build of WildCrane carries no Cloud project to sign in against.";
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
// ../cli/src/lib/machine/home.ts
|
|
1029
|
+
import os from "node:os";
|
|
568
1030
|
import path3 from "node:path";
|
|
569
|
-
function
|
|
1031
|
+
function machineHome() {
|
|
1032
|
+
return process.env.AI4KANBAN_HOME || path3.join(os.homedir(), ".ai4kanban");
|
|
1033
|
+
}
|
|
1034
|
+
var init_home = __esm({
|
|
1035
|
+
"../cli/src/lib/machine/home.ts"() {
|
|
1036
|
+
"use strict";
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
// ../cli/src/lib/cloud/session.ts
|
|
1041
|
+
import fs3 from "node:fs";
|
|
1042
|
+
import { createHash } from "node:crypto";
|
|
1043
|
+
import path4 from "node:path";
|
|
1044
|
+
function readRetry(session) {
|
|
1045
|
+
try {
|
|
1046
|
+
const retry2 = JSON.parse(fs3.readFileSync(retryFile(), "utf8"));
|
|
1047
|
+
if (retry2.key === refreshKey(session) && Number.isFinite(retry2.until) && Number.isInteger(retry2.attempt) && retry2.attempt > 0 && typeof retry2.error === "string") return retry2;
|
|
1048
|
+
} catch {
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function deferRefresh(session, error, after2) {
|
|
1052
|
+
const current = readSession();
|
|
1053
|
+
if (current?.subject === session.subject && current.refreshToken === session.refreshToken) {
|
|
1054
|
+
const attempt2 = Math.min((readRetry(session)?.attempt ?? 0) + 1, 4);
|
|
1055
|
+
const seconds = after2?.trim() ? Number(after2) : NaN;
|
|
1056
|
+
const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after2 ?? "") - Date.now();
|
|
1057
|
+
const delay2 = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt2 - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
|
|
1058
|
+
const retry2 = { key: refreshKey(session), until: Date.now() + delay2, attempt: attempt2, error };
|
|
1059
|
+
const temporary = `${retryFile()}.${process.pid}.tmp`;
|
|
1060
|
+
fs3.writeFileSync(temporary, JSON.stringify(retry2), { mode: 384 });
|
|
1061
|
+
fs3.renameSync(temporary, retryFile());
|
|
1062
|
+
}
|
|
1063
|
+
return { ok: false, reason: "unreachable", error };
|
|
1064
|
+
}
|
|
1065
|
+
function readSession() {
|
|
1066
|
+
let raw;
|
|
1067
|
+
try {
|
|
1068
|
+
raw = fs3.readFileSync(sessionFile(), "utf8");
|
|
1069
|
+
} catch {
|
|
1070
|
+
return null;
|
|
1071
|
+
}
|
|
1072
|
+
try {
|
|
1073
|
+
const held4 = JSON.parse(raw);
|
|
1074
|
+
if (!held4.accessToken || !held4.refreshToken || !held4.subject) return null;
|
|
1075
|
+
if (held4.supabaseUrl !== cloudEndpoints().supabaseUrl) return null;
|
|
1076
|
+
return { ...held4, version: 1, expiresAt: Number(held4.expiresAt) || 0 };
|
|
1077
|
+
} catch {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function writeSession(session) {
|
|
1082
|
+
fs3.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
1083
|
+
const tmp = `${sessionFile()}.${process.pid}.tmp`;
|
|
1084
|
+
fs3.writeFileSync(tmp, `${JSON.stringify(session, null, 2)}
|
|
1085
|
+
`, { mode: 384 });
|
|
1086
|
+
fs3.renameSync(tmp, sessionFile());
|
|
1087
|
+
if (!expiringSoon(session) || !readRetry(session)) fs3.rmSync(retryFile(), { force: true });
|
|
1088
|
+
}
|
|
1089
|
+
function clearSession() {
|
|
1090
|
+
try {
|
|
1091
|
+
fs3.rmSync(sessionFile());
|
|
1092
|
+
fs3.rmSync(retryFile(), { force: true });
|
|
1093
|
+
} catch {
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
async function accessToken() {
|
|
1097
|
+
const held4 = readSession();
|
|
1098
|
+
if (!held4) return { ok: false, reason: "signed-out" };
|
|
1099
|
+
if (!expiringSoon(held4)) return { ok: true, token: held4.accessToken, session: held4 };
|
|
1100
|
+
return refresh();
|
|
1101
|
+
}
|
|
1102
|
+
async function refresh() {
|
|
1103
|
+
const lock = await takeLock();
|
|
1104
|
+
if (!lock) return { ok: false, reason: "unreachable", error: "Cloud sign-in refresh is busy. Try again shortly." };
|
|
1105
|
+
try {
|
|
1106
|
+
const now = readSession();
|
|
1107
|
+
if (!now) return { ok: false, reason: "signed-out" };
|
|
1108
|
+
if (!expiringSoon(now)) return { ok: true, token: now.accessToken, session: now };
|
|
1109
|
+
const retry2 = readRetry(now);
|
|
1110
|
+
if (retry2 && retry2.until > Date.now()) return { ok: false, reason: "unreachable", error: retry2.error };
|
|
1111
|
+
const { api, anonKey } = cloudEndpoints();
|
|
1112
|
+
let response;
|
|
1113
|
+
try {
|
|
1114
|
+
response = await fetch(`${api}/auth/v1/token?grant_type=refresh_token`, {
|
|
1115
|
+
method: "POST",
|
|
1116
|
+
headers: { apikey: anonKey, "content-type": "application/json" },
|
|
1117
|
+
body: JSON.stringify({ refresh_token: now.refreshToken }),
|
|
1118
|
+
signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS)
|
|
1119
|
+
});
|
|
1120
|
+
} catch (e2) {
|
|
1121
|
+
return deferRefresh(now, e2 instanceof Error ? e2.message : String(e2));
|
|
1122
|
+
}
|
|
1123
|
+
if (!response.ok) {
|
|
1124
|
+
const body = await response.json().catch(() => null);
|
|
1125
|
+
const error = body?.error_description ?? body?.msg ?? body?.message;
|
|
1126
|
+
if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error ?? `Cloud answered ${response.status}`, response.headers.get("retry-after"));
|
|
1127
|
+
return { ok: false, reason: "expired", error };
|
|
1128
|
+
}
|
|
1129
|
+
const fresh = sessionFrom(await response.json().catch(() => null), now);
|
|
1130
|
+
if (!fresh) return deferRefresh(now, "Cloud returned an invalid sign-in refresh response.");
|
|
1131
|
+
const current = readSession();
|
|
1132
|
+
if (!current || current.subject !== now.subject) return { ok: false, reason: "expired" };
|
|
1133
|
+
if (current.refreshToken !== now.refreshToken) return { ok: true, token: current.accessToken, session: current };
|
|
1134
|
+
writeSession(fresh);
|
|
1135
|
+
return { ok: true, token: fresh.accessToken, session: fresh };
|
|
1136
|
+
} finally {
|
|
1137
|
+
lock();
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function sessionFrom(body, previous) {
|
|
1141
|
+
if (!body || typeof body !== "object") return null;
|
|
1142
|
+
const token2 = body;
|
|
1143
|
+
const subject = token2.user?.id ?? previous?.subject;
|
|
1144
|
+
if (!token2.access_token || !token2.refresh_token || !subject) return null;
|
|
1145
|
+
const expiresAt = token2.expires_at ? token2.expires_at * 1e3 : Date.now() + (token2.expires_in ?? 3600) * 1e3;
|
|
1146
|
+
return {
|
|
1147
|
+
version: 1,
|
|
1148
|
+
supabaseUrl: cloudEndpoints().supabaseUrl,
|
|
1149
|
+
accessToken: token2.access_token,
|
|
1150
|
+
refreshToken: token2.refresh_token,
|
|
1151
|
+
expiresAt,
|
|
1152
|
+
subject,
|
|
1153
|
+
email: token2.user?.email ?? previous?.email,
|
|
1154
|
+
handle: previous?.handle,
|
|
1155
|
+
name: previous?.name,
|
|
1156
|
+
avatarUrl: previous?.avatarUrl,
|
|
1157
|
+
avatar: previous?.avatar
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
async function takeLock() {
|
|
1161
|
+
const until = Date.now() + LOCK_WAIT_MS;
|
|
1162
|
+
for (; ; ) {
|
|
1163
|
+
try {
|
|
1164
|
+
fs3.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
1165
|
+
fs3.mkdirSync(lockDir());
|
|
1166
|
+
try {
|
|
1167
|
+
fs3.writeFileSync(lockOwner(), `${process.pid}
|
|
1168
|
+
`);
|
|
1169
|
+
} catch {
|
|
1170
|
+
}
|
|
1171
|
+
return () => {
|
|
1172
|
+
try {
|
|
1173
|
+
fs3.rmSync(lockDir(), { recursive: true, force: true });
|
|
1174
|
+
} catch {
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
} catch (err) {
|
|
1178
|
+
if (err.code !== "EEXIST") throw err;
|
|
1179
|
+
if (stale()) {
|
|
1180
|
+
fs3.rmSync(lockDir(), { recursive: true, force: true });
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (Date.now() > until) return null;
|
|
1184
|
+
await sleep(LOCK_RETRY_MS);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function stale() {
|
|
1189
|
+
let held4;
|
|
1190
|
+
try {
|
|
1191
|
+
const pid = Number(fs3.readFileSync(lockOwner(), "utf8").trim());
|
|
1192
|
+
held4 = Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
1193
|
+
} catch {
|
|
1194
|
+
held4 = void 0;
|
|
1195
|
+
}
|
|
1196
|
+
if (held4 !== void 0) return !alive(held4);
|
|
1197
|
+
try {
|
|
1198
|
+
return Date.now() - fs3.statSync(lockDir()).mtimeMs > LOCK_STALE_MS;
|
|
1199
|
+
} catch {
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
function alive(pid) {
|
|
1204
|
+
try {
|
|
1205
|
+
process.kill(pid, 0);
|
|
1206
|
+
return true;
|
|
1207
|
+
} catch (e2) {
|
|
1208
|
+
return e2.code === "EPERM";
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
var REFRESH_MARGIN_MS, LOCK_STALE_MS, LOCK_WAIT_MS, LOCK_RETRY_MS, REFRESH_TIMEOUT_MS, REFRESH_BACKOFF_MS, sessionFile, lockDir, lockOwner, retryFile, refreshKey, expiringSoon, sleep;
|
|
1212
|
+
var init_session = __esm({
|
|
1213
|
+
"../cli/src/lib/cloud/session.ts"() {
|
|
1214
|
+
"use strict";
|
|
1215
|
+
init_home();
|
|
1216
|
+
init_config();
|
|
1217
|
+
REFRESH_MARGIN_MS = 6e4;
|
|
1218
|
+
LOCK_STALE_MS = 3e4;
|
|
1219
|
+
LOCK_WAIT_MS = 2e4;
|
|
1220
|
+
LOCK_RETRY_MS = 50;
|
|
1221
|
+
REFRESH_TIMEOUT_MS = 15e3;
|
|
1222
|
+
REFRESH_BACKOFF_MS = 6e4;
|
|
1223
|
+
sessionFile = () => path4.join(machineHome(), "session.json");
|
|
1224
|
+
lockDir = () => path4.join(machineHome(), "session.lock");
|
|
1225
|
+
lockOwner = () => path4.join(lockDir(), "owner");
|
|
1226
|
+
retryFile = () => path4.join(machineHome(), "session-refresh.json");
|
|
1227
|
+
refreshKey = (session) => createHash("sha256").update(JSON.stringify([cloudEndpoints().api, session.subject, session.refreshToken])).digest("hex");
|
|
1228
|
+
expiringSoon = (session) => session.expiresAt - REFRESH_MARGIN_MS <= Date.now();
|
|
1229
|
+
sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
// ../cli/src/lib/cloud/tasks.ts
|
|
1234
|
+
import crypto from "node:crypto";
|
|
1235
|
+
import fs4 from "node:fs";
|
|
1236
|
+
import path5 from "node:path";
|
|
1237
|
+
function workspaceTask() {
|
|
1238
|
+
const id = process.env[TASK_ENV];
|
|
1239
|
+
return id && id.trim() ? id.trim() : null;
|
|
1240
|
+
}
|
|
1241
|
+
function cloudStudio(name) {
|
|
1242
|
+
if (/^wf-/.test(name)) return name.replace("-", "_");
|
|
1243
|
+
return `wf_builtin_${name.replace(/-/g, "_")}`;
|
|
1244
|
+
}
|
|
1245
|
+
async function call(method, route2, body, key) {
|
|
1246
|
+
if (!cloudConfigured()) return { ok: false, error: NOT_CONFIGURED, code: "bad_request" };
|
|
1247
|
+
const token2 = await accessToken();
|
|
1248
|
+
if (!token2.ok) {
|
|
1249
|
+
return token2.reason === "unreachable" ? { ok: false, error: `Cloud could not be reached: ${token2.error}` } : { ok: false, error: token2.reason === "expired" ? "Cloud sign-in has expired. Sign in again." : "This machine is not signed in to Cloud.", code: "unauthenticated" };
|
|
1250
|
+
}
|
|
1251
|
+
let response;
|
|
1252
|
+
try {
|
|
1253
|
+
response = await fetch(`${cloudEndpoints().api}${route2}`, {
|
|
1254
|
+
method,
|
|
1255
|
+
headers: {
|
|
1256
|
+
authorization: `Bearer ${token2.token}`,
|
|
1257
|
+
...body ? { "content-type": "application/json" } : {},
|
|
1258
|
+
...key ? { "idempotency-key": key } : {}
|
|
1259
|
+
},
|
|
1260
|
+
...body ? { body: JSON.stringify(body) } : {},
|
|
1261
|
+
signal: AbortSignal.timeout(2e4)
|
|
1262
|
+
});
|
|
1263
|
+
} catch (e2) {
|
|
1264
|
+
return { ok: false, error: `Cloud could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}` };
|
|
1265
|
+
}
|
|
1266
|
+
const parsed = await response.json().catch(() => ({}));
|
|
1267
|
+
if (!response.ok) return { ok: false, code: parsed.error?.code ?? "refused", error: parsed.error?.message ?? `Cloud answered ${response.status}.` };
|
|
1268
|
+
return { ok: true, value: parsed, replayed: response.headers.get("idempotent-replayed") === "true" };
|
|
1269
|
+
}
|
|
1270
|
+
async function createTask(from, said2) {
|
|
1271
|
+
const source2 = await call("GET", `/v1/tasks/${encodeURIComponent(from)}`);
|
|
1272
|
+
if (!source2.ok) return source2;
|
|
1273
|
+
const studio = said2.studio ? cloudStudio(said2.studio) : source2.value.studio?.id;
|
|
1274
|
+
const body = {
|
|
1275
|
+
title: said2.title,
|
|
1276
|
+
project: source2.value.project,
|
|
1277
|
+
...studio ? { studio } : {},
|
|
1278
|
+
...said2.request?.trim() ? { request: said2.request.trim() } : {},
|
|
1279
|
+
source: "api",
|
|
1280
|
+
source_context: { task: from, ...said2.agent ? { agent: said2.agent } : {} },
|
|
1281
|
+
...said2.run ? { run: true } : {},
|
|
1282
|
+
...said2.metadata && Object.keys(said2.metadata).length ? { metadata: said2.metadata } : {},
|
|
1283
|
+
...said2.triage ? { triage: `tri_${source2.value.project.replace(/^prj_/, "")}_${said2.triage}` } : {}
|
|
1284
|
+
};
|
|
1285
|
+
const key = `akb-${crypto.createHash("sha256").update(`${from}
|
|
1286
|
+
${said2.slug?.trim() || said2.title}`).digest("hex").slice(0, 40)}`;
|
|
1287
|
+
const made = await call("POST", "/v1/tasks", body, key);
|
|
1288
|
+
if (!made.ok) return made;
|
|
1289
|
+
const number = numberOf(made.value.key);
|
|
1290
|
+
if (!Number.isInteger(number)) return { ok: false, error: `Cloud answered a task with no number: ${made.value.key}`, code: "refused" };
|
|
1291
|
+
return { ok: true, value: { task: made.value, number, from: source2.value, replayed: made.replayed === true } };
|
|
1292
|
+
}
|
|
1293
|
+
function runnerProject(board2) {
|
|
1294
|
+
if (path5.basename(board2) !== "kanban" || path5.basename(path5.dirname(board2)) !== ".akb") return null;
|
|
1295
|
+
const linked2 = linkedProject(board2, path5.dirname(path5.dirname(board2)));
|
|
1296
|
+
return linked2.ok ? linked2.value : null;
|
|
1297
|
+
}
|
|
1298
|
+
function linkedProject(board2, root2) {
|
|
1299
|
+
const file2 = path5.join(root2, ".akb", "base.json");
|
|
1300
|
+
if (!fs4.existsSync(file2)) return { ok: true, value: null };
|
|
1301
|
+
try {
|
|
1302
|
+
const base = JSON.parse(fs4.readFileSync(file2, "utf8"));
|
|
1303
|
+
if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
|
|
1304
|
+
const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
|
|
1305
|
+
if (typeof base.project === "string") projects.add(base.project);
|
|
1306
|
+
if (projects.size !== 1) throw new Error();
|
|
1307
|
+
return { ok: true, value: [...projects][0] };
|
|
1308
|
+
} catch {
|
|
1309
|
+
return { ok: false, error: "The project link is invalid or names multiple projects.", code: "invalid-link" };
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
async function creationProject(board2, root2, task = workspaceTask()) {
|
|
1313
|
+
const link2 = linkedProject(board2, root2);
|
|
1314
|
+
if (!link2.ok) return link2;
|
|
1315
|
+
let project2 = link2.value;
|
|
1316
|
+
if (task) {
|
|
1317
|
+
const source2 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}`);
|
|
1318
|
+
if (!source2.ok) return {
|
|
1319
|
+
...source2,
|
|
1320
|
+
error: source2.code === "forbidden" ? "Cannot access this task. Check your account and task access in WildCrane, then try again." : source2.code === "not_found" ? "This task does not exist. Start a new task from the WildCrane web app." : source2.error
|
|
1321
|
+
};
|
|
1322
|
+
if (project2 && project2 !== source2.value.project) return { ok: false, error: "The source task conflicts with this board\u2019s project link.", code: "invalid-link" };
|
|
1323
|
+
project2 = source2.value.project;
|
|
1324
|
+
}
|
|
1325
|
+
if (!project2) return { ok: false, error: "This board is not linked to a Cloud project.", code: "unlinked" };
|
|
1326
|
+
const checked = await call("GET", `/v1/projects/${encodeURIComponent(project2)}`);
|
|
1327
|
+
return checked.ok ? { ok: true, value: project2 } : checked;
|
|
1328
|
+
}
|
|
1329
|
+
async function createProjectTask(project2, said2, key) {
|
|
1330
|
+
const made = await call("POST", "/v1/tasks", {
|
|
1331
|
+
title: said2.title,
|
|
1332
|
+
project: project2,
|
|
1333
|
+
source: "api",
|
|
1334
|
+
...said2.studio ? { studio: cloudStudio(said2.studio) } : {},
|
|
1335
|
+
...said2.request?.trim() ? { request: said2.request.trim() } : {},
|
|
1336
|
+
...said2.agent ? { source_context: { agent: said2.agent } } : {},
|
|
1337
|
+
...said2.triage ? { triage: `tri_${project2.replace(/^prj_/, "")}_${said2.triage}` } : {}
|
|
1338
|
+
}, key);
|
|
1339
|
+
if (!made.ok) return made;
|
|
1340
|
+
const number = numberOf(made.value.key);
|
|
1341
|
+
if (!Number.isInteger(number)) return { ok: false, error: `Cloud answered a task with no number: ${made.value.key}`, code: "refused" };
|
|
1342
|
+
return { ok: true, value: { task: made.value, number } };
|
|
1343
|
+
}
|
|
1344
|
+
async function approveTask(project2, number) {
|
|
1345
|
+
const held4 = await call("GET", `/v1/projects/${encodeURIComponent(project2)}`);
|
|
1346
|
+
if (!held4.ok) return held4;
|
|
1347
|
+
const key = `${held4.value.prefix}-${number}`;
|
|
1348
|
+
const task = await call("GET", `/v1/tasks/${encodeURIComponent(key)}`);
|
|
1349
|
+
if (!task.ok) return task;
|
|
1350
|
+
const revision = task.value.review?.revision;
|
|
1351
|
+
const decided = await call("POST", `/v1/tasks/${encodeURIComponent(key)}/decisions`, {
|
|
1352
|
+
decision: "approve",
|
|
1353
|
+
...revision !== void 0 ? { review_revision: revision } : {}
|
|
1354
|
+
});
|
|
1355
|
+
return decided.ok ? { ok: true, value: { key } } : decided;
|
|
1356
|
+
}
|
|
1357
|
+
var TASK_ENV, numberOf;
|
|
1358
|
+
var init_tasks = __esm({
|
|
1359
|
+
"../cli/src/lib/cloud/tasks.ts"() {
|
|
1360
|
+
"use strict";
|
|
1361
|
+
init_config();
|
|
1362
|
+
init_session();
|
|
1363
|
+
TASK_ENV = "AI4KANBAN_TASK";
|
|
1364
|
+
numberOf = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? NaN);
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
// ../cli/src/lib/lock.ts
|
|
1369
|
+
import fs5 from "node:fs";
|
|
1370
|
+
import path6 from "node:path";
|
|
1371
|
+
function sleep2(ms) {
|
|
570
1372
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
571
1373
|
}
|
|
572
1374
|
function ageOf(dir) {
|
|
573
1375
|
try {
|
|
574
|
-
return Date.now() -
|
|
1376
|
+
return Date.now() - fs5.statSync(dir).mtimeMs;
|
|
575
1377
|
} catch {
|
|
576
1378
|
return 0;
|
|
577
1379
|
}
|
|
@@ -587,7 +1389,7 @@ function pidAlive(pid) {
|
|
|
587
1389
|
}
|
|
588
1390
|
function ownerOf(dir) {
|
|
589
1391
|
try {
|
|
590
|
-
const pid = Number(
|
|
1392
|
+
const pid = Number(fs5.readFileSync(path6.join(dir, OWNER), "utf8").trim());
|
|
591
1393
|
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
592
1394
|
} catch {
|
|
593
1395
|
return void 0;
|
|
@@ -595,7 +1397,7 @@ function ownerOf(dir) {
|
|
|
595
1397
|
}
|
|
596
1398
|
function claimBreak(dir) {
|
|
597
1399
|
try {
|
|
598
|
-
|
|
1400
|
+
fs5.mkdirSync(path6.join(dir, BREAKING));
|
|
599
1401
|
return true;
|
|
600
1402
|
} catch {
|
|
601
1403
|
return false;
|
|
@@ -606,9 +1408,9 @@ function withLock(dir, what, fn2) {
|
|
|
606
1408
|
let held4;
|
|
607
1409
|
for (; ; ) {
|
|
608
1410
|
try {
|
|
609
|
-
|
|
1411
|
+
fs5.mkdirSync(dir, { recursive: false });
|
|
610
1412
|
try {
|
|
611
|
-
|
|
1413
|
+
fs5.writeFileSync(path6.join(dir, OWNER), `${process.pid}
|
|
612
1414
|
`);
|
|
613
1415
|
} catch {
|
|
614
1416
|
}
|
|
@@ -616,17 +1418,17 @@ function withLock(dir, what, fn2) {
|
|
|
616
1418
|
} catch (err) {
|
|
617
1419
|
const code = err.code;
|
|
618
1420
|
if (code === "ENOENT") {
|
|
619
|
-
|
|
1421
|
+
fs5.mkdirSync(path6.dirname(dir), { recursive: true });
|
|
620
1422
|
continue;
|
|
621
1423
|
}
|
|
622
1424
|
if (code !== "EEXIST") throw err;
|
|
623
1425
|
if (ageOf(dir) > STALE_MS) {
|
|
624
|
-
|
|
1426
|
+
fs5.rmSync(dir, { recursive: true, force: true });
|
|
625
1427
|
continue;
|
|
626
1428
|
}
|
|
627
1429
|
held4 = ownerOf(dir);
|
|
628
1430
|
if (held4 !== void 0 && !pidAlive(held4) && claimBreak(dir)) {
|
|
629
|
-
|
|
1431
|
+
fs5.rmSync(dir, { recursive: true, force: true });
|
|
630
1432
|
continue;
|
|
631
1433
|
}
|
|
632
1434
|
if (Date.now() > until) {
|
|
@@ -635,18 +1437,18 @@ function withLock(dir, what, fn2) {
|
|
|
635
1437
|
"board-busy"
|
|
636
1438
|
);
|
|
637
1439
|
}
|
|
638
|
-
|
|
1440
|
+
sleep2(RETRY_MS);
|
|
639
1441
|
}
|
|
640
1442
|
}
|
|
641
1443
|
try {
|
|
642
1444
|
return fn2();
|
|
643
1445
|
} finally {
|
|
644
1446
|
const owner = ownerOf(dir);
|
|
645
|
-
if (owner === void 0 || owner === process.pid)
|
|
1447
|
+
if (owner === void 0 || owner === process.pid) fs5.rmSync(dir, { recursive: true, force: true });
|
|
646
1448
|
}
|
|
647
1449
|
}
|
|
648
1450
|
function withBoardLock(fn2) {
|
|
649
|
-
if (!
|
|
1451
|
+
if (!fs5.existsSync(KANBAN)) return fn2();
|
|
650
1452
|
if (depth > 0) return fn2();
|
|
651
1453
|
try {
|
|
652
1454
|
ensureAkbDir();
|
|
@@ -712,8 +1514,8 @@ var init_argv = __esm({
|
|
|
712
1514
|
});
|
|
713
1515
|
|
|
714
1516
|
// ../cli/src/lib/agent/installed.ts
|
|
715
|
-
import
|
|
716
|
-
import
|
|
1517
|
+
import fs6 from "node:fs";
|
|
1518
|
+
import path7 from "node:path";
|
|
717
1519
|
function windowsExtensions() {
|
|
718
1520
|
const raw = process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD";
|
|
719
1521
|
return raw.split(";").map((ext) => ext.trim().toLowerCase()).filter(Boolean);
|
|
@@ -724,21 +1526,21 @@ function commandBinary(command) {
|
|
|
724
1526
|
function binaryOnPath(binary) {
|
|
725
1527
|
if (!binary) return false;
|
|
726
1528
|
const extensions = WINDOWS ? ["", ...windowsExtensions()] : [""];
|
|
727
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
1529
|
+
for (const dir of (process.env.PATH ?? "").split(path7.delimiter)) {
|
|
728
1530
|
if (!dir) continue;
|
|
729
1531
|
for (const ext of extensions) {
|
|
730
|
-
if (
|
|
1532
|
+
if (fs6.existsSync(path7.join(dir, `${binary}${ext}`))) return true;
|
|
731
1533
|
}
|
|
732
1534
|
}
|
|
733
1535
|
return false;
|
|
734
1536
|
}
|
|
735
1537
|
function pathLookup() {
|
|
736
1538
|
const names3 = /* @__PURE__ */ new Set();
|
|
737
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
1539
|
+
for (const dir of (process.env.PATH ?? "").split(path7.delimiter)) {
|
|
738
1540
|
if (!dir) continue;
|
|
739
1541
|
let entries;
|
|
740
1542
|
try {
|
|
741
|
-
entries =
|
|
1543
|
+
entries = fs6.readdirSync(dir);
|
|
742
1544
|
} catch {
|
|
743
1545
|
continue;
|
|
744
1546
|
}
|
|
@@ -748,7 +1550,7 @@ function pathLookup() {
|
|
|
748
1550
|
return (command) => {
|
|
749
1551
|
const binary = commandBinary(command);
|
|
750
1552
|
if (!binary) return false;
|
|
751
|
-
if (binary.includes("/") || binary.includes("\\")) return
|
|
1553
|
+
if (binary.includes("/") || binary.includes("\\")) return fs6.existsSync(binary);
|
|
752
1554
|
if (!WINDOWS) return names3.has(binary);
|
|
753
1555
|
const lower = binary.toLowerCase();
|
|
754
1556
|
return names3.has(lower) || extensions.some((ext) => names3.has(`${lower}${ext}`));
|
|
@@ -765,11 +1567,11 @@ var init_installed = __esm({
|
|
|
765
1567
|
|
|
766
1568
|
// ../cli/src/lib/agent/launch.ts
|
|
767
1569
|
import { spawn } from "node:child_process";
|
|
768
|
-
import
|
|
769
|
-
import
|
|
1570
|
+
import fs7 from "node:fs";
|
|
1571
|
+
import path8 from "node:path";
|
|
770
1572
|
import { fileURLToPath } from "node:url";
|
|
771
1573
|
function boardArgs() {
|
|
772
|
-
const standard =
|
|
1574
|
+
const standard = path8.join(REPO_ROOT, "docs", "kanban");
|
|
773
1575
|
return KANBAN === standard ? ["--dir", REPO_ROOT] : ["--board", KANBAN];
|
|
774
1576
|
}
|
|
775
1577
|
function watcherEnv(env2 = process.env) {
|
|
@@ -778,8 +1580,8 @@ function watcherEnv(env2 = process.env) {
|
|
|
778
1580
|
}
|
|
779
1581
|
function spawnWatcher(sessionId) {
|
|
780
1582
|
if (!BUILT) return void 0;
|
|
781
|
-
|
|
782
|
-
const out =
|
|
1583
|
+
fs7.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
1584
|
+
const out = fs7.openSync(path8.join(SESSIONS_DIR, `${sessionId}.watch.log`), "a");
|
|
783
1585
|
try {
|
|
784
1586
|
const child = spawn(process.execPath, [SELF, "__watch", sessionId, ...boardArgs()], {
|
|
785
1587
|
cwd: REPO_ROOT,
|
|
@@ -795,7 +1597,7 @@ function spawnWatcher(sessionId) {
|
|
|
795
1597
|
return void 0;
|
|
796
1598
|
} finally {
|
|
797
1599
|
try {
|
|
798
|
-
|
|
1600
|
+
fs7.closeSync(out);
|
|
799
1601
|
} catch {
|
|
800
1602
|
}
|
|
801
1603
|
}
|
|
@@ -812,13 +1614,13 @@ var init_launch = __esm({
|
|
|
812
1614
|
});
|
|
813
1615
|
|
|
814
1616
|
// ../cli/src/lib/agent/command.ts
|
|
815
|
-
import
|
|
816
|
-
import
|
|
1617
|
+
import fs8 from "node:fs";
|
|
1618
|
+
import path9 from "node:path";
|
|
817
1619
|
function selfCommand() {
|
|
818
|
-
const bin =
|
|
819
|
-
const file2 =
|
|
1620
|
+
const bin = path9.resolve(path9.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
1621
|
+
const file2 = fs8.existsSync(bin) ? bin : SELF;
|
|
820
1622
|
const inside2 = rel(file2);
|
|
821
|
-
const shortHop = !inside2.startsWith("..") && !
|
|
1623
|
+
const shortHop = !inside2.startsWith("..") && !path9.isAbsolute(inside2) && inside2.split(/[\\/]/).length <= 3;
|
|
822
1624
|
return `node ${shortHop ? inside2 : file2}`;
|
|
823
1625
|
}
|
|
824
1626
|
function boardCommand() {
|
|
@@ -833,8 +1635,8 @@ function rawMove(words) {
|
|
|
833
1635
|
return `${command} raw ${words}${BOARD_FLAG || ` --dir ${REPO_ROOT}`}`;
|
|
834
1636
|
}
|
|
835
1637
|
function absoluteSelf() {
|
|
836
|
-
const bin =
|
|
837
|
-
return
|
|
1638
|
+
const bin = path9.resolve(path9.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
1639
|
+
return fs8.existsSync(bin) ? bin : SELF;
|
|
838
1640
|
}
|
|
839
1641
|
function commandNote(command) {
|
|
840
1642
|
if (command === "akb") return "";
|
|
@@ -850,9 +1652,9 @@ var init_command = __esm({
|
|
|
850
1652
|
});
|
|
851
1653
|
|
|
852
1654
|
// ../cli/src/lib/machine/identity.ts
|
|
853
|
-
import
|
|
1655
|
+
import os2 from "node:os";
|
|
854
1656
|
function machineName() {
|
|
855
|
-
const raw =
|
|
1657
|
+
const raw = os2.hostname().trim();
|
|
856
1658
|
return raw.replace(/\.local$/i, "") || "this machine";
|
|
857
1659
|
}
|
|
858
1660
|
var init_identity = __esm({
|
|
@@ -931,21 +1733,9 @@ var init_capabilities = __esm({
|
|
|
931
1733
|
}
|
|
932
1734
|
});
|
|
933
1735
|
|
|
934
|
-
// ../cli/src/lib/machine/home.ts
|
|
935
|
-
import os2 from "node:os";
|
|
936
|
-
import path7 from "node:path";
|
|
937
|
-
function machineHome() {
|
|
938
|
-
return process.env.AI4KANBAN_HOME || path7.join(os2.homedir(), ".ai4kanban");
|
|
939
|
-
}
|
|
940
|
-
var init_home = __esm({
|
|
941
|
-
"../cli/src/lib/machine/home.ts"() {
|
|
942
|
-
"use strict";
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
|
|
946
1736
|
// ../cli/src/lib/agent/spawnable.ts
|
|
947
|
-
import
|
|
948
|
-
import
|
|
1737
|
+
import fs9 from "node:fs";
|
|
1738
|
+
import path10 from "node:path";
|
|
949
1739
|
function cmdArg(arg) {
|
|
950
1740
|
const quoted = `"${arg.replace(/\r?\n|\r/g, " ").replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1")}"`;
|
|
951
1741
|
return quoted.replace(META, "^$1").replace(META, "^$1");
|
|
@@ -954,21 +1744,21 @@ function cmdLine(file2, args2) {
|
|
|
954
1744
|
return `"${[file2.replace(META, "^$1"), ...args2.map(cmdArg)].join(" ")}"`;
|
|
955
1745
|
}
|
|
956
1746
|
function shimTarget(text6, file2) {
|
|
957
|
-
const dir =
|
|
1747
|
+
const dir = path10.win32.dirname(file2);
|
|
958
1748
|
const found2 = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(text6);
|
|
959
1749
|
if (!found2 || !/\\node\.exe"/i.test(text6)) return null;
|
|
960
|
-
const script =
|
|
961
|
-
const local =
|
|
1750
|
+
const script = path10.win32.resolve(dir, found2[1].replace(/\//g, "\\"));
|
|
1751
|
+
const local = path10.win32.join(dir, "node.exe");
|
|
962
1752
|
const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(text6)?.[1];
|
|
963
|
-
return { script, node:
|
|
1753
|
+
return { script, node: fs9.existsSync(local) ? local : "node", env: nodePath ? { NODE_PATH: nodePath } : {} };
|
|
964
1754
|
}
|
|
965
1755
|
function onWindowsPath(name, env2) {
|
|
966
1756
|
const exts = (env2.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
967
1757
|
const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
|
|
968
1758
|
for (const dir of (env2[key] ?? "").split(";").filter(Boolean)) {
|
|
969
1759
|
for (const ext of exts) {
|
|
970
|
-
const file2 =
|
|
971
|
-
if (
|
|
1760
|
+
const file2 = path10.win32.join(dir, `${name}${ext.toLowerCase()}`);
|
|
1761
|
+
if (fs9.existsSync(file2)) return file2;
|
|
972
1762
|
}
|
|
973
1763
|
}
|
|
974
1764
|
return void 0;
|
|
@@ -976,13 +1766,13 @@ function onWindowsPath(name, env2) {
|
|
|
976
1766
|
function spawnable(command, args2, options = {}, platform = process.platform) {
|
|
977
1767
|
if (platform !== "win32") return { command, args: args2, options };
|
|
978
1768
|
const env2 = options.env ?? process.env;
|
|
979
|
-
const file2 =
|
|
980
|
-
const ext =
|
|
1769
|
+
const file2 = path10.extname(command) || /[\\/]/.test(command) ? command : onWindowsPath(command, env2) ?? command;
|
|
1770
|
+
const ext = path10.extname(file2).toLowerCase();
|
|
981
1771
|
const hidden = { ...options, windowsHide: true, shell: false };
|
|
982
1772
|
if (ext !== ".cmd" && ext !== ".bat") return { command: file2, args: args2, options: hidden };
|
|
983
1773
|
let text6 = "";
|
|
984
1774
|
try {
|
|
985
|
-
text6 =
|
|
1775
|
+
text6 = fs9.readFileSync(file2, "utf8");
|
|
986
1776
|
} catch {
|
|
987
1777
|
}
|
|
988
1778
|
const shim = shimTarget(text6, file2);
|
|
@@ -1005,9 +1795,9 @@ var init_spawnable = __esm({
|
|
|
1005
1795
|
|
|
1006
1796
|
// ../cli/src/lib/agent/locate.ts
|
|
1007
1797
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
1008
|
-
import
|
|
1798
|
+
import fs10 from "node:fs";
|
|
1009
1799
|
import os3 from "node:os";
|
|
1010
|
-
import
|
|
1800
|
+
import path11 from "node:path";
|
|
1011
1801
|
function versionIn(output) {
|
|
1012
1802
|
const plain = output.replace(/\x1b\[[0-9;]*m/g, "");
|
|
1013
1803
|
return /(?<![\w.-])v?(\d+(?:\.\d+)+(?:-[0-9A-Za-z.-]+)?)/.exec(plain)?.[1] ?? null;
|
|
@@ -1052,7 +1842,7 @@ function pick(copies) {
|
|
|
1052
1842
|
}
|
|
1053
1843
|
function folders(parent) {
|
|
1054
1844
|
try {
|
|
1055
|
-
return
|
|
1845
|
+
return fs10.readdirSync(parent, { withFileTypes: true }).filter((one) => one.isDirectory()).map((one) => one.name);
|
|
1056
1846
|
} catch {
|
|
1057
1847
|
return [];
|
|
1058
1848
|
}
|
|
@@ -1071,28 +1861,28 @@ function byVersion(names3) {
|
|
|
1071
1861
|
function latestIn(parent, tail = "") {
|
|
1072
1862
|
let names3;
|
|
1073
1863
|
try {
|
|
1074
|
-
names3 =
|
|
1864
|
+
names3 = fs10.readdirSync(parent);
|
|
1075
1865
|
} catch {
|
|
1076
1866
|
return [];
|
|
1077
1867
|
}
|
|
1078
|
-
return byVersion(names3.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) =>
|
|
1868
|
+
return byVersion(names3.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) => path11.join(parent, name, tail));
|
|
1079
1869
|
}
|
|
1080
1870
|
function commonDirs() {
|
|
1081
1871
|
const home3 = os3.homedir();
|
|
1082
|
-
const under = (...parts) =>
|
|
1083
|
-
const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) =>
|
|
1872
|
+
const under = (...parts) => path11.join(home3, ...parts);
|
|
1873
|
+
const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) => path11.join(root2, version, ...tail)) : [];
|
|
1084
1874
|
if (WINDOWS2) {
|
|
1085
1875
|
const [app, local, data, programs] = [env("APPDATA"), env("LOCALAPPDATA"), env("ProgramData"), env("ProgramFiles")];
|
|
1086
1876
|
return [
|
|
1087
1877
|
under(".local", "bin"),
|
|
1088
1878
|
under(".bun", "bin"),
|
|
1089
1879
|
under("scoop", "shims"),
|
|
1090
|
-
...app ? [
|
|
1091
|
-
...local ? [
|
|
1092
|
-
...data ? [
|
|
1093
|
-
...programs ? [
|
|
1880
|
+
...app ? [path11.join(app, "npm")] : [],
|
|
1881
|
+
...local ? [path11.join(local, "pnpm"), path11.join(local, "Volta", "bin"), path11.join(local, "Microsoft", "WinGet", "Links")] : [],
|
|
1882
|
+
...data ? [path11.join(data, "chocolatey", "bin")] : [],
|
|
1883
|
+
...programs ? [path11.join(programs, "nodejs")] : [],
|
|
1094
1884
|
...nodes(env("NVM_HOME")),
|
|
1095
|
-
...app ? nodes(
|
|
1885
|
+
...app ? nodes(path11.join(app, "fnm", "node-versions"), ["installation"]) : []
|
|
1096
1886
|
];
|
|
1097
1887
|
}
|
|
1098
1888
|
const support = process.platform === "darwin" ? under("Library", "Application Support") : under(".local", "share");
|
|
@@ -1109,10 +1899,10 @@ function commonDirs() {
|
|
|
1109
1899
|
...env("PNPM_HOME") ? [env("PNPM_HOME")] : [],
|
|
1110
1900
|
under("Library", "pnpm"),
|
|
1111
1901
|
under(".local", "share", "pnpm"),
|
|
1112
|
-
|
|
1113
|
-
...nodes(
|
|
1114
|
-
...nodes(
|
|
1115
|
-
...nodes(
|
|
1902
|
+
path11.join(env("VOLTA_HOME") || under(".volta"), "bin"),
|
|
1903
|
+
...nodes(path11.join(env("NVM_DIR") || under(".nvm"), "versions", "node"), ["bin"]),
|
|
1904
|
+
...nodes(path11.join(env("FNM_DIR") || path11.join(support, "fnm"), "node-versions"), ["installation", "bin"]),
|
|
1905
|
+
...nodes(path11.join(env("ASDF_DATA_DIR") || under(".asdf"), "installs", "nodejs"), ["bin"]),
|
|
1116
1906
|
...nodes(under(".local", "share", "mise", "installs", "node"), ["bin"]),
|
|
1117
1907
|
...nodes(under(".nodenv", "versions"), ["bin"]),
|
|
1118
1908
|
...nodes("/usr/local/n/versions/node", ["bin"])
|
|
@@ -1120,19 +1910,19 @@ function commonDirs() {
|
|
|
1120
1910
|
}
|
|
1121
1911
|
function onPath(binary) {
|
|
1122
1912
|
const names3 = WINDOWS2 ? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((ext) => `${binary}${ext.toLowerCase()}`) : [binary];
|
|
1123
|
-
return (process.env.PATH ?? "").split(
|
|
1913
|
+
return (process.env.PATH ?? "").split(path11.delimiter).filter(Boolean).flatMap((dir) => names3.map((name) => path11.join(dir, name)));
|
|
1124
1914
|
}
|
|
1125
1915
|
function copyFiles(harness) {
|
|
1126
1916
|
const pinned2 = harness.pinned?.();
|
|
1127
1917
|
if (pinned2 && isFile(pinned2)) return [{ file: pinned2, entry: false }];
|
|
1128
1918
|
const binary = commandBinary(harness.command);
|
|
1129
|
-
const exe = (file2) => WINDOWS2 && !
|
|
1919
|
+
const exe = (file2) => WINDOWS2 && !path11.extname(file2) ? [`${file2}.exe`, `${file2}.cmd`] : [file2];
|
|
1130
1920
|
const path_ = onPath(binary).filter(isFile);
|
|
1131
|
-
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) =>
|
|
1921
|
+
const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) => path11.join(dir, binary))];
|
|
1132
1922
|
const others = elsewhere.flatMap(exe).filter(isFile);
|
|
1133
1923
|
const seen = /* @__PURE__ */ new Set();
|
|
1134
1924
|
return [...path_, ...others].flatMap((file2, i) => {
|
|
1135
|
-
const real2 =
|
|
1925
|
+
const real2 = fs10.realpathSync.native(file2);
|
|
1136
1926
|
if (seen.has(real2)) return [];
|
|
1137
1927
|
seen.add(real2);
|
|
1138
1928
|
return [{ file: file2, entry: i === 0 && path_.length > 0 }];
|
|
@@ -1141,7 +1931,7 @@ function copyFiles(harness) {
|
|
|
1141
1931
|
function kept() {
|
|
1142
1932
|
if (answers) return answers;
|
|
1143
1933
|
try {
|
|
1144
|
-
answers = JSON.parse(
|
|
1934
|
+
answers = JSON.parse(fs10.readFileSync(answersFile(), "utf8"));
|
|
1145
1935
|
} catch {
|
|
1146
1936
|
answers = {};
|
|
1147
1937
|
}
|
|
@@ -1150,16 +1940,16 @@ function kept() {
|
|
|
1150
1940
|
function keep(file2, answer2) {
|
|
1151
1941
|
kept()[file2] = answer2;
|
|
1152
1942
|
try {
|
|
1153
|
-
|
|
1943
|
+
fs10.mkdirSync(machineHome(), { recursive: true });
|
|
1154
1944
|
const staged = `${answersFile()}.${process.pid}`;
|
|
1155
|
-
|
|
1156
|
-
|
|
1945
|
+
fs10.writeFileSync(staged, JSON.stringify(answers));
|
|
1946
|
+
fs10.renameSync(staged, answersFile());
|
|
1157
1947
|
} catch {
|
|
1158
1948
|
}
|
|
1159
1949
|
}
|
|
1160
1950
|
function keyOf(file2) {
|
|
1161
|
-
const real2 =
|
|
1162
|
-
const stat =
|
|
1951
|
+
const real2 = fs10.realpathSync.native(file2);
|
|
1952
|
+
const stat = fs10.statSync(real2);
|
|
1163
1953
|
return `${real2}|${stat.size}|${stat.mtimeMs}`;
|
|
1164
1954
|
}
|
|
1165
1955
|
function known(file2, maxAge) {
|
|
@@ -1172,8 +1962,8 @@ function judge(code, status, stdout, stderr) {
|
|
|
1172
1962
|
return { starts: true, version: status === 0 ? versionIn(stdout) ?? versionIn(stderr) : null };
|
|
1173
1963
|
}
|
|
1174
1964
|
function copyEnv(file2, given = process.env) {
|
|
1175
|
-
if (!
|
|
1176
|
-
return { ...given, PATH: [
|
|
1965
|
+
if (!path11.isAbsolute(file2)) return given;
|
|
1966
|
+
return { ...given, PATH: [path11.dirname(file2), given.PATH].filter(Boolean).join(path11.delimiter) };
|
|
1177
1967
|
}
|
|
1178
1968
|
function probe(file2) {
|
|
1179
1969
|
const key = keyOf(file2);
|
|
@@ -1224,13 +2014,13 @@ var init_locate = __esm({
|
|
|
1224
2014
|
env = (name) => process.env[name]?.trim() ?? "";
|
|
1225
2015
|
isFile = (file2) => {
|
|
1226
2016
|
try {
|
|
1227
|
-
return
|
|
2017
|
+
return fs10.statSync(file2).isFile();
|
|
1228
2018
|
} catch {
|
|
1229
2019
|
return false;
|
|
1230
2020
|
}
|
|
1231
2021
|
};
|
|
1232
2022
|
isCopy = (harness, file2) => copyFiles(harness).some((one) => one.file === file2);
|
|
1233
|
-
answersFile = () =>
|
|
2023
|
+
answersFile = () => path11.join(machineHome(), "agent-copies.json");
|
|
1234
2024
|
probeOptions = (file2) => ({ cwd: os3.tmpdir(), env: copyEnv(file2), windowsHide: true, shell: false });
|
|
1235
2025
|
spawnName = (copy2, binary) => copy2 && (!copy2.entry || /\.(cmd|bat)$/i.test(copy2.file)) ? copy2.file : binary;
|
|
1236
2026
|
}
|
|
@@ -1287,21 +2077,21 @@ var init_models = __esm({
|
|
|
1287
2077
|
});
|
|
1288
2078
|
|
|
1289
2079
|
// ../cli/src/lib/agent/harnesses/types.ts
|
|
1290
|
-
import { createHash } from "node:crypto";
|
|
1291
|
-
import
|
|
1292
|
-
import
|
|
2080
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
2081
|
+
import fs11 from "node:fs";
|
|
2082
|
+
import path12 from "node:path";
|
|
1293
2083
|
function namesFlag(argv, flags) {
|
|
1294
2084
|
return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
|
|
1295
2085
|
}
|
|
1296
2086
|
function machineFile(name, text6) {
|
|
1297
|
-
const suffix =
|
|
1298
|
-
const file2 =
|
|
2087
|
+
const suffix = createHash2("sha256").update(text6).digest("hex").slice(0, 16);
|
|
2088
|
+
const file2 = path12.join(machineHome(), "prompts", `${path12.parse(name).name}-${suffix}${path12.extname(name)}`);
|
|
1299
2089
|
try {
|
|
1300
|
-
if (
|
|
2090
|
+
if (fs11.readFileSync(file2, "utf8") === text6) return file2;
|
|
1301
2091
|
} catch {
|
|
1302
2092
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
2093
|
+
fs11.mkdirSync(path12.dirname(file2), { recursive: true });
|
|
2094
|
+
fs11.writeFileSync(file2, text6);
|
|
1305
2095
|
return file2;
|
|
1306
2096
|
}
|
|
1307
2097
|
var RAW_ARGS_KEY, MODEL_KEY, RAW_ARGS, MCP_CONFIG;
|
|
@@ -1342,12 +2132,12 @@ var init_types2 = __esm({
|
|
|
1342
2132
|
});
|
|
1343
2133
|
|
|
1344
2134
|
// ../cli/src/lib/machine/settings.ts
|
|
1345
|
-
import
|
|
1346
|
-
import
|
|
2135
|
+
import fs12 from "node:fs";
|
|
2136
|
+
import path13 from "node:path";
|
|
1347
2137
|
function heldSettings() {
|
|
1348
2138
|
let text6;
|
|
1349
2139
|
try {
|
|
1350
|
-
text6 =
|
|
2140
|
+
text6 = fs12.readFileSync(settingsFile(), "utf8");
|
|
1351
2141
|
} catch (err) {
|
|
1352
2142
|
if (err.code === "ENOENT") return { unreadable: false, values: {} };
|
|
1353
2143
|
return { unreadable: true, values: {} };
|
|
@@ -1370,12 +2160,12 @@ function saveSettings(patch2) {
|
|
|
1370
2160
|
const next = { ...values, ...patch2 };
|
|
1371
2161
|
for (const [key, value] of Object.entries(patch2)) if (value === void 0) delete next[key];
|
|
1372
2162
|
try {
|
|
1373
|
-
|
|
2163
|
+
fs12.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
1374
2164
|
const file2 = settingsFile();
|
|
1375
2165
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
1376
|
-
|
|
2166
|
+
fs12.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}
|
|
1377
2167
|
`);
|
|
1378
|
-
|
|
2168
|
+
fs12.renameSync(tmp, file2);
|
|
1379
2169
|
return { ok: true };
|
|
1380
2170
|
} catch (err) {
|
|
1381
2171
|
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
@@ -1387,7 +2177,7 @@ var init_settings = __esm({
|
|
|
1387
2177
|
"use strict";
|
|
1388
2178
|
init_home();
|
|
1389
2179
|
init_types2();
|
|
1390
|
-
settingsFile = () =>
|
|
2180
|
+
settingsFile = () => path13.join(machineHome(), "settings.json");
|
|
1391
2181
|
held = () => heldSettings().values;
|
|
1392
2182
|
}
|
|
1393
2183
|
});
|
|
@@ -1821,9 +2611,9 @@ var init_antigravity = __esm({
|
|
|
1821
2611
|
});
|
|
1822
2612
|
|
|
1823
2613
|
// ../cli/src/lib/agent/harnesses/antigravity.ts
|
|
1824
|
-
import
|
|
1825
|
-
import
|
|
1826
|
-
import { createHash as
|
|
2614
|
+
import fs13 from "node:fs";
|
|
2615
|
+
import path14 from "node:path";
|
|
2616
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
1827
2617
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
1828
2618
|
function antigravityModels(output) {
|
|
1829
2619
|
return output.split("\n").flatMap((line) => {
|
|
@@ -1833,7 +2623,7 @@ function antigravityModels(output) {
|
|
|
1833
2623
|
}
|
|
1834
2624
|
function args(argv, resume) {
|
|
1835
2625
|
if (namesFlag(argv, ["--continue", "-c", "--conversation", "--remote-agent"])) throw new Error(translating() ? "\u8BF7\u901A\u8FC7 WildCrane \u9009\u62E9 Antigravity \u4F1A\u8BDD\uFF0C\u4E0D\u8981\u5728\u989D\u5916\u53C2\u6570\u4E2D\u6307\u5B9A\u4F1A\u8BDD\u6216\u8FDC\u7A0B\u6267\u884C\u3002" : "Antigravity: select a session through WildCrane, not extra arguments.");
|
|
1836
|
-
if (resume && (!/^[a-f0-9-]{36}$/i.test(resume) || !
|
|
2626
|
+
if (resume && (!/^[a-f0-9-]{36}$/i.test(resume) || !fs13.existsSync(home(".gemini", "antigravity-cli", "conversations", `${resume}.db`)))) throw new Error(translating() ? "Antigravity \u4F1A\u8BDD\u4E0D\u5B58\u5728\u3002\u8BF7\u5728\u672C\u673A\u6062\u590D\u539F\u4F1A\u8BDD\u540E\u7EED\u63A5\u3002" : "Antigravity session not found. Restore the original conversation on this computer before resuming.");
|
|
1837
2627
|
const extra = resume ? ["--conversation", resume] : [];
|
|
1838
2628
|
if (!namesFlag(argv, ["--output-format"])) extra.push("--output-format", "stream-json");
|
|
1839
2629
|
if (!namesFlag(argv, ["--dangerously-skip-permissions"])) extra.push("--dangerously-skip-permissions");
|
|
@@ -1884,11 +2674,11 @@ var init_antigravity2 = __esm({
|
|
|
1884
2674
|
const rule = `${text6}
|
|
1885
2675
|
|
|
1886
2676
|
The task working directory is ${env2.PWD ?? process.cwd()}. Use it as the base for project files and commands. This additional workspace contains only language rules; do not write task output here.`;
|
|
1887
|
-
const hash2 =
|
|
1888
|
-
const root2 =
|
|
1889
|
-
const file2 =
|
|
1890
|
-
|
|
1891
|
-
|
|
2677
|
+
const hash2 = createHash3("sha256").update(rule).digest("hex").slice(0, 16);
|
|
2678
|
+
const root2 = path14.join(machineHome(), "prompts", `antigravity-${hash2}`);
|
|
2679
|
+
const file2 = path14.join(root2, ".agents", "rules", "language.md");
|
|
2680
|
+
fs13.mkdirSync(path14.dirname(file2), { recursive: true });
|
|
2681
|
+
fs13.writeFileSync(file2, `---
|
|
1892
2682
|
trigger: always_on
|
|
1893
2683
|
---
|
|
1894
2684
|
|
|
@@ -2309,7 +3099,7 @@ var init_prices = __esm({
|
|
|
2309
3099
|
import { readFileSync as readFileSync2, readdirSync, statSync as statSync2 } from "node:fs";
|
|
2310
3100
|
import { homedir as homedir2 } from "node:os";
|
|
2311
3101
|
import { join as join2 } from "node:path";
|
|
2312
|
-
function
|
|
3102
|
+
function text2(value) {
|
|
2313
3103
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
2314
3104
|
}
|
|
2315
3105
|
function count(value) {
|
|
@@ -2407,8 +3197,8 @@ function readCodexRunFacts(threadId) {
|
|
|
2407
3197
|
} catch {
|
|
2408
3198
|
}
|
|
2409
3199
|
}
|
|
2410
|
-
if (entry.type === "session_meta") facts.provider ??=
|
|
2411
|
-
if (entry.type === "turn_context") facts.model =
|
|
3200
|
+
if (entry.type === "session_meta") facts.provider ??= text2(payload.model_provider);
|
|
3201
|
+
if (entry.type === "turn_context") facts.model = text2(payload.model) ?? facts.model;
|
|
2412
3202
|
if (payload.type === "token_count") {
|
|
2413
3203
|
facts.context = contextIn(payload.info) ?? facts.context;
|
|
2414
3204
|
const info = payload.info && typeof payload.info === "object" ? payload.info : {};
|
|
@@ -2942,7 +3732,7 @@ function createKimiStreamRenderer(cwd, resumeId) {
|
|
|
2942
3732
|
subagents.add(str2(call2.id));
|
|
2943
3733
|
events.subagent(str2(call2.id), str2(args2.description) || name);
|
|
2944
3734
|
} else {
|
|
2945
|
-
events.toolCall(str2(call2.id), name,
|
|
3735
|
+
events.toolCall(str2(call2.id), name, kindOf2(name), ARG_KEYS2.map((k2) => str2(args2[k2])).find((v) => v.trim()));
|
|
2946
3736
|
}
|
|
2947
3737
|
}
|
|
2948
3738
|
return `${said2 ? `${said2}
|
|
@@ -2991,7 +3781,7 @@ function createKimiStreamRenderer(cwd, resumeId) {
|
|
|
2991
3781
|
}
|
|
2992
3782
|
};
|
|
2993
3783
|
}
|
|
2994
|
-
var ARG_KEYS2, TOOL_KINDS3,
|
|
3784
|
+
var ARG_KEYS2, TOOL_KINDS3, kindOf2, LOOK_EVERY_MS2;
|
|
2995
3785
|
var init_kimi_stream = __esm({
|
|
2996
3786
|
"../cli/src/lib/agent/wire/kimi-stream.ts"() {
|
|
2997
3787
|
"use strict";
|
|
@@ -3008,22 +3798,22 @@ var init_kimi_stream = __esm({
|
|
|
3008
3798
|
[/bash|shell/i, "execute"],
|
|
3009
3799
|
[/write|edit|replace/i, "edit"]
|
|
3010
3800
|
];
|
|
3011
|
-
|
|
3801
|
+
kindOf2 = (name) => TOOL_KINDS3.find(([re3]) => re3.test(name))?.[1] ?? "other";
|
|
3012
3802
|
LOOK_EVERY_MS2 = 3e3;
|
|
3013
3803
|
}
|
|
3014
3804
|
});
|
|
3015
3805
|
|
|
3016
3806
|
// ../cli/src/lib/agent/wire/acp-cost.ts
|
|
3017
|
-
import
|
|
3018
|
-
import
|
|
3019
|
-
import { createHash as
|
|
3807
|
+
import fs14 from "node:fs";
|
|
3808
|
+
import path15 from "node:path";
|
|
3809
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
3020
3810
|
function acpCostFile(tool, cwd, session) {
|
|
3021
|
-
const key =
|
|
3022
|
-
return
|
|
3811
|
+
const key = createHash4("sha256").update(JSON.stringify([tool, cwd, session])).digest("hex");
|
|
3812
|
+
return path15.join(machineHome(), "usage", "acp", `${key}.json`);
|
|
3023
3813
|
}
|
|
3024
3814
|
function readAcpCost(file2) {
|
|
3025
3815
|
try {
|
|
3026
|
-
const n = JSON.parse(
|
|
3816
|
+
const n = JSON.parse(fs14.readFileSync(file2, "utf8"));
|
|
3027
3817
|
return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
3028
3818
|
} catch {
|
|
3029
3819
|
return void 0;
|
|
@@ -3032,10 +3822,10 @@ function readAcpCost(file2) {
|
|
|
3032
3822
|
function saveAcpCost(file2, cost) {
|
|
3033
3823
|
if (cost === void 0) return;
|
|
3034
3824
|
try {
|
|
3035
|
-
|
|
3825
|
+
fs14.mkdirSync(path15.dirname(file2), { recursive: true, mode: 448 });
|
|
3036
3826
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
3037
|
-
|
|
3038
|
-
|
|
3827
|
+
fs14.writeFileSync(tmp, JSON.stringify(cost), { mode: 384 });
|
|
3828
|
+
fs14.renameSync(tmp, file2);
|
|
3039
3829
|
} catch {
|
|
3040
3830
|
}
|
|
3041
3831
|
}
|
|
@@ -3214,7 +4004,7 @@ var init_package = __esm({
|
|
|
3214
4004
|
"../cli/package.json"() {
|
|
3215
4005
|
package_default = {
|
|
3216
4006
|
name: "wildcrane",
|
|
3217
|
-
version: "0.11.
|
|
4007
|
+
version: "0.11.66",
|
|
3218
4008
|
akbContract: 17,
|
|
3219
4009
|
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.",
|
|
3220
4010
|
keywords: [
|
|
@@ -3290,7 +4080,7 @@ var init_version = __esm({
|
|
|
3290
4080
|
});
|
|
3291
4081
|
|
|
3292
4082
|
// ../cli/src/lib/agent/wire/acp.ts
|
|
3293
|
-
import
|
|
4083
|
+
import fs15 from "node:fs";
|
|
3294
4084
|
function whereHint(update2, title) {
|
|
3295
4085
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
3296
4086
|
const path88 = str2(obj2(locations[0]).path);
|
|
@@ -3355,7 +4145,7 @@ function ticksUsd(value) {
|
|
|
3355
4145
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? ticks / TICKS_PER_USD : void 0;
|
|
3356
4146
|
}
|
|
3357
4147
|
function mcpServersIn(file2) {
|
|
3358
|
-
const servers = obj2(obj2(JSON.parse(
|
|
4148
|
+
const servers = obj2(obj2(JSON.parse(fs15.readFileSync(file2, "utf8"))).mcpServers);
|
|
3359
4149
|
return Object.entries(servers).map(([name, raw]) => {
|
|
3360
4150
|
const s = obj2(raw);
|
|
3361
4151
|
return {
|
|
@@ -3585,7 +4375,7 @@ var init_acp = __esm({
|
|
|
3585
4375
|
});
|
|
3586
4376
|
|
|
3587
4377
|
// ../cli/src/lib/agent/wire/zcode.ts
|
|
3588
|
-
import
|
|
4378
|
+
import path16 from "node:path";
|
|
3589
4379
|
function whereHint2(input, title) {
|
|
3590
4380
|
const named2 = obj2(input);
|
|
3591
4381
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
@@ -3736,7 +4526,7 @@ async function oneTurn2(io, options) {
|
|
|
3736
4526
|
{ stringIds: true }
|
|
3737
4527
|
);
|
|
3738
4528
|
try {
|
|
3739
|
-
const workspacePath =
|
|
4529
|
+
const workspacePath = path16.resolve(io.cwd);
|
|
3740
4530
|
const workspace2 = { workspacePath, workspaceKey: workspacePath };
|
|
3741
4531
|
let opened;
|
|
3742
4532
|
if (io.resumeId) {
|
|
@@ -3874,14 +4664,14 @@ var init_zcode = __esm({
|
|
|
3874
4664
|
});
|
|
3875
4665
|
|
|
3876
4666
|
// ../cli/src/lib/file-memo.ts
|
|
3877
|
-
import
|
|
3878
|
-
import
|
|
4667
|
+
import fs16 from "node:fs";
|
|
4668
|
+
import path17 from "node:path";
|
|
3879
4669
|
function stamp(paths) {
|
|
3880
4670
|
const parts = [];
|
|
3881
4671
|
const visit = (p2) => {
|
|
3882
4672
|
let st2;
|
|
3883
4673
|
try {
|
|
3884
|
-
st2 =
|
|
4674
|
+
st2 = fs16.statSync(p2, { bigint: true });
|
|
3885
4675
|
} catch {
|
|
3886
4676
|
parts.push(`${p2}:-`);
|
|
3887
4677
|
return;
|
|
@@ -3893,11 +4683,11 @@ function stamp(paths) {
|
|
|
3893
4683
|
parts.push(`${p2}/`);
|
|
3894
4684
|
let names3;
|
|
3895
4685
|
try {
|
|
3896
|
-
names3 =
|
|
4686
|
+
names3 = fs16.readdirSync(p2).sort();
|
|
3897
4687
|
} catch {
|
|
3898
4688
|
return;
|
|
3899
4689
|
}
|
|
3900
|
-
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(
|
|
4690
|
+
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(path17.join(p2, name));
|
|
3901
4691
|
};
|
|
3902
4692
|
for (const p2 of paths) visit(p2);
|
|
3903
4693
|
return parts.join("\n");
|
|
@@ -4007,15 +4797,15 @@ var init_types3 = __esm({
|
|
|
4007
4797
|
});
|
|
4008
4798
|
|
|
4009
4799
|
// ../cli/src/lib/agent/settings.ts
|
|
4010
|
-
import
|
|
4011
|
-
import
|
|
4800
|
+
import fs17 from "node:fs";
|
|
4801
|
+
import path18 from "node:path";
|
|
4012
4802
|
function configBlock(value) {
|
|
4013
4803
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4014
4804
|
return value;
|
|
4015
4805
|
}
|
|
4016
4806
|
function readConfigRaw() {
|
|
4017
|
-
if (!
|
|
4018
|
-
return JSON.parse(
|
|
4807
|
+
if (!fs17.existsSync(UI_CONFIG)) return {};
|
|
4808
|
+
return JSON.parse(fs17.readFileSync(UI_CONFIG, "utf8"));
|
|
4019
4809
|
}
|
|
4020
4810
|
function safeConfig() {
|
|
4021
4811
|
try {
|
|
@@ -4072,8 +4862,8 @@ function writeConfig(change2) {
|
|
|
4072
4862
|
}
|
|
4073
4863
|
change2(cfg);
|
|
4074
4864
|
try {
|
|
4075
|
-
|
|
4076
|
-
|
|
4865
|
+
fs17.mkdirSync(path18.dirname(UI_CONFIG), { recursive: true });
|
|
4866
|
+
fs17.writeFileSync(UI_CONFIG, JSON.stringify(cfg, null, 2) + "\n");
|
|
4077
4867
|
forgetFileMemos();
|
|
4078
4868
|
return { ok: true };
|
|
4079
4869
|
} catch (e2) {
|
|
@@ -4100,7 +4890,7 @@ function unquote(value) {
|
|
|
4100
4890
|
function readEnvFile() {
|
|
4101
4891
|
let text6;
|
|
4102
4892
|
try {
|
|
4103
|
-
text6 =
|
|
4893
|
+
text6 = fs17.readFileSync(ENV_FILE, "utf8");
|
|
4104
4894
|
} catch {
|
|
4105
4895
|
return {};
|
|
4106
4896
|
}
|
|
@@ -4113,15 +4903,15 @@ function readEnvFile() {
|
|
|
4113
4903
|
}
|
|
4114
4904
|
function ensureIgnored() {
|
|
4115
4905
|
try {
|
|
4116
|
-
if (!
|
|
4117
|
-
|
|
4118
|
-
|
|
4906
|
+
if (!fs17.existsSync(KANBAN_GITIGNORE)) {
|
|
4907
|
+
fs17.mkdirSync(path18.dirname(KANBAN_GITIGNORE), { recursive: true });
|
|
4908
|
+
fs17.writeFileSync(KANBAN_GITIGNORE, IGNORE_BLOCK);
|
|
4119
4909
|
return { ok: true };
|
|
4120
4910
|
}
|
|
4121
|
-
const text6 =
|
|
4911
|
+
const text6 = fs17.readFileSync(KANBAN_GITIGNORE, "utf8");
|
|
4122
4912
|
if (text6.split("\n").some((line) => line.trim() === ".env")) return { ok: true };
|
|
4123
4913
|
const separator = !text6 || text6.endsWith("\n") ? "" : "\n";
|
|
4124
|
-
|
|
4914
|
+
fs17.writeFileSync(KANBAN_GITIGNORE, `${text6}${separator}${IGNORE_BLOCK}`);
|
|
4125
4915
|
return { ok: true };
|
|
4126
4916
|
} catch (e2) {
|
|
4127
4917
|
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
@@ -4139,7 +4929,7 @@ function setSecret(name, value) {
|
|
|
4139
4929
|
if (!ignored.ok) return ignored;
|
|
4140
4930
|
let lines;
|
|
4141
4931
|
try {
|
|
4142
|
-
lines =
|
|
4932
|
+
lines = fs17.existsSync(ENV_FILE) ? fs17.readFileSync(ENV_FILE, "utf8").split("\n") : [];
|
|
4143
4933
|
} catch (e2) {
|
|
4144
4934
|
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
4145
4935
|
return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
|
|
@@ -4162,7 +4952,7 @@ function setSecret(name, value) {
|
|
|
4162
4952
|
if (next && !written) text6 += `${name}=${next}
|
|
4163
4953
|
`;
|
|
4164
4954
|
try {
|
|
4165
|
-
|
|
4955
|
+
fs17.writeFileSync(ENV_FILE, text6, { mode: 384 });
|
|
4166
4956
|
return { ok: true };
|
|
4167
4957
|
} catch (e2) {
|
|
4168
4958
|
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
@@ -4957,22 +5747,22 @@ var init_transient = __esm({
|
|
|
4957
5747
|
});
|
|
4958
5748
|
|
|
4959
5749
|
// ../cli/src/lib/agent/harnesses/claude-code.ts
|
|
4960
|
-
import
|
|
5750
|
+
import path19 from "node:path";
|
|
4961
5751
|
function claudeStreamArgs(argv) {
|
|
4962
5752
|
if (argv.includes("--output-format")) return [];
|
|
4963
5753
|
return ["--output-format", "stream-json", "--verbose", ...argv.includes("--input-format") ? [] : ["--input-format", "stream-json"]];
|
|
4964
5754
|
}
|
|
4965
5755
|
function claudeOnWindows() {
|
|
4966
5756
|
const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
|
|
4967
|
-
const packages = local ?
|
|
5757
|
+
const packages = local ? path19.join(local, "Packages") : "";
|
|
4968
5758
|
const data = [
|
|
4969
|
-
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) =>
|
|
4970
|
-
...roaming ? [
|
|
5759
|
+
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path19.join(packages, name, "LocalCache", "Roaming", "Claude")),
|
|
5760
|
+
...roaming ? [path19.join(roaming, "Claude")] : []
|
|
4971
5761
|
];
|
|
4972
5762
|
return data.flatMap(
|
|
4973
|
-
(dir) => latestIn(
|
|
4974
|
-
|
|
4975
|
-
...folders(version).map((build) =>
|
|
5763
|
+
(dir) => latestIn(path19.join(dir, "claude-code")).flatMap((version) => [
|
|
5764
|
+
path19.join(version, "claude.exe"),
|
|
5765
|
+
...folders(version).map((build) => path19.join(version, build, "claude.exe"))
|
|
4976
5766
|
])
|
|
4977
5767
|
);
|
|
4978
5768
|
}
|
|
@@ -5242,7 +6032,7 @@ var init_claude_code = __esm({
|
|
|
5242
6032
|
...latestIn(home(".local", "share", "claude", "versions")),
|
|
5243
6033
|
// The copy Claude Desktop carries.
|
|
5244
6034
|
...process.platform === "win32" ? claudeOnWindows() : latestIn(home("Library", "Application Support", "Claude", "claude-code")).flatMap(
|
|
5245
|
-
(version) => folders(version).map((build) =>
|
|
6035
|
+
(version) => folders(version).map((build) => path19.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
|
|
5246
6036
|
)
|
|
5247
6037
|
],
|
|
5248
6038
|
install: "npm install -g @anthropic-ai/claude-code"
|
|
@@ -5252,8 +6042,8 @@ var init_claude_code = __esm({
|
|
|
5252
6042
|
|
|
5253
6043
|
// ../cli/src/lib/agent/worktree.ts
|
|
5254
6044
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
5255
|
-
import
|
|
5256
|
-
import
|
|
6045
|
+
import fs18 from "node:fs";
|
|
6046
|
+
import path20 from "node:path";
|
|
5257
6047
|
function spawnGit(args2, options) {
|
|
5258
6048
|
const out = spawnSync4("git", args2, {
|
|
5259
6049
|
...options,
|
|
@@ -5288,15 +6078,15 @@ var init_worktree = __esm({
|
|
|
5288
6078
|
gitLimits = { timeoutMs: 3e4 };
|
|
5289
6079
|
GitTimeoutError = class extends Error {
|
|
5290
6080
|
};
|
|
5291
|
-
worktreeDir = (relPath) =>
|
|
6081
|
+
worktreeDir = (relPath) => path20.resolve(REPO_ROOT, relPath);
|
|
5292
6082
|
headCommit = (cwd = REPO_ROOT) => git(["rev-parse", "HEAD"], cwd)?.trim() || null;
|
|
5293
|
-
worktreeExists = (relPath) => !!relPath &&
|
|
6083
|
+
worktreeExists = (relPath) => !!relPath && fs18.existsSync(path20.join(worktreeDir(relPath), ".git"));
|
|
5294
6084
|
}
|
|
5295
6085
|
});
|
|
5296
6086
|
|
|
5297
6087
|
// ../cli/src/lib/agent/harnesses/codex.ts
|
|
5298
|
-
import
|
|
5299
|
-
import
|
|
6088
|
+
import fs19 from "node:fs";
|
|
6089
|
+
import path21 from "node:path";
|
|
5300
6090
|
function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
5301
6091
|
const extra = [];
|
|
5302
6092
|
if (!namesFlag(argv, ["--json", "--experimental-json"])) extra.push("--json");
|
|
@@ -5312,10 +6102,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
|
5312
6102
|
}
|
|
5313
6103
|
const flags = [...argv, ...extra];
|
|
5314
6104
|
const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
|
|
5315
|
-
if (workspaceWrite &&
|
|
6105
|
+
if (workspaceWrite && path21.resolve(cwd) !== path21.resolve(REPO_ROOT)) {
|
|
5316
6106
|
for (const dir of [KANBAN, AKB_DIR]) {
|
|
5317
|
-
const relative =
|
|
5318
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
6107
|
+
const relative = path21.relative(cwd, dir);
|
|
6108
|
+
if (relative === ".." || relative.startsWith(`..${path21.sep}`) || path21.isAbsolute(relative)) {
|
|
5319
6109
|
extra.push("--add-dir", dir);
|
|
5320
6110
|
}
|
|
5321
6111
|
}
|
|
@@ -5338,7 +6128,7 @@ function envRoot(name) {
|
|
|
5338
6128
|
}
|
|
5339
6129
|
function modified(file2) {
|
|
5340
6130
|
try {
|
|
5341
|
-
return
|
|
6131
|
+
return fs19.statSync(file2).mtimeMs;
|
|
5342
6132
|
} catch {
|
|
5343
6133
|
return 0;
|
|
5344
6134
|
}
|
|
@@ -5363,28 +6153,28 @@ function codexOnWindows() {
|
|
|
5363
6153
|
const local = envRoot("LOCALAPPDATA");
|
|
5364
6154
|
const profile = envRoot("USERPROFILE");
|
|
5365
6155
|
const programs = envRoot("ProgramFiles");
|
|
5366
|
-
const cache = local ?
|
|
5367
|
-
const releases = profile ?
|
|
5368
|
-
const packages = programs ?
|
|
6156
|
+
const cache = local ? path21.join(local, "OpenAI", "Codex", "bin") : "";
|
|
6157
|
+
const releases = profile ? path21.join(profile, ".codex", "packages", "standalone", "releases") : "";
|
|
6158
|
+
const packages = programs ? path21.join(programs, "WindowsApps") : "";
|
|
5369
6159
|
return [
|
|
5370
6160
|
// Desktop's relocated CLI cache: a folder per build hash, newest file first.
|
|
5371
|
-
...byNewest(folders(cache).map((name) =>
|
|
6161
|
+
...byNewest(folders(cache).map((name) => path21.join(cache, name, "codex.exe"))),
|
|
5372
6162
|
// The separate standalone launcher, at a path with nothing variable in it.
|
|
5373
|
-
...local ? [
|
|
6163
|
+
...local ? [path21.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
|
|
5374
6164
|
// That launcher's release payload: a folder per version and target.
|
|
5375
6165
|
...byVersion(folders(releases).filter(ourArch)).map(
|
|
5376
|
-
(name) =>
|
|
6166
|
+
(name) => path21.join(releases, name, "bin", "codex.exe")
|
|
5377
6167
|
),
|
|
5378
6168
|
// Desktop's own MSIX package.
|
|
5379
6169
|
...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
|
|
5380
|
-
(name) =>
|
|
6170
|
+
(name) => path21.join(packages, name, "app", "resources", "codex.exe")
|
|
5381
6171
|
)
|
|
5382
6172
|
];
|
|
5383
6173
|
}
|
|
5384
6174
|
function codexInstalls() {
|
|
5385
6175
|
const chosen = process.env.CODEX_INSTALL_DIR?.trim();
|
|
5386
6176
|
return [
|
|
5387
|
-
...chosen ? [
|
|
6177
|
+
...chosen ? [path21.join(chosen, "codex")] : [],
|
|
5388
6178
|
...process.platform === "win32" ? codexOnWindows() : [
|
|
5389
6179
|
// macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
|
|
5390
6180
|
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
|
|
@@ -5443,7 +6233,7 @@ var init_codex2 = __esm({
|
|
|
5443
6233
|
systemPrompt(text6, argv) {
|
|
5444
6234
|
if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
|
|
5445
6235
|
try {
|
|
5446
|
-
const config =
|
|
6236
|
+
const config = fs19.readFileSync(path21.join(process.env.CODEX_HOME || home(".codex"), "config.toml"), "utf8");
|
|
5447
6237
|
if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
|
|
5448
6238
|
} catch {
|
|
5449
6239
|
}
|
|
@@ -5696,24 +6486,24 @@ var init_cursor = __esm({
|
|
|
5696
6486
|
});
|
|
5697
6487
|
|
|
5698
6488
|
// ../cli/src/lib/agent/harnesses/dsh.ts
|
|
5699
|
-
import
|
|
5700
|
-
import
|
|
6489
|
+
import fs20 from "node:fs";
|
|
6490
|
+
import path22 from "node:path";
|
|
5701
6491
|
function dshHome(argv) {
|
|
5702
6492
|
const binary = argv[0];
|
|
5703
6493
|
if (!binary) return void 0;
|
|
5704
|
-
const names3 = process.platform === "win32" && !
|
|
5705
|
-
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(
|
|
6494
|
+
const names3 = process.platform === "win32" && !path22.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
|
|
6495
|
+
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(path22.delimiter).filter(Boolean).flatMap((dir2) => names3.map((name) => path22.join(dir2, name)));
|
|
5706
6496
|
let dir;
|
|
5707
6497
|
try {
|
|
5708
|
-
const found2 = candidates.find((candidate) =>
|
|
6498
|
+
const found2 = candidates.find((candidate) => fs20.existsSync(candidate));
|
|
5709
6499
|
if (!found2) return void 0;
|
|
5710
|
-
const script = /\.cmd$/i.test(found2) ? shimTarget(
|
|
5711
|
-
dir =
|
|
6500
|
+
const script = /\.cmd$/i.test(found2) ? shimTarget(fs20.readFileSync(found2, "utf8"), found2)?.script : void 0;
|
|
6501
|
+
dir = path22.dirname(fs20.realpathSync(script ?? found2));
|
|
5712
6502
|
} catch {
|
|
5713
6503
|
return void 0;
|
|
5714
6504
|
}
|
|
5715
|
-
for (let up =
|
|
5716
|
-
if (
|
|
6505
|
+
for (let up = path22.dirname(dir); dir !== up; up = path22.dirname(dir)) {
|
|
6506
|
+
if (fs20.existsSync(path22.join(dir, "package.json"))) return dir;
|
|
5717
6507
|
dir = up;
|
|
5718
6508
|
}
|
|
5719
6509
|
return void 0;
|
|
@@ -5721,7 +6511,7 @@ function dshHome(argv) {
|
|
|
5721
6511
|
function dshFound(binary, onPath2) {
|
|
5722
6512
|
const home3 = dshHome([binary]);
|
|
5723
6513
|
const exts = process.platform === "win32" ? [".cmd", ".exe"] : [""];
|
|
5724
|
-
return !!home3 && exts.some((ext) =>
|
|
6514
|
+
return !!home3 && exts.some((ext) => fs20.existsSync(path22.join(home3, "node_modules", ".bin", `dsh${ext}`))) || onPath2("dsh");
|
|
5725
6515
|
}
|
|
5726
6516
|
function dshExtraArgs(argv) {
|
|
5727
6517
|
const args2 = namesFlag(argv, ["--permission-mode"]) ? [] : ["--permission-mode", "workspace-write"];
|
|
@@ -6441,7 +7231,7 @@ var init_providers = __esm({
|
|
|
6441
7231
|
});
|
|
6442
7232
|
|
|
6443
7233
|
// ../cli/src/lib/agent/run-settings.ts
|
|
6444
|
-
import
|
|
7234
|
+
import path23 from "node:path";
|
|
6445
7235
|
function isFilled(harness, { values, secretsSet }) {
|
|
6446
7236
|
return (key) => {
|
|
6447
7237
|
const setting = harness.settings.find((s) => s.key === key);
|
|
@@ -6521,7 +7311,7 @@ function languageEnv(given) {
|
|
|
6521
7311
|
try {
|
|
6522
7312
|
const config = JSON.parse(env2.OPENCODE_CONFIG_CONTENT ?? "{}");
|
|
6523
7313
|
if (Array.isArray(config.instructions)) {
|
|
6524
|
-
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" ||
|
|
7314
|
+
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" || path23.dirname(file2) !== path23.join(machineHome(), "prompts") || !/^opencode-language(?:-[a-f0-9]{16})?\.md$/.test(path23.basename(file2)));
|
|
6525
7315
|
env2.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
|
|
6526
7316
|
}
|
|
6527
7317
|
} catch {
|
|
@@ -6537,7 +7327,7 @@ function withSystemLanguage(harness, argv, env2, language) {
|
|
|
6537
7327
|
const note = language === "zh" ? "\u8BED\u8A00\u89C4\u5219\u672A\u80FD\u66F4\u65B0\uFF1A\u8FDE\u63A5\u5668\u3001\u5DF2\u6709\u4F1A\u8BDD\u6216\u81EA\u8BBE\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4E0D\u652F\u6301\u6CE8\u5165\u3002\u8BF7\u81EA\u884C\u53E6\u5F00\u652F\u6301\u7684\u4F1A\u8BDD\u4EE5\u91C7\u7528\u65B0\u89C4\u5219\u3002" : "Language rules could not be updated: the connector, existing session, or custom system prompt prevents injection. Open a supported new session to apply them.";
|
|
6538
7328
|
return { argv, env: env2, note };
|
|
6539
7329
|
}
|
|
6540
|
-
const at2 = /^node(?:\.exe)?$/.test(
|
|
7330
|
+
const at2 = /^node(?:\.exe)?$/.test(path23.basename(argv[0])) && argv[1] && !argv[1].startsWith("-") ? 2 : 1;
|
|
6541
7331
|
return { argv: [...argv.slice(0, at2), ...added?.args ?? [], ...argv.slice(at2)], env: { ...env2, ...added?.env } };
|
|
6542
7332
|
}
|
|
6543
7333
|
var init_run_settings = __esm({
|
|
@@ -6553,223 +7343,6 @@ var init_run_settings = __esm({
|
|
|
6553
7343
|
}
|
|
6554
7344
|
});
|
|
6555
7345
|
|
|
6556
|
-
// ../cli/src/lib/cloud/config.ts
|
|
6557
|
-
function cloudEndpoints() {
|
|
6558
|
-
return {
|
|
6559
|
-
supabaseUrl: trimSlash(process.env.AI4KANBAN_SUPABASE_URL || SUPABASE_URL),
|
|
6560
|
-
anonKey: process.env.AI4KANBAN_SUPABASE_ANON_KEY || SUPABASE_ANON_KEY,
|
|
6561
|
-
api: trimSlash(process.env.AI4KANBAN_CLOUD_URL || API_URL)
|
|
6562
|
-
};
|
|
6563
|
-
}
|
|
6564
|
-
function cloudConfigured() {
|
|
6565
|
-
const { supabaseUrl, anonKey } = cloudEndpoints();
|
|
6566
|
-
return !!supabaseUrl && !!anonKey;
|
|
6567
|
-
}
|
|
6568
|
-
var SUPABASE_URL, SUPABASE_ANON_KEY, API_URL, trimSlash, NOT_CONFIGURED;
|
|
6569
|
-
var init_config = __esm({
|
|
6570
|
-
"../cli/src/lib/cloud/config.ts"() {
|
|
6571
|
-
"use strict";
|
|
6572
|
-
SUPABASE_URL = "https://yajrbpprmdvtkvjjfpbk.supabase.co";
|
|
6573
|
-
SUPABASE_ANON_KEY = "sb_publishable_ioUQ23BTtoj8NKqndp0Jrw_omVR3m4n";
|
|
6574
|
-
API_URL = "https://api.ai4kanban.dev";
|
|
6575
|
-
trimSlash = (url) => url.replace(/\/+$/, "");
|
|
6576
|
-
NOT_CONFIGURED = "This build of WildCrane carries no Cloud project to sign in against.";
|
|
6577
|
-
}
|
|
6578
|
-
});
|
|
6579
|
-
|
|
6580
|
-
// ../cli/src/lib/cloud/session.ts
|
|
6581
|
-
import fs19 from "node:fs";
|
|
6582
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
6583
|
-
import path22 from "node:path";
|
|
6584
|
-
function readRetry(session) {
|
|
6585
|
-
try {
|
|
6586
|
-
const retry2 = JSON.parse(fs19.readFileSync(retryFile(), "utf8"));
|
|
6587
|
-
if (retry2.key === refreshKey(session) && Number.isFinite(retry2.until) && Number.isInteger(retry2.attempt) && retry2.attempt > 0 && typeof retry2.error === "string") return retry2;
|
|
6588
|
-
} catch {
|
|
6589
|
-
}
|
|
6590
|
-
}
|
|
6591
|
-
function deferRefresh(session, error, after2) {
|
|
6592
|
-
const current = readSession();
|
|
6593
|
-
if (current?.subject === session.subject && current.refreshToken === session.refreshToken) {
|
|
6594
|
-
const attempt2 = Math.min((readRetry(session)?.attempt ?? 0) + 1, 4);
|
|
6595
|
-
const seconds = after2?.trim() ? Number(after2) : NaN;
|
|
6596
|
-
const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after2 ?? "") - Date.now();
|
|
6597
|
-
const delay2 = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt2 - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
|
|
6598
|
-
const retry2 = { key: refreshKey(session), until: Date.now() + delay2, attempt: attempt2, error };
|
|
6599
|
-
const temporary = `${retryFile()}.${process.pid}.tmp`;
|
|
6600
|
-
fs19.writeFileSync(temporary, JSON.stringify(retry2), { mode: 384 });
|
|
6601
|
-
fs19.renameSync(temporary, retryFile());
|
|
6602
|
-
}
|
|
6603
|
-
return { ok: false, reason: "unreachable", error };
|
|
6604
|
-
}
|
|
6605
|
-
function readSession() {
|
|
6606
|
-
let raw;
|
|
6607
|
-
try {
|
|
6608
|
-
raw = fs19.readFileSync(sessionFile(), "utf8");
|
|
6609
|
-
} catch {
|
|
6610
|
-
return null;
|
|
6611
|
-
}
|
|
6612
|
-
try {
|
|
6613
|
-
const held4 = JSON.parse(raw);
|
|
6614
|
-
if (!held4.accessToken || !held4.refreshToken || !held4.subject) return null;
|
|
6615
|
-
if (held4.supabaseUrl !== cloudEndpoints().supabaseUrl) return null;
|
|
6616
|
-
return { ...held4, version: 1, expiresAt: Number(held4.expiresAt) || 0 };
|
|
6617
|
-
} catch {
|
|
6618
|
-
return null;
|
|
6619
|
-
}
|
|
6620
|
-
}
|
|
6621
|
-
function writeSession(session) {
|
|
6622
|
-
fs19.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
6623
|
-
const tmp = `${sessionFile()}.${process.pid}.tmp`;
|
|
6624
|
-
fs19.writeFileSync(tmp, `${JSON.stringify(session, null, 2)}
|
|
6625
|
-
`, { mode: 384 });
|
|
6626
|
-
fs19.renameSync(tmp, sessionFile());
|
|
6627
|
-
if (!expiringSoon(session) || !readRetry(session)) fs19.rmSync(retryFile(), { force: true });
|
|
6628
|
-
}
|
|
6629
|
-
function clearSession() {
|
|
6630
|
-
try {
|
|
6631
|
-
fs19.rmSync(sessionFile());
|
|
6632
|
-
fs19.rmSync(retryFile(), { force: true });
|
|
6633
|
-
} catch {
|
|
6634
|
-
}
|
|
6635
|
-
}
|
|
6636
|
-
async function accessToken() {
|
|
6637
|
-
const held4 = readSession();
|
|
6638
|
-
if (!held4) return { ok: false, reason: "signed-out" };
|
|
6639
|
-
if (!expiringSoon(held4)) return { ok: true, token: held4.accessToken, session: held4 };
|
|
6640
|
-
return refresh();
|
|
6641
|
-
}
|
|
6642
|
-
async function refresh() {
|
|
6643
|
-
const lock = await takeLock();
|
|
6644
|
-
if (!lock) return { ok: false, reason: "unreachable", error: "Cloud sign-in refresh is busy. Try again shortly." };
|
|
6645
|
-
try {
|
|
6646
|
-
const now = readSession();
|
|
6647
|
-
if (!now) return { ok: false, reason: "signed-out" };
|
|
6648
|
-
if (!expiringSoon(now)) return { ok: true, token: now.accessToken, session: now };
|
|
6649
|
-
const retry2 = readRetry(now);
|
|
6650
|
-
if (retry2 && retry2.until > Date.now()) return { ok: false, reason: "unreachable", error: retry2.error };
|
|
6651
|
-
const { api, anonKey } = cloudEndpoints();
|
|
6652
|
-
let response;
|
|
6653
|
-
try {
|
|
6654
|
-
response = await fetch(`${api}/auth/v1/token?grant_type=refresh_token`, {
|
|
6655
|
-
method: "POST",
|
|
6656
|
-
headers: { apikey: anonKey, "content-type": "application/json" },
|
|
6657
|
-
body: JSON.stringify({ refresh_token: now.refreshToken }),
|
|
6658
|
-
signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS)
|
|
6659
|
-
});
|
|
6660
|
-
} catch (e2) {
|
|
6661
|
-
return deferRefresh(now, e2 instanceof Error ? e2.message : String(e2));
|
|
6662
|
-
}
|
|
6663
|
-
if (!response.ok) {
|
|
6664
|
-
const body = await response.json().catch(() => null);
|
|
6665
|
-
const error = body?.error_description ?? body?.msg ?? body?.message;
|
|
6666
|
-
if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error ?? `Cloud answered ${response.status}`, response.headers.get("retry-after"));
|
|
6667
|
-
return { ok: false, reason: "expired", error };
|
|
6668
|
-
}
|
|
6669
|
-
const fresh = sessionFrom(await response.json().catch(() => null), now);
|
|
6670
|
-
if (!fresh) return deferRefresh(now, "Cloud returned an invalid sign-in refresh response.");
|
|
6671
|
-
const current = readSession();
|
|
6672
|
-
if (!current || current.subject !== now.subject) return { ok: false, reason: "expired" };
|
|
6673
|
-
if (current.refreshToken !== now.refreshToken) return { ok: true, token: current.accessToken, session: current };
|
|
6674
|
-
writeSession(fresh);
|
|
6675
|
-
return { ok: true, token: fresh.accessToken, session: fresh };
|
|
6676
|
-
} finally {
|
|
6677
|
-
lock();
|
|
6678
|
-
}
|
|
6679
|
-
}
|
|
6680
|
-
function sessionFrom(body, previous) {
|
|
6681
|
-
if (!body || typeof body !== "object") return null;
|
|
6682
|
-
const token2 = body;
|
|
6683
|
-
const subject = token2.user?.id ?? previous?.subject;
|
|
6684
|
-
if (!token2.access_token || !token2.refresh_token || !subject) return null;
|
|
6685
|
-
const expiresAt = token2.expires_at ? token2.expires_at * 1e3 : Date.now() + (token2.expires_in ?? 3600) * 1e3;
|
|
6686
|
-
return {
|
|
6687
|
-
version: 1,
|
|
6688
|
-
supabaseUrl: cloudEndpoints().supabaseUrl,
|
|
6689
|
-
accessToken: token2.access_token,
|
|
6690
|
-
refreshToken: token2.refresh_token,
|
|
6691
|
-
expiresAt,
|
|
6692
|
-
subject,
|
|
6693
|
-
email: token2.user?.email ?? previous?.email,
|
|
6694
|
-
handle: previous?.handle,
|
|
6695
|
-
name: previous?.name,
|
|
6696
|
-
avatarUrl: previous?.avatarUrl,
|
|
6697
|
-
avatar: previous?.avatar
|
|
6698
|
-
};
|
|
6699
|
-
}
|
|
6700
|
-
async function takeLock() {
|
|
6701
|
-
const until = Date.now() + LOCK_WAIT_MS;
|
|
6702
|
-
for (; ; ) {
|
|
6703
|
-
try {
|
|
6704
|
-
fs19.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
6705
|
-
fs19.mkdirSync(lockDir());
|
|
6706
|
-
try {
|
|
6707
|
-
fs19.writeFileSync(lockOwner(), `${process.pid}
|
|
6708
|
-
`);
|
|
6709
|
-
} catch {
|
|
6710
|
-
}
|
|
6711
|
-
return () => {
|
|
6712
|
-
try {
|
|
6713
|
-
fs19.rmSync(lockDir(), { recursive: true, force: true });
|
|
6714
|
-
} catch {
|
|
6715
|
-
}
|
|
6716
|
-
};
|
|
6717
|
-
} catch (err) {
|
|
6718
|
-
if (err.code !== "EEXIST") throw err;
|
|
6719
|
-
if (stale()) {
|
|
6720
|
-
fs19.rmSync(lockDir(), { recursive: true, force: true });
|
|
6721
|
-
continue;
|
|
6722
|
-
}
|
|
6723
|
-
if (Date.now() > until) return null;
|
|
6724
|
-
await sleep2(LOCK_RETRY_MS);
|
|
6725
|
-
}
|
|
6726
|
-
}
|
|
6727
|
-
}
|
|
6728
|
-
function stale() {
|
|
6729
|
-
let held4;
|
|
6730
|
-
try {
|
|
6731
|
-
const pid = Number(fs19.readFileSync(lockOwner(), "utf8").trim());
|
|
6732
|
-
held4 = Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
6733
|
-
} catch {
|
|
6734
|
-
held4 = void 0;
|
|
6735
|
-
}
|
|
6736
|
-
if (held4 !== void 0) return !alive(held4);
|
|
6737
|
-
try {
|
|
6738
|
-
return Date.now() - fs19.statSync(lockDir()).mtimeMs > LOCK_STALE_MS;
|
|
6739
|
-
} catch {
|
|
6740
|
-
return false;
|
|
6741
|
-
}
|
|
6742
|
-
}
|
|
6743
|
-
function alive(pid) {
|
|
6744
|
-
try {
|
|
6745
|
-
process.kill(pid, 0);
|
|
6746
|
-
return true;
|
|
6747
|
-
} catch (e2) {
|
|
6748
|
-
return e2.code === "EPERM";
|
|
6749
|
-
}
|
|
6750
|
-
}
|
|
6751
|
-
var REFRESH_MARGIN_MS, LOCK_STALE_MS, LOCK_WAIT_MS, LOCK_RETRY_MS, REFRESH_TIMEOUT_MS, REFRESH_BACKOFF_MS, sessionFile, lockDir, lockOwner, retryFile, refreshKey, expiringSoon, sleep2;
|
|
6752
|
-
var init_session = __esm({
|
|
6753
|
-
"../cli/src/lib/cloud/session.ts"() {
|
|
6754
|
-
"use strict";
|
|
6755
|
-
init_home();
|
|
6756
|
-
init_config();
|
|
6757
|
-
REFRESH_MARGIN_MS = 6e4;
|
|
6758
|
-
LOCK_STALE_MS = 3e4;
|
|
6759
|
-
LOCK_WAIT_MS = 2e4;
|
|
6760
|
-
LOCK_RETRY_MS = 50;
|
|
6761
|
-
REFRESH_TIMEOUT_MS = 15e3;
|
|
6762
|
-
REFRESH_BACKOFF_MS = 6e4;
|
|
6763
|
-
sessionFile = () => path22.join(machineHome(), "session.json");
|
|
6764
|
-
lockDir = () => path22.join(machineHome(), "session.lock");
|
|
6765
|
-
lockOwner = () => path22.join(lockDir(), "owner");
|
|
6766
|
-
retryFile = () => path22.join(machineHome(), "session-refresh.json");
|
|
6767
|
-
refreshKey = (session) => createHash4("sha256").update(JSON.stringify([cloudEndpoints().api, session.subject, session.refreshToken])).digest("hex");
|
|
6768
|
-
expiringSoon = (session) => session.expiresAt - REFRESH_MARGIN_MS <= Date.now();
|
|
6769
|
-
sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
6770
|
-
}
|
|
6771
|
-
});
|
|
6772
|
-
|
|
6773
7346
|
// ../cli/src/lib/cloud/execution.ts
|
|
6774
7347
|
function executionOf(value = process.env.AI4KANBAN_EXECUTION) {
|
|
6775
7348
|
try {
|
|
@@ -6808,20 +7381,20 @@ var init_execution = __esm({
|
|
|
6808
7381
|
});
|
|
6809
7382
|
|
|
6810
7383
|
// ../cli/src/lib/agent/log.ts
|
|
6811
|
-
import
|
|
6812
|
-
import
|
|
7384
|
+
import fs21 from "node:fs";
|
|
7385
|
+
import path24 from "node:path";
|
|
6813
7386
|
function pruneLogs() {
|
|
6814
7387
|
try {
|
|
6815
|
-
const runs =
|
|
7388
|
+
const runs = fs21.readdirSync(SESSIONS_DIR).filter((f2) => f2.endsWith(".log") && !f2.endsWith(".watch.log")).map((f2) => ({ id: f2.slice(0, -".log".length), t: fs21.statSync(path24.join(SESSIONS_DIR, f2)).mtimeMs })).sort((a2, b2) => b2.t - a2.t);
|
|
6816
7389
|
const kept2 = new Set(runs.slice(0, KEEP_LOGS).map((r2) => r2.id));
|
|
6817
7390
|
const drop = new Set(runs.slice(KEEP_LOGS).map((r2) => r2.id));
|
|
6818
|
-
for (const f2 of
|
|
7391
|
+
for (const f2 of fs21.readdirSync(SESSIONS_DIR)) {
|
|
6819
7392
|
const dot = f2.indexOf(".");
|
|
6820
7393
|
const id = dot === -1 ? f2 : f2.slice(0, dot);
|
|
6821
7394
|
const stray = f2.endsWith(".images") && !kept2.has(id) && !drop.has(id) && stale2(f2);
|
|
6822
7395
|
if (!stray && !drop.has(id)) continue;
|
|
6823
7396
|
try {
|
|
6824
|
-
|
|
7397
|
+
fs21.rmSync(path24.join(SESSIONS_DIR, f2), { recursive: true, force: true });
|
|
6825
7398
|
} catch {
|
|
6826
7399
|
}
|
|
6827
7400
|
}
|
|
@@ -6830,7 +7403,7 @@ function pruneLogs() {
|
|
|
6830
7403
|
}
|
|
6831
7404
|
function stale2(name) {
|
|
6832
7405
|
try {
|
|
6833
|
-
return Date.now() -
|
|
7406
|
+
return Date.now() - fs21.statSync(path24.join(SESSIONS_DIR, name)).mtimeMs > STRAY_MS;
|
|
6834
7407
|
} catch {
|
|
6835
7408
|
return false;
|
|
6836
7409
|
}
|
|
@@ -6857,13 +7430,13 @@ function asContext(v) {
|
|
|
6857
7430
|
function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
6858
7431
|
let fd;
|
|
6859
7432
|
try {
|
|
6860
|
-
const size =
|
|
7433
|
+
const size = fs21.statSync(logPath).size;
|
|
6861
7434
|
const start = Math.max(0, size - maxBytes);
|
|
6862
7435
|
const len = size - start;
|
|
6863
7436
|
if (len === 0) return "";
|
|
6864
|
-
fd =
|
|
7437
|
+
fd = fs21.openSync(logPath, "r");
|
|
6865
7438
|
const buf = Buffer.alloc(len);
|
|
6866
|
-
|
|
7439
|
+
fs21.readSync(fd, buf, 0, len, start);
|
|
6867
7440
|
let text6 = buf.toString("utf8");
|
|
6868
7441
|
if (start > 0) {
|
|
6869
7442
|
const nl2 = text6.indexOf("\n");
|
|
@@ -6875,7 +7448,7 @@ function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
|
6875
7448
|
} finally {
|
|
6876
7449
|
if (fd !== void 0) {
|
|
6877
7450
|
try {
|
|
6878
|
-
|
|
7451
|
+
fs21.closeSync(fd);
|
|
6879
7452
|
} catch {
|
|
6880
7453
|
}
|
|
6881
7454
|
}
|
|
@@ -6986,15 +7559,15 @@ __export(store_exports, {
|
|
|
6986
7559
|
withRuns: () => withRuns,
|
|
6987
7560
|
withStore: () => withStore
|
|
6988
7561
|
});
|
|
6989
|
-
import
|
|
6990
|
-
import
|
|
7562
|
+
import fs22 from "node:fs";
|
|
7563
|
+
import path25 from "node:path";
|
|
6991
7564
|
function logPathIn(held4, sessionId) {
|
|
6992
|
-
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR +
|
|
7565
|
+
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR + path25.sep) ? held4 : logPathOf(sessionId);
|
|
6993
7566
|
}
|
|
6994
7567
|
function parseStore() {
|
|
6995
7568
|
let data;
|
|
6996
7569
|
try {
|
|
6997
|
-
data = JSON.parse(
|
|
7570
|
+
data = JSON.parse(fs22.readFileSync(SESSIONS, "utf8"));
|
|
6998
7571
|
} catch {
|
|
6999
7572
|
return { runs: [], deliveries: [], marks: {} };
|
|
7000
7573
|
}
|
|
@@ -7160,7 +7733,7 @@ function readDeliveryRow(raw) {
|
|
|
7160
7733
|
cloudExecution: executionOf(entry.cloudExecution ?? null),
|
|
7161
7734
|
approved: typeof entry.approved === "string" ? entry.approved : "",
|
|
7162
7735
|
// The plan a card-less build was started from (#481), where it was one.
|
|
7163
|
-
plan:
|
|
7736
|
+
plan: text3(entry.plan),
|
|
7164
7737
|
initialQuestions: typeof entry.initialQuestions === "number" && entry.initialQuestions >= 0 ? Math.floor(entry.initialQuestions) : void 0,
|
|
7165
7738
|
steps: readSteps(entry.steps),
|
|
7166
7739
|
completions: Array.isArray(entry.completions) ? entry.completions.filter((c2) => c2 && typeof c2.sessionId === "string" && Number.isInteger(c2.step) && typeof c2.at === "number") : void 0,
|
|
@@ -7173,10 +7746,10 @@ function readDeliveryRow(raw) {
|
|
|
7173
7746
|
commitMode: entry.commitMode === "auto" || entry.commitMode === "manual" || entry.commitMode === "files" ? entry.commitMode : void 0,
|
|
7174
7747
|
touched: readTouched(entry.touched),
|
|
7175
7748
|
planned: Array.isArray(entry.planned) ? entry.planned.filter((t) => typeof t === "string") : void 0,
|
|
7176
|
-
manualWhy:
|
|
7177
|
-
targetBranch:
|
|
7178
|
-
worktree:
|
|
7179
|
-
branch:
|
|
7749
|
+
manualWhy: text3(entry.manualWhy),
|
|
7750
|
+
targetBranch: text3(entry.targetBranch),
|
|
7751
|
+
worktree: text3(entry.worktree),
|
|
7752
|
+
branch: text3(entry.branch),
|
|
7180
7753
|
reviewed: readReviewed(entry.reviewed),
|
|
7181
7754
|
landing: readLanding(entry.landing),
|
|
7182
7755
|
// The flow rules this delivery froze (#306). A delivery written down before they
|
|
@@ -7191,16 +7764,16 @@ function readDeliveryRow(raw) {
|
|
|
7191
7764
|
function readStudio(raw) {
|
|
7192
7765
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
7193
7766
|
const box2 = raw;
|
|
7194
|
-
const id =
|
|
7767
|
+
const id = text3(box2.id);
|
|
7195
7768
|
if (!id) return void 0;
|
|
7196
7769
|
const rows = (value) => (Array.isArray(value) ? value : []).flatMap((one) => {
|
|
7197
7770
|
if (!one || typeof one !== "object" || Array.isArray(one)) return [];
|
|
7198
7771
|
const row = one;
|
|
7199
|
-
const agent =
|
|
7772
|
+
const agent = text3(row.agent);
|
|
7200
7773
|
return agent ? [{ agent, extra: typeof row.extra === "string" ? row.extra : "" }] : [];
|
|
7201
7774
|
});
|
|
7202
7775
|
const stages = box2.stages && typeof box2.stages === "object" ? box2.stages : {};
|
|
7203
|
-
const lead =
|
|
7776
|
+
const lead = text3(stages.execute?.lead);
|
|
7204
7777
|
const previews = Array.isArray(box2.previews) ? rows(box2.previews.flat()) : stages.plan ? rows(stages.plan.helpers) : [];
|
|
7205
7778
|
const land = Array.isArray(box2.land) ? rows(box2.land) : lead ? [{ agent: lead, extra: "" }] : [];
|
|
7206
7779
|
return {
|
|
@@ -7223,9 +7796,9 @@ function readPictures(raw) {
|
|
|
7223
7796
|
function readBlocker(raw) {
|
|
7224
7797
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
7225
7798
|
const box2 = raw;
|
|
7226
|
-
const step =
|
|
7227
|
-
const cause =
|
|
7228
|
-
const unblock =
|
|
7799
|
+
const step = text3(box2.step);
|
|
7800
|
+
const cause = text3(box2.cause);
|
|
7801
|
+
const unblock = text3(box2.unblock);
|
|
7229
7802
|
return step && cause && unblock ? { step, cause, unblock } : void 0;
|
|
7230
7803
|
}
|
|
7231
7804
|
function readRules(raw) {
|
|
@@ -7239,9 +7812,9 @@ function readRules(raw) {
|
|
|
7239
7812
|
function readReviewed(raw) {
|
|
7240
7813
|
if (!raw || typeof raw !== "object") return void 0;
|
|
7241
7814
|
const box2 = raw;
|
|
7242
|
-
const mark =
|
|
7815
|
+
const mark = text3(box2.mark);
|
|
7243
7816
|
if (!mark) return void 0;
|
|
7244
|
-
return { mark, diff:
|
|
7817
|
+
return { mark, diff: text3(box2.diff), at: typeof box2.at === "number" ? box2.at : 0 };
|
|
7245
7818
|
}
|
|
7246
7819
|
function readLanding(raw) {
|
|
7247
7820
|
if (!raw || typeof raw !== "object") return void 0;
|
|
@@ -7249,14 +7822,14 @@ function readLanding(raw) {
|
|
|
7249
7822
|
const num3 = (value) => typeof value === "number" ? value : void 0;
|
|
7250
7823
|
return {
|
|
7251
7824
|
status: asLandingStatus(box2.status),
|
|
7252
|
-
why:
|
|
7825
|
+
why: text3(box2.why),
|
|
7253
7826
|
attempts: typeof box2.attempts === "number" && box2.attempts > 0 ? Math.floor(box2.attempts) : 0,
|
|
7254
7827
|
rebasedAt: num3(box2.rebasedAt),
|
|
7255
|
-
rebasedFrom:
|
|
7256
|
-
originalBase:
|
|
7828
|
+
rebasedFrom: text3(box2.rebasedFrom),
|
|
7829
|
+
originalBase: text3(box2.originalBase),
|
|
7257
7830
|
rebaseKind: box2.rebaseKind === "disjoint" || box2.rebaseKind === "overlap" || box2.rebaseKind === "conflict" ? box2.rebaseKind : void 0,
|
|
7258
|
-
commit:
|
|
7259
|
-
onto:
|
|
7831
|
+
commit: text3(box2.commit),
|
|
7832
|
+
onto: text3(box2.onto),
|
|
7260
7833
|
overlap: Array.isArray(box2.overlap) ? box2.overlap.filter((n) => Number.isInteger(n)) : void 0,
|
|
7261
7834
|
wait: readLandingWait(box2.wait),
|
|
7262
7835
|
reason: readLandingReason(box2.reason),
|
|
@@ -7285,7 +7858,7 @@ function readLandingReason(raw) {
|
|
|
7285
7858
|
const files = Array.isArray(box2.files) ? box2.files.filter((f2) => typeof f2 === "string") : [];
|
|
7286
7859
|
return {
|
|
7287
7860
|
kind: box2.kind,
|
|
7288
|
-
...
|
|
7861
|
+
...text3(box2.behind) ? { behind: text3(box2.behind) } : {},
|
|
7289
7862
|
...files.length ? { files } : {}
|
|
7290
7863
|
};
|
|
7291
7864
|
}
|
|
@@ -7293,7 +7866,7 @@ function readAnswers(raw) {
|
|
|
7293
7866
|
if (!Array.isArray(raw)) return void 0;
|
|
7294
7867
|
const answers2 = raw.flatMap((entry) => {
|
|
7295
7868
|
if (!entry || entry.outcome !== "changed" && entry.outcome !== "unchanged") return [];
|
|
7296
|
-
const why2 =
|
|
7869
|
+
const why2 = text3(entry.why);
|
|
7297
7870
|
if (!why2) return [];
|
|
7298
7871
|
return [
|
|
7299
7872
|
{
|
|
@@ -7355,16 +7928,16 @@ function writeStore(store) {
|
|
|
7355
7928
|
marks: store.marks,
|
|
7356
7929
|
...store.refined ? { refined: store.refined } : {}
|
|
7357
7930
|
};
|
|
7358
|
-
|
|
7931
|
+
fs22.mkdirSync(path25.dirname(SESSIONS), { recursive: true });
|
|
7359
7932
|
const tmp = `${SESSIONS}.tmp`;
|
|
7360
|
-
|
|
7361
|
-
|
|
7933
|
+
fs22.writeFileSync(tmp, JSON.stringify(kept2, null, 2) + "\n");
|
|
7934
|
+
fs22.renameSync(tmp, SESSIONS);
|
|
7362
7935
|
forgetFileMemos();
|
|
7363
7936
|
}
|
|
7364
7937
|
function prune(runs, deliveries) {
|
|
7365
7938
|
const held4 = new Set(deliveries.filter(holdsCheckout).map((d2) => d2.deliveryId));
|
|
7366
7939
|
const live = runs.filter((r2) => r2.status === "running");
|
|
7367
|
-
const finished = runs.filter((r2) => r2.status !== "running" && (
|
|
7940
|
+
const finished = runs.filter((r2) => r2.status !== "running" && (fs22.existsSync(r2.logPath) || r2.deliveryId && held4.has(r2.deliveryId))).sort((a2, b2) => b2.startedAt - a2.startedAt).slice(0, KEEP_RUNS);
|
|
7368
7941
|
const spared = runs.filter(
|
|
7369
7942
|
(r2) => r2.status !== "running" && !finished.includes(r2) && (!!r2.discardedCards?.length || r2.deliveryId && held4.has(r2.deliveryId))
|
|
7370
7943
|
);
|
|
@@ -7409,7 +7982,7 @@ function handoffOf(value) {
|
|
|
7409
7982
|
cwd: typeof h3.cwd === "string" && h3.cwd ? h3.cwd : void 0
|
|
7410
7983
|
};
|
|
7411
7984
|
}
|
|
7412
|
-
var KEEP_RUNS, KEEP_DELIVERIES, logPathOf, eventsPathOf, WAS_CLARIFY, RETIRED_ACTIONS, knownAction, readAction, readStore, strings, stringRecord, readRuns, PENDING_MS, runIsLive, creationOf, cardCreation,
|
|
7985
|
+
var KEEP_RUNS, KEEP_DELIVERIES, logPathOf, eventsPathOf, WAS_CLARIFY, RETIRED_ACTIONS, knownAction, readAction, readStore, strings, stringRecord, readRuns, PENDING_MS, runIsLive, creationOf, cardCreation, text3, LANDING_REASONS, asLandingStatus, isVerdict, holdsCheckout;
|
|
7413
7986
|
var init_store = __esm({
|
|
7414
7987
|
"../cli/src/lib/agent/store.ts"() {
|
|
7415
7988
|
"use strict";
|
|
@@ -7421,8 +7994,8 @@ var init_store = __esm({
|
|
|
7421
7994
|
init_log();
|
|
7422
7995
|
KEEP_RUNS = 100;
|
|
7423
7996
|
KEEP_DELIVERIES = 30;
|
|
7424
|
-
logPathOf = (sessionId) =>
|
|
7425
|
-
eventsPathOf = (sessionId) =>
|
|
7997
|
+
logPathOf = (sessionId) => path25.join(SESSIONS_DIR, `${sessionId}.log`);
|
|
7998
|
+
eventsPathOf = (sessionId) => path25.join(SESSIONS_DIR, `${sessionId}.events.jsonl`);
|
|
7426
7999
|
WAS_CLARIFY = /* @__PURE__ */ new Set(["auto-refine", "refine", "raise-questions"]);
|
|
7427
8000
|
RETIRED_ACTIONS = /* @__PURE__ */ new Set([
|
|
7428
8001
|
"channel",
|
|
@@ -7456,7 +8029,7 @@ var init_store = __esm({
|
|
|
7456
8029
|
if (strict) return state;
|
|
7457
8030
|
return state && state.runId === insideRun() ? void 0 : state;
|
|
7458
8031
|
};
|
|
7459
|
-
|
|
8032
|
+
text3 = (value) => typeof value === "string" && value ? value : void 0;
|
|
7460
8033
|
LANDING_REASONS = /* @__PURE__ */ new Set([
|
|
7461
8034
|
"queued",
|
|
7462
8035
|
"worktree-gone",
|
|
@@ -7996,9 +8569,9 @@ var init_parse = __esm({
|
|
|
7996
8569
|
// ../cli/src/lib/agent/studio-def.ts
|
|
7997
8570
|
function readAgent(item) {
|
|
7998
8571
|
const row = typeof item === "string" ? { agent: item } : box(item);
|
|
7999
|
-
const agent =
|
|
8572
|
+
const agent = text4(row.agent);
|
|
8000
8573
|
if (!agent) return null;
|
|
8001
|
-
return { agent, extra: typeof row.extra === "string" ? row.extra : "", ...
|
|
8574
|
+
return { agent, extra: typeof row.extra === "string" ? row.extra : "", ...text4(row.off) === "true" ? { off: true } : {} };
|
|
8002
8575
|
}
|
|
8003
8576
|
function readPreviews(value) {
|
|
8004
8577
|
if (value === void 0 || value === "") return [];
|
|
@@ -8027,7 +8600,7 @@ function parseStudioFile(id, source2, from) {
|
|
|
8027
8600
|
const { meta, body } = splitFrontmatter(source2);
|
|
8028
8601
|
if (meta === null) return { problem: `${from}: no \`---\` frontmatter` };
|
|
8029
8602
|
const raw = parseYamlBlock(meta);
|
|
8030
|
-
const name =
|
|
8603
|
+
const name = text4(raw.name).replace(/\s+/g, " ");
|
|
8031
8604
|
if (!name) return { problem: `${from}: its frontmatter has no \`name\`` };
|
|
8032
8605
|
const old = OLD_KEYS.filter((key) => key in raw);
|
|
8033
8606
|
if (old.length) {
|
|
@@ -8052,21 +8625,21 @@ function parseStudioFile(id, source2, from) {
|
|
|
8052
8625
|
const scheduled = [];
|
|
8053
8626
|
for (const item of Array.isArray(raw.scheduled) ? raw.scheduled : []) {
|
|
8054
8627
|
const row = typeof item === "string" ? { agent: item } : box(item);
|
|
8055
|
-
const agent =
|
|
8628
|
+
const agent = text4(row.agent);
|
|
8056
8629
|
if (!agent || scheduled.some((s) => s.agent === agent)) continue;
|
|
8057
|
-
scheduled.push({ agent, ...
|
|
8630
|
+
scheduled.push({ agent, ...text4(row.cadence) ? { cadence: text4(row.cadence) } : {} });
|
|
8058
8631
|
}
|
|
8059
8632
|
const workspace2 = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
|
|
8060
8633
|
if (typeof workspace2 === "string") return { problem: `${from}: declares ${workspace2}` };
|
|
8061
|
-
const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang,
|
|
8634
|
+
const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang, text4(said2)]).filter(([, said2]) => said2));
|
|
8062
8635
|
return {
|
|
8063
8636
|
def: {
|
|
8064
8637
|
id,
|
|
8065
8638
|
name,
|
|
8066
8639
|
...Object.keys(names3).length ? { names: names3 } : {},
|
|
8067
|
-
description:
|
|
8068
|
-
when:
|
|
8069
|
-
needsArtifact:
|
|
8640
|
+
description: text4(raw.description),
|
|
8641
|
+
when: text4(raw.when),
|
|
8642
|
+
needsArtifact: text4(raw.needsArtifact) === "true",
|
|
8070
8643
|
...icon2 ? { icon: icon2 } : {},
|
|
8071
8644
|
previews,
|
|
8072
8645
|
land,
|
|
@@ -8076,7 +8649,7 @@ function parseStudioFile(id, source2, from) {
|
|
|
8076
8649
|
}
|
|
8077
8650
|
};
|
|
8078
8651
|
}
|
|
8079
|
-
var STUDIO_ID, OLD_KEYS, box,
|
|
8652
|
+
var STUDIO_ID, OLD_KEYS, box, text4, readGroup;
|
|
8080
8653
|
var init_studio_def = __esm({
|
|
8081
8654
|
"../cli/src/lib/agent/studio-def.ts"() {
|
|
8082
8655
|
"use strict";
|
|
@@ -8087,7 +8660,7 @@ var init_studio_def = __esm({
|
|
|
8087
8660
|
STUDIO_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
8088
8661
|
OLD_KEYS = ["stages", "delivers", "helpers", "every"];
|
|
8089
8662
|
box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
8090
|
-
|
|
8663
|
+
text4 = (value) => typeof value === "string" ? value.trim() : "";
|
|
8091
8664
|
readGroup = (value) => (Array.isArray(value) ? value : []).map(readAgent).filter((h3) => !!h3);
|
|
8092
8665
|
}
|
|
8093
8666
|
});
|
|
@@ -8278,17 +8851,17 @@ var init_studio_files = __esm({
|
|
|
8278
8851
|
});
|
|
8279
8852
|
|
|
8280
8853
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
8281
|
-
import
|
|
8282
|
-
import
|
|
8854
|
+
import fs23 from "node:fs";
|
|
8855
|
+
import path26 from "node:path";
|
|
8283
8856
|
function filesOf(dir, base = dir) {
|
|
8284
|
-
return
|
|
8285
|
-
const full =
|
|
8286
|
-
return e2.isDirectory() ? filesOf(full, base) : [
|
|
8857
|
+
return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
|
|
8858
|
+
const full = path26.join(dir, e2.name);
|
|
8859
|
+
return e2.isDirectory() ? filesOf(full, base) : [path26.relative(base, full).split(path26.sep).join("/")];
|
|
8287
8860
|
});
|
|
8288
8861
|
}
|
|
8289
8862
|
function readStudioFile(dir, file2) {
|
|
8290
|
-
const full =
|
|
8291
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[
|
|
8863
|
+
const full = path26.join(dir, file2);
|
|
8864
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path26.extname(file2)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
|
|
8292
8865
|
}
|
|
8293
8866
|
var MIME, readStudioFolder;
|
|
8294
8867
|
var init_studio_folder = __esm({
|
|
@@ -8301,23 +8874,23 @@ var init_studio_folder = __esm({
|
|
|
8301
8874
|
});
|
|
8302
8875
|
|
|
8303
8876
|
// ../official/pack.ts
|
|
8304
|
-
import
|
|
8305
|
-
import
|
|
8306
|
-
import
|
|
8877
|
+
import crypto2 from "node:crypto";
|
|
8878
|
+
import fs24 from "node:fs";
|
|
8879
|
+
import path27 from "node:path";
|
|
8307
8880
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8308
8881
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
8309
|
-
const agentsDir =
|
|
8882
|
+
const agentsDir = path27.join(root2, "agents");
|
|
8310
8883
|
const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
|
|
8311
|
-
const dir =
|
|
8884
|
+
const dir = path27.join(agentsDir, name);
|
|
8312
8885
|
return [name, readStudioFolder(dir)];
|
|
8313
8886
|
}));
|
|
8314
8887
|
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
8315
8888
|
const read4 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
8316
8889
|
if ("problem" in read4) throw new Error(read4.problem);
|
|
8317
8890
|
}
|
|
8318
|
-
const studiosDir =
|
|
8891
|
+
const studiosDir = path27.join(root2, "studios");
|
|
8319
8892
|
return dirs(studiosDir).map((folder) => {
|
|
8320
|
-
const dir =
|
|
8893
|
+
const dir = path27.join(studiosDir, folder);
|
|
8321
8894
|
const files = {};
|
|
8322
8895
|
for (const f2 of filesOf(dir).sort()) {
|
|
8323
8896
|
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);
|
|
@@ -8354,144 +8927,9 @@ var init_pack = __esm({
|
|
|
8354
8927
|
init_studio_def();
|
|
8355
8928
|
init_studio_folder();
|
|
8356
8929
|
init_studio_files();
|
|
8357
|
-
OFFICIAL =
|
|
8358
|
-
dirs = (dir) =>
|
|
8359
|
-
hashOf = (files) =>
|
|
8360
|
-
}
|
|
8361
|
-
});
|
|
8362
|
-
|
|
8363
|
-
// ../cli/src/lib/cloud/tasks.ts
|
|
8364
|
-
import crypto2 from "node:crypto";
|
|
8365
|
-
import fs24 from "node:fs";
|
|
8366
|
-
import path27 from "node:path";
|
|
8367
|
-
function workspaceTask() {
|
|
8368
|
-
const id = process.env[TASK_ENV];
|
|
8369
|
-
return id && id.trim() ? id.trim() : null;
|
|
8370
|
-
}
|
|
8371
|
-
function cloudStudio(name) {
|
|
8372
|
-
if (/^wf-/.test(name)) return name.replace("-", "_");
|
|
8373
|
-
return `wf_builtin_${name.replace(/-/g, "_")}`;
|
|
8374
|
-
}
|
|
8375
|
-
async function call(method, route2, body, key) {
|
|
8376
|
-
if (!cloudConfigured()) return { ok: false, error: NOT_CONFIGURED, code: "bad_request" };
|
|
8377
|
-
const token2 = await accessToken();
|
|
8378
|
-
if (!token2.ok) {
|
|
8379
|
-
return token2.reason === "unreachable" ? { ok: false, error: `Cloud could not be reached: ${token2.error}` } : { ok: false, error: token2.reason === "expired" ? "Cloud sign-in has expired. Sign in again." : "This machine is not signed in to Cloud.", code: "unauthenticated" };
|
|
8380
|
-
}
|
|
8381
|
-
let response;
|
|
8382
|
-
try {
|
|
8383
|
-
response = await fetch(`${cloudEndpoints().api}${route2}`, {
|
|
8384
|
-
method,
|
|
8385
|
-
headers: {
|
|
8386
|
-
authorization: `Bearer ${token2.token}`,
|
|
8387
|
-
...body ? { "content-type": "application/json" } : {},
|
|
8388
|
-
...key ? { "idempotency-key": key } : {}
|
|
8389
|
-
},
|
|
8390
|
-
...body ? { body: JSON.stringify(body) } : {},
|
|
8391
|
-
signal: AbortSignal.timeout(2e4)
|
|
8392
|
-
});
|
|
8393
|
-
} catch (e2) {
|
|
8394
|
-
return { ok: false, error: `Cloud could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}` };
|
|
8395
|
-
}
|
|
8396
|
-
const parsed = await response.json().catch(() => ({}));
|
|
8397
|
-
if (!response.ok) return { ok: false, code: parsed.error?.code ?? "refused", error: parsed.error?.message ?? `Cloud answered ${response.status}.` };
|
|
8398
|
-
return { ok: true, value: parsed, replayed: response.headers.get("idempotent-replayed") === "true" };
|
|
8399
|
-
}
|
|
8400
|
-
async function createTask(from, said2) {
|
|
8401
|
-
const source2 = await call("GET", `/v1/tasks/${encodeURIComponent(from)}`);
|
|
8402
|
-
if (!source2.ok) return source2;
|
|
8403
|
-
const studio = said2.studio ? cloudStudio(said2.studio) : source2.value.studio?.id;
|
|
8404
|
-
const body = {
|
|
8405
|
-
title: said2.title,
|
|
8406
|
-
project: source2.value.project,
|
|
8407
|
-
...studio ? { studio } : {},
|
|
8408
|
-
...said2.request?.trim() ? { request: said2.request.trim() } : {},
|
|
8409
|
-
source: "api",
|
|
8410
|
-
source_context: { task: from, ...said2.agent ? { agent: said2.agent } : {} },
|
|
8411
|
-
...said2.run ? { run: true } : {},
|
|
8412
|
-
...said2.metadata && Object.keys(said2.metadata).length ? { metadata: said2.metadata } : {},
|
|
8413
|
-
...said2.triage ? { triage: `tri_${source2.value.project.replace(/^prj_/, "")}_${said2.triage}` } : {}
|
|
8414
|
-
};
|
|
8415
|
-
const key = `akb-${crypto2.createHash("sha256").update(`${from}
|
|
8416
|
-
${said2.slug?.trim() || said2.title}`).digest("hex").slice(0, 40)}`;
|
|
8417
|
-
const made = await call("POST", "/v1/tasks", body, key);
|
|
8418
|
-
if (!made.ok) return made;
|
|
8419
|
-
const number = numberOf(made.value.key);
|
|
8420
|
-
if (!Number.isInteger(number)) return { ok: false, error: `Cloud answered a task with no number: ${made.value.key}`, code: "refused" };
|
|
8421
|
-
return { ok: true, value: { task: made.value, number, from: source2.value, replayed: made.replayed === true } };
|
|
8422
|
-
}
|
|
8423
|
-
function runnerProject(board2) {
|
|
8424
|
-
if (path27.basename(board2) !== "kanban" || path27.basename(path27.dirname(board2)) !== ".akb") return null;
|
|
8425
|
-
const linked2 = linkedProject(board2, path27.dirname(path27.dirname(board2)));
|
|
8426
|
-
return linked2.ok ? linked2.value : null;
|
|
8427
|
-
}
|
|
8428
|
-
function linkedProject(board2, root2) {
|
|
8429
|
-
const file2 = path27.join(root2, ".akb", "base.json");
|
|
8430
|
-
if (!fs24.existsSync(file2)) return { ok: true, value: null };
|
|
8431
|
-
try {
|
|
8432
|
-
const base = JSON.parse(fs24.readFileSync(file2, "utf8"));
|
|
8433
|
-
if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
|
|
8434
|
-
const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
|
|
8435
|
-
if (typeof base.project === "string") projects.add(base.project);
|
|
8436
|
-
if (projects.size !== 1) throw new Error();
|
|
8437
|
-
return { ok: true, value: [...projects][0] };
|
|
8438
|
-
} catch {
|
|
8439
|
-
return { ok: false, error: "The project link is invalid or names multiple projects.", code: "invalid-link" };
|
|
8440
|
-
}
|
|
8441
|
-
}
|
|
8442
|
-
async function creationProject(board2, root2, task = workspaceTask()) {
|
|
8443
|
-
const link2 = linkedProject(board2, root2);
|
|
8444
|
-
if (!link2.ok) return link2;
|
|
8445
|
-
let project2 = link2.value;
|
|
8446
|
-
if (task) {
|
|
8447
|
-
const source2 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}`);
|
|
8448
|
-
if (!source2.ok) return {
|
|
8449
|
-
...source2,
|
|
8450
|
-
error: source2.code === "forbidden" ? "Cannot access this task. Check your account and task access in WildCrane, then try again." : source2.code === "not_found" ? "This task does not exist. Start a new task from the WildCrane web app." : source2.error
|
|
8451
|
-
};
|
|
8452
|
-
if (project2 && project2 !== source2.value.project) return { ok: false, error: "The source task conflicts with this board\u2019s project link.", code: "invalid-link" };
|
|
8453
|
-
project2 = source2.value.project;
|
|
8454
|
-
}
|
|
8455
|
-
if (!project2) return { ok: false, error: "This board is not linked to a Cloud project.", code: "unlinked" };
|
|
8456
|
-
const checked = await call("GET", `/v1/projects/${encodeURIComponent(project2)}`);
|
|
8457
|
-
return checked.ok ? { ok: true, value: project2 } : checked;
|
|
8458
|
-
}
|
|
8459
|
-
async function createProjectTask(project2, said2, key) {
|
|
8460
|
-
const made = await call("POST", "/v1/tasks", {
|
|
8461
|
-
title: said2.title,
|
|
8462
|
-
project: project2,
|
|
8463
|
-
source: "api",
|
|
8464
|
-
...said2.studio ? { studio: cloudStudio(said2.studio) } : {},
|
|
8465
|
-
...said2.request?.trim() ? { request: said2.request.trim() } : {},
|
|
8466
|
-
...said2.agent ? { source_context: { agent: said2.agent } } : {},
|
|
8467
|
-
...said2.triage ? { triage: `tri_${project2.replace(/^prj_/, "")}_${said2.triage}` } : {}
|
|
8468
|
-
}, key);
|
|
8469
|
-
if (!made.ok) return made;
|
|
8470
|
-
const number = numberOf(made.value.key);
|
|
8471
|
-
if (!Number.isInteger(number)) return { ok: false, error: `Cloud answered a task with no number: ${made.value.key}`, code: "refused" };
|
|
8472
|
-
return { ok: true, value: { task: made.value, number } };
|
|
8473
|
-
}
|
|
8474
|
-
async function approveTask(project2, number) {
|
|
8475
|
-
const held4 = await call("GET", `/v1/projects/${encodeURIComponent(project2)}`);
|
|
8476
|
-
if (!held4.ok) return held4;
|
|
8477
|
-
const key = `${held4.value.prefix}-${number}`;
|
|
8478
|
-
const task = await call("GET", `/v1/tasks/${encodeURIComponent(key)}`);
|
|
8479
|
-
if (!task.ok) return task;
|
|
8480
|
-
const revision = task.value.review?.revision;
|
|
8481
|
-
const decided = await call("POST", `/v1/tasks/${encodeURIComponent(key)}/decisions`, {
|
|
8482
|
-
decision: "approve",
|
|
8483
|
-
...revision !== void 0 ? { review_revision: revision } : {}
|
|
8484
|
-
});
|
|
8485
|
-
return decided.ok ? { ok: true, value: { key } } : decided;
|
|
8486
|
-
}
|
|
8487
|
-
var TASK_ENV, numberOf;
|
|
8488
|
-
var init_tasks = __esm({
|
|
8489
|
-
"../cli/src/lib/cloud/tasks.ts"() {
|
|
8490
|
-
"use strict";
|
|
8491
|
-
init_config();
|
|
8492
|
-
init_session();
|
|
8493
|
-
TASK_ENV = "AI4KANBAN_TASK";
|
|
8494
|
-
numberOf = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? NaN);
|
|
8930
|
+
OFFICIAL = path27.dirname(fileURLToPath2(import.meta.url));
|
|
8931
|
+
dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
8932
|
+
hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
8495
8933
|
}
|
|
8496
8934
|
});
|
|
8497
8935
|
|
|
@@ -12713,7 +13151,7 @@ function storyboardProblem(data) {
|
|
|
12713
13151
|
return null;
|
|
12714
13152
|
}
|
|
12715
13153
|
var COMPARE_IMAGES, COMPARE_VIDEOS, TAG, ATTR;
|
|
12716
|
-
var
|
|
13154
|
+
var init_compare2 = __esm({
|
|
12717
13155
|
"../cli/src/lib/compare.ts"() {
|
|
12718
13156
|
"use strict";
|
|
12719
13157
|
COMPARE_IMAGES = ["png", "jpg", "jpeg", "webp", "gif", "svg"];
|
|
@@ -12765,7 +13203,7 @@ function assetName(src, cardId2, exts, nested = false) {
|
|
|
12765
13203
|
return { name };
|
|
12766
13204
|
}
|
|
12767
13205
|
var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, studioTag;
|
|
12768
|
-
var
|
|
13206
|
+
var init_storyboard2 = __esm({
|
|
12769
13207
|
"../cli/src/lib/storyboard.ts"() {
|
|
12770
13208
|
"use strict";
|
|
12771
13209
|
TAG2 = /^<Storyboard\b([^<>]*?)\/>$/;
|
|
@@ -12782,407 +13220,6 @@ var init_storyboard = __esm({
|
|
|
12782
13220
|
}
|
|
12783
13221
|
});
|
|
12784
13222
|
|
|
12785
|
-
// ../artifact-sdk/src/builtin/compare.json
|
|
12786
|
-
var compare_default;
|
|
12787
|
-
var init_compare2 = __esm({
|
|
12788
|
-
"../artifact-sdk/src/builtin/compare.json"() {
|
|
12789
|
-
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", "spritesheet", "studio"] },\n { "json": "/b", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "studio"] }\n ]\n}\n';
|
|
12790
|
-
}
|
|
12791
|
-
});
|
|
12792
|
-
|
|
12793
|
-
// ../artifact-sdk/src/builtin/html.json
|
|
12794
|
-
var html_default;
|
|
12795
|
-
var init_html = __esm({
|
|
12796
|
-
"../artifact-sdk/src/builtin/html.json"() {
|
|
12797
|
-
html_default = `{
|
|
12798
|
-
"name": "html",
|
|
12799
|
-
"title": { "en": "Page", "zh": "\u9875\u9762" },
|
|
12800
|
-
"types": ["html"],
|
|
12801
|
-
"references": [
|
|
12802
|
-
{ "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
12803
|
-
{ "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
12804
|
-
{ "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
|
|
12805
|
-
{ "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
12806
|
-
{ "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
|
|
12807
|
-
],
|
|
12808
|
-
"skip": ["(?<=<script\\\\b[^<>]*>)[\\\\s\\\\S]*?(?=</script\\\\s*>|$)"]
|
|
12809
|
-
}
|
|
12810
|
-
`;
|
|
12811
|
-
}
|
|
12812
|
-
});
|
|
12813
|
-
|
|
12814
|
-
// ../artifact-sdk/src/builtin/image.json
|
|
12815
|
-
var image_default;
|
|
12816
|
-
var init_image = __esm({
|
|
12817
|
-
"../artifact-sdk/src/builtin/image.json"() {
|
|
12818
|
-
image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
|
|
12819
|
-
}
|
|
12820
|
-
});
|
|
12821
|
-
|
|
12822
|
-
// ../artifact-sdk/src/builtin/markdown.json
|
|
12823
|
-
var markdown_default;
|
|
12824
|
-
var init_markdown = __esm({
|
|
12825
|
-
"../artifact-sdk/src/builtin/markdown.json"() {
|
|
12826
|
-
markdown_default = `{
|
|
12827
|
-
"name": "markdown",
|
|
12828
|
-
"title": { "en": "Document", "zh": "\u6587\u6863" },
|
|
12829
|
-
"types": ["markdown"],
|
|
12830
|
-
"references": [
|
|
12831
|
-
{ "text": "!\\\\[[^\\\\]\\\\n]*\\\\]\\\\(\\\\s*<?([^\\\\s)>]+)>?(?:\\\\s+[\\"'][^\\"'\\\\n]*[\\"'])?\\\\s*\\\\)" },
|
|
12832
|
-
{ "text": "<img\\\\b[^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" }
|
|
12833
|
-
]
|
|
12834
|
-
}
|
|
12835
|
-
`;
|
|
12836
|
-
}
|
|
12837
|
-
});
|
|
12838
|
-
|
|
12839
|
-
// ../artifact-sdk/src/builtin/spritesheet.json
|
|
12840
|
-
var spritesheet_default;
|
|
12841
|
-
var init_spritesheet = __esm({
|
|
12842
|
-
"../artifact-sdk/src/builtin/spritesheet.json"() {
|
|
12843
|
-
spritesheet_default = '{\n "name": "spritesheet",\n "title": { "en": "Sprite animation", "zh": "\u7CBE\u7075\u52A8\u753B" },\n "types": ["spritesheet"],\n "schema": {\n "type": "object",\n "required": ["frames", "meta"],\n "properties": {\n "frames": {\n "anyOf": [\n { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["frame"] } },\n { "type": "object", "additionalProperties": { "type": "object", "required": ["frame"] } }\n ]\n },\n "meta": {\n "type": "object",\n "required": ["app", "image"],\n "properties": { "app": { "type": "string", "pattern": "codeandweb\\\\.com/texturepacker" }, "image": { "type": "string" } }\n }\n }\n },\n "references": [{ "json": "/meta/image" }]\n}\n';
|
|
12844
|
-
}
|
|
12845
|
-
});
|
|
12846
|
-
|
|
12847
|
-
// ../artifact-sdk/src/builtin/storyboard.json
|
|
12848
|
-
var storyboard_default;
|
|
12849
|
-
var init_storyboard2 = __esm({
|
|
12850
|
-
"../artifact-sdk/src/builtin/storyboard.json"() {
|
|
12851
|
-
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", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/slides/*/preview/src", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
12852
|
-
}
|
|
12853
|
-
});
|
|
12854
|
-
|
|
12855
|
-
// ../artifact-sdk/src/builtin/tiled.json
|
|
12856
|
-
var tiled_default;
|
|
12857
|
-
var init_tiled = __esm({
|
|
12858
|
-
"../artifact-sdk/src/builtin/tiled.json"() {
|
|
12859
|
-
tiled_default = `{
|
|
12860
|
-
"name": "tiled",
|
|
12861
|
-
"title": { "en": "Tiled map", "zh": "Tiled \u5730\u56FE" },
|
|
12862
|
-
"types": ["tiled"],
|
|
12863
|
-
"references": [
|
|
12864
|
-
{ "text": "<tileset\\\\b[^<>]*?\\\\ssource\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "types": ["tiled"] },
|
|
12865
|
-
{ "text": "<image\\\\b[^<>]*?\\\\ssource\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
12866
|
-
{ "text": "\\"source\\"\\\\s*:\\\\s*\\"([^\\"]+)\\"", "types": ["tiled"] },
|
|
12867
|
-
{ "text": "\\"image\\"\\\\s*:\\\\s*\\"([^\\"]+)\\"" }
|
|
12868
|
-
]
|
|
12869
|
-
}
|
|
12870
|
-
`;
|
|
12871
|
-
}
|
|
12872
|
-
});
|
|
12873
|
-
|
|
12874
|
-
// ../artifact-sdk/src/builtin/video.json
|
|
12875
|
-
var video_default;
|
|
12876
|
-
var init_video = __esm({
|
|
12877
|
-
"../artifact-sdk/src/builtin/video.json"() {
|
|
12878
|
-
video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
12879
|
-
}
|
|
12880
|
-
});
|
|
12881
|
-
|
|
12882
|
-
// ../artifact-sdk/src/builtin/studio.json
|
|
12883
|
-
var studio_default;
|
|
12884
|
-
var init_studio = __esm({
|
|
12885
|
-
"../artifact-sdk/src/builtin/studio.json"() {
|
|
12886
|
-
studio_default = '{\n "name": "studio",\n "title": {\n "en": "Studio",\n "zh": "\u5DE5\u4F5C\u53F0"\n },\n "types": [\n "studio"\n ],\n "schema": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "rounds",\n "land",\n "scheduled"\n ],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string"\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ]\n }\n }\n }\n }\n },\n "land": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "scheduled": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ]\n }\n },\n "version": {\n "enum": [\n 1\n ]\n }\n }\n },\n {\n "type": "object",\n "required": [\n "version",\n "base",\n "fingerprint",\n "agents",\n "files",\n "results"\n ],\n "properties": {\n "version": {\n "const": 2\n },\n "base": {\n "anyOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "required": [\n "id",\n "version",\n "fingerprint"\n ],\n "properties": {\n "id": {\n "type": "string",\n "minLength": 1\n },\n "version": {\n "type": "integer",\n "minimum": 1\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n ]\n },\n "fingerprint": {\n "type": "string",\n "minLength": 1\n },\n "agents": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "agent",\n "title"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "title": {\n "type": "object",\n "required": [\n "en"\n ],\n "properties": {\n "en": {\n "type": "string",\n "minLength": 1\n },\n "zh": {\n "type": "string"\n }\n }\n }\n }\n }\n },\n "files": {\n "type": "array",\n "maxItems": 1000,\n "items": {\n "type": "object",\n "required": [\n "path",\n "before",\n "after"\n ],\n "properties": {\n "path": {\n "type": "string",\n "minLength": 1\n },\n "before": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "after": {\n "anyOf": [\n {\n "type": "string",\n "minLength": 1\n },\n {\n "type": "null"\n }\n ]\n },\n "diff": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n "results": {\n "type": "array",\n "maxItems": 500,\n "items": {\n "anyOf": [\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Asset"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "label",\n "items"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Set"\n },\n "label": {\n "type": "string"\n },\n "items": {\n "type": "array",\n "minItems": 1,\n "maxItems": 500,\n "items": {\n "type": "object",\n "required": [\n "src"\n ],\n "properties": {\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "alt": {\n "type": "string"\n },\n "device": {\n "enum": [\n "mobile",\n "desktop"\n ]\n },\n "loop": {\n "type": "boolean"\n },\n "variants": {\n "type": "object",\n "additionalProperties": {\n "type": "string",\n "minLength": 1\n }\n }\n }\n }\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "a",\n "b"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Compare"\n },\n "a": {\n "type": "string",\n "minLength": 1\n },\n "b": {\n "type": "string",\n "minLength": 1\n },\n "shots": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n },\n "a-label": {\n "type": "string"\n },\n "b-label": {\n "type": "string"\n }\n }\n },\n {\n "type": "object",\n "required": [\n "agent",\n "component",\n "src"\n ],\n "properties": {\n "agent": {\n "type": "string",\n "minLength": 1\n },\n "component": {\n "const": "Storyboard"\n },\n "src": {\n "type": "string",\n "minLength": 1\n },\n "label": {\n "type": "string"\n }\n }\n }\n ]\n }\n }\n }\n }\n ]\n },\n "references": [\n {\n "json": "/files/*/before"\n },\n {\n "json": "/files/*/after"\n },\n {\n "json": "/files/*/diff"\n },\n {\n "json": "/results/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/src",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/variants/*",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/a",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/b",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n },\n {\n "json": "/results/*/items/*/shots",\n "types": [\n "storyboard",\n "compare",\n "spritesheet",\n "studio",\n "asset"\n ]\n }\n ]\n}\n';
|
|
12887
|
-
}
|
|
12888
|
-
});
|
|
12889
|
-
|
|
12890
|
-
// ../artifact-sdk/src/builtin/index.ts
|
|
12891
|
-
var read, builtin_default;
|
|
12892
|
-
var init_builtin = __esm({
|
|
12893
|
-
"../artifact-sdk/src/builtin/index.ts"() {
|
|
12894
|
-
"use strict";
|
|
12895
|
-
init_compare2();
|
|
12896
|
-
init_html();
|
|
12897
|
-
init_image();
|
|
12898
|
-
init_markdown();
|
|
12899
|
-
init_spritesheet();
|
|
12900
|
-
init_storyboard2();
|
|
12901
|
-
init_tiled();
|
|
12902
|
-
init_video();
|
|
12903
|
-
init_studio();
|
|
12904
|
-
read = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
12905
|
-
builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, studio_default, tiled_default, spritesheet_default].map(read);
|
|
12906
|
-
}
|
|
12907
|
-
});
|
|
12908
|
-
|
|
12909
|
-
// ../artifact-sdk/src/internal/schema.ts
|
|
12910
|
-
function typeOk(type, v) {
|
|
12911
|
-
const types = Array.isArray(type) ? type : [type];
|
|
12912
|
-
return types.some(
|
|
12913
|
-
(t) => t === "null" ? v === null : t === "array" ? Array.isArray(v) : t === "object" ? isObj(v) : t === "integer" ? Number.isInteger(v) : t === "number" ? typeof v === "number" && Number.isFinite(v) : typeof v === t
|
|
12914
|
-
);
|
|
12915
|
-
}
|
|
12916
|
-
function schemaProblem(schema, value, at2 = "") {
|
|
12917
|
-
if (!isObj(schema)) return null;
|
|
12918
|
-
const s = schema;
|
|
12919
|
-
const here = at2 || "/";
|
|
12920
|
-
if (s.type !== void 0 && !typeOk(s.type, value)) return here;
|
|
12921
|
-
if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
|
|
12922
|
-
if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
|
|
12923
|
-
if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
|
|
12924
|
-
if (typeof value === "string") {
|
|
12925
|
-
if (typeof s.minLength === "number" && value.length < s.minLength) return here;
|
|
12926
|
-
if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
|
|
12927
|
-
if (typeof s.pattern === "string") {
|
|
12928
|
-
try {
|
|
12929
|
-
if (!new RegExp(s.pattern, "u").test(value)) return here;
|
|
12930
|
-
} catch {
|
|
12931
|
-
}
|
|
12932
|
-
}
|
|
12933
|
-
}
|
|
12934
|
-
if (typeof value === "number") {
|
|
12935
|
-
if (typeof s.minimum === "number" && value < s.minimum) return here;
|
|
12936
|
-
if (typeof s.maximum === "number" && value > s.maximum) return here;
|
|
12937
|
-
}
|
|
12938
|
-
if (Array.isArray(value)) {
|
|
12939
|
-
if (typeof s.minItems === "number" && value.length < s.minItems) return here;
|
|
12940
|
-
if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
|
|
12941
|
-
if (isObj(s.items)) {
|
|
12942
|
-
for (let i = 0; i < value.length; i++) {
|
|
12943
|
-
const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
|
|
12944
|
-
if (bad) return bad;
|
|
12945
|
-
}
|
|
12946
|
-
}
|
|
12947
|
-
}
|
|
12948
|
-
if (isObj(value)) {
|
|
12949
|
-
const props = isObj(s.properties) ? s.properties : {};
|
|
12950
|
-
if (Array.isArray(s.required)) {
|
|
12951
|
-
for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
|
|
12952
|
-
}
|
|
12953
|
-
for (const [k2, v] of Object.entries(value)) {
|
|
12954
|
-
if (k2 in props) {
|
|
12955
|
-
const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
|
|
12956
|
-
if (bad) return bad;
|
|
12957
|
-
} else if (s.additionalProperties === false) return `${at2}/${k2}`;
|
|
12958
|
-
else if (isObj(s.additionalProperties)) {
|
|
12959
|
-
const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
|
|
12960
|
-
if (bad) return bad;
|
|
12961
|
-
}
|
|
12962
|
-
}
|
|
12963
|
-
}
|
|
12964
|
-
return null;
|
|
12965
|
-
}
|
|
12966
|
-
var isObj;
|
|
12967
|
-
var init_schema = __esm({
|
|
12968
|
-
"../artifact-sdk/src/internal/schema.ts"() {
|
|
12969
|
-
"use strict";
|
|
12970
|
-
isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
12971
|
-
}
|
|
12972
|
-
});
|
|
12973
|
-
|
|
12974
|
-
// ../artifact-sdk/src/internal/references.ts
|
|
12975
|
-
function bodyReferences(body) {
|
|
12976
|
-
const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
|
|
12977
|
-
let fence = "";
|
|
12978
|
-
let inTag = false;
|
|
12979
|
-
const out = [];
|
|
12980
|
-
const visible = [];
|
|
12981
|
-
for (const line of lines) {
|
|
12982
|
-
const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
12983
|
-
if (fence) {
|
|
12984
|
-
if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
|
|
12985
|
-
visible.push("");
|
|
12986
|
-
continue;
|
|
12987
|
-
}
|
|
12988
|
-
if (delimiter) {
|
|
12989
|
-
fence = delimiter;
|
|
12990
|
-
visible.push("");
|
|
12991
|
-
continue;
|
|
12992
|
-
}
|
|
12993
|
-
const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
|
|
12994
|
-
visible.push(kept2 ? line : "");
|
|
12995
|
-
if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Studio)\b/.test(line)) inTag = true;
|
|
12996
|
-
if (line.includes("/>")) inTag = false;
|
|
12997
|
-
}
|
|
12998
|
-
const text6 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
|
|
12999
|
-
const tag = /<(Asset|Mockup|Compare|Storyboard|Studio)\b([^<>]*?)\/>/g;
|
|
13000
|
-
const blocks = text6.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Studio)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
13001
|
-
for (const block of blocks) {
|
|
13002
|
-
const tags = [...block[0].matchAll(tag)];
|
|
13003
|
-
for (const m of tags) {
|
|
13004
|
-
const a2 = {};
|
|
13005
|
-
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
13006
|
-
if (m[1] === "Compare") {
|
|
13007
|
-
if (!a2.a || !a2.b) continue;
|
|
13008
|
-
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: ARRANGED });
|
|
13009
|
-
} else if (a2.src) {
|
|
13010
|
-
out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Studio" ? STUDIO : m[1] === "Asset" ? ASSET : [] });
|
|
13011
|
-
if (a2.variants) {
|
|
13012
|
-
try {
|
|
13013
|
-
const v = JSON.parse(a2.variants);
|
|
13014
|
-
if (isObject(v)) {
|
|
13015
|
-
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: m[1] === "Asset" ? ASSET : [] });
|
|
13016
|
-
}
|
|
13017
|
-
} catch {
|
|
13018
|
-
}
|
|
13019
|
-
}
|
|
13020
|
-
}
|
|
13021
|
-
}
|
|
13022
|
-
}
|
|
13023
|
-
for (const m of text6.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
|
|
13024
|
-
return out;
|
|
13025
|
-
}
|
|
13026
|
-
function kindOf2(ext) {
|
|
13027
|
-
if (ext === ".tsx" || ext === ".html") return "html";
|
|
13028
|
-
if (ext === ".md" || ext === ".mdx") return "markdown";
|
|
13029
|
-
if (ext === ".tmx" || ext === ".tmj" || ext === ".tsj") return "tiled";
|
|
13030
|
-
const type = TYPES[ext] ?? "";
|
|
13031
|
-
if (type.startsWith("image/")) return "image";
|
|
13032
|
-
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
13033
|
-
}
|
|
13034
|
-
var STORYBOARD, STUDIO, ARRANGED, ASSET, isObject, bodySources, TYPES;
|
|
13035
|
-
var init_references = __esm({
|
|
13036
|
-
"../artifact-sdk/src/internal/references.ts"() {
|
|
13037
|
-
"use strict";
|
|
13038
|
-
STORYBOARD = ["storyboard"];
|
|
13039
|
-
STUDIO = ["studio"];
|
|
13040
|
-
ARRANGED = ["storyboard", "compare", "spritesheet", "studio"];
|
|
13041
|
-
ASSET = ["spritesheet", "asset"];
|
|
13042
|
-
isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
13043
|
-
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
13044
|
-
TYPES = {
|
|
13045
|
-
".png": "image/png",
|
|
13046
|
-
".jpg": "image/jpeg",
|
|
13047
|
-
".jpeg": "image/jpeg",
|
|
13048
|
-
".gif": "image/gif",
|
|
13049
|
-
".webp": "image/webp",
|
|
13050
|
-
".svg": "image/svg+xml",
|
|
13051
|
-
".mp4": "video/mp4",
|
|
13052
|
-
".webm": "video/webm",
|
|
13053
|
-
".mp3": "audio/mpeg",
|
|
13054
|
-
".pdf": "application/pdf",
|
|
13055
|
-
".html": "text/html",
|
|
13056
|
-
".md": "text/markdown",
|
|
13057
|
-
".mdx": "text/markdown",
|
|
13058
|
-
".mov": "video/quicktime",
|
|
13059
|
-
".wav": "audio/wav",
|
|
13060
|
-
".m4a": "audio/mp4",
|
|
13061
|
-
".json": "application/json",
|
|
13062
|
-
".txt": "text/plain",
|
|
13063
|
-
".otf": "font/otf",
|
|
13064
|
-
".ttf": "font/ttf",
|
|
13065
|
-
".woff": "font/woff",
|
|
13066
|
-
".woff2": "font/woff2",
|
|
13067
|
-
".css": "text/css",
|
|
13068
|
-
".tmx": "application/xml",
|
|
13069
|
-
".tmj": "application/json",
|
|
13070
|
-
".tsj": "application/json"
|
|
13071
|
-
};
|
|
13072
|
-
}
|
|
13073
|
-
});
|
|
13074
|
-
|
|
13075
|
-
// ../artifact-sdk/src/internal/format/studio.ts
|
|
13076
|
-
function resultProblem(value, agents) {
|
|
13077
|
-
if (!Array.isArray(value) || value.length > 500) return "/results";
|
|
13078
|
-
for (let i = 0; i < value.length; i++) {
|
|
13079
|
-
const r2 = value[i];
|
|
13080
|
-
if (!isObject(r2) || !text4(r2.agent) || !agents.has(r2.agent) || !optionalText(r2, ["label"])) return `/results/${i}`;
|
|
13081
|
-
const valid = r2.component === "Asset" ? asset(r2) : r2.component === "Set" ? typeof r2.label === "string" && Array.isArray(r2.items) && r2.items.length > 0 && r2.items.length <= 500 && r2.items.every(asset) : r2.component === "Compare" ? source(r2.a) && source(r2.b) && (r2.shots === void 0 || source(r2.shots)) && optionalText(r2, ["a-label", "b-label"]) : r2.component === "Storyboard" && source(r2.src);
|
|
13082
|
-
if (!valid) return `/results/${i}`;
|
|
13083
|
-
}
|
|
13084
|
-
return null;
|
|
13085
|
-
}
|
|
13086
|
-
function reviewProblem(v) {
|
|
13087
|
-
if (!isObject(v) || v.version !== 2) return "/version";
|
|
13088
|
-
if (!text4(v.fingerprint)) return "/fingerprint";
|
|
13089
|
-
if (v.base !== null && !(isObject(v.base) && text4(v.base.id) && Number.isInteger(v.base.version) && Number(v.base.version) > 0 && text4(v.base.fingerprint))) return "/base";
|
|
13090
|
-
if (!Array.isArray(v.agents) || v.agents.length > 500) return "/agents";
|
|
13091
|
-
const agents = /* @__PURE__ */ new Set();
|
|
13092
|
-
for (const a2 of v.agents) {
|
|
13093
|
-
if (!isObject(a2) || !text4(a2.agent) || !/^[a-z][a-z0-9-]*$/.test(a2.agent) || agents.has(a2.agent) || !isObject(a2.title) || !text4(a2.title.en) || !optionalText(a2.title, ["zh"]) || !icon(a2.icon)) return "/agents";
|
|
13094
|
-
agents.add(a2.agent);
|
|
13095
|
-
}
|
|
13096
|
-
if (!Array.isArray(v.files) || v.files.length > 1e3) return "/files";
|
|
13097
|
-
const paths = /* @__PURE__ */ new Set();
|
|
13098
|
-
for (const f2 of v.files) {
|
|
13099
|
-
if (!isObject(f2) || !relativePath(f2.path) || paths.has(f2.path) || !(f2.before === null || source(f2.before)) || !(f2.after === null || source(f2.after)) || f2.before === null && f2.after === null || f2.diff !== void 0 && !source(f2.diff) || (f2.before === null || f2.after === null) && !f2.diff) return "/files";
|
|
13100
|
-
if (f2.path.startsWith("agents/") && !agents.has(f2.path.split("/")[1])) return "/files";
|
|
13101
|
-
paths.add(f2.path);
|
|
13102
|
-
}
|
|
13103
|
-
return resultProblem(v.results, agents);
|
|
13104
|
-
}
|
|
13105
|
-
var text4, source, icon, relativePath, optionalText, asset, parseReview, isReview;
|
|
13106
|
-
var init_studio2 = __esm({
|
|
13107
|
-
"../artifact-sdk/src/internal/format/studio.ts"() {
|
|
13108
|
-
"use strict";
|
|
13109
|
-
init_references();
|
|
13110
|
-
text4 = (v) => typeof v === "string" && v.length > 0;
|
|
13111
|
-
source = (v) => text4(v) && !/^(?:[a-z][\w+.-]*:|\/|#)|\\|[\u0000-\u001f]/i.test(v);
|
|
13112
|
-
icon = (v) => v === void 0 || typeof v === "string" || Array.isArray(v) && v.length > 0 && v.length <= 12 && v.every((p2) => isObject(p2) && text4(p2.d) && /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/.test(p2.d) && ["f", "s"].every((k2) => p2[k2] === void 0 || typeof p2[k2] === "string" && /^[kwcgopsmlry]$/.test(p2[k2])) && (p2.o === void 0 || p2.o === true) && (p2.w === void 0 || typeof p2.w === "number" && p2.w > 0 && p2.w <= 3));
|
|
13113
|
-
relativePath = (v) => source(v) && v.split("/").every((p2) => p2 && p2 !== "." && p2 !== "..");
|
|
13114
|
-
optionalText = (v, keys) => keys.every((k2) => v[k2] === void 0 || typeof v[k2] === "string");
|
|
13115
|
-
asset = (v) => isObject(v) && source(v.src) && optionalText(v, ["label", "alt"]) && (v.alt === void 0 || !/[<>]/.test(v.alt)) && (v.device === void 0 || v.device === "desktop" || v.device === "mobile") && (v.loop === void 0 || typeof v.loop === "boolean") && (v.variants === void 0 || isObject(v.variants) && Object.values(v.variants).every(source));
|
|
13116
|
-
parseReview = (v) => reviewProblem(v) ? null : v;
|
|
13117
|
-
isReview = (v) => isObject(v) && v.version === 2;
|
|
13118
|
-
}
|
|
13119
|
-
});
|
|
13120
|
-
|
|
13121
|
-
// ../artifact-sdk/src/internal/manifest.ts
|
|
13122
|
-
function typeOf(data, types) {
|
|
13123
|
-
const problem = (type) => type === "studio" && isReview(data) ? reviewProblem(data) : schemaProblem(manifestOf(type)?.schema, data);
|
|
13124
|
-
for (const type of types) if (!problem(type)) return { type };
|
|
13125
|
-
if (types.length !== 1) return { type: null };
|
|
13126
|
-
return { type: types[0], problem: `does not match ${types[0]} at ${problem(types[0])}` };
|
|
13127
|
-
}
|
|
13128
|
-
function mapJson(node, keys, at2, visit) {
|
|
13129
|
-
if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
|
|
13130
|
-
const [key, ...rest] = keys;
|
|
13131
|
-
if (Array.isArray(node)) {
|
|
13132
|
-
if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
|
|
13133
|
-
const i = Number(key);
|
|
13134
|
-
return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
|
|
13135
|
-
}
|
|
13136
|
-
if (!isObject2(node)) return node;
|
|
13137
|
-
const out = { ...node };
|
|
13138
|
-
for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
|
|
13139
|
-
return out;
|
|
13140
|
-
}
|
|
13141
|
-
function mapText(text6, rule, skipped, visit, includeRemote) {
|
|
13142
|
-
let out = "";
|
|
13143
|
-
let last = 0;
|
|
13144
|
-
for (const m of text6.matchAll(new RegExp(rule.text, "gid"))) {
|
|
13145
|
-
const span = m.indices?.[1];
|
|
13146
|
-
if (!span || m[1] === void 0 || skipped.some(([a2, b2]) => span[0] >= a2 && span[0] < b2)) continue;
|
|
13147
|
-
const line = text6.slice(0, span[0]).split("\n").length;
|
|
13148
|
-
const one = (src) => remote(src) && !includeRemote ? src : visit(src, line);
|
|
13149
|
-
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]);
|
|
13150
|
-
out += text6.slice(last, span[0]) + value;
|
|
13151
|
-
last = span[1];
|
|
13152
|
-
}
|
|
13153
|
-
return out + text6.slice(last);
|
|
13154
|
-
}
|
|
13155
|
-
function mapReferences(manifest, content, map2, includeRemote = false) {
|
|
13156
|
-
const skipped = (text6) => (manifest?.skip ?? []).flatMap((re3) => [...text6.matchAll(new RegExp(re3, "gi"))].map((m) => [m.index, m.index + m[0].length]));
|
|
13157
|
-
for (const rule of manifest?.references ?? []) {
|
|
13158
|
-
const types = rule.types ?? [];
|
|
13159
|
-
if ("json" in rule) {
|
|
13160
|
-
if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
|
|
13161
|
-
} else if (typeof content === "string") {
|
|
13162
|
-
content = mapText(content, rule, skipped(content), (src, line) => map2(src, { src, types, text: true, line }), includeRemote);
|
|
13163
|
-
}
|
|
13164
|
-
}
|
|
13165
|
-
return content;
|
|
13166
|
-
}
|
|
13167
|
-
function referencesOf(manifest, content, includeRemote = false) {
|
|
13168
|
-
const found2 = [];
|
|
13169
|
-
mapReferences(manifest, content, (src, ref) => (found2.push(ref), src), includeRemote);
|
|
13170
|
-
return found2;
|
|
13171
|
-
}
|
|
13172
|
-
var BUILTINS, manifestOf, isObject2, remote;
|
|
13173
|
-
var init_manifest = __esm({
|
|
13174
|
-
"../artifact-sdk/src/internal/manifest.ts"() {
|
|
13175
|
-
"use strict";
|
|
13176
|
-
init_builtin();
|
|
13177
|
-
init_schema();
|
|
13178
|
-
init_studio2();
|
|
13179
|
-
BUILTINS = builtin_default;
|
|
13180
|
-
manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
|
|
13181
|
-
isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
13182
|
-
remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
|
|
13183
|
-
}
|
|
13184
|
-
});
|
|
13185
|
-
|
|
13186
13223
|
// ../artifact-sdk/src/internal/collect.ts
|
|
13187
13224
|
function collect(body, card, host2) {
|
|
13188
13225
|
return collectSources(bodyReferences(body), card, host2);
|
|
@@ -13282,7 +13319,7 @@ var init_collect = __esm({
|
|
|
13282
13319
|
textKind = (ext, types) => types.find((t) => {
|
|
13283
13320
|
const m = manifestOf(t);
|
|
13284
13321
|
return m && !m.schema;
|
|
13285
|
-
}) ??
|
|
13322
|
+
}) ?? kindOf(ext);
|
|
13286
13323
|
kindAt = (src, types) => extOf(src) === ".json" ? types.includes("asset") ? "asset" : types[0] ?? "asset" : textKind(extOf(src), types);
|
|
13287
13324
|
}
|
|
13288
13325
|
});
|
|
@@ -13692,8 +13729,8 @@ var init_spec_contract = __esm({
|
|
|
13692
13729
|
init_cards();
|
|
13693
13730
|
init_frontmatter();
|
|
13694
13731
|
init_paths();
|
|
13695
|
-
|
|
13696
|
-
|
|
13732
|
+
init_compare2();
|
|
13733
|
+
init_storyboard2();
|
|
13697
13734
|
init_preview_files();
|
|
13698
13735
|
init_validate();
|
|
13699
13736
|
ASSET_LINE = /^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/;
|
|
@@ -17917,7 +17954,18 @@ import path65 from "node:path";
|
|
|
17917
17954
|
import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
|
|
17918
17955
|
function readPreviewProgress(id) {
|
|
17919
17956
|
try {
|
|
17920
|
-
|
|
17957
|
+
const all2 = JSON.parse(fs62.readFileSync(file(id), "utf8"));
|
|
17958
|
+
if (!runnerProject(KANBAN) && !process.env[PREVIEW_BRIDGE_ENV]) {
|
|
17959
|
+
const body = findCard(id)?.body ?? "";
|
|
17960
|
+
for (const [name, progress] of Object.entries(all2)) {
|
|
17961
|
+
const section = previewSection(body, name);
|
|
17962
|
+
try {
|
|
17963
|
+
syncPreviewContent(progress, section, localPreviewAssets(id, section));
|
|
17964
|
+
} catch {
|
|
17965
|
+
}
|
|
17966
|
+
}
|
|
17967
|
+
}
|
|
17968
|
+
return all2;
|
|
17921
17969
|
} catch (error) {
|
|
17922
17970
|
if (error.code === "ENOENT") return {};
|
|
17923
17971
|
throw error;
|
|
@@ -17928,6 +17976,7 @@ function updatePreviewProgress(id, change2) {
|
|
|
17928
17976
|
return withLock(`${file(id)}.lock`, "updating preview progress", () => {
|
|
17929
17977
|
const all2 = readPreviewProgress(id);
|
|
17930
17978
|
const result = change2(all2);
|
|
17979
|
+
if (!runnerProject(KANBAN) && !process.env[PREVIEW_BRIDGE_ENV]) freezeLocalAssets(id, all2);
|
|
17931
17980
|
const temp = `${file(id)}.${process.pid}.tmp`;
|
|
17932
17981
|
fs62.writeFileSync(temp, JSON.stringify(all2) + "\n");
|
|
17933
17982
|
fs62.renameSync(temp, file(id));
|
|
@@ -17961,13 +18010,13 @@ Select with: ${command} raw previews ${name} ${id} --stages <id,...>.`;
|
|
|
17961
18010
|
const current = progress.stages.find((stage) => stage.id === progress.currentStageId);
|
|
17962
18011
|
if (!current) return `Saved stages: ${JSON.stringify(progress.stages)}
|
|
17963
18012
|
Select with: ${command} raw previews ${name} ${id} --stages <id,...>.`;
|
|
17964
|
-
if (
|
|
18013
|
+
if (["awaiting_confirmation", "ready", "confirmed"].includes(current.status)) return "The current preview is awaiting user review. Stop and wait for approval before starting the next stage; do not poll.";
|
|
17965
18014
|
return [
|
|
17966
18015
|
`Selected stages: ${progress.stages.map((stage) => stage.id).join(", ")}. Current stage: ${current.id}.`,
|
|
17967
18016
|
progress.files[current.instructions] === progress.body ? "" : progress.files[current.instructions],
|
|
17968
18017
|
...progress.stages.filter((stage) => stage.status === "confirmed").map((stage) => `Confirmed ${stage.id} v${stage.version}:
|
|
17969
18018
|
${stage.artifact?.body ?? ""}`),
|
|
17970
|
-
`
|
|
18019
|
+
`Report completion with: ${command} raw previews ${name} ${id} --stage ${current.id} --status done. Stop and wait for user approval before starting the next stage.`
|
|
17971
18020
|
].join("\n\n");
|
|
17972
18021
|
}
|
|
17973
18022
|
function previewOwner(id, name, inside2 = insideRun()) {
|
|
@@ -18025,28 +18074,6 @@ function previewSection(body, name) {
|
|
|
18025
18074
|
const end2 = lines.findIndex((line, index) => index > start && (/^## /.test(line) || line.trim() === "<!-- agent -->"));
|
|
18026
18075
|
return lines.slice(start + 1, end2 < 0 ? void 0 : end2).join("\n").trim();
|
|
18027
18076
|
}
|
|
18028
|
-
function submitLocalPreview(id, name, stage, baseline) {
|
|
18029
|
-
const run4 = previewRun(id, name);
|
|
18030
|
-
const card = findCard(id);
|
|
18031
|
-
if (!card) throw Error("The task is no longer open.");
|
|
18032
|
-
const body = previewSection(card.body, name);
|
|
18033
|
-
const snapshot2 = randomUUID6();
|
|
18034
|
-
const source2 = path65.join(ASSETS, String(id));
|
|
18035
|
-
const dest = path65.join(BOARD_STATE, "previews", "assets", String(id), snapshot2);
|
|
18036
|
-
if (fs62.existsSync(source2) && fs62.lstatSync(source2).isSymbolicLink()) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18037
|
-
if (fs62.existsSync(source2)) fs62.cpSync(source2, dest, { recursive: true, dereference: true, filter: (file2) => {
|
|
18038
|
-
const real2 = fs62.realpathSync(file2);
|
|
18039
|
-
if (real2 !== fs62.realpathSync(source2) && !real2.startsWith(fs62.realpathSync(source2) + path65.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18040
|
-
return true;
|
|
18041
|
-
} });
|
|
18042
|
-
return updatePreviewProgress(id, (all2) => {
|
|
18043
|
-
const progress = all2[name];
|
|
18044
|
-
if (!progress) throw Error("Select the stages first.");
|
|
18045
|
-
const base = baseline ?? readPreviewBaseline(id, name, run4.sessionId);
|
|
18046
|
-
if (base.stageId !== stage) throw Error("Wrong stage.");
|
|
18047
|
-
return submitPreviewStage(progress, base, body, { folder: dest });
|
|
18048
|
-
});
|
|
18049
|
-
}
|
|
18050
18077
|
function savePreviewBaseline(id, name, run4, baseline) {
|
|
18051
18078
|
writeJson2(baselineFile(id, name, run4), baseline);
|
|
18052
18079
|
}
|
|
@@ -18083,10 +18110,83 @@ function frozenPreviewFile(agent, relative) {
|
|
|
18083
18110
|
if (run4?.action !== "spec" || run4.specAgent !== agent || run4.cardId === null) return void 0;
|
|
18084
18111
|
return readPreviewProgress(run4.cardId)[agent]?.files[relative];
|
|
18085
18112
|
}
|
|
18113
|
+
function reportLocalPreview(id, name, stage, status) {
|
|
18114
|
+
const run4 = previewRun(id, name);
|
|
18115
|
+
return updatePreviewProgress(id, (all2) => {
|
|
18116
|
+
const progress = all2[name];
|
|
18117
|
+
if (!progress || progress.execution !== run4.sessionId) throw Error("This execution is outdated. Reload the task.");
|
|
18118
|
+
const baseline = reportPreviewStage(progress, stage, "running", run4.sessionId);
|
|
18119
|
+
const body = previewSection(findCard(id)?.body ?? "", name);
|
|
18120
|
+
const assets = localPreviewAssets(id, body);
|
|
18121
|
+
syncPreviewContent(progress, body, assets);
|
|
18122
|
+
reportPreviewStage(progress, stage, status, run4.sessionId);
|
|
18123
|
+
savePreviewBaseline(id, name, run4.sessionId, baseline);
|
|
18124
|
+
return progress;
|
|
18125
|
+
});
|
|
18126
|
+
}
|
|
18127
|
+
function localPreviewAssets(id, body) {
|
|
18128
|
+
const assets = {};
|
|
18129
|
+
const taskRoot = path65.join(ASSETS, String(id));
|
|
18130
|
+
const visit = (src) => {
|
|
18131
|
+
if (src in assets || /^[a-z][\w+.-]*:/i.test(src)) return;
|
|
18132
|
+
const file2 = path65.resolve(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18133
|
+
if (!file2.startsWith(taskRoot + path65.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18134
|
+
if (!fs62.existsSync(file2)) {
|
|
18135
|
+
assets[src] = null;
|
|
18136
|
+
return;
|
|
18137
|
+
}
|
|
18138
|
+
if (fs62.lstatSync(taskRoot).isSymbolicLink()) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18139
|
+
const real2 = fs62.realpathSync(file2);
|
|
18140
|
+
if (!real2.startsWith(fs62.realpathSync(taskRoot) + path65.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18141
|
+
const bytes2 = fs62.readFileSync(real2);
|
|
18142
|
+
assets[src] = createHash5("sha256").update(bytes2).digest("hex");
|
|
18143
|
+
const manifest = manifestOf(kindOf(path65.extname(file2)));
|
|
18144
|
+
let content = bytes2.toString();
|
|
18145
|
+
if (manifest?.references?.some((ref) => "json" in ref)) {
|
|
18146
|
+
try {
|
|
18147
|
+
content = JSON.parse(content);
|
|
18148
|
+
} catch {
|
|
18149
|
+
return;
|
|
18150
|
+
}
|
|
18151
|
+
}
|
|
18152
|
+
for (const ref of referencesOf(manifest, content)) {
|
|
18153
|
+
if (/^[a-z][\w+.-]*:/i.test(ref.src)) continue;
|
|
18154
|
+
visit(path65.posix.normalize(path65.posix.join(path65.posix.dirname(src), ref.src)));
|
|
18155
|
+
}
|
|
18156
|
+
};
|
|
18157
|
+
for (const ref of bodyReferences(body)) if (ref.src.startsWith(".assets/") || fs62.existsSync(path65.join(ASSETS, ref.src))) visit(ref.src);
|
|
18158
|
+
return assets;
|
|
18159
|
+
}
|
|
18160
|
+
function freezeLocalAssets(id, all2) {
|
|
18161
|
+
for (const progress of Object.values(all2)) for (const stage of progress.stages) {
|
|
18162
|
+
const artifact = stage.artifact;
|
|
18163
|
+
if (!artifact || artifact.localAssets) continue;
|
|
18164
|
+
const pinned2 = {};
|
|
18165
|
+
for (const [src, hash2] of Object.entries(artifact.assets)) {
|
|
18166
|
+
if (typeof hash2 !== "string") continue;
|
|
18167
|
+
const file2 = path65.join(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18168
|
+
if (!fs62.existsSync(file2)) continue;
|
|
18169
|
+
const root2 = path65.join(ASSETS, String(id));
|
|
18170
|
+
if (fs62.lstatSync(root2).isSymbolicLink() || !fs62.realpathSync(file2).startsWith(fs62.realpathSync(root2) + path65.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18171
|
+
if (createHash5("sha256").update(fs62.readFileSync(file2)).digest("hex") !== hash2) continue;
|
|
18172
|
+
const frozen = path65.join(BOARD_STATE, "previews", "assets", String(id), stage.id, String(progress.generation), String(artifact.version), hash2, src.replace(/^\.assets\//, ""));
|
|
18173
|
+
fs62.mkdirSync(path65.dirname(frozen), { recursive: true });
|
|
18174
|
+
if (!fs62.existsSync(frozen)) fs62.copyFileSync(file2, frozen, fs62.constants.COPYFILE_EXCL);
|
|
18175
|
+
pinned2[src] = frozen;
|
|
18176
|
+
}
|
|
18177
|
+
artifact.localAssets = pinned2;
|
|
18178
|
+
for (const saved of stage.history ?? []) if (saved.version === artifact.version) saved.localAssets = pinned2;
|
|
18179
|
+
if (progress.displayedArtifact?.stageId === stage.id && progress.displayedArtifact.version === artifact.version) progress.displayedArtifact.localAssets = pinned2;
|
|
18180
|
+
}
|
|
18181
|
+
}
|
|
18086
18182
|
var file, contextFile, PreviewContextMissing, baselineFile;
|
|
18087
18183
|
var init_preview_progress = __esm({
|
|
18088
18184
|
"../cli/src/lib/agent/preview-progress.ts"() {
|
|
18089
18185
|
"use strict";
|
|
18186
|
+
init_references();
|
|
18187
|
+
init_manifest();
|
|
18188
|
+
init_tasks();
|
|
18189
|
+
init_paths();
|
|
18090
18190
|
init_paths();
|
|
18091
18191
|
init_lock();
|
|
18092
18192
|
init_agents();
|
|
@@ -18098,6 +18198,7 @@ var init_preview_progress = __esm({
|
|
|
18098
18198
|
init_cards();
|
|
18099
18199
|
init_frontmatter();
|
|
18100
18200
|
init_execution();
|
|
18201
|
+
init_preview();
|
|
18101
18202
|
init_preview_stages();
|
|
18102
18203
|
file = (id) => path65.join(BOARD_STATE, "previews", `${id}.json`);
|
|
18103
18204
|
contextFile = (id, name, owner) => path65.join(BOARD_STATE, "previews", "contexts", String(id), name, `${createHash5("sha256").update(owner).digest("hex")}.json`);
|
|
@@ -30980,8 +31081,8 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
30980
31081
|
say(specAgentList(program2, !insideRun()));
|
|
30981
31082
|
return { agents: specAgentNamesOnBoard(), problems: specAgentProblems() };
|
|
30982
31083
|
}
|
|
30983
|
-
if ([opts.
|
|
30984
|
-
if (opts.submit && !opts.stage || opts.
|
|
31084
|
+
if ([opts.stage !== void 0, opts.stages !== void 0, opts.reviseFrom, opts.resetStages].filter(Boolean).length > 1) die("Choose one stage operation.", { kind: "invalid-usage" });
|
|
31085
|
+
if (opts.submit && !opts.stage || opts.status && !opts.stage || opts.status && !["running", "done"].includes(opts.status)) die("Use --stage <id> [--status running|done].", { kind: "invalid-usage" });
|
|
30985
31086
|
const askedName = opts.agent.trim();
|
|
30986
31087
|
const agent = findSpecAgent(askedName);
|
|
30987
31088
|
if (!agent) die(notAnAgent(askedName), { kind: "no-such-spec-agent", specAgent: askedName });
|
|
@@ -30991,7 +31092,7 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
30991
31092
|
die(`say which card: ${program2} raw previews ${name} <id> [note]`, { kind: "needs-input" });
|
|
30992
31093
|
}
|
|
30993
31094
|
if (!locate2(id)) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
30994
|
-
if (opts.stages !== void 0 || opts.
|
|
31095
|
+
if (opts.stages !== void 0 || opts.stage || opts.reviseFrom) {
|
|
30995
31096
|
try {
|
|
30996
31097
|
let run5;
|
|
30997
31098
|
try {
|
|
@@ -31002,7 +31103,7 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
31002
31103
|
run5 = previewRun(id, name);
|
|
31003
31104
|
}
|
|
31004
31105
|
const ids = opts.stages?.split(",").map((id2) => id2.trim());
|
|
31005
|
-
const result = await previewBridge(name, ids ? "select" : opts.reviseFrom ? "revise" : "submit", { run: run5.sessionId, cardId: id, ...ids ? { stages: ids } : opts.reviseFrom ? { stageId: opts.reviseFrom } : { baseline: readPreviewBaseline(id, name, run5.sessionId), stageId: opts.stage } });
|
|
31106
|
+
const result = await previewBridge(name, ids ? "select" : opts.reviseFrom ? "revise" : opts.submit ? "submit" : "status", { run: run5.sessionId, cardId: id, ...ids ? { stages: ids } : opts.reviseFrom ? { stageId: opts.reviseFrom } : { ...opts.submit ? { baseline: readPreviewBaseline(id, name, run5.sessionId) } : {}, stageId: opts.stage, status: opts.submit ? "done" : opts.status ?? "running" } });
|
|
31006
31107
|
if (result?.progress) {
|
|
31007
31108
|
updatePreviewProgress(id, (all2) => {
|
|
31008
31109
|
all2[name] = result.progress;
|
|
@@ -31010,17 +31111,18 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
31010
31111
|
if (result.baseline) savePreviewBaseline(id, name, run5.sessionId, result.baseline);
|
|
31011
31112
|
} else if (opts.reviseFrom) {
|
|
31012
31113
|
updatePreviewProgress(id, (all2) => {
|
|
31013
|
-
const
|
|
31014
|
-
choosePreviewRevision(
|
|
31015
|
-
savePreviewBaseline(id, name, run5.sessionId, previewBaseline(
|
|
31114
|
+
const progress2 = all2[name];
|
|
31115
|
+
choosePreviewRevision(progress2, opts.reviseFrom, run5.sessionId);
|
|
31116
|
+
savePreviewBaseline(id, name, run5.sessionId, previewBaseline(progress2, opts.reviseFrom, run5.sessionId));
|
|
31016
31117
|
});
|
|
31017
31118
|
} else if (ids) {
|
|
31018
31119
|
const selected = selectLocalPreview(id, name, ids);
|
|
31019
31120
|
savePreviewBaseline(id, name, run5.sessionId, selected.baseline);
|
|
31020
|
-
} else
|
|
31021
|
-
|
|
31022
|
-
|
|
31023
|
-
|
|
31121
|
+
} else reportLocalPreview(id, name, opts.stage, opts.submit ? "done" : opts.status ?? "running");
|
|
31122
|
+
say(previewStagePrompt(id, name, boardCommandFor(id)));
|
|
31123
|
+
const progress = readPreviewProgress(id)[name];
|
|
31124
|
+
const at2 = progress.stages.findIndex((stage) => stage.id === progress.currentStageId);
|
|
31125
|
+
return { specAgent: name, cardId: id, currentStageId: progress.currentStageId, status: ["awaiting_confirmation", "ready", "confirmed"].includes(progress.stages[at2]?.status) ? "done" : "running", position: at2 + 1, title: progress.stages[at2]?.title, instructions: progress.stages[at2]?.status === "running" ? progress.files[progress.stages[at2].instructions] : void 0, submitted: !!opts.submit };
|
|
31024
31126
|
} catch (error) {
|
|
31025
31127
|
die(error instanceof Error ? error.message : "Preview submission failed.", { kind: "preview-refused" });
|
|
31026
31128
|
}
|
|
@@ -115753,7 +115855,7 @@ function declareRaw(program2, cli) {
|
|
|
115753
115855
|
groups.delivery.addHelpText("after", HELP_AFTER.deliveries(cli.program));
|
|
115754
115856
|
withShared(program2.command("previews")).argument("[agent]", "which preview agent; left off, the agents this board has are listed").argument("[id]", "the card to put it on", cardId).argument("[note...]", "what the flow wants looked at").summary("put a preview agent on a card; bare, list the preview agents this board has").description(
|
|
115755
115857
|
"Fill one part of a card spec. Use --print to follow the specialist instructions in the current session. Without --print, start a separate run; inside a board run, queue it until that run ends."
|
|
115756
|
-
).option("-f, --follow", "watch its log instead of returning").option("--notes <text>", "what the flow wants looked at, for a caller building a command").option("--print", "print specialist instructions and work in this session").option("--reset-stages", "explicitly change the preview scope and choose its stages again").option("--revise-from <id>", "start the requested revision at its earliest affected stage").option("--stages <ids>", "save this preview agent\u2019s ordered stage selection").option("--
|
|
115858
|
+
).option("-f, --follow", "watch its log instead of returning").option("--notes <text>", "what the flow wants looked at, for a caller building a command").option("--print", "print specialist instructions and work in this session").option("--reset-stages", "explicitly change the preview scope and choose its stages again").option("--revise-from <id>", "start the requested revision at its earliest affected stage").option("--stages <ids>", "save this preview agent\u2019s ordered stage selection").option("--status <status>", "report running or done for the current stage").addOption(new Option("--submit").hideHelp()).option("--stage <id>", "the authorized stage to work on").option("--events", "with --follow: print structured events").option("--continue", "continue the saved preview stage").option("--triggers", "list agent names and trigger conditions without starting a run").option("--studio <id>", "only enabled preview agents of this studio").option("--workspace <id>", "the workspace whose studios to query").addHelpText("after", `
|
|
115757
115859
|
List trigger conditions: ${raw} previews --triggers --json`).action(async function(...vals) {
|
|
115758
115860
|
const [agent, id, note] = positional(vals);
|
|
115759
115861
|
const opts = this.opts();
|