@six5536/smllm-wasm 0.4.0 → 0.5.0

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.
@@ -1,5 +1,5 @@
1
1
  import type { Host } from "../types.js";
2
- /** `timeoutSecs` default (DEC-5), as the CLI's. */
2
+ /** `timeoutSecs` default (CLI-11), as the CLI's. */
3
3
  export declare const DEFAULT_TIMEOUT_SECS = 60;
4
4
  /**
5
5
  * A host that runs `command` guards and actions. `configDir` is the folder
package/dist/node/host.js CHANGED
@@ -1,17 +1,16 @@
1
- // The Node command host (HOST-15): `command` guards
2
- // and actions run as the CLI runs them (DEC-4..DEC-7). Host methods are
1
+ // The Node command host (WASM-3): `command` guards
2
+ // and actions run as the CLI runs them (CLI-11..CLI-11). Host methods are
3
3
  // synchronous, so commands run with `spawnSync`. On unix the command is
4
4
  // started detached, as the leader of its own process group, and a timeout
5
5
  // kills that whole group, so what the command started dies with it; its
6
6
  // output goes to a file, not a pipe, so a process it leaves running cannot
7
7
  // hold the call open. On Windows the command's own process is killed, as the
8
8
  // CLI does.
9
- // @zen-component: HOST-JsPackage
10
9
  import { spawnSync } from "node:child_process";
11
10
  import { closeSync, mkdtempSync, openSync, readFileSync, rmSync } from "node:fs";
12
11
  import { tmpdir } from "node:os";
13
12
  import { join, resolve } from "node:path";
14
- /** `timeoutSecs` default (DEC-5), as the CLI's. */
13
+ /** `timeoutSecs` default (CLI-11), as the CLI's. */
15
14
  export const DEFAULT_TIMEOUT_SECS = 60;
16
15
  const TAIL_CHARS = 400;
17
16
  /** The last `TAIL_CHARS` characters of `text`, on one line (as the CLI's). */
@@ -22,6 +21,7 @@ function tail(text) {
22
21
  return cut ? `…${s}` : s;
23
22
  }
24
23
  /** A command's failure text, `""` when it passed. */
24
+ // sokf-implements: WASM-3_AC-1
25
25
  function runCommand(params, env, sessionCwd, configDir, timeoutSecs) {
26
26
  const run = params.run;
27
27
  let argv;
@@ -1,8 +1,7 @@
1
- // Node file storage (HOST-14): a file per record, written
1
+ // Node file storage (WASM-2): a file per record, written
2
2
  // atomically (temp file, then rename), and history as JSONL, one line per
3
3
  // entry in the CLI's format. One process owns a folder: several processes
4
4
  // sharing state should use the CLI, whose store locks.
5
- // @zen-component: HOST-JsPackage
6
5
  import { appendFileSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
7
6
  import { join } from "node:path";
8
7
  const SHELF = {
package/dist/storage.js CHANGED
@@ -1,6 +1,5 @@
1
- // In-memory storage (HOST-14): what `nodeFileStorage` does with files,
1
+ // In-memory storage (WASM-2): what `nodeFileStorage` does with files,
2
2
  // without them; for tests, examples and hosts that persist elsewhere.
3
- // @zen-component: HOST-JsPackage
4
3
  /** A storage that keeps everything in memory. `history` holds the log by `machine/id`. */
5
4
  export function memoryStorage() {
6
5
  const state = { sessions: {}, bindings: {}, instances: {} };
package/dist/types.d.ts CHANGED
@@ -13,7 +13,7 @@ export interface Reply {
13
13
  location: Location;
14
14
  text: string;
15
15
  }
16
- /** The stop hook's decision (TURN-4..6). */
16
+ /** The stop hook's decision (AGT-8..6). */
17
17
  export type StopDecision = {
18
18
  decision: "allow";
19
19
  }
@@ -79,7 +79,7 @@ export interface Host {
79
79
  /** What `put` hands on: a session (key: its key), a binding (`harness/hostSession`, record: the session key) or an instance (`machine/id`). */
80
80
  export type RecordKind = "session" | "binding" | "instance";
81
81
  /**
82
- * Where an engine's state lives (HOST-14): `load` once, into `importState`;
82
+ * Where an engine's state lives (WASM-2): `load` once, into `importState`;
83
83
  * then each saved record through `put` and each history entry through
84
84
  * `history`, as they happen, so persisting costs what changed.
85
85
  */
package/dist/wrap.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare class Engine {
39
39
  * record and history entry (its `put` and `history` go before `host`'s).
40
40
  */
41
41
  constructor(compiled: string | object, host?: Host, storage?: Storage);
42
- /** The agent-facing tool, to hand to an LLM's tool list (HOST-13). */
42
+ /** The agent-facing tool, to hand to an LLM's tool list (WASM-1). */
43
43
  tool(): Tool;
44
44
  /** Answer a tool call as the MCP server does; a malformed call is `ok: false`, never a throw. */
45
45
  callTool(args?: ToolArgs): Reply;
package/dist/wrap.js CHANGED
@@ -46,12 +46,13 @@ export class Engine {
46
46
  }
47
47
  : host;
48
48
  this.#raw = new Raw(json, adapt(all));
49
+ // sokf-implements: WASM-2_AC-2
49
50
  const saved = storage?.load();
50
51
  if (saved) {
51
52
  this.importState(saved);
52
53
  }
53
54
  }
54
- /** The agent-facing tool, to hand to an LLM's tool list (HOST-13). */
55
+ /** The agent-facing tool, to hand to an LLM's tool list (WASM-1). */
55
56
  tool() {
56
57
  return parse(this.#raw.tool());
57
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@six5536/smllm-wasm",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "smllm's engine as WebAssembly: run smllm state machines that drive an LLM agent, in a browser or Node.",
5
5
  "homepage": "https://github.com/six5536/smllm#readme",
6
6
  "repository": {
@@ -13,7 +13,7 @@ export class Engine {
13
13
  bind(harness: string, host_session: string | null | undefined, cwd: string): string;
14
14
  /**
15
15
  * A tool call: the agent's arguments as JSON, answered as the MCP
16
- * server answers them (HOST-13). A malformed call or an engine error is
16
+ * server answers them (WASM-1). A malformed call or an engine error is
17
17
  * a reply with `ok: false` and `error: …`, never a throw: the agent
18
18
  * sees its mistake as the tool's answer.
19
19
  */
@@ -43,11 +43,11 @@ export class Engine {
43
43
  */
44
44
  promptSubmitted(key: string): void;
45
45
  /**
46
- * Where the session is, as the `smllm statusline --json` object (STL-8).
46
+ * Where the session is, as the `smllm statusline --json` object (ENG-3).
47
47
  */
48
48
  status(key: string): string;
49
49
  /**
50
- * The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
50
+ * The stop decision as JSON (AGT-8..6): `{"decision": "allow"}` = may
51
51
  * stop; `{"decision": "block", "text"}` = hold the agent with the events
52
52
  * list; `{"decision": "runaway", "text"}` = let it stop, showing the
53
53
  * list to the user (the harness was already continuing because of a
@@ -56,7 +56,7 @@ export class Engine {
56
56
  stop(key: string, stop_hook_active: boolean): string;
57
57
  /**
58
58
  * The agent-facing tool, as JSON `{name, description, inputSchema}`:
59
- * the core's definition, as the MCP server offers it (HOST-13).
59
+ * the core's definition, as the MCP server offers it (WASM-1).
60
60
  */
61
61
  tool(): string;
62
62
  /**
@@ -51,7 +51,7 @@ export class Engine {
51
51
  }
52
52
  /**
53
53
  * A tool call: the agent's arguments as JSON, answered as the MCP
54
- * server answers them (HOST-13). A malformed call or an engine error is
54
+ * server answers them (WASM-1). A malformed call or an engine error is
55
55
  * a reply with `ok: false` and `error: …`, never a throw: the agent
56
56
  * sees its mistake as the tool's answer.
57
57
  * @param {string} args
@@ -226,7 +226,7 @@ export class Engine {
226
226
  }
227
227
  }
228
228
  /**
229
- * Where the session is, as the `smllm statusline --json` object (STL-8).
229
+ * Where the session is, as the `smllm statusline --json` object (ENG-3).
230
230
  * @param {string} key
231
231
  * @returns {string}
232
232
  */
@@ -257,7 +257,7 @@ export class Engine {
257
257
  }
258
258
  }
259
259
  /**
260
- * The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
260
+ * The stop decision as JSON (AGT-8..6): `{"decision": "allow"}` = may
261
261
  * stop; `{"decision": "block", "text"}` = hold the agent with the events
262
262
  * list; `{"decision": "runaway", "text"}` = let it stop, showing the
263
263
  * list to the user (the harness was already continuing because of a
@@ -294,7 +294,7 @@ export class Engine {
294
294
  }
295
295
  /**
296
296
  * The agent-facing tool, as JSON `{name, description, inputSchema}`:
297
- * the core's definition, as the MCP server offers it (HOST-13).
297
+ * the core's definition, as the MCP server offers it (WASM-1).
298
298
  * @returns {string}
299
299
  */
300
300
  tool() {
@@ -370,7 +370,7 @@ export function __wbg_Error_30c8987f7c2ed4e2(arg0, arg1) {
370
370
  const ret = Error(getStringFromWasm0(arg0, arg1));
371
371
  return addHeapObject(ret);
372
372
  }
373
- export function __wbg_String_50e8e7e5340432bd(arg0, arg1) {
373
+ export function __wbg_String_bbd7b99db50d2c72(arg0, arg1) {
374
374
  const ret = String(getObject(arg1));
375
375
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
376
376
  const len1 = WASM_VECTOR_LEN;
@@ -380,43 +380,43 @@ export function __wbg_String_50e8e7e5340432bd(arg0, arg1) {
380
380
  export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
381
381
  throw new Error(getStringFromWasm0(arg0, arg1));
382
382
  }
383
- export function __wbg_check_50c1a220e37a7313() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
383
+ export function __wbg_check_6dfc683de5752eb9() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
384
384
  const ret = getObject(arg0).check(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), getStringFromWasm0(arg7, arg8));
385
385
  return ret;
386
386
  }, arguments); }
387
- export function __wbg_history_96f90f47fe48bff5() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
387
+ export function __wbg_history_ed6a3249cdbf6fba() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
388
388
  getObject(arg0).history(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
389
389
  }, arguments); }
390
- export function __wbg_isMatch_6fae7431ba8c03f8() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
390
+ export function __wbg_isMatch_b6fb6fb03924405a() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
391
391
  const ret = getObject(arg0).isMatch(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
392
392
  return ret;
393
393
  }, arguments); }
394
- export function __wbg_now_fc028ce4f381e65e() { return handleError(function (arg0) {
394
+ export function __wbg_now_976fd88331086448() { return handleError(function (arg0) {
395
395
  const ret = getObject(arg0).now();
396
396
  return ret;
397
397
  }, arguments); }
398
- export function __wbg_put_d358a9a844a38014() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
398
+ export function __wbg_put_9cd5b2a059778929() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
399
399
  getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
400
400
  }, arguments); }
401
- export function __wbg_random_00b1f6c7178bf1c0() { return handleError(function (arg0) {
401
+ export function __wbg_random_5e704a8263f19bfe() { return handleError(function (arg0) {
402
402
  const ret = getObject(arg0).random();
403
403
  return ret;
404
404
  }, arguments); }
405
- export function __wbg_read_1bd3096dfdac8efb() { return handleError(function (arg0, arg1, arg2, arg3) {
405
+ export function __wbg_read_3a7eb14b88f4a798() { return handleError(function (arg0, arg1, arg2, arg3) {
406
406
  const ret = getObject(arg1).read(getStringFromWasm0(arg2, arg3));
407
407
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
408
408
  var len1 = WASM_VECTOR_LEN;
409
409
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
410
410
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
411
411
  }, arguments); }
412
- export function __wbg_run_a559624047f1d933() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
412
+ export function __wbg_run_9856da75a23eb26d() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
413
413
  const ret = getObject(arg1).run(getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
414
414
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
415
415
  const len1 = WASM_VECTOR_LEN;
416
416
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
417
417
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
418
418
  }, arguments); }
419
- export function __wbg_supports_e8118f6f4e42b431() { return handleError(function (arg0, arg1, arg2) {
419
+ export function __wbg_supports_ecfa18db153d083b() { return handleError(function (arg0, arg1, arg2) {
420
420
  const ret = getObject(arg0).supports(getStringFromWasm0(arg1, arg2));
421
421
  return ret;
422
422
  }, arguments); }
Binary file
@@ -13,7 +13,7 @@ export class Engine {
13
13
  bind(harness: string, host_session: string | null | undefined, cwd: string): string;
14
14
  /**
15
15
  * A tool call: the agent's arguments as JSON, answered as the MCP
16
- * server answers them (HOST-13). A malformed call or an engine error is
16
+ * server answers them (WASM-1). A malformed call or an engine error is
17
17
  * a reply with `ok: false` and `error: …`, never a throw: the agent
18
18
  * sees its mistake as the tool's answer.
19
19
  */
@@ -43,11 +43,11 @@ export class Engine {
43
43
  */
44
44
  promptSubmitted(key: string): void;
45
45
  /**
46
- * Where the session is, as the `smllm statusline --json` object (STL-8).
46
+ * Where the session is, as the `smllm statusline --json` object (ENG-3).
47
47
  */
48
48
  status(key: string): string;
49
49
  /**
50
- * The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
50
+ * The stop decision as JSON (AGT-8..6): `{"decision": "allow"}` = may
51
51
  * stop; `{"decision": "block", "text"}` = hold the agent with the events
52
52
  * list; `{"decision": "runaway", "text"}` = let it stop, showing the
53
53
  * list to the user (the harness was already continuing because of a
@@ -56,7 +56,7 @@ export class Engine {
56
56
  stop(key: string, stop_hook_active: boolean): string;
57
57
  /**
58
58
  * The agent-facing tool, as JSON `{name, description, inputSchema}`:
59
- * the core's definition, as the MCP server offers it (HOST-13).
59
+ * the core's definition, as the MCP server offers it (WASM-1).
60
60
  */
61
61
  tool(): string;
62
62
  /**
@@ -53,7 +53,7 @@ export class Engine {
53
53
  }
54
54
  /**
55
55
  * A tool call: the agent's arguments as JSON, answered as the MCP
56
- * server answers them (HOST-13). A malformed call or an engine error is
56
+ * server answers them (WASM-1). A malformed call or an engine error is
57
57
  * a reply with `ok: false` and `error: …`, never a throw: the agent
58
58
  * sees its mistake as the tool's answer.
59
59
  * @param {string} args
@@ -228,7 +228,7 @@ export class Engine {
228
228
  }
229
229
  }
230
230
  /**
231
- * Where the session is, as the `smllm statusline --json` object (STL-8).
231
+ * Where the session is, as the `smllm statusline --json` object (ENG-3).
232
232
  * @param {string} key
233
233
  * @returns {string}
234
234
  */
@@ -259,7 +259,7 @@ export class Engine {
259
259
  }
260
260
  }
261
261
  /**
262
- * The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
262
+ * The stop decision as JSON (AGT-8..6): `{"decision": "allow"}` = may
263
263
  * stop; `{"decision": "block", "text"}` = hold the agent with the events
264
264
  * list; `{"decision": "runaway", "text"}` = let it stop, showing the
265
265
  * list to the user (the harness was already continuing because of a
@@ -296,7 +296,7 @@ export class Engine {
296
296
  }
297
297
  /**
298
298
  * The agent-facing tool, as JSON `{name, description, inputSchema}`:
299
- * the core's definition, as the MCP server offers it (HOST-13).
299
+ * the core's definition, as the MCP server offers it (WASM-1).
300
300
  * @returns {string}
301
301
  */
302
302
  tool() {
@@ -375,7 +375,7 @@ function __wbg_get_imports() {
375
375
  const ret = Error(getStringFromWasm0(arg0, arg1));
376
376
  return addHeapObject(ret);
377
377
  },
378
- __wbg_String_50e8e7e5340432bd: function(arg0, arg1) {
378
+ __wbg_String_bbd7b99db50d2c72: function(arg0, arg1) {
379
379
  const ret = String(getObject(arg1));
380
380
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
381
381
  const len1 = WASM_VECTOR_LEN;
@@ -385,43 +385,43 @@ function __wbg_get_imports() {
385
385
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
386
386
  throw new Error(getStringFromWasm0(arg0, arg1));
387
387
  },
388
- __wbg_check_50c1a220e37a7313: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
388
+ __wbg_check_6dfc683de5752eb9: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
389
389
  const ret = getObject(arg0).check(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), getStringFromWasm0(arg7, arg8));
390
390
  return ret;
391
391
  }, arguments); },
392
- __wbg_history_96f90f47fe48bff5: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
392
+ __wbg_history_ed6a3249cdbf6fba: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
393
393
  getObject(arg0).history(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
394
394
  }, arguments); },
395
- __wbg_isMatch_6fae7431ba8c03f8: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
395
+ __wbg_isMatch_b6fb6fb03924405a: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
396
396
  const ret = getObject(arg0).isMatch(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
397
397
  return ret;
398
398
  }, arguments); },
399
- __wbg_now_fc028ce4f381e65e: function() { return handleError(function (arg0) {
399
+ __wbg_now_976fd88331086448: function() { return handleError(function (arg0) {
400
400
  const ret = getObject(arg0).now();
401
401
  return ret;
402
402
  }, arguments); },
403
- __wbg_put_d358a9a844a38014: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
403
+ __wbg_put_9cd5b2a059778929: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
404
404
  getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
405
405
  }, arguments); },
406
- __wbg_random_00b1f6c7178bf1c0: function() { return handleError(function (arg0) {
406
+ __wbg_random_5e704a8263f19bfe: function() { return handleError(function (arg0) {
407
407
  const ret = getObject(arg0).random();
408
408
  return ret;
409
409
  }, arguments); },
410
- __wbg_read_1bd3096dfdac8efb: function() { return handleError(function (arg0, arg1, arg2, arg3) {
410
+ __wbg_read_3a7eb14b88f4a798: function() { return handleError(function (arg0, arg1, arg2, arg3) {
411
411
  const ret = getObject(arg1).read(getStringFromWasm0(arg2, arg3));
412
412
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
413
413
  var len1 = WASM_VECTOR_LEN;
414
414
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
415
415
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
416
416
  }, arguments); },
417
- __wbg_run_a559624047f1d933: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
417
+ __wbg_run_9856da75a23eb26d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
418
418
  const ret = getObject(arg1).run(getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
419
419
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
420
420
  const len1 = WASM_VECTOR_LEN;
421
421
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
422
422
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
423
423
  }, arguments); },
424
- __wbg_supports_e8118f6f4e42b431: function() { return handleError(function (arg0, arg1, arg2) {
424
+ __wbg_supports_ecfa18db153d083b: function() { return handleError(function (arg0, arg1, arg2) {
425
425
  const ret = getObject(arg0).supports(getStringFromWasm0(arg1, arg2));
426
426
  return ret;
427
427
  }, arguments); },
Binary file