var{defineProperty:R,getOwnPropertyNames:M,getOwnPropertyDescriptor:g}=Object,S=Object.prototype.hasOwnProperty;function f(L){return this[L]}var o=(L)=>{var N=(Z??=new WeakMap).get(L),O;if(N)return N;if(N=R({},"__esModule",{value:!0}),L&&typeof L==="object"||typeof L==="function"){for(var _ of M(L))if(!S.call(N,_))R(N,_,{get:f.bind(L,_),enumerable:!(O=g(L,_))||O.enumerable})}return Z.set(L,N),N},Z;var x=(L)=>L;function h(L,N){this[L]=x.bind(null,N)}var y=(L,N)=>{for(var O in N)R(L,O,{get:N[O],enumerable:!0,configurable:!0,set:h.bind(N,O)})};var c=(L,N)=>()=>(L&&(N=L(L=0)),N);var j={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},z={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},a=z,B={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"},i=B;import{compareVersions as C}from"compare-versions";var Y=(L,N)=>`${L}.v${N}`;class k{items=new Map;surfaceIndex=null;register(L){let N=Y(L.meta.key,L.meta.version);if(this.items.has(N))throw Error(`Duplicate capability ${N}`);return this.items.set(N,L),this.surfaceIndex=null,this}list(){return[...this.items.values()]}get(L,N){if(N!=null)return this.items.get(Y(L,N));let O;for(let _ of this.items.values()){if(_.meta.key!==L)continue;if(!O||C(_.meta.version,O.meta.version)>0)O=_}return O}satisfies(L,N){if(L.optional)return!0;if(N?.some((_)=>q(_,L)))return!0;let O=L.version?this.get(L.key,L.version):this.get(L.key);if(!O)return!1;if(L.kind&&O.meta.kind!==L.kind)return!1;if(L.version!=null&&O.meta.version!==L.version)return!1;return!0}buildSurfaceIndex(){if(this.surfaceIndex)return this.surfaceIndex;this.surfaceIndex=new Map;for(let L of this.items.values()){let N=Y(L.meta.key,L.meta.version);for(let O of L.provides??[]){let _=`${O.surface}:${O.key}`;if(!this.surfaceIndex.has(_))this.surfaceIndex.set(_,new Set);this.surfaceIndex.get(_)?.add(N)}}return this.surfaceIndex}getOperationsFor(L,N){let O=this.get(L,N);if(!O)return[];return O.provides?.filter((_)=>_.surface==="operation").map((_)=>_.key)??[]}getEventsFor(L,N){let O=this.get(L,N);if(!O)return[];return O.provides?.filter((_)=>_.surface==="event").map((_)=>_.key)??[]}getPresentationsFor(L,N){let O=this.get(L,N);if(!O)return[];return O.provides?.filter((_)=>_.surface==="presentation").map((_)=>_.key)??[]}getWorkflowsFor(L,N){let O=this.get(L,N);if(!O)return[];return O.provides?.filter((_)=>_.surface==="workflow").map((_)=>_.key)??[]}getResourcesFor(L,N){let O=this.get(L,N);if(!O)return[];return O.provides?.filter((_)=>_.surface==="resource").map((_)=>_.key)??[]}getCapabilitiesForOperation(L){let O=this.buildSurfaceIndex().get(`operation:${L}`);if(!O)return[];return[...O].map((_)=>{let P=this.items.get(_);return{key:P?.meta.key??"",version:P?.meta.version??""}})}getCapabilitiesForEvent(L){let O=this.buildSurfaceIndex().get(`event:${L}`);if(!O)return[];return[...O].map((_)=>{let P=this.items.get(_);return{key:P?.meta.key??"",version:P?.meta.version??""}})}getCapabilitiesForPresentation(L){let O=this.buildSurfaceIndex().get(`presentation:${L}`);if(!O)return[];return[...O].map((_)=>{let P=this.items.get(_);return{key:P?.meta.key??"",version:P?.meta.version??""}})}getAncestors(L,N){let O=[],_=new Set,P=this.get(L,N);while(P?.extends){let A=Y(P.extends.key,P.extends.version);if(_.has(A))break;_.add(A);let T=this.get(P.extends.key,P.extends.version);if(!T)break;O.push(T),P=T}return O}getEffectiveRequirements(L,N){let O=this.get(L,N);if(!O)return[];let _=this.getAncestors(L,N),P=new Map;for(let A of[..._].reverse())for(let T of A.requires??[])P.set(T.key,T);for(let A of O.requires??[])P.set(A.key,A);return[...P.values()]}getEffectiveSurfaces(L,N){let O=this.get(L,N);if(!O)return[];let _=this.getAncestors(L,N),P=[];for(let A of[..._].reverse())P.push(...A.provides??[]);return P.push(...O.provides??[]),P}}function q(L,N){if(L.key!==N.key)return!1;if(N.version!=null&&L.version!==N.version)return!1;return!0}function r(L){return Y(L.meta.key,L.meta.version)}function $(L){return L}var s=[{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 D extends Error{capabilityKey;requiredVersion;constructor(L,N){let O=N?`.v${N}`:"";super(`Missing required capability: ${L}${O}`);this.name="CapabilityMissingError",this.capabilityKey=L,this.requiredVersion=N}}class I{capabilities;capabilityVersions;constructor(L){let N=new Set,O=new Map;for(let _ of L)N.add(_.key),O.set(_.key,_.version);this.capabilities=N,this.capabilityVersions=O}hasCapability(L,N){if(!this.capabilities.has(L))return!1;if(N!=null)return this.capabilityVersions.get(L)===N;return!0}requireCapability(L,N){if(!this.hasCapability(L,N))throw new D(L,N)}hasAllCapabilities(L){return L.every((N)=>this.capabilities.has(N))}hasAnyCapability(L){return L.some((N)=>this.capabilities.has(N))}getMatchingCapabilities(L){if(!L.includes("*"))return this.capabilities.has(L)?[L]:[];let N=L.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*"),O=new RegExp(`^${N}$`);return[...this.capabilities].filter((_)=>O.test(_))}}function LL(L){return new I(L)}function _L(){return new I([])}function NL(L){return new I(L)}function G(L,N){if(!N.capability)return{allowed:!0};let{key:O,version:_}=N.capability;if(L.hasCapability(O,_))return{allowed:!0};return{allowed:!1,missingCapability:{key:O,version:_},reason:`Operation "${N.meta.key}" requires capability "${O}.v${_}"`}}function AL(L,N){let O=G(L,N);if(!O.allowed&&O.missingCapability)throw new D(O.missingCapability.key,O.missingCapability.version)}function U(L,N){if(!N.capability)return{allowed:!0};let{key:O,version:_}=N.capability;if(L.hasCapability(O,_))return{allowed:!0};return{allowed:!1,missingCapability:{key:O,version:_},reason:`Event "${N.meta.key}" requires capability "${O}.v${_}"`}}function TL(L,N){let O=U(L,N);if(!O.allowed&&O.missingCapability)throw new D(O.missingCapability.key,O.missingCapability.version)}function W(L,N){if(!N.capability)return{allowed:!0};let{key:O,version:_}=N.capability;if(L.hasCapability(O,_))return{allowed:!0};return{allowed:!1,missingCapability:{key:O,version:_},reason:`Presentation "${N.meta.key}" requires capability "${O}.v${_}"`}}function jL(L,N){let O=W(L,N);if(!O.allowed&&O.missingCapability)throw new D(O.missingCapability.key,O.missingCapability.version)}function DL(L,N){return N.filter((O)=>G(L,O).allowed)}function YL(L,N){return N.filter((O)=>U(L,O).allowed)}function IL(L,N){return N.filter((O)=>W(L,O).allowed)}var H=["platform.integrations"],J=["meeting-recorder","transcripts","integrations"],m={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:[...H],tags:[...J,"meetings"],stability:j.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."}]},l={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:[...H],tags:[...J,"transcripts"],stability:j.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."}]},K={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:[...H],tags:[...J,"webhooks"],stability:j.Experimental},provides:[{surface:"operation",key:"meeting-recorder.webhooks.ingest",version:"1.0.0",description:"Ingest and verify meeting recorder webhook payloads."}]};function BL(L){return L.register(m).register(l).register(K)}var Q=["platform.finance"],X=["open-banking","finance"],d={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:[...Q],tags:[...X],stability:j.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."}]},b={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:[...Q],tags:[...X,"transactions"],stability:j.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."}]},v={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:[...Q],tags:[...X,"balances"],stability:j.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 QL(L){return L.register(d).register(b).register(v)}function ZL(L){let N=[],O=[];for(let _ of L.capabilities.list()){let P=`${_.meta.key}.v${_.meta.version}`;for(let A of _.provides??[])if(!u(L,A.surface,A.key))N.push({type:"missing_surface_spec",message:`Capability "${P}" provides ${A.surface} "${A.key}" but spec not found`,capabilityKey:P,surface:A.surface,specKey:A.key})}if(L.operations){for(let _ of L.operations.list())if(_.capability){let P=L.capabilities.get(_.capability.key,_.capability.version);if(!P)N.push({type:"capability_not_found",message:`Operation "${_.meta.key}" references capability "${_.capability.key}.v${_.capability.version}" but capability not found`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"operation"});else if(!P.provides?.some((T)=>T.surface==="operation"&&T.key===_.meta.key))N.push({type:"surface_not_in_provides",message:`Operation "${_.meta.key}" claims capability "${_.capability.key}.v${_.capability.version}" but not in capability's provides`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"operation"})}}if(L.events){for(let _ of L.events.list())if(_.capability){let P=L.capabilities.get(_.capability.key,_.capability.version);if(!P)N.push({type:"capability_not_found",message:`Event "${_.meta.key}" references capability "${_.capability.key}.v${_.capability.version}" but capability not found`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"event"});else if(!P.provides?.some((T)=>T.surface==="event"&&T.key===_.meta.key))N.push({type:"surface_not_in_provides",message:`Event "${_.meta.key}" claims capability "${_.capability.key}.v${_.capability.version}" but not in capability's provides`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"event"})}}if(L.presentations){for(let _ of L.presentations.list())if(_.capability){let P=L.capabilities.get(_.capability.key,_.capability.version);if(!P)N.push({type:"capability_not_found",message:`Presentation "${_.meta.key}" references capability "${_.capability.key}.v${_.capability.version}" but capability not found`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"presentation"});else if(!P.provides?.some((T)=>T.surface==="presentation"&&T.key===_.meta.key))N.push({type:"surface_not_in_provides",message:`Presentation "${_.meta.key}" claims capability "${_.capability.key}.v${_.capability.version}" but not in capability's provides`,specKey:_.meta.key,capabilityKey:`${_.capability.key}.v${_.capability.version}`,surface:"presentation"})}}return{valid:N.length===0,errors:N,warnings:O}}function u(L,N,O){switch(N){case"operation":return L.operations?.has(O)??!0;case"event":return L.events?.has(O)??!0;case"presentation":return L.presentations?.has(O)??!0;case"workflow":case"resource":return!0;default:return!0}}function $L(L){let N={operations:[],events:[],presentations:[]};if(L.operations){for(let O of L.operations.list())if(!O.capability)N.operations.push(O.meta.key)}if(L.events){for(let O of L.events.list())if(!O.capability)N.events.push(O.meta.key)}if(L.presentations){for(let O of L.presentations.list())if(!O.capability)N.presentations.push(O.meta.key)}return N}var w="control-plane",V=[z.PlatformCore],E=[B.Automation,"control-plane","agent-runtime"],F=j.Experimental;var hL=$({meta:{key:"control-plane.skill-registry",version:"1.0.0",kind:"integration",title:"Control Plane Skill Registry",description:"Signed skill lifecycle and compatibility governance.",domain:w,owners:V,tags:[...E,"skills"],stability:F},provides:[{surface:"operation",key:"controlPlane.skill.install",version:"1.0.0",description:"Install signed skill artifacts."},{surface:"operation",key:"controlPlane.skill.disable",version:"1.0.0",description:"Disable installed skill artifacts."},{surface:"operation",key:"controlPlane.skill.list",version:"1.0.0",description:"List installed skill artifacts."},{surface:"operation",key:"controlPlane.skill.verify",version:"1.0.0",description:"Verify skill signatures and constraints."},{surface:"event",key:"controlPlane.skill.installed",version:"1.0.0",description:"Skill install succeeded."},{surface:"event",key:"controlPlane.skill.rejected",version:"1.0.0",description:"Skill install rejected."}]});export{hL as ControlPlaneSkillRegistryCapability};
