@kriya-ai/harness 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +379 -2
- package/SAFETY.md +162 -0
- package/THIRD_PARTY_NOTICES.md +7911 -0
- package/bin/kriya.js +577 -0
- package/bundle/cordis.patch.yml +397 -0
- package/contract/SOURCE.md +15 -0
- package/contract/contract.json +1355 -0
- package/package.json +57 -4
- package/plugins/anchor/index.js +56 -0
- package/plugins/anchor/package.json +13 -0
- package/plugins/approvals/index.js +183 -0
- package/plugins/approvals/package.json +13 -0
- package/plugins/brand/DESIGN.md +112 -0
- package/plugins/brand/client.js +826 -0
- package/plugins/brand/index.js +15 -0
- package/plugins/brand/package.json +25 -0
- package/plugins/brand/src/client.js +823 -0
- package/plugins/browser/index.js +218 -0
- package/plugins/browser/package.json +13 -0
- package/plugins/budget/index.js +108 -0
- package/plugins/budget/package.json +13 -0
- package/plugins/changes/client.js +245 -0
- package/plugins/changes/index.js +75 -0
- package/plugins/changes/package.json +22 -0
- package/plugins/edit/client.js +113 -0
- package/plugins/edit/index.js +58 -0
- package/plugins/edit/package.json +23 -0
- package/plugins/fs-freshness/index.js +28 -0
- package/plugins/fs-freshness/package.json +13 -0
- package/plugins/graph/client.js +178 -0
- package/plugins/graph/index.js +4 -0
- package/plugins/graph/package.json +22 -0
- package/plugins/kriya-handoff/index.js +194 -0
- package/plugins/kriya-handoff/package.json +13 -0
- package/plugins/kriya-tools/index.js +189 -0
- package/plugins/kriya-tools/package.json +13 -0
- package/plugins/loop/index.js +743 -0
- package/plugins/loop/package.json +13 -0
- package/plugins/mirror/index.js +235 -0
- package/plugins/mirror/package.json +13 -0
- package/plugins/overview/client.js +276 -0
- package/plugins/overview/index.js +95 -0
- package/plugins/overview/package.json +22 -0
- package/plugins/preview/client.js +337 -0
- package/plugins/preview/index.js +4 -0
- package/plugins/preview/package.json +22 -0
- package/plugins/progress/client.js +290 -0
- package/plugins/progress/index.js +100 -0
- package/plugins/progress/package.json +22 -0
- package/plugins/projects/client.js +249 -0
- package/plugins/projects/index.js +30 -0
- package/plugins/projects/package.json +24 -0
- package/plugins/rea/index.js +256 -0
- package/plugins/rea/package.json +10 -0
- package/plugins/rea/skill/LICENSE +21 -0
- package/plugins/rea/skill/SKILL.md +360 -0
- package/plugins/rea/skill/references/android-applications.md +36 -0
- package/plugins/rea/skill/references/connection-and-recovery.md +127 -0
- package/plugins/rea/skill/references/evidence-workflows.md +71 -0
- package/plugins/rea/skill/references/javascript-applications.md +218 -0
- package/plugins/rea/skill/references/native-and-artifacts.md +297 -0
- package/plugins/rea/skill/references/runtime-observation.md +78 -0
- package/plugins/remote/index.js +297 -0
- package/plugins/remote/package.json +10 -0
- package/plugins/router/index.js +84 -0
- package/plugins/router/package.json +13 -0
- package/plugins/sessions/client.js +68 -0
- package/plugins/sessions/index.js +79 -0
- package/plugins/sessions/package.json +20 -0
- package/plugins/skills/client.js +504 -0
- package/plugins/skills/index.js +166 -0
- package/plugins/skills/package.json +23 -0
- package/src/api.js +97 -0
- package/src/browser.js +286 -0
- package/src/changes.js +191 -0
- package/src/checkpoints.js +313 -0
- package/src/daemon.js +503 -0
- package/src/doctor.js +137 -0
- package/src/edit/core/anchors.js +102 -0
- package/src/edit/core/audio.js +158 -0
- package/src/edit/core/faces.js +99 -0
- package/src/edit/core/ffmpeg.js +258 -0
- package/src/edit/core/handoff.js +220 -0
- package/src/edit/core/history.js +90 -0
- package/src/edit/core/layout.js +92 -0
- package/src/edit/core/mix.js +115 -0
- package/src/edit/core/ops.js +602 -0
- package/src/edit/core/plan.js +266 -0
- package/src/edit/core/project.d.ts +134 -0
- package/src/edit/core/project.js +307 -0
- package/src/edit/core/reframe.js +125 -0
- package/src/edit/core/solver.js +416 -0
- package/src/edit/core/time.js +110 -0
- package/src/edit/core/tonemap.js +57 -0
- package/src/edit/director/ask.js +120 -0
- package/src/edit/director/gateway.js +16 -0
- package/src/edit/director/revise.js +186 -0
- package/src/edit/engine/capabilities.js +33 -0
- package/src/edit/engine/captions.js +154 -0
- package/src/edit/engine/color.js +269 -0
- package/src/edit/engine/confine.js +67 -0
- package/src/edit/engine/dna.js +148 -0
- package/src/edit/engine/index.js +473 -0
- package/src/edit/engine/loudness.js +43 -0
- package/src/edit/engine/media.js +57 -0
- package/src/edit/engine/motion.js +281 -0
- package/src/edit/engine/packs.js +87 -0
- package/src/edit/engine/probe.js +101 -0
- package/src/edit/engine/receipt.js +123 -0
- package/src/edit/engine/tool.js +101 -0
- package/src/edit/gates/copy.js +113 -0
- package/src/edit/gates/index.js +430 -0
- package/src/edit/gates/picture.js +130 -0
- package/src/edit/gates/sound.js +58 -0
- package/src/edit/gates/speech.js +127 -0
- package/src/edit/gates/text.js +196 -0
- package/src/edit/gates/text.swift +22 -0
- package/src/edit/graph/index.js +139 -0
- package/src/edit/graph/journal.js +69 -0
- package/src/edit/graph/scheduler.js +79 -0
- package/src/edit/host/client.js +58 -0
- package/src/edit/host/deliver.js +119 -0
- package/src/edit/host/jobs.js +84 -0
- package/src/edit/host/main.js +135 -0
- package/src/edit/host/paths.js +11 -0
- package/src/edit/host/projects.js +415 -0
- package/src/edit/host/server.js +391 -0
- package/src/edit/host/taste.js +135 -0
- package/src/edit/host/tavi.js +417 -0
- package/src/edit/host/watch.js +141 -0
- package/src/edit/index/db.js +109 -0
- package/src/edit/index/index.js +236 -0
- package/src/edit/index/layers/faces.js +78 -0
- package/src/edit/index/layers/faces.swift +18 -0
- package/src/edit/index/layers/meta.js +35 -0
- package/src/edit/index/layers/music.js +146 -0
- package/src/edit/index/layers/quality.js +120 -0
- package/src/edit/index/layers/retakes.js +132 -0
- package/src/edit/index/layers/screen.js +99 -0
- package/src/edit/index/layers/shots.js +29 -0
- package/src/edit/index/layers/sound.js +42 -0
- package/src/edit/index/layers/words.js +64 -0
- package/src/edit/index/story.js +248 -0
- package/src/edit/index/views.js +71 -0
- package/src/edit/loop/governor.js +112 -0
- package/src/edit/loop/loop.js +69 -0
- package/src/edit/loop/make.js +115 -0
- package/src/edit/loop/repair.js +97 -0
- package/src/edit/loop/replay.js +32 -0
- package/src/edit/recipes/multicam.js +461 -0
- package/src/edit/recipes/reel.js +202 -0
- package/src/edit/recipes/short-from-long.js +237 -0
- package/src/edit/recipes/tutorial.js +137 -0
- package/src/edit/recipes/youtube.js +155 -0
- package/src/edit/runtime/cli.js +126 -0
- package/src/edit/runtime/doctor.js +122 -0
- package/src/edit/runtime/fetch.js +15 -0
- package/src/edit/runtime/licences.js +88 -0
- package/src/edit/runtime/manifest.js +73 -0
- package/src/edit/runtime/setup.js +252 -0
- package/src/failure.js +69 -0
- package/src/gateway-proxy.js +213 -0
- package/src/intent.js +130 -0
- package/src/launch.js +315 -0
- package/src/live.js +81 -0
- package/src/local-skills.js +284 -0
- package/src/login.js +82 -0
- package/src/loop.js +428 -0
- package/src/modes.js +128 -0
- package/src/overview.js +71 -0
- package/src/paths.js +30 -0
- package/src/profiles.js +92 -0
- package/src/projects.js +104 -0
- package/src/recon.js +244 -0
- package/src/rules.js +139 -0
- package/src/runner.bundle.js +21172 -0
- package/src/sentinel.js +248 -0
- package/src/skill-switches.js +130 -0
- package/src/store.js +58 -0
- package/src/strict.js +124 -0
- package/src/verify.js +659 -0
- package/src/world.js +268 -0
- package/studio/dist/index.html +14 -0
- package/studio/dist/studio.css +163 -0
- package/studio/dist/studio.js +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ChangesError, fileDiff, listChanges } from "../../src/changes.js"
|
|
2
|
+
|
|
3
|
+
// The Changes tab, node half: routes on DSH's shared /api channel, inside
|
|
4
|
+
// Connection's fence (Host/Origin checks, the signed browser cookie, owner
|
|
5
|
+
// Peers only), as plugins/skills registers its own. The browser names a
|
|
6
|
+
// Session, never a folder: its folder comes from the Session's header, the
|
|
7
|
+
// way dsh-api-workspace-files resolves one, and a diff is only produced for a
|
|
8
|
+
// file git lists as changed there.
|
|
9
|
+
|
|
10
|
+
export const name = "kriya-changes"
|
|
11
|
+
export const inject = ["connection", "sessions"]
|
|
12
|
+
|
|
13
|
+
export const ROUTES = {
|
|
14
|
+
list: "/api/kriya.changes",
|
|
15
|
+
diff: "/api/kriya.changes.diff",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const reply = (body, status = 200) => Response.json(body, { status, headers: { "cache-control": "no-store" } })
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The route handlers, separate from DSH so tests call them directly.
|
|
22
|
+
* @param {(sessionId: string) => Promise<string | undefined>} folderOf a Session's folder
|
|
23
|
+
* @param {(sessionId: string) => Promise<number | undefined>} [startOf] when it began (ms)
|
|
24
|
+
*/
|
|
25
|
+
export function handlers(folderOf, startOf = async () => undefined) {
|
|
26
|
+
const folder = async (request) => {
|
|
27
|
+
const id = new URL(request.url).searchParams.get("session")
|
|
28
|
+
if (!id || id.length > 200) throw new ChangesError("Which session?")
|
|
29
|
+
const cwd = await folderOf(id)
|
|
30
|
+
if (!cwd) throw new ChangesError("That session isn't known here.")
|
|
31
|
+
return { cwd, id, since: await startOf(id) }
|
|
32
|
+
}
|
|
33
|
+
// base and now are tree ids the diff route uses; the browser doesn't need them
|
|
34
|
+
const shown = ({ base, now, ...rest }) => rest
|
|
35
|
+
return {
|
|
36
|
+
[ROUTES.list]: async (request) => {
|
|
37
|
+
const { cwd, id, since } = await folder(request)
|
|
38
|
+
return shown(await listChanges(cwd, id, since))
|
|
39
|
+
},
|
|
40
|
+
[ROUTES.diff]: async (request) => {
|
|
41
|
+
const { cwd, id, since } = await folder(request)
|
|
42
|
+
return fileDiff(cwd, new URL(request.url).searchParams.get("path"), id, since)
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Runs one handler: a ChangesError is the person's to fix (400), anything else is ours (500). */
|
|
48
|
+
export async function answer(handler, request, log = () => {}) {
|
|
49
|
+
try {
|
|
50
|
+
return reply(await handler(request))
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof ChangesError) return reply({ error: error.message }, 400)
|
|
53
|
+
log(error)
|
|
54
|
+
return reply({ error: "Kriya couldn't read the changes; see the terminal for details." }, 500)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function apply(ctx) {
|
|
59
|
+
// A live Session's header, else the stored one (a Session not open now)
|
|
60
|
+
const headerOf = async (id) => {
|
|
61
|
+
const live = ctx.sessions.get(id)?.header
|
|
62
|
+
const stored = live === undefined ? await ctx.get("sessionPersistence")?.stat(id) : undefined
|
|
63
|
+
return live ?? stored?.header
|
|
64
|
+
}
|
|
65
|
+
const table = handlers(
|
|
66
|
+
async (id) => (await headerOf(id))?.cwd,
|
|
67
|
+
async (id) => (await headerOf(id))?.createdAt
|
|
68
|
+
)
|
|
69
|
+
const log = (error) => ctx.logger("kriya-changes").warn(error)
|
|
70
|
+
for (const [path, handler] of Object.entries(table)) {
|
|
71
|
+
ctx.effect(() =>
|
|
72
|
+
ctx.connection.fetch.register({ path, methods: ["GET"], requestBody: "buffered", fetch: (request) => answer(handler, request, log) })
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-changes",
|
|
3
|
+
"description": "The Changes tab of the Kriya Harness Web UI: every file changed in a session's folder against HEAD, with its diff",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./client": "./client.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dsh": {
|
|
14
|
+
"client": {
|
|
15
|
+
"inject": [
|
|
16
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right"
|
|
17
|
+
],
|
|
18
|
+
"platform": "web"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED"
|
|
22
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// The Editing Studio row, browser half: an "Editing Studio" row in the sidebar's
|
|
2
|
+
// panel list (the seat the Projects page uses) and its page in the main slot. The
|
|
3
|
+
// page asks the node half for a one-time link and navigates the whole tab to the
|
|
4
|
+
// Studio (STUDIO_APP_AND_BROWSER §1); the Studio's "Kriya Harness" link comes back.
|
|
5
|
+
// Coming back, the page waits for a click instead of leaving again at once.
|
|
6
|
+
window.__ModuleLoader__.load({
|
|
7
|
+
id: "@kriya-ai/harness-edit",
|
|
8
|
+
factory: (require) => {
|
|
9
|
+
const React = require("react")
|
|
10
|
+
const { useCallback, useEffect, useState } = React
|
|
11
|
+
const h = React.createElement
|
|
12
|
+
|
|
13
|
+
const PLUGIN = "@kriya-ai/harness-edit"
|
|
14
|
+
const PANEL_ID = "kriya-edit"
|
|
15
|
+
const API = "api/kriya.edit.launch"
|
|
16
|
+
const LEFT = "kriya-edit-left"
|
|
17
|
+
|
|
18
|
+
const CSS = `
|
|
19
|
+
.kh-ed { display: flex; flex-direction: column; gap: 14px; padding: 32px; color: var(--dsw-alias-label-primary); font-size: 14px; max-width: 64ch; }
|
|
20
|
+
.kh-ed-title { margin: 0; font-family: var(--dsw-font-family-brand); font-size: 30px; line-height: 36px; font-weight: 420; letter-spacing: -0.016em; }
|
|
21
|
+
.kh-ed-note { margin: 0; color: var(--dsw-alias-label-secondary); line-height: 1.5; }
|
|
22
|
+
.kh-ed-error { margin: 0; color: var(--dsw-alias-state-error-primary); }
|
|
23
|
+
.kh-ed-btn { align-self: flex-start; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--dsw-alias-button-info-fill); color: var(--dsw-alias-label-primary-foreground); font: inherit; font-weight: 500; cursor: pointer; }
|
|
24
|
+
.kh-ed-btn:hover:not(:disabled) { background: var(--dsw-alias-button-info-hover); }
|
|
25
|
+
.kh-ed-btn:disabled { opacity: .55; cursor: default; }
|
|
26
|
+
.kh-ed-btn:focus-visible { outline: 2px solid var(--dsw-alias-link); outline-offset: 2px; }
|
|
27
|
+
@media (max-width: 760px) { .kh-ed { padding: 20px 16px; } }
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
function installStyles() {
|
|
31
|
+
const tag = document.createElement("style")
|
|
32
|
+
tag.dataset.plugin = PLUGIN
|
|
33
|
+
tag.textContent = CSS
|
|
34
|
+
document.head.appendChild(tag)
|
|
35
|
+
return () => tag.remove()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A frame of film with a cut through it
|
|
39
|
+
function EditIcon({ size = 20 }) {
|
|
40
|
+
return h(
|
|
41
|
+
"svg",
|
|
42
|
+
{ width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
|
|
43
|
+
h("rect", { x: 3, y: 5, width: 18, height: 14, rx: 2.5 }),
|
|
44
|
+
h("path", { d: "M7 5v14M17 5v14M3 9.5h4M3 14.5h4M17 9.5h4M17 14.5h4M12 9l-1.5 6" })
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const seen = (key) => {
|
|
49
|
+
try {
|
|
50
|
+
const value = sessionStorage.getItem(key)
|
|
51
|
+
sessionStorage.removeItem(key)
|
|
52
|
+
return value !== null
|
|
53
|
+
} catch {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Asks for a link and goes there. @returns {Promise<string | null>} an error to show, or null */
|
|
59
|
+
async function open(fetchImpl = fetch, go = (url) => window.location.assign(url)) {
|
|
60
|
+
try {
|
|
61
|
+
const response = await fetchImpl(API, { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
|
|
62
|
+
const value = await response.json().catch(() => ({}))
|
|
63
|
+
if (!response.ok || typeof value.url !== "string") return value.error ?? "The Editing Studio couldn't start."
|
|
64
|
+
try {
|
|
65
|
+
sessionStorage.setItem(LEFT, "1")
|
|
66
|
+
} catch {
|
|
67
|
+
// Without storage, coming back simply opens it again
|
|
68
|
+
}
|
|
69
|
+
go(value.url)
|
|
70
|
+
return null
|
|
71
|
+
} catch {
|
|
72
|
+
return "Kriya Harness couldn't reach the Editing Studio."
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function EditPage() {
|
|
77
|
+
const [returned] = useState(() => seen(LEFT))
|
|
78
|
+
const [error, setError] = useState(null)
|
|
79
|
+
const [busy, setBusy] = useState(!returned)
|
|
80
|
+
const start = useCallback(() => {
|
|
81
|
+
setBusy(true)
|
|
82
|
+
setError(null)
|
|
83
|
+
open().then((problem) => {
|
|
84
|
+
if (problem) {
|
|
85
|
+
setError(problem)
|
|
86
|
+
setBusy(false)
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}, [])
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!returned) start()
|
|
92
|
+
}, [returned, start])
|
|
93
|
+
return h(
|
|
94
|
+
"div",
|
|
95
|
+
{ className: "kh-ed" },
|
|
96
|
+
h("h1", { className: "kh-ed-title" }, "Editing Studio"),
|
|
97
|
+
h("p", { className: "kh-ed-note" }, "Edit video on this computer: your footage stays here. The Studio opens in this tab; its Kriya Harness link brings you back."),
|
|
98
|
+
error ? h("p", { className: "kh-ed-error", role: "alert" }, error) : null,
|
|
99
|
+
h("button", { type: "button", className: "kh-ed-btn", onClick: start, disabled: busy }, busy ? "Opening…" : "Open the Editing Studio")
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const inject = ["slots"]
|
|
104
|
+
|
|
105
|
+
function apply(ctx) {
|
|
106
|
+
if (typeof document !== "undefined") ctx.effect(installStyles, "kriya-edit: styles")
|
|
107
|
+
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: PANEL_ID }, EditPage))
|
|
108
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({ name: "sidebar.panellist", id: PANEL_ID, order: 5, label: "Editing Studio" }, EditIcon))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return { apply, inject, EditPage, EditIcon, open, API, PANEL_ID }
|
|
112
|
+
},
|
|
113
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The Editing Studio row, node half (UX_SPEC §1): one route on DSH's shared /api
|
|
2
|
+
// channel, inside Connection's fence (Host and Origin checks, the signed browser
|
|
3
|
+
// cookie, owner peers only). It starts the Edit Host if need be and asks it, over
|
|
4
|
+
// its owner-only socket, for a one-time link to the Studio. The row exists only
|
|
5
|
+
// with KRIYA_EDIT on (bundle/cordis.patch.yml), and src/edit loads only here, lazily.
|
|
6
|
+
|
|
7
|
+
export const name = "kriya-edit"
|
|
8
|
+
export const inject = ["connection"]
|
|
9
|
+
|
|
10
|
+
export const ROUTE = "/api/kriya.edit.launch"
|
|
11
|
+
|
|
12
|
+
const json = (value, status = 200) => Response.json(value, { status, headers: { "cache-control": "no-store" } })
|
|
13
|
+
|
|
14
|
+
/** @param {Request} request @param {{ warn: (e: unknown) => void }} log */
|
|
15
|
+
export async function launch(request, log, load = () => import("../../src/edit/host/client.js")) {
|
|
16
|
+
if (process.env.KRIYA_EDIT !== "on") return json({ error: "The Editing Studio is off." }, 404)
|
|
17
|
+
try {
|
|
18
|
+
const { ensureHost, hostCall } = await load()
|
|
19
|
+
const { kriyaHome } = await import("../../src/paths.js")
|
|
20
|
+
// The Host reads the device itself; it never inherits the harness's token
|
|
21
|
+
const { KRIYA_DEVICE_TOKEN: _, ...env } = process.env
|
|
22
|
+
await ensureHost({ env })
|
|
23
|
+
// Back to this page: the Host keeps it only if it's a loopback origin
|
|
24
|
+
const back = request.headers.get("origin") ?? new URL(request.url).origin
|
|
25
|
+
const { url } = await hostCall(kriyaHome(), "POST", "/internal/launch", { back })
|
|
26
|
+
return json({ url })
|
|
27
|
+
} catch (error) {
|
|
28
|
+
log.warn(error)
|
|
29
|
+
return json({ error: "The Editing Studio couldn't start; see the terminal for details." }, 500)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* While this Web UI runs, tell a running Edit Host a person is working here, so its
|
|
35
|
+
* Governor keeps to one open answer (EDIT_LOOP §8). It never starts a Host.
|
|
36
|
+
*/
|
|
37
|
+
export async function ping(load = () => import("../../src/edit/host/client.js")) {
|
|
38
|
+
if (process.env.KRIYA_EDIT !== "on") return false
|
|
39
|
+
try {
|
|
40
|
+
const { hostCall } = await load()
|
|
41
|
+
const { kriyaHome } = await import("../../src/paths.js")
|
|
42
|
+
await hostCall(kriyaHome(), "POST", "/internal/live")
|
|
43
|
+
return true
|
|
44
|
+
} catch {
|
|
45
|
+
return false // no Host running: nothing to tell
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function apply(ctx) {
|
|
50
|
+
const log = ctx.logger("kriya-edit")
|
|
51
|
+
ctx.effect(() => ctx.connection.fetch.register({ path: ROUTE, methods: ["POST"], requestBody: "buffered", fetch: (request) => launch(request, log) }))
|
|
52
|
+
ctx.effect(() => {
|
|
53
|
+
void ping()
|
|
54
|
+
const timer = setInterval(() => void ping(), 20_000)
|
|
55
|
+
timer.unref?.()
|
|
56
|
+
return () => clearInterval(timer)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-edit",
|
|
3
|
+
"description": "The Editing Studio row of the Kriya Harness Web UI: opens the Studio, the Edit Host's own app, in the same tab",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./client": "./client.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dsh": {
|
|
14
|
+
"client": {
|
|
15
|
+
"inject": [
|
|
16
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
17
|
+
"@deepseek-ai/dsh-client-ui-sidebar"
|
|
18
|
+
],
|
|
19
|
+
"platform": "web"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"license": "UNLICENSED"
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// DSH guards write and edit with a file version of dev:ino:size:mtime:ctime.
|
|
2
|
+
// ctime moves whenever anything touches a file's metadata: iCloud Drive does
|
|
3
|
+
// it for seconds after every save, so in a synced folder an edit fails as
|
|
4
|
+
// "changed since it was read" with the content untouched (measured
|
|
5
|
+
// 2026-11-06: 3 ctime changes in 5 s in ~/Documents, none in ~/Developer).
|
|
6
|
+
// This wraps DSH's freshness decision: when only the ctime moved, the guard
|
|
7
|
+
// takes the file's current version. Any change of content still moves
|
|
8
|
+
// mtime, size or inode, so a real change is refused exactly as before.
|
|
9
|
+
|
|
10
|
+
export const name = "kriya-fs-freshness"
|
|
11
|
+
export const inject = ["fs"]
|
|
12
|
+
|
|
13
|
+
const withoutCtime = (version) => String(version).slice(0, String(version).lastIndexOf(":"))
|
|
14
|
+
|
|
15
|
+
/** An fs/*-intent listener: `next` is DSH's own decision, which it never weakens but for ctime */
|
|
16
|
+
export function freshen(fs) {
|
|
17
|
+
return async (target, actor, next) => {
|
|
18
|
+
const intent = await next()
|
|
19
|
+
if (!intent?.version) return intent
|
|
20
|
+
const now = await fs.stat(target)
|
|
21
|
+
return now && withoutCtime(now.version) === withoutCtime(intent.version) ? { ...intent, version: now.version } : intent
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function apply(ctx) {
|
|
26
|
+
// First in line, so it wraps fs-observation-policy, which ends the chain
|
|
27
|
+
for (const event of ["fs/edit-intent", "fs/write-intent"]) ctx.on(event, freshen(ctx.fs), true)
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-fs-freshness",
|
|
3
|
+
"description": "Kriya Harness: a file whose content didn't change stays fresh for edits, whatever touched its metadata",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"license": "UNLICENSED"
|
|
13
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// The Graph tab, browser half: the session's plan as a graph, step by step,
|
|
2
|
+
// from the loop's own records (GET api/kriya.progress, the Progress tab's
|
|
3
|
+
// route), so what it draws is what ran, never what the model said. A flow is
|
|
4
|
+
// designed in Kriya; this is where you watch it on the machine doing the work.
|
|
5
|
+
// Plain React, SVG and DSH's theme tokens; no DSH file is edited (HD-02).
|
|
6
|
+
window.__ModuleLoader__.load({
|
|
7
|
+
id: "@kriya-ai/harness-graph",
|
|
8
|
+
factory: (require) => {
|
|
9
|
+
const React = require("react")
|
|
10
|
+
const { useCallback, useEffect, useState } = React
|
|
11
|
+
const h = React.createElement
|
|
12
|
+
|
|
13
|
+
const PLUGIN = "@kriya-ai/harness-graph"
|
|
14
|
+
const KIND = "kriya-graph"
|
|
15
|
+
const API = "api/kriya.progress"
|
|
16
|
+
const REFRESH_MS = 3000
|
|
17
|
+
const CARD_H = 56
|
|
18
|
+
const ROW = 92
|
|
19
|
+
const WIDTH = 300
|
|
20
|
+
const GAP = 12
|
|
21
|
+
|
|
22
|
+
const CSS = `
|
|
23
|
+
.kh-gr { height: 100%; overflow: auto; color: var(--dsw-alias-label-primary); font-size: 13px; padding: 12px 14px; }
|
|
24
|
+
.kh-gr-goal { line-height: 1.45; margin: 0 0 10px; color: var(--dsw-alias-label-secondary); }
|
|
25
|
+
.kh-gr svg { display: block; width: 100%; max-width: 340px; height: auto; }
|
|
26
|
+
.kh-gr-card { fill: var(--dsw-alias-bg-layer-1, transparent); stroke: var(--dsw-alias-border-l2); stroke-width: 1; }
|
|
27
|
+
.kh-gr-card.pass { stroke: var(--dsw-alias-state-success-primary); }
|
|
28
|
+
.kh-gr-card.blocked { stroke: var(--dsw-alias-state-error-primary); stroke-width: 1.5; }
|
|
29
|
+
.kh-gr-card.fail { stroke: var(--dsw-alias-state-warn-label); }
|
|
30
|
+
.kh-gr-card.building { stroke: var(--dsw-alias-link); stroke-width: 1.5; }
|
|
31
|
+
.kh-gr-card.skipped { stroke-dasharray: 4 4; }
|
|
32
|
+
.kh-gr-title { fill: var(--dsw-alias-label-primary); font-size: 12.5px; font-weight: 500; }
|
|
33
|
+
.kh-gr-state { fill: var(--dsw-alias-label-tertiary); font-size: 11px; }
|
|
34
|
+
.kh-gr-state.pass { fill: var(--dsw-alias-state-success-primary); }
|
|
35
|
+
.kh-gr-state.blocked { fill: var(--dsw-alias-state-error-primary); }
|
|
36
|
+
.kh-gr-state.fail { fill: var(--dsw-alias-state-warn-label); }
|
|
37
|
+
.kh-gr-state.building { fill: var(--dsw-alias-link); }
|
|
38
|
+
.kh-gr-edge { fill: none; stroke: var(--dsw-alias-border-l2); stroke-width: 1.5; }
|
|
39
|
+
.kh-gr-edge.done { stroke: var(--dsw-alias-state-success-primary); }
|
|
40
|
+
.kh-gr-note { padding: 14px; color: var(--dsw-alias-label-tertiary); line-height: 1.5; }
|
|
41
|
+
.kh-gr-error { padding: 10px 14px; color: var(--dsw-alias-state-error-primary); }
|
|
42
|
+
`
|
|
43
|
+
|
|
44
|
+
function installStyles() {
|
|
45
|
+
const tag = document.createElement("style")
|
|
46
|
+
tag.dataset.plugin = PLUGIN
|
|
47
|
+
tag.textContent = CSS
|
|
48
|
+
document.head.appendChild(tag)
|
|
49
|
+
return () => tag.remove()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A step sits one row below the deepest step it needs. `after` always
|
|
53
|
+
// points back (Loop v2's plan), so one pass in order is enough. Without
|
|
54
|
+
// `after` the plan is a chain, as it runs.
|
|
55
|
+
function layers(steps) {
|
|
56
|
+
const row = new Map()
|
|
57
|
+
const needs = (s, i) => (s.after?.length ? s.after : i === 0 ? [] : s.after ? [] : [steps[i - 1].n])
|
|
58
|
+
steps.forEach((s, i) => row.set(s.n, Math.max(-1, ...needs(s, i).map((d) => row.get(d) ?? -1)) + 1))
|
|
59
|
+
const rows = []
|
|
60
|
+
for (const s of steps) (rows[row.get(s.n)] ??= []).push(s)
|
|
61
|
+
const at = new Map()
|
|
62
|
+
rows.forEach((list, r) => {
|
|
63
|
+
const width = (WIDTH - GAP * (list.length - 1)) / list.length
|
|
64
|
+
list.forEach((s, i) => at.set(s.n, { x: i * (width + GAP), y: r * ROW, width }))
|
|
65
|
+
})
|
|
66
|
+
const edges = steps.flatMap((s, i) => needs(s, i).map((d) => ({ from: d, to: s.n })))
|
|
67
|
+
return { at, edges, height: rows.length * ROW - (ROW - CARD_H) }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const STATE = {
|
|
71
|
+
pass: "Passed",
|
|
72
|
+
built: "Built, not checked",
|
|
73
|
+
fail: "Failing",
|
|
74
|
+
blocked: "Blocked",
|
|
75
|
+
skipped: "Skipped",
|
|
76
|
+
"not started": "Not started",
|
|
77
|
+
}
|
|
78
|
+
const toneOf = (s) => (s.building ? "building" : s.status === "built" ? "" : s.status === "not started" ? "" : s.status)
|
|
79
|
+
const stateOf = (s) =>
|
|
80
|
+
s.building ? `Building · attempt ${s.building.attempt}` : `${STATE[s.status] ?? s.status}${s.attempts ? ` · ${s.attempts} run${s.attempts === 1 ? "" : "s"}` : ""}`
|
|
81
|
+
const clip = (text, width) => {
|
|
82
|
+
const room = Math.max(8, Math.floor((width - 20) / 6.6))
|
|
83
|
+
return text.length > room ? `${text.slice(0, room - 1)}…` : text
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function Graph({ steps }) {
|
|
87
|
+
const { at, edges, height } = layers(steps)
|
|
88
|
+
const byN = new Map(steps.map((s) => [s.n, s]))
|
|
89
|
+
return h(
|
|
90
|
+
"svg",
|
|
91
|
+
{ viewBox: `0 0 ${WIDTH} ${height}`, role: "img", "aria-label": `Plan: ${steps.map((s) => `${s.n}. ${s.title}, ${stateOf(s)}`).join("; ")}` },
|
|
92
|
+
...edges.map(({ from, to }) => {
|
|
93
|
+
const a = at.get(from)
|
|
94
|
+
const b = at.get(to)
|
|
95
|
+
const [x1, y1, x2, y2] = [a.x + a.width / 2, a.y + CARD_H, b.x + b.width / 2, b.y]
|
|
96
|
+
const mid = (y1 + y2) / 2
|
|
97
|
+
return h("path", {
|
|
98
|
+
key: `${from}-${to}`,
|
|
99
|
+
className: `kh-gr-edge${byN.get(from)?.status === "pass" ? " done" : ""}`,
|
|
100
|
+
d: x1 === x2 ? `M ${x1} ${y1} L ${x2} ${y2}` : `M ${x1} ${y1} L ${x1} ${mid} L ${x2} ${mid} L ${x2} ${y2}`,
|
|
101
|
+
})
|
|
102
|
+
}),
|
|
103
|
+
...steps.map((s) => {
|
|
104
|
+
const p = at.get(s.n)
|
|
105
|
+
const tone = toneOf(s)
|
|
106
|
+
return h(
|
|
107
|
+
"g",
|
|
108
|
+
{ key: s.n, transform: `translate(${p.x} ${p.y})` },
|
|
109
|
+
h("title", null, `${s.title}: ${stateOf(s)}`),
|
|
110
|
+
h("rect", { className: `kh-gr-card ${s.status === "skipped" ? "skipped" : tone}`, width: p.width, height: CARD_H, rx: 10 }),
|
|
111
|
+
h("text", { className: "kh-gr-title", x: 10, y: 23 }, clip(`${s.n}. ${s.title}`, p.width)),
|
|
112
|
+
h("text", { className: `kh-gr-state ${tone}`, x: 10, y: 41 }, clip(stateOf(s), p.width))
|
|
113
|
+
)
|
|
114
|
+
})
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function GraphBody({ useTabInfo, sessionId }) {
|
|
119
|
+
const { tab } = useTabInfo()
|
|
120
|
+
const visible = tab?.visible !== false
|
|
121
|
+
const [plan, setPlan] = useState(undefined)
|
|
122
|
+
const [error, setError] = useState(null)
|
|
123
|
+
const load = useCallback(async () => {
|
|
124
|
+
if (!sessionId) return
|
|
125
|
+
try {
|
|
126
|
+
const response = await fetch(`${API}?session=${encodeURIComponent(sessionId)}`, { credentials: "same-origin" })
|
|
127
|
+
const body = await response.json().catch(() => ({}))
|
|
128
|
+
if (!response.ok) throw new Error(body.error || `Kriya answered ${response.status}.`)
|
|
129
|
+
setError(null)
|
|
130
|
+
setPlan(body.plan)
|
|
131
|
+
} catch (e) {
|
|
132
|
+
setError(e.message)
|
|
133
|
+
}
|
|
134
|
+
}, [sessionId])
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!visible) return
|
|
137
|
+
load()
|
|
138
|
+
const timer = setInterval(load, REFRESH_MS)
|
|
139
|
+
return () => clearInterval(timer)
|
|
140
|
+
}, [visible, load])
|
|
141
|
+
if (!sessionId) return h("div", { className: "kh-gr-note" }, "Start or open a session to see its graph.")
|
|
142
|
+
if (error && plan === undefined) return h("div", { className: "kh-gr-error", role: "alert" }, error)
|
|
143
|
+
if (plan === undefined) return h("div", { className: "kh-gr-note" }, "Loading…")
|
|
144
|
+
if (!plan) return h("div", { className: "kh-gr-note" }, "No plan yet. The agent plans when a task has several parts, or design one in Kriya under Flows.")
|
|
145
|
+
return h("div", { className: "kh-gr" }, plan.goal && h("p", { className: "kh-gr-goal" }, plan.goal), h(Graph, { steps: plan.steps }))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const TabIcon = () =>
|
|
149
|
+
h(
|
|
150
|
+
"svg",
|
|
151
|
+
{ width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
|
|
152
|
+
h("rect", { x: 3, y: 3, width: 8, height: 6, rx: 1.5 }),
|
|
153
|
+
h("rect", { x: 13, y: 15, width: 8, height: 6, rx: 1.5 }),
|
|
154
|
+
h("path", { d: "M7 9v3a3 3 0 0 0 3 3h3" })
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
const definition = {
|
|
158
|
+
id: PLUGIN,
|
|
159
|
+
kind: KIND,
|
|
160
|
+
priority: "extension",
|
|
161
|
+
title: () => "Graph",
|
|
162
|
+
guide: [{ id: "graph", order: 7, title: () => "Graph", description: () => "The plan as a graph, from what really ran", icon: TabIcon }],
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const inject = ["slots", "sidebarRightTabs"]
|
|
166
|
+
|
|
167
|
+
function apply(ctx) {
|
|
168
|
+
if (typeof document !== "undefined") ctx.effect(installStyles, "kriya-graph: styles")
|
|
169
|
+
ctx.effect(() => ctx.sidebarRightTabs.register(definition), "kriya-graph: type")
|
|
170
|
+
ctx.effect(
|
|
171
|
+
() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: PLUGIN }, GraphBody)),
|
|
172
|
+
"kriya-graph: body"
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return { apply, inject, GraphBody, definition, API, layers, stateOf }
|
|
177
|
+
},
|
|
178
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-graph",
|
|
3
|
+
"description": "The Graph tab of the Kriya Harness Web UI: the session's plan drawn as a graph, from the loop's records",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./client": "./client.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dsh": {
|
|
14
|
+
"client": {
|
|
15
|
+
"inject": [
|
|
16
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right"
|
|
17
|
+
],
|
|
18
|
+
"platform": "web"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED"
|
|
22
|
+
}
|