@energy8platform/golem 0.6.0 → 0.7.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 (64) hide show
  1. package/README.md +14 -0
  2. package/dist/editor.css +3 -4
  3. package/dist/editor.js +108 -61
  4. package/dist/lib/cli.js +101 -70
  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 +6781 -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 +6929 -0
  16. package/dist/lib/e8-host.js.map +7 -0
  17. package/dist/lib/e8-runtime.js +2024 -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 +2 -0
  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 +102 -70
  28. package/dist/lib/editor-entry.js.map +4 -4
  29. package/dist/lib/rig-import-layers.d.ts +2 -0
  30. package/dist/lib/rig-version.d.ts +12 -0
  31. package/dist/lib/tool-schema.d.ts +3 -0
  32. package/dist/lib/tools.d.ts +2 -0
  33. package/dist/lib/tools.js +49 -10
  34. package/dist/lib/tools.js.map +4 -4
  35. package/editor.html +2 -2
  36. package/package.json +38 -3
  37. package/skills/e8-golem/SKILL.md +71 -0
  38. package/skills/golem-symbol-animation/SKILL.md +87 -0
  39. package/skills/golem-symbol-animation/agents/openai.yaml +4 -0
  40. package/skills/golem-symbol-animation/references/facial-controls.md +48 -0
  41. package/skills/golem-symbol-animation/references/game-engine-integration.md +133 -0
  42. package/skills/golem-symbol-animation/references/golem-authoring.md +138 -0
  43. package/skills/golem-symbol-animation/references/interactive-editor.md +17 -0
  44. package/skills/golem-symbol-animation/references/motion-craft.md +113 -0
  45. package/skills/golem-symbol-animation/references/packed-delivery.md +88 -0
  46. package/skills/golem-symbol-animation/references/quantitative-qa.md +106 -0
  47. package/skills/golem-symbol-animation/references/spine-rive-study.md +87 -0
  48. package/skills/golem-symbol-animation/scripts/atlas_parts.py +87 -0
  49. package/skills/golem-symbol-animation/scripts/check_package.py +71 -0
  50. package/skills/golem-symbol-animation/scripts/image_gates.py +143 -0
  51. package/skills/golem-symbol-cutting/SKILL.md +70 -0
  52. package/skills/golem-symbol-cutting/agents/openai.yaml +4 -0
  53. package/skills/golem-symbol-cutting/assets/h1/h1.atlas.png +0 -0
  54. package/skills/golem-symbol-cutting/assets/h1/h1.png +0 -0
  55. package/skills/golem-symbol-cutting/references/cutting-workflow.md +92 -0
  56. package/skills/golem-symbol-cutting/references/facial-layers.md +44 -0
  57. package/skills/golem-symbol-cutting/references/generation-workflow.md +109 -0
  58. package/skills/golem-symbol-cutting/references/golem-handoff.md +62 -0
  59. package/skills/golem-symbol-cutting/references/h1-example.md +46 -0
  60. package/skills/golem-symbol-cutting/references/hybrid-workflow.md +119 -0
  61. package/skills/golem-symbol-cutting/references/registration-and-motion.md +89 -0
  62. package/skills/golem-symbol-cutting/references/spine-rive-construction.md +73 -0
  63. package/skills/golem-symbol-cutting/scripts/atlas_parts.py +87 -0
  64. package/skills/golem-symbol-cutting/scripts/hybrid_parts.py +279 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * e8/client — the IDE half of golem's e8 row, a plain ES module the e8 IDE loads as is (no JSX, no bare imports;
3
+ * React comes from the IDE). A rig.json opens the rig editor (the host half serves it under /golem/) in its tab,
4
+ * painted with the IDE's theme tokens; an agent's rig write becomes one undo step that golem's own history takes back.
5
+ */
6
+ const { React } = globalThis.__E8_IDE__;
7
+
8
+ export const name = 'golem';
9
+ export const inject = ['viewers', 'history', 'connection'];
10
+
11
+ export const isRig = (path) => path === 'rig.json' || path.endsWith('/rig.json');
12
+
13
+ /** golem editor token, the IDE token it takes its value from */
14
+ export const THEME = [
15
+ ['--bg', '--e8-editor-bg'], ['--panel', '--e8-surface'], ['--chrome', '--e8-shell-bg'], ['--line', '--e8-border'],
16
+ ['--accent', '--e8-accent'], ['--accent-hover', '--e8-accent'], ['--fg', '--e8-fg'], ['--fg2', '--e8-fg-muted'],
17
+ ['--ctl', '--e8-hover'], ['--ctl-hover', '--e8-selected'], ['--ctl-line', '--e8-border'],
18
+ ['--err', '--e8-error'], ['--warn', '--e8-warning'], ['--font', '--e8-font'], ['--size', '--e8-size'],
19
+ ];
20
+
21
+ /** The golem tokens from the IDE's computed style; a token the IDE does not define is left out. */
22
+ export function themeVars(style) {
23
+ const vars = {};
24
+ for (const [golem, e8] of THEME) {
25
+ const value = style.getPropertyValue(e8).trim();
26
+ if (value) vars[golem] = value;
27
+ }
28
+ return vars;
29
+ }
30
+
31
+ export const editorUrl = (path) => `/golem/editor.html?rig=${encodeURIComponent(path)}&embed=1`;
32
+
33
+ function RigEditor({ path }) {
34
+ const ref = React.useRef(null);
35
+ React.useEffect(() => {
36
+ const frame = ref.current;
37
+ if (!frame) return undefined;
38
+ // on every load (the editor reloads itself on reconnects) and on every theme switch
39
+ const post = () =>
40
+ frame.contentWindow?.postMessage(
41
+ { type: 'golem:theme', vars: themeVars(getComputedStyle(document.documentElement)) },
42
+ location.origin,
43
+ );
44
+ frame.addEventListener('load', post);
45
+ const observer = new MutationObserver(post);
46
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
47
+ return () => {
48
+ frame.removeEventListener('load', post);
49
+ observer.disconnect();
50
+ };
51
+ }, []);
52
+ return React.createElement('iframe', {
53
+ ref,
54
+ src: editorUrl(path),
55
+ title: path,
56
+ 'data-testid': 'golem-editor',
57
+ style: { border: 0, width: '100%', height: '100%', display: 'block' },
58
+ });
59
+ }
60
+
61
+ /**
62
+ * Per rig, a version an agent write saw (its before or after) → the version that same content has now. Versions are
63
+ * `mtimeMs:size`, so a move gives the content back under a new version; the steps around it find it here.
64
+ */
65
+ const moved = new Map();
66
+ function now(rig, version) {
67
+ const seen = new Set();
68
+ while (moved.has(`${rig}\n${version}`) && !seen.has(version)) {
69
+ seen.add(version);
70
+ version = moved.get(`${rig}\n${version}`);
71
+ }
72
+ return version;
73
+ }
74
+
75
+ /**
76
+ * One undo step for an agent's write to `rig` (`before` → `after`): golem's rig_undo / rig_redo, each refused (409)
77
+ * when the rig is no longer at the version that content has now — someone edited it since. Answers are the IDE's
78
+ * StepAnswer.
79
+ */
80
+ export function rigStep(rig, label, before, after, post = fetch) {
81
+ const move = async (tool, verb, from, to) => {
82
+ let res;
83
+ try {
84
+ res = await post(`/golem/api/tool/${tool}`, {
85
+ method: 'POST',
86
+ headers: { 'content-type': 'application/json' },
87
+ body: JSON.stringify({ rig, baseVersion: now(rig, from) }),
88
+ });
89
+ } catch {
90
+ return { reason: 'golem editor unreachable — try again', keep: true }; // the IDE keeps the step for a later Mod+Z
91
+ }
92
+ if (res.status === 409) return `changed elsewhere since — can't ${verb}`;
93
+ const body = await res.json().catch(() => ({}));
94
+ if (!res.ok || body.isError) return String(body.text ?? `${res.status} ${res.statusText}`).replace(/^ERROR: /, '');
95
+ if (typeof body.version !== 'string') return `golem answered with no version — can't ${verb}`;
96
+ moved.set(`${rig}\n${to}`, body.version);
97
+ return null;
98
+ };
99
+ return { label, undo: () => move('rig_undo', 'undo', after, before), redo: () => move('rig_redo', 'redo', before, after) };
100
+ }
101
+
102
+ export function apply(ctx) {
103
+ ctx.effect(() => ctx.viewers.register({ id: 'golem', match: isRig, component: RigEditor }), 'golem:viewer');
104
+ ctx.effect(
105
+ () => ctx.history.scope((key) => (key.startsWith('f:') && isRig(key.slice(2)) ? [`rig:${key.slice(2)}`] : undefined)),
106
+ 'golem:history-scope',
107
+ );
108
+ ctx.effect(
109
+ () =>
110
+ ctx.connection.onFrame((frame) => {
111
+ if (frame.type !== 'agent-write' || !frame.key.startsWith('rig:')) return;
112
+ ctx.history.record(frame.key, rigStep(frame.key.slice(4), frame.label, frame.before, frame.after));
113
+ }),
114
+ 'golem:agent-writes',
115
+ );
116
+ }