@kriya-ai/harness 2.2.0 → 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/RELEASE_NOTES.md +9 -0
- package/install.sh +1 -1
- package/package.json +1 -1
- package/src/api.js +3 -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/launch.js +2 -3
- package/studio/dist/studio.js +3 -3
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
3
12
|
## 2.2.0
|
|
4
13
|
|
|
5
14
|
- **Added:** **Standalone Mode** (`--standalone`, or automatically when signed
|
package/install.sh
CHANGED
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -68,6 +68,9 @@ 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.
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// The Editing Studio without Kriya (Standalone Mode): when this computer is signed out or
|
|
2
|
+
// Kriya can't be reached (a network error, a timeout, a 5xx such as a suspended host), the
|
|
3
|
+
// Director's slots go to the person's own models (~/.kriya/own-models.json, the keys they
|
|
4
|
+
// saved in Settings → Models or the Developer tab) or a local OpenAI-compatible server
|
|
5
|
+
// (Ollama, LM Studio, vLLM). A Kriya that answers and refuses (401, 403, 426) is never
|
|
6
|
+
// worked around: those callers fail closed as before. Keys stay in the Edit Host's memory
|
|
7
|
+
// and go only to their own provider, never to Kriya, a log or the Studio.
|
|
8
|
+
|
|
9
|
+
import { KriyaError } from "../../api.js"
|
|
10
|
+
import { findLocalModel } from "../../local-model.js"
|
|
11
|
+
import { ownFile, PROVIDERS, providerUrl, readOwn } from "../../own-models.js"
|
|
12
|
+
|
|
13
|
+
/** The tier aliases the Director sends (src/launch.js START_TIERS) */
|
|
14
|
+
export const EDIT_TIERS = ["balanced", "budget", "escalation"]
|
|
15
|
+
// How long a found (or absent) local server, and a Kriya that didn't answer, are believed
|
|
16
|
+
const LOCAL_MS = 60_000
|
|
17
|
+
export const DOWN_MS = 60_000
|
|
18
|
+
const MAX_ERROR = 300
|
|
19
|
+
|
|
20
|
+
export const NO_MODEL =
|
|
21
|
+
"The Editing Studio has no model to ask: Kriya isn't connected, and no API key or local model is set up. Add a key (OpenRouter, OpenAI, …) in Kriya Harness → Settings → Models, start Ollama or LM Studio, or run kriya login."
|
|
22
|
+
|
|
23
|
+
/** What only Kriya provides, named where the Studio says why it's off */
|
|
24
|
+
export const CLOUD_ONLY = "Stock pictures, definitions, the Media Runtime download and phone orders need Kriya."
|
|
25
|
+
|
|
26
|
+
const providerName = (id) => (id === "custom" ? "Custom" : PROVIDERS.find((p) => p.id === id)?.name ?? id)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The person's own and local models for the Director, and whether Kriya answered lately.
|
|
30
|
+
* @param {{ file?: string, find?: typeof findLocalModel, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, now?: () => number }} [options]
|
|
31
|
+
*/
|
|
32
|
+
// The request in decreasing faith in the provider: as sent, without `reasoning`, json_object, no format
|
|
33
|
+
const SHAPES = 4
|
|
34
|
+
function shaped(body, v) {
|
|
35
|
+
const out = { ...body }
|
|
36
|
+
if (v >= 1) delete out.reasoning
|
|
37
|
+
if (v === 2 && out.response_format?.type === "json_schema") out.response_format = { type: "json_object" }
|
|
38
|
+
if (v >= 3) delete out.response_format
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
41
|
+
/** Whether the next shape differs from this one for this body (else another try changes nothing) */
|
|
42
|
+
const shapeMatters = (body, v) => (v === 0 ? "reasoning" in body || Boolean(body.response_format) : Boolean(body.response_format))
|
|
43
|
+
|
|
44
|
+
export function localModels({ file, find = findLocalModel, env = process.env, fetchImpl = fetch, now = Date.now } = {}) {
|
|
45
|
+
let probe = null
|
|
46
|
+
let downAt = -Infinity
|
|
47
|
+
const shapes = new Map()
|
|
48
|
+
const local = async () => {
|
|
49
|
+
if (!probe || now() - probe.at > LOCAL_MS) {
|
|
50
|
+
const asked = env.KRIYA_LOCAL_MODEL
|
|
51
|
+
let found = null
|
|
52
|
+
if (asked !== "off") {
|
|
53
|
+
const url = asked && /^https?:\/\//.test(asked) ? asked : undefined
|
|
54
|
+
const answer = await find({ url, name: env.KRIYA_LOCAL_MODEL_NAME || undefined }).catch(() => ({ error: "unreachable" }))
|
|
55
|
+
found = "error" in answer ? null : answer
|
|
56
|
+
}
|
|
57
|
+
probe = { at: now(), value: found }
|
|
58
|
+
}
|
|
59
|
+
return probe.value
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Which model answers each tier: the person's orchestration (head for balanced and
|
|
64
|
+
* escalation, worker for budget), else their first own model, with a local server as
|
|
65
|
+
* the budget worker; a local server alone answers everything. {} when there is none.
|
|
66
|
+
*/
|
|
67
|
+
const routes = async () => {
|
|
68
|
+
const s = readOwn(file ?? ownFile())
|
|
69
|
+
const own = (id) => {
|
|
70
|
+
const m = s.models.find((x) => x.id === id)
|
|
71
|
+
const url = m && providerUrl(m.provider, s.keys[m.provider])
|
|
72
|
+
return m && url ? { url, model: m.model, key: s.keys[m.provider].key, provider: m.provider, name: `${providerName(m.provider)} · ${m.model}`.slice(0, 80) } : null
|
|
73
|
+
}
|
|
74
|
+
const found = await local()
|
|
75
|
+
const loc = found ? { url: found.url, model: found.model, provider: "local", name: `Local · ${found.model}`.slice(0, 80) } : null
|
|
76
|
+
const pick = (id) => (id === "local" ? loc : own(id))
|
|
77
|
+
const head = (s.orchestra && pick(s.orchestra.head)) || own(s.models[0]?.id) || loc
|
|
78
|
+
if (!head) return {}
|
|
79
|
+
const worker = (s.orchestra && pick(s.orchestra.worker)) || loc || head
|
|
80
|
+
return { balanced: head, escalation: head, budget: worker }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
routes,
|
|
85
|
+
/** Kriya didn't answer: for DOWN_MS, calls go straight to the person's models instead of waiting on it again */
|
|
86
|
+
markDown: () => (downAt = now()),
|
|
87
|
+
isDown: () => now() - downAt < DOWN_MS,
|
|
88
|
+
/**
|
|
89
|
+
* One Director call (an OpenAI-compatible chat completion, as Kriya's gateway takes it) on the
|
|
90
|
+
* model behind its tier; the answer in the same shape Kriya's gateway gives.
|
|
91
|
+
*/
|
|
92
|
+
async send(body, signal) {
|
|
93
|
+
const table = await routes()
|
|
94
|
+
const route = table[body?.model] ?? table.balanced
|
|
95
|
+
if (!route) throw new KriyaError(503, "no_model", NO_MODEL)
|
|
96
|
+
// Kriya's gateway takes `reasoning` and json_schema formats; a provider may refuse either (400/422, nothing
|
|
97
|
+
// generated, nothing charged), so each is let go in turn, and what this model took is remembered
|
|
98
|
+
const key = `${route.url} ${route.model}`
|
|
99
|
+
let answer
|
|
100
|
+
for (let v = shapes.get(key) ?? 0; ; v++) {
|
|
101
|
+
try {
|
|
102
|
+
answer = await fetchImpl(`${route.url}/chat/completions`, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: { "content-type": "application/json", accept: "application/json", ...(route.key && { authorization: `Bearer ${route.key}` }) },
|
|
105
|
+
body: JSON.stringify(shaped({ ...body, model: route.model, stream: false }, v)),
|
|
106
|
+
...(signal && { signal }),
|
|
107
|
+
redirect: "error",
|
|
108
|
+
})
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (signal?.aborted) throw error
|
|
111
|
+
throw new KriyaError(0, "network", `${route.name} isn't answering (${error?.cause?.code ?? error?.name ?? "network error"}).`)
|
|
112
|
+
}
|
|
113
|
+
if ((answer.status !== 400 && answer.status !== 422) || v >= SHAPES - 1 || !shapeMatters(body, v)) {
|
|
114
|
+
if (answer.ok) shapes.set(key, v)
|
|
115
|
+
break
|
|
116
|
+
}
|
|
117
|
+
await answer.body?.cancel().catch(() => {})
|
|
118
|
+
}
|
|
119
|
+
const text = await answer.text()
|
|
120
|
+
let data = null
|
|
121
|
+
try {
|
|
122
|
+
data = text ? JSON.parse(text) : null
|
|
123
|
+
} catch {
|
|
124
|
+
// A proxy page: said below without its body
|
|
125
|
+
}
|
|
126
|
+
if (!answer.ok) {
|
|
127
|
+
const said = typeof data?.error?.message === "string" ? data.error.message : typeof data?.error === "string" ? data.error : ""
|
|
128
|
+
// A provider may quote what it was sent: never the key
|
|
129
|
+
const clean = (route.key ? said.split(route.key).join("…") : said).slice(0, MAX_ERROR)
|
|
130
|
+
throw new KriyaError(answer.status, answer.status === 401 || answer.status === 403 ? "provider_refused" : "provider_error", `${route.name} answered ${answer.status}${clean ? `: ${clean}` : ""}.`)
|
|
131
|
+
}
|
|
132
|
+
if (!data || !Array.isArray(data.choices)) throw new KriyaError(502, "provider_error", `${route.name} didn't answer with a chat completion.`)
|
|
133
|
+
return data
|
|
134
|
+
},
|
|
135
|
+
/** What the Studio says about where the Director runs (no key, no address) */
|
|
136
|
+
async status(signedIn) {
|
|
137
|
+
if (signedIn && now() - downAt >= DOWN_MS) return { mode: "kriya" }
|
|
138
|
+
const reason = signedIn ? "server_unreachable" : "signed_out"
|
|
139
|
+
const head = (await routes()).balanced
|
|
140
|
+
if (!head) return { mode: "none", reason, message: NO_MODEL }
|
|
141
|
+
return { mode: head.provider === "local" ? "local" : "own", reason, label: head.name, cloudOnly: CLOUD_ONLY }
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let shared = null
|
|
147
|
+
/** The Edit Host's one instance (its Governor, tiers and features share what Kriya last said) */
|
|
148
|
+
export const sharedLocal = () => (shared ??= localModels())
|
|
@@ -30,9 +30,10 @@ import { planAssembly } from "../recipes/assembly.js"
|
|
|
30
30
|
import { planMontage } from "../recipes/montage.js"
|
|
31
31
|
import { analyseMulticam, PODCAST_MULTICAM } from "../recipes/multicam.js"
|
|
32
32
|
import { planProgramme, programmeRecipe } from "../recipes/programme.js"
|
|
33
|
-
import { defineTerms, fetchFeatures, searchMedia } from "../runtime/fetch.js"
|
|
33
|
+
import { defineTerms, fetchFeatures, LOCAL_FEATURES, searchMedia } from "../runtime/fetch.js"
|
|
34
34
|
import { readDevice } from "../../store.js"
|
|
35
|
-
import { models } from "../../api.js"
|
|
35
|
+
import { models, unreachable } from "../../api.js"
|
|
36
|
+
import { sharedLocal } from "../director/local.js"
|
|
36
37
|
import { measureDraft, timelineOf, viewerReport } from "../director/viewer.js"
|
|
37
38
|
import { sayWatch } from "../director/watch-fix.js"
|
|
38
39
|
import { planOpenings } from "../recipes/openings.js"
|
|
@@ -116,17 +117,30 @@ const JOB_CALLS = 40
|
|
|
116
117
|
|
|
117
118
|
// What the server has switched on, asked for at most once a minute, so turning a switch off takes effect soon
|
|
118
119
|
const FEATURES_MS = 60_000
|
|
119
|
-
|
|
120
|
+
// Signed out or Kriya unreachable: Standalone Mode's local features (runtime/fetch.js LOCAL_FEATURES)
|
|
121
|
+
export const askServer = async () => {
|
|
120
122
|
const device = readDevice()
|
|
121
|
-
|
|
123
|
+
const local = sharedLocal()
|
|
124
|
+
if (!device || local.isDown()) return { ...LOCAL_FEATURES }
|
|
125
|
+
return fetchFeatures(device, { onDown: local.markDown })
|
|
122
126
|
}
|
|
123
127
|
// The tiers this person's plan lists, exactly as Kriya says (GET /models): never a guess, so a slot is
|
|
124
128
|
// only ever sent on one of them (EH-65). Signed out or unanswered: none, and nothing escalates
|
|
125
|
-
|
|
129
|
+
// Standalone Mode: the tiers the person's own or local models answer (director/local.js); a refusal stays a throw
|
|
130
|
+
export const askTiers = async () => {
|
|
126
131
|
const device = readDevice()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
const local = sharedLocal()
|
|
133
|
+
if (device && !local.isDown()) {
|
|
134
|
+
try {
|
|
135
|
+
const answer = await models(device.url, device.token)
|
|
136
|
+
return Array.isArray(answer?.data) ? answer.data.map((m) => m?.id).filter((id) => typeof id === "string") : null
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (!unreachable(error)) throw error
|
|
139
|
+
local.markDown()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const tiers = Object.keys(await local.routes())
|
|
143
|
+
return tiers.length ? tiers : null
|
|
130
144
|
}
|
|
131
145
|
const NOTHING_FOUND = { items: {}, definitions: {} }
|
|
132
146
|
|
package/src/edit/host/server.js
CHANGED
|
@@ -21,6 +21,8 @@ import { TRANSITIONS } from "../core/transitions.js"
|
|
|
21
21
|
import { regionOf } from "../core/effects.js"
|
|
22
22
|
import { EngineFailure } from "../engine/tool.js"
|
|
23
23
|
import { activeRuntime } from "../runtime/setup.js"
|
|
24
|
+
import { readDevice } from "../../store.js"
|
|
25
|
+
import { sharedLocal } from "../director/local.js"
|
|
24
26
|
import { recogniser } from "../index/layers/words.js"
|
|
25
27
|
import { assemblyProblems, isAssembly } from "../director/assembly.js"
|
|
26
28
|
import { FORMATS, GRADES } from "../recipes/reel.js"
|
|
@@ -179,7 +181,10 @@ const statusOf = (error) => ({ outside_project: 403, missing_file: 404, exists:
|
|
|
179
181
|
*/
|
|
180
182
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
181
183
|
|
|
182
|
-
|
|
184
|
+
// The Media Runtime comes from Kriya; without it, what still works and the two ways to get speech-to-text
|
|
185
|
+
export const OFFLINE_SETUP = "Kriya isn't connected, so it can't send the Media Runtime. Cutting, captions and export already work with this computer's FFmpeg. For speech-to-text, run kriya edit setup --manifest <file> with a signed manifest, or kriya login."
|
|
186
|
+
|
|
187
|
+
export function createHandler({ home, ipcToken = null, roots, projects, jobs, tavi, tools, tokenTtlMs, port, onActivity, onStop, onLive = () => {}, sse, log, pid, stamp = null, busy = () => 0, director = () => sharedLocal().status(readDevice()) }) {
|
|
183
188
|
const tokens = new Map() // sha256 of a launch token → { expires, back }
|
|
184
189
|
const sessions = new Set()
|
|
185
190
|
const mediaSecret = randomBytes(32)
|
|
@@ -226,15 +231,22 @@ export function createHandler({ home, ipcToken = null, roots, projects, jobs, ta
|
|
|
226
231
|
}
|
|
227
232
|
let told = 0
|
|
228
233
|
const run = async () => {
|
|
229
|
-
const [{
|
|
234
|
+
const [{ unreachable }, { fetchManifest }, { install }] = await Promise.all([import("../../api.js"), import("../runtime/fetch.js"), import("../runtime/setup.js")])
|
|
230
235
|
const device = readDevice()
|
|
231
|
-
if (!device) throw new Error(
|
|
236
|
+
if (!device) throw new Error(OFFLINE_SETUP)
|
|
232
237
|
const say = (line) => ((setup.line = line), tell())
|
|
233
238
|
const progress = (at) => {
|
|
234
239
|
Object.assign(setup, at)
|
|
235
240
|
if (Date.now() - told > 250 || at.done === at.total) ((told = Date.now()), tell())
|
|
236
241
|
}
|
|
237
|
-
|
|
242
|
+
let manifest
|
|
243
|
+
try {
|
|
244
|
+
manifest = await fetchManifest(device)
|
|
245
|
+
} catch (error) {
|
|
246
|
+
if (unreachable(error)) throw new Error(OFFLINE_SETUP)
|
|
247
|
+
throw error
|
|
248
|
+
}
|
|
249
|
+
await install(manifest, { home, say, progress })
|
|
238
250
|
}
|
|
239
251
|
onActivity(1)
|
|
240
252
|
run().then(
|
|
@@ -350,7 +362,8 @@ export function createHandler({ home, ipcToken = null, roots, projects, jobs, ta
|
|
|
350
362
|
|
|
351
363
|
// The person's own screen. Never on the socket, so nothing but a Studio session can
|
|
352
364
|
// say yes to a rule (ET-TST-01): no tool, no daemon, no job
|
|
353
|
-
|
|
365
|
+
// Where the Director runs now (Kriya, the person's own model, a local one, or none), for the Studio's banner
|
|
366
|
+
if (parts[0] === "runtime" && parts.length === 1 && method === "GET") return say(200, { ...runtimeView(), director: await director().catch(() => null) })
|
|
354
367
|
if (parts[0] === "runtime" && parts[1] === "setup" && parts.length === 2 && method === "POST") return say(202, startSetup())
|
|
355
368
|
if (parts[0] === "taste" && parts.length === 1 && method === "GET") return say(200, projects.taste.list())
|
|
356
369
|
if (parts[0] === "taste" && parts.length === 3 && method === "POST") {
|
package/src/edit/runtime/cli.js
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import { spawn } from "node:child_process"
|
|
4
4
|
|
|
5
|
-
import { KriyaError } from "../../api.js"
|
|
5
|
+
import { KriyaError, unreachable } from "../../api.js"
|
|
6
6
|
import { kriyaHome } from "../../paths.js"
|
|
7
7
|
import { readDevice } from "../../store.js"
|
|
8
8
|
import { checkRuntime } from "./doctor.js"
|
|
9
9
|
import { fetchManifest } from "./fetch.js"
|
|
10
|
-
import { RuntimeError } from "./manifest.js"
|
|
10
|
+
import { openManifest, RuntimeError } from "./manifest.js"
|
|
11
11
|
import { install, installPack, removePack, rollback } from "./setup.js"
|
|
12
12
|
|
|
13
13
|
const USAGE = `Usage:
|
|
14
14
|
kriya edit [--no-open] open the Editing Studio in your browser (--no-open: only print its link)
|
|
15
15
|
kriya edit setup [--rollback] install the Media Runtime, or go back to the last one
|
|
16
|
+
kriya edit setup --manifest <file-or-https-url>
|
|
17
|
+
install it from a signed manifest, without Kriya (the
|
|
18
|
+
signature is checked against the same trusted key)
|
|
16
19
|
kriya edit setup --pack <name> add a capability pack (color, voice-clean, depth)
|
|
17
20
|
kriya edit setup --remove-pack <name>
|
|
18
21
|
remove one; the rest of the runtime stays
|
|
@@ -91,21 +94,19 @@ export async function editCommand([action, ...rest], { say = (line) => process.s
|
|
|
91
94
|
const pack = PACKS[`pack-${rest[1]}`]
|
|
92
95
|
if (!pack) return say(`There is no ${rest[1]} pack. Packs: ${Object.keys(PACKS).map((id) => id.slice(5)).join(", ")}.`), 1
|
|
93
96
|
if (!pack.artifacts.length) return say(`The ${pack.title} pack comes with FFmpeg; there is nothing to download. kriya edit doctor says whether this FFmpeg has what it needs.`), 0
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const manifest = await kriyaManifest(say)
|
|
98
|
+
if (!manifest) return 1
|
|
99
|
+
await installPack(manifest, `pack-${rest[1]}`, { say })
|
|
100
|
+
return 0
|
|
101
|
+
}
|
|
102
|
+
if (action === "setup" && rest.length === 2 && rest[0] === "--manifest") {
|
|
103
|
+
await install(await manifestFrom(rest[1]), { say })
|
|
100
104
|
return 0
|
|
101
105
|
}
|
|
102
106
|
if (action === "setup" && rest.length === 0) {
|
|
103
|
-
const
|
|
104
|
-
if (!
|
|
105
|
-
|
|
106
|
-
return 1
|
|
107
|
-
}
|
|
108
|
-
await install(await fetchManifest(device), { say })
|
|
107
|
+
const manifest = await kriyaManifest(say)
|
|
108
|
+
if (!manifest) return 1
|
|
109
|
+
await install(manifest, { say })
|
|
109
110
|
return 0
|
|
110
111
|
}
|
|
111
112
|
say(USAGE)
|
|
@@ -117,6 +118,56 @@ export async function editCommand([action, ...rest], { say = (line) => process.s
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
121
|
+
const OFFLINE = (why) =>
|
|
122
|
+
`${why} Cutting, captions and export already work with this computer's FFmpeg (kriya edit doctor says what it has). For speech-to-text, run kriya edit setup --manifest <file> with a signed manifest, or kriya login.`
|
|
123
|
+
|
|
124
|
+
/** The Media Runtime's manifest from Kriya; null, said plainly, when Kriya isn't there to ask */
|
|
125
|
+
async function kriyaManifest(say) {
|
|
126
|
+
const device = readDevice()
|
|
127
|
+
if (!device) return say(OFFLINE("This computer isn't signed in to Kriya, which sends the Media Runtime.")), null
|
|
128
|
+
try {
|
|
129
|
+
return await fetchManifest(device)
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (unreachable(error)) return say(OFFLINE(`Kriya isn't reachable right now (${error.message})`)), null
|
|
132
|
+
throw error
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const MAX_MANIFEST = 1024 * 1024
|
|
137
|
+
|
|
138
|
+
/** A signed manifest from a file or an https address; it installs only if signed by a trusted key */
|
|
139
|
+
export async function manifestFrom(where, { fetchImpl = fetch } = {}) {
|
|
140
|
+
let text
|
|
141
|
+
if (/^https:\/\//.test(where)) {
|
|
142
|
+
let answer
|
|
143
|
+
try {
|
|
144
|
+
answer = await fetchImpl(where, { signal: AbortSignal.timeout(30_000), redirect: "error" })
|
|
145
|
+
} catch {
|
|
146
|
+
throw new RuntimeError(`Couldn't reach ${new URL(where).host}.`)
|
|
147
|
+
}
|
|
148
|
+
if (!answer.ok) throw new RuntimeError(`${new URL(where).host} answered ${answer.status}.`)
|
|
149
|
+
text = await answer.text()
|
|
150
|
+
} else if (/^[a-z]+:\/\//i.test(where)) throw new RuntimeError("A manifest comes from a file or an https address.")
|
|
151
|
+
else {
|
|
152
|
+
const { readFileSync, statSync } = await import("node:fs")
|
|
153
|
+
try {
|
|
154
|
+
if (statSync(where).size > MAX_MANIFEST) throw new RuntimeError("That file is too large to be a manifest.")
|
|
155
|
+
text = readFileSync(where, "utf8")
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error instanceof RuntimeError) throw error
|
|
158
|
+
throw new RuntimeError(`Can't read ${where}.`)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (text.length > MAX_MANIFEST) throw new RuntimeError("That is too large to be a manifest.")
|
|
162
|
+
let value
|
|
163
|
+
try {
|
|
164
|
+
value = JSON.parse(text)
|
|
165
|
+
} catch {
|
|
166
|
+
throw new RuntimeError("That isn't a manifest (not JSON).")
|
|
167
|
+
}
|
|
168
|
+
return openManifest(value ?? {})
|
|
169
|
+
}
|
|
170
|
+
|
|
120
171
|
async function verifyCommand(file, receiptFile, say) {
|
|
121
172
|
const { existsSync } = await import("node:fs")
|
|
122
173
|
const { readReceipt, receiptPath, verifyFile } = await import("../engine/receipt.js")
|
|
@@ -107,7 +107,12 @@ export async function checkRuntime({ home = kriyaHome(), platform = platformId()
|
|
|
107
107
|
const available = free(home)
|
|
108
108
|
check(available >= MIN_FREE, `disk: ${(available / 1e9).toFixed(0)} GB free`, `the runtime and its cache need about ${(MIN_FREE / 1e9).toFixed(0)} GB`)
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
// Without the Media Runtime, the Studio still edits on this computer's FFmpeg (fresh npm installs, or no Kriya)
|
|
111
|
+
const local = Boolean(ffmpeg) && ffprobe === ffmpeg && !older(ffmpeg, minVersion)
|
|
112
|
+
if (!runtime || !spec) {
|
|
113
|
+
check(false, "Media Runtime", "run kriya edit setup (without Kriya: kriya edit setup --manifest <signed manifest file>)")
|
|
114
|
+
if (local) say(`ok editing on this FFmpeg ${ffmpeg}: import, cutting, captions, grading and export work now; speech-to-text (words in the transcript, dictation) needs the Media Runtime`)
|
|
115
|
+
}
|
|
111
116
|
else {
|
|
112
117
|
check(true, `Media Runtime ${runtime.version}`)
|
|
113
118
|
for (const artifact of spec.artifacts) check(executable(join(runtime.dir, artifact.id, artifact.entry)), `${artifact.id} ${artifact.version}`, "run kriya edit setup")
|
|
@@ -118,5 +123,6 @@ export async function checkRuntime({ home = kriyaHome(), platform = platformId()
|
|
|
118
123
|
|
|
119
124
|
const synced = syncedFolder(cwd)
|
|
120
125
|
if (synced) say(`note ${synced}`)
|
|
121
|
-
|
|
126
|
+
// editing: "full" with the runtime, "local" on this FFmpeg alone, "none" without a usable FFmpeg
|
|
127
|
+
return { ok, ffmpeg, encoders, metal, tier, runtime: runtime?.version ?? null, editing: !local ? "none" : runtime && spec ? "full" : "local" }
|
|
122
128
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The one place the runtime talks to Kriya, kept apart from manifest.js so the
|
|
2
2
|
// Engine can use the rest with no path to the API client (ARCHITECTURE §6).
|
|
3
3
|
|
|
4
|
-
import { call, KriyaError } from "../../api.js"
|
|
4
|
+
import { call, KriyaError, unreachable } from "../../api.js"
|
|
5
5
|
import { openManifest, RuntimeError, TRUSTED_KEYS } from "./manifest.js"
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,13 +9,29 @@ import { openManifest, RuntimeError, TRUSTED_KEYS } from "./manifest.js"
|
|
|
9
9
|
* route among them, means off: the server ships first, and a client never assumes (track E rule 17).
|
|
10
10
|
* @returns {Promise<{ visuals: boolean, playbooks: boolean, mediaSearch: boolean, motion: boolean, customMotion: boolean, assembly: boolean }>}
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const OFF = { visuals: false, playbooks: false, mediaSearch: false, motion: false, customMotion: false, assembly: false, livePreview: false, intent: false, craft: false, typeKit: false, referenceIntent: false, directorLoop: false, taviOrder: false }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Standalone Mode (signed out, or Kriya unreachable): everything that runs on this computer
|
|
16
|
+
* with the person's own or local model. Stock pictures and definitions (mediaSearch) and
|
|
17
|
+
* phone orders (taviOrder) are Kriya's own services, so they stay off.
|
|
18
|
+
*/
|
|
19
|
+
export const LOCAL_FEATURES = Object.freeze({ ...OFF, visuals: true, playbooks: true, motion: true, customMotion: true, assembly: true, livePreview: true, intent: true, craft: true, typeKit: true, referenceIntent: true, directorLoop: true })
|
|
20
|
+
|
|
21
|
+
// onDown: Standalone Mode's opt-in (host/projects.js askServer). Without it, any failure means off,
|
|
22
|
+
// as track E rule 17 has it; with it, a Kriya that can't be asked at all gives LOCAL_FEATURES
|
|
23
|
+
export async function fetchFeatures(device, { onDown } = {}) {
|
|
13
24
|
try {
|
|
14
25
|
const found = await call(device.url, "GET", "/editing/features", { token: device.token })
|
|
15
26
|
// motion, customMotion, assembly, livePreview, intent, craft, typeKit, referenceIntent, directorLoop, taviOrder: a server from before them says nothing, which is off
|
|
16
27
|
return { visuals: found?.visuals === true, playbooks: found?.playbooks === true, mediaSearch: found?.mediaSearch === true, motion: found?.motion === true, customMotion: found?.customMotion === true, assembly: found?.assembly === true, livePreview: found?.livePreview === true, intent: found?.intent === true, craft: found?.craft === true, typeKit: found?.typeKit === true, referenceIntent: found?.referenceIntent === true, directorLoop: found?.directorLoop === true, taviOrder: found?.taviOrder === true }
|
|
17
|
-
} catch {
|
|
18
|
-
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// Kriya can't be asked: this computer's own features. Kriya answered and refused, or an older Kriya: off
|
|
30
|
+
if (onDown && unreachable(error)) {
|
|
31
|
+
onDown()
|
|
32
|
+
return { ...LOCAL_FEATURES }
|
|
33
|
+
}
|
|
34
|
+
return { ...OFF }
|
|
19
35
|
}
|
|
20
36
|
}
|
|
21
37
|
|
package/src/launch.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join } from "node:path"
|
|
|
4
4
|
|
|
5
5
|
import { broadcastRun } from "./daemon.js"
|
|
6
6
|
import { BODY_ENCODING, ORCHESTRA_ALIAS, startGatewayProxy } from "./gateway-proxy.js"
|
|
7
|
-
import { BASE_PATH, KriyaError, models } from "./api.js"
|
|
7
|
+
import { BASE_PATH, KriyaError, models, unreachable } from "./api.js"
|
|
8
8
|
import { applyWorkforce, DEFAULT_MODE, modeEnv, SET_BY_PERSON, STANDALONE_SWITCHES } from "./modes.js"
|
|
9
9
|
import { LOCAL_WORKER, localWorker } from "./local-model.js"
|
|
10
10
|
import { launchOwn, ownFile, readOwn } from "./own-models.js"
|
|
@@ -67,8 +67,7 @@ export async function planTiers(device, list = models, { standalone = false } =
|
|
|
67
67
|
|
|
68
68
|
// Sign-in, suspension and version refusals: these stay Kriya's to decide
|
|
69
69
|
const REFUSED = new Set([401, 403, 426])
|
|
70
|
-
|
|
71
|
-
export const unreachable = (error) => error instanceof KriyaError && (error.status === 0 || error.status >= 500)
|
|
70
|
+
export { unreachable }
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* Standalone Mode: no Kriya account, `--standalone`, or Kriya unreachable.
|