@forgeax/engine-dsh 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 (47) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +78 -0
  3. package/cordis.patch.yml +5 -0
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/__tests__/dsh-activity-http.test.d.ts +30 -0
  6. package/dist/__tests__/dsh-activity-http.test.d.ts.map +1 -0
  7. package/dist/__tests__/dsh-host.test.d.ts +16 -0
  8. package/dist/__tests__/dsh-host.test.d.ts.map +1 -0
  9. package/dist/__tests__/engine-host.test.d.ts +2 -0
  10. package/dist/__tests__/engine-host.test.d.ts.map +1 -0
  11. package/dist/__tests__/engine-preview.test.d.ts +2 -0
  12. package/dist/__tests__/engine-preview.test.d.ts.map +1 -0
  13. package/dist/__tests__/intelligence.test.d.ts +2 -0
  14. package/dist/__tests__/intelligence.test.d.ts.map +1 -0
  15. package/dist/__tests__/launch-binding-owner.test-d.d.ts +2 -0
  16. package/dist/__tests__/launch-binding-owner.test-d.d.ts.map +1 -0
  17. package/dist/__tests__/protocol.test.d.ts +2 -0
  18. package/dist/__tests__/protocol.test.d.ts.map +1 -0
  19. package/dist/client.d.ts +12 -0
  20. package/dist/client.d.ts.map +1 -0
  21. package/dist/embedded.d.ts +2 -0
  22. package/dist/embedded.d.ts.map +1 -0
  23. package/dist/embedded.mjs +250 -0
  24. package/dist/embedded.mjs.map +1 -0
  25. package/dist/engine-host.d.ts +43 -0
  26. package/dist/engine-host.d.ts.map +1 -0
  27. package/dist/engine-host.mjs +384 -0
  28. package/dist/engine-host.mjs.map +1 -0
  29. package/dist/engine-preview.d.ts +12 -0
  30. package/dist/engine-preview.d.ts.map +1 -0
  31. package/dist/engine-preview.mjs +70 -0
  32. package/dist/engine-preview.mjs.map +1 -0
  33. package/dist/index.d.ts +26 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.mjs +187 -0
  36. package/dist/index.mjs.map +1 -0
  37. package/dist/intelligence.d.ts +5 -0
  38. package/dist/intelligence.d.ts.map +1 -0
  39. package/dist/intelligence.mjs +60 -0
  40. package/dist/intelligence.mjs.map +1 -0
  41. package/dist/protocol.d.ts +60 -0
  42. package/dist/protocol.d.ts.map +1 -0
  43. package/dist/protocol.mjs +36 -0
  44. package/dist/protocol.mjs.map +1 -0
  45. package/lib/client.js +295 -0
  46. package/lib/client.js.map +1 -0
  47. package/package.json +103 -0
@@ -0,0 +1,250 @@
1
+ import { createServer } from 'http';
2
+ import { Context } from '@forgeax/engine-plugin';
3
+ import { randomUUID } from 'crypto';
4
+ import { World, createWorldContext, Update } from '@forgeax/engine-ecs';
5
+
6
+ // src/embedded.ts
7
+
8
+ // src/protocol.ts
9
+ var FEDERATION_PROTOCOL_VERSION = 1;
10
+ var FEDERATION_ROUTE_PREFIX = "/forgeax-federation/v1";
11
+
12
+ // src/index.ts
13
+ var MAX_ACTIVITY_BODY_BYTES = 65536;
14
+ var inject = ["webServer"];
15
+ async function apply(ctx, config = {}) {
16
+ const identity = config.identity ?? `dsh-${randomUUID()}`;
17
+ const leases = /* @__PURE__ */ new Set();
18
+ let tick = 0;
19
+ let state = 0;
20
+ let embeddedContext;
21
+ let timer;
22
+ const disposers = [];
23
+ let disposed = false;
24
+ ctx.effect(
25
+ () => async () => {
26
+ if (disposed) return;
27
+ disposed = true;
28
+ for (const dispose of disposers.reverse()) dispose();
29
+ leases.clear();
30
+ if (timer !== void 0) clearInterval(timer);
31
+ await embeddedContext?.fiber.dispose();
32
+ },
33
+ "forgeax-federation: routes and embedded engine"
34
+ );
35
+ if (config.engineEndpoint === void 0) {
36
+ const world = new World();
37
+ embeddedContext = await createWorldContext(world);
38
+ world.addSystem(Update, {
39
+ name: "forgeax-federation-headless-tick",
40
+ queries: [],
41
+ fn: () => {
42
+ tick += 1;
43
+ }
44
+ }).unwrap();
45
+ timer = setInterval(() => {
46
+ const result = world.update(1 / 30);
47
+ if (!result.ok) ctx.logger.warn(result.error);
48
+ }, 1e3 / 30);
49
+ }
50
+ const status = () => ({
51
+ protocol: FEDERATION_PROTOCOL_VERSION,
52
+ identity,
53
+ ready: true,
54
+ realm: "dsh",
55
+ capabilities: ["lease", "community-probe", "engine-projection"],
56
+ leases: leases.size,
57
+ engine: config.engineEndpoint === void 0 ? { binding: "embedded", ready: true, frameId: tick, tick, state } : { binding: "external", endpoint: config.engineEndpoint, ready: true }
58
+ });
59
+ disposers.push(
60
+ ctx.webServer.register({
61
+ kind: "exact",
62
+ path: `${FEDERATION_ROUTE_PREFIX}/status`,
63
+ handler(_request, response) {
64
+ writeJson(response, 200, status());
65
+ }
66
+ }),
67
+ ctx.webServer.register({
68
+ kind: "exact",
69
+ path: `${FEDERATION_ROUTE_PREFIX}/activity`,
70
+ async handler(request, response) {
71
+ if (request.method !== "POST") {
72
+ writeJson(response, 405, { code: "federation-method-not-allowed" });
73
+ return;
74
+ }
75
+ const candidate = ctx.get("forgeaxIntelligenceCapability");
76
+ if (candidate === void 0 || typeof candidate.run !== "function") {
77
+ writeJson(response, 404, { code: "federation-intelligence-capability-missing" });
78
+ return;
79
+ }
80
+ const parsed = await readJsonBody(request);
81
+ if (!parsed.ok) {
82
+ writeJson(response, parsed.status, parsed.body);
83
+ return;
84
+ }
85
+ const body = parsed.value;
86
+ if (typeof body !== "object" || body === null || typeof Reflect.get(body, "input") !== "string" || typeof Reflect.get(body, "sessionId") !== "string") {
87
+ writeJson(response, 400, { code: "federation-activity-invalid" });
88
+ return;
89
+ }
90
+ writeJson(
91
+ response,
92
+ 200,
93
+ await candidate.run(Reflect.get(body, "input"), Reflect.get(body, "sessionId"))
94
+ );
95
+ }
96
+ }),
97
+ ctx.webServer.register({
98
+ kind: "exact",
99
+ path: `${FEDERATION_ROUTE_PREFIX}/lease`,
100
+ handler(request, response) {
101
+ if (request.method === "POST") {
102
+ const leaseId = randomUUID();
103
+ leases.add(leaseId);
104
+ writeJson(response, 201, { leaseId });
105
+ return;
106
+ }
107
+ if (request.method === "DELETE") {
108
+ const leaseId = new URL(request.url ?? "/", "http://localhost").searchParams.get(
109
+ "leaseId"
110
+ );
111
+ if (leaseId !== null) leases.delete(leaseId);
112
+ writeJson(response, 200, { released: leaseId !== null });
113
+ return;
114
+ }
115
+ writeJson(response, 405, { code: "federation-method-not-allowed" });
116
+ }
117
+ }),
118
+ ctx.webServer.register({
119
+ kind: "exact",
120
+ path: `${FEDERATION_ROUTE_PREFIX}/community`,
121
+ async handler(_request, response) {
122
+ const candidate = ctx.get("forgeaxFederationCapability");
123
+ if (candidate === void 0 || typeof candidate.inspect !== "function") {
124
+ writeJson(response, 404, { code: "federation-community-capability-missing" });
125
+ return;
126
+ }
127
+ let community;
128
+ try {
129
+ community = await candidate.inspect();
130
+ } catch {
131
+ writeJson(response, 503, { code: "federation-community-capability-failed" });
132
+ return;
133
+ }
134
+ writeJson(response, 200, community);
135
+ }
136
+ }),
137
+ ctx.webServer.register({
138
+ kind: "exact",
139
+ path: `${FEDERATION_ROUTE_PREFIX}/engine/control`,
140
+ handler(request, response) {
141
+ if (request.method !== "POST" || config.engineEndpoint !== void 0) {
142
+ writeJson(response, 409, { code: "federation-engine-control-unavailable" });
143
+ return;
144
+ }
145
+ state = state === 0 ? 1 : 0;
146
+ writeJson(response, 200, status().engine);
147
+ }
148
+ })
149
+ );
150
+ }
151
+ async function readJsonBody(request) {
152
+ const chunks = [];
153
+ let size = 0;
154
+ let tooLarge = false;
155
+ for await (const chunk of request) {
156
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
157
+ if (tooLarge) continue;
158
+ size += buffer.byteLength;
159
+ if (size > MAX_ACTIVITY_BODY_BYTES) {
160
+ tooLarge = true;
161
+ chunks.length = 0;
162
+ continue;
163
+ }
164
+ chunks.push(buffer);
165
+ }
166
+ if (tooLarge) {
167
+ return {
168
+ ok: false,
169
+ status: 413,
170
+ body: { code: "federation-activity-body-too-large", limit: MAX_ACTIVITY_BODY_BYTES }
171
+ };
172
+ }
173
+ try {
174
+ return { ok: true, value: JSON.parse(Buffer.concat(chunks).toString("utf8")) };
175
+ } catch {
176
+ return { ok: false, status: 400, body: { code: "federation-activity-invalid" } };
177
+ }
178
+ }
179
+ function writeJson(response, status, value) {
180
+ response.writeHead(status, {
181
+ "cache-control": "no-store",
182
+ "content-type": "application/json; charset=utf-8"
183
+ });
184
+ response.end(JSON.stringify(value));
185
+ }
186
+
187
+ // src/embedded.ts
188
+ var EmbeddedWebServer = class {
189
+ routes = /* @__PURE__ */ new Set();
190
+ register(route) {
191
+ this.routes.add(route);
192
+ return () => this.routes.delete(route);
193
+ }
194
+ match(pathname) {
195
+ return [...this.routes].find(
196
+ (route) => route.kind === "exact" ? pathname === route.path : pathname === route.path || pathname.startsWith(`${route.path}/`)
197
+ );
198
+ }
199
+ };
200
+ var routes = new EmbeddedWebServer();
201
+ var server = createServer((request, response) => {
202
+ const pathname = new URL(request.url ?? "/", "http://localhost").pathname;
203
+ const route = routes.match(pathname);
204
+ if (route === void 0) {
205
+ response.writeHead(404);
206
+ response.end();
207
+ return;
208
+ }
209
+ Promise.resolve(route.handler(request, response)).catch(() => {
210
+ if (!response.headersSent) response.writeHead(500);
211
+ response.end();
212
+ });
213
+ });
214
+ await new Promise((resolve, reject) => {
215
+ server.once("error", reject);
216
+ server.listen(0, "127.0.0.1", () => resolve());
217
+ });
218
+ var context = new Context();
219
+ var carrier = {
220
+ name: "embedded-webserver",
221
+ provide: "webServer",
222
+ apply(ctx) {
223
+ const provide = ctx.provide;
224
+ provide.call(ctx, "webServer", routes);
225
+ }
226
+ };
227
+ await context.plugin(carrier);
228
+ await context.plugin({
229
+ name: "forgeax-federation",
230
+ inject,
231
+ apply
232
+ });
233
+ var address = server.address();
234
+ process.stdout.write(`forgeax embedded: http://127.0.0.1:${address.port}
235
+ `);
236
+ var closing = false;
237
+ var close = async () => {
238
+ if (closing) return;
239
+ closing = true;
240
+ await context.fiber.dispose();
241
+ await new Promise((resolve) => server.close(() => resolve()));
242
+ };
243
+ process.once("SIGTERM", () => {
244
+ void close().then(() => process.exit(0));
245
+ });
246
+ process.once("SIGINT", () => {
247
+ void close().then(() => process.exit(0));
248
+ });
249
+ //# sourceMappingURL=embedded.mjs.map
250
+ //# sourceMappingURL=embedded.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/protocol.ts","../src/index.ts","../src/embedded.ts"],"names":[],"mappings":";;;;;;;;AAAO,IAAM,2BAAA,GAA8B,CAAA;AACpC,IAAM,uBAAA,GAA0B,wBAAA;;;ACyCvC,IAAM,uBAAA,GAA0B,KAAA;AAuBzB,IAAM,MAAA,GAAS,CAAC,WAAW,CAAA;AAGlC,eAAsB,KAAA,CAAM,GAAA,EAAqB,MAAA,GAAiB,EAAC,EAAkB;AACnF,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,IAAY,CAAA,IAAA,EAAO,YAAY,CAAA,CAAA;AACvD,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAY;AAC/B,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,EAAA,IAAI,eAAA;AACJ,EAAA,IAAI,KAAA;AACJ,EAAA,MAAM,YAA+B,EAAC;AACtC,EAAA,IAAI,QAAA,GAAW,KAAA;AAEf,EAAA,GAAA,CAAI,MAAA;AAAA,IACF,MAAM,YAAY;AAChB,MAAA,IAAI,QAAA,EAAU;AACd,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,KAAA,MAAW,OAAA,IAAW,SAAA,CAAU,OAAA,EAAQ,EAAG,OAAA,EAAQ;AACnD,MAAA,MAAA,CAAO,KAAA,EAAM;AACb,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,aAAA,CAAc,KAAK,CAAA;AAC5C,MAAA,MAAM,eAAA,EAAiB,MAAM,OAAA,EAAQ;AAAA,IACvC,CAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,MAAA,CAAO,mBAAmB,MAAA,EAA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IAAA,CAAK,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA;AACD,OAAA,CAAQ,IAAA,CAAK,UAAU,MAAM;AAC3B,EAAA,KAAK,OAAM,CAAE,IAAA,CAAK,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA","file":"embedded.mjs","sourcesContent":["export const FEDERATION_PROTOCOL_VERSION = 1 as const;\nexport const FEDERATION_ROUTE_PREFIX = '/forgeax-federation/v1' as const;\n\nexport type FederationBinding = 'attach' | 'external' | 'embedded';\nexport type FederationOwnership = 'lease' | 'instance';\n\nexport interface FederationStatus {\n readonly protocol: typeof FEDERATION_PROTOCOL_VERSION;\n readonly identity: string;\n readonly ready: true;\n readonly realm: 'dsh';\n readonly capabilities: readonly string[];\n readonly leases: number;\n readonly engine: EngineProjection;\n}\n\nexport type EngineProjection = EngineEndpointProjection | EmbeddedEngineProjection;\n\nexport interface EngineEndpointProjection {\n readonly binding: 'external';\n readonly endpoint: string;\n readonly ready: true;\n}\n\nexport interface EmbeddedEngineProjection {\n readonly binding: 'embedded';\n readonly ready: true;\n readonly frameId: number;\n readonly tick: number;\n readonly state: number;\n}\n\nexport interface FederationLease {\n readonly leaseId: string;\n}\n\nexport interface FederationCommunityCapability {\n readonly id: string;\n readonly value: string;\n}\n\nexport interface FederationActivityResult {\n readonly output: string;\n}\n\nexport function isFederationCommunityCapability(\n value: unknown,\n): value is FederationCommunityCapability {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n return typeof record.id === 'string' && typeof record.value === 'string';\n}\n\nexport interface EnginePreviewStatus {\n readonly protocol: typeof FEDERATION_PROTOCOL_VERSION;\n readonly kind: 'forgeax-engine-status';\n readonly binding: 'external';\n readonly ready: true;\n readonly frameId: number;\n readonly tick: number;\n readonly state: number;\n}\n\nexport interface EnginePreviewPoll {\n readonly protocol: typeof FEDERATION_PROTOCOL_VERSION;\n readonly kind: 'forgeax-engine-poll';\n}\n\nexport interface EnginePreviewControl {\n readonly protocol: typeof FEDERATION_PROTOCOL_VERSION;\n readonly kind: 'forgeax-engine-control';\n readonly action: 'toggle';\n}\n\nexport type EnginePreviewRequest = EnginePreviewPoll | EnginePreviewControl;\n\nexport function isEnginePreviewRequest(value: unknown): value is EnginePreviewRequest {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n if (record.protocol !== FEDERATION_PROTOCOL_VERSION) return false;\n if (record.kind === 'forgeax-engine-poll') return true;\n return record.kind === 'forgeax-engine-control' && record.action === 'toggle';\n}\n\nexport function isEnginePreviewStatus(value: unknown): value is EnginePreviewStatus {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n return (\n record.protocol === FEDERATION_PROTOCOL_VERSION &&\n record.kind === 'forgeax-engine-status' &&\n record.binding === 'external' &&\n record.ready === true &&\n typeof record.frameId === 'number' &&\n typeof record.tick === 'number' &&\n typeof record.state === 'number'\n );\n}\n\nexport function isFederationStatus(value: unknown): value is FederationStatus {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n return (\n record.protocol === FEDERATION_PROTOCOL_VERSION &&\n record.realm === 'dsh' &&\n record.ready === true &&\n typeof record.identity === 'string' &&\n Array.isArray(record.capabilities) &&\n record.capabilities.every((capability) => typeof capability === 'string') &&\n Number.isInteger(record.leases) &&\n (record.leases as number) >= 0 &&\n isEngineProjection(record.engine)\n );\n}\n\nfunction isEngineProjection(value: unknown): value is EngineProjection {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Record<string, unknown>;\n if (record.ready !== true) return false;\n if (record.binding === 'external') return typeof record.endpoint === 'string';\n return (\n record.binding === 'embedded' &&\n typeof record.frameId === 'number' &&\n typeof record.tick === 'number' &&\n typeof record.state === 'number'\n );\n}\n","import { randomUUID } from 'node:crypto';\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport { createWorldContext, Update, World } from '@forgeax/engine-ecs';\nimport type { Context } from '@forgeax/engine-plugin';\n\nimport {\n FEDERATION_PROTOCOL_VERSION,\n FEDERATION_ROUTE_PREFIX,\n type FederationActivityResult,\n type FederationCommunityCapability,\n type FederationStatus,\n} from './protocol';\n\ninterface WebRoute {\n readonly kind: 'exact' | 'prefix';\n readonly path: string;\n readonly handler: (request: IncomingMessage, response: ServerResponse) => void | Promise<void>;\n}\n\ninterface WebServerService {\n register(route: WebRoute): () => void;\n}\n\ninterface DshHostContext {\n readonly webServer: WebServerService;\n readonly logger: { warn(error: unknown): void };\n effect(callback: () => void | (() => void | Promise<void>), label?: string): void;\n get(name: string): unknown;\n}\n\ninterface CommunityProbeService {\n inspect(): FederationCommunityCapability | Promise<FederationCommunityCapability>;\n}\n\ninterface IntelligenceCapabilityService {\n run(\n input: string,\n sessionId: string,\n ): FederationActivityResult | Promise<FederationActivityResult>;\n}\n\nconst MAX_ACTIVITY_BODY_BYTES = 65_536 as const;\n\ntype ActivityBodyResult =\n | { readonly ok: true; readonly value: unknown }\n | {\n readonly ok: false;\n readonly status: 400;\n readonly body: { readonly code: 'federation-activity-invalid' };\n }\n | {\n readonly ok: false;\n readonly status: 413;\n readonly body: {\n readonly code: 'federation-activity-body-too-large';\n readonly limit: typeof MAX_ACTIVITY_BODY_BYTES;\n };\n };\n\nexport interface Config {\n readonly engineEndpoint?: string;\n readonly identity?: string;\n}\n\nexport const inject = ['webServer'];\n\n/** DSH-native Host half. DSH's Loader mounts this ordinary plugin from the package patch. */\nexport async function apply(ctx: DshHostContext, config: Config = {}): Promise<void> {\n const identity = config.identity ?? `dsh-${randomUUID()}`;\n const leases = new Set<string>();\n let tick = 0;\n let state = 0;\n let embeddedContext: Context | undefined;\n let timer: ReturnType<typeof setInterval> | undefined;\n const disposers: Array<() => void> = [];\n let disposed = false;\n\n ctx.effect(\n () => async () => {\n if (disposed) return;\n disposed = true;\n for (const dispose of disposers.reverse()) dispose();\n leases.clear();\n if (timer !== undefined) clearInterval(timer);\n await embeddedContext?.fiber.dispose();\n },\n 'forgeax-federation: routes and embedded engine',\n );\n\n if (config.engineEndpoint === undefined) {\n const world = new World();\n embeddedContext = await createWorldContext(world);\n world\n .addSystem(Update, {\n name: 'forgeax-federation-headless-tick',\n queries: [],\n fn: () => {\n tick += 1;\n },\n })\n .unwrap();\n timer = setInterval(() => {\n const result = world.update(1 / 30);\n if (!result.ok) ctx.logger.warn(result.error);\n }, 1000 / 30);\n }\n\n const status = (): FederationStatus => ({\n protocol: FEDERATION_PROTOCOL_VERSION,\n identity,\n ready: true,\n realm: 'dsh',\n capabilities: ['lease', 'community-probe', 'engine-projection'],\n leases: leases.size,\n engine:\n config.engineEndpoint === undefined\n ? { binding: 'embedded', ready: true, frameId: tick, tick, state }\n : { binding: 'external', endpoint: config.engineEndpoint, ready: true },\n });\n\n disposers.push(\n ctx.webServer.register({\n kind: 'exact',\n path: `${FEDERATION_ROUTE_PREFIX}/status`,\n handler(_request, response) {\n writeJson(response, 200, status());\n },\n }),\n ctx.webServer.register({\n kind: 'exact',\n path: `${FEDERATION_ROUTE_PREFIX}/activity`,\n async handler(request, response) {\n if (request.method !== 'POST') {\n writeJson(response, 405, { code: 'federation-method-not-allowed' });\n return;\n }\n const candidate = ctx.get('forgeaxIntelligenceCapability') as\n | IntelligenceCapabilityService\n | undefined;\n if (candidate === undefined || typeof candidate.run !== 'function') {\n writeJson(response, 404, { code: 'federation-intelligence-capability-missing' });\n return;\n }\n const parsed = await readJsonBody(request);\n if (!parsed.ok) {\n writeJson(response, parsed.status, parsed.body);\n return;\n }\n const body = parsed.value;\n if (\n typeof body !== 'object' ||\n body === null ||\n typeof Reflect.get(body, 'input') !== 'string' ||\n typeof Reflect.get(body, 'sessionId') !== 'string'\n ) {\n writeJson(response, 400, { code: 'federation-activity-invalid' });\n return;\n }\n writeJson(\n response,\n 200,\n await candidate.run(Reflect.get(body, 'input'), Reflect.get(body, 'sessionId')),\n );\n },\n }),\n ctx.webServer.register({\n kind: 'exact',\n path: `${FEDERATION_ROUTE_PREFIX}/lease`,\n handler(request, response) {\n if (request.method === 'POST') {\n const leaseId = randomUUID();\n leases.add(leaseId);\n writeJson(response, 201, { leaseId });\n return;\n }\n if (request.method === 'DELETE') {\n const leaseId = new URL(request.url ?? '/', 'http://localhost').searchParams.get(\n 'leaseId',\n );\n if (leaseId !== null) leases.delete(leaseId);\n writeJson(response, 200, { released: leaseId !== null });\n return;\n }\n writeJson(response, 405, { code: 'federation-method-not-allowed' });\n },\n }),\n ctx.webServer.register({\n kind: 'exact',\n path: `${FEDERATION_ROUTE_PREFIX}/community`,\n async handler(_request, response) {\n const candidate = ctx.get('forgeaxFederationCapability') as\n | CommunityProbeService\n | undefined;\n if (candidate === undefined || typeof candidate.inspect !== 'function') {\n writeJson(response, 404, { code: 'federation-community-capability-missing' });\n return;\n }\n let community: FederationCommunityCapability;\n try {\n community = await candidate.inspect();\n } catch {\n writeJson(response, 503, { code: 'federation-community-capability-failed' });\n return;\n }\n writeJson(response, 200, community);\n },\n }),\n ctx.webServer.register({\n kind: 'exact',\n path: `${FEDERATION_ROUTE_PREFIX}/engine/control`,\n handler(request, response) {\n if (request.method !== 'POST' || config.engineEndpoint !== undefined) {\n writeJson(response, 409, { code: 'federation-engine-control-unavailable' });\n return;\n }\n state = state === 0 ? 1 : 0;\n writeJson(response, 200, status().engine);\n },\n }),\n );\n}\n\nasync function readJsonBody(request: IncomingMessage): Promise<ActivityBodyResult> {\n const chunks: Buffer[] = [];\n let size = 0;\n let tooLarge = false;\n for await (const chunk of request) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);\n if (tooLarge) continue;\n size += buffer.byteLength;\n if (size > MAX_ACTIVITY_BODY_BYTES) {\n tooLarge = true;\n chunks.length = 0;\n continue;\n }\n chunks.push(buffer);\n }\n if (tooLarge) {\n return {\n ok: false,\n status: 413,\n body: { code: 'federation-activity-body-too-large', limit: MAX_ACTIVITY_BODY_BYTES },\n };\n }\n try {\n return { ok: true, value: JSON.parse(Buffer.concat(chunks).toString('utf8')) as unknown };\n } catch {\n return { ok: false, status: 400, body: { code: 'federation-activity-invalid' } };\n }\n}\n\nfunction writeJson(response: ServerResponse, status: number, value: unknown): void {\n response.writeHead(status, {\n 'cache-control': 'no-store',\n 'content-type': 'application/json; charset=utf-8',\n });\n response.end(JSON.stringify(value));\n}\n","import { createServer, type IncomingMessage, type ServerResponse } from 'node:http';\nimport type { AddressInfo } from 'node:net';\n\nimport { Context, type Plugin } from '@forgeax/engine-plugin';\n\nimport { apply as federationApply, inject as federationInject } from './index';\n\ninterface Route {\n readonly kind: 'exact' | 'prefix';\n readonly path: string;\n readonly handler: (request: IncomingMessage, response: ServerResponse) => void | Promise<void>;\n}\n\nclass EmbeddedWebServer {\n private readonly routes = new Set<Route>();\n\n register(route: Route): () => void {\n this.routes.add(route);\n return () => this.routes.delete(route);\n }\n\n match(pathname: string): Route | undefined {\n return [...this.routes].find((route) =>\n route.kind === 'exact'\n ? pathname === route.path\n : pathname === route.path || pathname.startsWith(`${route.path}/`),\n );\n }\n}\n\nconst routes = new EmbeddedWebServer();\nconst server = createServer((request, response) => {\n const pathname = new URL(request.url ?? '/', 'http://localhost').pathname;\n const route = routes.match(pathname);\n if (route === undefined) {\n response.writeHead(404);\n response.end();\n return;\n }\n Promise.resolve(route.handler(request, response)).catch(() => {\n if (!response.headersSent) response.writeHead(500);\n response.end();\n });\n});\n\nawait new Promise<void>((resolve, reject) => {\n server.once('error', reject);\n server.listen(0, '127.0.0.1', () => resolve());\n});\n\nconst context = new Context();\nconst carrier: Plugin = {\n name: 'embedded-webserver',\n provide: 'webServer',\n apply(ctx) {\n const provide = ctx.provide as unknown as (name: string, value: unknown) => void;\n provide.call(ctx, 'webServer', routes);\n },\n};\nawait context.plugin(carrier);\nawait context.plugin({\n name: 'forgeax-federation',\n inject: federationInject,\n apply: federationApply as unknown as Plugin['apply'],\n});\n\nconst address = server.address() as AddressInfo;\nprocess.stdout.write(`forgeax embedded: http://127.0.0.1:${address.port}\\n`);\n\nlet closing = false;\nconst close = async (): Promise<void> => {\n if (closing) return;\n closing = true;\n await context.fiber.dispose();\n await new Promise<void>((resolve) => server.close(() => resolve()));\n};\n\nprocess.once('SIGTERM', () => {\n void close().then(() => process.exit(0));\n});\nprocess.once('SIGINT', () => {\n void close().then(() => process.exit(0));\n});\n"]}
@@ -0,0 +1,43 @@
1
+ import type { Plugin } from '@forgeax/engine-plugin';
2
+ import { type Result } from '@forgeax/engine-types';
3
+ import { type FederationActivityResult, type FederationBinding, type FederationCommunityCapability, type FederationOwnership, type FederationStatus } from './protocol';
4
+ declare module '@forgeax/engine-plugin' {
5
+ interface EngineContextServices {
6
+ dshRealm: DshRealmConnection;
7
+ }
8
+ }
9
+ export type DshRealmErrorCode = 'dsh-target-unavailable' | 'dsh-target-incompatible' | 'dsh-launch-failed' | 'dsh-handshake-timeout' | 'dsh-lease-failed' | 'dsh-community-failed';
10
+ export declare class DshRealmError extends Error {
11
+ readonly code: DshRealmErrorCode;
12
+ readonly expected: string;
13
+ readonly hint: string;
14
+ readonly detail: Readonly<Record<string, unknown>>;
15
+ constructor(code: DshRealmErrorCode, expected: string, hint: string, detail: Readonly<Record<string, unknown>>, cause?: unknown);
16
+ }
17
+ export interface DshRealmPluginOptions {
18
+ /** Attach to an already-running compatible DSH realm. Never closes that realm. */
19
+ readonly endpoint?: string;
20
+ /** Explicit DSH executable. Omit to discover `dsh` on PATH. */
21
+ readonly executable?: string;
22
+ readonly profile?: string;
23
+ readonly home?: string;
24
+ readonly cwd?: string;
25
+ readonly handshakeTimeoutMs?: number;
26
+ readonly allowEmbedded?: boolean;
27
+ }
28
+ export interface DshRealmConnection {
29
+ readonly endpoint: string;
30
+ readonly binding: FederationBinding;
31
+ readonly ownership: FederationOwnership;
32
+ readonly status: FederationStatus;
33
+ community(): Promise<FederationCommunityCapability>;
34
+ activity(input: string, sessionId: string, signal?: AbortSignal): Promise<FederationActivityResult>;
35
+ }
36
+ export interface ConnectedRealm {
37
+ readonly connection: DshRealmConnection;
38
+ dispose(): Promise<void>;
39
+ }
40
+ /** Engine-side Realm Host Plugin. It publishes no service until handshake and lease acquisition succeed. */
41
+ export declare function dshRealmPlugin(options?: DshRealmPluginOptions): Plugin;
42
+ export declare function connectDshRealm(options?: DshRealmPluginOptions): Promise<Result<ConnectedRealm, DshRealmError>>;
43
+ //# sourceMappingURL=engine-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-host.d.ts","sourceRoot":"","sources":["../src/engine-host.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAElC,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,YAAY,CAAC;AAEpB,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAU,qBAAqB;QAC7B,QAAQ,EAAE,kBAAkB,CAAC;KAC9B;CACF;AAED,MAAM,MAAM,iBAAiB,GACzB,wBAAwB,GACxB,yBAAyB,GACzB,mBAAmB,GACnB,uBAAuB,GACvB,kBAAkB,GAClB,sBAAsB,CAAC;AAE3B,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAGjD,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,KAAK,CAAC,EAAE,OAAO;CASlB;AAED,MA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