@tangle-network/agent-runtime 0.52.0 → 0.54.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 (74) hide show
  1. package/README.md +27 -16
  2. package/dist/agent.d.ts +2 -2
  3. package/dist/agent.js +5 -3
  4. package/dist/agent.js.map +1 -1
  5. package/dist/analyst-loop.d.ts +1 -1
  6. package/dist/analyst-loop.js +2 -2
  7. package/dist/{chunk-COAVO6QB.js → chunk-2BDXWZUC.js} +5 -34
  8. package/dist/chunk-2BDXWZUC.js.map +1 -0
  9. package/dist/chunk-A73RADPB.js +281 -0
  10. package/dist/chunk-A73RADPB.js.map +1 -0
  11. package/dist/chunk-FRBWCJLP.js +396 -0
  12. package/dist/chunk-FRBWCJLP.js.map +1 -0
  13. package/dist/chunk-GRAGM4MC.js +72 -0
  14. package/dist/chunk-GRAGM4MC.js.map +1 -0
  15. package/dist/{chunk-2OU7ZQPD.js → chunk-JTH2FPCK.js} +3248 -456
  16. package/dist/chunk-JTH2FPCK.js.map +1 -0
  17. package/dist/{chunk-V2K35HF2.js → chunk-KJH62YEK.js} +2 -2
  18. package/dist/{chunk-HNUXAZIJ.js → chunk-P5OKDSLB.js} +2 -2
  19. package/dist/{chunk-GSUO5QS6.js → chunk-VLF5RHEQ.js} +2 -5
  20. package/dist/{chunk-GSUO5QS6.js.map → chunk-VLF5RHEQ.js.map} +1 -1
  21. package/dist/{chunk-7JITYN6T.js → chunk-XRYEZPR6.js} +18 -2
  22. package/dist/chunk-XRYEZPR6.js.map +1 -0
  23. package/dist/{coder-_YCf3BAK.d.ts → coder-CEkUFv8h.d.ts} +1 -1
  24. package/dist/{types-5MGt5KTY.d.ts → coordination-BMzskrUR.d.ts} +268 -2
  25. package/dist/{kb-gate-CHAyt4aI.d.ts → delegates-BPLIl8EC.d.ts} +491 -566
  26. package/dist/{delegation-profile-1GbW5yA3.d.ts → delegation-profile-Bvfro2m1.d.ts} +28 -2
  27. package/dist/index.d.ts +7 -7
  28. package/dist/index.js +25 -80
  29. package/dist/index.js.map +1 -1
  30. package/dist/intelligence.d.ts +475 -5
  31. package/dist/intelligence.js +547 -3
  32. package/dist/intelligence.js.map +1 -1
  33. package/dist/kb-gate-CuzMYGYM.d.ts +76 -0
  34. package/dist/{loop-runner-bin-DFUNgpeK.d.ts → loop-runner-bin-BGpVVyXp.d.ts} +6 -27
  35. package/dist/loop-runner-bin.d.ts +5 -5
  36. package/dist/loop-runner-bin.js +6 -5
  37. package/dist/loops.d.ts +8 -5
  38. package/dist/loops.js +32 -8
  39. package/dist/mcp/bin.js +94 -30
  40. package/dist/mcp/bin.js.map +1 -1
  41. package/dist/mcp/index.d.ts +10 -273
  42. package/dist/mcp/index.js +45 -365
  43. package/dist/mcp/index.js.map +1 -1
  44. package/dist/{openai-tools-D4HLDWgw.d.ts → openai-tools-CoeLQ7Uo.d.ts} +1 -1
  45. package/dist/profiles.d.ts +2 -2
  46. package/dist/profiles.js +4 -4
  47. package/dist/router-client-30Y_pca8.d.ts +120 -0
  48. package/dist/{run-loop-BIineL1T.d.ts → run-loop-DluzfJ2h.d.ts} +1 -1
  49. package/dist/runtime.d.ts +429 -131
  50. package/dist/runtime.js +32 -8
  51. package/dist/topology.d.ts +54 -1
  52. package/dist/topology.js +222 -0
  53. package/dist/topology.js.map +1 -1
  54. package/dist/{types-BEQsBhOE.d.ts → types-C8rNlxfV.d.ts} +6 -5
  55. package/dist/workflow.d.ts +2 -2
  56. package/dist/workflow.js +4 -2
  57. package/dist/workflow.js.map +1 -1
  58. package/package.json +5 -5
  59. package/skills/agent-runtime-adoption/SKILL.md +54 -46
  60. package/skills/build-with-agent-runtime/SKILL.md +12 -8
  61. package/skills/loop-writer/SKILL.md +9 -1
  62. package/skills/supervise/SKILL.md +24 -0
  63. package/dist/chunk-2OU7ZQPD.js.map +0 -1
  64. package/dist/chunk-4JI4BCBI.js +0 -623
  65. package/dist/chunk-4JI4BCBI.js.map +0 -1
  66. package/dist/chunk-7JITYN6T.js.map +0 -1
  67. package/dist/chunk-7SP2OVYZ.js +0 -908
  68. package/dist/chunk-7SP2OVYZ.js.map +0 -1
  69. package/dist/chunk-BERLUBAP.js +0 -1356
  70. package/dist/chunk-BERLUBAP.js.map +0 -1
  71. package/dist/chunk-COAVO6QB.js.map +0 -1
  72. package/dist/driver-DLI1io57.d.ts +0 -221
  73. /package/dist/{chunk-V2K35HF2.js.map → chunk-KJH62YEK.js.map} +0 -0
  74. /package/dist/{chunk-HNUXAZIJ.js.map → chunk-P5OKDSLB.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { AgentProfileFileMount, AgentProfileMcpServer, AgentProfile } from '@tangle-network/sandbox';
1
+ import { AgentProfileFileMount, AgentProfile, AgentSubagentProfile, AgentProfileMcpServer } from '@tangle-network/sandbox';
2
2
 
3
3
  /**
4
4
  * Production-profile composition for the agent-runtime delegation MCP.
@@ -17,6 +17,11 @@ import { AgentProfileFileMount, AgentProfileMcpServer, AgentProfile } from '@tan
17
17
  * authenticate on startup. No static profile entry, ever.
18
18
  */
19
19
 
20
+ /** One hook command entry. The SDK declares `AgentProfile.hooks` as
21
+ * `Record<string, AgentProfileHookCommand[]>` but does not re-export the element
22
+ * type from the package entry, so derive it from `AgentProfile` by indexed
23
+ * access — the single source of truth, no drift from the SDK shape. */
24
+ type AgentProfileHookCommand = NonNullable<AgentProfile['hooks']>[string][number];
20
25
  /** MCP server key under which the agent-runtime delegation tools mount. */
21
26
  declare const DELEGATION_MCP_SERVER_KEY = "agent-runtime-delegation";
22
27
  interface BuildDelegationMcpServerOptions {
@@ -53,6 +58,22 @@ interface ComposeProductionAgentProfileOptions {
53
58
  name?: string;
54
59
  /** Environment source for key + OTEL resolution. Defaults to `process.env`. */
55
60
  env?: Record<string, string | undefined>;
61
+ /** Box built-in tool ON/OFF flags merged over the base profile's `tools`
62
+ * (overlay wins per key). The sandbox-seam mapping of a certified surface's
63
+ * tool grants — `AgentProfile.tools` is `Record<string, boolean>` box flags,
64
+ * so it carries grants, not arbitrary tool defs. */
65
+ tools?: Record<string, boolean>;
66
+ /** Per-event hook commands merged over the base profile's `hooks`. An event
67
+ * present in both has the extra commands appended after the base ones. */
68
+ hooks?: Record<string, AgentProfileHookCommand[]>;
69
+ /** Subagent definitions merged over the base profile's `subagents` (overlay
70
+ * wins per key). */
71
+ subagents?: Record<string, AgentSubagentProfile>;
72
+ /** Resolved certified MCP connections injected into `AgentProfile.mcp` — the
73
+ * sandbox-seam delivery of a `ResolvedSurface.mcpConnections`. Merged after
74
+ * the base map and before the delegation entry, so a base/delegation key is
75
+ * never silently shadowed by an injected one. */
76
+ mcpConnections?: Record<string, AgentProfileMcpServer>;
56
77
  }
57
78
  /**
58
79
  * Compose the production `AgentProfile`: the canonical base profile with the
@@ -61,9 +82,14 @@ interface ComposeProductionAgentProfileOptions {
61
82
  * the scorecard profile hash reflects the actual production profile.
62
83
  *
63
84
  * Merge rules:
64
- * - `mcp`: base map preserved; the delegation entry is appended under
85
+ * - `mcp`: base map preserved; `options.mcpConnections` (resolved certified
86
+ * servers) merged over it; the delegation entry is appended last under
65
87
  * {@link DELEGATION_MCP_SERVER_KEY}, and omitted entirely when no sandbox
66
88
  * API key resolves.
89
+ * - `tools`: base box-flags map preserved; `options.tools` overlaid per key.
90
+ * - `hooks`: per event, base commands preserved; `options.hooks[event]`
91
+ * appended after the base ones.
92
+ * - `subagents`: base map preserved; `options.subagents` overlaid per key.
67
93
  * - `prompt.systemPrompt`: replaced when `options.systemPrompt` is set.
68
94
  * - `resources.files`: `options.extraFiles` concatenated after base files.
69
95
  * - `name`: replaced when `options.name` is set.
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { AgentProfile, AgentEvalError, KnowledgeReadinessReport, RunRecord, ControlEvalResult, KnowledgeRequirement } from '@tangle-network/agent-eval';
2
2
  export { AgentEvalError, AgentEvalErrorCode, ConfigError, ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, JudgeError, KnowledgeReadinessReport, KnowledgeRequirement, NotFoundError, RunRecord, ValidationError } from '@tangle-network/agent-eval';
3
- import { h as AgentBackendInput, i as AgentExecutionBackend, c as OpenAIChatTool, j as OpenAIChatToolChoice, k as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, l as RunAgentTaskOptions, m as AgentTaskRunResult, n as RunAgentTaskStreamOptions, o as AgentRuntimeEvent, p as AgentTaskStatus, q as RuntimeSessionStore, r as RuntimeSession } from './types-BEQsBhOE.js';
4
- export { s as AgentAdapter, t as AgentKnowledgeProvider, u as AgentRuntimeEventSink, v as AgentTaskContext, w as AgentTaskSpec, B as BackendErrorDetail, x as RuntimeRunHandle, y as RuntimeRunPersistenceAdapter, z as RuntimeRunRow, C as startRuntimeRun } from './types-BEQsBhOE.js';
3
+ import { h as AgentBackendInput, i as AgentExecutionBackend, c as OpenAIChatTool, j as OpenAIChatToolChoice, k as AgentBackendContext, R as RuntimeStreamEvent, K as KnowledgeReadinessDecision, l as RunAgentTaskOptions, m as AgentTaskRunResult, n as RunAgentTaskStreamOptions, o as AgentRuntimeEvent, p as AgentTaskStatus, q as RuntimeSessionStore, r as RuntimeSession } from './types-C8rNlxfV.js';
4
+ export { s as AgentAdapter, t as AgentKnowledgeProvider, u as AgentRuntimeEventSink, v as AgentTaskContext, w as AgentTaskSpec, B as BackendErrorDetail, x as RuntimeRunHandle, y as RuntimeRunPersistenceAdapter, z as RuntimeRunRow, C as startRuntimeRun } from './types-C8rNlxfV.js';
5
5
  import { Scenario, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
6
- export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, e as DynamicLoopRunnerOptions, L as LoopRunnerCliArgs, f as LoopRunnerCliResult, R as ResearchLoopResult, g as ResearchLoopRunnerOptions, h as RunDelegatedLoopOptions, V as VetoedFact, i as auditLoopRunner, j as coderLoopRunner, k as dynamicLoopRunner, l as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, m as reviewLoopRunner, n as runDelegatedLoop, o as runLoopRunnerCli, s as selfImproveLoopRunner } from './loop-runner-bin-DFUNgpeK.js';
7
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-D4HLDWgw.js';
8
- export { aD as EvalRunEvent, aE as EvalRunGeneration, aF as EvalRunsExportConfig, aG as EvalRunsExportResult, aH as INTELLIGENCE_WIRE_VERSION, aI as LoopSpanNode, aJ as OtelAttribute, aK as OtelExportConfig, aL as OtelExporter, aM as OtelSpan, aN as buildLoopOtelSpans, aO as buildLoopSpanNodes, aP as createOtelExporter, aQ as exportEvalRuns, aR as loopEventToOtelSpan } from './kb-gate-CHAyt4aI.js';
6
+ export { C as CoderLoopRunnerOptions, D as DELEGATED_LOOP_MODES, a as DelegatedLoopMode, b as DelegatedLoopRegistry, c as DelegatedLoopResult, d as DelegatedLoopRunner, L as LoopRunnerCliArgs, e as LoopRunnerCliResult, R as ResearchLoopResult, f as ResearchLoopRunnerOptions, g as RunDelegatedLoopOptions, V as VetoedFact, h as auditLoopRunner, i as coderLoopRunner, j as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, k as reviewLoopRunner, l as runDelegatedLoop, m as runLoopRunnerCli, s as selfImproveLoopRunner } from './loop-runner-bin-BGpVVyXp.js';
7
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-CoeLQ7Uo.js';
8
+ export { ax as EvalRunEvent, ay as EvalRunGeneration, az as EvalRunsExportConfig, aA as EvalRunsExportResult, aB as INTELLIGENCE_WIRE_VERSION, aC as LoopSpanNode, aD as OtelAttribute, aE as OtelExportConfig, aF as OtelExporter, aG as OtelSpan, aH as buildLoopOtelSpans, aI as buildLoopSpanNodes, aJ as createOtelExporter, aK as exportEvalRuns, aL as loopEventToOtelSpan } from './delegates-BPLIl8EC.js';
9
9
  import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
10
10
  export { b as RuntimeDecisionEvidenceRef, c as RuntimeDecisionKind, d as RuntimeDecisionPoint, e as RuntimeHookContext, f as RuntimeHookErrorContext, a as RuntimeHookEvent, g as RuntimeHookPhase, h as RuntimeHookTarget, i as composeRuntimeHooks, j as defineRuntimeHooks, n as notifyRuntimeDecisionPoint, k as notifyRuntimeHookEvent } from './runtime-hooks-C7JwKb9E.js';
11
11
  import '@tangle-network/sandbox';
12
12
  import '@tangle-network/agent-eval/contract';
13
13
  import './types-p8dWBIXL.js';
14
- import './coder-_YCf3BAK.js';
15
- import './driver-DLI1io57.js';
14
+ import './kb-gate-CuzMYGYM.js';
15
+ import './coder-CEkUFv8h.js';
16
16
  import './substrate-CUgk7F7s.js';
17
17
 
18
18
  /**
package/dist/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  import {
2
2
  mcpToolsForRuntimeMcp,
3
3
  mcpToolsForRuntimeMcpSubset
4
- } from "./chunk-V2K35HF2.js";
5
- import "./chunk-BERLUBAP.js";
4
+ } from "./chunk-KJH62YEK.js";
5
+ import {
6
+ DEFAULT_ROUTER_BASE_URL,
7
+ cleanModelId,
8
+ getModels,
9
+ resolveChatModel,
10
+ resolveRouterBaseUrl,
11
+ validateChatModelId
12
+ } from "./chunk-GRAGM4MC.js";
6
13
  import {
7
14
  DELEGATED_LOOP_MODES,
8
15
  auditLoopRunner,
9
16
  coderLoopRunner,
10
- dynamicLoopRunner,
11
17
  isDelegatedLoopMode,
12
18
  parseLoopRunnerArgv,
13
19
  researchLoopRunner,
@@ -15,25 +21,18 @@ import {
15
21
  runDelegatedLoop,
16
22
  runLoopRunnerCli,
17
23
  selfImproveLoopRunner
18
- } from "./chunk-COAVO6QB.js";
24
+ } from "./chunk-2BDXWZUC.js";
19
25
  import "./chunk-FNMGYYSS.js";
20
- import "./chunk-4JI4BCBI.js";
26
+ import "./chunk-A73RADPB.js";
21
27
  import "./chunk-KADIJAD4.js";
22
- import "./chunk-HNUXAZIJ.js";
23
- import {
24
- INTELLIGENCE_WIRE_VERSION,
25
- buildLoopOtelSpans,
26
- buildLoopSpanNodes,
27
- createOtelExporter,
28
- exportEvalRuns,
29
- loopEventToOtelSpan
30
- } from "./chunk-G3RGMA7C.js";
28
+ import "./chunk-P5OKDSLB.js";
31
29
  import {
32
30
  composeRuntimeHooks,
33
31
  defineRuntimeHooks,
34
32
  notifyRuntimeDecisionPoint,
35
33
  notifyRuntimeHookEvent
36
- } from "./chunk-2OU7ZQPD.js";
34
+ } from "./chunk-JTH2FPCK.js";
35
+ import "./chunk-WIR4HOOJ.js";
37
36
  import {
38
37
  AgentEvalError,
39
38
  BackendTransportError,
@@ -44,7 +43,15 @@ import {
44
43
  RuntimeRunStateError,
45
44
  SessionMismatchError,
46
45
  ValidationError
47
- } from "./chunk-GSUO5QS6.js";
46
+ } from "./chunk-VLF5RHEQ.js";
47
+ import {
48
+ INTELLIGENCE_WIRE_VERSION,
49
+ buildLoopOtelSpans,
50
+ buildLoopSpanNodes,
51
+ createOtelExporter,
52
+ exportEvalRuns,
53
+ loopEventToOtelSpan
54
+ } from "./chunk-G3RGMA7C.js";
48
55
  import "./chunk-DGUM43GV.js";
49
56
 
50
57
  // src/sessions.ts
@@ -351,6 +358,7 @@ function mapCommonBackendEvent(event, context) {
351
358
  proposalId,
352
359
  title: stringValue(data.title) ?? stringValue(record.title) ?? proposalId,
353
360
  status: status === "pending" || status === "approved" || status === "rejected" ? status : void 0,
361
+ content: stringValue(data.content) ?? stringValue(data.body) ?? stringValue(record.content),
354
362
  timestamp: nowIso()
355
363
  };
356
364
  }
@@ -1860,69 +1868,6 @@ function deriveExecutionId(input) {
1860
1868
  return `${input.projectId}:${input.sessionId}:${input.turnIndex}`;
1861
1869
  }
1862
1870
 
1863
- // src/model-resolution.ts
1864
- var DEFAULT_ROUTER_BASE_URL = "https://router.tangle.tools";
1865
- function resolveRouterBaseUrl(env = {}) {
1866
- return (env.TANGLE_ROUTER_URL ?? env.TANGLE_ROUTER_BASE_URL ?? DEFAULT_ROUTER_BASE_URL).replace(/\/v1\/?$/, "").replace(/\/$/, "");
1867
- }
1868
- async function getModels(routerBaseUrl = DEFAULT_ROUTER_BASE_URL) {
1869
- const res = await fetch(`${routerBaseUrl}/v1/models`, {
1870
- headers: { Accept: "application/json" }
1871
- });
1872
- if (!res.ok) throw new Error(`router /v1/models ${res.status}`);
1873
- const body = await res.json();
1874
- return Array.isArray(body.data) ? body.data : [];
1875
- }
1876
- function cleanModelId(value) {
1877
- if (typeof value !== "string") return void 0;
1878
- const trimmed = value.trim();
1879
- return trimmed.length > 0 ? trimmed : void 0;
1880
- }
1881
- function resolveChatModel(candidates, fallback) {
1882
- for (const candidate of candidates) {
1883
- const model = cleanModelId(candidate.model);
1884
- if (model) return { source: candidate.source, model };
1885
- }
1886
- return fallback;
1887
- }
1888
- var WELL_FORMED_MODEL_ID = /^[A-Za-z0-9._/@:-]+$/;
1889
- function isWellFormedModelId(modelId) {
1890
- return modelId.length <= 200 && WELL_FORMED_MODEL_ID.test(modelId);
1891
- }
1892
- function catalogIdsForModel(model) {
1893
- const ids = /* @__PURE__ */ new Set();
1894
- const id = cleanModelId(model.id);
1895
- if (id) ids.add(id);
1896
- const provider = cleanModelId(model._provider) ?? cleanModelId(model.provider);
1897
- if (provider && id && !id.includes("/")) ids.add(`${provider}/${id}`);
1898
- return [...ids];
1899
- }
1900
- async function validateChatModelId(modelId, options = {}) {
1901
- const {
1902
- allowlist = [],
1903
- routerBaseUrl = DEFAULT_ROUTER_BASE_URL,
1904
- loadModels = getModels
1905
- } = options;
1906
- const cleaned = cleanModelId(modelId);
1907
- if (!cleaned) return { succeeded: false, error: "Model id must be a non-empty string." };
1908
- if (!isWellFormedModelId(cleaned)) {
1909
- return { succeeded: false, error: `Model id is malformed: ${cleaned}` };
1910
- }
1911
- if (allowlist.some((id) => cleanModelId(id) === cleaned)) {
1912
- return { succeeded: true, value: cleaned };
1913
- }
1914
- let catalog;
1915
- try {
1916
- catalog = await loadModels(routerBaseUrl);
1917
- } catch (err) {
1918
- const message = err instanceof Error ? err.message : String(err);
1919
- return { succeeded: false, error: `Could not validate model catalog: ${message}` };
1920
- }
1921
- const ids = new Set(catalog.flatMap(catalogIdsForModel));
1922
- if (!ids.has(cleaned)) return { succeeded: false, error: `Model is not available: ${cleaned}` };
1923
- return { succeeded: true, value: cleaned };
1924
- }
1925
-
1926
1871
  // src/readiness.ts
1927
1872
  var DEFAULT_MINIMUM_READINESS_SCORE = 0.7;
1928
1873
  function decideKnowledgeReadiness(report, options = {}) {
@@ -2604,6 +2549,7 @@ function sanitizeRuntimeStreamEvent(event, options = {}) {
2604
2549
  timestamp: event.timestamp,
2605
2550
  proposalId: event.proposalId,
2606
2551
  title: options.includeControlPayloads ? event.title : void 0,
2552
+ content: options.includeControlPayloads ? event.content : void 0,
2607
2553
  status: event.status
2608
2554
  };
2609
2555
  }
@@ -3367,7 +3313,6 @@ export {
3367
3313
  defineConversation,
3368
3314
  defineRuntimeHooks,
3369
3315
  deriveExecutionId,
3370
- dynamicLoopRunner,
3371
3316
  exportEvalRuns,
3372
3317
  getModels,
3373
3318
  handleChatTurn,