@tangle-network/agent-runtime 0.79.3 → 0.80.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 (48) hide show
  1. package/README.md +54 -325
  2. package/dist/agent.js +5 -5
  3. package/dist/analyst-loop.js +2 -2
  4. package/dist/{chunk-VMNEQHJR.js → chunk-3X53HYRW.js} +17 -2
  5. package/dist/chunk-3X53HYRW.js.map +1 -0
  6. package/dist/{chunk-T2HVQVB4.js → chunk-4J6RBI3K.js} +15 -1
  7. package/dist/chunk-4J6RBI3K.js.map +1 -0
  8. package/dist/{chunk-IODKUOBA.js → chunk-C2FZ6GR6.js} +2 -2
  9. package/dist/{chunk-63MHOCIE.js → chunk-DH72UOYR.js} +4 -4
  10. package/dist/{chunk-Z3RRRPRB.js → chunk-H7IBHAFT.js} +23 -14
  11. package/dist/chunk-H7IBHAFT.js.map +1 -0
  12. package/dist/{chunk-PVPFDTO3.js → chunk-LLJRUTE7.js} +2 -2
  13. package/dist/{chunk-PBE35ULD.js → chunk-M3Y362RW.js} +2 -2
  14. package/dist/{chunk-AG335EXG.js → chunk-QSO2TVDS.js} +668 -74
  15. package/dist/chunk-QSO2TVDS.js.map +1 -0
  16. package/dist/{chunk-KRULXIWS.js → chunk-TPII5AU7.js} +55 -7
  17. package/dist/chunk-TPII5AU7.js.map +1 -0
  18. package/dist/{coordination-DCmljYDf.d.ts → coordination-BI9tpcmF.d.ts} +12 -3
  19. package/dist/environment-provider.d.ts +1 -1
  20. package/dist/environment-provider.js +1 -1
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +8 -8
  23. package/dist/intelligence.d.ts +30 -2
  24. package/dist/intelligence.js +33 -23
  25. package/dist/intelligence.js.map +1 -1
  26. package/dist/{loop-runner-bin-C4X0FZ2Z.d.ts → loop-runner-bin-CBkLsyFg.d.ts} +2 -2
  27. package/dist/loop-runner-bin.d.ts +4 -4
  28. package/dist/loop-runner-bin.js +7 -7
  29. package/dist/loops.d.ts +265 -14
  30. package/dist/loops.js +28 -6
  31. package/dist/mcp/bin.js +5 -5
  32. package/dist/mcp/index.d.ts +6 -6
  33. package/dist/mcp/index.js +7 -7
  34. package/dist/{router-client-Ak2IGuXq.d.ts → router-client-D6Ocf4jG.d.ts} +19 -0
  35. package/dist/{types-C1sozrte.d.ts → types-By9LXllv.d.ts} +9 -2
  36. package/dist/{worktree-fanout-CXGzHET4.d.ts → worktree-fanout-D9Z2dMS9.d.ts} +2 -2
  37. package/dist/{worktree-harness-Bmho9SH0.d.ts → worktree-harness-Dx8XULW3.d.ts} +1 -1
  38. package/package.json +1 -1
  39. package/skills/build-with-agent-runtime/SKILL.md +53 -23
  40. package/dist/chunk-AG335EXG.js.map +0 -1
  41. package/dist/chunk-KRULXIWS.js.map +0 -1
  42. package/dist/chunk-T2HVQVB4.js.map +0 -1
  43. package/dist/chunk-VMNEQHJR.js.map +0 -1
  44. package/dist/chunk-Z3RRRPRB.js.map +0 -1
  45. /package/dist/{chunk-IODKUOBA.js.map → chunk-C2FZ6GR6.js.map} +0 -0
  46. /package/dist/{chunk-63MHOCIE.js.map → chunk-DH72UOYR.js.map} +0 -0
  47. /package/dist/{chunk-PVPFDTO3.js.map → chunk-LLJRUTE7.js.map} +0 -0
  48. /package/dist/{chunk-PBE35ULD.js.map → chunk-M3Y362RW.js.map} +0 -0
@@ -1,12 +1,12 @@
1
- import { E as ExecutorFactory, b as ExecutorRegistry, h as Spend, c as Agent, i as Scope, d as ResultBlobStore, B as Budget } from './types-C1sozrte.js';
1
+ import { E as ExecutorFactory, b as ExecutorRegistry, h as Spend, c as Agent, i as Scope, d as ResultBlobStore, B as Budget } from './types-By9LXllv.js';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
3
  import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-rNj6TDc3.js';
4
4
  import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-BF-MEsQB.js';
5
5
  import { SandboxEvent, SandboxInstance, BackendType } from '@tangle-network/sandbox';
6
6
  import { AgentEvalError } from '@tangle-network/agent-eval';
7
7
  import { O as OtelExporter } from './otel-export-BKmNwiCb.js';
8
- import { T as ToolSpec, R as RouterConfig } from './router-client-Ak2IGuXq.js';
9
- import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './worktree-harness-Bmho9SH0.js';
8
+ import { T as ToolSpec, R as RouterConfig } from './router-client-D6Ocf4jG.js';
9
+ import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './worktree-harness-Dx8XULW3.js';
10
10
  import { L as LocalHarness } from './local-harness-DU7yV6mG.js';
11
11
  import { ProviderExecutorOptions, AgentEnvironmentProviderRegistry } from './environment-provider.js';
12
12
  import { AgentEnvironmentProvider } from '@tangle-network/agent-interface/environment-provider';
@@ -2092,6 +2092,15 @@ interface CoordinationTools {
2092
2092
  * (mid-run, on the worker pipe) uses to tell the driver "this worker is looping/erroring" the
2093
2093
  * moment it happens, instead of only at settle. Queued for `await_event` + pass-through. */
2094
2094
  raiseFinding(finding: AnalystFindingEvent): Promise<void>;
2095
+ /**
2096
+ * Post-loop drain: pull every ALREADY-settled, unpulled child into the ledger (publishing each
2097
+ * as a `settled` bus event for the audit trail) WITHOUT awaiting live children. The driver
2098
+ * calls this once its brain loop ends, so a delivered child the brain never awaited still
2099
+ * reaches `finalizeBestDelivered` — a gate-verified delivery must never be lost to the
2100
+ * driver's pull discipline. Analyst-on-settle hooks do NOT fire here (the driver has stopped;
2101
+ * nobody is left to read a finding, and analysts spend real compute). Returns the count.
2102
+ */
2103
+ drainResolved(): Promise<number>;
2095
2104
  }
2096
2105
  /** Build the driver's MCP tools over a live scope. */
2097
2106
  declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
@@ -2,7 +2,7 @@ import { AgentProfile, AgentProfileValidationResult } from '@tangle-network/agen
2
2
  import { AgentEnvironmentProvider, AgentEnvironmentCapabilities, CreateAgentEnvironmentInput, AgentTurnInput, AgentProfileRef } from '@tangle-network/agent-interface/environment-provider';
3
3
  export { AgentEnvironment, AgentEnvironmentCapabilities, AgentEnvironmentEvent, AgentEnvironmentProvider, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSession, AgentSessionRef, AgentSessionStatus, AgentTurnInput, AgentTurnResult, CheckpointRef, CheckpointRequest, CreateAgentEnvironmentInput, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from '@tangle-network/agent-interface/environment-provider';
4
4
  import { CreateSandboxOptions, BackendType } from '@tangle-network/sandbox';
5
- import { R as Runtime, E as ExecutorFactory } from './types-C1sozrte.js';
5
+ import { R as Runtime, E as ExecutorFactory } from './types-By9LXllv.js';
6
6
  import { S as SandboxClient } from './types-BF-MEsQB.js';
7
7
  import '@tangle-network/agent-eval';
8
8
 
@@ -4,7 +4,7 @@ import {
4
4
  providerAsSandboxClient,
5
5
  resolveAgentEnvironmentProvider,
6
6
  sandboxClientAsProvider
7
- } from "./chunk-Z3RRRPRB.js";
7
+ } from "./chunk-H7IBHAFT.js";
8
8
  import "./chunk-DGUM43GV.js";
9
9
  export {
10
10
  createAgentEnvironmentProviderRegistry,
package/dist/index.d.ts CHANGED
@@ -9,16 +9,16 @@ import { Scenario as Scenario$1, SurfaceProposer, JudgeConfig, MutableSurface, D
9
9
  import { AgentProfile as AgentProfile$1 } from '@tangle-network/agent-interface';
10
10
  import { S as SurfaceImprovementEdit } from './improvement-adapter-CioiEE2z.js';
11
11
  import { I as ImprovementAdapter } from './types-BC3bZpH0.js';
12
- export { 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, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-C4X0FZ2Z.js';
12
+ export { 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, W as WorktreeLoopRunnerOptions, h as auditLoopRunner, i as isDelegatedLoopMode, p as parseLoopRunnerArgv, r as researchLoopRunner, j as runDelegatedLoop, k as runLoopRunnerCli, s as selfImproveLoopRunner, w as worktreeLoopRunner } from './loop-runner-bin-CBkLsyFg.js';
13
13
  export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from './openai-tools-B-3v06BE.js';
14
14
  export { E as EvalRunEvent, a as EvalRunGeneration, b as EvalRunsExportConfig, c as EvalRunsExportResult, I as INTELLIGENCE_WIRE_VERSION, L as LoopSpanNode, d as OtelAttribute, e as OtelExportConfig, O as OtelExporter, f as OtelSpan, g as buildLoopOtelSpans, h as buildLoopSpanNodes, i as createOtelExporter, j as exportEvalRuns, l as loopEventToOtelSpan } from './otel-export-BKmNwiCb.js';
15
15
  import '@tangle-network/sandbox';
16
16
  import './local-harness-DU7yV6mG.js';
17
17
  import 'node:child_process';
18
18
  import './kb-gate-CuzMYGYM.js';
19
- import './types-C1sozrte.js';
20
- import './worktree-fanout-CXGzHET4.js';
21
- import './worktree-harness-Bmho9SH0.js';
19
+ import './types-By9LXllv.js';
20
+ import './worktree-fanout-D9Z2dMS9.js';
21
+ import './worktree-harness-Dx8XULW3.js';
22
22
 
23
23
  /**
24
24
  * @stable
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  mcpToolsForRuntimeMcp,
3
3
  mcpToolsForRuntimeMcpSubset
4
- } from "./chunk-PVPFDTO3.js";
4
+ } from "./chunk-LLJRUTE7.js";
5
5
  import {
6
6
  DEFAULT_ROUTER_BASE_URL,
7
7
  cleanModelId,
@@ -20,16 +20,16 @@ import {
20
20
  runLoopRunnerCli,
21
21
  selfImproveLoopRunner,
22
22
  worktreeLoopRunner
23
- } from "./chunk-63MHOCIE.js";
23
+ } from "./chunk-DH72UOYR.js";
24
24
  import "./chunk-FNMGYYSS.js";
25
- import "./chunk-AG335EXG.js";
25
+ import "./chunk-QSO2TVDS.js";
26
26
  import {
27
27
  assertModelAllowed,
28
28
  composeRuntimeHooks,
29
29
  defineRuntimeHooks,
30
30
  notifyRuntimeDecisionPoint,
31
31
  notifyRuntimeHookEvent
32
- } from "./chunk-KRULXIWS.js";
32
+ } from "./chunk-TPII5AU7.js";
33
33
  import {
34
34
  INTELLIGENCE_WIRE_VERSION,
35
35
  buildLoopOtelSpans,
@@ -37,10 +37,10 @@ import {
37
37
  createOtelExporter,
38
38
  exportEvalRuns,
39
39
  loopEventToOtelSpan
40
- } from "./chunk-VMNEQHJR.js";
41
- import "./chunk-Z3RRRPRB.js";
42
- import "./chunk-IODKUOBA.js";
43
- import "./chunk-T2HVQVB4.js";
40
+ } from "./chunk-3X53HYRW.js";
41
+ import "./chunk-H7IBHAFT.js";
42
+ import "./chunk-C2FZ6GR6.js";
43
+ import "./chunk-4J6RBI3K.js";
44
44
  import {
45
45
  agenticGenerator,
46
46
  commandVerifier,
@@ -1,6 +1,6 @@
1
1
  import { c as LoopTraceEvent } from './types-BF-MEsQB.js';
2
2
  import { AgentProfileMcpServer } from '@tangle-network/agent-interface';
3
- import { T as ToolSpec } from './router-client-Ak2IGuXq.js';
3
+ import { T as ToolSpec } from './router-client-D6Ocf4jG.js';
4
4
  import '@tangle-network/agent-eval';
5
5
  import '@tangle-network/sandbox';
6
6
 
@@ -242,6 +242,34 @@ declare function pullCertified(opts: PullCertifiedOptions): Promise<PullOutcome>
242
242
  * usable certified content.
243
243
  */
244
244
  declare function composeCertifiedPrompt(base: string, certified: CertifiedProfile | null): string;
245
+ /** A cached, self-refreshing source of a target's certified prompt additions —
246
+ * the prompt-only delivery lane for callers that assemble their OWN system
247
+ * prompt (product chat routes) rather than wrapping an agent fn. Same
248
+ * fail-closed semantics as {@link withCertifiedDelivery}: pulls at most every
249
+ * `refreshMs`, coalesces concurrent pulls, keeps the last-known profile on a
250
+ * failed/404 pull, never throws, never blocks past the pull timeout. */
251
+ interface CertifiedPromptSource {
252
+ /** Refresh (window-respecting) then fold the certified additions into a
253
+ * base system prompt. Returns `base` unchanged when nothing is promoted. */
254
+ compose(base: string): Promise<string>;
255
+ /** The certified profile currently in effect (`null` = none pulled yet). */
256
+ current(): CertifiedProfile | null;
257
+ /** Pull now if the refresh window has elapsed; coalesced and fail-closed. */
258
+ refresh(): Promise<void>;
259
+ }
260
+ /** Options for {@link createCertifiedPromptSource} — the pull coordinates plus
261
+ * the refresh cadence. */
262
+ interface CertifiedPromptSourceOptions extends PullCertifiedOptions {
263
+ /** Min interval between certified-profile pulls. Default 5m. */
264
+ refreshMs?: number;
265
+ }
266
+ /**
267
+ * Create the cached certified-prompt source — the ONE module-scope-cache +
268
+ * coalesced-refresh + keep-last-known implementation. Product wiring uses this
269
+ * rather than hand-rolling the same lines around `pullCertified`, and
270
+ * {@link withCertifiedDelivery} is built on it.
271
+ */
272
+ declare function createCertifiedPromptSource(opts: CertifiedPromptSourceOptions): CertifiedPromptSource;
245
273
  /** What the delivery wrapper hands the agent each run. */
246
274
  interface AppliedIntelligence {
247
275
  /** The certified profile in effect (null when none promoted / pull failed —
@@ -890,4 +918,4 @@ type ClientOrConfig = IntelligenceClient | IntelligenceConfig;
890
918
  */
891
919
  declare function withTangleIntelligence<TInput, TOutput>(agent: Agent<TInput, TOutput>, clientOrConfig: ClientOrConfig): Agent<TInput, TOutput>;
892
920
 
893
- export { type Agent, type AppliedIntelligence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedProfile, type CertifiedPromptSurface, type ClientOrConfig, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveredAgent, type DeliveryBinding, type DeliveryBindingKind, type DeliveryConfig, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type HostSpec, type IntelligenceClient, type IntelligenceConfig, type JsonSchema, type ModeReadiness, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createIntelligenceClient, defaultEffortTier, defaultRedactor, isIntelligenceOff, manifestFromProfile, pullCertified, resolveEffort, resolveRedactor, withCertifiedDelivery, withTangleIntelligence };
921
+ export { type Agent, type AppliedIntelligence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ClientOrConfig, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveredAgent, type DeliveryBinding, type DeliveryBindingKind, type DeliveryConfig, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type HostSpec, type IntelligenceClient, type IntelligenceConfig, type JsonSchema, type ModeReadiness, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, isIntelligenceOff, manifestFromProfile, pullCertified, resolveEffort, resolveRedactor, withCertifiedDelivery, withTangleIntelligence };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  buildLoopOtelSpans,
3
3
  createOtelExporter,
4
- loopEventToOtelSpan
5
- } from "./chunk-VMNEQHJR.js";
4
+ flatOtelSpan
5
+ } from "./chunk-3X53HYRW.js";
6
6
  import "./chunk-DGUM43GV.js";
7
7
 
8
8
  // src/intelligence/effort.ts
@@ -325,10 +325,8 @@ function composeCertifiedPrompt(base, certified) {
325
325
 
326
326
  ${parts.join("\n\n")}`;
327
327
  }
328
- function withCertifiedDelivery(agent, config) {
329
- const client = createIntelligenceClient(config);
330
- const target = config.target ?? config.project;
331
- const refreshMs = config.refreshMs ?? defaultRefreshMs;
328
+ function createCertifiedPromptSource(opts) {
329
+ const refreshMs = opts.refreshMs ?? defaultRefreshMs;
332
330
  let certified = null;
333
331
  let lastPullAt = 0;
334
332
  let inflight = null;
@@ -336,13 +334,7 @@ function withCertifiedDelivery(agent, config) {
336
334
  if (Date.now() - lastPullAt < refreshMs) return;
337
335
  if (inflight) return inflight;
338
336
  inflight = (async () => {
339
- const outcome = await pullCertified({
340
- target,
341
- apiKey: config.apiKey,
342
- baseUrl: config.baseUrl,
343
- timeoutMs: config.timeoutMs,
344
- fetchImpl: config.fetchImpl
345
- });
337
+ const outcome = await pullCertified(opts);
346
338
  lastPullAt = Date.now();
347
339
  if (outcome.succeeded) certified = outcome.value;
348
340
  })();
@@ -352,8 +344,28 @@ function withCertifiedDelivery(agent, config) {
352
344
  inflight = null;
353
345
  }
354
346
  }
347
+ return {
348
+ refresh,
349
+ current: () => certified,
350
+ async compose(base) {
351
+ await refresh();
352
+ return composeCertifiedPrompt(base, certified);
353
+ }
354
+ };
355
+ }
356
+ function withCertifiedDelivery(agent, config) {
357
+ const client = createIntelligenceClient(config);
358
+ const source = createCertifiedPromptSource({
359
+ target: config.target ?? config.project,
360
+ ...config.apiKey !== void 0 ? { apiKey: config.apiKey } : {},
361
+ ...config.baseUrl !== void 0 ? { baseUrl: config.baseUrl } : {},
362
+ ...config.timeoutMs !== void 0 ? { timeoutMs: config.timeoutMs } : {},
363
+ ...config.fetchImpl !== void 0 ? { fetchImpl: config.fetchImpl } : {},
364
+ ...config.refreshMs !== void 0 ? { refreshMs: config.refreshMs } : {}
365
+ });
355
366
  const wrapped = (async (input) => {
356
- await refresh();
367
+ await source.refresh();
368
+ const certified = source.current();
357
369
  const applied = {
358
370
  certified,
359
371
  composePrompt: (base) => composeCertifiedPrompt(base, certified)
@@ -367,7 +379,7 @@ function withCertifiedDelivery(agent, config) {
367
379
  }
368
380
  );
369
381
  });
370
- wrapped.refresh = refresh;
382
+ wrapped.refresh = source.refresh;
371
383
  return wrapped;
372
384
  }
373
385
 
@@ -832,14 +844,11 @@ function createIntelligenceClient(config) {
832
844
  if (redactedOutput !== void 0) labels["tangle.output"] = previewJson(redactedOutput);
833
845
  try {
834
846
  ex.exportSpan(
835
- loopEventToOtelSpan(
836
- {
837
- kind: "tangle.intelligence.run",
838
- runId: outcome.runId,
839
- timestamp: Date.now(),
840
- payload: labels
841
- },
842
- outcome.traceId
847
+ flatOtelSpan(
848
+ "tangle.intelligence.run",
849
+ { "tangle.runId": outcome.runId, ...labels },
850
+ outcome.traceId,
851
+ Date.now()
843
852
  )
844
853
  );
845
854
  } catch {
@@ -957,6 +966,7 @@ export {
957
966
  composeCertifiedProfile,
958
967
  composeCertifiedProfileFromWire,
959
968
  composeCertifiedPrompt,
969
+ createCertifiedPromptSource,
960
970
  createIntelligenceClient,
961
971
  defaultEffortTier,
962
972
  defaultRedactor,