@energy8platform/golem 0.6.0 → 0.8.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.
Files changed (73) hide show
  1. package/README.md +14 -0
  2. package/dist/editor.css +3 -4
  3. package/dist/editor.js +202 -101
  4. package/dist/lib/cli.js +225 -118
  5. package/dist/lib/cli.js.map +4 -4
  6. package/dist/lib/e8/agent.d.ts +35 -0
  7. package/dist/lib/e8/host.d.ts +22 -0
  8. package/dist/lib/e8/node.d.ts +66 -0
  9. package/dist/lib/e8/runtime.d.ts +10 -0
  10. package/dist/lib/e8/schema.d.ts +3 -0
  11. package/dist/lib/e8/types.d.ts +80 -0
  12. package/dist/lib/e8-agent.js +6865 -0
  13. package/dist/lib/e8-agent.js.map +7 -0
  14. package/dist/lib/e8-client.js +116 -0
  15. package/dist/lib/e8-host.js +7005 -0
  16. package/dist/lib/e8-host.js.map +7 -0
  17. package/dist/lib/e8-runtime.js +2079 -0
  18. package/dist/lib/e8-runtime.js.map +7 -0
  19. package/dist/lib/e8-schema.js +7 -0
  20. package/dist/lib/e8-schema.js.map +7 -0
  21. package/dist/lib/editor/api.d.ts +1 -0
  22. package/dist/lib/editor/embed.d.ts +9 -0
  23. package/dist/lib/editor/server.d.ts +23 -1
  24. package/dist/lib/editor/store.d.ts +34 -32
  25. package/dist/lib/editor/timeline.d.ts +15 -0
  26. package/dist/lib/editor-entry.d.ts +1 -1
  27. package/dist/lib/editor-entry.js +226 -118
  28. package/dist/lib/editor-entry.js.map +4 -4
  29. package/dist/lib/harness.js +54 -1
  30. package/dist/lib/interactive-editor.js.map +1 -1
  31. package/dist/lib/rig-check.d.ts +11 -0
  32. package/dist/lib/rig-control-qa.d.ts +8 -8
  33. package/dist/lib/rig-format.d.ts +184 -184
  34. package/dist/lib/rig-import-layers.d.ts +2 -0
  35. package/dist/lib/rig-symbol.d.ts +5 -2
  36. package/dist/lib/rig-tools.d.ts +2 -1
  37. package/dist/lib/rig-version.d.ts +12 -0
  38. package/dist/lib/runtime.js +60 -3
  39. package/dist/lib/runtime.js.map +3 -3
  40. package/dist/lib/tool-schema.d.ts +3 -0
  41. package/dist/lib/tools.d.ts +2 -0
  42. package/dist/lib/tools.js +179 -58
  43. package/dist/lib/tools.js.map +4 -4
  44. package/editor.html +2 -2
  45. package/package.json +38 -3
  46. package/skills/e8-golem/SKILL.md +71 -0
  47. package/skills/golem-symbol-animation/SKILL.md +87 -0
  48. package/skills/golem-symbol-animation/agents/openai.yaml +4 -0
  49. package/skills/golem-symbol-animation/references/facial-controls.md +48 -0
  50. package/skills/golem-symbol-animation/references/game-engine-integration.md +133 -0
  51. package/skills/golem-symbol-animation/references/golem-authoring.md +138 -0
  52. package/skills/golem-symbol-animation/references/interactive-editor.md +17 -0
  53. package/skills/golem-symbol-animation/references/motion-craft.md +116 -0
  54. package/skills/golem-symbol-animation/references/packed-delivery.md +88 -0
  55. package/skills/golem-symbol-animation/references/quantitative-qa.md +109 -0
  56. package/skills/golem-symbol-animation/references/spine-rive-study.md +87 -0
  57. package/skills/golem-symbol-animation/scripts/atlas_parts.py +87 -0
  58. package/skills/golem-symbol-animation/scripts/check_package.py +71 -0
  59. package/skills/golem-symbol-animation/scripts/image_gates.py +143 -0
  60. package/skills/golem-symbol-cutting/SKILL.md +70 -0
  61. package/skills/golem-symbol-cutting/agents/openai.yaml +4 -0
  62. package/skills/golem-symbol-cutting/assets/h1/h1.atlas.png +0 -0
  63. package/skills/golem-symbol-cutting/assets/h1/h1.png +0 -0
  64. package/skills/golem-symbol-cutting/references/cutting-workflow.md +92 -0
  65. package/skills/golem-symbol-cutting/references/facial-layers.md +44 -0
  66. package/skills/golem-symbol-cutting/references/generation-workflow.md +109 -0
  67. package/skills/golem-symbol-cutting/references/golem-handoff.md +62 -0
  68. package/skills/golem-symbol-cutting/references/h1-example.md +46 -0
  69. package/skills/golem-symbol-cutting/references/hybrid-workflow.md +119 -0
  70. package/skills/golem-symbol-cutting/references/registration-and-motion.md +89 -0
  71. package/skills/golem-symbol-cutting/references/spine-rive-construction.md +73 -0
  72. package/skills/golem-symbol-cutting/scripts/atlas_parts.py +87 -0
  73. package/skills/golem-symbol-cutting/scripts/hybrid_parts.py +279 -0
@@ -28,5 +28,7 @@ export interface LayerSpec {
28
28
  blend?: "normal" | "add" | "multiply" | "screen";
29
29
  }
30
30
  export declare function pngSize(buf: Buffer): [number, number];
31
+ /** `file`, named by a sidecar inside `dir` (layers.json, a Spine atlas), leaves `dir`: absolute or climbing out. */
32
+ export declare function outsideDir(dir: string, file: string): boolean;
31
33
  export declare function importLayers(doc: Doc, dir: string, relPrefix?: string): Promise<Doc>;
32
34
  export {};
@@ -2,7 +2,8 @@
2
2
  * rig-symbol — a rig as a slot symbol view for @energy8platform/game-engine (SymbolView, engine ≥ 0.43: square or rectangular cells).
3
3
  *
4
4
  * The interface is copied structurally (playIdle / playWin / showStatic / resize) so this package does not
5
- * depend on the engine. Centred at the origin and scaled so the rig canvas fits the cell, like AnimatedSymbol.
5
+ * depend on the engine. Centred at the origin and scaled so the rig's parts at rest fit the cell, like a static sprite
6
+ * symbol: the canvas margin left for the motion does not shrink it (a rig with nothing visible at rest fits its canvas).
6
7
  * `setDim(on)` is an extra for non-winning symbols. Updated through a ticker (Ticker.shared by default).
7
8
  */
8
9
  import { Container, type Texture } from "pixi.js";
@@ -22,7 +23,7 @@ export type SymbolSize = number | {
22
23
  height: number;
23
24
  };
24
25
  export interface RigSymbolOptions {
25
- /** cell size in px: a number scales the larger canvas side to it, a rectangle fits the canvas inside it */
26
+ /** cell size in px: a number scales the larger side of the parts at rest to it, a rectangle fits them inside it */
26
27
  size: SymbolSize;
27
28
  /** animation ids to use; missing ones are skipped gracefully */
28
29
  animations?: {
@@ -47,6 +48,8 @@ export declare class RigSymbol extends Container implements SymbolViewLike {
47
48
  private readonly names;
48
49
  private readonly ticker;
49
50
  private readonly onTick;
51
+ /** the parts at rest in the player's own space, measured before anything plays */
52
+ private readonly rest;
50
53
  constructor(doc: RigDocument, textures: Map<string, Texture>, opts: RigSymbolOptions);
51
54
  private has;
52
55
  resize(size: SymbolSize): void;
@@ -258,7 +258,8 @@ export declare function setKeys(doc: Doc, animId: string, track: Omit<Track, "ke
258
258
  }): Doc;
259
259
  /**
260
260
  * Re-tune one existing track without retyping keys: `amplitude` scales deviations from the rest value
261
- * (scale props as ratios), `offset` adds a constant, `timeScale` stretches key times (duration grows to fit).
261
+ * (scale props as ratios), `offset` adds a constant, `timeScale` stretches key times (duration grows to fit);
262
+ * `track.interpolation`, when given, replaces the track's.
262
263
  */
263
264
  export declare function adjustTrack(doc: Doc, animId: string, track: Omit<Track, "keys">, adj: {
264
265
  amplitude?: number;
@@ -0,0 +1,12 @@
1
+ import { type ToolResult } from "./rig-api";
2
+ /** `mtimeMs:size` of the file, or "missing" */
3
+ export declare function rigVersion(abs: string): Promise<string>;
4
+ /**
5
+ * callTool with the rig's version just before and just after, both read inside the rig's queue, so no other writer in
6
+ * this process lands between them. `args.path` must be absolute; a call without one reads "missing" twice.
7
+ */
8
+ export declare function callToolVersioned(name: string, args: Record<string, unknown>): Promise<{
9
+ result: ToolResult;
10
+ before: string;
11
+ after: string;
12
+ }>;
@@ -229,7 +229,7 @@ var Key = z.object({
229
229
  /** Optional independent easing for numeric-array components (for example Spine RGBA curves). */
230
230
  componentEase: z.array(Ease).min(1).optional()
231
231
  });
232
- var Interpolation = { interpolation: z.enum(["segment", "pchip"]).optional() };
232
+ var Interpolation = { interpolation: z.enum(["segment", "pchip", "spline"]).optional() };
233
233
  var Track = z.discriminatedUnion("target", [
234
234
  z.object({ target: z.literal("control"), id: Id, prop: z.literal("value"), ...Interpolation, keys: z.array(Key).min(1) }),
235
235
  z.object({ target: z.literal("bone"), id: Id, prop: BoneProp, ...Interpolation, keys: z.array(Key).min(1) }),
@@ -650,6 +650,57 @@ function smoothValue(track, i, t, component, loop) {
650
650
  const u = (t - k[i].t) / h(i), u2 = u * u, u3 = u2 * u;
651
651
  return (2 * u3 - 3 * u2 + 1) * v(i) + (u3 - 2 * u2 + u) * h(i) * tangent(i) + (-2 * u3 + 3 * u2) * v(i + 1) + (u3 - u2) * h(i) * tangent(i + 1);
652
652
  }
653
+ function tridiagonal(a, b, c, r) {
654
+ const n = b.length, cp = [], x = [];
655
+ let beta = b[0];
656
+ x[0] = r[0] / beta;
657
+ for (let i = 1; i < n; i++) {
658
+ cp[i] = c[i - 1] / beta;
659
+ beta = b[i] - a[i] * cp[i];
660
+ x[i] = (r[i] - a[i] * x[i - 1]) / beta;
661
+ }
662
+ for (let i = n - 2; i >= 0; i--) x[i] -= cp[i + 1] * x[i + 1];
663
+ return x;
664
+ }
665
+ function splineMoments(t, v, periodic) {
666
+ const n = t.length, h = (j) => t[j + 1] - t[j], d = (j) => (v[j + 1] - v[j]) / h(j);
667
+ if (!periodic) {
668
+ const a2 = [], b2 = [], c2 = [], r2 = [];
669
+ for (let i = 0; i < n; i++) {
670
+ const hp = i > 0 ? h(i - 1) : 0, hn = i < n - 1 ? h(i) : 0;
671
+ a2.push(hp);
672
+ b2.push(2 * (hp + hn));
673
+ c2.push(hn);
674
+ r2.push(6 * ((i < n - 1 ? d(i) : 0) - (i > 0 ? d(i - 1) : 0)));
675
+ }
676
+ return tridiagonal(a2, b2, c2, r2);
677
+ }
678
+ const m = n - 1, a = [], b = [], c = [], r = [];
679
+ for (let i = 0; i < m; i++) {
680
+ const p = (i + m - 1) % m;
681
+ a.push(h(p));
682
+ b.push(2 * (h(p) + h(i)));
683
+ c.push(h(i));
684
+ r.push(6 * (d(i) - d(p)));
685
+ }
686
+ const top = a[0], bottom = c[m - 1], gamma = -b[0];
687
+ const bb = [...b];
688
+ bb[0] -= gamma;
689
+ bb[m - 1] -= bottom * top / gamma;
690
+ const x = tridiagonal(a, bb, c, r), u = new Array(m).fill(0);
691
+ u[0] = gamma;
692
+ u[m - 1] = bottom;
693
+ const z2 = tridiagonal(a, bb, c, u);
694
+ const f = (x[0] + top * x[m - 1] / gamma) / (1 + z2[0] + top * z2[m - 1] / gamma);
695
+ const M = x.map((xi, i) => xi - f * z2[i]);
696
+ return [...M, M[0]];
697
+ }
698
+ function splineValue(track, i, t, component, loop) {
699
+ const k = track.keys, ts = k.map((x) => x.t), vs = k.map((x) => component === void 0 ? x.v : x.v[component]);
700
+ const M = splineMoments(ts, vs, loop && k.length > 3 && vs[0] === vs[k.length - 1]);
701
+ const H = ts[i + 1] - ts[i], A = (ts[i + 1] - t) / H, B = (t - ts[i]) / H;
702
+ return A * vs[i] + B * vs[i + 1] + ((A ** 3 - A) * M[i] + (B ** 3 - B) * M[i + 1]) * H * H / 6;
703
+ }
653
704
  function sample(track, t, loop = false) {
654
705
  const keys = track.keys;
655
706
  if (t <= keys[0].t) return keys[0].v;
@@ -661,11 +712,13 @@ function sample(track, t, loop = false) {
661
712
  if (a.ease === "step") return a.v;
662
713
  if (typeof a.v === "number" && typeof b.v === "number") {
663
714
  if (track.interpolation === "pchip") return smoothValue(track, i, t, void 0, loop);
715
+ if (track.interpolation === "spline") return splineValue(track, i, t, void 0, loop);
664
716
  const u = ease(a.ease)((t - a.t) / (b.t - a.t));
665
717
  return a.v + (b.v - a.v) * u;
666
718
  }
667
719
  if (Array.isArray(a.v) && Array.isArray(b.v) && typeof a.v[0] === "number") {
668
720
  if (track.interpolation === "pchip") return a.v.map((_, j) => smoothValue(track, i, t, j, loop));
721
+ if (track.interpolation === "spline") return a.v.map((_, j) => splineValue(track, i, t, j, loop));
669
722
  const phase = (t - a.t) / (b.t - a.t), av = a.v, bv = b.v;
670
723
  return av.map((v, k) => v + ((bv[k] ?? v) - v) * ease(a.componentEase?.[k] ?? a.ease)(phase));
671
724
  }
@@ -1869,6 +1922,8 @@ var RigSymbol = class extends Container2 {
1869
1922
  this.names = { idle: "idle", win: "win", dim: "dim", ...opts.animations };
1870
1923
  this.ticker = opts.ticker ?? Ticker.shared;
1871
1924
  this.addChild(this.player.view);
1925
+ const r = this.player.view.getLocalBounds();
1926
+ this.rest = r.width > 0 && r.height > 0 ? { x: r.x, y: r.y, width: r.width, height: r.height } : { x: 0, y: 0, ...doc.meta };
1872
1927
  this.resize(opts.size);
1873
1928
  this.ticker.add(this.onTick);
1874
1929
  }
@@ -1876,14 +1931,16 @@ var RigSymbol = class extends Container2 {
1876
1931
  names;
1877
1932
  ticker;
1878
1933
  onTick = (t) => this.player.tick(t.deltaMS / 1e3);
1934
+ /** the parts at rest in the player's own space, measured before anything plays */
1935
+ rest;
1879
1936
  has(id) {
1880
1937
  return this.doc.animations.some((a) => a.id === id);
1881
1938
  }
1882
1939
  resize(size) {
1883
- const { width, height } = this.doc.meta;
1940
+ const { x, y, width, height } = this.rest;
1884
1941
  const s = typeof size === "number" ? size / Math.max(width, height) : Math.min(size.width / width, size.height / height);
1885
1942
  this.player.view.scale.set(s);
1886
- this.player.view.position.set(-width * s / 2, -height * s / 2);
1943
+ this.player.view.position.set(-(x + width / 2) * s, -(y + height / 2) * s);
1887
1944
  }
1888
1945
  playIdle() {
1889
1946
  if (this.has(this.names.idle)) this.player.state.setBase(this.names.idle);