@tangle-network/agent-runtime 0.170.0 → 0.172.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.
Files changed (52) hide show
  1. package/dist/{activation-8RxHIo02.js → activation-DTleO7Fl.js} +2 -2
  2. package/dist/{activation-8RxHIo02.js.map → activation-DTleO7Fl.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +2 -2
  5. package/dist/{authored-code-C2TGxNtf.js → authored-code-DzYtiflw.js} +9 -16
  6. package/dist/authored-code-DzYtiflw.js.map +1 -0
  7. package/dist/{authoring-CUTgAxxE.js → authoring-c9yTIa3G.js} +2 -2
  8. package/dist/{authoring-CUTgAxxE.js.map → authoring-c9yTIa3G.js.map} +1 -1
  9. package/dist/durable.d.ts +1 -1
  10. package/dist/durable.js +1 -1
  11. package/dist/{graph-ZDMygFIo.js → graph-CtMnqYYC.js} +2 -2
  12. package/dist/{graph-ZDMygFIo.js.map → graph-CtMnqYYC.js.map} +1 -1
  13. package/dist/graph.d.ts +25 -85
  14. package/dist/graph.js +7 -162
  15. package/dist/graph.js.map +1 -1
  16. package/dist/{improvement-cycle-BYCnKZ_G.js → improvement-cycle-ipnDcl3P.js} +3 -3
  17. package/dist/{improvement-cycle-BYCnKZ_G.js.map → improvement-cycle-ipnDcl3P.js.map} +1 -1
  18. package/dist/{index-BgptUCKl.d.ts → index-DEEN055X.d.ts} +2 -2
  19. package/dist/{index-BGQtpQuJ.d.ts → index-cFm21prV.d.ts} +66 -10
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +7 -7
  22. package/dist/intelligence.js +3 -3
  23. package/dist/kernel.d.ts +2 -2
  24. package/dist/kernel.js +7 -7
  25. package/dist/{knowledge-D3211Z_x.js → knowledge-BHfAAu6C.js} +3 -3
  26. package/dist/{knowledge-D3211Z_x.js.map → knowledge-BHfAAu6C.js.map} +1 -1
  27. package/dist/knowledge.d.ts +1 -1
  28. package/dist/knowledge.js +1 -1
  29. package/dist/{loop-runner-bin-B_g5JOKA.js → loop-runner-bin-B3ju0qWS.js} +3 -3
  30. package/dist/{loop-runner-bin-B_g5JOKA.js.map → loop-runner-bin-B3ju0qWS.js.map} +1 -1
  31. package/dist/{loop-runner-bin-C2NXQK7J.d.ts → loop-runner-bin-BGcW6Gm7.d.ts} +2 -2
  32. package/dist/loop-runner-bin.d.ts +1 -1
  33. package/dist/loop-runner-bin.js +1 -1
  34. package/dist/mcp/bin.js +3 -3
  35. package/dist/mcp/index.d.ts +1 -1
  36. package/dist/mcp/index.js +4 -4
  37. package/dist/{openai-tools-UyXVO0kd.js → openai-tools-CfsSJ2sn.js} +2 -2
  38. package/dist/{openai-tools-UyXVO0kd.js.map → openai-tools-CfsSJ2sn.js.map} +1 -1
  39. package/dist/{runtime-C-7uhhFs.js → runtime-ckAefgVV.js} +248 -8
  40. package/dist/runtime-ckAefgVV.js.map +1 -0
  41. package/dist/{structural-rollout-C7nNNhri.js → structural-rollout-DjUoh2aA.js} +2 -2
  42. package/dist/{structural-rollout-C7nNNhri.js.map → structural-rollout-DjUoh2aA.js.map} +1 -1
  43. package/dist/{supervise-rEE46ruH.js → supervise-CnHd8x54.js} +12 -3
  44. package/dist/{supervise-rEE46ruH.js.map → supervise-CnHd8x54.js.map} +1 -1
  45. package/dist/{supervisor-B-mmmiOU.js → supervisor-Dw-5mGKr.js} +19 -22
  46. package/dist/{supervisor-B-mmmiOU.js.map → supervisor-Dw-5mGKr.js.map} +1 -1
  47. package/dist/testing.d.ts +1 -1
  48. package/dist/testing.js +11 -11
  49. package/package.json +1 -1
  50. package/skills/codemode/SKILL.md +5 -4
  51. package/dist/authored-code-C2TGxNtf.js.map +0 -1
  52. package/dist/runtime-C-7uhhFs.js.map +0 -1
package/dist/graph.js CHANGED
@@ -1,163 +1,10 @@
1
1
  import { m as ValidationError } from "./errors-CDZ8XsVj.js";
2
2
  import { d as replaySpawnTree, i as InMemorySpawnJournal, l as materializeTreeView, o as closesCursorSlot, r as InMemoryResultBlobStore, u as pendingWaits, x as contentAddress } from "./spawn-journal-Tgvp5VS5.js";
3
3
  import { t as addSpend } from "./util-D6ZEuBMi.js";
4
- import { N as createBudgetPool, U as createExecutorRegistry, a as uncertainSpawnBudgets, i as sumMeasuredSpendFromEvents, l as runFinalizer, o as bestDelivered, p as createScope, r as maxSeqOf, s as collectDelivered } from "./supervisor-B-mmmiOU.js";
5
- import { i as workerFromBackend, s as supervisorAgent } from "./supervise-rEE46ruH.js";
6
- import { n as extractCodeBlock, t as assertAuthoredCode } from "./authored-code-C2TGxNtf.js";
7
- import { t as GraphEdgeCapError } from "./graph-ZDMygFIo.js";
8
- //#region src/runtime/graph/codemode.ts
9
- const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;
10
- /** The API doc the model is shown — generated from the grant, so the two cannot disagree. */
11
- function renderCodeApi(config) {
12
- return [
13
- "Write ONE async function body. It may call only these operations:",
14
- "",
15
- ...config.operations.map((operation) => ` ${operation.signature}\n // ${operation.description}`),
16
- "",
17
- "Return the result as the body's return value. No imports, no require, no process, no fetch.",
18
- "Reply with a single fenced code block and nothing else.",
19
- "",
20
- `TASK: ${config.task}`
21
- ].join("\n");
22
- }
23
- /**
24
- * A node that asks a model for a program and runs it. Declares the two effects it cannot supply
25
- * itself — `model` (who writes the code) and `codeRunner` (where it runs) — so the host owns both.
26
- */
27
- function codemodeKind() {
28
- return {
29
- id: "codemode",
30
- version: 1,
31
- description: "Ask a model for a program over a granted API, then run it as one node.",
32
- validateConfig: (raw, context) => {
33
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new ValidationError(`${context}: codemode config must be an object`);
34
- const config = raw;
35
- if (typeof config.task !== "string" || config.task.trim().length === 0) throw new ValidationError(`${context}: codemode config.task must be a non-empty string`);
36
- if (!Array.isArray(config.operations) || config.operations.length === 0) throw new ValidationError(`${context}: codemode config.operations must grant at least one operation`);
37
- const seen = /* @__PURE__ */ new Set();
38
- for (const operation of config.operations) {
39
- if (!IDENTIFIER.test(operation?.name ?? "")) throw new ValidationError(`${context}: operation name ${JSON.stringify(operation?.name)} is not a JS identifier`);
40
- if (seen.has(operation.name)) throw new ValidationError(`${context}: duplicate operation ${operation.name}`);
41
- seen.add(operation.name);
42
- if (typeof operation.call !== "function") throw new ValidationError(`${context}: operation ${operation.name} has no call`);
43
- }
44
- return {
45
- operations: config.operations,
46
- task: config.task,
47
- ...config.allowedImports === void 0 ? {} : { allowedImports: config.allowedImports }
48
- };
49
- },
50
- configSchema: {
51
- type: "object",
52
- properties: {
53
- task: { type: "string" },
54
- operations: { type: "array" }
55
- },
56
- required: ["task", "operations"]
57
- },
58
- inputs: [{
59
- name: "context",
60
- schema: {}
61
- }],
62
- outputs: [],
63
- effects: ["model", "codeRunner"],
64
- onCrash: "restart",
65
- budget: "metered",
66
- run: ({ config, profile, inputs, effects }) => {
67
- const author = effects.model;
68
- const runner = effects.codeRunner;
69
- let artifact;
70
- return {
71
- name: profile.name ?? "codemode",
72
- act: () => Promise.reject(new ValidationError("codemode: act() is not the execution path")),
73
- executorSpec: {
74
- profile,
75
- harness: null,
76
- executor: {
77
- runtime: "inline",
78
- async execute(task, signal) {
79
- const spends = [];
80
- const prompt = [
81
- renderCodeApi(config),
82
- inputs.context === void 0 ? "" : `\nCONTEXT: ${JSON.stringify(inputs.context)}`,
83
- typeof task === "string" && task.length > 0 ? `\n${task}` : ""
84
- ].filter((part) => part.length > 0).join("\n");
85
- const authored = await author.complete({
86
- prompt,
87
- profile,
88
- signal
89
- });
90
- if (authored.spend) spends.push(authored.spend);
91
- const code = extractCodeBlock(authored.text);
92
- assertAuthoredCode(code, {
93
- ...config.allowedImports === void 0 ? {} : { allowedImports: config.allowedImports },
94
- context: `codemode ${JSON.stringify(profile.name ?? "node")}`
95
- });
96
- const api = {};
97
- for (const operation of config.operations) api[operation.name] = async (...args) => {
98
- const result = await operation.call(...args);
99
- if (result?.spend) spends.push(result.spend);
100
- return result?.value;
101
- };
102
- const out = await runner.run({
103
- code,
104
- api: Object.freeze(api),
105
- signal
106
- });
107
- artifact = {
108
- outRef: contentAddress({ codemode: out }),
109
- out,
110
- spent: totalSpend(spends)
111
- };
112
- return artifact;
113
- },
114
- teardown: () => Promise.resolve({ destroyed: true }),
115
- resultArtifact: () => {
116
- if (!artifact) throw new ValidationError("codemode: resultArtifact() read before execute()");
117
- return artifact;
118
- }
119
- }
120
- }
121
- };
122
- }
123
- };
124
- }
125
- /** The node's spend is the model call plus every operation that reported one. An operation that
126
- * reports nothing is not assumed free — it contributes an UNKNOWN mark, like the kernel's own. */
127
- function totalSpend(parts) {
128
- return parts.reduce((total, part) => ({
129
- iterations: total.iterations + (part.iterations ?? 0),
130
- tokens: {
131
- input: total.tokens.input + (part.tokens?.input ?? 0),
132
- output: total.tokens.output + (part.tokens?.output ?? 0),
133
- ...part.tokens?.tokensKnown === false ? { tokensKnown: false } : {}
134
- },
135
- usd: total.usd + (part.usd ?? 0),
136
- ...part.usdKnown === false ? { usdKnown: false } : {},
137
- ms: total.ms + (part.ms ?? 0)
138
- }), {
139
- iterations: 1,
140
- tokens: {
141
- input: 0,
142
- output: 0
143
- },
144
- usd: 0,
145
- ms: 0
146
- });
147
- }
148
- /**
149
- * An in-process `codeRunner`: builds the authored body as a function with the granted API in
150
- * scope. **A development convenience, not a security boundary** — `assertAuthoredCode` is a lint,
151
- * and code running in this process can reach whatever the process can. Supply a jailed runner for
152
- * code you did not write.
153
- */
154
- function inlineCodeRunner() {
155
- return { async run({ code, api }) {
156
- const names = Object.keys(api);
157
- return new Function(...names, `"use strict"; return (async () => { ${code} })()`)(...names.map((name) => api[name]));
158
- } };
159
- }
160
- //#endregion
4
+ import { N as createBudgetPool, U as createExecutorRegistry, a as uncertainSpawnBudgets, i as sumMeasuredSpendFromEvents, l as runFinalizer, o as bestDelivered, p as createScope, r as maxSeqOf, s as collectDelivered } from "./supervisor-Dw-5mGKr.js";
5
+ import { i as workerFromBackend, s as supervisorAgent } from "./supervise-CnHd8x54.js";
6
+ import { t as assertAuthoredCode } from "./authored-code-DzYtiflw.js";
7
+ import { t as GraphEdgeCapError } from "./graph-CtMnqYYC.js";
161
8
  //#region src/runtime/graph/condition.ts
162
9
  /**
163
10
  * The ONE predicate tree: every guard in a graph — an edge `guard`, a filter projection's
@@ -1542,12 +1389,10 @@ async function openGraphRun(args) {
1542
1389
  seq: 0,
1543
1390
  at: new Date(runEpochMs).toISOString()
1544
1391
  });
1545
- const elapsed = () => args.now() - runEpochMs;
1546
1392
  const measured = resuming ? sumMeasuredSpendFromEvents([...prior]) : void 0;
1547
- const pool = createBudgetPool(rootBudget, elapsed, measured === void 0 ? void 0 : {
1393
+ const pool = createBudgetPool(rootBudget, runEpochMs, measured === void 0 ? {} : {
1548
1394
  committed: addSpend(measured.childWork, measured.driverInference),
1549
- uncertainReservations: uncertainSpawnBudgets([...prior]),
1550
- ...rootBudget.deadlineMs !== void 0 ? { absoluteDeadlineMs: runEpochMs + rootBudget.deadlineMs } : {}
1395
+ uncertainReservations: uncertainSpawnBudgets([...prior])
1551
1396
  });
1552
1397
  const abort = new AbortController();
1553
1398
  if (args.signal !== void 0) {
@@ -2226,6 +2071,6 @@ async function runGraphLoop(engine, compiled, task, options, wakes, onWakeSignal
2226
2071
  });
2227
2072
  }
2228
2073
  //#endregion
2229
- export { CONDITION_OPS, DEFAULT_MAX_NODE_VISITS, ENGINE_WOKEN_SEQ_BASE, JOIN_RULES, MAX_MAX_NODE_VISITS, RUN_GRAPH_ROOT_KIND, admitPayload, agentKind, applyGraphFoldEvent, applyProjection, assembleGraphResult, assertAuthoredCode, codemodeKind, compileGraph, createEdgeLedger, createGraphEngine, createGraphRun, createRegistry, decideJoin, emptyFoldState, evaluateCondition, extractCodeBlock, foldGraphJournal, formatRegistryHandle, graphFromRunGraph, inlineCodeRunner, isEngineFired, isSuspensionRequest, kindHandle, materializeSettles, mintSuspensionToken, narrowEffects, openGraphRun, parseRegistryHandle, renderCodeApi, runEngineGraph, schemaAccepts, scriptKind, subgraphKind, supervisorKind, suspended, suspensionNodeId, tokenFromSuspensionNodeId, validateCondition, validateNodeKind, validateProjection };
2074
+ export { CONDITION_OPS, DEFAULT_MAX_NODE_VISITS, ENGINE_WOKEN_SEQ_BASE, JOIN_RULES, MAX_MAX_NODE_VISITS, RUN_GRAPH_ROOT_KIND, admitPayload, agentKind, applyGraphFoldEvent, applyProjection, assembleGraphResult, assertAuthoredCode, compileGraph, createEdgeLedger, createGraphEngine, createGraphRun, createRegistry, decideJoin, emptyFoldState, evaluateCondition, foldGraphJournal, formatRegistryHandle, graphFromRunGraph, isEngineFired, isSuspensionRequest, kindHandle, materializeSettles, mintSuspensionToken, narrowEffects, openGraphRun, parseRegistryHandle, runEngineGraph, schemaAccepts, scriptKind, subgraphKind, supervisorKind, suspended, suspensionNodeId, tokenFromSuspensionNodeId, validateCondition, validateNodeKind, validateProjection };
2230
2075
 
2231
2076
  //# sourceMappingURL=graph.js.map