@tangle-network/agent-runtime 0.100.0 → 0.101.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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/{activation-Cdp4wKQ0.d.ts → activation-Cm-9MMX1.d.ts} +1 -1
  3. package/dist/agent.js +4 -3
  4. package/dist/agent.js.map +1 -1
  5. package/dist/chunk-2VZYRB55.js +834 -0
  6. package/dist/chunk-2VZYRB55.js.map +1 -0
  7. package/dist/{chunk-Y3SRWZMP.js → chunk-AYU35OTU.js} +2 -2
  8. package/dist/chunk-DI677IPX.js +200 -0
  9. package/dist/chunk-DI677IPX.js.map +1 -0
  10. package/dist/{chunk-HZDEXTSL.js → chunk-IKGCKPDX.js} +2 -833
  11. package/dist/chunk-IKGCKPDX.js.map +1 -0
  12. package/dist/{chunk-WYC2XJF2.js → chunk-KSBUSEUA.js} +2 -2
  13. package/dist/{chunk-UQ6PNNXM.js → chunk-KVJQV342.js} +5 -3
  14. package/dist/{chunk-UQ6PNNXM.js.map → chunk-KVJQV342.js.map} +1 -1
  15. package/dist/{chunk-FXF2OL34.js → chunk-MAONWP4R.js} +2 -2
  16. package/dist/{chunk-SGQ4YIQW.js → chunk-N2CEE5Q3.js} +3 -3
  17. package/dist/{chunk-VOPHC4LB.js → chunk-RJPQLUDA.js} +5 -187
  18. package/dist/chunk-RJPQLUDA.js.map +1 -0
  19. package/dist/{chunk-LV6WCT43.js → chunk-TA4RBJLE.js} +3 -3
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +9 -7
  22. package/dist/index.js.map +1 -1
  23. package/dist/intelligence.d.ts +46 -3
  24. package/dist/intelligence.js +91 -6
  25. package/dist/intelligence.js.map +1 -1
  26. package/dist/knowledge.d.ts +1 -1
  27. package/dist/knowledge.js +6 -4
  28. package/dist/loop-runner-bin.js +5 -4
  29. package/dist/loops.js +4 -3
  30. package/dist/mcp/bin.js +4 -3
  31. package/dist/mcp/bin.js.map +1 -1
  32. package/dist/mcp/index.js +6 -5
  33. package/dist/mcp/index.js.map +1 -1
  34. package/dist/testing.d.ts +6 -0
  35. package/dist/testing.js +2596 -0
  36. package/dist/testing.js.map +1 -0
  37. package/package.json +9 -2
  38. package/dist/chunk-HZDEXTSL.js.map +0 -1
  39. package/dist/chunk-VOPHC4LB.js.map +0 -1
  40. /package/dist/{chunk-Y3SRWZMP.js.map → chunk-AYU35OTU.js.map} +0 -0
  41. /package/dist/{chunk-WYC2XJF2.js.map → chunk-KSBUSEUA.js.map} +0 -0
  42. /package/dist/{chunk-FXF2OL34.js.map → chunk-MAONWP4R.js.map} +0 -0
  43. /package/dist/{chunk-SGQ4YIQW.js.map → chunk-N2CEE5Q3.js.map} +0 -0
  44. /package/dist/{chunk-LV6WCT43.js.map → chunk-TA4RBJLE.js.map} +0 -0
@@ -1,11 +1,12 @@
1
- import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer, AgentImprovementActivationTarget, Sha256Digest, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement, AgentImprovementProposal, AgentImprovementReviewDecision, AgentCandidateBenchmarkCellRef, AgentImprovementReview, AgentImprovementActivation, CandidateExecutionEvidence } from '@tangle-network/agent-interface';
1
+ import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer, AgentImprovementActivationTarget, Sha256Digest, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement, AgentImprovementProposal, AgentImprovementReviewDecision, AgentCandidateBenchmarkCellRef, AgentImprovementReview, AgentImprovementActivation, CandidateExecutionEvidence, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition } from '@tangle-network/agent-interface';
2
2
  export { AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementReview, AgentImprovementReviewDecision, CandidateExecutionEvidence, AgentCandidateProfileActivation as CandidateProfileMaterialization } from '@tangle-network/agent-interface';
3
3
  import { b as LoopTraceEvent } from './types-B3vAW0Oq.js';
4
4
  import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-BTSsdBXw.js';
5
5
  import { R as RuntimeStreamEvent } from './types-BwoZWq-i.js';
6
6
  import { P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, A as AgentCandidateExecutionClaimStore } from './profile-DbfaMTdk.js';
7
7
  export { p as parseCandidateProfileMaterialization } from './profile-DbfaMTdk.js';
8
- export { A as AgentImprovementActivationReconciliation, a as AgentImprovementActivationResultStore, b as AgentImprovementActivationTargetPlan, c as AgentImprovementActivationTransition, d as AgentImprovementActivationTransitionInput, C as CreateAgentImprovementActivationResultOptions, E as ExecuteAgentImprovementActivationInput, e as ExecuteAgentImprovementActivationOptions, f as createAgentImprovementActivationResult, g as executeAgentImprovementActivation, v as verifyAgentImprovementActivationResult } from './activation-Cdp4wKQ0.js';
8
+ import { A as AgentImprovementActivationTargetPlan } from './activation-Cm-9MMX1.js';
9
+ export { a as AgentImprovementActivationReconciliation, b as AgentImprovementActivationResultStore, c as AgentImprovementActivationTransition, d as AgentImprovementActivationTransitionInput, C as CreateAgentImprovementActivationResultOptions, E as ExecuteAgentImprovementActivationInput, e as ExecuteAgentImprovementActivationOptions, f as createAgentImprovementActivationResult, g as executeAgentImprovementActivation, v as verifyAgentImprovementActivationResult } from './activation-Cm-9MMX1.js';
9
10
  import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
10
11
  import { CandidateExperimentExecutionInput, Scenario, CompareCandidateExperimentOptions } from '@tangle-network/agent-eval/contract';
11
12
  import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-CmYCMbFT.js';
@@ -776,6 +777,48 @@ declare function verifyAgentImprovementActivation(input: {
776
777
  /** Recheck one Runtime receipt against its exact signed experiment cell. */
777
778
  declare function verifyCandidateExecutionEvidence(input: unknown, options: VerifyCandidateExecutionEvidenceOptions): CandidateExecutionEvidence;
778
779
 
780
+ type AgentImprovementProfileActivationTarget = Omit<AgentImprovementActivationTargetPlan, 'surface'> & {
781
+ surface: AgentImprovementProfileSurface;
782
+ };
783
+ type AgentImprovementProfileTargetState = Omit<AgentImprovementActivationTargetState, 'surface'> & {
784
+ surface: AgentImprovementProfileSurface;
785
+ };
786
+ type AgentImprovementProfileTargetTransition = Omit<AgentImprovementActivationTargetTransition, 'surface'> & {
787
+ surface: AgentImprovementProfileSurface;
788
+ };
789
+ interface AgentImprovementProfileReplacement {
790
+ identity: string;
791
+ profile: AgentProfile;
792
+ }
793
+ type AgentImprovementProfileActivationPreparation = {
794
+ status: 'missing';
795
+ identities: readonly string[];
796
+ } | {
797
+ status: 'already-applied' | 'conflict';
798
+ targets: [AgentImprovementProfileTargetState, ...AgentImprovementProfileTargetState[]];
799
+ } | {
800
+ status: 'apply';
801
+ replacements: [AgentImprovementProfileReplacement, ...AgentImprovementProfileReplacement[]];
802
+ targets: [
803
+ AgentImprovementProfileTargetTransition,
804
+ ...AgentImprovementProfileTargetTransition[]
805
+ ];
806
+ };
807
+ /**
808
+ * Compare product-owned profiles with an exact measured transition and prepare
809
+ * the all-or-none replacements. The caller owns locking, persistence, and the
810
+ * durable activation receipt; this function owns profile semantics only.
811
+ * Profiles stay in product-owned stores, so this returns replacements instead
812
+ * of owning the transition callbacks used by Runtime-owned knowledge stores.
813
+ */
814
+ declare function prepareAgentImprovementProfileActivation(input: {
815
+ currentByIdentity: ReadonlyMap<string, AgentProfile>;
816
+ targets: readonly [
817
+ AgentImprovementProfileActivationTarget,
818
+ ...AgentImprovementProfileActivationTarget[]
819
+ ];
820
+ }): AgentImprovementProfileActivationPreparation;
821
+
779
822
  /**
780
823
  *
781
824
  * The capability resolver — the ONLY place that knows binding kinds. It lowers a
@@ -1324,4 +1367,4 @@ interface DoctorReport {
1324
1367
  */
1325
1368
  declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
1326
1369
 
1327
- export { AGENT_IMPROVEMENT_PROFILE_SURFACES, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivationTargetIdentity, type AgentImprovementProfileSurface, type AgentImprovementTargetProfileDiffOptions, 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 CreateAgentImprovementActivationOptions, type CreateAgentImprovementProposalOptions, type CreateSandboxCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExecuteAgentCandidateExperimentCellOptions, 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 RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type RunRecord, type RunReport, type SandboxCandidateExperimentExecution, type SandboxCandidateExperimentExecutor, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, buildAgentImprovementActivationTargets, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementMeasuredComparison, createAgentImprovementProposal, createCertifiedPromptSource, createIntelligenceClient, createSandboxCandidateExperimentExecutor, defaultEffortTier, defaultRedactor, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, runAgentCandidateExperiment, sandboxCandidateExperimentExecutionSupport, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
1370
+ export { AGENT_IMPROVEMENT_PROFILE_SURFACES, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivationTargetIdentity, AgentImprovementActivationTargetPlan, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementTargetProfileDiffOptions, 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 CreateAgentImprovementActivationOptions, type CreateAgentImprovementProposalOptions, type CreateSandboxCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExecuteAgentCandidateExperimentCellOptions, 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 RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type RunRecord, type RunReport, type SandboxCandidateExperimentExecution, type SandboxCandidateExperimentExecutor, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, buildAgentImprovementActivationTargets, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementMeasuredComparison, createAgentImprovementProposal, createCertifiedPromptSource, createIntelligenceClient, createSandboxCandidateExperimentExecutor, defaultEffortTier, defaultRedactor, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, runAgentCandidateExperiment, sandboxCandidateExperimentExecutionSupport, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
@@ -1,3 +1,8 @@
1
+ import {
2
+ createAgentImprovementActivationResult,
3
+ executeAgentImprovementActivation,
4
+ verifyAgentImprovementActivationResult
5
+ } from "./chunk-DI677IPX.js";
1
6
  import {
2
7
  AGENT_IMPROVEMENT_PROFILE_SURFACES,
3
8
  AgentCandidateExperimentCellExecutionError,
@@ -6,35 +11,37 @@ import {
6
11
  agentImprovementTargetProfileDiffs,
7
12
  buildAgentImprovementActivationTargets,
8
13
  createAgentImprovementActivation,
9
- createAgentImprovementActivationResult,
10
14
  createAgentImprovementMeasuredComparison,
11
15
  createAgentImprovementProposal,
12
16
  executeAgentCandidateExperimentCell,
13
- executeAgentImprovementActivation,
14
17
  isAgentImprovementProfileSurface,
15
18
  proposeAgentImprovement,
16
19
  reviewAgentImprovementProposal,
17
20
  runAgentCandidateExperiment,
18
21
  verifyAgentImprovementActivation,
19
- verifyAgentImprovementActivationResult,
20
22
  verifyAgentImprovementProposal,
21
23
  verifyAgentImprovementReview,
22
24
  verifyCandidateExecutionEvidence
23
- } from "./chunk-VOPHC4LB.js";
25
+ } from "./chunk-RJPQLUDA.js";
24
26
  import {
25
27
  AGENT_CANDIDATE_EXECUTION_SUPPORT,
26
28
  CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
27
29
  CANDIDATE_KNOWLEDGE_ROOT_ENV,
30
+ applyExactAgentProfileDiff,
28
31
  candidateKnowledgeExecutionPaths,
29
32
  canonicalCandidateBytes,
30
- parseAgentCandidateProfileActivation
33
+ immutableCandidateValue,
34
+ omitUndefinedObjectFields,
35
+ parseAgentCandidateProfileActivation,
36
+ parseExactAgentProfile
31
37
  } from "./chunk-HGSHPVJ6.js";
32
38
  import {
33
39
  buildLoopOtelSpans,
34
40
  buildRuntimeEventOtelSpans,
35
41
  createOtelExporter,
36
42
  flatOtelSpan
37
- } from "./chunk-HZDEXTSL.js";
43
+ } from "./chunk-2VZYRB55.js";
44
+ import "./chunk-IKGCKPDX.js";
38
45
  import "./chunk-IMSNJSXH.js";
39
46
  import "./chunk-3MDZX7YU.js";
40
47
  import "./chunk-FD2MBMOH.js";
@@ -424,6 +431,83 @@ function isJsonSchema(v) {
424
431
  return typeof v === "object" && v !== null && !Array.isArray(v);
425
432
  }
426
433
 
434
+ // src/intelligence/profile-activation.ts
435
+ function prepareAgentImprovementProfileActivation(input) {
436
+ const targetKeys = input.targets.map((target) => `${target.identity}\0${target.surface}`);
437
+ if (new Set(targetKeys).size !== targetKeys.length) {
438
+ throw new Error("agent profile activation repeats a target");
439
+ }
440
+ const identities = [...new Set(input.targets.map((target) => target.identity))].sort();
441
+ const missing = identities.filter((identity) => !input.currentByIdentity.has(identity));
442
+ if (missing.length > 0) {
443
+ return immutableCandidateValue({ status: "missing", identities: missing });
444
+ }
445
+ const currentProfiles = new Map(
446
+ identities.map((identity) => {
447
+ const profile = input.currentByIdentity.get(identity);
448
+ if (!profile) throw new Error(`missing agent profile ${identity}`);
449
+ const label = `agent profile activation ${identity}`;
450
+ return [identity, parseExactAgentProfile(omitUndefinedObjectFields(profile, label), label)];
451
+ })
452
+ );
453
+ const current = input.targets.map((target) => {
454
+ const profile = currentProfiles.get(target.identity);
455
+ if (!profile) throw new Error(`missing agent profile ${target.identity}`);
456
+ return {
457
+ target,
458
+ currentDigest: agentImprovementProfileSurfaceDigest(profile, target.surface)
459
+ };
460
+ });
461
+ const states = current.map(({ target, currentDigest }) => ({
462
+ surface: target.surface,
463
+ identity: target.identity,
464
+ currentDigest
465
+ }));
466
+ if (current.every(({ target, currentDigest }) => currentDigest === target.desiredDigest)) {
467
+ return immutableCandidateValue({ status: "already-applied", targets: states });
468
+ }
469
+ if (current.some(({ target, currentDigest }) => currentDigest !== target.expectedBaseDigest)) {
470
+ return immutableCandidateValue({ status: "conflict", targets: states });
471
+ }
472
+ const profiles = /* @__PURE__ */ new Map();
473
+ for (const identity of identities) {
474
+ const currentProfile = currentProfiles.get(identity);
475
+ if (!currentProfile) throw new Error(`missing agent profile ${identity}`);
476
+ const profile = input.targets.filter((target) => target.identity === identity).flatMap(
477
+ (target) => agentImprovementTargetProfileDiffs(target, {
478
+ id: `${target.identity}:${target.desiredDigest}`,
479
+ metadata: { identity }
480
+ })
481
+ ).reduce(
482
+ (value, diff) => applyExactAgentProfileDiff(value, diff, `agent profile activation ${identity}`),
483
+ currentProfile
484
+ );
485
+ profiles.set(identity, immutableCandidateValue(profile));
486
+ }
487
+ for (const target of input.targets) {
488
+ const profile = profiles.get(target.identity);
489
+ if (!profile || agentImprovementProfileSurfaceDigest(profile, target.surface) !== target.desiredDigest) {
490
+ throw new Error(
491
+ `agent profile activation did not produce ${target.identity}:${target.surface}`
492
+ );
493
+ }
494
+ }
495
+ return immutableCandidateValue({
496
+ status: "apply",
497
+ replacements: identities.map((identity) => {
498
+ const profile = profiles.get(identity);
499
+ if (!profile) throw new Error(`missing prepared agent profile ${identity}`);
500
+ return { identity, profile };
501
+ }),
502
+ targets: input.targets.map((target) => ({
503
+ surface: target.surface,
504
+ identity: target.identity,
505
+ beforeDigest: target.expectedBaseDigest,
506
+ afterDigest: target.desiredDigest
507
+ }))
508
+ });
509
+ }
510
+
427
511
  // src/intelligence/resolver.ts
428
512
  function emptyAccumulator() {
429
513
  return {
@@ -1715,6 +1799,7 @@ export {
1715
1799
  manifestFromProfile,
1716
1800
  normalizeCertifiedProfile,
1717
1801
  parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization,
1802
+ prepareAgentImprovementProfileActivation,
1718
1803
  proposeAgentImprovement,
1719
1804
  pullCertified,
1720
1805
  resolveEffort,