@kriya-ai/harness 2.0.1 → 2.1.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/bin/kriya.js +18 -4
- package/bundle/cordis.patch.yml +55 -3
- package/contract/SOURCE.md +3 -3
- package/contract/contract.json +219 -0
- package/install.sh +187 -0
- package/package.json +2 -1
- package/plugins/cockpit/client.js +492 -0
- package/plugins/cockpit/index.js +197 -0
- package/plugins/cockpit/package.json +22 -0
- package/plugins/directory-picker/index.js +73 -0
- package/plugins/directory-picker/native.js +42 -0
- package/plugins/directory-picker/package.json +14 -0
- package/plugins/keyguard/index.js +76 -0
- package/plugins/keyguard/package.json +13 -0
- package/plugins/providers/index.js +155 -0
- package/plugins/providers/package.json +13 -0
- package/src/cockpit.js +223 -0
- package/src/daemon.js +9 -2
- package/src/gateway-proxy.js +107 -1
- package/src/launch.js +80 -13
- package/src/local-model.js +110 -0
- package/src/loop.js +4 -1
- package/src/modes.js +37 -1
- package/src/orchestra.js +8 -1
- package/src/own-models.js +176 -0
- package/src/own-usage.js +63 -0
- package/src/profiles.js +4 -0
- package/src/proof.js +78 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
// The Developer tab, browser half (Kriya-Tavi docs/kriya-harness/DEVELOPER_COCKPIT.md):
|
|
2
|
+
// a right-sidebar page beside Overview with the project's GitHub state, the
|
|
3
|
+
// person's connections (each provider's own CLI login), the servers running in
|
|
4
|
+
// this folder and the project's health. Every change is the person's click,
|
|
5
|
+
// confirmed first; it reads and acts only through this plugin's route (index.js).
|
|
6
|
+
window.__ModuleLoader__.load({
|
|
7
|
+
id: "@kriya-ai/harness-cockpit",
|
|
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-cockpit"
|
|
14
|
+
const KIND = "kriya-cockpit"
|
|
15
|
+
const API = "api/kriya.cockpit"
|
|
16
|
+
const REFRESH_MS = 5000
|
|
17
|
+
|
|
18
|
+
const CSS = `
|
|
19
|
+
.kh-dv { height: 100%; overflow: auto; color: var(--dsw-alias-label-primary); font-size: 13px; padding: 4px 0 16px; }
|
|
20
|
+
.kh-dv-sec { padding: 10px 14px 12px; border-bottom: 1px solid var(--dsw-alias-border-l2); }
|
|
21
|
+
.kh-dv-sec:last-child { border-bottom: 0; }
|
|
22
|
+
.kh-dv-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-secondary); }
|
|
23
|
+
.kh-dv-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
|
|
24
|
+
.kh-dv-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
25
|
+
.kh-dv-mono { font-family: var(--dsw-font-code, ui-monospace, monospace); font-size: 12px; }
|
|
26
|
+
.kh-dv-dim { color: var(--dsw-alias-label-tertiary); }
|
|
27
|
+
.kh-dv-note { font-size: 12px; line-height: 1.45; color: var(--dsw-alias-label-tertiary); margin: 2px 0 6px; }
|
|
28
|
+
.kh-dv-warn { color: var(--dsw-alias-state-warn-label, var(--dsw-alias-state-error-primary)); }
|
|
29
|
+
.kh-dv-err { color: var(--dsw-alias-state-error-primary); }
|
|
30
|
+
.kh-dv-ok { color: var(--dsw-alias-state-success-primary); }
|
|
31
|
+
.kh-dv-pill { flex: none; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-secondary); white-space: nowrap; }
|
|
32
|
+
.kh-dv-pill.ok { color: var(--dsw-alias-state-success-primary); border-color: currentColor; }
|
|
33
|
+
.kh-dv-pill.bad { color: var(--dsw-alias-state-error-primary); border-color: currentColor; }
|
|
34
|
+
.kh-dv-pill.wait { color: var(--dsw-alias-link); border-color: currentColor; }
|
|
35
|
+
.kh-dv-btn { flex: none; min-height: 32px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-1, transparent); color: inherit; font: inherit; font-size: 12.5px; cursor: pointer; }
|
|
36
|
+
/* Accent text on a light tint of it: the theme's link colour already meets contrast on panels in light and dark */
|
|
37
|
+
.kh-dv-btn.primary { background: color-mix(in srgb, var(--dsw-alias-link) 12%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-link) 55%, transparent); color: var(--dsw-alias-link); font-weight: 600; }
|
|
38
|
+
.kh-dv-btn:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
39
|
+
.kh-dv-btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--dsw-alias-link) 20%, transparent); }
|
|
40
|
+
.kh-dv-btn:disabled { opacity: .5; cursor: default; }
|
|
41
|
+
.kh-dv-btn:focus-visible, .kh-dv-input:focus-visible, .kh-dv-link:focus-visible { outline: 2px solid var(--dsw-alias-link); outline-offset: 2px; }
|
|
42
|
+
.kh-dv-icon { min-width: 44px; min-height: 44px; margin: -12px -10px -12px 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; }
|
|
43
|
+
.kh-dv-icon:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
44
|
+
.kh-dv-input { flex: 1; min-width: 0; min-height: 32px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l2); background: transparent; color: inherit; font: inherit; font-size: 12.5px; }
|
|
45
|
+
.kh-dv-code { display: flex; align-items: center; gap: 8px; margin: 4px 0; padding: 6px 8px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-border-l2)); }
|
|
46
|
+
.kh-dv-code > code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--dsw-font-code, ui-monospace, monospace); font-size: 12px; }
|
|
47
|
+
.kh-dv-big { font-family: var(--dsw-font-code, ui-monospace, monospace); font-size: 20px; letter-spacing: .08em; font-weight: 600; }
|
|
48
|
+
.kh-dv-link { color: var(--dsw-alias-link); text-decoration: none; }
|
|
49
|
+
.kh-dv-link:hover { text-decoration: underline; }
|
|
50
|
+
.kh-dv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
|
|
51
|
+
.kh-dv-switch { flex: none; width: 44px; height: 26px; padding: 3px; border: 0; border-radius: 999px; background: var(--dsw-alias-border-l2); cursor: pointer; position: relative; }
|
|
52
|
+
.kh-dv-switch::before { content: ""; position: absolute; inset: -9px 0; }
|
|
53
|
+
.kh-dv-switch > span { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
|
|
54
|
+
.kh-dv-switch.on { background: var(--dsw-alias-link); }
|
|
55
|
+
.kh-dv-switch.on > span { transform: translateX(18px); }
|
|
56
|
+
.kh-dv-switch:focus-visible { outline: 2px solid var(--dsw-alias-link); outline-offset: 2px; }
|
|
57
|
+
.kh-dv-wrap { white-space: normal; line-height: 1.4; padding: 4px 0; }
|
|
58
|
+
.kh-dv-sub { margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-secondary); }
|
|
59
|
+
.kh-dv-form { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
|
|
60
|
+
.kh-dv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 6px; }
|
|
61
|
+
.kh-dv-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12px; }
|
|
62
|
+
select.kh-dv-input { padding-right: 6px; }
|
|
63
|
+
.kh-dv-confirm { position: sticky; top: 0; z-index: 2; margin: 0 10px 6px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--dsw-alias-link); background: var(--dsw-alias-bg-layer-0, var(--dsw-alias-bg-primary, Canvas)); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
|
|
64
|
+
.kh-dv-confirm p { margin: 0 0 8px; line-height: 1.45; }
|
|
65
|
+
.kh-dv-error { padding: 12px 14px; color: var(--dsw-alias-state-error-primary); }
|
|
66
|
+
.kh-dv-empty { padding: 14px; color: var(--dsw-alias-label-tertiary); line-height: 1.5; }
|
|
67
|
+
@media (pointer: coarse) { .kh-dv-btn, .kh-dv-input { min-height: 44px; } }
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
function installStyles() {
|
|
71
|
+
const tag = document.createElement("style")
|
|
72
|
+
tag.dataset.plugin = PLUGIN
|
|
73
|
+
tag.textContent = CSS
|
|
74
|
+
document.head.appendChild(tag)
|
|
75
|
+
return () => tag.remove()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const icon = (paths, size = 16) =>
|
|
79
|
+
h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, ...paths.map((d, i) => h("path", { key: i, d })))
|
|
80
|
+
const ICON = {
|
|
81
|
+
tab: ["M8 9l-4 3 4 3", "M16 9l4 3-4 3", "M13.5 5l-3 14"],
|
|
82
|
+
refresh: ["M20 11a8 8 0 1 0-2.3 5.7", "M20 4v7h-7"],
|
|
83
|
+
copy: ["M9 9h10v10H9z", "M5 15V5h10"],
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const Section = (title, children, action) => h("section", { className: "kh-dv-sec", "aria-label": title }, h("h3", { className: "kh-dv-h" }, title, action), children)
|
|
87
|
+
const Pill = (text, tone) => h("span", { className: `kh-dv-pill${tone ? ` ${tone}` : ""}` }, text)
|
|
88
|
+
|
|
89
|
+
function Copy({ text, label }) {
|
|
90
|
+
const [done, setDone] = useState(false)
|
|
91
|
+
return h(
|
|
92
|
+
"div",
|
|
93
|
+
{ className: "kh-dv-code" },
|
|
94
|
+
h("code", null, text),
|
|
95
|
+
h(
|
|
96
|
+
"button",
|
|
97
|
+
{
|
|
98
|
+
type: "button",
|
|
99
|
+
className: "kh-dv-icon",
|
|
100
|
+
"aria-label": done ? "Copied" : label || `Copy ${text}`,
|
|
101
|
+
title: done ? "Copied" : "Copy",
|
|
102
|
+
onClick: () => navigator.clipboard?.writeText(text).then(() => (setDone(true), setTimeout(() => setDone(false), 1500))),
|
|
103
|
+
},
|
|
104
|
+
done ? h("span", { className: "kh-dv-ok", "aria-hidden": true }, "✓") : icon(ICON.copy)
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function Switch({ label, checked, disabled, onChange }) {
|
|
110
|
+
return h("button", { type: "button", role: "switch", "aria-checked": checked, "aria-label": label, disabled, className: `kh-dv-switch${checked ? " on" : ""}`, onClick: () => onChange(!checked) }, h("span", null))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// A saved switch: what the next start uses, and whether that differs from now
|
|
114
|
+
function Saved({ label, what, state, busy, onChange }) {
|
|
115
|
+
const on = state.saved ?? state.running
|
|
116
|
+
return [
|
|
117
|
+
h("div", { key: "s", className: "kh-dv-row" }, h("span", { className: "kh-dv-val" }, label), h(Switch, { label, checked: on, disabled: busy, onChange })),
|
|
118
|
+
h("p", { key: "n", className: "kh-dv-note" }, on !== state.running ? `${what} Restart Kriya Harness to apply this.` : what),
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function GitHub({ data, act, busy }) {
|
|
123
|
+
const g = data.github
|
|
124
|
+
const sign = data.signIn
|
|
125
|
+
const [name, setName] = useState(() => data.folder.split(/[\\/]/).filter(Boolean).pop() || "")
|
|
126
|
+
const rows = []
|
|
127
|
+
const push = (key, node) => rows.push(h(React.Fragment, { key }, node))
|
|
128
|
+
if (g.state === "unavailable") push("u", h("p", { className: "kh-dv-note kh-dv-err" }, g.note))
|
|
129
|
+
else if (g.state === "not a repository") {
|
|
130
|
+
push("n", h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-val kh-dv-dim" }, "Not under version control"), h("button", { type: "button", className: "kh-dv-btn", disabled: busy, onClick: () => act({ action: "git.init" }, "Start a git repository in this folder (git init)?") }, "Start a git repository")))
|
|
131
|
+
} else {
|
|
132
|
+
push("b", h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-val" }, "Branch ", h("span", { className: "kh-dv-mono" }, g.branch)), Pill(`${g.changed} changed`)))
|
|
133
|
+
for (const r of g.remotes) push(`r${r}`, h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-val kh-dv-mono", title: r }, r)))
|
|
134
|
+
if (g.state === "no remote") {
|
|
135
|
+
push("nr", h("p", { className: "kh-dv-note" }, "Not on GitHub yet. Create a private repository and connect this folder to it (nothing is pushed until you or the agent push)."))
|
|
136
|
+
push(
|
|
137
|
+
"c",
|
|
138
|
+
h(
|
|
139
|
+
"div",
|
|
140
|
+
{ className: "kh-dv-row" },
|
|
141
|
+
h("input", { className: "kh-dv-input", value: name, onChange: (e) => setName(e.target.value), "aria-label": "Repository name", placeholder: "repository-name", maxLength: 100 }),
|
|
142
|
+
h("button", { type: "button", className: "kh-dv-btn primary", disabled: busy || !name.trim(), onClick: () => act({ action: "github.create", name: name.trim() }, `Create the private GitHub repository "${name.trim()}" and set it as origin?`) }, "Create on GitHub")
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
if (g.state === "remote, gh not installed") push("ni", [h("p", { key: "p", className: "kh-dv-note" }, "Install the GitHub CLI to see pull requests and checks:"), h(Copy, { key: "c", text: "brew install gh" })])
|
|
147
|
+
if (g.state === "remote, gh signed out" || (g.state === "no remote" && !data.connections.find((c) => c.id === "github")?.signedIn)) {
|
|
148
|
+
if (sign.status === "waiting")
|
|
149
|
+
push(
|
|
150
|
+
"w",
|
|
151
|
+
h(
|
|
152
|
+
"div",
|
|
153
|
+
{ role: "status" },
|
|
154
|
+
h("p", { className: "kh-dv-note" }, "Enter this code on the GitHub page that opened in your browser:"),
|
|
155
|
+
h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-big" }, sign.code), h("button", { type: "button", className: "kh-dv-btn", onClick: () => act({ action: "github.signin.cancel" }) }, "Cancel"))
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
else
|
|
159
|
+
push(
|
|
160
|
+
"s",
|
|
161
|
+
h(
|
|
162
|
+
"div",
|
|
163
|
+
{ className: "kh-dv-row" },
|
|
164
|
+
h("span", { className: "kh-dv-val kh-dv-dim" }, sign.status === "failed" ? h("span", { className: "kh-dv-err" }, sign.error) : "Sign in to GitHub to create repositories and see pull requests."),
|
|
165
|
+
h("button", { type: "button", className: "kh-dv-btn primary", disabled: busy || sign.status === "starting", onClick: () => act({ action: "github.signin" }) }, "Sign in to GitHub")
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
if (g.state === "remote, signed in") {
|
|
170
|
+
push(
|
|
171
|
+
"pr",
|
|
172
|
+
g.pr
|
|
173
|
+
? h(
|
|
174
|
+
"div",
|
|
175
|
+
{ className: "kh-dv-row" },
|
|
176
|
+
h("span", { className: "kh-dv-val", title: g.pr.title }, g.pr.url ? h("a", { className: "kh-dv-link", href: g.pr.url, target: "_blank", rel: "noreferrer" }, `#${g.pr.number}`) : `#${g.pr.number}`, " ", g.pr.title),
|
|
177
|
+
Pill(g.pr.draft ? "Draft" : String(g.pr.state).toLowerCase(), g.pr.state === "OPEN" ? "wait" : "")
|
|
178
|
+
)
|
|
179
|
+
: h("div", { className: "kh-dv-row kh-dv-dim" }, "No pull request for this branch.")
|
|
180
|
+
)
|
|
181
|
+
if (g.checks?.total)
|
|
182
|
+
push(
|
|
183
|
+
"ck",
|
|
184
|
+
h(
|
|
185
|
+
"div",
|
|
186
|
+
{ className: "kh-dv-chips", "aria-label": "Pull request checks" },
|
|
187
|
+
g.checks.passed ? Pill(`✓ ${g.checks.passed} passed`, "ok") : null,
|
|
188
|
+
g.checks.failed ? Pill(`✗ ${g.checks.failed} failed`, "bad") : null,
|
|
189
|
+
g.checks.pending ? Pill(`${g.checks.pending} running`, "wait") : null
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
if (g.exposed?.length) push("ex", h("p", { className: "kh-dv-note kh-dv-warn", role: "alert" }, `Committed secret files: ${g.exposed.join(", ")}. Remove them from git (git rm --cached <file>) and rotate those keys.`))
|
|
194
|
+
}
|
|
195
|
+
push("t", Saved({ label: "Repository tools", what: "The agent may branch, commit, push and open draft pull requests, asking you each time.", state: data.switches.repoTools, busy, onChange: (on) => act({ action: "switch", flag: "repo-tools", on }) }))
|
|
196
|
+
return Section("GitHub", rows)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function Connections({ data, act, busy, refresh }) {
|
|
200
|
+
const rows = data.connections.map((c) => {
|
|
201
|
+
const status = !c.installed ? Pill("Not installed") : c.signedIn ? Pill(c.account ? `Signed in · ${c.account}` : "Signed in", "ok") : Pill("Not signed in")
|
|
202
|
+
return h(
|
|
203
|
+
"div",
|
|
204
|
+
{ key: c.id },
|
|
205
|
+
h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-val" }, c.name, c.version && h("span", { className: "kh-dv-dim" }, ` · ${c.version}`)), status),
|
|
206
|
+
!c.installed
|
|
207
|
+
? [h("p", { key: "p", className: "kh-dv-note" }, "Install its CLI, then refresh:"), h(Copy, { key: "c", text: c.install })]
|
|
208
|
+
: !c.signedIn && c.id !== "github"
|
|
209
|
+
? [h("p", { key: "p", className: "kh-dv-note" }, "Sign in with its own CLI in a terminal (your browser opens); Kriya never sees the token:"), h(Copy, { key: "c", text: c.login })]
|
|
210
|
+
: !c.signedIn
|
|
211
|
+
? h("p", { className: "kh-dv-note" }, "Sign in from the GitHub section above.")
|
|
212
|
+
: null
|
|
213
|
+
)
|
|
214
|
+
})
|
|
215
|
+
return Section(
|
|
216
|
+
"Connections",
|
|
217
|
+
[
|
|
218
|
+
...rows,
|
|
219
|
+
h(React.Fragment, { key: "pt" }, Saved({ label: "Supabase and Render tools", what: "The agent may read projects, services, deploys, logs and migrations; anything that changes something asks you first.", state: data.switches.providerTools, busy, onChange: (on) => act({ action: "switch", flag: "provider-tools", on }) })),
|
|
220
|
+
],
|
|
221
|
+
h("button", { type: "button", className: "kh-dv-icon", onClick: refresh, "aria-label": "Check connections again", title: "Check again" }, icon(ICON.refresh))
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function Servers({ data, act, busy }) {
|
|
226
|
+
const s = data.servers
|
|
227
|
+
if (!s.available) return Section("Running servers", h("p", { className: "kh-dv-note" }, "Listing servers needs lsof on this computer."))
|
|
228
|
+
if (!s.list.length) return Section("Running servers", h("div", { className: "kh-dv-row kh-dv-dim" }, "No server is running in this folder."))
|
|
229
|
+
return Section(
|
|
230
|
+
"Running servers",
|
|
231
|
+
s.list.map((p) =>
|
|
232
|
+
h(
|
|
233
|
+
"div",
|
|
234
|
+
{ key: p.pid, className: "kh-dv-row" },
|
|
235
|
+
h(
|
|
236
|
+
"span",
|
|
237
|
+
{ className: "kh-dv-val" },
|
|
238
|
+
h("span", { className: "kh-dv-mono" }, p.command),
|
|
239
|
+
" ",
|
|
240
|
+
...p.ports.map((port) => h("a", { key: port, className: "kh-dv-link kh-dv-mono", href: `http://localhost:${port}`, target: "_blank", rel: "noreferrer", style: { marginRight: 6 } }, `:${port}`)),
|
|
241
|
+
p.folder !== "." && h("span", { className: "kh-dv-dim" }, ` · ${p.folder}`)
|
|
242
|
+
),
|
|
243
|
+
h("button", { type: "button", className: "kh-dv-btn", disabled: busy, "aria-label": `Stop ${p.command} (process ${p.pid})`, onClick: () => act({ action: "server.stop", pid: p.pid }, `Stop ${p.command} on port ${p.ports.join(", ")} (process ${p.pid})?`) }, "Stop")
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function Health({ data, act, busy }) {
|
|
250
|
+
const x = data.health
|
|
251
|
+
return Section("Project health", [
|
|
252
|
+
x.stack.length ? h("div", { key: "s", className: "kh-dv-chips" }, ...x.stack.map((s) => h(React.Fragment, { key: s.id }, Pill(s.label)))) : h("div", { key: "s", className: "kh-dv-row kh-dv-dim" }, "No known project files here."),
|
|
253
|
+
x.scripts.length ? h("div", { key: "sc", className: "kh-dv-row" }, h("span", { className: "kh-dv-val" }, "Scripts ", h("span", { className: "kh-dv-mono kh-dv-dim" }, x.scripts.join(" · ")))) : null,
|
|
254
|
+
h(
|
|
255
|
+
"div",
|
|
256
|
+
{ key: "c", className: "kh-dv-row" },
|
|
257
|
+
h("span", { className: "kh-dv-val" }, "Check ", x.check ? h("span", { className: "kh-dv-mono" }, x.check) : h("span", { className: "kh-dv-dim" }, "none confirmed yet")),
|
|
258
|
+
x.check ? Pill("confirmed", "ok") : null
|
|
259
|
+
),
|
|
260
|
+
!x.check && h("p", { key: "cn", className: "kh-dv-note" }, "Confirm how this project is checked so Kriya can verify the agent's work:"),
|
|
261
|
+
!x.check && h(Copy, { key: "cc", text: "kriya verify" }),
|
|
262
|
+
!x.git && h("p", { key: "g", className: "kh-dv-note" }, "Not a git repository, so secret files can't be checked against .gitignore."),
|
|
263
|
+
x.tracked.length > 0 && h("p", { key: "t", className: "kh-dv-note kh-dv-warn", role: "alert" }, `Committed secret files: ${x.tracked.join(", ")}. Remove them from git (git rm --cached <file>) and rotate those keys.`),
|
|
264
|
+
x.unignored.length > 0 &&
|
|
265
|
+
h(
|
|
266
|
+
"div",
|
|
267
|
+
{ key: "u" },
|
|
268
|
+
h("p", { className: "kh-dv-note kh-dv-warn" }, `Not ignored yet, so a commit could include them: ${x.unignored.join(", ")}.`),
|
|
269
|
+
h("button", { type: "button", className: "kh-dv-btn", disabled: busy, onClick: () => act({ action: "health.ignore", files: x.unignored }, `Add ${x.unignored.join(", ")} to .gitignore?`) }, "Add to .gitignore")
|
|
270
|
+
),
|
|
271
|
+
x.git && !x.tracked.length && !x.unignored.length && h("div", { key: "ok", className: "kh-dv-row kh-dv-ok" }, "No secret files exposed to git."),
|
|
272
|
+
])
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Your models (Kriya-Tavi docs/kriya-harness/OWN_MODELS.md): the person's own API keys and
|
|
276
|
+
// their own orchestration. A key is typed here once, saved on this computer only, and never
|
|
277
|
+
// shown again (its last four characters only)
|
|
278
|
+
function OwnModels({ own, run, busy, changed }) {
|
|
279
|
+
const [keyFor, setKeyFor] = useState(null)
|
|
280
|
+
const [key, setKey] = useState("")
|
|
281
|
+
const [url, setUrl] = useState("")
|
|
282
|
+
const [provider, setProvider] = useState(() => own.providers.find((p) => p.saved)?.id ?? "")
|
|
283
|
+
const [list, setList] = useState(null)
|
|
284
|
+
const [model, setModel] = useState("")
|
|
285
|
+
const [head, setHead] = useState(own.orchestra?.head ?? "")
|
|
286
|
+
const [worker, setWorker] = useState(own.orchestra?.worker ?? "")
|
|
287
|
+
const saved = own.providers.filter((p) => p.saved)
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (!saved.some((p) => p.id === provider)) setProvider(saved[0]?.id ?? "")
|
|
290
|
+
}, [own])
|
|
291
|
+
const name = (id) => own.choices.find((c) => c.id === id)?.name ?? id
|
|
292
|
+
const saveKey = async () => {
|
|
293
|
+
const answer = await run({ action: "own.key.save", provider: keyFor, key, ...(keyFor === "custom" && { url }) })
|
|
294
|
+
setKey("")
|
|
295
|
+
if (answer) setKeyFor(null)
|
|
296
|
+
}
|
|
297
|
+
const load = async () => {
|
|
298
|
+
setList(null)
|
|
299
|
+
const answer = await run({ action: "own.models.list", provider })
|
|
300
|
+
if (answer) setList(answer.models)
|
|
301
|
+
}
|
|
302
|
+
const picked = list?.find((m) => m.id === model)
|
|
303
|
+
const rows = []
|
|
304
|
+
const push = (k, node) => rows.push(h(React.Fragment, { key: k }, node))
|
|
305
|
+
push("i", h("p", { className: "kh-dv-note" }, "Use your own API keys. Calls go straight from this computer to the provider; Kriya never sees your key, and counts only calls and tokens, never content."))
|
|
306
|
+
for (const p of own.providers)
|
|
307
|
+
push(
|
|
308
|
+
`p-${p.id}`,
|
|
309
|
+
h(
|
|
310
|
+
"div",
|
|
311
|
+
null,
|
|
312
|
+
h(
|
|
313
|
+
"div",
|
|
314
|
+
{ className: "kh-dv-row" },
|
|
315
|
+
h("span", { className: "kh-dv-val" }, p.name, p.saved && p.url && h("span", { className: "kh-dv-dim kh-dv-mono" }, ` · ${p.url}`)),
|
|
316
|
+
p.saved ? Pill(`Key ••••${p.last4}`, "ok") : null,
|
|
317
|
+
h("button", { type: "button", className: "kh-dv-btn", disabled: busy, "aria-expanded": keyFor === p.id, onClick: () => (setKeyFor(keyFor === p.id ? null : p.id), setKey(""), setUrl(p.url ?? "")) }, p.saved ? "Replace" : "Add key"),
|
|
318
|
+
p.saved && h("button", { type: "button", className: "kh-dv-btn", disabled: busy, "aria-label": `Remove the ${p.name} key`, onClick: () => run({ action: "own.key.remove", provider: p.id }) }, "Remove")
|
|
319
|
+
),
|
|
320
|
+
keyFor === p.id &&
|
|
321
|
+
h(
|
|
322
|
+
"form",
|
|
323
|
+
{ className: "kh-dv-form", onSubmit: (e) => (e.preventDefault(), saveKey()) },
|
|
324
|
+
p.id === "custom" && h("input", { className: "kh-dv-input", value: url, onChange: (e) => setUrl(e.target.value), placeholder: "https://api.example.com/v1", "aria-label": "Custom provider address", inputMode: "url", autoComplete: "off", spellCheck: false }),
|
|
325
|
+
h(
|
|
326
|
+
"div",
|
|
327
|
+
{ className: "kh-dv-row" },
|
|
328
|
+
h("input", { className: "kh-dv-input", type: "password", value: key, onChange: (e) => setKey(e.target.value), placeholder: `${p.name} API key`, "aria-label": `${p.name} API key`, autoComplete: "off", spellCheck: false, autoFocus: true }),
|
|
329
|
+
h("button", { type: "submit", className: "kh-dv-btn primary", disabled: busy || key.trim().length < 8 }, "Save")
|
|
330
|
+
),
|
|
331
|
+
p.keysUrl && h("p", { className: "kh-dv-note" }, "Get a key at ", h("a", { className: "kh-dv-link", href: p.keysUrl, target: "_blank", rel: "noreferrer" }, new URL(p.keysUrl).host), ". It's saved on this computer only.")
|
|
332
|
+
)
|
|
333
|
+
)
|
|
334
|
+
)
|
|
335
|
+
if (saved.length) {
|
|
336
|
+
push("mh", h("h4", { className: "kh-dv-sub" }, "Models"))
|
|
337
|
+
for (const m of own.models)
|
|
338
|
+
push(`m-${m.id}`, h("div", { className: "kh-dv-row" }, h("span", { className: "kh-dv-val", title: m.name }, m.name, h("span", { className: "kh-dv-dim" }, ` · ${Math.round(m.contextWindow / 1000)}k`)), h("button", { type: "button", className: "kh-dv-btn", disabled: busy, "aria-label": `Remove ${m.name}`, onClick: () => run({ action: "own.model.remove", id: m.id }) }, "Remove")))
|
|
339
|
+
if (!own.models.length) push("mn", h("div", { className: "kh-dv-row kh-dv-dim" }, "No model added yet."))
|
|
340
|
+
push(
|
|
341
|
+
"ma",
|
|
342
|
+
h(
|
|
343
|
+
"div",
|
|
344
|
+
{ className: "kh-dv-row" },
|
|
345
|
+
h("select", { className: "kh-dv-input", value: provider, onChange: (e) => (setProvider(e.target.value), setList(null), setModel("")), "aria-label": "Provider" }, ...saved.map((p) => h("option", { key: p.id, value: p.id }, p.name))),
|
|
346
|
+
h("button", { type: "button", className: "kh-dv-btn", disabled: busy || !provider, onClick: load }, "Load models")
|
|
347
|
+
)
|
|
348
|
+
)
|
|
349
|
+
if (list)
|
|
350
|
+
push(
|
|
351
|
+
"ml",
|
|
352
|
+
h(
|
|
353
|
+
"form",
|
|
354
|
+
{ className: "kh-dv-row", onSubmit: (e) => (e.preventDefault(), run({ action: "own.model.add", provider, model, ...(picked?.contextWindow && { contextWindow: picked.contextWindow }) }).then((a) => a && setModel(""))) },
|
|
355
|
+
h("input", { className: "kh-dv-input kh-dv-mono", list: "kh-dv-models", value: model, onChange: (e) => setModel(e.target.value), placeholder: `Search ${list.length} models`, "aria-label": "Model", autoComplete: "off", spellCheck: false }),
|
|
356
|
+
h("datalist", { id: "kh-dv-models" }, ...list.slice(0, 1000).map((m) => h("option", { key: m.id, value: m.id }))),
|
|
357
|
+
h("button", { type: "submit", className: "kh-dv-btn primary", disabled: busy || !list.some((m) => m.id === model) }, "Add")
|
|
358
|
+
)
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
const options = (role) => [h("option", { key: "", value: "" }, role === "head" ? "Choose the head…" : "Choose the worker…"), ...own.choices.filter((c) => role === "worker" || c.id !== "local").map((c) => h("option", { key: c.id, value: c.id }, c.name))]
|
|
362
|
+
push("oh", h("h4", { className: "kh-dv-sub" }, "Your orchestration"))
|
|
363
|
+
push("on", h("p", { className: "kh-dv-note" }, "The head plans, reviews and takes over when the worker is stuck; the worker builds each step. Mix your models, Kriya's and a local one."))
|
|
364
|
+
push(
|
|
365
|
+
"os",
|
|
366
|
+
h(
|
|
367
|
+
"div",
|
|
368
|
+
{ className: "kh-dv-grid" },
|
|
369
|
+
h("label", { className: "kh-dv-field" }, h("span", { className: "kh-dv-dim" }, "Head"), h("select", { className: "kh-dv-input", value: head, "aria-label": "Head model", onChange: (e) => setHead(e.target.value) }, ...options("head"))),
|
|
370
|
+
h("label", { className: "kh-dv-field" }, h("span", { className: "kh-dv-dim" }, "Worker"), h("select", { className: "kh-dv-input", value: worker, "aria-label": "Worker model", onChange: (e) => setWorker(e.target.value) }, ...options("worker")))
|
|
371
|
+
)
|
|
372
|
+
)
|
|
373
|
+
push(
|
|
374
|
+
"ob",
|
|
375
|
+
h(
|
|
376
|
+
"div",
|
|
377
|
+
{ className: "kh-dv-row" },
|
|
378
|
+
h("span", { className: "kh-dv-val kh-dv-dim kh-dv-wrap" }, own.orchestra ? `Saved: ${name(own.orchestra.head)} leads, ${name(own.orchestra.worker)} builds.` : "Not set: Kriya's orchestration is used."),
|
|
379
|
+
own.orchestra && h("button", { type: "button", className: "kh-dv-btn", disabled: busy, onClick: () => run({ action: "own.orchestra", orchestra: null }).then(() => (setHead(""), setWorker(""))) }, "Clear"),
|
|
380
|
+
h("button", { type: "button", className: "kh-dv-btn primary", disabled: busy || !head || !worker || head === worker || (own.orchestra?.head === head && own.orchestra?.worker === worker), onClick: () => run({ action: "own.orchestra", orchestra: { head, worker } }) }, "Save")
|
|
381
|
+
)
|
|
382
|
+
)
|
|
383
|
+
if (head && head === worker) push("ow", h("p", { className: "kh-dv-note kh-dv-warn" }, "Choose two different models."))
|
|
384
|
+
if (changed) push("rs", h("p", { className: "kh-dv-note", role: "status" }, "Saved. Restart Kriya Harness to use these changes."))
|
|
385
|
+
return Section("Your models", rows)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function DeveloperBody({ useTabInfo, sessionId }) {
|
|
389
|
+
const { tab } = useTabInfo()
|
|
390
|
+
const visible = tab?.visible !== false
|
|
391
|
+
const [data, setData] = useState(null)
|
|
392
|
+
const [error, setError] = useState(null)
|
|
393
|
+
const [busy, setBusy] = useState(false)
|
|
394
|
+
const [done, setDone] = useState(null)
|
|
395
|
+
// An action waiting for the person's Confirm, shown in the tab (no native dialog)
|
|
396
|
+
const [pending, setPending] = useState(null)
|
|
397
|
+
|
|
398
|
+
const load = useCallback(
|
|
399
|
+
async (fresh) => {
|
|
400
|
+
if (!sessionId) return
|
|
401
|
+
try {
|
|
402
|
+
const q = new URLSearchParams({ session: sessionId, ...(fresh && { fresh: "1" }) })
|
|
403
|
+
const response = await fetch(`${API}?${q}`, { credentials: "same-origin" })
|
|
404
|
+
const body = await response.json().catch(() => ({}))
|
|
405
|
+
if (!response.ok) throw new Error(body.error || `Kriya Harness answered ${response.status}.`)
|
|
406
|
+
setData(body)
|
|
407
|
+
setError(null)
|
|
408
|
+
} catch (e) {
|
|
409
|
+
setError(e.message === "Failed to fetch" ? "Kriya Harness isn't answering; is it still running?" : e.message)
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
[sessionId]
|
|
413
|
+
)
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
if (!visible) return
|
|
416
|
+
load()
|
|
417
|
+
const timer = setInterval(() => load(), REFRESH_MS)
|
|
418
|
+
return () => clearInterval(timer)
|
|
419
|
+
}, [visible, load])
|
|
420
|
+
|
|
421
|
+
const act = (body, confirmText) => (confirmText ? setPending({ body, text: confirmText }) : run(body))
|
|
422
|
+
const run = async (body) => {
|
|
423
|
+
setPending(null)
|
|
424
|
+
setBusy(true)
|
|
425
|
+
setDone(null)
|
|
426
|
+
try {
|
|
427
|
+
const response = await fetch(API, { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify({ session: sessionId, ...body }) })
|
|
428
|
+
const answer = await response.json().catch(() => ({}))
|
|
429
|
+
if (!response.ok) throw new Error(answer.error || `Kriya Harness answered ${response.status}.`)
|
|
430
|
+
if (answer.url) setDone(answer.url)
|
|
431
|
+
setError(null)
|
|
432
|
+
if (body.action.startsWith("own.")) setChanged(body.action !== "own.models.list")
|
|
433
|
+
await load(body.action === "github.create" || body.action === "switch")
|
|
434
|
+
setBusy(false)
|
|
435
|
+
return answer
|
|
436
|
+
} catch (e) {
|
|
437
|
+
setError(e.message)
|
|
438
|
+
}
|
|
439
|
+
setBusy(false)
|
|
440
|
+
return null
|
|
441
|
+
}
|
|
442
|
+
// Own models: saved changes apply at the next start, which the section says
|
|
443
|
+
const [changed, setChangedState] = useState(false)
|
|
444
|
+
const setChanged = (v) => v && setChangedState(true)
|
|
445
|
+
|
|
446
|
+
if (!sessionId) return h("div", { className: "kh-dv-empty" }, "Start or open a session to see this folder's GitHub, connections, servers and health.")
|
|
447
|
+
if (error && !data) return h("div", { className: "kh-dv-error", role: "alert" }, error)
|
|
448
|
+
if (!data) return h("div", { className: "kh-dv-empty" }, "Loading…")
|
|
449
|
+
return h(
|
|
450
|
+
"div",
|
|
451
|
+
{ className: "kh-dv" },
|
|
452
|
+
error && h("div", { className: "kh-dv-error", role: "alert" }, error),
|
|
453
|
+
pending &&
|
|
454
|
+
h(
|
|
455
|
+
"div",
|
|
456
|
+
{ className: "kh-dv-confirm", role: "alertdialog", "aria-label": "Confirm", "aria-describedby": "kh-dv-confirm-text" },
|
|
457
|
+
h("p", { id: "kh-dv-confirm-text" }, pending.text),
|
|
458
|
+
h(
|
|
459
|
+
"div",
|
|
460
|
+
{ className: "kh-dv-row" },
|
|
461
|
+
h("button", { type: "button", className: "kh-dv-btn primary", autoFocus: true, onClick: () => run(pending.body) }, "Confirm"),
|
|
462
|
+
h("button", { type: "button", className: "kh-dv-btn", onClick: () => setPending(null) }, "Cancel")
|
|
463
|
+
)
|
|
464
|
+
),
|
|
465
|
+
done && h("div", { className: "kh-dv-empty", role: "status" }, "Created: ", h("a", { className: "kh-dv-link", href: done, target: "_blank", rel: "noreferrer" }, done)),
|
|
466
|
+
h(GitHub, { key: "g", data, act, busy }),
|
|
467
|
+
data.own && h(OwnModels, { key: "o", own: data.own, run, busy, changed }),
|
|
468
|
+
h(Connections, { key: "c", data, act, busy, refresh: () => load(true) }),
|
|
469
|
+
h(Servers, { key: "s", data, act, busy }),
|
|
470
|
+
h(Health, { key: "h", data, act, busy })
|
|
471
|
+
)
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const definition = {
|
|
475
|
+
id: PLUGIN,
|
|
476
|
+
kind: KIND,
|
|
477
|
+
priority: "extension",
|
|
478
|
+
title: () => "Developer",
|
|
479
|
+
guide: [{ id: "developer", order: 6, title: () => "Developer", description: () => "GitHub, connections, running servers and project health", icon: () => icon(ICON.tab, 20) }],
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const inject = ["slots", "sidebarRightTabs"]
|
|
483
|
+
|
|
484
|
+
function apply(ctx) {
|
|
485
|
+
if (typeof document !== "undefined") ctx.effect(installStyles, "kriya-cockpit: styles")
|
|
486
|
+
ctx.effect(() => ctx.sidebarRightTabs.register(definition), "kriya-cockpit: type")
|
|
487
|
+
ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: PLUGIN }, DeveloperBody)), "kriya-cockpit: body")
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return { apply, inject, DeveloperBody, definition, API }
|
|
491
|
+
},
|
|
492
|
+
})
|