@kriya-ai/harness 2.1.1 → 2.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 +19 -0
- package/RELEASE_NOTES.md +22 -0
- package/bin/kriya.js +43 -47
- package/bundle/cordis.patch.yml +8 -0
- package/install.sh +1 -1
- package/package.json +1 -1
- package/plugins/brand/client.js +1 -1
- package/plugins/brand/src/client.js +1 -1
- package/plugins/cockpit/client.js +89 -4
- package/plugins/cockpit/index.js +51 -24
- package/plugins/kriya-tools/index.js +3 -0
- package/plugins/remote/index.js +2 -2
- package/plugins/runstrip/index.js +1 -1
- package/src/api.js +5 -0
- package/src/edit/director/gateway.js +18 -6
- package/src/edit/director/local.js +148 -0
- package/src/edit/host/projects.js +22 -8
- package/src/edit/host/server.js +18 -5
- package/src/edit/runtime/cli.js +65 -14
- package/src/edit/runtime/doctor.js +8 -2
- package/src/edit/runtime/fetch.js +20 -4
- package/src/gateway-proxy.js +6 -2
- package/src/intent.js +2 -1
- package/src/launch.js +129 -26
- package/src/local-model.js +5 -3
- package/src/modes.js +11 -3
- package/src/own-usage.js +5 -1
- package/src/store.js +3 -0
- package/studio/dist/studio.js +3 -3
package/README.md
CHANGED
|
@@ -17,6 +17,25 @@ npm install
|
|
|
17
17
|
node bin/kriya.js login --url https://<your Kriya address>
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
### Standalone Mode (no Kriya account needed)
|
|
21
|
+
|
|
22
|
+
`npm i -g @kriya-ai/harness && kriya` works with no setup. Signed out,
|
|
23
|
+
with `--standalone`, or when Kriya can't be reached (network error, a
|
|
24
|
+
timeout, or a 5xx such as a suspended host's 503), Kriya Harness runs every
|
|
25
|
+
Harness 2.0 feature on this computer: cartridges, orchestra, gates, critic,
|
|
26
|
+
milestones, grounding, explore, the Run strip and the Developer tab. Models
|
|
27
|
+
come from **Settings → Models** or the **Developer** tab: your own API keys
|
|
28
|
+
(OpenRouter, OpenAI, DeepSeek, Groq, Together, Mistral, or any
|
|
29
|
+
OpenAI-compatible endpoint), alone or as your own Orchestration (a head that
|
|
30
|
+
plans and reviews, a worker that builds), or a local model
|
|
31
|
+
(`kriya --local-model`, Ollama or LM Studio). Keys stay in
|
|
32
|
+
`~/.kriya/own-models.json` (mode 600) and go only to their provider.
|
|
33
|
+
|
|
34
|
+
A Kriya that answers and refuses (401 signed out, 403 paused, 426 update
|
|
35
|
+
needed) is never bypassed: kriya says why and runs connected, as before.
|
|
36
|
+
`kriya login`, `handoff`, `pull`, `usage`, `daemon` and `serve` need an
|
|
37
|
+
account.
|
|
38
|
+
|
|
20
39
|
| Command | What it does |
|
|
21
40
|
| --- | --- |
|
|
22
41
|
| `kriya login [--url …] [--no-browser]` | Signs this device in: shows a code, opens Kriya's connect page, waits for you to approve it there |
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Kriya Harness release notes
|
|
2
2
|
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
- **Added:** **Standalone Mode for the Editing Studio** — when signed out or
|
|
6
|
+
when Kriya is unreachable (network error, timeout, or 5xx), the Director's
|
|
7
|
+
slots route to your own models (`~/.kriya/own-models.json`) or a local
|
|
8
|
+
OpenAI-compatible server (Ollama, LM Studio, vLLM), while local Editing
|
|
9
|
+
Studio features remain enabled and explicit refusals (401, 403, 426) stay
|
|
10
|
+
refused.
|
|
11
|
+
|
|
12
|
+
## 2.2.0
|
|
13
|
+
|
|
14
|
+
- **Added:** **Standalone Mode** (`--standalone`, or automatically when signed
|
|
15
|
+
out or when Kriya is unreachable due to network errors, timeouts, or 5xx
|
|
16
|
+
responses). All local Harness 2.0 features run on your machine using your own
|
|
17
|
+
API keys (OpenRouter, OpenAI, DeepSeek, Groq, Together, Mistral, or custom
|
|
18
|
+
OpenAI-compatible endpoints), your own Orchestration, or a local model
|
|
19
|
+
(`--local-model`). Explicit account refusals (401, 403, 426) are surfaced
|
|
20
|
+
and never bypassed.
|
|
21
|
+
- **Added:** **Settings → Models** panel in the Web UI (and `--workforce`
|
|
22
|
+
flag) to configure your own API keys, models, and Orchestration without an
|
|
23
|
+
active session.
|
|
24
|
+
|
|
3
25
|
## 2.1.1
|
|
4
26
|
|
|
5
27
|
- **Fixed:** the Developer tab showed "Kriya couldn't do that; see the
|
package/bin/kriya.js
CHANGED
|
@@ -20,7 +20,7 @@ import { login } from "../src/login.js"
|
|
|
20
20
|
import { setShare, shareStatus } from "../src/outcomes.js"
|
|
21
21
|
import { latestSession, makeReceipt, makeReport, ReceiptError, verifyReceipt } from "../src/receipts.js"
|
|
22
22
|
import { readRelease, ReleaseError, useRelease } from "../src/release.js"
|
|
23
|
-
import { APP_MODES, FULL_ACCESS_WARNING, MODES, ModeError, parseMode, planJob, switchEnv } from "../src/modes.js"
|
|
23
|
+
import { APP_MODES, FULL_ACCESS_WARNING, MODES, ModeError, parseMode, planJob, SWITCHES, switchEnv, WORKFORCE_SWITCHES } from "../src/modes.js"
|
|
24
24
|
import { CLIENT_VERSION, DSH_VERSION, kriyaHome } from "../src/paths.js"
|
|
25
25
|
import { deleteDevice, ensureHome, kriyaUrl, readDevice } from "../src/store.js"
|
|
26
26
|
|
|
@@ -33,13 +33,19 @@ Usage:
|
|
|
33
33
|
kriya login [--url <your Kriya address>] [--no-browser]
|
|
34
34
|
kriya [--mode <mode>] [--no-loop] [--loop-v2] [--loop-guard] [--strict-loop] [--defensive] [--recon] [--jit-tools] [--no-browser-tools] [--router] [--no-budget] [--anchor] [--no-open] [--port <n>]
|
|
35
35
|
[--local-model [<url>]] [--local-model-name <name>]
|
|
36
|
+
[--standalone] [--workforce] [--<switch> | --no-<switch>]
|
|
36
37
|
open the agent in your browser (local, 127.0.0.1)
|
|
38
|
+
--standalone: no Kriya account needed (also what happens when
|
|
39
|
+
you're signed out or Kriya is unreachable): your own API keys
|
|
40
|
+
(OpenRouter, OpenAI, …) or a local model, with Orchestration,
|
|
41
|
+
set up in the Developer tab. --workforce: every Harness 2.0 switch
|
|
37
42
|
--local-model: a model on this computer (Ollama or LM Studio, found
|
|
38
43
|
by itself, or <url> on your network) builds; Kriya's model plans
|
|
39
44
|
and reviews. Needs the orchestra and your Kriya owner's switch
|
|
40
45
|
kriya run [--mode <mode>] [--no-loop] [--loop-v2] [--loop-guard] [--strict-loop] [--defensive] [--recon] [--jit-tools] [--no-browser-tools] [--router] [--no-budget] [--anchor] "<job>"
|
|
41
46
|
run one job and print the answer (--json for events)
|
|
42
|
-
kriya
|
|
47
|
+
kriya run --standalone "<job>" the same, without a Kriya account
|
|
48
|
+
kriya acp [--standalone] the agent for editors: an ACP server on stdin/stdout
|
|
43
49
|
kriya usage [--json] this month's Kriya Harness spend and limit
|
|
44
50
|
kriya release use --build "<cmd>" --app http://localhost:<port> [--out dist] [--routes /,/pricing]
|
|
45
51
|
[--budget-kb <n>] [--domain <host>] [--headers <names>] [--marker "<text>"]
|
|
@@ -199,14 +205,29 @@ function option(args, name) {
|
|
|
199
205
|
return value
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
|
|
208
|
+
/** Takes a bare flag out of `args`; true when it was there */
|
|
209
|
+
function flag(args, name) {
|
|
210
|
+
const at = args.indexOf(name)
|
|
211
|
+
if (at !== -1) args.splice(at, 1)
|
|
212
|
+
return at !== -1
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// --workforce: every Harness 2.0 switch on, as the person's own choice; a --no-<name>
|
|
216
|
+
// or KRIYA_<NAME>=off of theirs still wins
|
|
217
|
+
function workforceArg(args, env = process.env) {
|
|
218
|
+
if (!flag(args, "--workforce")) return
|
|
219
|
+
for (const [name, variable] of SWITCHES) if (WORKFORCE_SWITCHES.includes(name) && env[variable] === undefined) env[variable] = "on"
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// The loop, budget and kept-request switches (src/modes.js switchEnv), --workforce,
|
|
203
223
|
// and --local-model [url] / --local-model-name <name> (S-1, src/local-model.js)
|
|
204
|
-
const useLoop = (args) => (switchEnv(args), localModelArgs(args))
|
|
224
|
+
const useLoop = (args) => (workforceArg(args), switchEnv(args), localModelArgs(args))
|
|
225
|
+
|
|
205
226
|
|
|
206
227
|
function signedIn() {
|
|
207
228
|
const device = readDevice()
|
|
208
229
|
if (!device) {
|
|
209
|
-
say("
|
|
230
|
+
say("This needs a Kriya account: run `kriya login`. (kriya, kriya run and kriya acp work without one, in Standalone Mode.)")
|
|
210
231
|
process.exit(1)
|
|
211
232
|
}
|
|
212
233
|
return device
|
|
@@ -669,69 +690,47 @@ async function main(argv) {
|
|
|
669
690
|
}
|
|
670
691
|
case "run": {
|
|
671
692
|
useLoop(args)
|
|
693
|
+
const standalone = flag(args, "--standalone")
|
|
672
694
|
const mode = parseMode(option(args, "--mode"))
|
|
673
|
-
const device =
|
|
695
|
+
const device = readDevice()
|
|
674
696
|
if (mode === "full") process.stderr.write(`${FULL_ACCESS_WARNING}\n`)
|
|
675
697
|
// The job is the first argument that isn't a flag; plan asks for a plan
|
|
676
698
|
const job = args.findIndex((arg) => !arg.startsWith("-"))
|
|
677
699
|
if (mode === "plan" && job !== -1) args[job] = planJob(args[job])
|
|
678
|
-
return runDsh("kriya-run", args, device, mode)
|
|
700
|
+
return runDsh("kriya-run", args, device, mode, { standalone })
|
|
679
701
|
}
|
|
680
702
|
case "acp": {
|
|
681
703
|
// Stdout carries only ACP frames (newline-delimited JSON-RPC), so
|
|
682
704
|
// everything kriya itself says goes to stderr. DSH's ACP app takes no
|
|
683
705
|
// options but --help; the transport is stdio, the editor's choice
|
|
706
|
+
const standalone = flag(args, "--standalone")
|
|
684
707
|
const help = args.length === 1 && (args[0] === "--help" || args[0] === "-h")
|
|
685
708
|
if (args.length && !help) {
|
|
686
|
-
process.stderr.write(`kriya acp takes no options but --help
|
|
709
|
+
process.stderr.write(`kriya acp takes no options but --help. (--standalone runs it without a Kriya account.)\n`)
|
|
687
710
|
return 1
|
|
688
711
|
}
|
|
689
712
|
if (help) {
|
|
690
713
|
say(ACP_HELP)
|
|
691
714
|
return 0
|
|
692
715
|
}
|
|
716
|
+
// Signed out: Standalone Mode (src/launch.js says so on stderr)
|
|
693
717
|
const device = readDevice()
|
|
694
|
-
if (!device) {
|
|
695
|
-
process.stderr.write("kriya: run `kriya login` to connect your Kriya account.\n")
|
|
696
|
-
return 1
|
|
697
|
-
}
|
|
698
718
|
// The same defaults as kriya run (U10), from the editor's environment
|
|
699
719
|
useLoop([])
|
|
700
|
-
return runDsh("kriya-acp", [], device)
|
|
720
|
+
return runDsh("kriya-acp", [], device, undefined, { standalone })
|
|
701
721
|
}
|
|
722
|
+
// The Web UI: plain `kriya` and any flag (every switch in src/modes.js SWITCHES, --workforce,
|
|
723
|
+
// --standalone, --mode, --port, --no-open, --local-model); anything else is refused below
|
|
702
724
|
case undefined:
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
case "--loop-v2":
|
|
709
|
-
case "--no-loop-v2":
|
|
710
|
-
case "--loop-guard":
|
|
711
|
-
case "--no-loop-guard":
|
|
712
|
-
case "--strict-loop":
|
|
713
|
-
case "--no-strict-loop":
|
|
714
|
-
case "--defensive":
|
|
715
|
-
case "--no-defensive":
|
|
716
|
-
case "--recon":
|
|
717
|
-
case "--no-recon":
|
|
718
|
-
case "--jit-tools":
|
|
719
|
-
case "--no-jit-tools":
|
|
720
|
-
case "--browser-tools":
|
|
721
|
-
case "--no-browser-tools":
|
|
722
|
-
case "--router":
|
|
723
|
-
case "--no-router":
|
|
724
|
-
case "--edit":
|
|
725
|
-
case "--no-edit":
|
|
726
|
-
case "--no-budget":
|
|
727
|
-
case "--no-anchor":
|
|
728
|
-
case "--no-open":
|
|
729
|
-
case "--local-model":
|
|
730
|
-
case "--local-model-name":
|
|
731
|
-
case "--port": {
|
|
725
|
+
default: {
|
|
726
|
+
if (command !== undefined && !command.startsWith("-")) {
|
|
727
|
+
say(`Unknown command ${command}.\n\n${HELP}`)
|
|
728
|
+
return 1
|
|
729
|
+
}
|
|
732
730
|
// Only these Web UI flags pass through; never --host, so the UI stays on 127.0.0.1
|
|
733
731
|
const flags = command === undefined ? [] : [command, ...args]
|
|
734
732
|
useLoop(flags)
|
|
733
|
+
const standalone = flag(flags, "--standalone")
|
|
735
734
|
const port = option(flags, "--port")
|
|
736
735
|
const mode = option(flags, "--mode")
|
|
737
736
|
if (mode === "plan") {
|
|
@@ -747,13 +746,10 @@ async function main(argv) {
|
|
|
747
746
|
say(`Unknown option ${flags.find((flag) => flag !== "--no-open")}.\n\n${HELP}`)
|
|
748
747
|
return 1
|
|
749
748
|
}
|
|
750
|
-
const device =
|
|
749
|
+
const device = readDevice()
|
|
751
750
|
if (chosen === "full") process.stderr.write(`${FULL_ACCESS_WARNING}\n`)
|
|
752
|
-
return runDsh("kriya", [...flags, ...(port ? ["--port", port] : [])], device, chosen)
|
|
751
|
+
return runDsh("kriya", [...flags, ...(port ? ["--port", port] : [])], device, chosen, { standalone })
|
|
753
752
|
}
|
|
754
|
-
default:
|
|
755
|
-
say(`Unknown command ${command}.\n\n${HELP}`)
|
|
756
|
-
return 1
|
|
757
753
|
}
|
|
758
754
|
}
|
|
759
755
|
|
package/bundle/cordis.patch.yml
CHANGED
|
@@ -107,6 +107,14 @@
|
|
|
107
107
|
disabled: true
|
|
108
108
|
- id: ui-settings-account
|
|
109
109
|
disabled: true
|
|
110
|
+
# DSH's Settings → Models page saves into `llm-pi-ai`, whose `kriya` route is
|
|
111
|
+
# built from `!!js` values; pi-ai checks a section before evaluating them, so
|
|
112
|
+
# every save there failed ("$.providers.kriya.baseURL expected string but got
|
|
113
|
+
# [object Object]"). Kriya's own Models section (plugins/cockpit) takes its
|
|
114
|
+
# place: the person's API keys (OpenRouter, OpenAI, …), models and Orchestration
|
|
115
|
+
# through the local relay. Web UI only; a no-op in the other profiles
|
|
116
|
+
- id: ui-settings-models
|
|
117
|
+
disabled: true
|
|
110
118
|
|
|
111
119
|
# The Web UI shows Kriya, not DeepSeek: the official brand row is off and
|
|
112
120
|
# Kriya's brand plugin (plugins/brand: sidebar mark and name, hero mark,
|
package/install.sh
CHANGED
package/package.json
CHANGED
package/plugins/brand/client.js
CHANGED
|
@@ -355,7 +355,7 @@ window.__ModuleLoader__.load({
|
|
|
355
355
|
jsx("span", { className: "kh-hero-question", children: "What are we working on?" }),
|
|
356
356
|
jsx("span", {
|
|
357
357
|
className: "kh-hero-note",
|
|
358
|
-
children: "Runs in this folder on your computer
|
|
358
|
+
children: "Runs in this folder on your computer, on Kriya's models or your own.",
|
|
359
359
|
}),
|
|
360
360
|
],
|
|
361
361
|
})
|
|
@@ -354,7 +354,7 @@ window.__ModuleLoader__.load({
|
|
|
354
354
|
jsx("span", { className: "kh-hero-question", children: "What are we working on?" }),
|
|
355
355
|
jsx("span", {
|
|
356
356
|
className: "kh-hero-note",
|
|
357
|
-
children: "Runs in this folder on your computer
|
|
357
|
+
children: "Runs in this folder on your computer, on Kriya's models or your own.",
|
|
358
358
|
}),
|
|
359
359
|
],
|
|
360
360
|
})
|
|
@@ -13,6 +13,7 @@ window.__ModuleLoader__.load({
|
|
|
13
13
|
const PLUGIN = "@kriya-ai/harness-cockpit"
|
|
14
14
|
const KIND = "kriya-cockpit"
|
|
15
15
|
const API = "api/kriya.cockpit"
|
|
16
|
+
const MODELS_API = "api/kriya.models"
|
|
16
17
|
const REFRESH_MS = 5000
|
|
17
18
|
|
|
18
19
|
const CSS = `
|
|
@@ -25,6 +26,9 @@ window.__ModuleLoader__.load({
|
|
|
25
26
|
.kh-dv-mono { font-family: var(--dsw-font-code, ui-monospace, monospace); font-size: 12px; }
|
|
26
27
|
.kh-dv-dim { color: var(--dsw-alias-label-tertiary); }
|
|
27
28
|
.kh-dv-note { font-size: 12px; line-height: 1.45; color: var(--dsw-alias-label-tertiary); margin: 2px 0 6px; }
|
|
29
|
+
.kh-dv-settings { padding: 0 0 24px; }
|
|
30
|
+
.kh-dv-title { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
|
|
31
|
+
.kh-dv-steps { font-size: 12px; line-height: 1.5; margin: 4px 0 6px; padding-left: 18px; display: grid; gap: 6px; }
|
|
28
32
|
.kh-dv-warn { color: var(--dsw-alias-state-warn-label, var(--dsw-alias-state-error-primary)); }
|
|
29
33
|
.kh-dv-err { color: var(--dsw-alias-state-error-primary); }
|
|
30
34
|
.kh-dv-ok { color: var(--dsw-alias-state-success-primary); }
|
|
@@ -278,7 +282,32 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
278
282
|
// Your models (Kriya-Tavi docs/kriya-harness/OWN_MODELS.md): the person's own API keys and
|
|
279
283
|
// their own orchestration. A key is typed here once, saved on this computer only, and never
|
|
280
284
|
// shown again (its last four characters only)
|
|
281
|
-
|
|
285
|
+
// Standalone Mode (no Kriya account, or Kriya unreachable): what runs, and the two ways to a model
|
|
286
|
+
const WHY = {
|
|
287
|
+
signed_out: "You're not signed in to Kriya.",
|
|
288
|
+
server_unreachable: "Kriya isn't reachable right now.",
|
|
289
|
+
requested: "Started with --standalone.",
|
|
290
|
+
}
|
|
291
|
+
function GetStarted({ mode, own }) {
|
|
292
|
+
if (!mode?.standalone) return null
|
|
293
|
+
const ready = (own?.models?.length ?? 0) > 0 || Boolean(mode.localModel)
|
|
294
|
+
const rows = [h("p", { key: "w", className: "kh-dv-note" }, `${WHY[mode.reason] ?? WHY.signed_out} Kriya Harness runs in Standalone Mode: every Harness 2.0 feature works on this computer, on your own models.`)]
|
|
295
|
+
if (ready)
|
|
296
|
+
rows.push(h("p", { key: "r", className: "kh-dv-note" }, `Ready: ${[...(own?.models ?? []).map((m) => m.name), ...(mode.localModel ? [mode.localModel] : [])].join(", ")}. Choose one, or Orchestration, in the model picker.`))
|
|
297
|
+
else
|
|
298
|
+
rows.push(
|
|
299
|
+
h(
|
|
300
|
+
"ol",
|
|
301
|
+
{ key: "s", className: "kh-dv-steps" },
|
|
302
|
+
h("li", null, "Add an API key under ", h("b", null, "Your models"), " below (OpenRouter, OpenAI, DeepSeek, Groq, …), load its models and add one or two; pick a head and a worker for Orchestration. Then restart kriya."),
|
|
303
|
+
h("li", null, "Or run a model on this computer: start Ollama or LM Studio, then restart with ", h(Copy, { text: "kriya --local-model" })),
|
|
304
|
+
h("li", null, "Or connect a Kriya account (cloud, or your own at localhost:6796): ", h(Copy, { text: "kriya login --url https://<your Kriya address>" }))
|
|
305
|
+
)
|
|
306
|
+
)
|
|
307
|
+
return Section("Standalone Mode", rows)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function OwnModels({ own, run, busy, changed, standalone }) {
|
|
282
311
|
const [keyFor, setKeyFor] = useState(null)
|
|
283
312
|
const [key, setKey] = useState("")
|
|
284
313
|
const [url, setUrl] = useState("")
|
|
@@ -363,7 +392,7 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
363
392
|
}
|
|
364
393
|
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))]
|
|
365
394
|
push("oh", h("h4", { className: "kh-dv-sub" }, "Your orchestration"))
|
|
366
|
-
push("on", h("p", { className: "kh-dv-note" },
|
|
395
|
+
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${standalone ? "" : ", Kriya's"} and a local one.`))
|
|
367
396
|
push(
|
|
368
397
|
"os",
|
|
369
398
|
h(
|
|
@@ -378,7 +407,7 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
378
407
|
h(
|
|
379
408
|
"div",
|
|
380
409
|
{ className: "kh-dv-row" },
|
|
381
|
-
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."),
|
|
410
|
+
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.` : standalone ? "Not set: one model runs the whole session." : "Not set: Kriya's orchestration is used."),
|
|
382
411
|
own.orchestra && h("button", { type: "button", className: "kh-dv-btn", disabled: busy, onClick: () => run({ action: "own.orchestra", orchestra: null }).then(() => (setHead(""), setWorker(""))) }, "Clear"),
|
|
383
412
|
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")
|
|
384
413
|
)
|
|
@@ -388,6 +417,57 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
388
417
|
return Section("Your models", rows)
|
|
389
418
|
}
|
|
390
419
|
|
|
420
|
+
// Settings → Models (in place of DSH's page, which can't save next to Kriya's own route):
|
|
421
|
+
// the person's API keys, models and Orchestration, the same as the Developer tab, no session needed
|
|
422
|
+
function SettingsModels() {
|
|
423
|
+
const [data, setData] = useState(null)
|
|
424
|
+
const [error, setError] = useState(null)
|
|
425
|
+
const [busy, setBusy] = useState(false)
|
|
426
|
+
const [changed, setChanged] = useState(false)
|
|
427
|
+
const load = useCallback(async () => {
|
|
428
|
+
try {
|
|
429
|
+
const response = await fetch(MODELS_API, { credentials: "same-origin" })
|
|
430
|
+
const body = await response.json().catch(() => ({}))
|
|
431
|
+
if (!response.ok) throw new Error(body.error || `Kriya Harness answered ${response.status}.`)
|
|
432
|
+
setData(body)
|
|
433
|
+
} catch (e) {
|
|
434
|
+
setError(e.message === "Failed to fetch" ? "Kriya Harness isn't answering; is it still running?" : e.message)
|
|
435
|
+
}
|
|
436
|
+
}, [])
|
|
437
|
+
useEffect(() => {
|
|
438
|
+
load()
|
|
439
|
+
}, [load])
|
|
440
|
+
const run = async (body) => {
|
|
441
|
+
setBusy(true)
|
|
442
|
+
setError(null)
|
|
443
|
+
try {
|
|
444
|
+
const response = await fetch(MODELS_API, { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })
|
|
445
|
+
const answer = await response.json().catch(() => ({}))
|
|
446
|
+
if (!response.ok) throw new Error(answer.error || `Kriya Harness answered ${response.status}.`)
|
|
447
|
+
if (body.action !== "own.models.list") setChanged(true)
|
|
448
|
+
if (answer.own) setData((d) => ({ ...d, own: answer.own }))
|
|
449
|
+
return answer
|
|
450
|
+
} catch (e) {
|
|
451
|
+
setError(e.message)
|
|
452
|
+
return null
|
|
453
|
+
} finally {
|
|
454
|
+
setBusy(false)
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const standalone = Boolean(data?.mode?.standalone)
|
|
458
|
+
return h(
|
|
459
|
+
"div",
|
|
460
|
+
{ className: "kh-dv kh-dv-settings" },
|
|
461
|
+
h("h2", { className: "kh-dv-title" }, "Models"),
|
|
462
|
+
h("p", { className: "kh-dv-note" }, standalone ? "Kriya Harness runs in Standalone Mode: use your own API keys (OpenRouter, OpenAI, …) or a local model, one at a time or as an Orchestration." : "Kriya's models come with your Kriya plan. Add your own API keys to use other models, alone or in your own Orchestration."),
|
|
463
|
+
error && h("div", { className: "kh-dv-error", role: "alert" }, error),
|
|
464
|
+
!data && !error && h("div", { className: "kh-dv-empty" }, "Loading…"),
|
|
465
|
+
data && h(GetStarted, { mode: data.mode, own: data.own }),
|
|
466
|
+
data?.own && h(OwnModels, { own: data.own, run, busy, changed, standalone }),
|
|
467
|
+
data && !data.own && h("p", { className: "kh-dv-note" }, "Your own models aren't turned on for your Kriya account yet; ask your Kriya owner, or run kriya --standalone.")
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
|
|
391
471
|
function DeveloperBody({ useTabInfo, sessionId }) {
|
|
392
472
|
const { tab } = useTabInfo()
|
|
393
473
|
const visible = tab?.visible !== false
|
|
@@ -466,8 +546,11 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
466
546
|
)
|
|
467
547
|
),
|
|
468
548
|
done && h("div", { className: "kh-dv-empty", role: "status" }, "Created: ", h("a", { className: "kh-dv-link", href: done, target: "_blank", rel: "noreferrer" }, done)),
|
|
549
|
+
h(GetStarted, { key: "gs", mode: data.mode, own: data.own }),
|
|
550
|
+
// Standalone, your models come first: nothing answers until one is set up
|
|
551
|
+
data.mode?.standalone && data.own && h(OwnModels, { key: "o", own: data.own, run, busy, changed, standalone: true }),
|
|
469
552
|
h(GitHub, { key: "g", data, act, busy }),
|
|
470
|
-
data.own && h(OwnModels, { key: "o", own: data.own, run, busy, changed }),
|
|
553
|
+
!data.mode?.standalone && data.own && h(OwnModels, { key: "o", own: data.own, run, busy, changed }),
|
|
471
554
|
data.ownError && Section("Your models", h("p", { className: "kh-dv-note kh-dv-err", role: "alert" }, data.ownError)),
|
|
472
555
|
h(Connections, { key: "c", data, act, busy, refresh: () => load(true) }),
|
|
473
556
|
h(Servers, { key: "s", data, act, busy }),
|
|
@@ -489,6 +572,8 @@ select.kh-dv-input { padding-right: 6px; }
|
|
|
489
572
|
if (typeof document !== "undefined") ctx.effect(installStyles, "kriya-cockpit: styles")
|
|
490
573
|
ctx.effect(() => ctx.sidebarRightTabs.register(definition), "kriya-cockpit: type")
|
|
491
574
|
ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: PLUGIN }, DeveloperBody)), "kriya-cockpit: body")
|
|
575
|
+
// Settings → Models, where DSH's own section was (bundle/cordis.patch.yml turns that one off)
|
|
576
|
+
ctx.effect(() => ctx.slots.inject("settings.section", () => ctx.slots.register({ name: "settings.section", id: "models", order: 10, label: () => "Models" }, SettingsModels)), "kriya-cockpit: settings models")
|
|
492
577
|
}
|
|
493
578
|
|
|
494
579
|
return { apply, inject, DeveloperBody, definition, API }
|
package/plugins/cockpit/index.js
CHANGED
|
@@ -14,6 +14,9 @@ export const name = "kriya-cockpit"
|
|
|
14
14
|
export const inject = ["connection", "sessions"]
|
|
15
15
|
|
|
16
16
|
export const ROUTE = "/api/kriya.cockpit"
|
|
17
|
+
// Settings → Models (Kriya's, in place of DSH's): the same own-model setup, with no session needed
|
|
18
|
+
export const MODELS_ROUTE = "/api/kriya.models"
|
|
19
|
+
const OWN_ACTIONS = new Set(["own.key.save", "own.key.remove", "own.models.list", "own.model.add", "own.model.remove", "own.orchestra"])
|
|
17
20
|
export const CACHE_MS = 60_000
|
|
18
21
|
const REPO_NAME = /^[A-Za-z0-9._-]{1,100}$/
|
|
19
22
|
|
|
@@ -30,6 +33,13 @@ export function handler(host) {
|
|
|
30
33
|
const ownOn = host.ownOn ?? (() => process.env.KRIYA_OWN_MODELS_OFFER === "on")
|
|
31
34
|
const ownPath = host.ownFile ?? ownFile()
|
|
32
35
|
const fetchImpl = host.fetchImpl ?? fetch
|
|
36
|
+
const standalone = host.standalone ?? (() => process.env.KRIYA_STANDALONE === "on")
|
|
37
|
+
// How this app runs, for the tab's first card: connected to Kriya, or Standalone Mode and why
|
|
38
|
+
const mode = () => ({
|
|
39
|
+
standalone: standalone(),
|
|
40
|
+
...(standalone() && { reason: ["signed_out", "server_unreachable", "requested"].includes(process.env.KRIYA_STANDALONE_REASON) ? process.env.KRIYA_STANDALONE_REASON : "signed_out" }),
|
|
41
|
+
localModel: process.env.KRIYA_LOCAL_MODEL_ID ? String(process.env.KRIYA_LOCAL_MODEL_LABEL || process.env.KRIYA_LOCAL_MODEL_ID).slice(0, 80) : null,
|
|
42
|
+
})
|
|
33
43
|
// What the head and worker can be: this plan's Kriya tiers, the person's own models, and the local model
|
|
34
44
|
const choices = () => {
|
|
35
45
|
let names = {}
|
|
@@ -38,7 +48,8 @@ export function handler(host) {
|
|
|
38
48
|
} catch {
|
|
39
49
|
names = {}
|
|
40
50
|
}
|
|
41
|
-
|
|
51
|
+
// Standalone Mode: no Kriya tier answers, so none is offered
|
|
52
|
+
const tiers = standalone() ? [] : String(process.env.KRIYA_ALLOWED_TIERS || "balanced,budget,escalation").split(",").filter((t) => ["balanced", "budget", "escalation"].includes(t))
|
|
42
53
|
return [
|
|
43
54
|
// The names keep their " · <tier>" when two tiers share a model, so each choice reads differently
|
|
44
55
|
...tiers.map((t) => ({ id: t, name: `Kriya · ${String(names[t] ?? t)}` })),
|
|
@@ -98,7 +109,35 @@ export function handler(host) {
|
|
|
98
109
|
return { repoTools: { saved: s["repo-tools"] ?? null, running: process.env.KRIYA_REPO_TOOLS === "on" }, providerTools: { saved: s["provider-tools"] ?? null, running: process.env.KRIYA_PROVIDER_TOOLS === "on" } }
|
|
99
110
|
}
|
|
100
111
|
|
|
112
|
+
async function ownAct(body) {
|
|
113
|
+
if (!ownOn()) throw new CockpitError("Your own models aren't turned on for your Kriya account yet.")
|
|
114
|
+
if (body.action === "own.key.save") saveKey(body.provider, body.key, body.url, ownPath)
|
|
115
|
+
else if (body.action === "own.key.remove") removeKey(body.provider, ownPath)
|
|
116
|
+
else if (body.action === "own.models.list") return { models: await listProviderModels(body.provider, ownPath, fetchImpl) }
|
|
117
|
+
else if (body.action === "own.model.add") addModel(body.provider, body.model, body.contextWindow, ownPath)
|
|
118
|
+
else if (body.action === "own.model.remove") removeModel(body.id, ownPath)
|
|
119
|
+
else setOrchestra(body.orchestra ?? null, ownPath)
|
|
120
|
+
// Never the key: the masked view only
|
|
121
|
+
return { done: body.action, own: own() }
|
|
122
|
+
}
|
|
123
|
+
const parse = async (request) => {
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(await request.text())
|
|
126
|
+
} catch {
|
|
127
|
+
throw new CockpitError("Kriya couldn't read that request.")
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
101
131
|
return {
|
|
132
|
+
// Settings → Models: how this app runs and the person's own models, outside any session
|
|
133
|
+
async models() {
|
|
134
|
+
return { mode: mode(), own: own() }
|
|
135
|
+
},
|
|
136
|
+
async modelsAct(request) {
|
|
137
|
+
const body = await parse(request)
|
|
138
|
+
if (!OWN_ACTIONS.has(body?.action)) throw new CockpitError("Kriya doesn't know that action.")
|
|
139
|
+
return ownAct(body)
|
|
140
|
+
},
|
|
102
141
|
async read(request) {
|
|
103
142
|
const url = new URL(request.url)
|
|
104
143
|
const cwd = await folder(url.searchParams.get("session"))
|
|
@@ -117,15 +156,11 @@ export function handler(host) {
|
|
|
117
156
|
section("the project's health", () => health(cwd, run), { stack: [], scripts: [], check: null, git: false, tracked: [], unignored: [] }),
|
|
118
157
|
section("your models", () => own(), null),
|
|
119
158
|
])
|
|
120
|
-
return { folder: cwd, connections: Array.isArray(list) ? list : [], ...(list?.error && { connectionsError: list.error }), signIn: signIn.state(), github: gh, servers: running, health: checkup, switches: saved(), own: ownView?.error ? null : ownView, ...(ownView?.error && { ownError: ownView.error }) }
|
|
159
|
+
return { folder: cwd, mode: mode(), connections: Array.isArray(list) ? list : [], ...(list?.error && { connectionsError: list.error }), signIn: signIn.state(), github: gh, servers: running, health: checkup, switches: saved(), own: ownView?.error ? null : ownView, ...(ownView?.error && { ownError: ownView.error }) }
|
|
121
160
|
},
|
|
122
161
|
async act(request) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
body = JSON.parse(await request.text())
|
|
126
|
-
} catch {
|
|
127
|
-
throw new CockpitError("Kriya couldn't read that request.")
|
|
128
|
-
}
|
|
162
|
+
const body = await parse(request)
|
|
163
|
+
if (OWN_ACTIONS.has(body?.action)) return ownAct(body)
|
|
129
164
|
const cwd = await folder(body?.session)
|
|
130
165
|
switch (body?.action) {
|
|
131
166
|
case "github.signin":
|
|
@@ -158,22 +193,6 @@ export function handler(host) {
|
|
|
158
193
|
switches.save(flag, body.on)
|
|
159
194
|
return { done: "switch", switches: saved() }
|
|
160
195
|
}
|
|
161
|
-
case "own.key.save":
|
|
162
|
-
case "own.key.remove":
|
|
163
|
-
case "own.models.list":
|
|
164
|
-
case "own.model.add":
|
|
165
|
-
case "own.model.remove":
|
|
166
|
-
case "own.orchestra": {
|
|
167
|
-
if (!ownOn()) throw new CockpitError("Your own models aren't turned on for your Kriya account yet.")
|
|
168
|
-
if (body.action === "own.key.save") saveKey(body.provider, body.key, body.url, ownPath)
|
|
169
|
-
else if (body.action === "own.key.remove") removeKey(body.provider, ownPath)
|
|
170
|
-
else if (body.action === "own.models.list") return { models: await listProviderModels(body.provider, ownPath, fetchImpl) }
|
|
171
|
-
else if (body.action === "own.model.add") addModel(body.provider, body.model, body.contextWindow, ownPath)
|
|
172
|
-
else if (body.action === "own.model.remove") removeModel(body.id, ownPath)
|
|
173
|
-
else setOrchestra(body.orchestra ?? null, ownPath)
|
|
174
|
-
// Never the key: the masked view only
|
|
175
|
-
return { done: body.action, own: own() }
|
|
176
|
-
}
|
|
177
196
|
default:
|
|
178
197
|
throw new CockpitError("Kriya doesn't know that action.")
|
|
179
198
|
}
|
|
@@ -210,5 +229,13 @@ export function apply(ctx) {
|
|
|
210
229
|
fetch: (request) => answer(request.method === "POST" ? routes.act : routes.read, request, log),
|
|
211
230
|
})
|
|
212
231
|
)
|
|
232
|
+
ctx.effect(() =>
|
|
233
|
+
ctx.connection.fetch.register({
|
|
234
|
+
path: MODELS_ROUTE,
|
|
235
|
+
methods: ["GET", "POST"],
|
|
236
|
+
requestBody: "buffered",
|
|
237
|
+
fetch: (request) => answer(request.method === "POST" ? routes.modelsAct : routes.models, request, log),
|
|
238
|
+
})
|
|
239
|
+
)
|
|
213
240
|
}
|
|
214
241
|
|
|
@@ -185,6 +185,9 @@ export const memorySave = defineTool({
|
|
|
185
185
|
export function apply(ctx) {
|
|
186
186
|
ctx.skills.registerProvider(() => kriyaSkills())
|
|
187
187
|
ctx.skills.registerProvider((control) => switchProvider(control))
|
|
188
|
+
// Signed out or Standalone Mode (the launch's sign-in is fixed for DSH's life): no memory
|
|
189
|
+
// tools at all, so the model never spends a step on one that can only answer "signed out"
|
|
190
|
+
if (!deviceFromEnv()) return
|
|
188
191
|
ctx.tools.register(memorySearch)
|
|
189
192
|
ctx.tools.register(memorySave)
|
|
190
193
|
}
|
package/plugins/remote/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { basename, join } from "node:path"
|
|
|
4
4
|
import { deviceSender, externalDaemon, offeredProjects, runDaemon } from "../../src/daemon.js"
|
|
5
5
|
import { liveChange } from "../../src/live.js"
|
|
6
6
|
import { kriyaHome } from "../../src/paths.js"
|
|
7
|
-
import { readDevice } from "../../src/store.js"
|
|
7
|
+
import { activeDevice as readDevice } from "../../src/store.js"
|
|
8
8
|
|
|
9
9
|
// Remote Control (Kriya-Tavi docs/kriya-harness/REMOTE_CONTROL.md): the switch
|
|
10
10
|
// in a session's Overview tab. On, this process (1) streams that session to
|
|
@@ -280,7 +280,7 @@ export function apply(ctx) {
|
|
|
280
280
|
const body = await request.json().catch(() => null)
|
|
281
281
|
const session = await sessionOf(id)
|
|
282
282
|
if (!body || !session) return reply({ error: "That session isn't known here." }, 400)
|
|
283
|
-
if (body.on === true && !readDevice()) return reply({ error: "Sign in with kriya login first." }, 400)
|
|
283
|
+
if (body.on === true && !readDevice()) return reply({ error: process.env.KRIYA_STANDALONE === "on" ? "Remote Control needs Kriya, and this app runs in Standalone Mode; restart kriya once Kriya is reachable (or after kriya login)." : "Sign in with kriya login first." }, 400)
|
|
284
284
|
// The allowances exist only while Remote Control is on
|
|
285
285
|
if ((body.serve === true || body.fullAccess === true || body.edit === true) && !r.state.sessions[id]) return reply({ error: "Turn on Remote Control first." }, 400)
|
|
286
286
|
await r.set(id, { on: body.on, serve: body.serve, fullAccess: body.fullAccess, edit: body.edit }, session)
|
|
@@ -16,7 +16,7 @@ import { receiptFiles, verifyReceipt } from "../../src/receipts.js"
|
|
|
16
16
|
import { formatInr, liveGates, missionRows, stepChips, stripState } from "../../src/runstrip.js"
|
|
17
17
|
import { projectRoot } from "../../src/skill-switches.js"
|
|
18
18
|
import { readProgress } from "../../src/verify.js"
|
|
19
|
-
import { readDevice } from "../../src/store.js"
|
|
19
|
+
import { activeDevice as readDevice } from "../../src/store.js"
|
|
20
20
|
import { createRepo } from "../repo/repo.js"
|
|
21
21
|
|
|
22
22
|
// Harness 2.0 W18 (WD-23), node half: the Run strip, Mission Control and the
|
package/src/api.js
CHANGED
|
@@ -68,11 +68,16 @@ export async function call(url, method, path, { token, body, bodyText, signal, h
|
|
|
68
68
|
return data
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/** Kriya can't be asked at all: no connection, a timeout, or the host itself failing (5xx). A 401, 403 or 426 is an answer */
|
|
72
|
+
export const unreachable = (error) => error instanceof KriyaError && (error.status === 0 || error.status >= 500)
|
|
73
|
+
|
|
71
74
|
/**
|
|
72
75
|
* Inside DSH: the signed-in device, from the variables the launcher sets
|
|
73
76
|
* (src/launch.js), for the Kriya plugins. Null when signed out.
|
|
74
77
|
*/
|
|
75
78
|
export function deviceFromEnv(env = process.env) {
|
|
79
|
+
// Standalone Mode (src/launch.js): the token is a stand-in and the relay has no Kriya behind it
|
|
80
|
+
if (env.KRIYA_STANDALONE === "on") return null
|
|
76
81
|
const token = env.KRIYA_DEVICE_TOKEN
|
|
77
82
|
const gateway = env.KRIYA_GATEWAY_URL
|
|
78
83
|
if (!token || !gateway?.endsWith(BASE_PATH)) return null
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
// The Director's route to a model: the person's own Kriya gateway, with the device the
|
|
2
2
|
// Edit Host reads itself (STUDIO_APP §2). Tier aliases only; Kriya maps them to models
|
|
3
|
-
// and meters the spend. Signed out,
|
|
3
|
+
// and meters the spend. Signed out, or Kriya unreachable (network, timeout, 5xx), the call
|
|
4
|
+
// goes to the person's own or local model (./local.js); a refusal (401, 403, 426, any other
|
|
5
|
+
// 4xx) stays a refusal. With no model at all, every call fails plainly and slots take defaults.
|
|
4
6
|
|
|
5
|
-
import { call,
|
|
7
|
+
import { call, unreachable } from "../../api.js"
|
|
6
8
|
import { readDevice } from "../../store.js"
|
|
9
|
+
import { sharedLocal } from "./local.js"
|
|
7
10
|
|
|
8
11
|
/** @returns {(body: object, signal?: AbortSignal) => Promise<object>} */
|
|
9
|
-
export function gatewaySend({ device = readDevice, timeoutMs = 120_000 } = {}) {
|
|
12
|
+
export function gatewaySend({ device = readDevice, timeoutMs = 120_000, local = sharedLocal() } = {}) {
|
|
10
13
|
return async (body, signal) => {
|
|
11
|
-
const signedIn = device()
|
|
12
|
-
if (!signedIn) throw new KriyaError(401, "signed_out", "This computer isn't signed in to Kriya. Run kriya login.")
|
|
13
14
|
const limit = AbortSignal.timeout(timeoutMs)
|
|
14
|
-
|
|
15
|
+
const both = signal ? AbortSignal.any([signal, limit]) : limit
|
|
16
|
+
const signedIn = device()
|
|
17
|
+
if (signedIn && !local.isDown()) {
|
|
18
|
+
try {
|
|
19
|
+
return await call(signedIn.url, "POST", "/chat/completions", { token: signedIn.token, body: { ...body, stream: false }, signal: both })
|
|
20
|
+
} catch (error) {
|
|
21
|
+
// The person stopped it, or Kriya answered and refused: as before
|
|
22
|
+
if (signal?.aborted || !unreachable(error)) throw error
|
|
23
|
+
local.markDown()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return local.send(body, both)
|
|
15
27
|
}
|
|
16
28
|
}
|