@tangle-network/agent-runtime 0.48.0 → 0.50.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 (51) hide show
  1. package/README.md +79 -15
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/{chunk-656G2XCL.js → chunk-BKAIVNFA.js} +3 -3
  6. package/dist/{chunk-IW2LMLK6.js → chunk-CM2IK7VS.js} +913 -152
  7. package/dist/chunk-CM2IK7VS.js.map +1 -0
  8. package/dist/{chunk-VR4JIC5H.js → chunk-ML4IXGTV.js} +2 -2
  9. package/dist/{chunk-TJS7S3HJ.js → chunk-NDM5VXZW.js} +19 -8
  10. package/dist/chunk-NDM5VXZW.js.map +1 -0
  11. package/dist/chunk-OM3YNZIW.js +978 -0
  12. package/dist/chunk-OM3YNZIW.js.map +1 -0
  13. package/dist/{chunk-JNPK46YH.js → chunk-RHW75JW5.js} +498 -350
  14. package/dist/chunk-RHW75JW5.js.map +1 -0
  15. package/dist/{coder-CVZNGbyg.d.ts → coder-_YCf3BAK.d.ts} +2 -2
  16. package/dist/{driver-DYU2sgHr.d.ts → driver-DLI1io57.d.ts} +1 -1
  17. package/dist/index.d.ts +34 -9
  18. package/dist/index.js +117 -27
  19. package/dist/index.js.map +1 -1
  20. package/dist/kb-gate-CHAyt4aI.d.ts +1571 -0
  21. package/dist/{loop-runner-bin-DEm4roYF.d.ts → loop-runner-bin-DFUNgpeK.d.ts} +4 -4
  22. package/dist/loop-runner-bin.d.ts +5 -5
  23. package/dist/loop-runner-bin.js +3 -3
  24. package/dist/loops.d.ts +6 -6
  25. package/dist/loops.js +17 -1
  26. package/dist/mcp/bin.js +206 -29
  27. package/dist/mcp/bin.js.map +1 -1
  28. package/dist/mcp/index.d.ts +41 -177
  29. package/dist/mcp/index.js +40 -6
  30. package/dist/mcp/index.js.map +1 -1
  31. package/dist/openai-tools-D4HLDWgw.d.ts +45 -0
  32. package/dist/platform.js +2 -2
  33. package/dist/platform.js.map +1 -1
  34. package/dist/profiles.d.ts +2 -2
  35. package/dist/{run-loop-DvD4aGiE.d.ts → run-loop-BIineL1T.d.ts} +1 -1
  36. package/dist/runtime.d.ts +403 -24
  37. package/dist/runtime.js +17 -1
  38. package/dist/{types-BpDfCPUp.d.ts → types-5MGt5KTY.d.ts} +1 -1
  39. package/dist/{types-nBMuollC.d.ts → types-BEQsBhOE.d.ts} +1 -1
  40. package/dist/workflow.d.ts +2 -2
  41. package/dist/workflow.js +1 -1
  42. package/package.json +6 -5
  43. package/dist/chunk-IW2LMLK6.js.map +0 -1
  44. package/dist/chunk-JNPK46YH.js.map +0 -1
  45. package/dist/chunk-LX66I3SC.js +0 -218
  46. package/dist/chunk-LX66I3SC.js.map +0 -1
  47. package/dist/chunk-TJS7S3HJ.js.map +0 -1
  48. package/dist/kb-gate-51BlLlVM.d.ts +0 -529
  49. package/dist/otel-export-EzfsVUhh.d.ts +0 -191
  50. /package/dist/{chunk-656G2XCL.js.map → chunk-BKAIVNFA.js.map} +0 -0
  51. /package/dist/{chunk-VR4JIC5H.js.map → chunk-ML4IXGTV.js.map} +0 -0
@@ -1,191 +0,0 @@
1
- import { d as OpenAIChatTool } from './types-nBMuollC.js';
2
-
3
- /**
4
- * @experimental
5
- *
6
- * OpenAI Chat Completions `tools[]` projection of the 5 agent-runtime MCP
7
- * delegation tools.
8
- *
9
- * Use when configuring `createOpenAICompatibleBackend({ tools: ... })` so the
10
- * model can call `delegate_code`, `delegate_research`, `delegate_feedback`,
11
- * `delegation_status`, and `delegation_history` through the OpenAI-compat
12
- * transport (tcloud, OpenRouter, OpenAI direct, cli-bridge). The runtime
13
- * surfaces tool calls as `tool_call` stream events — execution is the
14
- * caller's responsibility (typically the parent sandbox runtime's MCP
15
- * mount).
16
- *
17
- * Sandbox-SDK callers do NOT need this helper: the sandbox runtime mounts
18
- * MCP servers natively and the in-sandbox harness discovers tools via the
19
- * runtime, not via an OpenAI tools array.
20
- *
21
- * Tool name + description + JSON-schema are pulled from the canonical
22
- * `DELEGATE_*` constants exported by `./tools/*` so the projection cannot
23
- * drift from the server's own validators.
24
- */
25
-
26
- /**
27
- * @experimental
28
- *
29
- * Returns the 5 delegation tools projected into OpenAI Chat Completions
30
- * `tools[]` shape. The order is stable: `delegate_code`,
31
- * `delegate_research`, `delegate_feedback`, `delegation_status`,
32
- * `delegation_history`.
33
- */
34
- declare function mcpToolsForRuntimeMcp(): OpenAIChatTool[];
35
- /**
36
- * @experimental
37
- *
38
- * Subset filter — return only the projected tools whose `function.name`
39
- * appears in `names`. Useful for curated mounts (e.g. only the queue-bound
40
- * delegation tools, omitting `delegate_feedback`). Unknown names are
41
- * silently ignored; pass an empty array to get an empty result.
42
- */
43
- declare function mcpToolsForRuntimeMcpSubset(names: ReadonlyArray<string>): OpenAIChatTool[];
44
-
45
- /**
46
- * OTEL span exporter — streams LoopTraceEvents to an OTLP/HTTP collector.
47
- *
48
- * Reads OTEL_EXPORTER_OTLP_ENDPOINT + OTEL_EXPORTER_OTLP_HEADERS from env
49
- * when no explicit config is given. Keeps the runtime dep-free from
50
- * @opentelemetry/sdk-trace-base — minimal OTLP/JSON serializer.
51
- *
52
- * The exporter accepts both raw OtelSpan objects and LoopTraceEvents
53
- * (which get converted to OTLP spans automatically).
54
- */
55
- interface OtelExportConfig {
56
- /** OTLP endpoint. Reads OTEL_EXPORTER_OTLP_ENDPOINT env by default. */
57
- endpoint?: string;
58
- /** OTLP headers. Reads OTEL_EXPORTER_OTLP_HEADERS env by default. */
59
- headers?: Record<string, string>;
60
- /** Batch size before flush. Default 64. */
61
- batchSize?: number;
62
- /** Flush interval ms. Default 5000. */
63
- flushIntervalMs?: number;
64
- /** Resource attributes stamped on every export. */
65
- resourceAttributes?: Record<string, string | number | boolean>;
66
- /** Service name. Default 'agent-runtime'. */
67
- serviceName?: string;
68
- }
69
- interface OtelExporter {
70
- /** Export a span. */
71
- exportSpan(span: OtelSpan): void;
72
- /** Force flush pending spans. */
73
- flush(): Promise<void>;
74
- /** Shutdown cleanly. */
75
- shutdown(): Promise<void>;
76
- }
77
- interface OtelSpan {
78
- traceId: string;
79
- spanId: string;
80
- parentSpanId?: string;
81
- name: string;
82
- kind?: number;
83
- startTimeUnixNano: string;
84
- endTimeUnixNano: string;
85
- attributes?: OtelAttribute[];
86
- status?: {
87
- code: number;
88
- message?: string;
89
- };
90
- }
91
- interface OtelAttribute {
92
- key: string;
93
- value: {
94
- stringValue?: string;
95
- intValue?: string;
96
- doubleValue?: number;
97
- boolValue?: boolean;
98
- };
99
- }
100
- /**
101
- * Create an OTEL exporter. Returns undefined when no endpoint is configured.
102
- */
103
- declare function createOtelExporter(config?: OtelExportConfig): OtelExporter | undefined;
104
- /**
105
- * Convert a LoopTraceEvent into an OtelSpan for export.
106
- */
107
- declare function loopEventToOtelSpan(event: {
108
- kind: string;
109
- runId: string;
110
- timestamp: number;
111
- payload: object;
112
- }, traceId: string, parentSpanId?: string): OtelSpan;
113
- /**
114
- * Build a nested, real-duration OTLP span tree for ONE loop run from its full
115
- * ordered `LoopTraceEvent` stream. Unlike `loopEventToOtelSpan` (one flat,
116
- * zero-duration span per event), this reconstructs the topology hierarchy a
117
- * GenAI trace viewer renders natively:
118
- *
119
- * loop (invoke_workflow)
120
- * └─ loop.round[k] (invoke_workflow) ← tangle.loop.move.{kind,width,rationale}
121
- * ├─ loop.iteration[i] (invoke_agent) ← gen_ai.agent.name + usage + verdict + placement
122
- * └─ …
123
- *
124
- * Attributes follow the current GenAI semconv (`gen_ai.*`) where they apply and
125
- * a namespaced `tangle.loop.*` / `tangle.cost.usd` extension for topology /
126
- * verdict / placement / cost (not yet standardized). Pure: feed it a buffered
127
- * per-runId event array (e.g. flushed on `loop.ended`) and export the result.
128
- */
129
- declare function buildLoopOtelSpans(events: ReadonlyArray<{
130
- kind: string;
131
- runId: string;
132
- timestamp: number;
133
- payload: object;
134
- }>, traceId: string, rootParentSpanId?: string): OtelSpan[];
135
- /** Wire version the eval-runs ingest enforces (X-Tangle-Wire-Version + body). */
136
- declare const INTELLIGENCE_WIRE_VERSION = "2026-05-26.v1";
137
- interface EvalRunGeneration {
138
- /** 0-based ordinal of this generation within the run (required by ingest). */
139
- index: number;
140
- /** Identity of the proposed surface change (content-addressed hash). */
141
- surfaceHash: string;
142
- /** Arbitrary provenance for this generation (rationale, evidence, source). */
143
- surface?: unknown;
144
- /** Per-scenario results; empty until the generation is measured. */
145
- cells?: unknown[];
146
- /** Mean composite score (0 when unmeasured — pair with labels.measured). */
147
- compositeMean: number;
148
- costUsd: number;
149
- durationMs: number;
150
- }
151
- interface EvalRunEvent {
152
- runId: string;
153
- runDir: string;
154
- /** ISO timestamp. */
155
- timestamp: string;
156
- status: 'started' | 'baseline-complete' | 'generation-complete' | 'gate-decided' | 'finished' | 'errored';
157
- labels?: Record<string, string>;
158
- baseline?: EvalRunGeneration;
159
- generations?: EvalRunGeneration[];
160
- gateDecision?: 'ship' | 'hold' | 'need_more_work' | 'model_ceiling' | 'arch_ceiling';
161
- holdoutLift?: number;
162
- totalCostUsd: number;
163
- totalDurationMs: number;
164
- errorMessage?: string;
165
- }
166
- interface EvalRunsExportConfig {
167
- /** Bearer key — tenant is resolved server-side from it. Reads TANGLE_API_KEY. */
168
- apiKey?: string;
169
- /** Intelligence base. Reads INTELLIGENCE_BASE env, else prod. */
170
- base?: string;
171
- /** Idempotency-Key header (e.g. the runId) — safe retries + upsert. */
172
- idempotencyKey?: string;
173
- }
174
- interface EvalRunsExportResult {
175
- ok: boolean;
176
- status: number;
177
- accepted: number;
178
- rejected: Array<{
179
- index: number;
180
- reason: string;
181
- }>;
182
- }
183
- /**
184
- * Ship self-improvement eval-run events to Tangle Intelligence. Unlike the
185
- * best-effort span exporter, this RESOLVES with the ingest verdict (accepted /
186
- * rejected per event) so a consumer's loop can assert its provenance landed.
187
- * Throws only on a missing key or network failure.
188
- */
189
- declare function exportEvalRuns(events: EvalRunEvent[], config?: EvalRunsExportConfig): Promise<EvalRunsExportResult>;
190
-
191
- export { type EvalRunEvent as E, INTELLIGENCE_WIRE_VERSION as I, type OtelExporter as O, mcpToolsForRuntimeMcpSubset as a, type EvalRunGeneration as b, type EvalRunsExportConfig as c, type EvalRunsExportResult as d, type OtelAttribute as e, type OtelExportConfig as f, type OtelSpan as g, buildLoopOtelSpans as h, createOtelExporter as i, exportEvalRuns as j, loopEventToOtelSpan as l, mcpToolsForRuntimeMcp as m };