@dot-agent/kernel-dsl 0.1.1 → 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.
package/index.js CHANGED
@@ -65,8 +65,8 @@ export class AgentDSLKernel {
65
65
  send_complete() { return this._kernel.send_complete(); }
66
66
  send_event(event) { return this._kernel.send_event(event); }
67
67
  send_failed() { return this._kernel.send_failed(); }
68
- send_fallback() { return this._kernel.send_fallback(); }
69
68
  send_intent(intent) { return this._kernel.send_intent(intent); }
69
+ set_memory(domain, key, value_json) { return this._kernel.set_memory(domain, key, value_json); }
70
70
  send_offtopic() { return this._kernel.send_offtopic(); }
71
71
  tick_prompt() { return this._kernel.tick_prompt(); }
72
72
  free() { return this._kernel.free(); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dot-agent/kernel-dsl",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "WASM kernel for parsing and executing the agent behavior DSL",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -41,6 +41,7 @@
41
41
  "scripts/patch-wasm-bindgen.js",
42
42
  "pkg/dot_agent_kernel_dsl.js",
43
43
  "pkg/dot_agent_kernel_dsl.d.ts",
44
+ "pkg/dot_agent_kernel_dsl_bg.js",
44
45
  "pkg/dot_agent_kernel_dsl_bg.wasm",
45
46
  "pkg/dot_agent_kernel_dsl_bg.wasm.d.ts",
46
47
  "pkg/package.json"
@@ -63,6 +64,5 @@
63
64
  "publishConfig": {
64
65
  "access": "public"
65
66
  },
66
- "dependencies": {
67
- }
67
+ "dependencies": {}
68
68
  }
@@ -0,0 +1,327 @@
1
+ export class AgentDSLKernel {
2
+ __destroy_into_raw() {
3
+ const ptr = this.__wbg_ptr;
4
+ this.__wbg_ptr = 0;
5
+ AgentDSLKernelFinalization.unregister(this);
6
+ return ptr;
7
+ }
8
+ free() {
9
+ const ptr = this.__destroy_into_raw();
10
+ wasm.__wbg_agentdslkernel_free(ptr, 0);
11
+ }
12
+ /**
13
+ * Return the name of the current state.
14
+ * @returns {string}
15
+ */
16
+ get_current_state() {
17
+ let deferred1_0;
18
+ let deferred1_1;
19
+ try {
20
+ const ret = wasm.agentdslkernel_get_current_state(this.__wbg_ptr);
21
+ deferred1_0 = ret[0];
22
+ deferred1_1 = ret[1];
23
+ return getStringFromWasm0(ret[0], ret[1]);
24
+ } finally {
25
+ wasm.__wbindgen_free_command_export(deferred1_0, deferred1_1, 1);
26
+ }
27
+ }
28
+ /**
29
+ * Return the state graph as { states, transitions, current }.
30
+ *
31
+ * Use this to render the Flow Graph panel in VS Code or any diagram tool.
32
+ * @returns {any}
33
+ */
34
+ get_graph() {
35
+ const ret = wasm.agentdslkernel_get_graph(this.__wbg_ptr);
36
+ return ret;
37
+ }
38
+ /**
39
+ * Return the full memory store as a JSON array of { domain, key, value } entries.
40
+ * @returns {any}
41
+ */
42
+ get_memory() {
43
+ const ret = wasm.agentdslkernel_get_memory(this.__wbg_ptr);
44
+ return ret;
45
+ }
46
+ /**
47
+ * Return an array of intent strings declared in the current state.
48
+ *
49
+ * Use this to build the list of valid intent names to pass to the LLM classifier.
50
+ * @returns {Array<any>}
51
+ */
52
+ get_valid_intents() {
53
+ const ret = wasm.agentdslkernel_get_valid_intents(this.__wbg_ptr);
54
+ return ret;
55
+ }
56
+ /**
57
+ * Parse and load a .behavior DSL text.
58
+ *
59
+ * Fires the observer for each entry effect of the first state (typically goal +
60
+ * request_interact). Also returns the effects array for imperative call sites.
61
+ * On parse error, fires and returns a single ParseError effect.
62
+ * @param {string} text
63
+ * @returns {any}
64
+ */
65
+ load_behavior(text) {
66
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
67
+ const len0 = WASM_VECTOR_LEN;
68
+ const ret = wasm.agentdslkernel_load_behavior(this.__wbg_ptr, ptr0, len0);
69
+ return ret;
70
+ }
71
+ constructor() {
72
+ const ret = wasm.agentdslkernel_new();
73
+ this.__wbg_ptr = ret;
74
+ AgentDSLKernelFinalization.register(this, this.__wbg_ptr, this);
75
+ return this;
76
+ }
77
+ /**
78
+ * Register a callback that WASM will call once per Effect as they are produced.
79
+ *
80
+ * This is the primary integration point — the equivalent of the importObject in a
81
+ * raw WebAssembly.instantiate call. The callback receives a single Effect object
82
+ * per invocation and must implement all WASM→JS directives (goal, guide, teach,
83
+ * run_script, run_subagent, run_tool, apply_css, …).
84
+ *
85
+ * Only one observer can be active at a time; calling observe() again replaces it.
86
+ * @param {Function} callback
87
+ */
88
+ observe(callback) {
89
+ wasm.agentdslkernel_observe(this.__wbg_ptr, callback);
90
+ }
91
+ /**
92
+ * Signal that the last async operation (run_script, run_subagent, run_tool) completed successfully.
93
+ *
94
+ * Fires the observer with the effects of the current state's `on complete` block.
95
+ * @returns {any}
96
+ */
97
+ send_complete() {
98
+ const ret = wasm.agentdslkernel_send_complete(this.__wbg_ptr);
99
+ return ret;
100
+ }
101
+ /**
102
+ * Signal that the runtime could not resolve the current action.
103
+ * Dispatch a named global event (e.g. "session.ended", "script.done").
104
+ *
105
+ * Matches top-level `on event "…"` declarations. Use this to notify the FSM
106
+ * when an async operation triggered by run_script / run_subagent / run_tool completes.
107
+ * @param {string} event
108
+ * @returns {any}
109
+ */
110
+ send_event(event) {
111
+ const ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.agentdslkernel_send_event(this.__wbg_ptr, ptr0, len0);
114
+ return ret;
115
+ }
116
+ /**
117
+ * Signal that the last async operation (run_script, run_subagent, run_tool) failed.
118
+ *
119
+ * Fires the observer with the effects of the current state's `on failed` block.
120
+ * @returns {any}
121
+ */
122
+ send_failed() {
123
+ const ret = wasm.agentdslkernel_send_failed(this.__wbg_ptr);
124
+ return ret;
125
+ }
126
+ /**
127
+ * Dispatch a named intent to the FSM.
128
+ *
129
+ * Call this after the LLM classifies the user's message into an intent name that
130
+ * matches one of the `on intent "…"` declarations in the current state.
131
+ * Fires the observer with transition + any entry effects of the new state.
132
+ * @param {string} intent
133
+ * @returns {any}
134
+ */
135
+ send_intent(intent) {
136
+ const ptr0 = passStringToWasm0(intent, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
137
+ const len0 = WASM_VECTOR_LEN;
138
+ const ret = wasm.agentdslkernel_send_intent(this.__wbg_ptr, ptr0, len0);
139
+ return ret;
140
+ }
141
+ /**
142
+ * Signal that the current message is off-topic.
143
+ *
144
+ * Fires the observer with the effects of the current state's `on offtopic` block.
145
+ * @returns {any}
146
+ */
147
+ send_offtopic() {
148
+ const ret = wasm.agentdslkernel_send_offtopic(this.__wbg_ptr);
149
+ return ret;
150
+ }
151
+ /**
152
+ * Set a value in the memory store from JS.
153
+ *
154
+ * domain: "context" | "session" | "worksession" | "user"
155
+ * value_json: value serialized as a JSON primitive ("text", 42, true, null)
156
+ * @param {string} domain
157
+ * @param {string} key
158
+ * @param {string} value_json
159
+ */
160
+ set_memory(domain, key, value_json) {
161
+ const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
162
+ const len0 = WASM_VECTOR_LEN;
163
+ const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
164
+ const len1 = WASM_VECTOR_LEN;
165
+ const ptr2 = passStringToWasm0(value_json, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
166
+ const len2 = WASM_VECTOR_LEN;
167
+ wasm.agentdslkernel_set_memory(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
168
+ }
169
+ /**
170
+ * Notify the engine that a prompt turn was processed.
171
+ *
172
+ * Call once per LLM completion. Triggers any matching `after N prompts` handlers
173
+ * in the current state, firing their effects through the observer.
174
+ * @returns {any}
175
+ */
176
+ tick_prompt() {
177
+ const ret = wasm.agentdslkernel_tick_prompt(this.__wbg_ptr);
178
+ return ret;
179
+ }
180
+ }
181
+ if (Symbol.dispose) AgentDSLKernel.prototype[Symbol.dispose] = AgentDSLKernel.prototype.free;
182
+ export function __wbg___wbindgen_throw_1506f2235d1bdba0(arg0, arg1) {
183
+ throw new Error(getStringFromWasm0(arg0, arg1));
184
+ }
185
+ export function __wbg_call_9c758de292015997() { return handleError(function (arg0, arg1, arg2) {
186
+ const ret = arg0.call(arg1, arg2);
187
+ return ret;
188
+ }, arguments); }
189
+ export function __wbg_new_ce1ab61c1c2b300d() {
190
+ const ret = new Object();
191
+ return ret;
192
+ }
193
+ export function __wbg_new_d90091b82fdf5b91() {
194
+ const ret = new Array();
195
+ return ret;
196
+ }
197
+ export function __wbg_push_a6822215aa43e71c(arg0, arg1) {
198
+ const ret = arg0.push(arg1);
199
+ return ret;
200
+ }
201
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
202
+ arg0[arg1] = arg2;
203
+ }
204
+ export function __wbg_set_dca99999bba88a9a(arg0, arg1, arg2) {
205
+ arg0[arg1 >>> 0] = arg2;
206
+ }
207
+ export function __wbindgen_cast_0000000000000001(arg0) {
208
+ // Cast intrinsic for `F64 -> Externref`.
209
+ const ret = arg0;
210
+ return ret;
211
+ }
212
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
213
+ // Cast intrinsic for `Ref(String) -> Externref`.
214
+ const ret = getStringFromWasm0(arg0, arg1);
215
+ return ret;
216
+ }
217
+ export function __wbindgen_init_externref_table() {
218
+ const table = wasm.__wbindgen_externrefs;
219
+ const offset = table.grow(4);
220
+ table.set(0, undefined);
221
+ table.set(offset + 0, undefined);
222
+ table.set(offset + 1, null);
223
+ table.set(offset + 2, true);
224
+ table.set(offset + 3, false);
225
+ }
226
+ const AgentDSLKernelFinalization = (typeof FinalizationRegistry === 'undefined')
227
+ ? { register: () => {}, unregister: () => {} }
228
+ : new FinalizationRegistry(ptr => wasm.__wbg_agentdslkernel_free(ptr, 1));
229
+
230
+ function addToExternrefTable0(obj) {
231
+ const idx = wasm.__externref_table_alloc_command_export();
232
+ wasm.__wbindgen_externrefs.set(idx, obj);
233
+ return idx;
234
+ }
235
+
236
+ function getStringFromWasm0(ptr, len) {
237
+ return decodeText(ptr >>> 0, len);
238
+ }
239
+
240
+ let cachedUint8ArrayMemory0 = null;
241
+ function getUint8ArrayMemory0() {
242
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
243
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
244
+ }
245
+ return cachedUint8ArrayMemory0;
246
+ }
247
+
248
+ function handleError(f, args) {
249
+ try {
250
+ return f.apply(this, args);
251
+ } catch (e) {
252
+ const idx = addToExternrefTable0(e);
253
+ wasm.__wbindgen_exn_store_command_export(idx);
254
+ }
255
+ }
256
+
257
+ function passStringToWasm0(arg, malloc, realloc) {
258
+ if (realloc === undefined) {
259
+ const buf = cachedTextEncoder.encode(arg);
260
+ const ptr = malloc(buf.length, 1) >>> 0;
261
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
262
+ WASM_VECTOR_LEN = buf.length;
263
+ return ptr;
264
+ }
265
+
266
+ let len = arg.length;
267
+ let ptr = malloc(len, 1) >>> 0;
268
+
269
+ const mem = getUint8ArrayMemory0();
270
+
271
+ let offset = 0;
272
+
273
+ for (; offset < len; offset++) {
274
+ const code = arg.charCodeAt(offset);
275
+ if (code > 0x7F) break;
276
+ mem[ptr + offset] = code;
277
+ }
278
+ if (offset !== len) {
279
+ if (offset !== 0) {
280
+ arg = arg.slice(offset);
281
+ }
282
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
283
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
284
+ const ret = cachedTextEncoder.encodeInto(arg, view);
285
+
286
+ offset += ret.written;
287
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
288
+ }
289
+
290
+ WASM_VECTOR_LEN = offset;
291
+ return ptr;
292
+ }
293
+
294
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
295
+ cachedTextDecoder.decode();
296
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
297
+ let numBytesDecoded = 0;
298
+ function decodeText(ptr, len) {
299
+ numBytesDecoded += len;
300
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
301
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
302
+ cachedTextDecoder.decode();
303
+ numBytesDecoded = len;
304
+ }
305
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
306
+ }
307
+
308
+ const cachedTextEncoder = new TextEncoder();
309
+
310
+ if (!('encodeInto' in cachedTextEncoder)) {
311
+ cachedTextEncoder.encodeInto = function (arg, view) {
312
+ const buf = cachedTextEncoder.encode(arg);
313
+ view.set(buf);
314
+ return {
315
+ read: arg.length,
316
+ written: buf.length
317
+ };
318
+ };
319
+ }
320
+
321
+ let WASM_VECTOR_LEN = 0;
322
+
323
+
324
+ let wasm;
325
+ export function __wbg_set_wasm(val) {
326
+ wasm = val;
327
+ }