@tangle-network/agent-runtime 0.91.0 → 0.92.1

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 +106 -25
  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-3D2RHC4K.js +73 -0
  11. package/dist/chunk-3D2RHC4K.js.map +1 -0
  12. package/dist/chunk-3MDZX7YU.js +125 -0
  13. package/dist/chunk-3MDZX7YU.js.map +1 -0
  14. package/dist/chunk-4FPXIMSI.js +659 -0
  15. package/dist/chunk-4FPXIMSI.js.map +1 -0
  16. package/dist/chunk-6O73TRHW.js +142 -0
  17. package/dist/chunk-6O73TRHW.js.map +1 -0
  18. package/dist/chunk-A62TP7SK.js +4784 -0
  19. package/dist/chunk-A62TP7SK.js.map +1 -0
  20. package/dist/{chunk-AD7JW4QG.js → chunk-BVVRQ4YC.js} +23 -1231
  21. package/dist/chunk-BVVRQ4YC.js.map +1 -0
  22. package/dist/chunk-FDJ7AHXG.js +1229 -0
  23. package/dist/chunk-FDJ7AHXG.js.map +1 -0
  24. package/dist/{chunk-FF77IBQM.js → chunk-FRBHUNQ7.js} +2 -141
  25. package/dist/chunk-FRBHUNQ7.js.map +1 -0
  26. package/dist/chunk-J2K6WIG6.js +2172 -0
  27. package/dist/chunk-J2K6WIG6.js.map +1 -0
  28. package/dist/{chunk-JRS3YSRZ.js → chunk-LQQPGRKT.js} +2 -2
  29. package/dist/{chunk-IOUUITQA.js → chunk-P6B3Z7PR.js} +3 -3
  30. package/dist/chunk-PH65PR4F.js +860 -0
  31. package/dist/chunk-PH65PR4F.js.map +1 -0
  32. package/dist/{chunk-7ON74BQO.js → chunk-R5GWDTM3.js} +2 -2
  33. package/dist/{chunk-DWWII6N2.js → chunk-TKJ3Q6CQ.js} +2 -2
  34. package/dist/{chunk-NC66AM3S.js → chunk-UO2L5VTP.js} +32 -1413
  35. package/dist/chunk-UO2L5VTP.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 +534 -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 +11 -6
  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-LQQPGRKT.js.map} +0 -0
  84. /package/dist/{chunk-IOUUITQA.js.map → chunk-P6B3Z7PR.js.map} +0 -0
  85. /package/dist/{chunk-7ON74BQO.js.map → chunk-R5GWDTM3.js.map} +0 -0
  86. /package/dist/{chunk-DWWII6N2.js.map → chunk-TKJ3Q6CQ.js.map} +0 -0
@@ -1,8 +1,17 @@
1
- import { d as LoopTraceEvent } from './types-SyuwunY_.js';
2
- import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer } from '@tangle-network/agent-interface';
3
- import { b as ToolSpec } from './router-client-DJImUDlm.js';
1
+ import { AgentCandidateBundle, AgentProfile, Sha256Digest, AgentProfileDiff, AgentProfileMcpServer } from '@tangle-network/agent-interface';
2
+ import { g as LoopTraceEvent, b as RuntimeStreamEvent } from './types-B00NtbCs.js';
3
+ import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-C9go6tXj.js';
4
+ import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
5
+ import { Scenario, SelfImproveResult } from '@tangle-network/agent-eval/contract';
6
+ import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
7
+ import { A as AgentCandidateTaskExecution, a as AgentCandidateExecutionPorts, P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, b as AgentCandidateRunFinalization } from './prepare-Z08a4heC.js';
8
+ import { I as ImproveSurface, a as ImproveOptions, b as ImproveResult } from './improve-CUVCq7xg.js';
4
9
  import '@tangle-network/agent-eval';
5
10
  import '@tangle-network/sandbox';
11
+ import './local-harness-dcD5WTTr.js';
12
+ import 'node:child_process';
13
+ import './agentic-generator-B8oeE2Yv.js';
14
+ import '@tangle-network/agent-eval/campaign';
6
15
 
7
16
  /**
8
17
  *
@@ -117,6 +126,99 @@ interface EffortOverridesCompiled {
117
126
  */
118
127
  declare function compileEffort(settings: EffortSettings): EffortOverridesCompiled;
119
128
 
129
+ type AgentCandidateBundleInput = Omit<AgentCandidateBundle, 'digest'>;
130
+
131
+ type AgentImprovementEvaluation<TScenario extends Scenario, TArtifact> = Pick<SelfImproveResult<TScenario, TArtifact>, 'baseline' | 'winner' | 'lift' | 'diff' | 'provenance' | 'gateDecision' | 'generationsExplored' | 'durationMs' | 'totalCostUsd' | 'insight' | 'power'>;
132
+ interface AgentImprovementProposal<TScenario extends Scenario = Scenario, TArtifact = unknown> {
133
+ schemaVersion: 1;
134
+ kind: 'agent-improvement-proposal';
135
+ runId: string;
136
+ surface: ImproveSurface;
137
+ proposedAt: string;
138
+ baselineProfileHash: string;
139
+ candidateProfile: AgentProfile;
140
+ candidateProfileHash: string;
141
+ findings: AnalystFinding[];
142
+ evaluation: AgentImprovementEvaluation<TScenario, TArtifact>;
143
+ candidateBundle?: AgentCandidateBundle;
144
+ digest: Sha256Digest;
145
+ }
146
+ type AgentImprovementReviewDecision = 'approve' | 'reject' | 'request-changes';
147
+ interface AgentImprovementReview {
148
+ schemaVersion: 1;
149
+ kind: 'agent-improvement-review';
150
+ proposalDigest: Sha256Digest;
151
+ candidateBundleDigest?: Sha256Digest;
152
+ decision: AgentImprovementReviewDecision;
153
+ reviewedBy: string;
154
+ reviewedAt: string;
155
+ reason: string;
156
+ feedback?: string;
157
+ digest: Sha256Digest;
158
+ }
159
+ interface CandidateExecutionEvidence {
160
+ proposalDigest: Sha256Digest;
161
+ reviewDigest: Sha256Digest;
162
+ bundleDigest: Sha256Digest;
163
+ executionId: string;
164
+ executionPlanDigest: Sha256Digest;
165
+ materializationReceiptDigest: Sha256Digest;
166
+ succeeded: boolean;
167
+ runReceiptDigest?: Sha256Digest;
168
+ }
169
+ interface ProposeAgentImprovementOptions<TScenario extends Scenario, TArtifact> {
170
+ runId: string;
171
+ profile: AgentProfile;
172
+ analysis: Omit<RunAnalystLoopOpts, 'runId' | 'improvementAdapter' | 'autoApply'>;
173
+ improvement: ImproveOptions<TScenario, TArtifact>;
174
+ /**
175
+ * Optional environment adapter that freezes an executable bundle after the
176
+ * measured comparison recommends the candidate. Runtime validates and
177
+ * computes the bundle digest; adapters never implement hashing themselves.
178
+ */
179
+ buildCandidate?: (input: {
180
+ analysis: RunAnalystLoopResult;
181
+ improvement: ImproveResult<TScenario, TArtifact>;
182
+ }) => AgentCandidateBundleInput | Promise<AgentCandidateBundleInput>;
183
+ now?: () => Date;
184
+ }
185
+ interface ProposeAgentImprovementResult<TScenario extends Scenario, TArtifact> {
186
+ analysis: RunAnalystLoopResult;
187
+ improvement: ImproveResult<TScenario, TArtifact>;
188
+ proposal: AgentImprovementProposal<TScenario, TArtifact>;
189
+ }
190
+ interface ReviewAgentImprovementInput {
191
+ decision: AgentImprovementReviewDecision;
192
+ reviewedBy: string;
193
+ reason: string;
194
+ feedback?: string;
195
+ now?: () => Date;
196
+ }
197
+ interface ExecuteApprovedAgentCandidateOptions {
198
+ proposal: AgentImprovementProposal;
199
+ review: AgentImprovementReview;
200
+ /** Product-owned authentication check for the persisted approval record. */
201
+ authorizeReview: (review: AgentImprovementReview, proposal: AgentImprovementProposal) => boolean | Promise<boolean>;
202
+ task: AgentCandidateTaskExecution;
203
+ ports: AgentCandidateExecutionPorts;
204
+ preparation?: PrepareAgentCandidateExecutionOptions;
205
+ execution: ExecutePreparedAgentCandidateOptions;
206
+ }
207
+ interface ExecuteApprovedAgentCandidateResult {
208
+ finalization: AgentCandidateRunFinalization;
209
+ evidence: CandidateExecutionEvidence;
210
+ }
211
+ /** Analyze one run and produce one measured, review-only improvement proposal. */
212
+ declare function proposeAgentImprovement<TScenario extends Scenario, TArtifact>(options: ProposeAgentImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentImprovementResult<TScenario, TArtifact>>;
213
+ /** Persist an approve/reject/change-request decision bound to one exact proposal. */
214
+ declare function reviewAgentImprovementProposal(inputProposal: AgentImprovementProposal, input: ReviewAgentImprovementInput): AgentImprovementReview;
215
+ /** Verify, materialize, run, grade, and receipt only the exact approved bundle. */
216
+ declare function executeApprovedAgentCandidate(options: ExecuteApprovedAgentCandidateOptions): Promise<ExecuteApprovedAgentCandidateResult>;
217
+ /** Validate a proposal's schema, profile, sealed bundle, and canonical digest. */
218
+ declare function verifyAgentImprovementProposal(input: unknown): AgentImprovementProposal;
219
+ /** Validate a review's decision fields and canonical digest. */
220
+ declare function verifyAgentImprovementReview(input: unknown): AgentImprovementReview;
221
+
120
222
  /**
121
223
  *
122
224
  * Redaction for Intelligence trace export. The trace carries the customer's
@@ -765,6 +867,9 @@ declare function composeCertifiedProfileFromWire(base: {
765
867
  * `proposals`/`applyProfile` surface the promoted profile DIFFS — never
766
868
  * auto-applied; `record` enriches the {@link RunRecord} that is sent. */
767
869
  interface AppliedIntelligence {
870
+ /** Stable ids shared by the run span and every nested runtime/loop span. */
871
+ runId: string;
872
+ traceId: string;
768
873
  /** The certified profile in effect (null when none promoted / pull failed —
769
874
  * fail-closed: the agent runs on its base surface). */
770
875
  certified: CertifiedProfile | null;
@@ -807,6 +912,8 @@ interface IntelligenceHookConfig extends IntelligenceConfig {
807
912
  type IntelligenceWrapped<I, O> = ((input: I) => Promise<O>) & {
808
913
  refresh(): Promise<void>;
809
914
  proposals(): ProposedProfileDiff[];
915
+ /** Flush buffered trace spans before a short-lived process exits. */
916
+ flush(): Promise<void>;
810
917
  };
811
918
  /**
812
919
  * Wrap an agent so it (a) RECEIVES the tenant's certified profile — the prompt
@@ -821,11 +928,11 @@ declare function withIntelligence<I, O>(agent: IntelligenceAgent<I, O>, config:
821
928
 
822
929
  /**
823
930
  *
824
- * Tangle Intelligence SDK — the Observe + Mode-0 product layer.
931
+ * Tangle Intelligence SDK — trace capture plus reviewable improvement.
825
932
  *
826
- * A thin, best-effort wrapper over the shipped trace-export substrate
827
- * (`createOtelExporter` in `../otel-export`). It does exactly two things in
828
- * this slice:
933
+ * The client keeps live-agent trace delivery best-effort. The separate
934
+ * improvement-cycle exports analyze completed traces, measure one candidate,
935
+ * bind human review, and execute only an approved immutable bundle.
829
936
  *
830
937
  * 1. OBSERVE — wrap a generic agent and export one trace span per call to
831
938
  * Tangle Intelligence, swallowing every export failure so a live agent
@@ -836,11 +943,6 @@ declare function withIntelligence<I, O>(agent: IntelligenceAgent<I, O>, config:
836
943
  * and at OFF `intelligenceUsd` is provably `0` — the mechanism that proves
837
944
  * an OFF customer paid inference-only.
838
945
  *
839
- * Behavior-changing intelligence (analyst steer, candidate promotion, loops)
840
- * is a LATER phase and is NOT built here. This wrapper only Observes and passes
841
- * through; there is no abort path, so the only fail-soft surface is the
842
- * telemetry export.
843
- *
844
946
  * @experimental
845
947
  */
846
948
 
@@ -881,6 +983,30 @@ interface RunRecord {
881
983
  model?: string;
882
984
  provider?: string;
883
985
  loopEvents?: LoopTraceEvent[];
986
+ runtimeEvents?: RuntimeStreamEvent[];
987
+ profile?: AgentProfile;
988
+ sessionId?: string;
989
+ harness?: string;
990
+ repository?: string;
991
+ commitSha?: string;
992
+ timing?: {
993
+ startedAt: number;
994
+ completedAt: number;
995
+ durationMs: number;
996
+ };
997
+ tokens?: {
998
+ input: number;
999
+ output: number;
1000
+ cachedInput?: number;
1001
+ reasoning?: number;
1002
+ };
1003
+ error?: {
1004
+ name: string;
1005
+ message: string;
1006
+ code?: string;
1007
+ };
1008
+ /** Exact proposal → review → execution → receipt linkage for candidate runs. */
1009
+ candidateExecution?: CandidateExecutionEvidence;
884
1010
  }
885
1011
  /**
886
1012
  * What an agent reports (via `applied.record`) to enrich the {@link RunRecord}
@@ -896,6 +1022,14 @@ interface RunReport {
896
1022
  model?: string;
897
1023
  provider?: string;
898
1024
  loopEvents?: LoopTraceEvent[];
1025
+ runtimeEvents?: RuntimeStreamEvent[];
1026
+ profile?: AgentProfile;
1027
+ sessionId?: string;
1028
+ harness?: string;
1029
+ commitSha?: string;
1030
+ tokens?: RunRecord['tokens'];
1031
+ error?: RunRecord['error'];
1032
+ candidateExecution?: CandidateExecutionEvidence;
899
1033
  }
900
1034
  /** Repo coordinates a product may declare for the (later) Gated-PR mode. The
901
1035
  * Observe slice only records their PRESENCE for `doctor()`; it never touches
@@ -938,6 +1072,19 @@ interface IntelligenceConfig {
938
1072
  checks?: string[];
939
1073
  /** Repo access a later PR mode would need. Recorded for `doctor()` only. */
940
1074
  repo?: RepoConfig;
1075
+ /** Full canonical profile used for this agent. Exported redacted with a stable hash. */
1076
+ profile?: AgentProfile;
1077
+ /** Commit that produced the running agent, when known. */
1078
+ commitSha?: string;
1079
+ /** Runtime-event payload policy. Tool inputs/results remain off unless explicitly enabled. */
1080
+ runtimeTelemetry?: RuntimeTelemetryOptions;
1081
+ /**
1082
+ * Payloads are metadata-only by default: the run span carries a stable hash
1083
+ * and UTF-8 byte count, but not the redacted content. Set `full` only when
1084
+ * the configured OTLP destination is approved to receive complete redacted
1085
+ * inputs, outputs, and profiles.
1086
+ */
1087
+ payloadAttributes?: 'metadata' | 'full';
941
1088
  }
942
1089
  /** Metadata describing one traced run. `runId`/`traceId` default to fresh ids. */
943
1090
  interface TraceMeta {
@@ -1068,4 +1215,4 @@ interface DoctorReport {
1068
1215
  */
1069
1216
  declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
1070
1217
 
1071
- export { type AppliedIntelligence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposedProfileDiff, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type RunRecord, type RunReport, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, withIntelligence };
1218
+ export { type AgentImprovementEvaluation, type AgentImprovementProposal, type AgentImprovementReview, type AgentImprovementReviewDecision, type AppliedIntelligence, type CandidateExecutionEvidence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExecuteApprovedAgentCandidateOptions, type ExecuteApprovedAgentCandidateResult, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunRecord, type RunReport, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, executeApprovedAgentCandidate, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, verifyAgentImprovementProposal, verifyAgentImprovementReview, withIntelligence };