@kriya-ai/harness 2.1.1 → 2.2.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/README.md +19 -0
- package/RELEASE_NOTES.md +13 -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 +2 -0
- package/src/gateway-proxy.js +6 -2
- package/src/intent.js +2 -1
- package/src/launch.js +130 -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/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,18 @@
|
|
|
1
1
|
# Kriya Harness release notes
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
- **Added:** **Standalone Mode** (`--standalone`, or automatically when signed
|
|
6
|
+
out or when Kriya is unreachable due to network errors, timeouts, or 5xx
|
|
7
|
+
responses). All local Harness 2.0 features run on your machine using your own
|
|
8
|
+
API keys (OpenRouter, OpenAI, DeepSeek, Groq, Together, Mistral, or custom
|
|
9
|
+
OpenAI-compatible endpoints), your own Orchestration, or a local model
|
|
10
|
+
(`--local-model`). Explicit account refusals (401, 403, 426) are surfaced
|
|
11
|
+
and never bypassed.
|
|
12
|
+
- **Added:** **Settings → Models** panel in the Web UI (and `--workforce`
|
|
13
|
+
flag) to configure your own API keys, models, and Orchestration without an
|
|
14
|
+
active session.
|
|
15
|
+
|
|
3
16
|
## 2.1.1
|
|
4
17
|
|
|
5
18
|
- **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
|
@@ -73,6 +73,8 @@ export async function call(url, method, path, { token, body, bodyText, signal, h
|
|
|
73
73
|
* (src/launch.js), for the Kriya plugins. Null when signed out.
|
|
74
74
|
*/
|
|
75
75
|
export function deviceFromEnv(env = process.env) {
|
|
76
|
+
// Standalone Mode (src/launch.js): the token is a stand-in and the relay has no Kriya behind it
|
|
77
|
+
if (env.KRIYA_STANDALONE === "on") return null
|
|
76
78
|
const token = env.KRIYA_DEVICE_TOKEN
|
|
77
79
|
const gateway = env.KRIYA_GATEWAY_URL
|
|
78
80
|
if (!token || !gateway?.endsWith(BASE_PATH)) return null
|
package/src/gateway-proxy.js
CHANGED
|
@@ -170,8 +170,10 @@ function counting(onEnd) {
|
|
|
170
170
|
* @param {{ target: string, encode: boolean, checkSupport?: () => Promise<boolean>, fetchImpl?: typeof fetch, log?: (text: string) => void, now?: () => number, retryMs?: number }} options
|
|
171
171
|
* @returns {Promise<{ url: string, close: () => Promise<void>, encoding: () => boolean }>} url stands in for device.url inside DSH
|
|
172
172
|
*/
|
|
173
|
-
export async function startGatewayProxy({ target, encode, checkSupport, aliases = {}, local = null, routes = null, onUsage = () => {}, fetchImpl = fetch, log = () => {}, now = Date.now, retryMs = RETRY_MS, outageMs = OUTAGE_MS, outageWaitMs = OUTAGE_WAIT_MS }) {
|
|
174
|
-
|
|
173
|
+
export async function startGatewayProxy({ target = null, offline = null, encode, checkSupport, aliases = {}, local = null, routes = null, onUsage = () => {}, fetchImpl = fetch, log = () => {}, now = Date.now, retryMs = RETRY_MS, outageMs = OUTAGE_MS, outageWaitMs = OUTAGE_WAIT_MS }) {
|
|
174
|
+
// Standalone Mode: no Kriya behind the relay; only routed models answer, anything else gets `offline`
|
|
175
|
+
const origin = target ? new URL(target).origin : null
|
|
176
|
+
if (!origin && !offline) throw new Error("The relay needs a Kriya address, or an offline answer")
|
|
175
177
|
const support = { on: Boolean(encode), checked: now(), pending: null }
|
|
176
178
|
// Routed models: the person's own (with their key) and S-1's local model (without one)
|
|
177
179
|
const table = { ...(routes ?? {}), ...(local && { [LOCAL_MODEL]: { ...local, provider: "local" } }) }
|
|
@@ -246,6 +248,8 @@ export async function startGatewayProxy({ target, encode, checkSupport, aliases
|
|
|
246
248
|
const counted = answer.ok ? answer.body.pipeThrough(counting((u) => onUsage({ provider: route.provider, model: route.model, requests: 1, inputTokens: u?.inputTokens ?? 0, outputTokens: u?.outputTokens ?? 0, ...(u?.reportedCostMicroUsd !== undefined && { reportedCostMicroUsd: u.reportedCostMicroUsd }) }))) : answer.body
|
|
247
249
|
return await pipeline(Readable.fromWeb(counted), res)
|
|
248
250
|
}
|
|
251
|
+
// A 400 is shown and not retried (DSH retries 5xx), so the person reads what to do at once
|
|
252
|
+
if (!origin) return reply(400, JSON.stringify({ error: { message: offline, type: "kriya_offline", code: "kriya_offline" } }))
|
|
249
253
|
const encodable = Boolean(plain) && /^application\/json\b/i.test(headers["content-type"] ?? "")
|
|
250
254
|
if (encodable && !support.on && now() - support.checked >= RECHECK_MS) await recheck()
|
|
251
255
|
const once = (encoded) => {
|
package/src/intent.js
CHANGED
|
@@ -19,7 +19,8 @@ export function tokens(text) {
|
|
|
19
19
|
.filter((w) => w.length > 1 && !STOP.has(w))
|
|
20
20
|
.map((w) => {
|
|
21
21
|
const base = w.replace(/(ies)$/, "y")
|
|
22
|
-
|
|
22
|
+
// "-es" only after s, x, z, ch, sh ("fixes" → "fix"); else just "-s" ("files" → "file", not "fil")
|
|
23
|
+
const stem = base.replace(/(?:(?<=(?:s|x|z|ch|sh))es|ing|ed|s)$/, (m, _i, str) => (str.length - m.length >= 3 && !/ss$/.test(str) ? "" : m))
|
|
23
24
|
// "debugging" → "debugg" → "debug", "running" → "run" (not "ll", "ss", "zz")
|
|
24
25
|
return stem !== base && /(ing|ed)$/.test(base) && /([b-df-hj-km-np-rtv-y])\1$/.test(stem) ? stem.slice(0, -1) : stem
|
|
25
26
|
})
|
package/src/launch.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "node:child_process"
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import { join } from "node:path"
|
|
2
4
|
|
|
3
5
|
import { broadcastRun } from "./daemon.js"
|
|
4
6
|
import { BODY_ENCODING, ORCHESTRA_ALIAS, startGatewayProxy } from "./gateway-proxy.js"
|
|
5
|
-
import { BASE_PATH, models } from "./api.js"
|
|
6
|
-
import { applyWorkforce, DEFAULT_MODE, modeEnv, SET_BY_PERSON } from "./modes.js"
|
|
7
|
+
import { BASE_PATH, KriyaError, models } from "./api.js"
|
|
8
|
+
import { applyWorkforce, DEFAULT_MODE, modeEnv, SET_BY_PERSON, STANDALONE_SWITCHES } from "./modes.js"
|
|
7
9
|
import { LOCAL_WORKER, localWorker } from "./local-model.js"
|
|
8
10
|
import { launchOwn, ownFile, readOwn } from "./own-models.js"
|
|
9
11
|
import { usageReporter } from "./own-usage.js"
|
|
@@ -30,9 +32,10 @@ export const START_TIERS = ["balanced", "budget", "escalation"]
|
|
|
30
32
|
* When Kriya can't be asked, all of them: the gateway still refuses what
|
|
31
33
|
* the plan lacks, and a short outage mustn't leave the picker empty.
|
|
32
34
|
*/
|
|
33
|
-
export async function planTiers(device, list = models) {
|
|
35
|
+
export async function planTiers(device, list = models, { standalone = false } = {}) {
|
|
34
36
|
const all = { start: START_TIERS[0], allowed: [...START_TIERS], names: {}, limits: {}, images: [], encodings: [] }
|
|
35
|
-
if (!device) return
|
|
37
|
+
if (!device) return standaloneTiers("signed_out")
|
|
38
|
+
if (standalone) return standaloneTiers("requested")
|
|
36
39
|
try {
|
|
37
40
|
const answer = await list(device.url, device.token)
|
|
38
41
|
const data = answer.data
|
|
@@ -52,12 +55,31 @@ export async function planTiers(device, list = models) {
|
|
|
52
55
|
// Own models: the person may use their own keys and orchestration (Kriya's harness.ownModels)
|
|
53
56
|
const ownModels = answer.ownModels === 1
|
|
54
57
|
return allowed.length ? { start: allowed[0], allowed, names: modelNames(data, allowed), limits: modelLimits(data, allowed), images: allowed.filter((tier) => data.find((m) => m.id === tier)?.images === true), encodings, ...(orchestra && { orchestra }), ...(workforce && { workforce }), ...(localModels && { localModels }), ...(cockpit && { cockpit }), ...(ownModels && { ownModels }) } : { ...all, encodings }
|
|
55
|
-
} catch {
|
|
56
|
-
//
|
|
58
|
+
} catch (error) {
|
|
59
|
+
// A suspended host (Render's 503), a network error or a timeout: this computer carries on alone
|
|
60
|
+
if (unreachable(error)) return standaloneTiers("server_unreachable")
|
|
61
|
+
// Kriya refused: said as such, never bypassed (the gateway refuses every request the same way)
|
|
62
|
+
if (error instanceof KriyaError && REFUSED.has(error.status)) return { ...all, refused: { status: error.status, code: error.code, message: error.message } }
|
|
63
|
+
// Anything else: Kriya answers the first request with the reason if it's refused
|
|
57
64
|
return all
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
|
|
68
|
+
// Sign-in, suspension and version refusals: these stay Kriya's to decide
|
|
69
|
+
const REFUSED = new Set([401, 403, 426])
|
|
70
|
+
/** Kriya can't be asked at all: no connection, a timeout, or the host itself failing (5xx) */
|
|
71
|
+
export const unreachable = (error) => error instanceof KriyaError && (error.status === 0 || error.status >= 500)
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Standalone Mode: no Kriya account, `--standalone`, or Kriya unreachable.
|
|
75
|
+
* Every Harness 2.0 feature runs on this computer, on the person's own keys and
|
|
76
|
+
* local model through the local relay; no Kriya tier is offered (none answers).
|
|
77
|
+
* @param {"signed_out" | "server_unreachable" | "requested"} reason
|
|
78
|
+
*/
|
|
79
|
+
export function standaloneTiers(reason) {
|
|
80
|
+
return { start: START_TIERS[0], allowed: [], names: {}, limits: {}, images: [], encodings: [], standalone: true, reason, workforce: true, cockpit: true, ownModels: true, localModels: true }
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
// The contract's own rule for a model name (contract/contract.json /models)
|
|
62
84
|
const MODEL_NAME = /^[\p{L}\p{N} .()+\/:_-]{1,60}$/u
|
|
63
85
|
|
|
@@ -116,17 +138,24 @@ export function orchestraName(orchestra, names = {}) {
|
|
|
116
138
|
return `Orchestration · ${plain(orchestra.head)} leads, ${plain(orchestra.worker)} builds`.slice(0, 120)
|
|
117
139
|
}
|
|
118
140
|
|
|
119
|
-
export function launchEnv(device, base = process.env, mode = DEFAULT_MODE, tier = START_TIERS[0], allowed = START_TIERS, names = {}, limits = {}, images = [], orchestra, pick = false, local = null, own = null) {
|
|
141
|
+
export function launchEnv(device, base = process.env, mode = DEFAULT_MODE, tier = START_TIERS[0], allowed = START_TIERS, names = {}, limits = {}, images = [], orchestra, pick = false, local = null, own = null, standalone = false) {
|
|
120
142
|
// Own models (src/own-models.js): ids, names and windows only; keys stay in the launcher's relay
|
|
121
143
|
const ownModels = pick && own?.models?.length ? own.models : []
|
|
122
144
|
const ownIds = ownModels.map((m) => m.id)
|
|
123
145
|
// The person's own orchestration, when it's the one chosen (and the relay that routes it is on)
|
|
124
146
|
const personal = Boolean(pick && own?.orchestra && orchestra === own.orchestra)
|
|
125
147
|
// S-1: a found local server builds as the owner's orchestra's worker; in the person's own, only where they chose it
|
|
126
|
-
|
|
127
|
-
const
|
|
148
|
+
// Standalone, it may also be a model of its own in the picker, with no orchestration
|
|
149
|
+
const localOn = Boolean(local && pick && (orchestra ? !personal || orchestra.worker === LOCAL_WORKER : standalone))
|
|
150
|
+
const levels = personal || !orchestra ? orchestra : localOn ? { ...orchestra, worker: LOCAL_WORKER } : orchestra
|
|
128
151
|
const named = { ...names, ...(localOn && { [LOCAL_WORKER]: `Local · ${local.model}`.slice(0, 80) }), ...Object.fromEntries(ownModels.map((m) => [m.id, m.name])) }
|
|
129
152
|
const usable = (id) => START_TIERS.includes(id) || ownIds.includes(id) || (id === LOCAL_WORKER && localOn)
|
|
153
|
+
const hidden = Boolean(standalone) && (ownIds.length > 0 || localOn)
|
|
154
|
+
// Standalone: `{ reason, keep, keepName }`; `keep` is a Kriya tier the person pinned as DSH's default
|
|
155
|
+
// model, kept in the picker (the relay sends it to their own model) so DSH doesn't refuse to start
|
|
156
|
+
const sa = standalone ? (typeof standalone === "string" ? { reason: standalone } : standalone) : null
|
|
157
|
+
const keep = hidden && START_TIERS.includes(sa?.keep) ? sa.keep : null
|
|
158
|
+
if (keep) named[keep] = `${String(sa.keepName ?? "Your model").slice(0, 50)} · your saved default`
|
|
130
159
|
const env = {
|
|
131
160
|
...base,
|
|
132
161
|
// The mode always comes from `--mode` (or the default), never the shell
|
|
@@ -137,7 +166,8 @@ export function launchEnv(device, base = process.env, mode = DEFAULT_MODE, tier
|
|
|
137
166
|
KRIYA_CLIENT_VERSION: CLIENT_VERSION,
|
|
138
167
|
KRIYA_START_TIER: START_TIERS.includes(tier) ? tier : START_TIERS[0],
|
|
139
168
|
// Read by the kriya provider row: the models the picker offers. Never from the shell
|
|
140
|
-
|
|
169
|
+
// Standalone with a model of the person's own: no Kriya tier (none would answer); "none" matches no tier
|
|
170
|
+
KRIYA_ALLOWED_TIERS: hidden ? (keep ?? "none") : (allowed.filter((t) => START_TIERS.includes(t)).length ? allowed.filter((t) => START_TIERS.includes(t)) : START_TIERS).join(","),
|
|
141
171
|
// The picker's name per tier (modelNames), as JSON. Never from the shell
|
|
142
172
|
KRIYA_MODEL_NAMES: JSON.stringify(Object.fromEntries(Object.entries(named).filter(([t, n]) => usable(t) && typeof n === "string" && n.length <= 80))),
|
|
143
173
|
// Each tier's context window, output cap and compaction headroom (modelLimits), as JSON. Never from the shell
|
|
@@ -155,6 +185,19 @@ export function launchEnv(device, base = process.env, mode = DEFAULT_MODE, tier
|
|
|
155
185
|
delete env.KRIYA_OWN_MODELS
|
|
156
186
|
delete env.KRIYA_OWN_MODEL_IDS
|
|
157
187
|
delete env.KRIYA_KEY_HASHES
|
|
188
|
+
// Standalone Mode only from the launcher, never the shell (plugins read it: src/api.js deviceFromEnv)
|
|
189
|
+
delete env.KRIYA_STANDALONE
|
|
190
|
+
delete env.KRIYA_STANDALONE_REASON
|
|
191
|
+
if (sa) {
|
|
192
|
+
env.KRIYA_STANDALONE = "on"
|
|
193
|
+
if (sa.reason) env.KRIYA_STANDALONE_REASON = sa.reason
|
|
194
|
+
}
|
|
195
|
+
// Standalone, the session starts on the person's own model, else the local one
|
|
196
|
+
if (hidden) env.KRIYA_START_TIER = ownIds[0] ?? LOCAL_WORKER
|
|
197
|
+
if (standalone && localOn) {
|
|
198
|
+
env.KRIYA_LOCAL_MODEL_ID = local.model
|
|
199
|
+
env.KRIYA_LOCAL_MODEL_LABEL = named[LOCAL_WORKER]
|
|
200
|
+
}
|
|
158
201
|
if (ownModels.length) {
|
|
159
202
|
// The picker's extra models and their windows (no key, no address), and the key hashes DSH redacts by
|
|
160
203
|
env.KRIYA_OWN_MODELS = JSON.stringify(ownModels.map((m) => ({ id: m.id, name: m.name, contextWindow: m.contextWindow })))
|
|
@@ -294,17 +337,67 @@ function relines(stream, write) {
|
|
|
294
337
|
stream.on("end", () => partial && write(rebrand(partial)))
|
|
295
338
|
}
|
|
296
339
|
|
|
340
|
+
export const STANDALONE_TOKEN = "kriya-standalone"
|
|
341
|
+
const STANDALONE_WHY = {
|
|
342
|
+
signed_out: "Not signed in to Kriya.",
|
|
343
|
+
server_unreachable: "Kriya isn't reachable right now (offline, suspended or restarting).",
|
|
344
|
+
requested: "--standalone:",
|
|
345
|
+
}
|
|
346
|
+
const REFUSAL_HINT = {
|
|
347
|
+
401: "Run kriya login to sign this device in again.",
|
|
348
|
+
403: "Ask your Kriya owner to turn Kriya Harness on, or resume the account.",
|
|
349
|
+
426: "Update Kriya Harness: npm install -g @kriya-ai/harness.",
|
|
350
|
+
}
|
|
351
|
+
const OFFLINE_CORE = "select one of your own models or the local model in the model picker (set them up in the Developer tab), or run kriya login."
|
|
352
|
+
/** What a Kriya tier answers in Standalone Mode, per reason */
|
|
353
|
+
export const OFFLINE = {
|
|
354
|
+
signed_out: `Kriya Harness is signed out, so Kriya's models aren't available: ${OFFLINE_CORE}`,
|
|
355
|
+
server_unreachable: `The Kriya server is offline, so Kriya's models aren't available: ${OFFLINE_CORE.replace("or run kriya login.", "or restart kriya once Kriya is back.")}`,
|
|
356
|
+
requested: `Kriya Harness runs with --standalone, so Kriya's models aren't available: ${OFFLINE_CORE.replace("or run kriya login.", "or restart kriya without --standalone.")}`,
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* The model the person pinned as DSH's default for this profile (Settings or the
|
|
361
|
+
* picker writes `agent-default-model` into their own patch files), when it's Kriya's
|
|
362
|
+
* provider; null otherwise. Their files are only read, never changed.
|
|
363
|
+
* shortcut: a line match on the block DSH itself writes, not a YAML parser; a hand-written
|
|
364
|
+
* flow-style row is missed (then DSH's own error says which model it lacks)
|
|
365
|
+
*/
|
|
366
|
+
export function pinnedModel(profile, home = kriyaHome()) {
|
|
367
|
+
let found = null
|
|
368
|
+
for (const file of [join(home, "profiles", profile, "cordis.patch.yml"), join(home, "cordis.patch.yml")]) {
|
|
369
|
+
let text
|
|
370
|
+
try {
|
|
371
|
+
text = readFileSync(file, "utf8")
|
|
372
|
+
} catch {
|
|
373
|
+
continue
|
|
374
|
+
}
|
|
375
|
+
const block = /^- id: agent-default-model\n((?:[ \t]+.*\n?)*)/m.exec(text)?.[1]
|
|
376
|
+
if (!block) continue
|
|
377
|
+
const provider = /^\s+provider:\s*['"]?([\w.-]+)/m.exec(block)?.[1]
|
|
378
|
+
const model = /^\s+model:\s*['"]?([\w.:\/@+-]+)/m.exec(block)?.[1]
|
|
379
|
+
// Later layers win (the home patch over the profile's)
|
|
380
|
+
if (model) found = provider === undefined || provider === "kriya" ? model : null
|
|
381
|
+
}
|
|
382
|
+
return found
|
|
383
|
+
}
|
|
384
|
+
|
|
297
385
|
/** Runs DSH in the foreground, passing the terminal through; resolves with its exit code. */
|
|
298
|
-
export async function runDsh(profile, rest, device, mode = DEFAULT_MODE) {
|
|
386
|
+
export async function runDsh(profile, rest, device, mode = DEFAULT_MODE, { standalone: asked = false } = {}) {
|
|
299
387
|
ensureProfile(profile)
|
|
300
388
|
const headless = profile === "kriya-run"
|
|
301
|
-
const tiers = await planTiers(device)
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
389
|
+
const tiers = await planTiers(device, models, { standalone: asked })
|
|
390
|
+
const { standalone } = tiers
|
|
391
|
+
const say = (text) => process.stderr.write(`kriya: ${text}\n`)
|
|
392
|
+
if (tiers.refused) say(`Kriya refused this device (${tiers.refused.status}): ${tiers.refused.message} ${REFUSAL_HINT[tiers.refused.status]}`)
|
|
393
|
+
if (standalone) say(`${STANDALONE_WHY[tiers.reason]} Standalone Mode: Harness 2.0 runs on this computer with your own API keys or a local model (Developer tab). Kriya's own models come back with kriya login${tiers.reason === "requested" ? " and without --standalone" : ""}.`)
|
|
394
|
+
// Harness 2.0: the owner's switches (standalone: this computer's), where the person set none of their own (src/modes.js applyWorkforce)
|
|
395
|
+
const turned = applyWorkforce(process.env, tiers.workforce, standalone ? STANDALONE_SWITCHES : undefined)
|
|
396
|
+
// The Developer tab from the owner's settings (standalone: always), unless the person said --no-cockpit
|
|
305
397
|
if (tiers.cockpit && !(process.env[SET_BY_PERSON] ?? "").split(",").includes("cockpit")) process.env.KRIYA_COCKPIT = "on"
|
|
306
|
-
if (turned.length)
|
|
307
|
-
|
|
398
|
+
if (turned.length) say(`Harness 2.0 is on${standalone ? "" : " from your Kriya owner settings"}: ${turned.join(", ")}. Turn one off with --no-<name>, e.g. --no-${turned[0]}.`)
|
|
399
|
+
// Standalone, the relay is the only way to a model, so KRIYA_RELAY=off doesn't apply
|
|
400
|
+
const relayOn = standalone || (Boolean(device) && process.env.KRIYA_RELAY !== "off")
|
|
308
401
|
// Own models (src/own-models.js): the person's keys and orchestration, with the owner's
|
|
309
402
|
// harness.ownModels and the relay that routes them; keys stay in this process
|
|
310
403
|
const own = tiers.ownModels && relayOn ? launchOwn(ownFile(), { allowed: tiers.allowed, local: true }) : null
|
|
@@ -317,12 +410,13 @@ export async function runDsh(profile, rest, device, mode = DEFAULT_MODE) {
|
|
|
317
410
|
const orchestrating = process.env.KRIYA_ORCHESTRA === "on" && process.env.KRIYA_LOOP === "on"
|
|
318
411
|
let orchestra = orchestrating ? (own?.orchestra ?? tiers.orchestra) : undefined
|
|
319
412
|
// S-1: `--local-model`, with the owner's offer, the orchestra and the relay (which sends the local model's requests)
|
|
320
|
-
const { local, note } = await localWorker(process.env, { offered: Boolean(tiers.localModels) && relayOn, orchestra })
|
|
321
|
-
if (note)
|
|
413
|
+
const { local, note } = await localWorker(process.env, { offered: Boolean(tiers.localModels) && relayOn, orchestra, alone: standalone })
|
|
414
|
+
if (note) say(note)
|
|
322
415
|
if (orchestra && orchestra === own?.orchestra && orchestra.worker === LOCAL_WORKER && !local) {
|
|
323
|
-
|
|
416
|
+
say(standalone ? "your orchestration builds on the local model, which isn't available now; using your models one at a time." : "your orchestration builds on the local model, which isn't available now; using Kriya's orchestration instead.")
|
|
324
417
|
orchestra = tiers.orchestra
|
|
325
418
|
}
|
|
419
|
+
if (standalone && !own?.models.length && !local) say("no model is set up yet: open the Developer tab and add an API key (OpenRouter, OpenAI, …) or start Ollama / LM Studio and run kriya --local-model, or run kriya login.")
|
|
326
420
|
if (orchestra && orchestra === own?.orchestra) {
|
|
327
421
|
const name = (id) => own.models.find((m) => m.id === id)?.name ?? (id === LOCAL_WORKER ? `Local · ${local?.model}` : tiers.names?.[id] ?? `Kriya ${id}`)
|
|
328
422
|
process.stderr.write(`kriya: your orchestration: ${name(orchestra.head)} leads, ${name(orchestra.worker)} builds.\n`)
|
|
@@ -331,28 +425,37 @@ export async function runDsh(profile, rest, device, mode = DEFAULT_MODE) {
|
|
|
331
425
|
process.env.KRIYA_OWN_MODELS_OFFER = tiers.ownModels && relayOn ? "on" : "off"
|
|
332
426
|
process.env.KRIYA_LOCAL_MODELS_OFFER = tiers.localModels && relayOn ? "on" : "off"
|
|
333
427
|
// Counts of own-key and local calls for Kriya (src/own-usage.js); never content or keys
|
|
334
|
-
|
|
428
|
+
// Standalone: a Kriya tier pinned as the default model goes to the session's own start (else DSH can't start)
|
|
429
|
+
const keepTo = standalone ? (orchestra?.head ?? own?.models[0]?.id ?? (local ? LOCAL_WORKER : null)) : null
|
|
430
|
+
const pinned = keepTo ? pinnedModel(profile) : null
|
|
431
|
+
const keep = START_TIERS.includes(pinned) ? pinned : null
|
|
432
|
+
const keepName = keep ? (own?.models.find((m) => m.id === keepTo)?.name ?? (keepTo === LOCAL_WORKER ? `Local · ${local.model}` : keepTo)) : null
|
|
433
|
+
if (keep) say(`your saved default model is Kriya ${keep}; in Standalone Mode it runs on ${keepName}.`)
|
|
434
|
+
// Standalone, nothing is sent: there is no Kriya to count for
|
|
435
|
+
const reporter = own && device && !standalone ? usageReporter({ device, log: say }) : null
|
|
335
436
|
// DSH and the Kriya plugins reach Kriya through the local relay
|
|
336
437
|
// (src/gateway-proxy.js): encoded bodies past the host's firewall, and a
|
|
337
438
|
// block said as such. KRIYA_RELAY=off talks to Kriya directly, as before
|
|
338
439
|
const relay =
|
|
339
440
|
relayOn
|
|
340
441
|
? await startGatewayProxy({
|
|
341
|
-
|
|
442
|
+
// Standalone: no Kriya behind it; only the person's own and local models answer
|
|
443
|
+
target: standalone ? null : device.url,
|
|
444
|
+
...(standalone && { offline: OFFLINE[tiers.reason] }),
|
|
342
445
|
encode: tiers.encodings.includes(BODY_ENCODING),
|
|
343
446
|
// Harness 2.0: the picker's Orchestration choice reaches Kriya as the head tier
|
|
344
|
-
...(orchestra && { aliases: { [ORCHESTRA_ALIAS]: orchestra.head } }),
|
|
447
|
+
...((orchestra || keep) && { aliases: { ...(orchestra && { [ORCHESTRA_ALIAS]: orchestra.head }), ...(keep && { [keep]: keepTo }) } }),
|
|
345
448
|
...(local && { local }),
|
|
346
449
|
...(own && { routes: own.routes }),
|
|
347
450
|
...(reporter && { onUsage: reporter.add }),
|
|
348
451
|
// A Kriya deployed after launch is picked up without a restart
|
|
349
|
-
checkSupport: async () => ((await models(device.url, device.token)).bodyEncodings ?? []).includes(BODY_ENCODING),
|
|
452
|
+
...(!standalone && { checkSupport: async () => ((await models(device.url, device.token)).bodyEncodings ?? []).includes(BODY_ENCODING) }),
|
|
350
453
|
log: (text) => process.stderr.write(`kriya: ${text}\n`),
|
|
351
454
|
})
|
|
352
455
|
: null
|
|
353
456
|
// What this process runs, for Kriya's Control Center (no task text; nothing on a Kriya without it)
|
|
354
457
|
const on = (name) => process.env[name] === "on"
|
|
355
|
-
const broadcast = broadcastRun(device, {
|
|
458
|
+
const broadcast = broadcastRun(standalone ? null : device, {
|
|
356
459
|
kind: profile === "kriya-run" ? "run" : profile === "kriya-acp" ? "acp" : "app",
|
|
357
460
|
mode,
|
|
358
461
|
switches: { loop: on("KRIYA_LOOP"), loopV2: on("KRIYA_LOOP_V2"), budget: on("KRIYA_BUDGET"), anchor: on("KRIYA_ANCHOR"), browser: on("KRIYA_BROWSER") },
|
|
@@ -362,7 +465,8 @@ export async function runDsh(profile, rest, device, mode = DEFAULT_MODE) {
|
|
|
362
465
|
// stdout: the answer (kriya run) and ACP's protocol frames pass untouched;
|
|
363
466
|
// the Web UI's stdout carries only log lines, rebranded like stderr
|
|
364
467
|
stdio: ["inherit", profile === "kriya" ? "pipe" : "inherit", "pipe"],
|
|
365
|
-
|
|
468
|
+
// Standalone: a stand-in token (DSH's route needs one; the relay never sends it anywhere)
|
|
469
|
+
env: launchEnv(relay ? { ...(standalone ? { token: STANDALONE_TOKEN } : device), url: relay.url } : device, process.env, mode, orchestra ? orchestra.head : tiers.start, tiers.allowed, tiers.names, tiers.limits, tiers.images, orchestra, Boolean(relay), local ?? null, own, standalone && { reason: tiers.reason, keep, keepName }),
|
|
366
470
|
})
|
|
367
471
|
let explained = null
|
|
368
472
|
const filter = htmlFilter((text) => process.stderr.write(rebrand(text)))
|
package/src/local-model.js
CHANGED
|
@@ -96,13 +96,15 @@ export function localModelArgs(args, env = process.env) {
|
|
|
96
96
|
* orchestra is on (the local model only builds), and a server answered.
|
|
97
97
|
* @returns {Promise<{ local?: { url: string, model: string, server: string }, note?: string }>}
|
|
98
98
|
*/
|
|
99
|
-
export async function localWorker(env, { offered, orchestra }, find = findLocalModel) {
|
|
99
|
+
export async function localWorker(env, { offered, orchestra, alone = false }, find = findLocalModel) {
|
|
100
100
|
const asked = env.KRIYA_LOCAL_MODEL
|
|
101
101
|
if (!asked || asked === "off") return {}
|
|
102
102
|
if (!offered) return { note: "local models aren't turned on for your Kriya account yet (the owner's harness.localModels); using Kriya's models." }
|
|
103
|
-
|
|
103
|
+
// Standalone, the local model may run the whole session by itself
|
|
104
|
+
if (!orchestra && !alone) return { note: "a local model builds the orchestra's worker steps, and the orchestra is off; using Kriya's models." }
|
|
104
105
|
const found = await find({ url: asked === "on" ? undefined : asked, name: env.KRIYA_LOCAL_MODEL_NAME || undefined })
|
|
105
|
-
if ("error" in found) return { note: `${found.error} Using Kriya's models
|
|
106
|
+
if ("error" in found) return { note: `${found.error} ${alone ? "Using your own models only." : "Using Kriya's models."}` }
|
|
107
|
+
if (!orchestra) return { local: found, note: `${found.model} (${found.server}, ${found.url}) runs on this computer; choose it in the model picker.` }
|
|
106
108
|
return {
|
|
107
109
|
local: found,
|
|
108
110
|
note: `${found.model} (${found.server}, ${found.url}) builds on this computer; Kriya's ${orchestra.head} plans, reviews and takes over when it's stuck.${found.server === "Ollama" ? " Give Ollama a 32k context: OLLAMA_CONTEXT_LENGTH=32768 ollama serve." : ""}`,
|
package/src/modes.js
CHANGED
|
@@ -212,17 +212,25 @@ export function switchEnv(args, env = process.env, saved = savedSwitches()) {
|
|
|
212
212
|
*/
|
|
213
213
|
export const WORKFORCE_SWITCHES = Object.freeze(["cartridges", "orchestra", "gates", "critic", "milestones", "grounding", "explore", "runstrip", "mcp"])
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Standalone Mode (no Kriya account, or Kriya unreachable): the Harness 2.0
|
|
217
|
+
* switches that run on this computer alone. MCP reads the owner's registry
|
|
218
|
+
* from Kriya, so it stays off.
|
|
219
|
+
*/
|
|
220
|
+
export const STANDALONE_SWITCHES = Object.freeze(WORKFORCE_SWITCHES.filter((flag) => flag !== "mcp"))
|
|
221
|
+
|
|
215
222
|
/**
|
|
216
223
|
* Turns on the owner's Harness 2.0 switches the person didn't set, when Kriya
|
|
217
|
-
* advertises them
|
|
224
|
+
* advertises them (or Standalone Mode, with its own list). Without the
|
|
225
|
+
* advertisement nothing changes (HT-REG).
|
|
218
226
|
* @returns {string[]} the switches this turned on
|
|
219
227
|
*/
|
|
220
|
-
export function applyWorkforce(env = process.env, advertised = false) {
|
|
228
|
+
export function applyWorkforce(env = process.env, advertised = false, list = WORKFORCE_SWITCHES) {
|
|
221
229
|
if (!advertised) return []
|
|
222
230
|
const chosen = new Set((env[SET_BY_PERSON] ?? "").split(",").filter(Boolean))
|
|
223
231
|
const turned = []
|
|
224
232
|
for (const [flag, name] of SWITCHES) {
|
|
225
|
-
if (!
|
|
233
|
+
if (!list.includes(flag) || chosen.has(flag) || env[name] === "on") continue
|
|
226
234
|
env[name] = "on"
|
|
227
235
|
turned.push(flag)
|
|
228
236
|
}
|
package/src/own-usage.js
CHANGED
|
@@ -17,6 +17,8 @@ export function usageReporter({ device, post = (body) => call(device.url, "POST"
|
|
|
17
17
|
const pending = new Map()
|
|
18
18
|
let stopped = false
|
|
19
19
|
let flushing = null
|
|
20
|
+
// One line per outage, not one every FLUSH_MS
|
|
21
|
+
let warned = false
|
|
20
22
|
const add = (e) => {
|
|
21
23
|
if (stopped || !e?.provider || !e?.model) return
|
|
22
24
|
const key = `${e.provider}\0${e.model}`
|
|
@@ -36,6 +38,7 @@ export function usageReporter({ device, post = (body) => call(device.url, "POST"
|
|
|
36
38
|
for (const e of batch) pending.delete(`${e.provider}\0${e.model}`)
|
|
37
39
|
try {
|
|
38
40
|
await post({ entries: batch.map((e) => ({ ...e, requests: Math.min(e.requests, 10_000) })) })
|
|
41
|
+
warned = false
|
|
39
42
|
} catch (error) {
|
|
40
43
|
if (error instanceof KriyaError && error.status === 404) {
|
|
41
44
|
stopped = true
|
|
@@ -44,7 +47,8 @@ export function usageReporter({ device, post = (body) => call(device.url, "POST"
|
|
|
44
47
|
}
|
|
45
48
|
// Kept for the next try, bounded
|
|
46
49
|
for (const e of batch) if (pending.size < MAX_KEYS) pending.set(`${e.provider}\0${e.model}`, e)
|
|
47
|
-
log(`own-model usage not sent yet (${error?.code ?? error?.message ?? "error"}); will retry`)
|
|
50
|
+
if (!warned) log(`own-model usage not sent yet (${error?.code ?? error?.message ?? "error"}); will retry quietly`)
|
|
51
|
+
warned = true
|
|
48
52
|
return
|
|
49
53
|
}
|
|
50
54
|
}
|
package/src/store.js
CHANGED
|
@@ -31,6 +31,9 @@ export function readDevice() {
|
|
|
31
31
|
return null
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Inside DSH: the sign-in, unless the launcher started in Standalone Mode (Kriya unreachable or --standalone) */
|
|
35
|
+
export const activeDevice = (env = process.env) => (env.KRIYA_STANDALONE === "on" ? null : readDevice())
|
|
36
|
+
|
|
34
37
|
/** @param {{ url: string, token: string, deviceId: string }} device */
|
|
35
38
|
export function writeDevice(device) {
|
|
36
39
|
ensureHome()
|