@gnufoo/canaad 0.4.3 → 0.5.1
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/errors.d.ts +5 -0
- package/errors.js +10 -0
- package/meta.d.ts +2 -1
- package/meta.js +4 -0
- package/package.json +1 -1
- package/tool.d.ts +2 -0
- package/tool.js +3 -5
package/errors.d.ts
ADDED
package/errors.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Thrown when an operation is called before `initWasm()` completes. */
|
|
2
|
+
export class WasmNotInitializedError extends Error {
|
|
3
|
+
/** Discriminant for branded error handling — always `'WasmNotInitializedError'`. */
|
|
4
|
+
kind = 'WasmNotInitializedError';
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super('WASM not initialized. Call initWasm() first.');
|
|
8
|
+
this.name = 'WasmNotInitializedError';
|
|
9
|
+
}
|
|
10
|
+
}
|
package/meta.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type CanaadInput = z.infer<typeof inputSchema>;
|
|
|
12
12
|
/** Discriminated union of all action output shapes. */
|
|
13
13
|
export type CanaadOutput = z.infer<typeof outputSchema>;
|
|
14
14
|
|
|
15
|
-
/** Tool metadata: id, name, slug, description, category, execution type, positional args, and
|
|
15
|
+
/** Tool metadata: id, name, slug, description, category, execution type, positional args, schemas, and optional registry links. */
|
|
16
16
|
export declare const meta: {
|
|
17
17
|
id: string;
|
|
18
18
|
name: string;
|
|
@@ -21,6 +21,7 @@ export declare const meta: {
|
|
|
21
21
|
category: string;
|
|
22
22
|
executionType: string;
|
|
23
23
|
positionalArgs: { order: string[]; required: number };
|
|
24
|
+
packages?: { npm?: string; crates?: string };
|
|
24
25
|
inputSchema: typeof inputSchema;
|
|
25
26
|
outputSchema: typeof outputSchema;
|
|
26
27
|
};
|
package/meta.js
CHANGED
package/package.json
CHANGED
package/tool.d.ts
CHANGED
package/tool.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { meta, inputSchema } from './meta.js';
|
|
2
2
|
import { initWasm, isInitialized } from './init.js';
|
|
3
3
|
import { canonicalize, canonicalizeString, hash, validate, AadBuilder } from './canaad_wasm.js';
|
|
4
|
-
|
|
4
|
+
import { WasmNotInitializedError } from './errors.js';
|
|
5
5
|
const bytesToHex = (bytes) => Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
6
6
|
const bytesToBase64 = (bytes) => globalThis.btoa(String.fromCharCode(...bytes));
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Main tool export. Merges AAD metadata with WASM lifecycle methods and the action dispatcher.
|
|
10
9
|
*/
|
|
@@ -18,11 +17,9 @@ export const toolDefinition = {
|
|
|
18
17
|
*/
|
|
19
18
|
async execute(rawInput) {
|
|
20
19
|
if (!isInitialized()) {
|
|
21
|
-
throw new
|
|
20
|
+
throw new WasmNotInitializedError();
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
const input = inputSchema.parse(rawInput);
|
|
25
|
-
|
|
26
23
|
switch (input.action) {
|
|
27
24
|
case 'canonicalize': {
|
|
28
25
|
if (input.outputFormat === 'bytes') {
|
|
@@ -50,3 +47,4 @@ export const toolDefinition = {
|
|
|
50
47
|
}
|
|
51
48
|
},
|
|
52
49
|
};
|
|
50
|
+
export { WasmNotInitializedError } from './errors.js';
|