@tensor-cad/engine 0.1.2 → 0.1.4
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/node.d.ts +15 -2
- package/node.js +13 -5
- package/package.json +1 -1
- package/tensorcad.wasm +0 -0
- package/types.d.ts +15 -0
package/node.d.ts
CHANGED
|
@@ -6,15 +6,28 @@
|
|
|
6
6
|
* singleton the way the editor does: one engine per process, loaded before the
|
|
7
7
|
* first command runs.
|
|
8
8
|
*/
|
|
9
|
-
import { type Engine } from "./index.js";
|
|
9
|
+
import { type Engine, type LoadOptions } from "./index.js";
|
|
10
10
|
import "../vendor/wasm_exec.js";
|
|
11
11
|
/**
|
|
12
12
|
* Loads the engine, once per process.
|
|
13
13
|
*
|
|
14
14
|
* A missing module is the one failure worth naming precisely: it means the
|
|
15
15
|
* repository was cloned but not built, and the fix is one command.
|
|
16
|
+
*
|
|
17
|
+
* ## Being handed the module instead of finding it
|
|
18
|
+
*
|
|
19
|
+
* `options.wasm` skips the search. That is not a convenience — it is the only
|
|
20
|
+
* way this entry point works in a Worker, where there is no filesystem to read
|
|
21
|
+
* and the module arrives already compiled from the bundler.
|
|
22
|
+
*
|
|
23
|
+
* It matters because of what else lives here: the free functions below share
|
|
24
|
+
* *this* singleton, and the MCP tools are written against them. A host that
|
|
25
|
+
* loaded its own engine through `createEngine` would have two, and the tools
|
|
26
|
+
* would find the one nobody filled — "the engine is not loaded yet", moments
|
|
27
|
+
* after loading it. So a host with its own module gives it to this loader
|
|
28
|
+
* rather than keeping it.
|
|
16
29
|
*/
|
|
17
|
-
export declare function loadEngine(): Promise<Engine>;
|
|
30
|
+
export declare function loadEngine(options?: LoadOptions): Promise<Engine>;
|
|
18
31
|
/** The engine. Throws if something asked before the load finished. */
|
|
19
32
|
export declare function engine(): Engine;
|
|
20
33
|
export * from "./index.js";
|
package/node.js
CHANGED
|
@@ -1371,9 +1371,14 @@ function modulePaths() {
|
|
|
1371
1371
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
1372
1372
|
return [join(here, "tensorcad.wasm"), join(here, "..", "wasm", "tensorcad.wasm")];
|
|
1373
1373
|
}
|
|
1374
|
-
async function loadEngine() {
|
|
1374
|
+
async function loadEngine(options) {
|
|
1375
1375
|
if (loaded)
|
|
1376
1376
|
return loaded;
|
|
1377
|
+
if (options?.wasm !== undefined) {
|
|
1378
|
+
loaded = await createEngine(options);
|
|
1379
|
+
publish(loaded);
|
|
1380
|
+
return loaded;
|
|
1381
|
+
}
|
|
1377
1382
|
const paths = modulePaths();
|
|
1378
1383
|
let bytes = null;
|
|
1379
1384
|
for (const path of paths) {
|
|
@@ -1387,12 +1392,15 @@ async function loadEngine() {
|
|
|
1387
1392
|
throw new EngineError(`The analysis engine is not built (looked in ${paths.join(" and ")}). Run: bun run build:wasm`);
|
|
1388
1393
|
}
|
|
1389
1394
|
loaded = await createEngine({ wasm: bytes });
|
|
1390
|
-
|
|
1391
|
-
HARDWARE.push(...loaded.hardware());
|
|
1392
|
-
for (const entry of loaded.blocks.builtInEntries)
|
|
1393
|
-
CATALOG[entry.type] = entry;
|
|
1395
|
+
publish(loaded);
|
|
1394
1396
|
return loaded;
|
|
1395
1397
|
}
|
|
1398
|
+
function publish(engine) {
|
|
1399
|
+
PRESET_NAMES.push(...engine.presets());
|
|
1400
|
+
HARDWARE.push(...engine.hardware());
|
|
1401
|
+
for (const entry of engine.blocks.builtInEntries)
|
|
1402
|
+
CATALOG[entry.type] = entry;
|
|
1403
|
+
}
|
|
1396
1404
|
function engine() {
|
|
1397
1405
|
if (!loaded)
|
|
1398
1406
|
throw new EngineError("The engine is not loaded yet; await loadEngine() first.");
|
package/package.json
CHANGED
package/tensorcad.wasm
CHANGED
|
Binary file
|
package/types.d.ts
CHANGED
|
@@ -170,12 +170,27 @@ export interface PortSpec {
|
|
|
170
170
|
dtype?: string;
|
|
171
171
|
/** A port that may legitimately dangle. */
|
|
172
172
|
optional?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* What the tensor carries, as a *kind* rather than a width: "real" for
|
|
175
|
+
* anything a matmul can multiply, "int" for an index, "bool" for a mask,
|
|
176
|
+
* "inherit" to take it from whatever arrives. Which real type — fp32,
|
|
177
|
+
* bf16, fp8 — is a condition of the run and belongs to the operating
|
|
178
|
+
* point (invariant 8), not to the block.
|
|
179
|
+
*/
|
|
173
180
|
/** "flow" or "side": which edge of the symbol a wire leaves by. */
|
|
174
181
|
anchor?: "flow" | "side";
|
|
175
182
|
showName?: boolean;
|
|
176
183
|
doc?: string;
|
|
177
184
|
}
|
|
178
185
|
export interface BlockDocs {
|
|
186
|
+
/**
|
|
187
|
+
* What a drawing calls this block: a short noun phrase in the words a
|
|
188
|
+
* published figure would use, where `type` is the identifier the engine
|
|
189
|
+
* dispatches on and a path is written with. Both are kept — the identifier is
|
|
190
|
+
* what an MCP call names, and a reader who found a block by its drawing then
|
|
191
|
+
* has to type it.
|
|
192
|
+
*/
|
|
193
|
+
name?: string;
|
|
179
194
|
summary?: string;
|
|
180
195
|
formula?: string;
|
|
181
196
|
refs?: string[];
|