nanocodex 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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/pkg-node/nanocodex.js +10 -10
- package/pkg-node/nanocodex_bg.wasm +0 -0
- package/pkg-web/nanocodex.js +10 -10
- package/pkg-web/nanocodex_bg.wasm +0 -0
- package/runtime/code-runtime.mjs +11 -4
package/README.md
CHANGED
|
@@ -286,7 +286,7 @@ manager or build step:
|
|
|
286
286
|
|
|
287
287
|
```html
|
|
288
288
|
<script type="module">
|
|
289
|
-
import { Agent } from "https://cdn.jsdelivr.net/npm/nanocodex@0.
|
|
289
|
+
import { Agent } from "https://cdn.jsdelivr.net/npm/nanocodex@0.5.0/browser/index.mjs";
|
|
290
290
|
const agent = await Agent.create({ websocketUrl: "/api/responses" });
|
|
291
291
|
const turn = agent.turn.prompt({ input: "Hello." });
|
|
292
292
|
try {
|
package/package.json
CHANGED
package/pkg-node/nanocodex.js
CHANGED
|
@@ -390,21 +390,21 @@ function __wbg_get_imports() {
|
|
|
390
390
|
const ret = arg0.call(arg1, arg2);
|
|
391
391
|
return ret;
|
|
392
392
|
}, arguments); },
|
|
393
|
-
|
|
393
|
+
__wbg_close_5e82a7961abc5249: function(arg0) {
|
|
394
394
|
globalThis.nanocodexHost.close(arg0 >>> 0);
|
|
395
395
|
},
|
|
396
|
-
|
|
396
|
+
__wbg_connect_784737156844fe4b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
|
|
397
397
|
const ret = globalThis.nanocodexHost.connect(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5), arg6 !== 0, getStringFromWasm0(arg7, arg8), arg9 === 0 ? undefined : getStringFromWasm0(arg9, arg10));
|
|
398
398
|
return ret;
|
|
399
399
|
}, arguments); },
|
|
400
|
-
|
|
400
|
+
__wbg_emitEvent_8dba526dc26aad24: function(arg0, arg1) {
|
|
401
401
|
globalThis.nanocodexHost.emitEvent(getStringFromWasm0(arg0, arg1));
|
|
402
402
|
},
|
|
403
|
-
|
|
403
|
+
__wbg_executeCode_8ca25a06a52c9880: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
404
404
|
const ret = globalThis.nanocodexHost.executeCode(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
|
|
405
405
|
return ret;
|
|
406
406
|
}, arguments); },
|
|
407
|
-
|
|
407
|
+
__wbg_executeTool_fac7aac121bb3e28: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
|
408
408
|
const ret = globalThis.nanocodexHost.executeTool(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7));
|
|
409
409
|
return ret;
|
|
410
410
|
}, arguments); },
|
|
@@ -469,7 +469,7 @@ function __wbg_get_imports() {
|
|
|
469
469
|
state0.a = 0;
|
|
470
470
|
}
|
|
471
471
|
},
|
|
472
|
-
|
|
472
|
+
__wbg_next_f69b14f858799a1a: function() { return handleError(function (arg0, arg1) {
|
|
473
473
|
const ret = globalThis.nanocodexHost.next(arg0 >>> 0, arg1 >>> 0);
|
|
474
474
|
return ret;
|
|
475
475
|
}, arguments); },
|
|
@@ -500,11 +500,11 @@ function __wbg_get_imports() {
|
|
|
500
500
|
const ret = arg0.resolvedOptions();
|
|
501
501
|
return ret;
|
|
502
502
|
},
|
|
503
|
-
|
|
503
|
+
__wbg_send_3123992aab0aeeb5: function() { return handleError(function (arg0, arg1, arg2) {
|
|
504
504
|
const ret = globalThis.nanocodexHost.send(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
|
|
505
505
|
return ret;
|
|
506
506
|
}, arguments); },
|
|
507
|
-
|
|
507
|
+
__wbg_sleep_c693614773b9e78b: function() { return handleError(function (arg0, arg1, arg2) {
|
|
508
508
|
const ret = globalThis.nanocodexHost.sleep(getStringFromWasm0(arg0, arg1), arg2 >>> 0);
|
|
509
509
|
return ret;
|
|
510
510
|
}, arguments); },
|
|
@@ -532,14 +532,14 @@ function __wbg_get_imports() {
|
|
|
532
532
|
const ret = arg0.then(arg1);
|
|
533
533
|
return ret;
|
|
534
534
|
},
|
|
535
|
-
|
|
535
|
+
__wbg_toolDefinitions_e70ae95834bb1650: function() { return handleError(function (arg0, arg1, arg2) {
|
|
536
536
|
const ret = globalThis.nanocodexHost.toolDefinitions(getStringFromWasm0(arg1, arg2));
|
|
537
537
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
538
538
|
const len1 = WASM_VECTOR_LEN;
|
|
539
539
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
540
540
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
541
541
|
}, arguments); },
|
|
542
|
-
|
|
542
|
+
__wbg_toolMode_6cf330c30a8a60c0: function(arg0, arg1, arg2) {
|
|
543
543
|
const ret = globalThis.nanocodexHost.toolMode(getStringFromWasm0(arg1, arg2));
|
|
544
544
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
545
545
|
const len1 = WASM_VECTOR_LEN;
|
|
Binary file
|
package/pkg-web/nanocodex.js
CHANGED
|
@@ -387,21 +387,21 @@ function __wbg_get_imports() {
|
|
|
387
387
|
const ret = arg0.call(arg1, arg2);
|
|
388
388
|
return ret;
|
|
389
389
|
}, arguments); },
|
|
390
|
-
|
|
390
|
+
__wbg_close_5e82a7961abc5249: function(arg0) {
|
|
391
391
|
globalThis.nanocodexHost.close(arg0 >>> 0);
|
|
392
392
|
},
|
|
393
|
-
|
|
393
|
+
__wbg_connect_784737156844fe4b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
|
|
394
394
|
const ret = globalThis.nanocodexHost.connect(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5), arg6 !== 0, getStringFromWasm0(arg7, arg8), arg9 === 0 ? undefined : getStringFromWasm0(arg9, arg10));
|
|
395
395
|
return ret;
|
|
396
396
|
}, arguments); },
|
|
397
|
-
|
|
397
|
+
__wbg_emitEvent_8dba526dc26aad24: function(arg0, arg1) {
|
|
398
398
|
globalThis.nanocodexHost.emitEvent(getStringFromWasm0(arg0, arg1));
|
|
399
399
|
},
|
|
400
|
-
|
|
400
|
+
__wbg_executeCode_8ca25a06a52c9880: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
401
401
|
const ret = globalThis.nanocodexHost.executeCode(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
|
|
402
402
|
return ret;
|
|
403
403
|
}, arguments); },
|
|
404
|
-
|
|
404
|
+
__wbg_executeTool_fac7aac121bb3e28: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
|
405
405
|
const ret = globalThis.nanocodexHost.executeTool(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7));
|
|
406
406
|
return ret;
|
|
407
407
|
}, arguments); },
|
|
@@ -466,7 +466,7 @@ function __wbg_get_imports() {
|
|
|
466
466
|
state0.a = 0;
|
|
467
467
|
}
|
|
468
468
|
},
|
|
469
|
-
|
|
469
|
+
__wbg_next_f69b14f858799a1a: function() { return handleError(function (arg0, arg1) {
|
|
470
470
|
const ret = globalThis.nanocodexHost.next(arg0 >>> 0, arg1 >>> 0);
|
|
471
471
|
return ret;
|
|
472
472
|
}, arguments); },
|
|
@@ -497,11 +497,11 @@ function __wbg_get_imports() {
|
|
|
497
497
|
const ret = arg0.resolvedOptions();
|
|
498
498
|
return ret;
|
|
499
499
|
},
|
|
500
|
-
|
|
500
|
+
__wbg_send_3123992aab0aeeb5: function() { return handleError(function (arg0, arg1, arg2) {
|
|
501
501
|
const ret = globalThis.nanocodexHost.send(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
|
|
502
502
|
return ret;
|
|
503
503
|
}, arguments); },
|
|
504
|
-
|
|
504
|
+
__wbg_sleep_c693614773b9e78b: function() { return handleError(function (arg0, arg1, arg2) {
|
|
505
505
|
const ret = globalThis.nanocodexHost.sleep(getStringFromWasm0(arg0, arg1), arg2 >>> 0);
|
|
506
506
|
return ret;
|
|
507
507
|
}, arguments); },
|
|
@@ -529,14 +529,14 @@ function __wbg_get_imports() {
|
|
|
529
529
|
const ret = arg0.then(arg1);
|
|
530
530
|
return ret;
|
|
531
531
|
},
|
|
532
|
-
|
|
532
|
+
__wbg_toolDefinitions_e70ae95834bb1650: function() { return handleError(function (arg0, arg1, arg2) {
|
|
533
533
|
const ret = globalThis.nanocodexHost.toolDefinitions(getStringFromWasm0(arg1, arg2));
|
|
534
534
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
535
535
|
const len1 = WASM_VECTOR_LEN;
|
|
536
536
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
537
537
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
538
538
|
}, arguments); },
|
|
539
|
-
|
|
539
|
+
__wbg_toolMode_6cf330c30a8a60c0: function(arg0, arg1, arg2) {
|
|
540
540
|
const ret = globalThis.nanocodexHost.toolMode(getStringFromWasm0(arg1, arg2));
|
|
541
541
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
542
542
|
const len1 = WASM_VECTOR_LEN;
|
|
Binary file
|
package/runtime/code-runtime.mjs
CHANGED
|
@@ -36,7 +36,7 @@ export function createCodeRuntime(toolConfiguration = {}, extras = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
38
|
const result = await tool.handler(input, { sessionId, parentCallId: "", callId });
|
|
39
|
-
return encodeToolOutput(outputBody(result), true,
|
|
39
|
+
return encodeToolOutput(outputBody(result), true, structuredResult(result, `tool ${name} result`));
|
|
40
40
|
} catch (error) {
|
|
41
41
|
return encodeToolOutput(errorMessage(error), false, null);
|
|
42
42
|
}
|
|
@@ -65,17 +65,20 @@ export function createCodeRuntime(toolConfiguration = {}, extras = {}) {
|
|
|
65
65
|
name,
|
|
66
66
|
input: recordedInput,
|
|
67
67
|
output: outputBody(result),
|
|
68
|
+
structured_result: structuredResult(result, `tool ${name} result`),
|
|
68
69
|
success: true,
|
|
69
70
|
started_after_ns: startedAfterNs,
|
|
70
71
|
duration_ns: elapsedNs(toolStartedAt),
|
|
71
72
|
});
|
|
72
73
|
return result;
|
|
73
74
|
} catch (error) {
|
|
75
|
+
const message = errorMessage(error);
|
|
74
76
|
nestedCalls.push({
|
|
75
77
|
call_id: callId,
|
|
76
78
|
name,
|
|
77
79
|
input: recordedInput,
|
|
78
|
-
output:
|
|
80
|
+
output: message,
|
|
81
|
+
structured_result: message,
|
|
79
82
|
success: false,
|
|
80
83
|
started_after_ns: startedAfterNs,
|
|
81
84
|
duration_ns: elapsedNs(toolStartedAt),
|
|
@@ -177,11 +180,11 @@ export function createCodeRuntime(toolConfiguration = {}, extras = {}) {
|
|
|
177
180
|
});
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
function encodeToolOutput(output, success,
|
|
183
|
+
function encodeToolOutput(output, success, structuredResult) {
|
|
181
184
|
return JSON.stringify({
|
|
182
185
|
output,
|
|
183
186
|
success,
|
|
184
|
-
|
|
187
|
+
structured_result: structuredResult,
|
|
185
188
|
metadata: null,
|
|
186
189
|
process_trace: null,
|
|
187
190
|
});
|
|
@@ -217,6 +220,10 @@ function jsonSnapshot(value, label) {
|
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
|
|
223
|
+
function structuredResult(value, label) {
|
|
224
|
+
return value === undefined ? null : jsonSnapshot(value, label);
|
|
225
|
+
}
|
|
226
|
+
|
|
220
227
|
function deepFreeze(value) {
|
|
221
228
|
if (!value || typeof value !== "object" || Object.isFrozen(value)) return value;
|
|
222
229
|
for (const child of Object.values(value)) deepFreeze(child);
|