@tangle-network/agent-runtime 0.99.0 → 0.101.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.
@@ -1,11 +1,12 @@
1
- import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer, AgentImprovementActivationTarget, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement, AgentImprovementProposal, AgentImprovementReviewDecision, AgentCandidateBenchmarkCellRef, Sha256Digest, 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';
@@ -645,6 +646,15 @@ type AgentImprovementActivationTargetIdentity = Pick<AgentImprovementActivationT
645
646
  declare function buildAgentImprovementActivationTargets(surfaces: readonly AgentImprovementSurface[], experiment: AgentCandidateExperiment, intent: AgentImprovementActivationIntent, identities: readonly AgentImprovementActivationTargetIdentity[]): [AgentImprovementActivationTarget, ...AgentImprovementActivationTarget[]];
646
647
  /** Return whether a measured surface can be delivered through an agent profile. */
647
648
  declare function isAgentImprovementProfileSurface(surface: AgentImprovementSurface): surface is AgentImprovementProfileSurface;
649
+ /**
650
+ * Return the canonical current-state input for one profile-deliverable improvement target.
651
+ * Missing slots become `null`; tools and subagents include both their direct and resource slots.
652
+ * Unrelated profile fields are excluded. The result matches `agentImprovementTargetInput` for the
653
+ * same profile inside a candidate bundle.
654
+ */
655
+ declare function agentImprovementProfileSurfaceInput(profile: AgentProfile, surface: AgentImprovementProfileSurface): unknown;
656
+ /** Return the `Sha256Digest` of one profile surface using Runtime's canonical candidate digest. */
657
+ declare function agentImprovementProfileSurfaceDigest(profile: AgentProfile, surface: AgentImprovementProfileSurface): Sha256Digest;
648
658
  /**
649
659
  * Replace one measured profile surface exactly, including array-valued resources.
650
660
  * Apply the returned diffs in order: a diff applies its set before its removal,
@@ -767,6 +777,48 @@ declare function verifyAgentImprovementActivation(input: {
767
777
  /** Recheck one Runtime receipt against its exact signed experiment cell. */
768
778
  declare function verifyCandidateExecutionEvidence(input: unknown, options: VerifyCandidateExecutionEvidenceOptions): CandidateExecutionEvidence;
769
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
+
770
822
  /**
771
823
  *
772
824
  * The capability resolver — the ONLY place that knows binding kinds. It lowers a
@@ -1315,4 +1367,4 @@ interface DoctorReport {
1315
1367
  */
1316
1368
  declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
1317
1369
 
1318
- 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, 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,6 +1,8 @@
1
1
  import {
2
2
  AGENT_IMPROVEMENT_PROFILE_SURFACES,
3
3
  AgentCandidateExperimentCellExecutionError,
4
+ agentImprovementProfileSurfaceDigest,
5
+ agentImprovementProfileSurfaceInput,
4
6
  agentImprovementTargetProfileDiffs,
5
7
  buildAgentImprovementActivationTargets,
6
8
  createAgentImprovementActivation,
@@ -18,15 +20,19 @@ import {
18
20
  verifyAgentImprovementProposal,
19
21
  verifyAgentImprovementReview,
20
22
  verifyCandidateExecutionEvidence
21
- } from "./chunk-JSPW2Y3P.js";
23
+ } from "./chunk-VOPHC4LB.js";
22
24
  import {
23
25
  AGENT_CANDIDATE_EXECUTION_SUPPORT,
24
26
  CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV,
25
27
  CANDIDATE_KNOWLEDGE_ROOT_ENV,
28
+ applyExactAgentProfileDiff,
26
29
  candidateKnowledgeExecutionPaths,
27
30
  canonicalCandidateBytes,
28
- parseAgentCandidateProfileActivation
29
- } from "./chunk-YOLKCWRV.js";
31
+ immutableCandidateValue,
32
+ omitUndefinedObjectFields,
33
+ parseAgentCandidateProfileActivation,
34
+ parseExactAgentProfile
35
+ } from "./chunk-HGSHPVJ6.js";
30
36
  import {
31
37
  buildLoopOtelSpans,
32
38
  buildRuntimeEventOtelSpans,
@@ -422,6 +428,83 @@ function isJsonSchema(v) {
422
428
  return typeof v === "object" && v !== null && !Array.isArray(v);
423
429
  }
424
430
 
431
+ // src/intelligence/profile-activation.ts
432
+ function prepareAgentImprovementProfileActivation(input) {
433
+ const targetKeys = input.targets.map((target) => `${target.identity}\0${target.surface}`);
434
+ if (new Set(targetKeys).size !== targetKeys.length) {
435
+ throw new Error("agent profile activation repeats a target");
436
+ }
437
+ const identities = [...new Set(input.targets.map((target) => target.identity))].sort();
438
+ const missing = identities.filter((identity) => !input.currentByIdentity.has(identity));
439
+ if (missing.length > 0) {
440
+ return immutableCandidateValue({ status: "missing", identities: missing });
441
+ }
442
+ const currentProfiles = new Map(
443
+ identities.map((identity) => {
444
+ const profile = input.currentByIdentity.get(identity);
445
+ if (!profile) throw new Error(`missing agent profile ${identity}`);
446
+ const label = `agent profile activation ${identity}`;
447
+ return [identity, parseExactAgentProfile(omitUndefinedObjectFields(profile, label), label)];
448
+ })
449
+ );
450
+ const current = input.targets.map((target) => {
451
+ const profile = currentProfiles.get(target.identity);
452
+ if (!profile) throw new Error(`missing agent profile ${target.identity}`);
453
+ return {
454
+ target,
455
+ currentDigest: agentImprovementProfileSurfaceDigest(profile, target.surface)
456
+ };
457
+ });
458
+ const states = current.map(({ target, currentDigest }) => ({
459
+ surface: target.surface,
460
+ identity: target.identity,
461
+ currentDigest
462
+ }));
463
+ if (current.every(({ target, currentDigest }) => currentDigest === target.desiredDigest)) {
464
+ return immutableCandidateValue({ status: "already-applied", targets: states });
465
+ }
466
+ if (current.some(({ target, currentDigest }) => currentDigest !== target.expectedBaseDigest)) {
467
+ return immutableCandidateValue({ status: "conflict", targets: states });
468
+ }
469
+ const profiles = /* @__PURE__ */ new Map();
470
+ for (const identity of identities) {
471
+ const currentProfile = currentProfiles.get(identity);
472
+ if (!currentProfile) throw new Error(`missing agent profile ${identity}`);
473
+ const profile = input.targets.filter((target) => target.identity === identity).flatMap(
474
+ (target) => agentImprovementTargetProfileDiffs(target, {
475
+ id: `${target.identity}:${target.desiredDigest}`,
476
+ metadata: { identity }
477
+ })
478
+ ).reduce(
479
+ (value, diff) => applyExactAgentProfileDiff(value, diff, `agent profile activation ${identity}`),
480
+ currentProfile
481
+ );
482
+ profiles.set(identity, immutableCandidateValue(profile));
483
+ }
484
+ for (const target of input.targets) {
485
+ const profile = profiles.get(target.identity);
486
+ if (!profile || agentImprovementProfileSurfaceDigest(profile, target.surface) !== target.desiredDigest) {
487
+ throw new Error(
488
+ `agent profile activation did not produce ${target.identity}:${target.surface}`
489
+ );
490
+ }
491
+ }
492
+ return immutableCandidateValue({
493
+ status: "apply",
494
+ replacements: identities.map((identity) => {
495
+ const profile = profiles.get(identity);
496
+ if (!profile) throw new Error(`missing prepared agent profile ${identity}`);
497
+ return { identity, profile };
498
+ }),
499
+ targets: input.targets.map((target) => ({
500
+ surface: target.surface,
501
+ identity: target.identity,
502
+ beforeDigest: target.expectedBaseDigest,
503
+ afterDigest: target.desiredDigest
504
+ }))
505
+ });
506
+ }
507
+
425
508
  // src/intelligence/resolver.ts
426
509
  function emptyAccumulator() {
427
510
  return {
@@ -1689,6 +1772,8 @@ export {
1689
1772
  AGENT_IMPROVEMENT_PROFILE_SURFACES,
1690
1773
  AgentCandidateExperimentCellExecutionError,
1691
1774
  CapabilityNotAdmittedError,
1775
+ agentImprovementProfileSurfaceDigest,
1776
+ agentImprovementProfileSurfaceInput,
1692
1777
  agentImprovementTargetProfileDiffs,
1693
1778
  buildAgentImprovementActivationTargets,
1694
1779
  compileEffort,
@@ -1711,6 +1796,7 @@ export {
1711
1796
  manifestFromProfile,
1712
1797
  normalizeCertifiedProfile,
1713
1798
  parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization,
1799
+ prepareAgentImprovementProfileActivation,
1714
1800
  proposeAgentImprovement,
1715
1801
  pullCertified,
1716
1802
  resolveEffort,