oda-engine 0.0.0-stage → 0.1.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 (204) hide show
  1. package/README.md +151 -2
  2. package/bin/nowhere.mjs +352 -0
  3. package/lib/account.mjs +57 -0
  4. package/lib/agentModules.mjs +57 -0
  5. package/lib/devServer.mjs +351 -0
  6. package/lib/headless.mjs +231 -0
  7. package/lib/headlessPreview.mjs +212 -0
  8. package/lib/keys.mjs +517 -0
  9. package/lib/make.mjs +855 -0
  10. package/lib/mcp.mjs +537 -0
  11. package/lib/open.mjs +22 -0
  12. package/lib/preview.mjs +87 -0
  13. package/lib/previewRpc.mjs +134 -0
  14. package/lib/project.mjs +359 -0
  15. package/lib/publishFlow.mjs +90 -0
  16. package/lib/resources.mjs +50 -0
  17. package/lib/rules.mjs +60 -0
  18. package/lib/scaffold.mjs +42 -0
  19. package/lib/setup.mjs +59 -0
  20. package/lib/tools.mjs +668 -0
  21. package/package.json +51 -4
  22. package/template/game.config.json +9 -0
  23. package/template/scene.json +4 -0
  24. package/template/src/main.ts +11 -0
  25. package/vendor/DOCS.md +447 -0
  26. package/vendor/agent/appRun.mjs +520 -0
  27. package/vendor/agent/assets/brief.mjs +242 -0
  28. package/vendor/agent/assets/collider.mjs +531 -0
  29. package/vendor/agent/assets/environments/index.mjs +12 -0
  30. package/vendor/agent/assets/environments/worldlabs.mjs +161 -0
  31. package/vendor/agent/assets/fetch.mjs +168 -0
  32. package/vendor/agent/assets/footprint.mjs +13 -0
  33. package/vendor/agent/assets/gltf.mjs +547 -0
  34. package/vendor/agent/assets/hdr.mjs +269 -0
  35. package/vendor/agent/assets/imageOps.mjs +171 -0
  36. package/vendor/agent/assets/images/codex.mjs +307 -0
  37. package/vendor/agent/assets/images/fal.mjs +75 -0
  38. package/vendor/agent/assets/images/gemini.mjs +84 -0
  39. package/vendor/agent/assets/images/index.mjs +25 -0
  40. package/vendor/agent/assets/images/openai.mjs +75 -0
  41. package/vendor/agent/assets/images/stability.mjs +71 -0
  42. package/vendor/agent/assets/images/views.mjs +31 -0
  43. package/vendor/agent/assets/import.mjs +1352 -0
  44. package/vendor/agent/assets/inspect.mjs +465 -0
  45. package/vendor/agent/assets/jobs.mjs +196 -0
  46. package/vendor/agent/assets/ktx2.mjs +290 -0
  47. package/vendor/agent/assets/ledger.mjs +466 -0
  48. package/vendor/agent/assets/net.mjs +254 -0
  49. package/vendor/agent/assets/prices.json +39 -0
  50. package/vendor/agent/assets/providers/fal.mjs +115 -0
  51. package/vendor/agent/assets/providers/index.mjs +22 -0
  52. package/vendor/agent/assets/providers/meshy.mjs +119 -0
  53. package/vendor/agent/assets/providers/tripo.mjs +188 -0
  54. package/vendor/agent/assets/sources/ambientcg.mjs +129 -0
  55. package/vendor/agent/assets/sources/index.mjs +23 -0
  56. package/vendor/agent/assets/sources/polyhaven.mjs +237 -0
  57. package/vendor/agent/assets/sources/polypizza.mjs +121 -0
  58. package/vendor/agent/assets/splat.mjs +631 -0
  59. package/vendor/agent/assets/targets.mjs +122 -0
  60. package/vendor/agent/assets/tile.mjs +261 -0
  61. package/vendor/agent/assets/unzip.mjs +180 -0
  62. package/vendor/agent/blender/cleanup.py +360 -0
  63. package/vendor/agent/blender/convert.py +167 -0
  64. package/vendor/agent/blender/find.mjs +192 -0
  65. package/vendor/agent/blender/nw_export.py +104 -0
  66. package/vendor/agent/blender/nw_rubric.py +426 -0
  67. package/vendor/agent/blender/run.mjs +193 -0
  68. package/vendor/agent/blender/runner.py +252 -0
  69. package/vendor/agent/blender/sheet.py +743 -0
  70. package/vendor/agent/depth.mjs +134 -0
  71. package/vendor/agent/director/board.mjs +451 -0
  72. package/vendor/agent/director/contracts.mjs +663 -0
  73. package/vendor/agent/director/director.mjs +2365 -0
  74. package/vendor/agent/director/estimate.mjs +200 -0
  75. package/vendor/agent/director/gate.mjs +802 -0
  76. package/vendor/agent/director/limits.json +16 -0
  77. package/vendor/agent/director/methods.mjs +457 -0
  78. package/vendor/agent/director/policy.json +33 -0
  79. package/vendor/agent/director/prompts.mjs +244 -0
  80. package/vendor/agent/director/reading.mjs +341 -0
  81. package/vendor/agent/director/router.mjs +184 -0
  82. package/vendor/agent/director/seams.mjs +243 -0
  83. package/vendor/agent/director/session.mjs +643 -0
  84. package/vendor/agent/director/store.mjs +119 -0
  85. package/vendor/agent/director/taskGate.mjs +110 -0
  86. package/vendor/agent/director/teamLedger.mjs +118 -0
  87. package/vendor/agent/director/triage.mjs +63 -0
  88. package/vendor/agent/downloads.cjs +363 -0
  89. package/vendor/agent/flow.mjs +78 -0
  90. package/vendor/agent/guard.mjs +613 -0
  91. package/vendor/agent/host.mjs +1736 -0
  92. package/vendor/agent/language.mjs +58 -0
  93. package/vendor/agent/ledger.mjs +360 -0
  94. package/vendor/agent/locale.cjs +186 -0
  95. package/vendor/agent/loop/capacity.mjs +74 -0
  96. package/vendor/agent/loop/compose.mjs +127 -0
  97. package/vendor/agent/loop/gate.mjs +205 -0
  98. package/vendor/agent/loop/judge.mjs +189 -0
  99. package/vendor/agent/loop/levels.mjs +273 -0
  100. package/vendor/agent/loop/state.mjs +358 -0
  101. package/vendor/agent/notes.cjs +278 -0
  102. package/vendor/agent/pace.mjs +258 -0
  103. package/vendor/agent/panels.mjs +431 -0
  104. package/vendor/agent/prompt.mjs +342 -0
  105. package/vendor/agent/reference/board.mjs +410 -0
  106. package/vendor/agent/reference/compose.mjs +364 -0
  107. package/vendor/agent/reference/decode.mjs +56 -0
  108. package/vendor/agent/reference/facts.mjs +1874 -0
  109. package/vendor/agent/reference/png.mjs +107 -0
  110. package/vendor/agent/reference/records.mjs +63 -0
  111. package/vendor/agent/reference/web.mjs +252 -0
  112. package/vendor/agent/roles/artist.mjs +69 -0
  113. package/vendor/agent/roles/builder.mjs +79 -0
  114. package/vendor/agent/roles/checks.mjs +223 -0
  115. package/vendor/agent/roles/common.mjs +188 -0
  116. package/vendor/agent/roles/critic.mjs +171 -0
  117. package/vendor/agent/roles/index.mjs +39 -0
  118. package/vendor/agent/roles/modeller.mjs +142 -0
  119. package/vendor/agent/roles/qa.mjs +58 -0
  120. package/vendor/agent/roles/rubrics.mjs +79 -0
  121. package/vendor/agent/roles/sound.mjs +69 -0
  122. package/vendor/agent/rounds.cjs +333 -0
  123. package/vendor/agent/shared.mjs +284 -0
  124. package/vendor/agent/stopGate.mjs +574 -0
  125. package/vendor/agent/subagents.mjs +129 -0
  126. package/vendor/agent/tools/assets.mjs +499 -0
  127. package/vendor/agent/tools/blender.mjs +754 -0
  128. package/vendor/agent/tools/cards.mjs +479 -0
  129. package/vendor/agent/tools/choices.mjs +479 -0
  130. package/vendor/agent/tools/compose.mjs +74 -0
  131. package/vendor/agent/tools/environment.mjs +488 -0
  132. package/vendor/agent/tools/eyes.mjs +733 -0
  133. package/vendor/agent/tools/generate.mjs +338 -0
  134. package/vendor/agent/tools/guide.mjs +46 -0
  135. package/vendor/agent/tools/harness.mjs +193 -0
  136. package/vendor/agent/tools/image.mjs +643 -0
  137. package/vendor/agent/tools/index.mjs +162 -0
  138. package/vendor/agent/tools/look.mjs +578 -0
  139. package/vendor/agent/tools/loop.mjs +858 -0
  140. package/vendor/agent/tools/others.mjs +123 -0
  141. package/vendor/agent/tools/pictures.mjs +535 -0
  142. package/vendor/agent/tools/reference.mjs +366 -0
  143. package/vendor/agent/transcripts.mjs +118 -0
  144. package/vendor/agent-loop.mjs +602 -0
  145. package/vendor/agent-plugin/.claude-plugin/plugin.json +5 -0
  146. package/vendor/agent-plugin/skills/art-direction/SKILL.md +82 -0
  147. package/vendor/agent-plugin/skills/asset-legality/SKILL.md +101 -0
  148. package/vendor/agent-plugin/skills/asset-sources/SKILL.md +111 -0
  149. package/vendor/agent-plugin/skills/blender-modeling/SKILL.md +97 -0
  150. package/vendor/agent-plugin/skills/look-dev/SKILL.md +104 -0
  151. package/vendor/agent-plugin/skills/playtesting/SKILL.md +74 -0
  152. package/vendor/agent-plugin/skills/reference-loop/SKILL.md +102 -0
  153. package/vendor/agent-plugin/skills/sound-design/SKILL.md +60 -0
  154. package/vendor/agent-plugin/skills/style/SKILL.md +35 -0
  155. package/vendor/agent-plugin/skills/tsl-r185/SKILL.md +107 -0
  156. package/vendor/auth.cjs +570 -0
  157. package/vendor/build.cjs +953 -0
  158. package/vendor/catalog.json +455 -0
  159. package/vendor/connectors.cjs +688 -0
  160. package/vendor/eyes.mjs +733 -0
  161. package/vendor/gameExports.json +1390 -0
  162. package/vendor/git.cjs +222 -0
  163. package/vendor/models.json +57 -0
  164. package/vendor/publish.cjs +1018 -0
  165. package/vendor/refBoard.cjs +301 -0
  166. package/vendor/schema/dist/assets.d.ts +335 -0
  167. package/vendor/schema/dist/assets.js +439 -0
  168. package/vendor/schema/dist/brief.d.ts +357 -0
  169. package/vendor/schema/dist/brief.js +302 -0
  170. package/vendor/schema/dist/common.d.ts +9 -0
  171. package/vendor/schema/dist/common.js +13 -0
  172. package/vendor/schema/dist/config.d.ts +406 -0
  173. package/vendor/schema/dist/config.js +355 -0
  174. package/vendor/schema/dist/contract.d.ts +599 -0
  175. package/vendor/schema/dist/contract.js +1146 -0
  176. package/vendor/schema/dist/index.d.ts +14 -0
  177. package/vendor/schema/dist/index.js +21 -0
  178. package/vendor/schema/dist/look.d.ts +463 -0
  179. package/vendor/schema/dist/look.js +681 -0
  180. package/vendor/schema/dist/lookStats.d.ts +230 -0
  181. package/vendor/schema/dist/lookStats.js +768 -0
  182. package/vendor/schema/dist/pilot.d.ts +32 -0
  183. package/vendor/schema/dist/pilot.js +44 -0
  184. package/vendor/schema/dist/publish.d.ts +214 -0
  185. package/vendor/schema/dist/publish.js +291 -0
  186. package/vendor/schema/dist/scene.d.ts +75 -0
  187. package/vendor/schema/dist/scene.js +120 -0
  188. package/vendor/schema/dist/skyLight.d.ts +141 -0
  189. package/vendor/schema/dist/skyLight.js +436 -0
  190. package/vendor/schema/dist/style.d.ts +131 -0
  191. package/vendor/schema/dist/style.js +155 -0
  192. package/vendor/schema/package.json +1 -0
  193. package/vendor/selectionPrompt.mjs +51 -0
  194. package/vendor/useTools.mjs +195 -0
  195. package/vendor/userMessage.mjs +26 -0
  196. package/web-dist/assets/GaussianSplatUtils-CB77cP9U.js +1 -0
  197. package/web-dist/assets/KTX2Loader-6OIWUF7s.js +2 -0
  198. package/web-dist/assets/SPZLoader-zYj0Alfv.js +1 -0
  199. package/web-dist/assets/gaussianSplat-CJTI1sEh.js +1 -0
  200. package/web-dist/assets/index-CcjyyQco.css +1 -0
  201. package/web-dist/assets/index-DMyJcoZJ.js +693 -0
  202. package/web-dist/assets/meshopt_decoder.module-BvwdjiD3.js +1 -0
  203. package/web-dist/assets/zstddec.module-CfFeQW7d.js +1 -0
  204. package/web-dist/index.html +34 -0
@@ -0,0 +1,162 @@
1
+ // The registry of the studio's own tools (the "nw" tools). Each stream's
2
+ // module exports TOOLS, a list of ToolDefs (name, description, zod shape,
3
+ // handler, flags), and RPC_METHODS, the main-process calls its handlers make.
4
+ // From the same defs this file makes the Agent SDK's tools for Claude and the
5
+ // plain JSON Schema specs the other vendors' loop sends, and both loops run a
6
+ // call through runDef, so errors and verification work the same for every
7
+ // model.
8
+ //
9
+ // A module that is not there yet is skipped, so a tree where one stream has
10
+ // landed and another has not still runs; any other import error is thrown,
11
+ // so a syntax error never silently drops tools.
12
+
13
+ import { tool } from '@anthropic-ai/claude-agent-sdk'
14
+ import { z } from 'zod'
15
+
16
+ /**
17
+ * @typedef {{ data: string, mime: 'image/png' | 'image/jpeg' }} ToolImage base64, no data: prefix
18
+ * @typedef {{ text: string, images?: ToolImage[], isError?: boolean, verifies?: 'view' | 'check' | null }} ToolResult
19
+ * verifies: what this call verified, when it is not the def's; null for nothing.
20
+ * @typedef {object} ToolDef
21
+ * @property {string} name
22
+ * @property {string} description
23
+ * @property {Record<string, import('zod').ZodType>} shape
24
+ * @property {(args: object, ctx: object) => Promise<ToolResult>} handler
25
+ * @property {boolean} [readOnly]
26
+ * @property {'view' | 'check'} [verifies]
27
+ * @property {boolean} [mainOnly]
28
+ */
29
+
30
+ /** In this order: names must be unique across them. */
31
+ export const TOOL_MODULES = ['./harness.mjs', './eyes.mjs', './cards.mjs', './choices.mjs', './loop.mjs', './blender.mjs', './look.mjs', './assets.mjs', './generate.mjs', './environment.mjs', './image.mjs', './reference.mjs', './compose.mjs', './others.mjs', './pictures.mjs']
32
+
33
+ /** Each module with what it exports, or null when it is not there yet. */
34
+ export async function loadToolModules({ log } = {}) {
35
+ const out = []
36
+ for (const rel of TOOL_MODULES) {
37
+ const url = new URL(rel, import.meta.url)
38
+ try {
39
+ out.push({ file: rel, module: await import(url.href) })
40
+ } catch (err) {
41
+ // Only the module itself missing; a missing import inside it is a real error.
42
+ if (err?.code === 'ERR_MODULE_NOT_FOUND' && err.url === url.href) {
43
+ log?.(`[agent] tools: ${rel} is not there yet; its tools are left out`)
44
+ out.push({ file: rel, module: null })
45
+ continue
46
+ }
47
+ throw err
48
+ }
49
+ }
50
+ return out
51
+ }
52
+
53
+ /** Every ToolDef, in module order. Throws on a duplicate name. */
54
+ export async function loadTools(options) {
55
+ const defs = []
56
+ const seen = new Set()
57
+ for (const { file, module } of await loadToolModules(options)) {
58
+ for (const def of module?.TOOLS ?? []) {
59
+ if (seen.has(def.name)) throw new Error(`Two tools are named ${def.name} (the second in ${file}).`)
60
+ seen.add(def.name)
61
+ defs.push(def)
62
+ }
63
+ }
64
+ return defs
65
+ }
66
+
67
+ /** A ToolResult as MCP content. */
68
+ export function toContent(result) {
69
+ return {
70
+ content: [
71
+ { type: 'text', text: result.text ?? '' },
72
+ ...(result.images ?? []).map((i) => ({ type: 'image', data: i.data, mimeType: i.mime })),
73
+ ],
74
+ ...(result.isError ? { isError: true } : {}),
75
+ }
76
+ }
77
+
78
+ /** The tools whose writes under .nowhere/ the mood board shows: the
79
+ * kickoff and the round (loop.json), the targets (drawn into
80
+ * .nowhere/targets/, copied onto the board), the pictures card (the board's
81
+ * copies) and image_generate (drawn targets, generated pictures). */
82
+ const MOOD_WRITERS = new Set(['nw_ask_kickoff', 'nw_ask_targets', 'nw_round', 'nw_ask_pictures', 'image_generate'])
83
+
84
+ /**
85
+ * Runs one call: the arguments through the def's schema (the other vendors
86
+ * send them unchecked, and without the defaults), the handler with anything
87
+ * it throws turned into an error result, then the Stop gate's record of a
88
+ * look or a passing check.
89
+ */
90
+ export async function runDef(def, args, ctx) {
91
+ let result
92
+ const parsed = z.object(def.shape).safeParse(args ?? {})
93
+ if (!parsed.success) {
94
+ const problems = parsed.error.issues.map((i) => `${i.path.join('.') || 'input'}: ${i.message}`).join('; ')
95
+ return { text: `The input for ${def.name} is not valid: ${problems}`, isError: true }
96
+ }
97
+ try {
98
+ result = await def.handler(parsed.data, ctx)
99
+ } catch (err) {
100
+ result = { text: err?.message ?? String(err), isError: true }
101
+ }
102
+ if (!result || typeof result !== 'object') result = { text: String(result ?? 'Done.') }
103
+ if (typeof result.text !== 'string') result = { ...result, text: String(result.text ?? '') }
104
+ // A frame-time reading a tool carries (nw_status and nw_check's perf) is
105
+ // what the reference loop's stop gate and approval card read.
106
+ if (result.perf && typeof result.perf === 'object') {
107
+ try {
108
+ ctx?.run?.notePerf?.(result.perf)
109
+ } catch {
110
+ // the reading is a convenience; the tool's answer stands
111
+ }
112
+ }
113
+ // A tool that writes what the mood board shows where the project's
114
+ // watcher does not look (.nowhere/: loop.json, the drawn targets, the
115
+ // reference board's copies) tells main, which tells an open board.
116
+ if (MOOD_WRITERS.has(def.name)) {
117
+ try {
118
+ ctx?.post?.({ type: 'mood-changed' })
119
+ } catch {
120
+ // the board reads it again when it next opens
121
+ }
122
+ }
123
+ const kind = result.verifies === undefined ? def.verifies : result.verifies
124
+ if (!result.isError && kind) {
125
+ try {
126
+ await ctx?.run?.record?.(kind)
127
+ } catch {
128
+ // the record is a convenience; the tool's answer stands
129
+ }
130
+ }
131
+ return result
132
+ }
133
+
134
+ /** The SDK tool for a def. `ctxFor()` gives the running request's ctx. */
135
+ export function toSdkTool(def, ctxFor) {
136
+ return tool(def.name, def.description, def.shape, async (args) => toContent(await runDef(def, args, ctxFor())), {
137
+ annotations: def.readOnly ? { readOnlyHint: true } : undefined,
138
+ })
139
+ }
140
+
141
+ /** A JSON Schema in the subset every vendor takes: no additionalProperties
142
+ * at any depth (zod puts it on every object, and Gemini's function
143
+ * declarations have refused it), and exclusiveMinimum and exclusiveMaximum
144
+ * as plain bounds. */
145
+ function plainSchema(node) {
146
+ if (Array.isArray(node)) return node.map(plainSchema)
147
+ if (!node || typeof node !== 'object') return node
148
+ const out = {}
149
+ for (const [key, value] of Object.entries(node)) {
150
+ if (key === '$schema' || key === 'additionalProperties' || key === 'exclusiveMinimum' || key === 'exclusiveMaximum') continue
151
+ out[key] = plainSchema(value)
152
+ }
153
+ // runDef's parse still holds a call to the exact bound.
154
+ if (typeof node.exclusiveMinimum === 'number') out.minimum = Math.max(node.exclusiveMinimum, out.minimum ?? -Infinity)
155
+ if (typeof node.exclusiveMaximum === 'number') out.maximum = Math.min(node.exclusiveMaximum, out.maximum ?? Infinity)
156
+ return out
157
+ }
158
+
159
+ /** The provider-neutral spec the other vendors' loop sends. */
160
+ export function toVendorSpec(def) {
161
+ return { name: def.name, description: def.description, parameters: plainSchema(z.toJSONSchema(z.object(def.shape))) }
162
+ }