@kriya-ai/harness 0.2.3 → 0.2.4
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/contract/SOURCE.md +3 -3
- package/contract/contract.json +188 -0
- package/package.json +1 -1
- package/src/edit/core/layout.js +24 -1
- package/src/edit/core/ops.js +3 -2
- package/src/edit/core/plan.js +2 -1
- package/src/edit/core/solver.js +39 -3
- package/src/edit/director/beats.js +335 -0
- package/src/edit/director/lookups.js +133 -0
- package/src/edit/director/plan.js +73 -6
- package/src/edit/director/playbooks.js +131 -0
- package/src/edit/director/revise.js +2 -0
- package/src/edit/engine/captions.js +32 -0
- package/src/edit/engine/found-media.js +64 -0
- package/src/edit/engine/motion.js +19 -2
- package/src/edit/engine/scenes.js +480 -0
- package/src/edit/gates/copy.js +25 -5
- package/src/edit/gates/index.js +12 -4
- package/src/edit/gates/picture.js +5 -0
- package/src/edit/gates/text.js +20 -4
- package/src/edit/graph/scheduler.js +1 -1
- package/src/edit/host/deliver.js +8 -1
- package/src/edit/host/projects.js +170 -9
- package/src/edit/host/server.js +40 -0
- package/src/edit/index/views.js +9 -0
- package/src/edit/loop/make.js +8 -5
- package/src/edit/recipes/montage.js +74 -0
- package/src/edit/recipes/programme.js +24 -0
- package/src/edit/recipes/reel.js +31 -11
- package/src/edit/recipes/scene-clips.js +127 -0
- package/src/edit/runtime/fetch.js +32 -0
- package/studio/dist/studio.css +14 -0
- package/studio/dist/studio.js +3 -3
package/contract/SOURCE.md
CHANGED
|
@@ -7,9 +7,9 @@ again from Kriya and update the hash below in the same change.
|
|
|
7
7
|
|
|
8
8
|
| Field | Value |
|
|
9
9
|
| --- | --- |
|
|
10
|
-
| Copied | 2026-11-
|
|
11
|
-
| From | Kriya repository `main` (uncommitted) on `
|
|
12
|
-
| sha256 | `
|
|
10
|
+
| Copied | 2026-11-09 (again: `GET /editing/features`, for the visual scenes) |
|
|
11
|
+
| From | Kriya repository `main` (uncommitted) on `a2bb6ed` |
|
|
12
|
+
| sha256 | `8bf16886bc6b98bda3f261c9a762c7424324e9a893f5a50ff12f77c4b71ed754` |
|
|
13
13
|
|
|
14
14
|
When the Kriya side commits the file, replace "From" with that commit.
|
|
15
15
|
`tests/contract.test.js` checks the hash, so a hand edit fails.
|
package/contract/contract.json
CHANGED
|
@@ -785,6 +785,194 @@
|
|
|
785
785
|
"additionalProperties": false
|
|
786
786
|
}
|
|
787
787
|
},
|
|
788
|
+
{
|
|
789
|
+
"method": "GET",
|
|
790
|
+
"path": "/editing/features",
|
|
791
|
+
"auth": true,
|
|
792
|
+
"request": null,
|
|
793
|
+
"response": {
|
|
794
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
795
|
+
"type": "object",
|
|
796
|
+
"properties": {
|
|
797
|
+
"visuals": {
|
|
798
|
+
"type": "boolean"
|
|
799
|
+
},
|
|
800
|
+
"playbooks": {
|
|
801
|
+
"type": "boolean"
|
|
802
|
+
},
|
|
803
|
+
"mediaSearch": {
|
|
804
|
+
"type": "boolean"
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
"required": ["visuals", "playbooks", "mediaSearch"],
|
|
808
|
+
"additionalProperties": false
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
"method": "POST",
|
|
813
|
+
"path": "/editing/media",
|
|
814
|
+
"auth": true,
|
|
815
|
+
"request": {
|
|
816
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
817
|
+
"type": "object",
|
|
818
|
+
"properties": {
|
|
819
|
+
"queries": {
|
|
820
|
+
"minItems": 1,
|
|
821
|
+
"maxItems": 6,
|
|
822
|
+
"type": "array",
|
|
823
|
+
"items": {
|
|
824
|
+
"type": "string",
|
|
825
|
+
"minLength": 2,
|
|
826
|
+
"maxLength": 80
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
"required": ["queries"],
|
|
831
|
+
"additionalProperties": false
|
|
832
|
+
},
|
|
833
|
+
"response": {
|
|
834
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
835
|
+
"type": "object",
|
|
836
|
+
"properties": {
|
|
837
|
+
"results": {
|
|
838
|
+
"type": "array",
|
|
839
|
+
"items": {
|
|
840
|
+
"type": "object",
|
|
841
|
+
"properties": {
|
|
842
|
+
"query": {
|
|
843
|
+
"type": "string"
|
|
844
|
+
},
|
|
845
|
+
"items": {
|
|
846
|
+
"type": "array",
|
|
847
|
+
"items": {
|
|
848
|
+
"type": "object",
|
|
849
|
+
"properties": {
|
|
850
|
+
"id": {
|
|
851
|
+
"type": "string"
|
|
852
|
+
},
|
|
853
|
+
"source": {
|
|
854
|
+
"type": "string",
|
|
855
|
+
"enum": ["wikimedia", "nasa", "openverse"]
|
|
856
|
+
},
|
|
857
|
+
"kind": {
|
|
858
|
+
"type": "string",
|
|
859
|
+
"enum": ["image", "video"]
|
|
860
|
+
},
|
|
861
|
+
"title": {
|
|
862
|
+
"type": "string"
|
|
863
|
+
},
|
|
864
|
+
"url": {
|
|
865
|
+
"type": "string"
|
|
866
|
+
},
|
|
867
|
+
"thumb": {
|
|
868
|
+
"type": "string"
|
|
869
|
+
},
|
|
870
|
+
"width": {
|
|
871
|
+
"type": ["number", "null"]
|
|
872
|
+
},
|
|
873
|
+
"height": {
|
|
874
|
+
"type": ["number", "null"]
|
|
875
|
+
},
|
|
876
|
+
"licence": {
|
|
877
|
+
"type": "string"
|
|
878
|
+
},
|
|
879
|
+
"rights": {
|
|
880
|
+
"type": "string",
|
|
881
|
+
"enum": ["public_domain", "licensed"]
|
|
882
|
+
},
|
|
883
|
+
"creator": {
|
|
884
|
+
"type": "string"
|
|
885
|
+
},
|
|
886
|
+
"page": {
|
|
887
|
+
"type": "string"
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
"required": [
|
|
891
|
+
"id",
|
|
892
|
+
"source",
|
|
893
|
+
"kind",
|
|
894
|
+
"title",
|
|
895
|
+
"url",
|
|
896
|
+
"thumb",
|
|
897
|
+
"width",
|
|
898
|
+
"height",
|
|
899
|
+
"licence",
|
|
900
|
+
"rights",
|
|
901
|
+
"creator",
|
|
902
|
+
"page"
|
|
903
|
+
],
|
|
904
|
+
"additionalProperties": false
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
"required": ["query", "items"],
|
|
909
|
+
"additionalProperties": false
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
"required": ["results"],
|
|
914
|
+
"additionalProperties": false
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"method": "POST",
|
|
919
|
+
"path": "/editing/define",
|
|
920
|
+
"auth": true,
|
|
921
|
+
"request": {
|
|
922
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
923
|
+
"type": "object",
|
|
924
|
+
"properties": {
|
|
925
|
+
"terms": {
|
|
926
|
+
"minItems": 1,
|
|
927
|
+
"maxItems": 6,
|
|
928
|
+
"type": "array",
|
|
929
|
+
"items": {
|
|
930
|
+
"type": "string",
|
|
931
|
+
"minLength": 2,
|
|
932
|
+
"maxLength": 80
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
"required": ["terms"],
|
|
937
|
+
"additionalProperties": false
|
|
938
|
+
},
|
|
939
|
+
"response": {
|
|
940
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
941
|
+
"type": "object",
|
|
942
|
+
"properties": {
|
|
943
|
+
"definitions": {
|
|
944
|
+
"type": "array",
|
|
945
|
+
"items": {
|
|
946
|
+
"type": "object",
|
|
947
|
+
"properties": {
|
|
948
|
+
"term": {
|
|
949
|
+
"type": "string"
|
|
950
|
+
},
|
|
951
|
+
"title": {
|
|
952
|
+
"type": "string"
|
|
953
|
+
},
|
|
954
|
+
"quote": {
|
|
955
|
+
"type": "string"
|
|
956
|
+
},
|
|
957
|
+
"source": {
|
|
958
|
+
"type": "string"
|
|
959
|
+
},
|
|
960
|
+
"page": {
|
|
961
|
+
"type": "string"
|
|
962
|
+
},
|
|
963
|
+
"licence": {
|
|
964
|
+
"type": "string"
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
"required": ["term", "title", "quote", "source", "page", "licence"],
|
|
968
|
+
"additionalProperties": false
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
"required": ["definitions"],
|
|
973
|
+
"additionalProperties": false
|
|
974
|
+
}
|
|
975
|
+
},
|
|
788
976
|
{
|
|
789
977
|
"method": "POST",
|
|
790
978
|
"path": "/editing/jobs/{id}/previews",
|
package/package.json
CHANGED
package/src/edit/core/layout.js
CHANGED
|
@@ -29,7 +29,30 @@ export function safeZoneFor(project) {
|
|
|
29
29
|
return zone
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/** A cutaway scene's block (VISUAL_SCENES.md): it covers the frame, so the speaker's face isn't in the picture under it. */
|
|
33
|
+
export const isSceneBlock = (block) => block?.blockId === "scene"
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A scene's two regions, in canvas pixels: its content box, inside the safe zones, and the
|
|
37
|
+
* caption row under it, so a caption over a scene never lands on the diagram.
|
|
38
|
+
* @param {{ width: number, height: number }} canvas
|
|
39
|
+
* @param {{ top?: number, right?: number, bottom?: number, left?: number }} safe
|
|
40
|
+
* @param {{ w: number, h: number }} caption the caption box's size
|
|
41
|
+
*/
|
|
42
|
+
export function sceneFrame(canvas, safe, caption) {
|
|
43
|
+
const margin = Math.round(Math.min(canvas.width, canvas.height) * 0.05)
|
|
44
|
+
// A little inside the safe zone: a spring's overshoot on entry mustn't cross it (found on real footage)
|
|
45
|
+
const inset = Math.round(margin / 4)
|
|
46
|
+
const left = Math.max(safe.left ?? 0, margin) + inset
|
|
47
|
+
const right = Math.max(safe.right ?? 0, margin) + inset
|
|
48
|
+
const top = Math.max(safe.top ?? 0, margin) + inset
|
|
49
|
+
const bottom = Math.max(safe.bottom ?? 0, Math.round(margin / 2))
|
|
50
|
+
const w = Math.min(caption.w, canvas.width - (safe.left ?? 0) - (safe.right ?? 0))
|
|
51
|
+
const row = { x: (safe.left ?? 0) + Math.floor((canvas.width - (safe.left ?? 0) - (safe.right ?? 0) - w) / 2), y: canvas.height - bottom - caption.h, w, h: caption.h }
|
|
52
|
+
return { row, content: { x: left, y: top, w: canvas.width - left - right, h: row.y - Math.round(margin / 2) - top } }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const overlaps =(a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h
|
|
33
56
|
|
|
34
57
|
function candidates(item, { canvas, safe, prefer }) {
|
|
35
58
|
if (item.fixed) return [{ box: item.fixed, cost: 0 }]
|
package/src/edit/core/ops.js
CHANGED
|
@@ -176,11 +176,12 @@ function removeFrom(s, op, asset, from, to) {
|
|
|
176
176
|
const OPS = {
|
|
177
177
|
// Selection
|
|
178
178
|
keep_range: {
|
|
179
|
-
|
|
179
|
+
// exact: cut where it's asked, not moved off a word or padded (a montage's cuts stay on the beat)
|
|
180
|
+
fields: { asset: "id", from: "ref", to: "ref", "after?": { nullable: "id" }, "exact?": "bool" },
|
|
180
181
|
run(op, s) {
|
|
181
182
|
const asset = assetOf(s, op.asset, SEQUENCED)
|
|
182
183
|
checkRange(s, asset, sourceEdge(s, op.from, asset.id, "start"), sourceEdge(s, op.to, asset.id, "end"))
|
|
183
|
-
const clip = addClip(s, "base", { source: { asset: asset.id, in: op.from, out: op.to } })
|
|
184
|
+
const clip = addClip(s, "base", { source: { asset: asset.id, in: op.from, out: op.to }, ...(op.exact ? { seamIn: true, seamOut: true } : {}) })
|
|
184
185
|
if (op.after === undefined) return
|
|
185
186
|
const clips = sequenceOf(s).clips
|
|
186
187
|
clips.pop()
|
package/src/edit/core/plan.js
CHANGED
|
@@ -157,7 +157,8 @@ export function compile(project, rawIndex, { engineVersion, runtimeVersion, qual
|
|
|
157
157
|
})
|
|
158
158
|
: []
|
|
159
159
|
const blockTiles = timeline.overlays
|
|
160
|
-
|
|
160
|
+
// A definition with no clear place stays out (the solver has said why), rather than land on a face
|
|
161
|
+
.filter((overlay) => overlay.block && !(overlay.block.blockId === "term" && !overlay.placement))
|
|
161
162
|
.map((overlay) => {
|
|
162
163
|
const node = { kind: "block", ...overlay.block, placement: overlay.placement, duration: overlay.end - overlay.at, ...(overlay.behind ? { behind: true } : {}) }
|
|
163
164
|
return { key: key(node, []), kind: "block", at: overlay.at, end: overlay.end, node }
|
package/src/edit/core/solver.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { anchorSource, openIndex, wordAfter, wordAt, wordBefore } from "./anchors.js"
|
|
6
6
|
import { mapBox } from "./faces.js"
|
|
7
|
-
import { safeZoneFor, solveLayout } from "./layout.js"
|
|
7
|
+
import { isSceneBlock, safeZoneFor, sceneFrame, solveLayout } from "./layout.js"
|
|
8
8
|
import { flicksToFrames, frameAtTimestamp, framesToFlicks, scaleFlicks, snapToFrame } from "./time.js"
|
|
9
9
|
|
|
10
10
|
const ms = (n) => n * 705_600
|
|
@@ -362,17 +362,53 @@ function facesDuring(s, at, end) {
|
|
|
362
362
|
return boxes
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
// A page a fast speaker says in a blink stays up long enough to read, until the next one starts (found on real footage)
|
|
366
|
+
const MIN_CAPTION = 1.2 * 705_600_000
|
|
367
|
+
function holdCaptions(s) {
|
|
368
|
+
// Only where a playbook asked for it (DP3): off, every existing project solves exactly as before
|
|
369
|
+
if (s.project.look?.caption?.hold !== true) return
|
|
370
|
+
const list = [...s.captions].sort((a, b) => a.at - b.at)
|
|
371
|
+
list.forEach((caption, i) => {
|
|
372
|
+
const next = list[i + 1]?.at ?? s.duration
|
|
373
|
+
// Text behind the speaker keeps its matte's window exactly
|
|
374
|
+
if (!caption.behind && caption.end - caption.at < MIN_CAPTION) caption.end = Math.max(caption.end, Math.min(caption.at + MIN_CAPTION, next, s.duration))
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
|
|
365
378
|
/** Step 6: every caption and card gets a place, or a report. */
|
|
366
379
|
function layOut(s) {
|
|
380
|
+
holdCaptions(s)
|
|
367
381
|
const { rules } = s
|
|
368
382
|
const { width, height } = s.project.canvas
|
|
369
383
|
const safe = rules.safe ?? safeZoneFor(s.project)
|
|
370
384
|
// Narrower than the look's width when the safe zone is (found in ED8: else no row fits)
|
|
371
385
|
const w = Math.min(Math.floor((width * rules.boxWidth) / 100), width - (safe.left ?? 0) - (safe.right ?? 0))
|
|
372
386
|
const h = Math.floor((height * rules.boxHeight) / 100)
|
|
373
|
-
|
|
387
|
+
// A scene takes its content box; what plays over it sits on the row below that, with no face to clear
|
|
388
|
+
const scenes = s.overlays.filter((o) => isSceneBlock(o.block))
|
|
389
|
+
const frame = sceneFrame({ width, height }, safe, { w, h })
|
|
390
|
+
for (const scene of scenes) scene.placement = frame.content
|
|
391
|
+
// A definition has its own place, above the caption row or at the top, wherever no face is; with none free
|
|
392
|
+
// it stays out. Captions under it keep to their row, so the two never meet
|
|
393
|
+
const terms = s.overlays.filter((o) => o.block?.blockId === "term")
|
|
394
|
+
for (const term of terms) {
|
|
395
|
+
const tall = Math.floor(height * 0.18)
|
|
396
|
+
const gap = Math.round(height * 0.012)
|
|
397
|
+
const clash = (box) => facesDuring(s, term.at, term.end).some((f) => box.x < f.x + f.w && f.x < box.x + box.w && box.y < f.y + f.h && f.y < box.y + box.h)
|
|
398
|
+
const options = [{ ...frame.row, y: frame.row.y - gap - tall, h: tall }, { ...frame.row, y: frame.content.y, h: tall }]
|
|
399
|
+
term.placement = options.find((box) => !clash(box)) ?? null
|
|
400
|
+
if (!term.placement) s.issue("no_placement", { clip: term.clip, message: "there's no place for this definition clear of the speaker's face, so it isn't shown" })
|
|
401
|
+
}
|
|
402
|
+
const onScene = (item) => [...scenes, ...terms].some((scene) => scene.at < item.end && item.at < scene.end)
|
|
403
|
+
// Footage over the whole frame hides the speaker, so a caption there has no face to clear
|
|
404
|
+
const footage = s.overlays.filter((o) => !o.block)
|
|
405
|
+
const hidden = (item) => footage.some((o) => o.at <= item.at && item.end <= o.end)
|
|
406
|
+
const placeable = [...s.captions, ...s.overlays.filter((o) => o.block && !isSceneBlock(o.block) && o.block.blockId !== "term")]
|
|
374
407
|
// Text behind the speaker may sit on the face: the matte puts the speaker in front of it
|
|
375
|
-
const items = placeable.map((item) =>
|
|
408
|
+
const items = placeable.map((item) => {
|
|
409
|
+
const covered = onScene(item)
|
|
410
|
+
return { id: item.clip, at: item.at, end: item.end, w, h, faces: item.behind || covered || hidden(item) ? [] : facesDuring(s, item.at, item.end), ...(item.placement ? { fixed: item.placement } : covered ? { fixed: frame.row } : {}) }
|
|
411
|
+
})
|
|
376
412
|
const { placements, issues } = solveLayout(items, { canvas: { width, height }, safe, prefer: rules.prefer })
|
|
377
413
|
for (const item of placeable) item.placement = placements[item.clip]
|
|
378
414
|
for (const issue of issues) s.issue(issue.code, issue)
|