@tangle-network/agent-runtime 0.91.0 → 0.92.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 (86) hide show
  1. package/README.md +4 -2
  2. package/dist/agent.d.ts +3 -3
  3. package/dist/agent.js +88 -9
  4. package/dist/agent.js.map +1 -1
  5. package/dist/{mcp-serve-verifier-XsX8rkB9.d.ts → agentic-generator-B8oeE2Yv.d.ts} +6 -33
  6. package/dist/analyst-loop.d.ts +1 -1
  7. package/dist/candidate-execution/index.d.ts +104 -0
  8. package/dist/candidate-execution/index.js +34 -0
  9. package/dist/candidate-execution/index.js.map +1 -0
  10. package/dist/chunk-3BE7KTMU.js +1229 -0
  11. package/dist/chunk-3BE7KTMU.js.map +1 -0
  12. package/dist/chunk-3D2RHC4K.js +73 -0
  13. package/dist/chunk-3D2RHC4K.js.map +1 -0
  14. package/dist/chunk-3MDZX7YU.js +125 -0
  15. package/dist/chunk-3MDZX7YU.js.map +1 -0
  16. package/dist/{chunk-NC66AM3S.js → chunk-6O5USWVH.js} +32 -1413
  17. package/dist/chunk-6O5USWVH.js.map +1 -0
  18. package/dist/chunk-6O73TRHW.js +142 -0
  19. package/dist/chunk-6O73TRHW.js.map +1 -0
  20. package/dist/{chunk-JRS3YSRZ.js → chunk-7VJJJ2T2.js} +2 -2
  21. package/dist/chunk-A62TP7SK.js +4784 -0
  22. package/dist/chunk-A62TP7SK.js.map +1 -0
  23. package/dist/chunk-APVPRF4Y.js +2166 -0
  24. package/dist/chunk-APVPRF4Y.js.map +1 -0
  25. package/dist/{chunk-DWWII6N2.js → chunk-AUEIDTR3.js} +2 -2
  26. package/dist/{chunk-FF77IBQM.js → chunk-FRBHUNQ7.js} +2 -141
  27. package/dist/chunk-FRBHUNQ7.js.map +1 -0
  28. package/dist/{chunk-7ON74BQO.js → chunk-GDAQUFG6.js} +2 -2
  29. package/dist/{chunk-AD7JW4QG.js → chunk-I7WVPJBZ.js} +23 -1231
  30. package/dist/chunk-I7WVPJBZ.js.map +1 -0
  31. package/dist/{chunk-IOUUITQA.js → chunk-IGGZGKJD.js} +3 -3
  32. package/dist/chunk-PH65PR4F.js +860 -0
  33. package/dist/chunk-PH65PR4F.js.map +1 -0
  34. package/dist/chunk-RSWM2ZKM.js +659 -0
  35. package/dist/chunk-RSWM2ZKM.js.map +1 -0
  36. package/dist/{chunk-BZF3KQ6G.js → chunk-VSWBYWFK.js} +4 -122
  37. package/dist/chunk-VSWBYWFK.js.map +1 -0
  38. package/dist/{completion-gate-DkAnUmpb.d.ts → completion-gate-BLaiN0-X.d.ts} +1 -1
  39. package/dist/{coordination-rRj5hjJK.d.ts → coordination-DxJ83oZA.d.ts} +12 -5
  40. package/dist/environment-provider.d.ts +2 -2
  41. package/dist/environment-provider.js +2 -1
  42. package/dist/improve-CUVCq7xg.d.ts +152 -0
  43. package/dist/{improvement-adapter-CDR8QNVM.d.ts → improvement-adapter-BieWeK5J.d.ts} +16 -0
  44. package/dist/index.d.ts +27 -1092
  45. package/dist/index.js +108 -6491
  46. package/dist/index.js.map +1 -1
  47. package/dist/intelligence.d.ts +160 -13
  48. package/dist/intelligence.js +535 -59
  49. package/dist/intelligence.js.map +1 -1
  50. package/dist/knowledge.d.ts +6 -6
  51. package/dist/knowledge.js +6 -4
  52. package/dist/lifecycle.d.ts +2 -1
  53. package/dist/lifecycle.js +5 -3
  54. package/dist/lifecycle.js.map +1 -1
  55. package/dist/{loop-runner-bin-DTbZVGfM.d.ts → loop-runner-bin-kKUNGLyV.d.ts} +2 -2
  56. package/dist/loop-runner-bin.d.ts +5 -5
  57. package/dist/loop-runner-bin.js +8 -5
  58. package/dist/loops.d.ts +16 -16
  59. package/dist/loops.js +47 -41
  60. package/dist/mcp/bin.js +6 -4
  61. package/dist/mcp/bin.js.map +1 -1
  62. package/dist/mcp/index.d.ts +8 -8
  63. package/dist/mcp/index.js +9 -6
  64. package/dist/mcp/index.js.map +1 -1
  65. package/dist/mcp-serve-verifier-Bg4C3p5S.d.ts +34 -0
  66. package/dist/{openai-tools-C4ZfUD4L.d.ts → openai-tools-E3woykz9.d.ts} +1 -1
  67. package/dist/prepare-Z08a4heC.d.ts +713 -0
  68. package/dist/profiles.d.ts +1 -1
  69. package/dist/{router-client-DJImUDlm.d.ts → sanitize-C9go6tXj.d.ts} +113 -1
  70. package/dist/{structural-rollout-MwlpgQ-6.d.ts → structural-rollout-DHGDbhvR.d.ts} +3 -3
  71. package/dist/{supervise-DPmYPk0j.d.ts → supervise-T2pazU3G.d.ts} +4 -4
  72. package/dist/{types-SyuwunY_.d.ts → types-B00NtbCs.d.ts} +1 -1
  73. package/dist/{types-eMNgWgFi.d.ts → types-DAdIm4AC.d.ts} +1 -1
  74. package/dist/{worktree-fanout-BDFQIO-Y.d.ts → worktree-fanout-BUb2Ag02.d.ts} +3 -3
  75. package/package.json +26 -35
  76. package/skills/build-with-agent-runtime/SKILL.md +1 -1
  77. package/dist/chunk-AD7JW4QG.js.map +0 -1
  78. package/dist/chunk-BZF3KQ6G.js.map +0 -1
  79. package/dist/chunk-FF77IBQM.js.map +0 -1
  80. package/dist/chunk-IVGYLCFH.js +0 -381
  81. package/dist/chunk-IVGYLCFH.js.map +0 -1
  82. package/dist/chunk-NC66AM3S.js.map +0 -1
  83. /package/dist/{chunk-JRS3YSRZ.js.map → chunk-7VJJJ2T2.js.map} +0 -0
  84. /package/dist/{chunk-DWWII6N2.js.map → chunk-AUEIDTR3.js.map} +0 -0
  85. /package/dist/{chunk-7ON74BQO.js.map → chunk-GDAQUFG6.js.map} +0 -0
  86. /package/dist/{chunk-IOUUITQA.js.map → chunk-IGGZGKJD.js.map} +0 -0
@@ -0,0 +1,152 @@
1
+ import { Scenario, SelfImproveOptions, SurfaceProposer, SelfImproveResult } from '@tangle-network/agent-eval/contract';
2
+ import { AgentProfile } from '@tangle-network/agent-interface';
3
+ import { L as LocalHarness } from './local-harness-dcD5WTTr.js';
4
+ import { V as Verifier, C as CandidateGenerator } from './agentic-generator-B8oeE2Yv.js';
5
+
6
+ /**
7
+ *
8
+ * `improve` — the ONE public, surface-pluggable RSI verb.
9
+ *
10
+ * A thin facade over agent-eval's `selfImprove` (the held-out-gated closed
11
+ * loop). It removes the two things a caller otherwise has to know to drive the
12
+ * loop by hand: WHICH `MutableSurface` of the profile is being optimized, and
13
+ * WHICH `SurfaceProposer` mutates that surface. You name a `surface`; the
14
+ * facade picks the matching default proposer, extracts the baseline surface from
15
+ * the profile, runs `selfImprove`, and (on a ship verdict) writes the promoted
16
+ * winner back into the corresponding profile field.
17
+ *
18
+ * - `surface: 'prompt'` → `gepaProposer` mutates `profile.prompt.systemPrompt`.
19
+ * - `surface: 'skills'` → `skillOptProposer` mutates a skills document string.
20
+ * - `surface: 'agent-profile'` → caller-supplied proposer mutates the complete
21
+ * canonical AgentProfile JSON in one candidate.
22
+ * - `surface: 'rollout-policy'` → `rolloutPolicyProposer` mutates the
23
+ * inference-time `StructuralRolloutPolicy` dials ({ k, repairRounds, testgen })
24
+ * persisted in `profile.extensions['structural-rollout']` — deterministic
25
+ * bounded neighbor enumeration; the held-out gate does the deciding. No-op
26
+ * (nothing proposed, nothing shipped) when the profile has no such extension.
27
+ * - `surface` ∈ {`tools`, `mcp`, `hooks`, `subagents`, `workflow`, `agent-profile`, `code`} → no zero-config default
28
+ * proposer exists (a code/config proposer needs caller-supplied wiring — a
29
+ * worktree repo root, a candidate generator, a serializer). The facade
30
+ * requires an explicit `opts.generator` for these and throws a `ConfigError`
31
+ * otherwise. This is a designed boundary, not a missing default: there is
32
+ * no safe value the facade could invent for those surfaces. Code also
33
+ * requires `opts.code.repoRoot` so its incumbent is a real isolated checkout.
34
+ *
35
+ * Everything else (`scenarios`, `judge`, `agent`, `budget`, `llm`) passes
36
+ * straight through to `selfImprove`.
37
+ *
38
+ * @experimental
39
+ */
40
+
41
+ /** The agent-profile lever `improve` optimizes. Mirrors the AgentProfile-law
42
+ * profile levers; `code` is the implementation-tier surface, `rollout-policy`
43
+ * the inference-time structuralRollout dials
44
+ * (`profile.extensions['structural-rollout']`). */
45
+ type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'workflow' | 'agent-profile' | 'code' | 'rollout-policy';
46
+ type ImproveOptions<TScenario extends Scenario, TArtifact> = Omit<SelfImproveOptions<TScenario, TArtifact>, 'analyzeGeneration' | 'baselineSurface' | 'findings' | 'gate' | 'proposer'> & {
47
+ /** Which profile lever to optimize. Default `'prompt'`. Selects the default
48
+ * generator + the baseline-surface extraction shape. */
49
+ surface?: ImproveSurface;
50
+ /** The `SurfaceProposer` that mutates the surface. When unset, the facade
51
+ * picks the default for `surface` (`gepaProposer` for prompt, `skillOptProposer`
52
+ * for skills); surfaces with no default REQUIRE this (fail-loud otherwise). */
53
+ generator?: SurfaceProposer;
54
+ /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
55
+ * `'none'` is a baseline-only run (`budget.generations = 0`). */
56
+ gate?: 'holdout' | 'none';
57
+ /** Restrict the run to this subset of models. When set, the reflection model
58
+ * (`llm.model`, or the default when unset) must be a member, or `improve()` throws
59
+ * a `ConfigError` before the generator is built. Unset = unrestricted. */
60
+ allowedModels?: readonly string[];
61
+ /** Per-generation findings producer passthrough (see selfImprove.analyzeGeneration).
62
+ * DEFAULT: the built-in failure distiller — after each generation it turns the
63
+ * worst-scoring/errored cells into structured findings ({ scenario, composite,
64
+ * notes, error }) for the NEXT proposal round, so the proposer reasons over what
65
+ * actually failed instead of a static seed. Pass your own producer (e.g. a
66
+ * trace-analyst over the runDir's traces) to replace it; pass `null` to disable
67
+ * and keep the static `findings` all the way through. */
68
+ analyzeGeneration?: SelfImproveOptions<TScenario, TArtifact>['analyzeGeneration'] | null;
69
+ /** META-HARNESS mode: instead of the ~400-char distilled findings, feed the
70
+ * proposer RAW-TRACE FILESYSTEM CONTEXT — the PATHS into the prior generation's
71
+ * real run traces under `runDir` (per-cell `spans.jsonl` event logs +
72
+ * `cached-result.json` scores + artifacts) plus a `grep`/`cat`-to-diagnose
73
+ * instruction — so the coding agent reads the actual failures itself rather than
74
+ * a pre-summary. Requires a REAL `runDir` (that is where the traces live).
75
+ * Ignored when `analyzeGeneration` is set explicitly (that wins) or is `null`
76
+ * (disabled). Equivalent to `analyzeGeneration: rawTraceDistiller()`; this flag
77
+ * is the one-line enable. Default `false` (the distiller stays the default). */
78
+ rawTraceContext?: boolean;
79
+ /** CODE-surface wiring: name `surface: 'code'`, point at a repo, and the
80
+ * facade assembles the whole candidate pipeline — an isolated incumbent plus git worktrees
81
+ * (`gitWorktreeAdapter`) driven by `improvementDriver` with the full agentic
82
+ * generator (a real coding harness edits each candidate worktree; a `verify`
83
+ * hook gates candidates before they are ever measured). Ignored when
84
+ * `opts.generator` is supplied. Required for every code run because a real
85
+ * repository and base ref are necessary to measure the incumbent. */
86
+ code?: ImproveCodeOptions;
87
+ /** SKILLS-surface wiring for real skill-DOCUMENT optimization. Without this,
88
+ * `surface: 'skills'` optimizes the profile's skills REFS array (file pointers)
89
+ * — which `skillOptProposer` (a document patcher) cannot meaningfully edit.
90
+ * Provide the document CONTENT to optimize + a `writeBack` to persist the
91
+ * shipped winner (the profile ref points at a file the caller owns). This is
92
+ * what makes skillOpt reachable through improve(). */
93
+ skills?: ImproveSkillsOptions;
94
+ /** Custom held-back-exam decision. The string `gate` above controls whether
95
+ * the exam runs; this callback controls how its evidence decides promotion. */
96
+ promotionGate?: SelfImproveOptions<TScenario, TArtifact>['gate'];
97
+ };
98
+ interface ImproveSkillsOptions {
99
+ /** The skill document's current text — the baseline `skillOptProposer` patches. */
100
+ document: string;
101
+ /** Persist the shipped winner document (write the file the profile ref points at).
102
+ * Called only on a ship verdict. When omitted, the winner is still returned in
103
+ * `result.raw.winner.surface` for the caller to materialize. */
104
+ writeBack?: (winnerDocument: string) => void;
105
+ }
106
+ interface ImproveCodeOptions {
107
+ /** Repo root candidate worktrees fork from. */
108
+ repoRoot: string;
109
+ /** Base ref candidates fork from. Default `main`. */
110
+ baseRef?: string;
111
+ /** Directory worktrees are created under. Default `<repoRoot>/.worktrees`. */
112
+ worktreeDir?: string;
113
+ /** Coding harness the agentic generator runs in each worktree. Default `claude`. */
114
+ harness?: LocalHarness;
115
+ /** Verify a candidate worktree before it becomes a measurable surface; failures
116
+ * feed the next shot (see `agenticGenerator.verify` / `commandVerifier`). */
117
+ verify?: Verifier;
118
+ /** Per-shot wall-clock timeout for the harness (ms). */
119
+ timeoutMs?: number;
120
+ /** Byte-producer override — the test seam and the escape hatch for custom
121
+ * candidate production. When set, `harness`/`verify`/`timeoutMs` are unused. */
122
+ generator?: CandidateGenerator;
123
+ }
124
+ interface ImproveResult<TScenario extends Scenario, TArtifact> {
125
+ /** The profile after improvement: the winner surface applied back into the
126
+ * matching field when the gate shipped, else the input profile unchanged. */
127
+ profile: AgentProfile;
128
+ /** True when `gateDecision === 'ship'`. */
129
+ shipped: boolean;
130
+ /** Held-out lift (`winner − baseline` composite). */
131
+ lift: number;
132
+ /** The five-valued gate verdict from `selfImprove`. */
133
+ gateDecision: SelfImproveResult<TScenario, TArtifact>['gateDecision'];
134
+ /** Full `selfImprove` result for advanced inspection. */
135
+ raw: SelfImproveResult<TScenario, TArtifact>;
136
+ }
137
+ /**
138
+ * Run the held-out-gated self-improvement loop on ONE profile surface.
139
+ *
140
+ * @example Optimize the system prompt, default holdout gate:
141
+ *
142
+ * const out = await improve(profile, findings, {
143
+ * surface: 'prompt',
144
+ * scenarios,
145
+ * judge,
146
+ * agent: (surface, scenario, ctx) => runAgent(surface, scenario, ctx.signal),
147
+ * })
148
+ * if (out.shipped) deploy(out.profile)
149
+ */
150
+ declare function improve<TScenario extends Scenario, TArtifact>(profile: AgentProfile, findings: unknown[], opts: ImproveOptions<TScenario, TArtifact>): Promise<ImproveResult<TScenario, TArtifact>>;
151
+
152
+ export { type ImproveSurface as I, type ImproveOptions as a, type ImproveResult as b, type ImproveCodeOptions as c, type ImproveSkillsOptions as d, improve as i };
@@ -52,6 +52,22 @@ interface AgentSurfaces {
52
52
  rag?: string;
53
53
  /** Optional: single file defining the output schema (Zod / JSON Schema). */
54
54
  outputSchema?: string;
55
+ /** Optional: directory containing Agent Skill packages. */
56
+ skills?: string;
57
+ /** Optional: directory containing MCP server/tool configuration. */
58
+ mcp?: string;
59
+ /** Optional: directory containing hook definitions. */
60
+ hooks?: string;
61
+ /** Optional: directory containing subagent definitions. */
62
+ subagents?: string;
63
+ /** Optional: directory containing orchestration/workflow policies. */
64
+ workflows?: string;
65
+ /** Optional: single file containing rollout-policy settings. */
66
+ rolloutPolicy?: string;
67
+ /** Optional: single canonical AgentProfile file. */
68
+ agentProfile?: string;
69
+ /** Optional: source root for code findings. */
70
+ code?: string;
55
71
  }
56
72
  interface ResolvedSurface {
57
73
  /** Absolute filesystem path the operator can `cat` / `vim`. */