@forgeax/engine-remote 0.1.2

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 (66) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +269 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__tests__/asset-runtime-inspection.unit.test.d.ts +2 -0
  5. package/dist/__tests__/asset-runtime-inspection.unit.test.d.ts.map +1 -0
  6. package/dist/__tests__/console.unit.test.d.ts +2 -0
  7. package/dist/__tests__/console.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/errors.unit.test.d.ts +2 -0
  9. package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
  10. package/dist/__tests__/execute-browser-safe.unit.test.d.ts +2 -0
  11. package/dist/__tests__/execute-browser-safe.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/execute-profiler-root.browser.test.d.ts +2 -0
  13. package/dist/__tests__/execute-profiler-root.browser.test.d.ts.map +1 -0
  14. package/dist/__tests__/execute.async.test.d.ts +2 -0
  15. package/dist/__tests__/execute.async.test.d.ts.map +1 -0
  16. package/dist/__tests__/execution-report-root.unit.test.d.ts +2 -0
  17. package/dist/__tests__/execution-report-root.unit.test.d.ts.map +1 -0
  18. package/dist/__tests__/introspect-profiler.unit.test.d.ts +2 -0
  19. package/dist/__tests__/introspect-profiler.unit.test.d.ts.map +1 -0
  20. package/dist/__tests__/method-roster-profiler.test.d.ts +2 -0
  21. package/dist/__tests__/method-roster-profiler.test.d.ts.map +1 -0
  22. package/dist/__tests__/rhi-capture-remote.integration.test.d.ts +2 -0
  23. package/dist/__tests__/rhi-capture-remote.integration.test.d.ts.map +1 -0
  24. package/dist/__tests__/server.unit.test.d.ts +2 -0
  25. package/dist/__tests__/server.unit.test.d.ts.map +1 -0
  26. package/dist/error-messages.d.ts +3 -0
  27. package/dist/error-messages.d.ts.map +1 -0
  28. package/dist/errors.d.ts +82 -0
  29. package/dist/errors.d.ts.map +1 -0
  30. package/dist/errors.mjs +37 -0
  31. package/dist/errors.mjs.map +1 -0
  32. package/dist/execute.d.ts +31 -0
  33. package/dist/execute.d.ts.map +1 -0
  34. package/dist/execute.mjs +93 -0
  35. package/dist/execute.mjs.map +1 -0
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.mjs +30 -0
  39. package/dist/index.mjs.map +1 -0
  40. package/dist/introspect.d.ts +21 -0
  41. package/dist/introspect.d.ts.map +1 -0
  42. package/dist/introspect.mjs +173 -0
  43. package/dist/introspect.mjs.map +1 -0
  44. package/dist/server.d.ts +35 -0
  45. package/dist/server.d.ts.map +1 -0
  46. package/dist/server.mjs +473 -0
  47. package/dist/server.mjs.map +1 -0
  48. package/package.json +78 -0
  49. package/src/__tests__/asset-runtime-inspection.unit.test.ts +16 -0
  50. package/src/__tests__/console.unit.test.ts +12 -0
  51. package/src/__tests__/errors.unit.test.ts +102 -0
  52. package/src/__tests__/execute-browser-safe.unit.test.ts +43 -0
  53. package/src/__tests__/execute-profiler-root.browser.test.ts +41 -0
  54. package/src/__tests__/execute.async.test.ts +369 -0
  55. package/src/__tests__/execution-report-root.unit.test.ts +38 -0
  56. package/src/__tests__/introspect-profiler.unit.test.ts +55 -0
  57. package/src/__tests__/method-roster-profiler.test.ts +80 -0
  58. package/src/__tests__/rhi-capture-remote.integration.test.ts +58 -0
  59. package/src/__tests__/server.unit.test.ts +856 -0
  60. package/src/__tests__/vm-async-eval-verify.mjs +149 -0
  61. package/src/error-messages.ts +9 -0
  62. package/src/errors.ts +143 -0
  63. package/src/execute.ts +152 -0
  64. package/src/index.ts +19 -0
  65. package/src/introspect.ts +223 -0
  66. package/src/server.ts +331 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ // src/errors.ts
2
+ var RemoteError = class extends Error {
3
+ code;
4
+ expected;
5
+ hint;
6
+ detail;
7
+ constructor(args) {
8
+ super(`[RemoteError ${args.code}] expected: ${args.expected}; hint: ${args.hint}`);
9
+ this.name = "RemoteError";
10
+ this.code = args.code;
11
+ this.expected = args.expected;
12
+ this.hint = args.hint;
13
+ if (args.detail !== void 0) {
14
+ this.detail = args.detail;
15
+ }
16
+ }
17
+ toJSON() {
18
+ const json = {
19
+ code: this.code,
20
+ expected: this.expected,
21
+ hint: this.hint,
22
+ message: this.message
23
+ };
24
+ return this.detail === void 0 ? json : { ...json, detail: this.detail };
25
+ }
26
+ };
27
+
28
+ export { RemoteError };
29
+ //# sourceMappingURL=index.mjs.map
30
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AAsFO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAkC;AAAA,EACxD,IAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EAET,YAAY,IAAA,EAKT;AACD,IAAA,KAAA,CAAM,CAAA,aAAA,EAAgB,KAAK,IAAI,CAAA,YAAA,EAAe,KAAK,QAAQ,CAAA,QAAA,EAAW,IAAA,CAAK,IAAI,CAAA,CAAE,CAAA;AACjF,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,WAAW,IAAA,CAAK,QAAA;AACrB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAI,IAAA,CAAK,WAAW,MAAA,EAAW;AAC7B,MAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,MAAA,GAME;AACA,IAAA,MAAM,IAAA,GAAO;AAAA,MACX,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,UAAU,IAAA,CAAK,QAAA;AAAA,MACf,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,SAAS,IAAA,CAAK;AAAA,KAChB;AACA,IAAA,OAAO,IAAA,CAAK,WAAW,MAAA,GAAY,IAAA,GAAO,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAO;AAAA,EAC3E;AACF","file":"index.mjs","sourcesContent":["// @forgeax/engine-remote/src/errors - RemoteError runtime class + re-export of\n// the closed `RemoteErrorCode` union; 5 members (feat-20260629-inspector-two-layer-model D-5).\n//\n// SSOT split: the **type alias** `RemoteErrorCode`\n// + **structural interface** `RemoteError` live in `@forgeax/engine-types`\n// (parallel to the existing `ShaderErrorCode` placement). This file owns\n// the **runtime class** (`extends Error` + `toJSON()`) only; the class\n// `implements` the type-side interface so the two sides cannot drift\n// (architecture-principles #1 SSOT).\n//\n// Shape (mirrors @forgeax/engine-rhi/src/errors.ts RhiError 4-field surface for\n// charter proposition 5 consistent abstraction):\n// - `RemoteErrorCode` = closed union 5 members (re-exported from types).\n// tsc strict-mode guards exhaustive switch completeness (charter\n// proposition 4); AI users consume via `switch (err.code) { case '...': ... }`\n// with NO default branch.\n// - `RemoteError` class extends Error with three readonly fields .code /\n// .expected / .hint (AGENTS.md \"Errors are structured\"). The constructor\n// auto-composes a human-readable .message (`[RemoteError <code>]\n// expected: <expected>; hint: <hint>`). The class implements the\n// `RemoteError` interface from `@forgeax/engine-types` so callers may\n// alternately type against the structural shape.\n// - `toJSON()` opts into JSON.stringify serialisation so the JSON-RPC 2.0\n// `error.data` payload carries .code / .expected / .hint / .message\n// verbatim through the WebSocket transport.\n\nimport type {\n RemoteErrorCode,\n RemoteErrorDetail,\n RemoteError as RemoteErrorShape,\n} from '@forgeax/engine-types';\n\n// Re-export the type-side alias verbatim so existing\n// `import { type RemoteErrorCode } from '@forgeax/engine-remote'` call sites\n// keep working (charter proposition 1 progressive disclosure — single\n// entry point for AI users).\nexport type { RemoteErrorCode };\n\n/**\n * Structured remote error. Four core fields plus bounded detail, mirroring `@forgeax/engine-rhi`\n * `RhiError` (charter proposition 5 consistent abstraction; AGENTS.md\n * \"Errors are structured\"). The class `implements RemoteErrorShape`\n * (the structural interface re-exported from `@forgeax/engine-types`) so the type\n * SSOT and the runtime class cannot drift.\n *\n * - `.code` closed union member (L1 key signal; switch-able).\n * - `.expected` expected-state description (L2 detail; ai-user-charter\n * proposition 4 requires expected-state copy).\n * - `.hint` actionable recovery guidance (L2 detail; charter\n * proposition 3 machine-readable hint > prose).\n * - `.message` auto-composed `[RemoteError <code>] expected: <expected>;\n * hint: <hint>` so human stack traces still surface the\n * triple. AI users prefer property access (charter\n * proposition 4: no string parsing).\n *\n * Per-code `.expected` + `.hint` templates (requirements §10.2 SSOT):\n *\n * | code | `.expected` | `.hint` |\n * |:--|:--|:--|\n * | `'script-syntax-error'` | `'script body is valid JavaScript'` | `'check syntax position in errMessage; fix and resubmit'` |\n * | `'script-runtime-error'` | `'script executes without throwing'` | `'inspect error; verify symbol availability; eval has full access to world/renderer/assets'` |\n * | `'server-startup-failed'` | `'server starts successfully on requested port'` | `'check if port is already in use (default 5732); pass different port; or kill existing process holding the port'` |\n * | `'server-not-running'` | `'server is reachable at ws://localhost:<port>'` | `'start the demo first; verify app.remote is wired; pass --port to override default 5732'` |\n * | `'eval-result-not-serializable'` | `'eval result is JSON-serializable'` | `'return a JSON-safe value; BigInt and cyclic objects are unsupported over JSON-RPC'` |\n *\n * JSON-RPC 2.0 transport contract: `toJSON()` returns the structured plain\n * object carried verbatim via `error.data` on the WebSocket envelope. The\n * JSON-RPC server-error `.code` numeric segment -32001 ~ -32005 maps 1:1\n * to the 5 members\n * at the dispatch layer.\n *\n * @example AI-user exhaustive switch on the 5 remote-domain alternatives (no default fallback)\n * ```ts\n * import { RemoteError, type RemoteErrorCode } from '@forgeax/engine-remote';\n *\n * function recover(code: RemoteErrorCode): string {\n * switch (code) {\n * case 'script-syntax-error': return 'fix script body syntax and resubmit';\n * case 'script-runtime-error': return 'inspect stack trace; verify symbol availability';\n * case 'server-startup-failed': return 'pick a different port or free port 5732';\n * case 'server-not-running': return 'start demo dev or wire app.remote';\n * case 'eval-result-not-serializable': return 'return a JSON-safe eval result';\n * }\n * }\n * ```\n */\nexport class RemoteError extends Error implements RemoteErrorShape {\n readonly code: RemoteErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: RemoteErrorDetail;\n\n constructor(args: {\n code: RemoteErrorCode;\n expected: string;\n hint: string;\n detail?: RemoteErrorDetail;\n }) {\n super(`[RemoteError ${args.code}] expected: ${args.expected}; hint: ${args.hint}`);\n this.name = 'RemoteError';\n this.code = args.code;\n this.expected = args.expected;\n this.hint = args.hint;\n if (args.detail !== undefined) {\n this.detail = args.detail;\n }\n }\n\n toJSON(): {\n readonly code: RemoteErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly message: string;\n readonly detail?: RemoteErrorDetail;\n } {\n const json = {\n code: this.code,\n expected: this.expected,\n hint: this.hint,\n message: this.message,\n };\n return this.detail === undefined ? json : { ...json, detail: this.detail };\n }\n}\n\n/**\n * SSOT mapping `RemoteErrorCode` -> JSON-RPC `error.code` numeric segment\n * (feat-20260629-inspector-two-layer-model D-5). The 5 remote P0\n * members occupy the closed segment `-32001..-32005`.\n *\n * `server.ts` consumes this map at the JSON-RPC envelope edge so the wire\n * always carries the lock-in numeric and a future drift in either direction\n * raises a TypeScript completeness error (the `Record<RemoteErrorCode,\n * number>` type guard requires every closed-union member to have a\n * numeric).\n */\nexport const REMOTE_ERROR_CODE_TO_JSONRPC: Readonly<Record<RemoteErrorCode, number>> = {\n 'script-syntax-error': -32001,\n 'script-runtime-error': -32002,\n 'server-startup-failed': -32003,\n 'server-not-running': -32004,\n 'eval-result-not-serializable': -32005,\n};\n"]}
@@ -0,0 +1,21 @@
1
+ export interface ComponentIntrospectionDescriptor {
2
+ readonly name: string;
3
+ readonly schema: Readonly<Record<string, string>>;
4
+ readonly fields: Readonly<Record<string, unknown>>;
5
+ readonly meta: Readonly<Record<string, unknown>>;
6
+ }
7
+ export interface RemoteRootValues {
8
+ readonly world: unknown;
9
+ readonly renderer: unknown;
10
+ readonly assets: unknown;
11
+ readonly rhiCapture?: unknown;
12
+ readonly profiler?: unknown;
13
+ readonly execution?: unknown;
14
+ readonly introspection?: readonly ComponentIntrospectionDescriptor[];
15
+ }
16
+ export declare function isProfilerRoot(value: unknown): boolean;
17
+ export declare function isExecutionRoot(value: unknown): value is {
18
+ report(): unknown;
19
+ };
20
+ export declare function buildIntrospectDoc(host: string, port: number, roots: RemoteRootValues): unknown;
21
+ //# sourceMappingURL=introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,gCAAgC,EAAE,CAAC;CACtE;AAiBD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CActD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,MAAM,IAAI,OAAO,CAAA;CAAE,CAM9E;AA8GD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAuD/F"}
@@ -0,0 +1,173 @@
1
+ // src/error-messages.ts
2
+ var REMOTE_ERROR_MESSAGES = {
3
+ "script-syntax-error": "Script syntax error",
4
+ "script-runtime-error": "Script runtime error",
5
+ "server-startup-failed": "Server startup failed",
6
+ "server-not-running": "Server not reachable",
7
+ "eval-result-not-serializable": "Eval result not serializable"
8
+ };
9
+
10
+ // src/errors.ts
11
+ var REMOTE_ERROR_CODE_TO_JSONRPC = {
12
+ "script-syntax-error": -32001,
13
+ "script-runtime-error": -32002,
14
+ "server-startup-failed": -32003,
15
+ "server-not-running": -32004,
16
+ "eval-result-not-serializable": -32005
17
+ };
18
+
19
+ // src/introspect.ts
20
+ function isProfilerRoot(value) {
21
+ if (value === null || typeof value !== "object") return false;
22
+ const root = value;
23
+ return typeof root.startCapture === "function" && typeof root.latestCapture === "function" && typeof root.activeSession === "function" && root.phaseCatalog !== void 0;
24
+ }
25
+ function isExecutionRoot(value) {
26
+ return value !== null && typeof value === "object" && typeof value.report === "function";
27
+ }
28
+ function profilerPhaseCatalog(value) {
29
+ if (value === null || typeof value !== "object") return void 0;
30
+ const catalog = value.phaseCatalog;
31
+ return catalog === void 0 ? void 0 : catalog;
32
+ }
33
+ function projectRoot(name, value) {
34
+ const descriptions = {
35
+ world: { type: "World", description: "The host World instance." },
36
+ renderer: { type: "Renderer", description: "The host Renderer instance." },
37
+ assets: { type: "AssetRegistry", description: "The host AssetRegistry instance." },
38
+ rhiCapture: {
39
+ type: "RhiCapture",
40
+ description: "The opt-in RHI frame capture capability."
41
+ },
42
+ profiler: {
43
+ type: "Profiler",
44
+ description: "The opt-in CPU profiler for bounded App and Render capture."
45
+ },
46
+ execution: {
47
+ type: "ExecutionReportProvider",
48
+ description: "The host execution report provider for tier, health, performance, and fault."
49
+ }
50
+ };
51
+ const descriptor = descriptions[name] ?? { type: "unknown", description: "A live eval root." };
52
+ return {
53
+ available: true,
54
+ ...descriptor,
55
+ ...name === "assets" ? {
56
+ operations: {
57
+ load: "assets.load(guid, expectedKind)",
58
+ snapshot: "assets.snapshot()",
59
+ subscribe: "assets.subscribe(listener)"
60
+ }
61
+ } : {},
62
+ ...name === "profiler" ? {
63
+ capability: "cpu-profile-v1",
64
+ operations: {
65
+ startCapture: "profiler.startCapture({ frameLimit, eventLimit })",
66
+ latestCapture: "profiler.latestCapture() after the host reaches the frame boundary"
67
+ },
68
+ ...profilerPhaseCatalog(value) === void 0 ? {} : { phaseCatalog: profilerPhaseCatalog(value) }
69
+ } : name === "execution" ? {
70
+ capability: "execution-report-v1"
71
+ } : name === "rhiCapture" ? {
72
+ capability: "rhi-capture-v1"
73
+ } : {}
74
+ };
75
+ }
76
+ function projectRoots(roots) {
77
+ const projected = {};
78
+ for (const [name, value] of Object.entries(roots)) {
79
+ if (value !== void 0 && (name !== "profiler" || isProfilerRoot(value)) && (name !== "execution" || isExecutionRoot(value))) {
80
+ projected[name] = projectRoot(name, value);
81
+ }
82
+ }
83
+ return projected;
84
+ }
85
+ function profilerCapability(roots) {
86
+ if (roots.profiler !== void 0) {
87
+ return {
88
+ enabled: true,
89
+ capability: "cpu-profile-v1",
90
+ limits: {
91
+ frameLimit: "positive-safe-integer",
92
+ eventLimit: "positive-safe-integer"
93
+ }
94
+ };
95
+ }
96
+ return {
97
+ enabled: false,
98
+ code: "profiler-not-enabled",
99
+ expected: "an explicitly opted-in profiler root",
100
+ hint: "Pass profiler: createProfiler() to createApp or startServer in development, then retry.",
101
+ detail: { enabled: false },
102
+ limits: {
103
+ frameLimit: "positive-safe-integer",
104
+ eventLimit: "positive-safe-integer"
105
+ }
106
+ };
107
+ }
108
+ function buildErrorProjection() {
109
+ const errors = {};
110
+ for (const [code, numericCode] of Object.entries(REMOTE_ERROR_CODE_TO_JSONRPC)) {
111
+ errors[code] = { code: numericCode, message: REMOTE_ERROR_MESSAGES[code] };
112
+ }
113
+ return errors;
114
+ }
115
+ function buildIntrospectDoc(host, port, roots) {
116
+ const projectedRoots = projectRoots(roots);
117
+ const schemas = {
118
+ World: { type: "object", description: "The host World instance." },
119
+ Renderer: { type: "object", description: "The host Renderer instance." },
120
+ Assets: { type: "object", description: "The host AssetRegistry instance." }
121
+ };
122
+ for (const [name, root] of Object.entries(projectedRoots)) {
123
+ schemas[root.type] = { type: "object", description: root.description };
124
+ if (name === "profiler") {
125
+ schemas.ProfilerCapture = {
126
+ type: "object",
127
+ description: "A bounded ProfileCapture v1 artifact returned through eval."
128
+ };
129
+ }
130
+ }
131
+ for (const descriptor of roots.introspection ?? []) {
132
+ schemas[descriptor.name] = descriptor;
133
+ }
134
+ return {
135
+ openrpc: "1.3.2",
136
+ info: {
137
+ title: "@forgeax/engine-remote remote eval",
138
+ version: "0.0.0",
139
+ description: "Remote eval server. Methods: eval / introspect. Errors map to JSON-RPC -32001..-32005."
140
+ },
141
+ servers: [{ name: "in-process", url: `ws://${host}:${port}/inspector` }],
142
+ methods: [
143
+ {
144
+ name: "eval",
145
+ summary: "Evaluate a JavaScript script against live eval roots.",
146
+ params: [
147
+ {
148
+ name: "script",
149
+ required: true,
150
+ schema: { type: "string" }
151
+ }
152
+ ],
153
+ result: { name: "value", schema: { type: "object" } }
154
+ },
155
+ {
156
+ name: "introspect",
157
+ summary: "Return this OpenRPC L2 subset document.",
158
+ params: [],
159
+ result: { name: "document", schema: { type: "object" } }
160
+ }
161
+ ],
162
+ roots: projectedRoots,
163
+ capabilities: { profiler: profilerCapability(projectedRoots) },
164
+ components: {
165
+ schemas,
166
+ errors: buildErrorProjection()
167
+ }
168
+ };
169
+ }
170
+
171
+ export { buildIntrospectDoc, isExecutionRoot, isProfilerRoot };
172
+ //# sourceMappingURL=introspect.mjs.map
173
+ //# sourceMappingURL=introspect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/error-messages.ts","../src/err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A,EAAc,CAAA;AAAA,IACvE,OAAA,EAAS;AAAA,MACP;AAAA,QACE,IAAA,EAAM,MAAA;AAAA,QACN,OAAA,EAAS,uDAAA;AAAA,QACT,MAAA,EAAQ;AAAA,UACN;AAAA,YACE,IAAA,EAAM,QAAA;AAAA,YACN,QAAA,EAAU,IAAA;AAAA,YACV,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA;AAAS;AAC3B,SACF;AAAA,QACA,MAAA,EAAQ,EAAE,IAAA,EAAM,OAAA,EAAS,QAAQ,EAAE,IAAA,EAAM,UAAS;AAAE,OACtD;AAAA,MACA;AAAA,QACE,IAAA,EAAM,YAAA;AAAA,QACN,OAAA,EAAS,yCAAA;AAAA,QACT,QAAQ,EAAC;AAAA,QACT,MAAA,EAAQ,EAAE,IAAA,EAAM,UAAA,EAAY,QAAQ,EAAE,IAAA,EAAM,UAAS;AAAE;AACzD,KACF;AAAA,IACA,KAAA,EAAO,cAAA;AAAA,IACP,YAAA,EAAc,EAAE,QAAA,EAAU,kBAAA,CAAmB,cAAc,CAAA,EAAE;AAAA,IAC7D,UAAA,EAAY;AAAA,MACV,OAAA;AAAA,MACA,QAAQ,oBAAA;AAAqB;AAC/B,GACF;AACF","file":"introspect.mjs","sourcesContent":["import type { RemoteErrorCode } from './errors';\n\nexport const REMOTE_ERROR_MESSAGES: Readonly<Record<RemoteErrorCode, string>> = {\n 'script-syntax-error': 'Script syntax error',\n 'script-runtime-error': 'Script runtime error',\n 'server-startup-failed': 'Server startup failed',\n 'server-not-running': 'Server not reachable',\n 'eval-result-not-serializable': 'Eval result not serializable',\n};\n","// @forgeax/engine-remote/src/errors - RemoteError runtime class + re-export of\n// the closed `RemoteErrorCode` union; 5 members (feat-20260629-inspector-two-layer-model D-5).\n//\n// SSOT split: the **type alias** `RemoteErrorCode`\n// + **structural interface** `RemoteError` live in `@forgeax/engine-types`\n// (parallel to the existing `ShaderErrorCode` placement). This file owns\n// the **runtime class** (`extends Error` + `toJSON()`) only; the class\n// `implements` the type-side interface so the two sides cannot drift\n// (architecture-principles #1 SSOT).\n//\n// Shape (mirrors @forgeax/engine-rhi/src/errors.ts RhiError 4-field surface for\n// charter proposition 5 consistent abstraction):\n// - `RemoteErrorCode` = closed union 5 members (re-exported from types).\n// tsc strict-mode guards exhaustive switch completeness (charter\n// proposition 4); AI users consume via `switch (err.code) { case '...': ... }`\n// with NO default branch.\n// - `RemoteError` class extends Error with three readonly fields .code /\n// .expected / .hint (AGENTS.md \"Errors are structured\"). The constructor\n// auto-composes a human-readable .message (`[RemoteError <code>]\n// expected: <expected>; hint: <hint>`). The class implements the\n// `RemoteError` interface from `@forgeax/engine-types` so callers may\n// alternately type against the structural shape.\n// - `toJSON()` opts into JSON.stringify serialisation so the JSON-RPC 2.0\n// `error.data` payload carries .code / .expected / .hint / .message\n// verbatim through the WebSocket transport.\n\nimport type {\n RemoteErrorCode,\n RemoteErrorDetail,\n RemoteError as RemoteErrorShape,\n} from '@forgeax/engine-types';\n\n// Re-export the type-side alias verbatim so existing\n// `import { type RemoteErrorCode } from '@forgeax/engine-remote'` call sites\n// keep working (charter proposition 1 progressive disclosure — single\n// entry point for AI users).\nexport type { RemoteErrorCode };\n\n/**\n * Structured remote error. Four core fields plus bounded detail, mirroring `@forgeax/engine-rhi`\n * `RhiError` (charter proposition 5 consistent abstraction; AGENTS.md\n * \"Errors are structured\"). The class `implements RemoteErrorShape`\n * (the structural interface re-exported from `@forgeax/engine-types`) so the type\n * SSOT and the runtime class cannot drift.\n *\n * - `.code` closed union member (L1 key signal; switch-able).\n * - `.expected` expected-state description (L2 detail; ai-user-charter\n * proposition 4 requires expected-state copy).\n * - `.hint` actionable recovery guidance (L2 detail; charter\n * proposition 3 machine-readable hint > prose).\n * - `.message` auto-composed `[RemoteError <code>] expected: <expected>;\n * hint: <hint>` so human stack traces still surface the\n * triple. AI users prefer property access (charter\n * proposition 4: no string parsing).\n *\n * Per-code `.expected` + `.hint` templates (requirements §10.2 SSOT):\n *\n * | code | `.expected` | `.hint` |\n * |:--|:--|:--|\n * | `'script-syntax-error'` | `'script body is valid JavaScript'` | `'check syntax position in errMessage; fix and resubmit'` |\n * | `'script-runtime-error'` | `'script executes without throwing'` | `'inspect error; verify symbol availability; eval has full access to world/renderer/assets'` |\n * | `'server-startup-failed'` | `'server starts successfully on requested port'` | `'check if port is already in use (default 5732); pass different port; or kill existing process holding the port'` |\n * | `'server-not-running'` | `'server is reachable at ws://localhost:<port>'` | `'start the demo first; verify app.remote is wired; pass --port to override default 5732'` |\n * | `'eval-result-not-serializable'` | `'eval result is JSON-serializable'` | `'return a JSON-safe value; BigInt and cyclic objects are unsupported over JSON-RPC'` |\n *\n * JSON-RPC 2.0 transport contract: `toJSON()` returns the structured plain\n * object carried verbatim via `error.data` on the WebSocket envelope. The\n * JSON-RPC server-error `.code` numeric segment -32001 ~ -32005 maps 1:1\n * to the 5 members\n * at the dispatch layer.\n *\n * @example AI-user exhaustive switch on the 5 remote-domain alternatives (no default fallback)\n * ```ts\n * import { RemoteError, type RemoteErrorCode } from '@forgeax/engine-remote';\n *\n * function recover(code: RemoteErrorCode): string {\n * switch (code) {\n * case 'script-syntax-error': return 'fix script body syntax and resubmit';\n * case 'script-runtime-error': return 'inspect stack trace; verify symbol availability';\n * case 'server-startup-failed': return 'pick a different port or free port 5732';\n * case 'server-not-running': return 'start demo dev or wire app.remote';\n * case 'eval-result-not-serializable': return 'return a JSON-safe eval result';\n * }\n * }\n * ```\n */\nexport class RemoteError extends Error implements RemoteErrorShape {\n readonly code: RemoteErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail?: RemoteErrorDetail;\n\n constructor(args: {\n code: RemoteErrorCode;\n expected: string;\n hint: string;\n detail?: RemoteErrorDetail;\n }) {\n super(`[RemoteError ${args.code}] expected: ${args.expected}; hint: ${args.hint}`);\n this.name = 'RemoteError';\n this.code = args.code;\n this.expected = args.expected;\n this.hint = args.hint;\n if (args.detail !== undefined) {\n this.detail = args.detail;\n }\n }\n\n toJSON(): {\n readonly code: RemoteErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly message: string;\n readonly detail?: RemoteErrorDetail;\n } {\n const json = {\n code: this.code,\n expected: this.expected,\n hint: this.hint,\n message: this.message,\n };\n return this.detail === undefined ? json : { ...json, detail: this.detail };\n }\n}\n\n/**\n * SSOT mapping `RemoteErrorCode` -> JSON-RPC `error.code` numeric segment\n * (feat-20260629-inspector-two-layer-model D-5). The 5 remote P0\n * members occupy the closed segment `-32001..-32005`.\n *\n * `server.ts` consumes this map at the JSON-RPC envelope edge so the wire\n * always carries the lock-in numeric and a future drift in either direction\n * raises a TypeScript completeness error (the `Record<RemoteErrorCode,\n * number>` type guard requires every closed-union member to have a\n * numeric).\n */\nexport const REMOTE_ERROR_CODE_TO_JSONRPC: Readonly<Record<RemoteErrorCode, number>> = {\n 'script-syntax-error': -32001,\n 'script-runtime-error': -32002,\n 'server-startup-failed': -32003,\n 'server-not-running': -32004,\n 'eval-result-not-serializable': -32005,\n};\n","import { REMOTE_ERROR_MESSAGES } from './error-messages';\nimport { REMOTE_ERROR_CODE_TO_JSONRPC, type RemoteErrorCode } from './errors';\n\nexport interface ComponentIntrospectionDescriptor {\n readonly name: string;\n readonly schema: Readonly<Record<string, string>>;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly meta: Readonly<Record<string, unknown>>;\n}\n\nexport interface RemoteRootValues {\n readonly world: unknown;\n readonly renderer: unknown;\n readonly assets: unknown;\n readonly rhiCapture?: unknown;\n readonly profiler?: unknown;\n readonly execution?: unknown;\n readonly introspection?: readonly ComponentIntrospectionDescriptor[];\n}\n\ntype RootProjection = {\n readonly available: true;\n readonly type: string;\n readonly description: string;\n readonly capability?: string;\n readonly phaseCatalog?: unknown;\n readonly operations?: {\n readonly startCapture?: string;\n readonly latestCapture?: string;\n readonly load?: string;\n readonly snapshot?: string;\n readonly subscribe?: string;\n };\n};\n\nexport function isProfilerRoot(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const root = value as {\n startCapture?: unknown;\n latestCapture?: unknown;\n activeSession?: unknown;\n phaseCatalog?: unknown;\n };\n return (\n typeof root.startCapture === 'function' &&\n typeof root.latestCapture === 'function' &&\n typeof root.activeSession === 'function' &&\n root.phaseCatalog !== undefined\n );\n}\n\nexport function isExecutionRoot(value: unknown): value is { report(): unknown } {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as { report?: unknown }).report === 'function'\n );\n}\n\nfunction profilerPhaseCatalog(value: unknown): unknown {\n if (value === null || typeof value !== 'object') return undefined;\n const catalog = (value as { phaseCatalog?: unknown }).phaseCatalog;\n return catalog === undefined ? undefined : catalog;\n}\n\nfunction projectRoot(name: string, value: unknown): RootProjection {\n const descriptions: Record<string, { type: string; description: string }> = {\n world: { type: 'World', description: 'The host World instance.' },\n renderer: { type: 'Renderer', description: 'The host Renderer instance.' },\n assets: { type: 'AssetRegistry', description: 'The host AssetRegistry instance.' },\n rhiCapture: {\n type: 'RhiCapture',\n description: 'The opt-in RHI frame capture capability.',\n },\n profiler: {\n type: 'Profiler',\n description: 'The opt-in CPU profiler for bounded App and Render capture.',\n },\n execution: {\n type: 'ExecutionReportProvider',\n description: 'The host execution report provider for tier, health, performance, and fault.',\n },\n };\n const descriptor = descriptions[name] ?? { type: 'unknown', description: 'A live eval root.' };\n return {\n available: true,\n ...descriptor,\n ...(name === 'assets'\n ? {\n operations: {\n load: 'assets.load(guid, expectedKind)',\n snapshot: 'assets.snapshot()',\n subscribe: 'assets.subscribe(listener)',\n },\n }\n : {}),\n ...(name === 'profiler'\n ? {\n capability: 'cpu-profile-v1',\n operations: {\n startCapture: 'profiler.startCapture({ frameLimit, eventLimit })',\n latestCapture: 'profiler.latestCapture() after the host reaches the frame boundary',\n },\n ...(profilerPhaseCatalog(value) === undefined\n ? {}\n : { phaseCatalog: profilerPhaseCatalog(value) }),\n }\n : name === 'execution'\n ? {\n capability: 'execution-report-v1',\n }\n : name === 'rhiCapture'\n ? {\n capability: 'rhi-capture-v1',\n }\n : {}),\n };\n}\n\nfunction projectRoots(roots: RemoteRootValues): Record<string, RootProjection> {\n const projected: Record<string, RootProjection> = {};\n for (const [name, value] of Object.entries(roots)) {\n if (\n value !== undefined &&\n (name !== 'profiler' || isProfilerRoot(value)) &&\n (name !== 'execution' || isExecutionRoot(value))\n ) {\n projected[name] = projectRoot(name, value);\n }\n }\n return projected;\n}\n\nfunction profilerCapability(roots: Record<string, RootProjection>): Record<string, unknown> {\n if (roots.profiler !== undefined) {\n return {\n enabled: true,\n capability: 'cpu-profile-v1',\n limits: {\n frameLimit: 'positive-safe-integer',\n eventLimit: 'positive-safe-integer',\n },\n };\n }\n return {\n enabled: false,\n code: 'profiler-not-enabled',\n expected: 'an explicitly opted-in profiler root',\n hint: 'Pass profiler: createProfiler() to createApp or startServer in development, then retry.',\n detail: { enabled: false },\n limits: {\n frameLimit: 'positive-safe-integer',\n eventLimit: 'positive-safe-integer',\n },\n };\n}\n\nfunction buildErrorProjection(): Record<string, { code: number; message: string }> {\n const errors: Record<string, { code: number; message: string }> = {};\n for (const [code, numericCode] of Object.entries(REMOTE_ERROR_CODE_TO_JSONRPC) as Array<\n [RemoteErrorCode, number]\n >) {\n errors[code] = { code: numericCode, message: REMOTE_ERROR_MESSAGES[code] };\n }\n return errors;\n}\n\nexport function buildIntrospectDoc(host: string, port: number, roots: RemoteRootValues): unknown {\n const projectedRoots = projectRoots(roots);\n const schemas: Record<string, unknown> = {\n World: { type: 'object', description: 'The host World instance.' },\n Renderer: { type: 'object', description: 'The host Renderer instance.' },\n Assets: { type: 'object', description: 'The host AssetRegistry instance.' },\n };\n for (const [name, root] of Object.entries(projectedRoots)) {\n schemas[root.type] = { type: 'object', description: root.description };\n if (name === 'profiler') {\n schemas.ProfilerCapture = {\n type: 'object',\n description: 'A bounded ProfileCapture v1 artifact returned through eval.',\n };\n }\n }\n for (const descriptor of roots.introspection ?? []) {\n schemas[descriptor.name] = descriptor;\n }\n return {\n openrpc: '1.3.2',\n info: {\n title: '@forgeax/engine-remote remote eval',\n version: '0.0.0',\n description:\n 'Remote eval server. Methods: eval / introspect. Errors map to JSON-RPC -32001..-32005.',\n },\n servers: [{ name: 'in-process', url: `ws://${host}:${port}/inspector` }],\n methods: [\n {\n name: 'eval',\n summary: 'Evaluate a JavaScript script against live eval roots.',\n params: [\n {\n name: 'script',\n required: true,\n schema: { type: 'string' },\n },\n ],\n result: { name: 'value', schema: { type: 'object' } },\n },\n {\n name: 'introspect',\n summary: 'Return this OpenRPC L2 subset document.',\n params: [],\n result: { name: 'document', schema: { type: 'object' } },\n },\n ],\n roots: projectedRoots,\n capabilities: { profiler: profilerCapability(projectedRoots) },\n components: {\n schemas,\n errors: buildErrorProjection(),\n },\n };\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import { type Result } from '@forgeax/engine-types';
2
+ import { RemoteError } from './errors';
3
+ import { type ComponentIntrospectionDescriptor } from './introspect';
4
+ export type { ComponentIntrospectionDescriptor } from './introspect';
5
+ export type { Result };
6
+ export type ConsoleHandle = {
7
+ readonly port: number;
8
+ readonly close: () => Promise<void>;
9
+ };
10
+ export type StartServerOptions = {
11
+ readonly port: number;
12
+ readonly host?: string;
13
+ readonly world: unknown;
14
+ readonly renderer?: unknown;
15
+ readonly assets?: unknown;
16
+ /** JSON-safe host reflection; the remote package does not know component owners. */
17
+ readonly introspection?: readonly ComponentIntrospectionDescriptor[];
18
+ /** Explicit CPU profiler capability; omitted unless the host opts in. */
19
+ readonly profiler?: unknown;
20
+ /** Structural report provider; remote never imports the App owner. */
21
+ readonly execution?: unknown;
22
+ /** Host-owned dynamic module resolver; omitted for package-neutral eval. */
23
+ readonly importModule?: (specifier: string) => Promise<unknown>;
24
+ /**
25
+ * Host-owned RHI capture capability for eval-scope injection (plan-strategy D-4).
26
+ * It is exposed as the single `rhiCapture` eval root.
27
+ * Undefined when FORGEAX_ENGINE_RHI_DEBUG !== '1'.
28
+ */
29
+ readonly rhiCapture?: unknown;
30
+ };
31
+ /**
32
+ * Start the remote eval WebSocket server.
33
+ */
34
+ export declare function startServer(opts: StartServerOptions): Promise<Result<ConsoleHandle, RemoteError>>;
35
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAYA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAgC,WAAW,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,EAEL,KAAK,gCAAgC,EAGtC,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAIrE,YAAY,EAAE,MAAM,EAAE,CAAC;AAEvB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,gCAAgC,EAAE,CAAC;IACrE,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,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