var{defineProperty:g,getOwnPropertyNames:U,getOwnPropertyDescriptor:W}=Object,d=Object.prototype.hasOwnProperty;function x(H){return this[H]}var b=(H)=>{var A=(Q??=new WeakMap).get(H),N;if(A)return A;if(A=g({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function"){for(var S of U(H))if(!d.call(A,S))g(A,S,{get:x.bind(H,S),enumerable:!(N=W(H,S))||N.enumerable})}return Q.set(H,A),A},Q;var M=(H)=>H;function P(H,A){this[H]=M.bind(null,A)}var l=(H,A)=>{for(var N in A)g(H,N,{get:A[N],enumerable:!0,configurable:!0,set:P.bind(A,N)})};var c=(H,A)=>()=>(H&&(A=H(H=0)),A);var h={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},V={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},y=V,z={Spots:"spots",Collectivity:"collectivity",Marketplace:"marketplace",Sellers:"sellers",Auth:"auth",Login:"login",Signup:"signup",Guide:"guide",Docs:"docs",I18n:"i18n",Incident:"incident",Automation:"automation",Hygiene:"hygiene"},r=z;import{compareVersions as F}from"compare-versions";var B=(H,A)=>`${H}.v${A}`;class o{items=new Map;surfaceIndex=null;register(H){let A=B(H.meta.key,H.meta.version);if(this.items.has(A))throw Error(`Duplicate capability ${A}`);return this.items.set(A,H),this.surfaceIndex=null,this}list(){return[...this.items.values()]}get(H,A){if(A!=null)return this.items.get(B(H,A));let N;for(let S of this.items.values()){if(S.meta.key!==H)continue;if(!N||F(S.meta.version,N.meta.version)>0)N=S}return N}satisfies(H,A){if(H.optional)return!0;if(A?.some((S)=>m(S,H)))return!0;let N=H.version?this.get(H.key,H.version):this.get(H.key);if(!N)return!1;if(H.kind&&N.meta.kind!==H.kind)return!1;if(H.version!=null&&N.meta.version!==H.version)return!1;return!0}buildSurfaceIndex(){if(this.surfaceIndex)return this.surfaceIndex;this.surfaceIndex=new Map;for(let H of this.items.values()){let A=B(H.meta.key,H.meta.version);for(let N of H.provides??[]){let S=`${N.surface}:${N.key}`;if(!this.surfaceIndex.has(S))this.surfaceIndex.set(S,new Set);this.surfaceIndex.get(S)?.add(A)}}return this.surfaceIndex}getOperationsFor(H,A){let N=this.get(H,A);if(!N)return[];return N.provides?.filter((S)=>S.surface==="operation").map((S)=>S.key)??[]}getEventsFor(H,A){let N=this.get(H,A);if(!N)return[];return N.provides?.filter((S)=>S.surface==="event").map((S)=>S.key)??[]}getPresentationsFor(H,A){let N=this.get(H,A);if(!N)return[];return N.provides?.filter((S)=>S.surface==="presentation").map((S)=>S.key)??[]}getWorkflowsFor(H,A){let N=this.get(H,A);if(!N)return[];return N.provides?.filter((S)=>S.surface==="workflow").map((S)=>S.key)??[]}getResourcesFor(H,A){let N=this.get(H,A);if(!N)return[];return N.provides?.filter((S)=>S.surface==="resource").map((S)=>S.key)??[]}getCapabilitiesForOperation(H){let N=this.buildSurfaceIndex().get(`operation:${H}`);if(!N)return[];return[...N].map((S)=>{let R=this.items.get(S);return{key:R?.meta.key??"",version:R?.meta.version??""}})}getCapabilitiesForEvent(H){let N=this.buildSurfaceIndex().get(`event:${H}`);if(!N)return[];return[...N].map((S)=>{let R=this.items.get(S);return{key:R?.meta.key??"",version:R?.meta.version??""}})}getCapabilitiesForPresentation(H){let N=this.buildSurfaceIndex().get(`presentation:${H}`);if(!N)return[];return[...N].map((S)=>{let R=this.items.get(S);return{key:R?.meta.key??"",version:R?.meta.version??""}})}getAncestors(H,A){let N=[],S=new Set,R=this.get(H,A);while(R?.extends){let _=B(R.extends.key,R.extends.version);if(S.has(_))break;S.add(_);let E=this.get(R.extends.key,R.extends.version);if(!E)break;N.push(E),R=E}return N}getEffectiveRequirements(H,A){let N=this.get(H,A);if(!N)return[];let S=this.getAncestors(H,A),R=new Map;for(let _ of[...S].reverse())for(let E of _.requires??[])R.set(E.key,E);for(let _ of N.requires??[])R.set(_.key,_);return[...R.values()]}getEffectiveSurfaces(H,A){let N=this.get(H,A);if(!N)return[];let S=this.getAncestors(H,A),R=[];for(let _ of[...S].reverse())R.push(..._.provides??[]);return R.push(...N.provides??[]),R}}function m(H,A){if(H.key!==A.key)return!1;if(A.version!=null&&H.version!==A.version)return!1;return!0}function i(H){return B(H.meta.key,H.meta.version)}function T(H){return H}var p=[{id:"docs.tech.contracts.capabilities",title:"CapabilitySpec Overview",summary:"Capability specs define what a module provides (operations, events, presentations) and requires (dependencies). They enable bidirectional linking, inheritance, runtime enforcement, and automated validation.",kind:"reference",visibility:"public",route:"/docs/tech/contracts/capabilities",tags:["tech","contracts","capabilities"],body:`# CapabilitySpec Overview

## Purpose

Capabilities are **module interfaces** that define:
1. What operations, events, and presentations a module exposes (\`provides\`)
2. What other capabilities it depends on (\`requires\`)
3. Inheritance hierarchies via \`extends\`

They enable:
- **Bidirectional linking**: Specs reference capabilities, capabilities list their specs
- **Dependency validation**: Features can't install without satisfying requirements
- **Runtime enforcement**: Check capabilities before executing operations
- **Inheritance**: Build capability hierarchies with shared requirements

## Schema

\`\`\`ts
export interface CapabilitySpec {
  meta: CapabilityMeta;              // ownership metadata + { key, version, kind }
  extends?: CapabilityRef;           // NEW: inherit from parent capability
  provides?: CapabilitySurfaceRef[]; // surfaces this capability exposes
  requires?: CapabilityRequirement[];// capabilities that must exist
}
\`\`\`

### Bidirectional Linking

Operations, events, and presentations can now declare their capability:

\`\`\`ts
// In OperationSpec
{
  meta: { key: 'payments.charge.create', ... },
  capability: { key: 'payments', version: '1.0.0' }, // Links to capability
  io: { ... }
}

// In CapabilitySpec
{
  meta: { key: 'payments', version: '1.0.0', ... },
  provides: [
    { surface: 'operation', key: 'payments.charge.create' }
  ]
}
\`\`\`

Validation ensures both sides match via \`validateCapabilityConsistency()\`.

## Registry Query Methods

The \`CapabilityRegistry\` now provides rich query capabilities:

\`\`\`ts
// Forward lookups: Capability → Specs
registry.getOperationsFor('payments');      // ['payments.charge.create', ...]
registry.getEventsFor('payments');          // ['payments.charge.succeeded', ...]
registry.getPresentationsFor('payments');   // ['payments.dashboard', ...]

// Reverse lookups: Spec → Capabilities
registry.getCapabilitiesForOperation('payments.charge.create');
registry.getCapabilitiesForEvent('payments.charge.succeeded');
registry.getCapabilitiesForPresentation('payments.dashboard');

// Inheritance
registry.getAncestors('payments.stripe');           // Parent chain
registry.getEffectiveRequirements('payments.stripe'); // Includes inherited
registry.getEffectiveSurfaces('payments.stripe');     // Includes inherited
\`\`\`

## Inheritance

Capabilities can extend other capabilities:

\`\`\`ts
// Base capability
defineCapability({
  meta: { key: 'payments.base', version: '1.0.0', ... },
  requires: [{ key: 'auth', version: '1.0.0' }],
  provides: [{ surface: 'operation', key: 'payments.list' }]
});

// Child capability inherits requirements
defineCapability({
  meta: { key: 'payments.stripe', version: '1.0.0', ... },
  extends: { key: 'payments.base', version: '1.0.0' },
  requires: [{ key: 'encryption', version: '1.0.0' }], // Added
  provides: [{ surface: 'operation', key: 'payments.stripe.charge' }]
});

// getEffectiveRequirements('payments.stripe') returns:
// [{ key: 'auth', ... }, { key: 'encryption', ... }]
\`\`\`

## Runtime Enforcement

Use \`CapabilityContext\` for opt-in runtime checks:

\`\`\`ts

// Create context from user's enabled capabilities
const ctx = createCapabilityContext(user.capabilities);

// Check capability
if (ctx.hasCapability('payments')) {
  // User can access payments features
}

// Assert capability (throws if missing)
ctx.requireCapability('payments');

// Guard an operation
assertCapabilityForOperation(ctx, paymentOperation);

// Filter operations by enabled capabilities
const allowedOps = filterOperationsByCapability(ctx, allOperations);
\`\`\`

## Validation

Validate bidirectional consistency between capabilities and specs:

\`\`\`ts

const result = validateCapabilityConsistency({
  capabilities: capabilityRegistry,
  operations: operationRegistry,
  events: eventRegistry,
  presentations: presentationRegistry,
});

if (!result.valid) {
  console.error('Validation errors:', result.errors);
}

// Find specs without capability assignment (informational)
const orphans = findOrphanSpecs({ capabilities, operations });
\`\`\`

## Feature Integration

During \`installFeature()\`:
1. \`provides\` capabilities must exist in the registry
2. \`requires\` must be satisfied by registered capabilities or local \`provides\`
3. Referenced operations/events/presentations must exist

## Authoring Guidelines

1. **Register capabilities first** before referencing them in features
2. **Use bidirectional linking** - set \`capability\` on specs and list them in \`provides\`
3. **Version consciously** - bump versions on breaking changes
4. **Document dependencies** with \`reason\` strings
5. **Use inheritance** for capability families with shared requirements
6. **Validate during CI** with \`validateCapabilityConsistency()\`

## Error Handling

\`\`\`ts

try {
  ctx.requireCapability('premium-features');
} catch (err) {
  if (err instanceof CapabilityMissingError) {
    console.log('Missing:', err.capabilityKey);
    console.log('Required version:', err.requiredVersion);
  }
}
\`\`\`

## API Reference

### Types
- \`CapabilitySpec\` - Capability definition
- \`CapabilityRef\` - Reference to a capability (key + version)
- \`CapabilitySurfaceRef\` - Reference to a provided surface
- \`CapabilityRequirement\` - Dependency requirement
- \`CapabilityContext\` - Runtime capability context
- \`CapabilityValidationResult\` - Validation result

### Functions
- \`defineCapability(spec)\` - Define a capability spec
- \`createCapabilityContext(caps)\` - Create runtime context
- \`validateCapabilityConsistency(deps)\` - Validate bidirectional links
- \`findOrphanSpecs(deps)\` - Find specs without capability assignment
- \`assertCapabilityForOperation/Event/Presentation(ctx, spec)\` - Guards
- \`filterOperationsByCapability(ctx, ops)\` - Filter by enabled capabilities
`}];class Y extends Error{capabilityKey;requiredVersion;constructor(H,A){let N=A?`.v${A}`:"";super(`Missing required capability: ${H}${N}`);this.name="CapabilityMissingError",this.capabilityKey=H,this.requiredVersion=A}}class G{capabilities;capabilityVersions;constructor(H){let A=new Set,N=new Map;for(let S of H)A.add(S.key),N.set(S.key,S.version);this.capabilities=A,this.capabilityVersions=N}hasCapability(H,A){if(!this.capabilities.has(H))return!1;if(A!=null)return this.capabilityVersions.get(H)===A;return!0}requireCapability(H,A){if(!this.hasCapability(H,A))throw new Y(H,A)}hasAllCapabilities(H){return H.every((A)=>this.capabilities.has(A))}hasAnyCapability(H){return H.some((A)=>this.capabilities.has(A))}getMatchingCapabilities(H){if(!H.includes("*"))return this.capabilities.has(H)?[H]:[];let A=H.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*"),N=new RegExp(`^${A}$`);return[...this.capabilities].filter((S)=>N.test(S))}}function H0(H){return new G(H)}function S0(){return new G([])}function A0(H){return new G(H)}function X(H,A){if(!A.capability)return{allowed:!0};let{key:N,version:S}=A.capability;if(H.hasCapability(N,S))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:S},reason:`Operation "${A.meta.key}" requires capability "${N}.v${S}"`}}function _0(H,A){let N=X(H,A);if(!N.allowed&&N.missingCapability)throw new Y(N.missingCapability.key,N.missingCapability.version)}function Z(H,A){if(!A.capability)return{allowed:!0};let{key:N,version:S}=A.capability;if(H.hasCapability(N,S))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:S},reason:`Event "${A.meta.key}" requires capability "${N}.v${S}"`}}function E0(H,A){let N=Z(H,A);if(!N.allowed&&N.missingCapability)throw new Y(N.missingCapability.key,N.missingCapability.version)}function $(H,A){if(!A.capability)return{allowed:!0};let{key:N,version:S}=A.capability;if(H.hasCapability(N,S))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:S},reason:`Presentation "${A.meta.key}" requires capability "${N}.v${S}"`}}function h0(H,A){let N=$(H,A);if(!N.allowed&&N.missingCapability)throw new Y(N.missingCapability.key,N.missingCapability.version)}function T0(H,A){return A.filter((N)=>X(H,N).allowed)}function I0(H,A){return A.filter((N)=>Z(H,N).allowed)}function f0(H,A){return A.filter((N)=>$(H,N).allowed)}var O=["platform.integrations"],j=["meeting-recorder","transcripts","integrations"],u={meta:{key:"meeting-recorder.meetings.read",version:"1.0.0",kind:"integration",title:"Meeting Recorder Meetings (Read)",description:"Provides read-only access to recorded meetings and their metadata.",domain:"integrations",owners:[...O],tags:[...j,"meetings"],stability:h.Experimental},provides:[{surface:"operation",key:"meeting-recorder.meetings.list",version:"1.0.0",description:"List meetings available from the recorder provider."},{surface:"operation",key:"meeting-recorder.meetings.get",version:"1.0.0",description:"Fetch detailed metadata for a specific meeting."}]},C={meta:{key:"meeting-recorder.transcripts.read",version:"1.0.0",kind:"integration",title:"Meeting Recorder Transcripts (Read)",description:"Enables retrieval of transcripts for recorded meetings from external providers.",domain:"integrations",owners:[...O],tags:[...j,"transcripts"],stability:h.Experimental},provides:[{surface:"operation",key:"meeting-recorder.transcripts.get",version:"1.0.0",description:"Fetch the transcript for a specific meeting recording."},{surface:"operation",key:"meeting-recorder.transcripts.sync",version:"1.0.0",description:"Trigger a transcript sync from the recorder provider."}]},v={meta:{key:"meeting-recorder.webhooks",version:"1.0.0",kind:"integration",title:"Meeting Recorder Webhooks",description:"Allows processing of webhook events for meeting transcript readiness.",domain:"integrations",owners:[...O],tags:[...j,"webhooks"],stability:h.Experimental},provides:[{surface:"operation",key:"meeting-recorder.webhooks.ingest",version:"1.0.0",description:"Ingest and verify meeting recorder webhook payloads."}]};function Y0(H){return H.register(u).register(C).register(v)}var w=["platform.finance"],J=["open-banking","finance"],k={meta:{key:"openbanking.accounts.read",version:"1.0.0",kind:"integration",title:"Open Banking Accounts (Read)",description:"Provides read-only access to linked bank accounts, including account summaries and metadata.",domain:"finance",owners:[...w],tags:[...J],stability:h.Experimental},provides:[{surface:"operation",key:"openbanking.accounts.list",version:"1.0.0",description:"List bank accounts linked to a Powens open banking connection."},{surface:"operation",key:"openbanking.accounts.get",version:"1.0.0",description:"Retrieve the canonical bank account record for a specific account."},{surface:"operation",key:"openbanking.accounts.sync",version:"1.0.0",description:"Trigger a refresh of bank account metadata from the open banking provider."}]},q={meta:{key:"openbanking.transactions.read",version:"1.0.0",kind:"integration",title:"Open Banking Transactions (Read)",description:"Enables retrieval of transaction history for linked bank accounts via open banking providers.",domain:"finance",owners:[...w],tags:[...J,"transactions"],stability:h.Experimental},provides:[{surface:"operation",key:"openbanking.transactions.list",version:"1.0.0",description:"List transactions for a given bank account with optional date filtering."},{surface:"operation",key:"openbanking.transactions.sync",version:"1.0.0",description:"Synchronise transactions from the open banking provider into the canonical ledger."}]},n={meta:{key:"openbanking.balances.read",version:"1.0.0",kind:"integration",title:"Open Banking Balances (Read)",description:"Allows querying of current and available balances for linked bank accounts via open banking providers.",domain:"finance",owners:[...w],tags:[...J,"balances"],stability:h.Experimental},provides:[{surface:"operation",key:"openbanking.balances.get",version:"1.0.0",description:"Retrieve the latest known balances for a specified bank account."},{surface:"operation",key:"openbanking.balances.refresh",version:"1.0.0",description:"Force a balance refresh from the open banking provider."}]};function g0(H){return H.register(k).register(q).register(n)}function O0(H){let A=[],N=[];for(let S of H.capabilities.list()){let R=`${S.meta.key}.v${S.meta.version}`;for(let _ of S.provides??[])if(!K(H,_.surface,_.key))A.push({type:"missing_surface_spec",message:`Capability "${R}" provides ${_.surface} "${_.key}" but spec not found`,capabilityKey:R,surface:_.surface,specKey:_.key})}if(H.operations){for(let S of H.operations.list())if(S.capability){let R=H.capabilities.get(S.capability.key,S.capability.version);if(!R)A.push({type:"capability_not_found",message:`Operation "${S.meta.key}" references capability "${S.capability.key}.v${S.capability.version}" but capability not found`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"operation"});else if(!R.provides?.some((E)=>E.surface==="operation"&&E.key===S.meta.key))A.push({type:"surface_not_in_provides",message:`Operation "${S.meta.key}" claims capability "${S.capability.key}.v${S.capability.version}" but not in capability's provides`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"operation"})}}if(H.events){for(let S of H.events.list())if(S.capability){let R=H.capabilities.get(S.capability.key,S.capability.version);if(!R)A.push({type:"capability_not_found",message:`Event "${S.meta.key}" references capability "${S.capability.key}.v${S.capability.version}" but capability not found`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"event"});else if(!R.provides?.some((E)=>E.surface==="event"&&E.key===S.meta.key))A.push({type:"surface_not_in_provides",message:`Event "${S.meta.key}" claims capability "${S.capability.key}.v${S.capability.version}" but not in capability's provides`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"event"})}}if(H.presentations){for(let S of H.presentations.list())if(S.capability){let R=H.capabilities.get(S.capability.key,S.capability.version);if(!R)A.push({type:"capability_not_found",message:`Presentation "${S.meta.key}" references capability "${S.capability.key}.v${S.capability.version}" but capability not found`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"presentation"});else if(!R.provides?.some((E)=>E.surface==="presentation"&&E.key===S.meta.key))A.push({type:"surface_not_in_provides",message:`Presentation "${S.meta.key}" claims capability "${S.capability.key}.v${S.capability.version}" but not in capability's provides`,specKey:S.meta.key,capabilityKey:`${S.capability.key}.v${S.capability.version}`,surface:"presentation"})}}return{valid:A.length===0,errors:A,warnings:N}}function K(H,A,N){switch(A){case"operation":return H.operations?.has(N)??!0;case"event":return H.events?.has(N)??!0;case"presentation":return H.presentations?.has(N)??!0;case"workflow":case"resource":return!0;default:return!0}}function j0(H){let A={operations:[],events:[],presentations:[]};if(H.operations){for(let N of H.operations.list())if(!N.capability)A.operations.push(N.meta.key)}if(H.events){for(let N of H.events.list())if(!N.capability)A.events.push(N.meta.key)}if(H.presentations){for(let N of H.presentations.list())if(!N.capability)A.presentations.push(N.meta.key)}return A}var I="harness",f=["platform.harness"],D=[z.Automation,"harness","evidence","evaluation"],L=h.Experimental;var V0=T({meta:{key:"harness.evaluation",version:"1.0.0",kind:"data",title:"Harness Evaluation",description:"Run scenario evaluations and inspect assertion outcomes.",domain:I,owners:f,tags:[...D,"evaluation"],stability:L},provides:[{surface:"operation",key:"harness.evaluation.run",version:"1.0.0",description:"Run a harness scenario or suite."},{surface:"operation",key:"harness.evaluation.get",version:"1.0.0",description:"Read one evaluation result."},{surface:"event",key:"harness.evaluation.completed",version:"1.0.0",description:"Evaluation completed with assertion results."}]});var u0=T({meta:{key:"harness.evidence",version:"1.0.0",kind:"data",title:"Harness Evidence",description:"Capture and retrieve normalized evidence artifacts.",domain:I,owners:f,tags:[...D,"evidence"],stability:L},provides:[{surface:"operation",key:"harness.evidence.list",version:"1.0.0",description:"List evidence for a run."},{surface:"operation",key:"harness.evidence.get",version:"1.0.0",description:"Read one evidence artifact."},{surface:"event",key:"harness.evidence.captured",version:"1.0.0",description:"Evidence captured during execution."},{surface:"presentation",key:"harness.run.audit",version:"1.0.0",description:"Audit presentation for harness runs and evidence."}]});var q0=T({meta:{key:"harness.execution",version:"1.0.0",kind:"integration",title:"Harness Execution",description:"Run, inspect, and cancel harness sessions.",domain:I,owners:f,tags:[...D,"execution"],stability:L},provides:[{surface:"operation",key:"harness.run.start",version:"1.0.0",description:"Start a harness run."},{surface:"operation",key:"harness.run.cancel",version:"1.0.0",description:"Cancel an active harness run."},{surface:"operation",key:"harness.run.get",version:"1.0.0",description:"Read one harness run."},{surface:"event",key:"harness.run.started",version:"1.0.0",description:"Harness run started."},{surface:"event",key:"harness.run.completed",version:"1.0.0",description:"Harness run completed."},{surface:"event",key:"harness.run.failed",version:"1.0.0",description:"Harness run failed."},{surface:"event",key:"harness.step.blocked",version:"1.0.0",description:"Harness step blocked."}],requires:[{key:"control-plane.core",version:"1.0.0",optional:!0,reason:"Execution links to control-plane plans and trace IDs when present."}]});var l0=T({meta:{key:"harness.targeting",version:"1.0.0",kind:"integration",title:"Harness Targeting",description:"Resolve preview, task, shared, and sandbox harness targets.",domain:I,owners:f,tags:[...D,"targeting"],stability:L},provides:[{surface:"operation",key:"harness.target.resolve",version:"1.0.0",description:"Resolve the execution target for a harness run."}]});export{l0 as HarnessTargetingCapability,q0 as HarnessExecutionCapability,u0 as HarnessEvidenceCapability,V0 as HarnessEvaluationCapability};
