melchizedek-agents 1.6.0 → 1.7.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/CHANGELOG.md +83 -0
- package/DOCUMENTATION.md +5 -1
- package/config/agents/syndicate.schema.json +63 -0
- package/config/agents/syndicateSchema.yaml +50 -0
- package/dist/lib/a2a/executor.js +21 -0
- package/dist/lib/compile.d.ts +4 -3
- package/dist/lib/compile.js +8 -3
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/loadSyndicate.d.ts +13 -0
- package/dist/lib/loadSyndicate.js +11 -1
- package/dist/lib/observability/supabaseSpanExporter.js +2 -1
- package/dist/lib/observability/tracer.d.ts +2 -2
- package/dist/lib/observability/tracer.js +2 -2
- package/dist/lib/runtime/native/checkpoint.d.ts +2 -1
- package/dist/lib/runtime/native/checkpoint.js +6 -2
- package/dist/lib/runtime/native/interrupts.js +9 -2
- package/dist/lib/runtime/nativeTurn.d.ts +2 -1
- package/dist/lib/runtime/nativeTurn.js +5 -1
- package/dist/lib/runtime/syndicateTurn.d.ts +11 -1
- package/dist/lib/runtime/syndicateTurn.js +383 -5
- package/dist/lib/sandbox/sandbox.d.ts +121 -0
- package/dist/lib/sandbox/sandbox.js +276 -0
- package/dist/lib/sandbox/worker.d.ts +29 -0
- package/dist/lib/sandbox/worker.js +280 -0
- package/dist/lib/script/config.d.ts +35 -0
- package/dist/lib/script/config.js +17 -0
- package/dist/lib/script/journal.d.ts +137 -0
- package/dist/lib/script/journal.js +193 -0
- package/dist/lib/script/run.d.ts +138 -0
- package/dist/lib/script/run.js +364 -0
- package/dist/lib/syndicateSchema.d.ts +20 -0
- package/dist/lib/syndicateSchema.js +98 -6
- package/dist/lib/toolRegistry.js +4 -0
- package/dist/lib/tools/runCodeTool.d.ts +50 -0
- package/dist/lib/tools/runCodeTool.js +59 -0
- package/package.json +5 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/tools/runCodeTool.ts — `run_code`: an agent runs JavaScript in the
|
|
3
|
+
* engine's sandbox and rests its answer on what the code returned
|
|
4
|
+
* (ADR 0137 items 2 to 4).
|
|
5
|
+
*
|
|
6
|
+
* WHY a registry tool: any agent on any provider can list it
|
|
7
|
+
* (`tools: [run_code]`), since the model only writes text, and it gets what
|
|
8
|
+
* every registry tool gets: `require_approval`, MCP exposure (ADR 0125), the
|
|
9
|
+
* result bound and `retries.tool_errors`. `code_execution: gemini` stays,
|
|
10
|
+
* for Python in Gemini's own sandbox on Gemini models (ADR 0033).
|
|
11
|
+
*
|
|
12
|
+
* THE CONTRACT: `{ code, input? }`. The code is a JavaScript module whose
|
|
13
|
+
* default export is called with `input`; the tool returns
|
|
14
|
+
* `{ result, logs, error }`: the export's JSON-serializable return, the
|
|
15
|
+
* `console.log` output, and what stopped it, if anything. Each is bounded at
|
|
16
|
+
* MAX_RESULT_CHARS. The code reaches nothing but `input` and `console`: no
|
|
17
|
+
* network, no host, no keys, no clock, no randomness (lib/sandbox/).
|
|
18
|
+
*
|
|
19
|
+
* THE SWITCH: nothing runs unless the operator set MELCHIZEDEK_CODE_SANDBOX=on;
|
|
20
|
+
* a syndicate listing run_code without it is refused at load (refuseOnNative),
|
|
21
|
+
* and a call that reaches here anyway answers with the reason.
|
|
22
|
+
*
|
|
23
|
+
* ATTACH: an agent's `run_code: { attach: true }` puts each run's code and
|
|
24
|
+
* result on the reply as a `code_run` data part (lib/runtime/syndicateTurn.ts
|
|
25
|
+
* collects them, the A2A executor publishes them). Off by default.
|
|
26
|
+
*/
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
import { codeSandboxEnabled, codeSandboxOffMessage, runInSandbox } from '../sandbox/sandbox.js';
|
|
29
|
+
import { MAX_RESULT_CHARS } from './tool.js';
|
|
30
|
+
import { defineTool } from './toolContract.js';
|
|
31
|
+
/** The registry name. */
|
|
32
|
+
export const RUN_CODE = 'run_code';
|
|
33
|
+
/** The largest program a call may send. */
|
|
34
|
+
export const MAX_CODE_CHARS = 64_000;
|
|
35
|
+
export const runCodeTool = defineTool({
|
|
36
|
+
name: RUN_CODE,
|
|
37
|
+
description: 'Run JavaScript and get back what it returns, so an answer can rest on a computation instead of mental arithmetic: totals, conversions, statistics, dates from given timestamps, parsing, sorting, checking a formula. '
|
|
38
|
+
+ '`code` is an ES module whose default export is called with `input` and returns a JSON-serializable value, e.g. `export default ({ xs }) => xs.reduce((a, b) => a + b, 0)`. '
|
|
39
|
+
+ 'console.log output comes back in `logs`. The code has no network, no files, no clock and no randomness (Date.now, new Date() and Math.random throw); pass any data it needs in `input`. '
|
|
40
|
+
+ 'It returns { result, logs, error }; when error is set, fix the code and run it again.',
|
|
41
|
+
schema: z.object({
|
|
42
|
+
code: z.string().min(1).max(MAX_CODE_CHARS).describe('An ES module: `export default (input) => value`. May be async.'),
|
|
43
|
+
input: z.unknown().optional().describe('JSON the default export is called with.'),
|
|
44
|
+
}),
|
|
45
|
+
async execute({ code, input }, ctx) {
|
|
46
|
+
if (!codeSandboxEnabled())
|
|
47
|
+
return { result: null, logs: '', error: codeSandboxOffMessage(RUN_CODE) };
|
|
48
|
+
const run = await runInSandbox({
|
|
49
|
+
source: code,
|
|
50
|
+
value: input ?? null,
|
|
51
|
+
...(ctx.signal ? { signal: ctx.signal } : {}),
|
|
52
|
+
limits: { maxLogChars: MAX_RESULT_CHARS, maxResultChars: MAX_RESULT_CHARS },
|
|
53
|
+
});
|
|
54
|
+
const logs = run.logsTruncated ? `${run.logs}\n[logs truncated at ${MAX_RESULT_CHARS.toLocaleString('en-US')} characters]` : run.logs;
|
|
55
|
+
if (!run.ok)
|
|
56
|
+
return { result: null, logs, error: `${run.error?.code ?? 'CODE_ERROR'}: ${run.error?.message ?? 'the code did not finish'}` };
|
|
57
|
+
return { result: run.result ?? null, logs, error: null };
|
|
58
|
+
},
|
|
59
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melchizedek-agents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A multi-model, multi-agent orchestration framework — YAML-defined syndicates on the engine's own agent loop, Supabase or Postgres session persistence, pgvector long-term memory. Companion repo to the lyceumagents.com curriculum.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"./loadSyndicate": "./dist/lib/loadSyndicate.js",
|
|
22
22
|
"./loadEnv": "./dist/lib/loadEnv.js",
|
|
23
23
|
"./dispatch": "./dist/lib/dispatch.js",
|
|
24
|
+
"./script": "./dist/lib/script/run.js",
|
|
25
|
+
"./sandbox": "./dist/lib/sandbox/sandbox.js",
|
|
24
26
|
"./compile": "./dist/lib/compile.js",
|
|
25
27
|
"./runtime": "./dist/lib/runtime/syndicateTurn.js",
|
|
26
28
|
"./runtime/turnControl": "./dist/lib/runtime/turnControl.js",
|
|
@@ -148,6 +150,7 @@
|
|
|
148
150
|
"@a2a-js/sdk": "^1.3.0",
|
|
149
151
|
"@anthropic-ai/sdk": "^0.131.0",
|
|
150
152
|
"@google/genai": "2.27.0",
|
|
153
|
+
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
|
|
151
154
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
152
155
|
"@opentelemetry/api": "^1.9.1",
|
|
153
156
|
"@opentelemetry/core": "^2.8.0",
|
|
@@ -161,6 +164,7 @@
|
|
|
161
164
|
"jose": "^6.2.12",
|
|
162
165
|
"openai": "^7.28.0",
|
|
163
166
|
"pg": "^8.23.1",
|
|
167
|
+
"quickjs-emscripten-core": "0.32.0",
|
|
164
168
|
"yaml": "^2.9.0",
|
|
165
169
|
"zod": "4.6.5"
|
|
166
170
|
},
|