@shardworks/fabricator-apparatus 0.1.109

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.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Sean Boots
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The Fabricator — guild engine design registry apparatus.
3
+ *
4
+ * Scans installed engine designs from kit contributions and apparatus supportKits,
5
+ * and serves them to the Walker on demand.
6
+ *
7
+ * The Fabricator does not execute engines. It is a pure query service:
8
+ * designs in, designs out.
9
+ */
10
+ import type { Plugin } from '@shardworks/nexus-core';
11
+ /** Minimal execution context passed to an engine's run() method. */
12
+ export interface EngineRunContext {
13
+ /** Simple string identity for this engine instance (e.g. 'draft', 'implement'). */
14
+ engineId: string;
15
+ /** All upstream yields, keyed by engine id. Escape hatch for engines that need to inspect the full upstream chain. */
16
+ upstream: Record<string, unknown>;
17
+ }
18
+ /**
19
+ * The result of an engine run.
20
+ *
21
+ * 'completed' — synchronous work done inline, yields are available immediately.
22
+ * 'launched' — async work launched in a session; the Walker polls for completion.
23
+ */
24
+ export type EngineRunResult = {
25
+ status: 'completed';
26
+ yields: unknown;
27
+ } | {
28
+ status: 'launched';
29
+ sessionId: string;
30
+ };
31
+ /**
32
+ * An engine design — the unit of work the Fabricator catalogues and the
33
+ * Walker executes. Kit authors import this type from @shardworks/fabricator-apparatus.
34
+ */
35
+ export interface EngineDesign {
36
+ /** Unique identifier for this engine design (e.g. 'draft', 'implement', 'review'). */
37
+ id: string;
38
+ /**
39
+ * Execute this engine.
40
+ *
41
+ * @param givens — the engine's declared inputs, assembled by the Walker.
42
+ * @param context — minimal execution context: engine id and upstream yields.
43
+ */
44
+ run(givens: Record<string, unknown>, context: EngineRunContext): Promise<EngineRunResult>;
45
+ }
46
+ /** The Fabricator's public API, exposed via `provides`. */
47
+ export interface FabricatorApi {
48
+ /**
49
+ * Look up an engine design by ID.
50
+ * Returns the design if registered, undefined otherwise.
51
+ */
52
+ getEngineDesign(id: string): EngineDesign | undefined;
53
+ }
54
+ /**
55
+ * Create the Fabricator apparatus plugin.
56
+ *
57
+ * Returns a Plugin with:
58
+ * - `consumes: ['engines']` — scans kit/supportKit contributions
59
+ * - `provides: FabricatorApi` — the engine design registry API
60
+ */
61
+ export declare function createFabricator(): Plugin;
62
+ //# sourceMappingURL=fabricator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabricator.d.ts","sourceRoot":"","sources":["../src/fabricator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAIV,MAAM,EACP,MAAM,wBAAwB,CAAC;AAShC,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,sHAAsH;IACtH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;OAKG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC3F;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;CACvD;AAmDD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAoCzC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The Fabricator — guild engine design registry apparatus.
3
+ *
4
+ * Scans installed engine designs from kit contributions and apparatus supportKits,
5
+ * and serves them to the Walker on demand.
6
+ *
7
+ * The Fabricator does not execute engines. It is a pure query service:
8
+ * designs in, designs out.
9
+ */
10
+ import { guild, isLoadedKit, isLoadedApparatus, } from '@shardworks/nexus-core';
11
+ // ── Type guard ────────────────────────────────────────────────────────
12
+ /** Narrow an unknown value to EngineDesign. */
13
+ function isEngineDesign(value) {
14
+ return (typeof value === 'object' &&
15
+ value !== null &&
16
+ typeof value.id === 'string' &&
17
+ typeof value.run === 'function');
18
+ }
19
+ // ── Implementation ────────────────────────────────────────────────────
20
+ /** The engine design registry — populated at startup, queried at runtime. */
21
+ class EngineRegistry {
22
+ designs = new Map();
23
+ /** Register all engine designs from a loaded plugin. */
24
+ register(plugin) {
25
+ if (isLoadedKit(plugin)) {
26
+ this.registerFromKit(plugin.kit);
27
+ }
28
+ else if (isLoadedApparatus(plugin)) {
29
+ if (plugin.apparatus.supportKit) {
30
+ this.registerFromKit(plugin.apparatus.supportKit);
31
+ }
32
+ }
33
+ }
34
+ /** Extract and register engine designs from a kit (or supportKit) contribution. */
35
+ registerFromKit(kit) {
36
+ const rawEngines = kit.engines;
37
+ if (typeof rawEngines !== 'object' || rawEngines === null)
38
+ return;
39
+ for (const value of Object.values(rawEngines)) {
40
+ if (isEngineDesign(value)) {
41
+ this.designs.set(value.id, value);
42
+ }
43
+ }
44
+ }
45
+ /** Look up an engine design by ID. */
46
+ get(id) {
47
+ return this.designs.get(id);
48
+ }
49
+ }
50
+ // ── Apparatus factory ─────────────────────────────────────────────────
51
+ /**
52
+ * Create the Fabricator apparatus plugin.
53
+ *
54
+ * Returns a Plugin with:
55
+ * - `consumes: ['engines']` — scans kit/supportKit contributions
56
+ * - `provides: FabricatorApi` — the engine design registry API
57
+ */
58
+ export function createFabricator() {
59
+ const registry = new EngineRegistry();
60
+ const api = {
61
+ getEngineDesign(id) {
62
+ return registry.get(id);
63
+ },
64
+ };
65
+ return {
66
+ apparatus: {
67
+ requires: [],
68
+ consumes: ['engines'],
69
+ provides: api,
70
+ start(ctx) {
71
+ const g = guild();
72
+ // Scan all already-loaded kits. These fired plugin:initialized before
73
+ // any apparatus started, so we can't catch them via events.
74
+ for (const kit of g.kits()) {
75
+ registry.register(kit);
76
+ }
77
+ // Subscribe to plugin:initialized for apparatus supportKits that
78
+ // fire after us in the startup sequence.
79
+ ctx.on('plugin:initialized', (plugin) => {
80
+ const loaded = plugin;
81
+ // Skip kits — we already scanned them above.
82
+ if (isLoadedApparatus(loaded)) {
83
+ registry.register(loaded);
84
+ }
85
+ });
86
+ },
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=fabricator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabricator.js","sourceRoot":"","sources":["../src/fabricator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EACL,KAAK,EACL,WAAW,EACX,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAgDhC,yEAAyE;AAEzE,+CAA+C;AAC/C,SAAS,cAAc,CAA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AU,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAEtC,MAAM,GAAG,GAAkB;QACzB,eAAe,CAAC,EAAU;YACxB,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;IAEF,OAAO;QACL,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,CAAC,SAAS,CAAC;YACrB,QAAQ,EAAE,GAAG;YAEb,KAAK,CAAC,GAAmB;gBACvB,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;gBAElB,sEAAsE;gBACtE,4DAA4D;gBAC5D,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC3B,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACzB,CAAC;gBAED,iEAAiE;gBACjE,yCAAyC;gBACzC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAe,EAAE,EAAE;oBAC/C,MAAM,MAAM,GAAG,MAAsB,CAAC;oBACtC,6CAA6C;oBAC7C,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;wBAC9B,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBAC5B,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @shardworks/fabricator-apparatus — The Fabricator.
3
+ *
4
+ * Guild engine design registry: scans kit contributions, stores engine designs
5
+ * by ID, and provides the FabricatorApi for design lookup.
6
+ *
7
+ * The EngineDesign, EngineRunContext, and EngineRunResult types live here
8
+ * canonically — kit authors import from this package to contribute engines.
9
+ */
10
+ export type { EngineDesign, EngineRunContext, EngineRunResult, } from './fabricator.ts';
11
+ export type { FabricatorApi } from './fabricator.ts';
12
+ declare const _default: import("@shardworks/nexus-core").Plugin;
13
+ export default _default;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAIzB,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;;AAIrD,wBAAkC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @shardworks/fabricator-apparatus — The Fabricator.
3
+ *
4
+ * Guild engine design registry: scans kit contributions, stores engine designs
5
+ * by ID, and provides the FabricatorApi for design lookup.
6
+ *
7
+ * The EngineDesign, EngineRunContext, and EngineRunResult types live here
8
+ * canonically — kit authors import from this package to contribute engines.
9
+ */
10
+ import { createFabricator } from "./fabricator.js";
11
+ // ── Default export: the apparatus plugin ──────────────────────────────
12
+ export default createFabricator();
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAcnD,yEAAyE;AAEzE,eAAe,gBAAgB,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@shardworks/fabricator-apparatus",
3
+ "version": "0.1.109",
4
+ "license": "ISC",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/shardworks/nexus",
8
+ "directory": "packages/plugins/fabricator"
9
+ },
10
+ "description": "The Fabricator — guild engine design registry apparatus",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "dependencies": {
19
+ "@shardworks/nexus-core": "0.1.109"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "25.5.0"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "test": "node --disable-warning=ExperimentalWarning --experimental-transform-types --test 'src/**/*.test.ts'",
30
+ "typecheck": "tsc --noEmit"
31
+ }
32
+ }