@kybernesis/kyberagent-extension-sdk 0.1.0-alpha

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.
@@ -0,0 +1,2 @@
1
+ export { d as AgentId, A as AnsweringPort, e as BlockedReason, b as BrainHit, B as BrainReadPort, a as BrainStatsView, f as BridgeDeclaration, C as ComposerCapabilityPort, g as ComposerDescriptor, h as ContributionKeyInput, D as DataEndpointPort, i as EXTENSION_HOST_SLOTS, j as EventSourcePort, k as ExtensionBridgeContributionDefinition, l as ExtensionComposerCapabilityDefinition, m as ExtensionContextualActionDefinition, n as ExtensionContributionDefinition, o as ExtensionDataEndpointDefinition, E as ExtensionDefinition, p as ExtensionHostSlot, q as ExtensionRuntime, r as ExtensionSettingsPanelDefinition, s as ExtensionSidecarContributionDefinition, t as ExtensionSurfaceDefinition, u as ExtensionWorkspaceTabDefinition, G as GatedHostPortFactory, v as HostCapabilityId, w as HostCommandDescriptor, x as HostCommandPort, y as HostContextPort, z as HostContextSnapshot, F as HostEventPort, H as HostPort, I as InvokablePort, K as KernelPermissionId, J as KernelPluginRegistryEntry, L as KernelRegistrySnapshot, N as NormalizedPluginExtensionContributionSet, M as PluginManifestContribution, O as PluginShipsState, Q as PluginThemeTokenSet, P as PortInjectionResult, R as ProviderRuntimeProjectionDescriptor, S as SeamCallContext, T as SeamPermissionDenied, U as SidecarDeclaration, V as VerifiedPrincipal, W as WorkspaceTabContributionMetadata, X as canonicalHostCapabilities, Y as defineBridge, Z as defineBridgeContribution, _ as defineComposerCapability, $ as defineContextualAction, a0 as defineDataEndpoint, a1 as defineExtension, a2 as defineProviderRuntimeProjection, a3 as defineSettingsPanel, a4 as defineSidecar, a5 as defineSidecarContribution, a6 as defineSurface, a7 as defineThemeTokens, a8 as deriveExtensionHostCapabilities, a9 as emitExtensionContributionSet, aa as gatedHostPort, ab as hostSlots, ac as makeAgentId, ad as makeSeamCallContext, ae as requiresHostCapabilities, af as requiresKernelPermissions, ag as validateDefinitionCrossRefs, ah as validateExtensionDefinition, ai as workspaceTab } from './index-M4tx9uKW.js';
2
+ import 'effect';
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ import {
2
+ EXTENSION_HOST_SLOTS,
3
+ SeamPermissionDenied,
4
+ canonicalHostCapabilities,
5
+ defineBridge,
6
+ defineBridgeContribution,
7
+ defineComposerCapability,
8
+ defineContextualAction,
9
+ defineDataEndpoint,
10
+ defineExtension,
11
+ defineProviderRuntimeProjection,
12
+ defineSettingsPanel,
13
+ defineSidecar,
14
+ defineSidecarContribution,
15
+ defineSurface,
16
+ defineThemeTokens,
17
+ deriveExtensionHostCapabilities,
18
+ emitExtensionContributionSet,
19
+ gatedHostPort,
20
+ hostSlots,
21
+ makeAgentId,
22
+ makeSeamCallContext,
23
+ requiresHostCapabilities,
24
+ requiresKernelPermissions,
25
+ validateDefinitionCrossRefs,
26
+ validateExtensionDefinition,
27
+ workspaceTab
28
+ } from "./chunk-ZDAZ7Q2A.js";
29
+ export {
30
+ EXTENSION_HOST_SLOTS,
31
+ SeamPermissionDenied,
32
+ canonicalHostCapabilities,
33
+ defineBridge,
34
+ defineBridgeContribution,
35
+ defineComposerCapability,
36
+ defineContextualAction,
37
+ defineDataEndpoint,
38
+ defineExtension,
39
+ defineProviderRuntimeProjection,
40
+ defineSettingsPanel,
41
+ defineSidecar,
42
+ defineSidecarContribution,
43
+ defineSurface,
44
+ defineThemeTokens,
45
+ deriveExtensionHostCapabilities,
46
+ emitExtensionContributionSet,
47
+ gatedHostPort,
48
+ hostSlots,
49
+ makeAgentId,
50
+ makeSeamCallContext,
51
+ requiresHostCapabilities,
52
+ requiresKernelPermissions,
53
+ validateDefinitionCrossRefs,
54
+ validateExtensionDefinition,
55
+ workspaceTab
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,234 @@
1
+ import { B as BrainReadPort, a as BrainStatsView, b as BrainHit, S as SeamCallContext, K as KernelPermissionId, H as HostPort, V as VerifiedPrincipal, E as ExtensionDefinition, A as AnsweringPort, P as PortInjectionResult, c as SeamResponse, d as AgentId } from '../index-M4tx9uKW.js';
2
+ import 'effect';
3
+
4
+ /**
5
+ * The behavioural host port an extension is INJECTED with — the testing seam.
6
+ *
7
+ * This is the "safe half" of the seam's dependency-injection story (SPEC Track 2):
8
+ * an extension contribution should *receive* its host collaborators rather than
9
+ * reach for a daemon global, so it can be unit-tested against a fake. The injector
10
+ * is the runner — the host in production, the test harness in tests.
11
+ *
12
+ * DELIBERATELY MINIMAL, on two axes:
13
+ * - Surface: only the brain READ channel is modelled — the one a data extension
14
+ * actually uses today. The full channel taxonomy is still under review
15
+ * (capability-model.md), so this is NOT a cemented contract.
16
+ * - Capability: an extension gets a NARROW read port (`BrainReadPort`), not the
17
+ * full write-capable `@kybernesis/brain-contracts` `BrainProvider`. Extensions
18
+ * only *consume* the host-owned brain (capability-model rule 3), so interface
19
+ * segregation applies. Aligning these signatures with the real provider so the
20
+ * production host can satisfy this port directly is the production-DI step
21
+ * (host PR) — see docs/kdd/decisions/adr-0028-autonomous-execution-stops-at-the-host-runtime-boundary-host.md.
22
+ */
23
+
24
+ /**
25
+ * The NARROW seed host port (brain.read only). Superseded by `HostPort` in
26
+ * ../seam-ports.ts; kept until Phase 5 retires it. `InMemoryHost` implements both.
27
+ */
28
+ interface ExtensionHostPort {
29
+ brain(agentName: string): BrainReadPort;
30
+ }
31
+
32
+ type InMemoryAgentBrain = {
33
+ entities?: {
34
+ id: string;
35
+ title: string;
36
+ }[];
37
+ notes?: string[];
38
+ };
39
+ /**
40
+ * A real-but-lightweight brain read provider backed by an in-memory seed — the
41
+ * "Fake" category (xUnit), named by backing strategy to sit beside the real
42
+ * Remote/local `BrainProvider`. Deterministic and daemon-free: a unit test can
43
+ * exercise a brain-reading extension without SQLite, Cortex, or a running daemon.
44
+ */
45
+ declare class InMemoryBrainProvider implements BrainReadPort {
46
+ private readonly seed;
47
+ constructor(seed?: InMemoryAgentBrain);
48
+ stats(): Promise<BrainStatsView>;
49
+ query(text: string, opts?: {
50
+ limit?: number;
51
+ }): Promise<BrainHit[]>;
52
+ }
53
+ /**
54
+ * In-memory implementation of the host port: the test harness plays the host's
55
+ * injector role and hands each agent its own InMemoryBrainProvider (brain is
56
+ * agent-keyed). Seed per agent; an unseeded agent gets an empty brain.
57
+ */
58
+ declare class InMemoryHost implements ExtensionHostPort {
59
+ private readonly brains;
60
+ constructor(seed?: Record<string, InMemoryAgentBrain>);
61
+ brain(agentName: string): InMemoryBrainProvider;
62
+ /**
63
+ * Inject a gated, ctx-bound `HostPort` — the GROWN contract an extension actually
64
+ * consumes (red-team A1/A3; P5-PORTS-1 brought forward as conformance-prep). The
65
+ * runner builds the raw port from this host's in-memory state, binds the active
66
+ * agent from `ctx`, then wraps it in `gatedHostPort(grants)` — the SAME gate
67
+ * production uses (SDK-N3). This is what makes C9 ("green against InMemoryHost")
68
+ * a real conformance check instead of a vacuous one.
69
+ */
70
+ inject(ctx: SeamCallContext, grants: ReadonlySet<KernelPermissionId>): HostPort;
71
+ }
72
+
73
+ /**
74
+ * The C1–C16 conformance suite — the Extension SDK spec, MECHANICALLY ENFORCED.
75
+ *
76
+ * This module is the Phase-4 deliverable of the SDK-coherence program (docs/61).
77
+ * docs/65 §5 states the conformance requirements in prose; THIS file encodes them as
78
+ * runnable checks an extension is run through against `InMemoryHost` (the DI test
79
+ * host, ADR-3). The suite IS the spec: a requirement that isn't a check here isn't
80
+ * enforced, and a check that no reference extension exercises is vacuous — so the
81
+ * suite carries BOTH ≥2 distinct conformant reference extensions (must pass) AND a
82
+ * negative fixture per check (must be REJECTED). The Phase-3 red-team killed the old
83
+ * harness for being green over only-good inputs; the negatives are the fix.
84
+ *
85
+ * FREEZE (ADR-6): this is conformance-prep, freeze-EXEMPT, and lives entirely under
86
+ * `packages/extension-sdk/src/testing/`. It touches no production runtime (daemon,
87
+ * desktop). It DEFINES what Phase-5 production code must satisfy; it does not write it.
88
+ *
89
+ * RED BY DESIGN (docs/61 `phase4_will_be_red_until_phase5`): C10/C11/C12, C14/C15,
90
+ * the grant-store and the agent-registry mint are HOST/BUILDER-side and have no
91
+ * production impl yet. They are modelled as `phase5` checks behind DI seams
92
+ * (`ConformanceWiring`): with the seam absent (today) they report a RED "pending"
93
+ * row but do NOT fail the process — so the suite stays green for the other devs while
94
+ * being honestly red-in-meaning. When Phase 5 wires a seam in (from a daemon-side
95
+ * test importing this suite), the check runs for real and a regression fails loudly.
96
+ * `CONFORMANCE_STRICT=1` makes pending rows fail the process too (CI gate once ready).
97
+ */
98
+
99
+ /**
100
+ * One extension, as the conformance suite needs to see it: its DECLARED shape (the
101
+ * definition — permissions, contributions) AND its RUNTIME behaviour (answering ports
102
+ * wired to an injected host). A conformant extension passes every `enforced` check;
103
+ * a negative fixture is tagged with the one check it is built to violate.
104
+ */
105
+ interface ConformanceSubject {
106
+ readonly name: string;
107
+ /** Host-attested principal — what the host would stamp (never read from a payload). */
108
+ readonly principal: VerifiedPrincipal;
109
+ /** The declared definition (built via the define* builders). */
110
+ readonly definition: ExtensionDefinition;
111
+ /**
112
+ * Wire the answering EXT ports to an INJECTED (already-gated) host port, keyed by
113
+ * contributionId. This is the runtime moment: the host injects the port at
114
+ * activation and the contributions close over it. Rendering kinds (surface,
115
+ * settingsPanel) contribute NO answering port (C8).
116
+ */
117
+ activate(host: HostPort): ReadonlyMap<string, AnsweringPort>;
118
+ /**
119
+ * The identity the extension would act under, given its call context and a
120
+ * (possibly forged) extensionId arriving in a payload. Conformant ⇒ `ctx.principal.id`,
121
+ * NEVER the payload value (C4). A harness probe because "where did identity come
122
+ * from" is otherwise invisible from the outside.
123
+ */
124
+ identityProbe(ctx: SeamCallContext, forgedExtensionId: string): string;
125
+ }
126
+ /** A negative fixture: a subject built to FAIL exactly one check, proving it bites. */
127
+ interface NegativeFixture {
128
+ readonly violates: string;
129
+ readonly subject: ConformanceSubject;
130
+ }
131
+ type SeamRouteOp = 'query' | 'describe' | 'invoke' | 'subscribe' | 'drain';
132
+ /**
133
+ * The Phase-5 PRODUCTION seam runner contract (the daemon host-side path). The suite
134
+ * tests against this interface; the daemon supplies the impl in Phase 5 (DI, ADR-3)
135
+ * by importing this suite from a daemon-side test. Until then it is absent and
136
+ * C10/C11/C12 + grant-store report `pending`. Encoding the contract here is what
137
+ * makes "the seam runner honours activation + gate on EVERY route" a checkable claim
138
+ * instead of a hope.
139
+ */
140
+ interface SeamRunner {
141
+ /** The activation authority's verdict for a principal in a given call context. */
142
+ activate(principalId: string, ctx: SeamCallContext): PortInjectionResult;
143
+ /**
144
+ * The ONE grant store: the grants for this principal — NOT a hardcoded startup list
145
+ * (DIV-2, displaces handlers.ts:542). The gate is fed from here.
146
+ */
147
+ grantsFor(principalId: string, ctx: SeamCallContext): ReadonlySet<KernelPermissionId>;
148
+ /**
149
+ * Route an op to a contribution. MUST consult `activate()` + the gate for EVERY op,
150
+ * INCLUDING the `drain` subscription side-door (C10 / HOST-N2): an inactive or
151
+ * ungranted principal gets a typed denial and the contribution is never reached.
152
+ */
153
+ route(op: SeamRouteOp, target: {
154
+ readonly principalId: string;
155
+ readonly contributionId: string;
156
+ }, payload: Record<string, unknown> | undefined, ctx: SeamCallContext): Promise<SeamResponse>;
157
+ /** How many independent activation authorities exist. C11 demands EXACTLY ONE. */
158
+ activationAuthorityCount(): number;
159
+ }
160
+ /**
161
+ * The DI seams Phase-5 wires in to turn the `phase5` checks from RED→green. Every
162
+ * field is optional; an absent field ⇒ its dependent checks report `pending`.
163
+ */
164
+ interface ConformanceWiring {
165
+ /** Production seam runner ⇒ enables C10, C11, C12, grant-store. */
166
+ readonly runner?: SeamRunner;
167
+ /**
168
+ * Override for the builder cross-validator (C15). Defaults to the shipped SDK
169
+ * `validateDefinitionCrossRefs` (Phase-5 slice 1 landed it in-package), so C15 is
170
+ * enforced without wiring; a daemon may substitute its own. Returns declaration
171
+ * errors for a definition (empty ⇒ valid).
172
+ */
173
+ readonly validateDefinitionCrossRefs?: (definition: ExtensionDefinition) => readonly string[];
174
+ /**
175
+ * Production registry-aware agent mint (HOST-N3) ⇒ enables agentId-registry. Must
176
+ * REJECT a name absent from `registry`, unlike today's `makeAgentId` (blank-only).
177
+ */
178
+ readonly mintAttestedAgent?: (attestedName: string, registry: ReadonlySet<string>) => AgentId;
179
+ /** The agent registry the mint validates against (and the suite seeds brains for). */
180
+ readonly agentRegistry?: ReadonlySet<string>;
181
+ }
182
+ type CheckStatus = 'pass' | 'fail' | 'pending';
183
+ type Disposition = 'enforced' | 'phase5';
184
+ interface CheckVerdict {
185
+ readonly id: string;
186
+ readonly title: string;
187
+ readonly disposition: Disposition;
188
+ readonly status: CheckStatus;
189
+ readonly notes: readonly string[];
190
+ }
191
+ interface ConformanceInput {
192
+ readonly subjects: readonly ConformanceSubject[];
193
+ readonly negatives: readonly NegativeFixture[];
194
+ readonly wiring?: ConformanceWiring;
195
+ /** Seed for the InMemoryHost — two agents seeded DIFFERENTLY so C2 can see variance. */
196
+ readonly host?: InMemoryHost;
197
+ }
198
+ interface ConformanceReport {
199
+ readonly verdicts: readonly CheckVerdict[];
200
+ readonly enforcedFailures: number;
201
+ readonly phase5Pending: number;
202
+ readonly phase5Regressions: number;
203
+ readonly negativeGaps: number;
204
+ readonly ok: boolean;
205
+ }
206
+ declare function runConformance(input: ConformanceInput): Promise<ConformanceReport>;
207
+ /** Render the visual conformance checklist (docs/61 Principle 6). */
208
+ declare function renderReport(report: ConformanceReport, opts?: {
209
+ strict?: boolean;
210
+ }): string;
211
+
212
+ /**
213
+ * Conformance subjects — the inputs the C1–C16 suite runs against.
214
+ *
215
+ * TWO distinct CONFORMANT reference extensions (docs/61 Phase-4 requirement: "≥2
216
+ * distinct reference extensions … design a second"):
217
+ * • Seam Probe — the canonical multi-channel probe: reads brain + host-context, asks
218
+ * host-command, has a rendering surface + a data endpoint + a composer capability.
219
+ * • Notes Lens — a deliberately DIFFERENT shape: brain-only (one declared permission),
220
+ * a data endpoint + a contextual action (chat/invoke), no host-context/command.
221
+ * Two different declared footprints and contribution kinds is what makes C2/C3/C8
222
+ * non-trivial — a suite over one extension can't tell "honours the contract" from
223
+ * "happens to match this one extension".
224
+ *
225
+ * Plus a NEGATIVE FIXTURE per check — a tiny extension built to FAIL exactly one
226
+ * requirement. Without these the suite is vacuous (the Phase-3 red-team's verdict on
227
+ * the old harness): every check here must both PASS the references AND REJECT its
228
+ * negative.
229
+ */
230
+
231
+ declare const REFERENCE_EXTENSIONS: readonly ConformanceSubject[];
232
+ declare const NEGATIVE_FIXTURES: readonly NegativeFixture[];
233
+
234
+ export { BrainHit, BrainReadPort, BrainStatsView, type CheckVerdict, type ConformanceInput, type ConformanceReport, type ConformanceSubject, type ConformanceWiring, type ExtensionHostPort, type InMemoryAgentBrain, InMemoryBrainProvider, InMemoryHost, NEGATIVE_FIXTURES, type NegativeFixture, REFERENCE_EXTENSIONS, type SeamRouteOp, type SeamRunner, renderReport, runConformance };