var{defineProperty:B,getOwnPropertyNames:E,getOwnPropertyDescriptor:V}=Object,F=Object.prototype.hasOwnProperty;function M(H){return this[H]}var o=(H)=>{var _=($??=new WeakMap).get(H),N;if(_)return _;if(_=B({},"__esModule",{value:!0}),H&&typeof H==="object"||typeof H==="function"){for(var A of E(H))if(!F.call(_,A))B(_,A,{get:M.bind(H,A),enumerable:!(N=V(H,A))||N.enumerable})}return $.set(H,_),_},$;var x=(H)=>H;function f(H,_){this[H]=x.bind(null,_)}var y=(H,_)=>{for(var N in _)B(H,N,{get:_[N],enumerable:!0,configurable:!0,set:f.bind(_,N)})};var c=(H,_)=>()=>(H&&(_=H(H=0)),_);var L={Idea:"idea",InCreation:"in_creation",Experimental:"experimental",Beta:"beta",Stable:"stable",Deprecated:"deprecated"},g={PlatformCore:"platform.core",PlatformSigil:"platform.sigil",PlatformMarketplace:"platform.marketplace",PlatformMessaging:"platform.messaging",PlatformContent:"platform.content",PlatformFeatureFlags:"platform.featureflags",PlatformFinance:"platform.finance"},a=g,J={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"},s=J;import{compareVersions as C}from"compare-versions";var j=(H,_)=>`${H}.v${_}`;class q{items=new Map;surfaceIndex=null;register(H){let _=j(H.meta.key,H.meta.version);if(this.items.has(_))throw Error(`Duplicate capability ${_}`);return this.items.set(_,H),this.surfaceIndex=null,this}list(){return[...this.items.values()]}get(H,_){if(_!=null)return this.items.get(j(H,_));let N;for(let A of this.items.values()){if(A.meta.key!==H)continue;if(!N||C(A.meta.version,N.meta.version)>0)N=A}return N}satisfies(H,_){if(H.optional)return!0;if(_?.some((A)=>m(A,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 _=j(H.meta.key,H.meta.version);for(let N of H.provides??[]){let A=`${N.surface}:${N.key}`;if(!this.surfaceIndex.has(A))this.surfaceIndex.set(A,new Set);this.surfaceIndex.get(A)?.add(_)}}return this.surfaceIndex}getOperationsFor(H,_){let N=this.get(H,_);if(!N)return[];return N.provides?.filter((A)=>A.surface==="operation").map((A)=>A.key)??[]}getEventsFor(H,_){let N=this.get(H,_);if(!N)return[];return N.provides?.filter((A)=>A.surface==="event").map((A)=>A.key)??[]}getPresentationsFor(H,_){let N=this.get(H,_);if(!N)return[];return N.provides?.filter((A)=>A.surface==="presentation").map((A)=>A.key)??[]}getWorkflowsFor(H,_){let N=this.get(H,_);if(!N)return[];return N.provides?.filter((A)=>A.surface==="workflow").map((A)=>A.key)??[]}getResourcesFor(H,_){let N=this.get(H,_);if(!N)return[];return N.provides?.filter((A)=>A.surface==="resource").map((A)=>A.key)??[]}getCapabilitiesForOperation(H){let N=this.buildSurfaceIndex().get(`operation:${H}`);if(!N)return[];return[...N].map((A)=>{let D=this.items.get(A);return{key:D?.meta.key??"",version:D?.meta.version??""}})}getCapabilitiesForEvent(H){let N=this.buildSurfaceIndex().get(`event:${H}`);if(!N)return[];return[...N].map((A)=>{let D=this.items.get(A);return{key:D?.meta.key??"",version:D?.meta.version??""}})}getCapabilitiesForPresentation(H){let N=this.buildSurfaceIndex().get(`presentation:${H}`);if(!N)return[];return[...N].map((A)=>{let D=this.items.get(A);return{key:D?.meta.key??"",version:D?.meta.version??""}})}getAncestors(H,_){let N=[],A=new Set,D=this.get(H,_);while(D?.extends){let Y=j(D.extends.key,D.extends.version);if(A.has(Y))break;A.add(Y);let I=this.get(D.extends.key,D.extends.version);if(!I)break;N.push(I),D=I}return N}getEffectiveRequirements(H,_){let N=this.get(H,_);if(!N)return[];let A=this.getAncestors(H,_),D=new Map;for(let Y of[...A].reverse())for(let I of Y.requires??[])D.set(I.key,I);for(let Y of N.requires??[])D.set(Y.key,Y);return[...D.values()]}getEffectiveSurfaces(H,_){let N=this.get(H,_);if(!N)return[];let A=this.getAncestors(H,_),D=[];for(let Y of[...A].reverse())D.push(...Y.provides??[]);return D.push(...N.provides??[]),D}}function m(H,_){if(H.key!==_.key)return!1;if(_.version!=null&&H.version!==_.version)return!1;return!0}function t(H){return j(H.meta.key,H.meta.version)}function G(H){return H}var i=[{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 R extends Error{capabilityKey;requiredVersion;constructor(H,_){let N=_?`.v${_}`:"";super(`Missing required capability: ${H}${N}`);this.name="CapabilityMissingError",this.capabilityKey=H,this.requiredVersion=_}}class z{capabilities;capabilityVersions;constructor(H){let _=new Set,N=new Map;for(let A of H)_.add(A.key),N.set(A.key,A.version);this.capabilities=_,this.capabilityVersions=N}hasCapability(H,_){if(!this.capabilities.has(H))return!1;if(_!=null)return this.capabilityVersions.get(H)===_;return!0}requireCapability(H,_){if(!this.hasCapability(H,_))throw new R(H,_)}hasAllCapabilities(H){return H.every((_)=>this.capabilities.has(_))}hasAnyCapability(H){return H.some((_)=>this.capabilities.has(_))}getMatchingCapabilities(H){if(!H.includes("*"))return this.capabilities.has(H)?[H]:[];let _=H.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*"),N=new RegExp(`^${_}$`);return[...this.capabilities].filter((A)=>N.test(A))}}function H0(H){return new z(H)}function A0(){return new z([])}function _0(H){return new z(H)}function S(H,_){if(!_.capability)return{allowed:!0};let{key:N,version:A}=_.capability;if(H.hasCapability(N,A))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:A},reason:`Operation "${_.meta.key}" requires capability "${N}.v${A}"`}}function Y0(H,_){let N=S(H,_);if(!N.allowed&&N.missingCapability)throw new R(N.missingCapability.key,N.missingCapability.version)}function U(H,_){if(!_.capability)return{allowed:!0};let{key:N,version:A}=_.capability;if(H.hasCapability(N,A))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:A},reason:`Event "${_.meta.key}" requires capability "${N}.v${A}"`}}function I0(H,_){let N=U(H,_);if(!N.allowed&&N.missingCapability)throw new R(N.missingCapability.key,N.missingCapability.version)}function W(H,_){if(!_.capability)return{allowed:!0};let{key:N,version:A}=_.capability;if(H.hasCapability(N,A))return{allowed:!0};return{allowed:!1,missingCapability:{key:N,version:A},reason:`Presentation "${_.meta.key}" requires capability "${N}.v${A}"`}}function L0(H,_){let N=W(H,_);if(!N.allowed&&N.missingCapability)throw new R(N.missingCapability.key,N.missingCapability.version)}function R0(H,_){return _.filter((N)=>S(H,N).allowed)}function j0(H,_){return _.filter((N)=>U(H,N).allowed)}function z0(H,_){return _.filter((N)=>W(H,N).allowed)}var Q=["platform.integrations"],T=["meeting-recorder","transcripts","integrations"],k={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:[...Q],tags:[...T,"meetings"],stability:L.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."}]},K={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:[...Q],tags:[...T,"transcripts"],stability:L.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."}]},d={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:[...Q],tags:[...T,"webhooks"],stability:L.Experimental},provides:[{surface:"operation",key:"meeting-recorder.webhooks.ingest",version:"1.0.0",description:"Ingest and verify meeting recorder webhook payloads."}]};function Q0(H){return H.register(k).register(K).register(d)}var X=["platform.finance"],Z=["open-banking","finance"],u={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:[...X],tags:[...Z],stability:L.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."}]},v={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:[...X],tags:[...Z,"transactions"],stability:L.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."}]},b={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:[...X],tags:[...Z,"balances"],stability:L.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 Z0(H){return H.register(u).register(v).register(b)}function G0(H){let _=[],N=[];for(let A of H.capabilities.list()){let D=`${A.meta.key}.v${A.meta.version}`;for(let Y of A.provides??[])if(!l(H,Y.surface,Y.key))_.push({type:"missing_surface_spec",message:`Capability "${D}" provides ${Y.surface} "${Y.key}" but spec not found`,capabilityKey:D,surface:Y.surface,specKey:Y.key})}if(H.operations){for(let A of H.operations.list())if(A.capability){let D=H.capabilities.get(A.capability.key,A.capability.version);if(!D)_.push({type:"capability_not_found",message:`Operation "${A.meta.key}" references capability "${A.capability.key}.v${A.capability.version}" but capability not found`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"operation"});else if(!D.provides?.some((I)=>I.surface==="operation"&&I.key===A.meta.key))_.push({type:"surface_not_in_provides",message:`Operation "${A.meta.key}" claims capability "${A.capability.key}.v${A.capability.version}" but not in capability's provides`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"operation"})}}if(H.events){for(let A of H.events.list())if(A.capability){let D=H.capabilities.get(A.capability.key,A.capability.version);if(!D)_.push({type:"capability_not_found",message:`Event "${A.meta.key}" references capability "${A.capability.key}.v${A.capability.version}" but capability not found`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"event"});else if(!D.provides?.some((I)=>I.surface==="event"&&I.key===A.meta.key))_.push({type:"surface_not_in_provides",message:`Event "${A.meta.key}" claims capability "${A.capability.key}.v${A.capability.version}" but not in capability's provides`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"event"})}}if(H.presentations){for(let A of H.presentations.list())if(A.capability){let D=H.capabilities.get(A.capability.key,A.capability.version);if(!D)_.push({type:"capability_not_found",message:`Presentation "${A.meta.key}" references capability "${A.capability.key}.v${A.capability.version}" but capability not found`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"presentation"});else if(!D.provides?.some((I)=>I.surface==="presentation"&&I.key===A.meta.key))_.push({type:"surface_not_in_provides",message:`Presentation "${A.meta.key}" claims capability "${A.capability.key}.v${A.capability.version}" but not in capability's provides`,specKey:A.meta.key,capabilityKey:`${A.capability.key}.v${A.capability.version}`,surface:"presentation"})}}return{valid:_.length===0,errors:_,warnings:N}}function l(H,_,N){switch(_){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 S0(H){let _={operations:[],events:[],presentations:[]};if(H.operations){for(let N of H.operations.list())if(!N.capability)_.operations.push(N.meta.key)}if(H.events){for(let N of H.events.list())if(!N.capability)_.events.push(N.meta.key)}if(H.presentations){for(let N of H.presentations.list())if(!N.capability)_.presentations.push(N.meta.key)}return _}var w="harness",O=["platform.harness"],P=[J.Automation,"harness","evidence","evaluation"],h=L.Experimental;var g0=G({meta:{key:"harness.execution",version:"1.0.0",kind:"integration",title:"Harness Execution",description:"Run, inspect, and cancel harness sessions.",domain:w,owners:O,tags:[...P,"execution"],stability:h},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."}]});export{g0 as HarnessExecutionCapability};
