kaizen-agent 1.79.1 → 1.80.0
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/cli/hermes.ts +20 -0
- package/cli/install.ts +20 -1
- package/cli/localsend.ts +61 -4
- package/cli/report.ts +7 -4
- package/cli/settings.ts +2 -8
- package/cli/state.ts +19 -3
- package/cli/task-results.ts +133 -0
- package/cli/task-service.ts +180 -0
- package/cli/tasks.ts +201 -0
- package/cli/ui-audit.allow.json +6 -0
- package/cli/ui-audit.ts +427 -0
- package/cli/web.ts +72 -1
- package/cli/whatsapp.ts +112 -0
- package/package.json +2 -1
- package/skills/kaizen/SKILL.md +4 -0
- package/skills/kaizen/adapters.md +4 -0
- package/skills/kaizen/spec-build.md +5 -1
- package/skills/kaizen/spec-main.md +4 -0
- package/skills/kaizen/spec-plan.md +4 -0
- package/skills/kaizen/spec-review.md +4 -0
- package/skills/kaizen/spec.md +52 -0
- package/web/board/add-project.ts +1 -1
- package/web/board/badge.ts +70 -8
- package/web/board/cards.ts +4 -2
- package/web/board/dom.ts +10 -0
- package/web/board/icebox.ts +2 -2
- package/web/board/keys.ts +1 -1
- package/web/board/live.ts +9 -5
- package/web/board/phone.ts +4 -3
- package/web/board/rich.ts +4 -2
- package/web/board/run-view.ts +16 -14
- package/web/board/settings-automations.ts +2 -2
- package/web/board/settings-skills.ts +2 -2
- package/web/board/settings.ts +12 -14
- package/web/board/task-page.ts +672 -0
- package/web/board/task-results.ts +235 -0
- package/web/board/tasks.ts +214 -200
- package/web/board/terms.ts +17 -2
- package/web/board/views.ts +35 -9
- package/web/board/whatsapp-setup.ts +137 -0
- package/web/board/workspace.ts +24 -2
- package/web/board.html +57 -35
- package/web/board.js +403 -142
- package/web/notebook.js +388 -153
- package/web/notes.html +16 -11
- package/web/term.js +1 -1
- package/web/video.html +22 -11
- package/web/video.js +415 -180
- package/web/video.ts +5 -5
- package/web/board/new-agent.ts +0 -20
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// Typed task outputs. Only server-issued artifact routes are embedded; live URLs are
|
|
2
|
+
// separate, mutable references and active HTML/SVG files remain downloads.
|
|
3
|
+
import { html, raw, type Safe } from "./dom.ts";
|
|
4
|
+
|
|
5
|
+
export type TaskArtifact = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
mediaType?: string;
|
|
10
|
+
preview?: string | boolean;
|
|
11
|
+
url?: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
missing?: boolean;
|
|
14
|
+
source?: string;
|
|
15
|
+
};
|
|
16
|
+
export type TaskResult = {
|
|
17
|
+
id: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
summary?: string;
|
|
20
|
+
createdAt?: number | string;
|
|
21
|
+
artifacts: TaskArtifact[];
|
|
22
|
+
checks?: (string | { label?: string; outcome?: string; evidence?: string })[];
|
|
23
|
+
limitations?: string[];
|
|
24
|
+
liveUrl?: string;
|
|
25
|
+
storedSize?: number;
|
|
26
|
+
size?: number;
|
|
27
|
+
};
|
|
28
|
+
export const webUrl = (value: unknown) => {
|
|
29
|
+
try {
|
|
30
|
+
const u = new URL(String(value));
|
|
31
|
+
return ["http:", "https:"].includes(u.protocol) && !u.username && !u.password ? u.href : null;
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const storedUrl = (value: unknown) =>
|
|
37
|
+
typeof value === "string" && /^\/task-artifact(?:\?|\/)/.test(value) && !value.includes("\\") && !/[\r\n]/.test(value)
|
|
38
|
+
? value
|
|
39
|
+
: null;
|
|
40
|
+
export const sizeLabel = (n?: number) =>
|
|
41
|
+
n == null
|
|
42
|
+
? ""
|
|
43
|
+
: n < 1024
|
|
44
|
+
? `${n} B`
|
|
45
|
+
: n < 1024 * 1024
|
|
46
|
+
? `${(n / 1024).toFixed(1)} KB`
|
|
47
|
+
: `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
48
|
+
export function artifactView(a: TaskArtifact, selected = false): Safe {
|
|
49
|
+
const url = storedUrl(a.url),
|
|
50
|
+
live = a.kind === "website" || a.kind === "app" || a.kind === "link" || a.kind === "live";
|
|
51
|
+
const href = live ? webUrl(a.url) : url;
|
|
52
|
+
const active =
|
|
53
|
+
/^(?:text\/(?:html|javascript|xml)|application\/(?:javascript|xml|xhtml\+xml)|image\/svg\+xml)(?:;|$)/i.test(
|
|
54
|
+
a.mediaType ?? "",
|
|
55
|
+
) || /\.(html?|svg|m?js|xml)$/i.test(a.name);
|
|
56
|
+
let view: Safe | string = "";
|
|
57
|
+
if (a.missing || !href)
|
|
58
|
+
view = html`<p class="tp-limit">
|
|
59
|
+
${a.missing ? "This saved file is unavailable." : "No preview is available for this output."} Ask for the file
|
|
60
|
+
again or inspect the technical details.
|
|
61
|
+
</p>`;
|
|
62
|
+
else if (selected && live)
|
|
63
|
+
view = html`<p class="tp-limit">Live preview — this address can change during later work.</p>
|
|
64
|
+
<iframe
|
|
65
|
+
class="tp-web"
|
|
66
|
+
data-live-url="${href}"
|
|
67
|
+
title="Live preview of ${a.name}"
|
|
68
|
+
sandbox="allow-forms allow-scripts allow-popups"
|
|
69
|
+
referrerpolicy="no-referrer"
|
|
70
|
+
></iframe>
|
|
71
|
+
<p class="dim" data-live-status>Checking preview availability… You can also use Open link.</p>`;
|
|
72
|
+
else if (selected && !active && a.preview !== false && a.preview !== "download" && a.preview !== "none") {
|
|
73
|
+
if (/^image\//.test(a.mediaType ?? "") || a.kind === "image" || a.kind === "screenshot")
|
|
74
|
+
view = html`<img class="tp-image" src="${href}" alt="${a.name}" loading="lazy" />`;
|
|
75
|
+
else if (/^video\//.test(a.mediaType ?? "") || a.kind === "video")
|
|
76
|
+
view = html`<video class="tp-media" controls preload="metadata" src="${href}">
|
|
77
|
+
Download this video to watch it.
|
|
78
|
+
</video>`;
|
|
79
|
+
else if (/^audio\//.test(a.mediaType ?? "") || a.kind === "audio")
|
|
80
|
+
view = html`<audio class="tp-media" controls preload="metadata" src="${href}">
|
|
81
|
+
Download this audio to listen.
|
|
82
|
+
</audio>`;
|
|
83
|
+
else if (a.mediaType === "application/pdf" || a.kind === "pdf")
|
|
84
|
+
view = html`<iframe class="tp-document" src="${href}" title="${a.name}" sandbox></iframe>
|
|
85
|
+
<p class="dim">Your browser may need you to download this PDF.</p>`;
|
|
86
|
+
else if (/^text\//.test(a.mediaType ?? "") || ["text", "markdown", "document"].includes(a.kind))
|
|
87
|
+
view = html`<pre class="tp-text" data-text-artifact="${href}" aria-label="${a.name}">Loading saved text…</pre>`;
|
|
88
|
+
else view = html`<p class="dim">Preview is unavailable for this format. Download to open it in your app.</p>`;
|
|
89
|
+
} else if (selected && active)
|
|
90
|
+
view = html`<p class="dim">
|
|
91
|
+
Download this file to open it. Executable files are kept separate from this task page.
|
|
92
|
+
</p>`;
|
|
93
|
+
return html`<section class="tp-artifact">
|
|
94
|
+
<div class="tp-artifact-head">
|
|
95
|
+
<span
|
|
96
|
+
>${a.name}<small
|
|
97
|
+
>${live ? "Live link · mutable" : "Saved file"}${a.size != null ? " · " + sizeLabel(a.size) : ""}</small
|
|
98
|
+
></span
|
|
99
|
+
>${href ? html`<a class="btn" href="${live ? href : href + (href.includes("?") ? "&" : "?") + "download=1"}" target="_blank" rel="noopener noreferrer" ${live ? "" : raw(` download`)}>${live ? "Open link" : "Download"}</a>` : ""}
|
|
100
|
+
</div>
|
|
101
|
+
${view}
|
|
102
|
+
</section>`;
|
|
103
|
+
}
|
|
104
|
+
export function resultView(result: TaskResult | undefined, artifactId?: string): Safe {
|
|
105
|
+
if (!result)
|
|
106
|
+
return html`<div class="tp-result-empty">
|
|
107
|
+
<h3>Your result will appear here</h3>
|
|
108
|
+
<p>Answer any questions in the conversation. You will confirm a short proposal before production starts.</p>
|
|
109
|
+
</div>`;
|
|
110
|
+
const artifacts = result.artifacts ?? [],
|
|
111
|
+
selected = artifacts.find((a) => a.id === artifactId) ?? artifacts[0];
|
|
112
|
+
return html`<header class="tp-result-heading">
|
|
113
|
+
<h2>${result.title || "Result"}</h2>
|
|
114
|
+
<p>${result.summary || ""}</p>
|
|
115
|
+
${result.createdAt ? html`<small class="dim">Saved ${new Date(result.createdAt).toLocaleString()}${(result.storedSize ?? result.size) != null ? " · " + sizeLabel(result.storedSize ?? result.size) + " preserved" : ""}</small>` : ""}
|
|
116
|
+
</header>
|
|
117
|
+
${artifacts.length > 1 ? html`<div class="tp-output-tabs" role="group" aria-label="Outputs">${artifacts.map((a) => html`<button class="tk-chip${a.id === selected?.id ? " on" : ""}" type="button" data-artifact="${a.id}" aria-pressed="${String(a.id === selected?.id)}">${a.name}</button>`)}</div>` : ""}${selected ? artifactView(selected, true) : html`<p class="tp-limit">No saved file was published for this result.</p>`}${result.liveUrl && !artifacts.some((a) => a.url === result.liveUrl) && webUrl(result.liveUrl) ? artifactView({ id: "live", name: "Live website", kind: "website", url: result.liveUrl }, true) : ""}
|
|
118
|
+
<section class="tp-checks">
|
|
119
|
+
<h3>Checks and limits</h3>
|
|
120
|
+
${
|
|
121
|
+
result.checks?.length
|
|
122
|
+
? html`<ul>
|
|
123
|
+
${result.checks.map((c) => html`<li>${typeof c === "string" ? c : [c.label, c.outcome, c.evidence].filter(Boolean).join(" — ")}</li>`)}
|
|
124
|
+
</ul>`
|
|
125
|
+
: html`<p>No verification evidence has been published.</p>`
|
|
126
|
+
}${
|
|
127
|
+
result.limitations?.length
|
|
128
|
+
? html`<ul>
|
|
129
|
+
${result.limitations.map((l) => html`<li>${l}</li>`)}
|
|
130
|
+
</ul>`
|
|
131
|
+
: ""
|
|
132
|
+
}
|
|
133
|
+
<p class="dim">Accepting a result does not publish it. A preview alone does not prove that a backend works.</p>
|
|
134
|
+
</section>`;
|
|
135
|
+
}
|
|
136
|
+
export async function loadTextArtifacts(box: HTMLElement) {
|
|
137
|
+
await Promise.all(
|
|
138
|
+
[...box.querySelectorAll<HTMLElement>("[data-text-artifact]")].map(async (el) => {
|
|
139
|
+
try {
|
|
140
|
+
const r = await fetch(el.dataset.textArtifact!);
|
|
141
|
+
if (!r.ok) throw new Error();
|
|
142
|
+
const value = await r.text();
|
|
143
|
+
if (el.isConnected)
|
|
144
|
+
el.textContent =
|
|
145
|
+
value.length > 1_000_000
|
|
146
|
+
? value.slice(0, 1_000_000) + "\nPreview shortened. Download for the whole file."
|
|
147
|
+
: value;
|
|
148
|
+
} catch {
|
|
149
|
+
if (el.isConnected) el.textContent = "The saved file could not be read. Try Download or refresh the task.";
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The workspace already checks frame headers and exposes local development ports
|
|
156
|
+
// for remote devices. Task previews use those same services, with an opaque sandbox.
|
|
157
|
+
export async function loadLiveArtifacts(box: HTMLElement) {
|
|
158
|
+
await Promise.all(
|
|
159
|
+
[...box.querySelectorAll<HTMLIFrameElement>("iframe[data-live-url]")].map(async (frame) => {
|
|
160
|
+
if (frame.dataset.checked) return;
|
|
161
|
+
frame.dataset.checked = "1";
|
|
162
|
+
const original = webUrl(frame.dataset.liveUrl),
|
|
163
|
+
section = frame.closest(".tp-artifact")!;
|
|
164
|
+
const note = section.querySelector<HTMLElement>("[data-live-status]")!,
|
|
165
|
+
link = section.querySelector<HTMLAnchorElement>("a")!;
|
|
166
|
+
if (!original) {
|
|
167
|
+
frame.hidden = true;
|
|
168
|
+
note.textContent = "The preview address is unavailable.";
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
let url = original;
|
|
172
|
+
try {
|
|
173
|
+
const response = await fetch("/frameable?url=" + encodeURIComponent(original));
|
|
174
|
+
const check = await response.json();
|
|
175
|
+
if (!frame.isConnected) return;
|
|
176
|
+
if (check.frameable === false) {
|
|
177
|
+
frame.hidden = true;
|
|
178
|
+
note.textContent = "This site refuses to appear inside kaizen. Use Open link to view it in another tab.";
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
} catch {
|
|
182
|
+
note.textContent = "Preview availability could not be checked. Use Open link if it does not appear.";
|
|
183
|
+
}
|
|
184
|
+
const local = /^(localhost|127\.0\.0\.1|\[::1\])$/;
|
|
185
|
+
if (local.test(new URL(original).hostname) && !local.test(location.hostname)) {
|
|
186
|
+
frame.hidden = true;
|
|
187
|
+
note.textContent = "Opening this computer’s preview for this device…";
|
|
188
|
+
try {
|
|
189
|
+
const response = await fetch("/expose", {
|
|
190
|
+
method: "POST",
|
|
191
|
+
headers: { "content-type": "application/json" },
|
|
192
|
+
body: JSON.stringify({ url: original }),
|
|
193
|
+
});
|
|
194
|
+
const exposed = await response.json();
|
|
195
|
+
if (!frame.isConnected) return;
|
|
196
|
+
const available = exposed.ok && webUrl(exposed.url);
|
|
197
|
+
if (!available) {
|
|
198
|
+
note.textContent =
|
|
199
|
+
"This preview is on the computer running kaizen and could not be opened for this device. Open the task on that computer.";
|
|
200
|
+
link.textContent = "Open on computer";
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
url = available;
|
|
204
|
+
link.href = url;
|
|
205
|
+
note.textContent = exposed.hint || "Live preview. This address can change during later work.";
|
|
206
|
+
} catch {
|
|
207
|
+
note.textContent =
|
|
208
|
+
"The preview could not be opened for this device. Open the task on the computer running kaizen.";
|
|
209
|
+
link.textContent = "Open on computer";
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (!frame.isConnected) return;
|
|
214
|
+
frame.hidden = false;
|
|
215
|
+
frame.src = url;
|
|
216
|
+
frame.addEventListener(
|
|
217
|
+
"load",
|
|
218
|
+
() => {
|
|
219
|
+
if (note.textContent?.startsWith("Checking"))
|
|
220
|
+
note.textContent =
|
|
221
|
+
"Live preview. If it does not appear, use Open link. Some apps require their own browser tab.";
|
|
222
|
+
},
|
|
223
|
+
{ once: true },
|
|
224
|
+
);
|
|
225
|
+
frame.addEventListener(
|
|
226
|
+
"error",
|
|
227
|
+
() => {
|
|
228
|
+
frame.hidden = true;
|
|
229
|
+
note.textContent = "The live preview could not be opened. Use Open link or ask for a saved screenshot.";
|
|
230
|
+
},
|
|
231
|
+
{ once: true },
|
|
232
|
+
);
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
}
|