@kehto/services 0.22.0 → 0.23.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.
package/README.md CHANGED
@@ -52,35 +52,24 @@ Current draft posture:
52
52
 
53
53
  ## NAP-INTENT manifest resolver
54
54
 
55
- Kehto follows merged [NAP-INTENT at
56
- `5ac0490461ca6fec2f0d2e45b4835cf9bc08de24`](https://github.com/napplet/naps/blob/5ac0490461ca6fec2f0d2e45b4835cf9bc08de24/naps/NAP-INTENT.md).
57
- Callers invoke a stable, queryless `napplet:<archetype>/<action>` convention.
58
- Installed verified manifest tags produce exact `{ slug, convention }`
59
- declarations; numbered protocol names, trailing metadata, and payload inspection
60
- do not select a handler.
61
-
62
- - `manifestToIntentCatalogEntry()` converts resolved manifest
63
- `{ dTag, title?, archetypes: [{ slug, convention }] }` data into exact
64
- candidates with `actions` and `conventions`.
65
- - `createCatalogIntentResolver()` filters by exact convention, applies the
66
- user-owned default/chooser/explicit-authorization policy, and asks an
67
- `IntentTargetController` to create/focus a target and dispatch the selected
68
- convention.
69
- - `createIntentService()` validates source envelopes, uses the runtime-attested
70
- sender, returns one final canonical `IntentResult`, and broadcasts catalog
71
- changes through recipient-policy-aware runtime sends.
72
-
73
- `ok: true` means the selected target was ready and the convention was dispatched.
74
- The result includes `handled`, `handler`, `windowId`, and `convention`. The
75
- target receives the convention and opaque payload through one runtime-attested
76
- `inc.event`; there is no separate `intent.deliver` lifecycle.
77
-
78
- Paja currently exposes only an exact-contract development simulator, and the
79
- playground currently exposes only a verified-manifest catalog builder. Phase
80
- 105 completed released `@napplet/*` package adoption plus the persistent live
81
- catalog/controller and feed-to-profile flow. Its public `Intent*` types are
82
- canonical releases from `@napplet/core` / `@napplet/nap`, not a local mirror;
83
- successful results report completed target dispatch.
55
+ Kehto follows [NAP-INTENT PR #106](https://github.com/napplet/naps/blob/fc121fc264615482143eda86125863d2e1f741a2/naps/NAP-INTENT.md) at `fc121fc264615482143eda86125863d2e1f741a2`. The shell binding normalizes URI calls into a
56
+ queryless convention and separate opaque payload before service dispatch.
57
+
58
+ - `manifestToIntentCatalogEntry()` converts verified `{ catalogId, title?, archetypes: [{ slug, convention, params }] }` facts into exact contracts.
59
+ - `createCatalogIntentResolver()` applies authorized explicit selection, an explicit chooser, or default → recommendation → compatible choice. Payload contents never select a handler.
60
+ - `createIntentService()` requires `resolveSender(windowId)`, derives the sender from the authenticated endpoint, validates requests, and returns one canonical result.
61
+
62
+ `ok: true` means the controller retained responsibility for delivery. It contains
63
+ `archetype`, `action`, `convention`, and the opaque handler ID. It does not expose
64
+ a window ID or promise target completion. The controller waits for the current
65
+ target's authenticated readiness and sends one `intent.deliver`; host observers
66
+ receive later completion or failure without a second source result. Source
67
+ teardown does not cancel accepted work. `intent.onDelivery` buffers arrivals;
68
+ INC is not required.
69
+
70
+ Paja and playground use verified persistent catalogs separately from live frames.
71
+ The installed `@napplet/nap@0.32.0` types predate this contract; the bounded local
72
+ canonical types and their removal condition are documented below.
84
73
 
85
74
  ## Quick Start
86
75
 
@@ -627,7 +616,7 @@ complete normal result without `error`: this explicit policy reconciles the
627
616
  draft error-only example without a mixed theme/error extension.
628
617
 
629
618
  ### Types
630
- `AudioSource`, `AudioServiceOptions`, `Notification`, `NotificationServiceOptions`, `IdentityServiceOptions`, `RelayPoolServiceOptions`, `CacheServiceOptions`, `CoordinatedRelayOptions`, `KeysServiceOptions`, `MediaServiceOptions`, `NotifyServiceOptions`, `NotifyPresentation`, `NotifyInteractionMessage`, `ThemeServiceOptions`, `ThemeService`, `IntentOpenOptions`, `IntentRequest`, `IntentResult`, `IntentCandidate`, `IntentAvailability`, `IntentResolver`, `IntentTargetController`, `IntentDispatchParams`, `IntentTargetDispatch`, `BleServiceOptions`, `BleServiceContext`, `WebrtcServiceOptions`, `WebrtcServiceContext`, `DmServiceOptions`, `DmAdapter`, `DmRelayPool`, `Nip17DmAdapterOptions`, `NdrDmAdapterOptions`, `CordnDmAdapterOptions`.
619
+ `AudioSource`, `AudioServiceOptions`, `Notification`, `NotificationServiceOptions`, `IdentityServiceOptions`, `RelayPoolServiceOptions`, `CacheServiceOptions`, `CoordinatedRelayOptions`, `KeysServiceOptions`, `MediaServiceOptions`, `NotifyServiceOptions`, `NotifyPresentation`, `NotifyInteractionMessage`, `ThemeServiceOptions`, `ThemeService`, `IntentRequest`, `IntentResult`, `IntentCandidate`, `IntentAvailability`, `IntentResolver`, `IntentTargetController`, `IntentDispatchParams`, `IntentTargetDispatch`, `BleServiceOptions`, `BleServiceContext`, `WebrtcServiceOptions`, `WebrtcServiceContext`, `DmServiceOptions`, `DmAdapter`, `DmRelayPool`, `Nip17DmAdapterOptions`, `NdrDmAdapterOptions`, `CordnDmAdapterOptions`.
631
620
 
632
621
  ## API Reference
633
622
 
@@ -637,3 +626,17 @@ Generated API module: `docs/api/modules/_kehto_services.html` (run `pnpm docs:ap
637
626
  ## License
638
627
 
639
628
  MIT
629
+
630
+ ## NIP-5D event compatibility
631
+
632
+ Current manifests use a direct artifact `x` hash, plain-text `content`, role-matched
633
+ `z`/`i` intent declarations, and required `R` / optional `O` domains. Kehto also
634
+ accepts legacy aggregate events through an isolated compatibility adapter.
635
+ Existing `aggregateHash` host/cache/ACL fields carry the verified artifact hash
636
+ for current events; legacy identities keep their original aggregate. Both paths
637
+ verify signatures and bytes before runtime injection and `srcdoc` execution.
638
+ For the schema and removal boundary, see [event migration](https://kehto.github.io/web/docs/migrations/NIP-5D-EVENT-SCHEMA.html).
639
+
640
+ ## Canonical intent contracts
641
+
642
+ `@kehto/services` temporarily owns the canonical NAP-INTENT PR #106 contracts because `@napplet/nap@0.32.0` has not yet published them. Candidates use opaque `id` plus exact `contracts`; successful results contain only `ok`, `archetype`, `action`, `convention`, and `handler` (never `handled`, `windowId`, or `newWindow`). `createIntentService` requires `resolveSender(windowId)` and rejects caller-supplied sender fields. `IntentResolverContext.sourceWindowId` and `IntentDispatchParams.sourceWindowId` are host-only correlation fields: they must never appear in `intent.deliver` or `intent.invoke.result`. A target controller accepts retained work as `{ completion }`; completion failure is host observation, not a second canonical result. Remove these local types only when an upstream package exports the checked PR #106 surface and Kehto's service/runtime regression suite proves direct replacement.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ServiceHandler, Signer, RelayEventResult, ServiceRuntimeContext } from '@kehto/runtime';
2
2
  import { IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage } from '@napplet/nap/identity/types';
3
- import { NostrFilter, NostrEvent, EventTemplate, IntentRequest, IntentResult, IntentAvailability, IntentBehavior, IntentCandidate, LinkOpenOptions, LinkOpenResult, ListSupport, ListRef, ListItem, ListOptions, ListMutationResult, SerialEvent, SerialOpenRequest, SerialOpenResult, BleEvent, BleOpenRequest, BleOpenResult, BleService, BleAttribute, BleWriteOptions, WebrtcEvent, WebrtcOpenRequest, WebrtcOpenResult, CommonProfileTarget, CommonProfileResult, CommonFollowsResult, CommonActionResult, CommonReaction, CommonReportTarget, CommonReportReason, DmStatus, DmConversationQuery, DmConversationPage, DmMessageQuery, DmMessagePage, DmSendRequest, DmSendResult, DmSubscribeRequest, DmMessage, DmSubscription, DmOk, DmHexPubkey, FsInfo, FsPickOptions, FsPickResult, FsMetadata, FsDirectoryEntry, FsReadOptions, FsReadResult, FsWriteOptions, FsWriteResult, FsMkdirOptions, FsWatchOptions, FsChange, FsError } from '@napplet/core';
4
- export { DmConversation, DmConversationPage, DmConversationQuery, DmHexPubkey, DmMessage, DmMessagePage, DmMessageQuery, DmMessageStatus, DmOk, DmPeer, DmSendRequest, DmSendResult, DmStatus, DmSubscribeRequest, DmSubscription, DmTimestamp, IntentAvailability, IntentBehavior, IntentCandidate, IntentHandlerPreference, IntentOpenOptions, IntentRequest, IntentResult } from '@napplet/core';
3
+ import { NostrFilter, NostrEvent, EventTemplate, LinkOpenOptions, LinkOpenResult, ListSupport, ListRef, ListItem, ListOptions, ListMutationResult, SerialEvent, SerialOpenRequest, SerialOpenResult, BleEvent, BleOpenRequest, BleOpenResult, BleService, BleAttribute, BleWriteOptions, WebrtcEvent, WebrtcOpenRequest, WebrtcOpenResult, CommonProfileTarget, CommonProfileResult, CommonFollowsResult, CommonActionResult, CommonReaction, CommonReportTarget, CommonReportReason, DmStatus, DmConversationQuery, DmConversationPage, DmMessageQuery, DmMessagePage, DmSendRequest, DmSendResult, DmSubscribeRequest, DmMessage, DmSubscription, DmOk, DmHexPubkey, FsInfo, FsPickOptions, FsPickResult, FsMetadata, FsDirectoryEntry, FsReadOptions, FsReadResult, FsWriteOptions, FsWriteResult, FsMkdirOptions, FsWatchOptions, FsChange, FsError } from '@napplet/core';
4
+ export { DmConversation, DmConversationPage, DmConversationQuery, DmHexPubkey, DmMessage, DmMessagePage, DmMessageQuery, DmMessageStatus, DmOk, DmPeer, DmSendRequest, DmSendResult, DmStatus, DmSubscribeRequest, DmSubscription, DmTimestamp } from '@napplet/core';
5
5
  import { MediaMetadata, MediaAction } from '@napplet/nap/media/types';
6
6
  export { MediaAction } from '@napplet/nap/media/types';
7
7
  import { NotifyActionMessage, NotifyClickedMessage, NotifyDismissedMessage, NotifySendMessage, NotifyChannelRegisterMessage, NotifyControl } from '@napplet/nap/notify/types';
@@ -2090,219 +2090,162 @@ interface HttpUploaderOptions {
2090
2090
  */
2091
2091
  declare function createHttpUploader(options: HttpUploaderOptions): Uploader;
2092
2092
 
2093
- /**
2094
- * intent-service.ts — NAP-INTENT (archetype intent dispatch) reference service.
2095
- *
2096
- * Shell-side handler for the NAP-INTENT wire protocol. It is a pure envelope
2097
- * router: it validates `intent.*` envelopes, delegates archetype resolution,
2098
- * default handling and target dispatch to an injected
2099
- * {@link IntentResolver}, then posts correlated result and push messages back
2100
- * to the napplet.
2101
- *
2102
- * The resolver is injected (options-as-bridge) so this service has no shell or
2103
- * target-lifecycle dependency and is fully unit-testable. A concrete
2104
- * catalog-backed resolver ships alongside as {@link createCatalogIntentResolver}.
2105
- *
2106
- * ──────────────────────────── Responsibilities ────────────────────────────
2107
- * Inbound: intent.invoke, intent.available, intent.handlers
2108
- * Outbound: intent.invoke.result, intent.available.result,
2109
- * intent.handlers.result, intent.changed
2110
- *
2111
- * The shell owns archetype→handler resolution, the user's default-handler
2112
- * preference, chooser, and target lifecycle policy behind the
2113
- * {@link IntentResolver}. This service only marshals the wire protocol and
2114
- * fans `intent.changed` pushes out to eligible napplets.
2115
- *
2116
- * @example
2117
- * ```ts
2118
- * import { createIntentService, createCatalogIntentResolver } from '@kehto/services';
2119
- *
2120
- * const resolver = createCatalogIntentResolver({ loadCatalog, targets });
2121
- * runtime.registerService('intent', createIntentService({ resolver }));
2122
- * ```
2123
- *
2124
- * @packageDocumentation
2125
- */
2093
+ /** Canonical NAP-INTENT contracts pending upstream @napplet/nap publication. */
2094
+ /** Lifecycle hints that remain subject to host workspace policy. */
2095
+ interface IntentBehavior {
2096
+ readonly focus?: boolean;
2097
+ readonly reuse?: boolean;
2098
+ }
2099
+ /** A verified named-manifest recommendation; relay URLs are discovery hints only. */
2100
+ interface IntentHandlerHint {
2101
+ readonly address: string;
2102
+ readonly relays?: readonly string[];
2103
+ }
2104
+ /** One advertised stable convention and its ordered, untyped parameter names. */
2105
+ interface IntentContract {
2106
+ readonly convention: string;
2107
+ readonly params: readonly string[];
2108
+ }
2109
+ /** Normalized runtime request. `action` and `convention` are always URI-derived. */
2110
+ interface IntentRequest {
2111
+ readonly archetype: string;
2112
+ readonly action: string;
2113
+ readonly convention: string;
2114
+ readonly payload?: unknown;
2115
+ readonly handler?: string;
2116
+ readonly handlerHint?: IntentHandlerHint;
2117
+ readonly behavior?: IntentBehavior;
2118
+ }
2119
+ /** Runtime-assigned catalog candidate; its ID is never a bare manifest d-tag. */
2120
+ interface IntentCandidate {
2121
+ readonly id: string;
2122
+ readonly title?: string;
2123
+ readonly actions: readonly string[];
2124
+ readonly conventions: readonly string[];
2125
+ readonly contracts: readonly IntentContract[];
2126
+ readonly isDefault?: boolean;
2127
+ }
2128
+ /** Candidate availability for one manifest-advertised role. */
2129
+ interface IntentAvailability {
2130
+ readonly archetype: string;
2131
+ readonly available: boolean;
2132
+ readonly candidates: readonly IntentCandidate[];
2133
+ readonly hasDefault: boolean;
2134
+ }
2135
+ /** Successful results mean retained delivery responsibility, never completion. */
2136
+ type IntentResult = {
2137
+ readonly ok: true;
2138
+ readonly archetype: string;
2139
+ readonly action: string;
2140
+ readonly convention: string;
2141
+ readonly handler: string;
2142
+ } | {
2143
+ readonly ok: false;
2144
+ readonly error: string;
2145
+ };
2146
+ /** Runtime-attested target delivery after it becomes ready. */
2147
+ interface IntentDelivery {
2148
+ readonly sender: string;
2149
+ readonly archetype: string;
2150
+ readonly action: string;
2151
+ readonly convention: string;
2152
+ readonly payload?: unknown;
2153
+ }
2154
+
2155
+ /** NAP-INTENT wire service using canonical Kehto contracts. */
2126
2156
 
2127
- /** Context passed to {@link IntentResolver.invoke} for trust/attribution. */
2157
+ /** Runtime-attested source catalog identity passed to intent policy. */
2128
2158
  interface IntentResolverContext {
2129
- /** Runtime-attested dTag of the napplet that issued the request. */
2130
- sender: string;
2159
+ readonly sender: string;
2160
+ /** Authenticated runtime source, internal to host policy and never wire data. */
2161
+ readonly sourceWindowId?: string;
2131
2162
  }
2132
- /**
2133
- * Abstract intent resolver. Implementors own the installed-napplet catalog,
2134
- * archetype→handler resolution, the user's default-handler preference, the
2135
- * chooser and target lifecycle/delivery policy. The
2136
- * service translates wire envelopes into these calls and back.
2137
- */
2163
+ /** Installed-catalog resolver and lifecycle policy. */
2138
2164
  interface IntentResolver {
2139
- /**
2140
- * Resolve and dispatch the request.
2141
- *
2142
- * @param request - Validated normalized intent request.
2143
- * @param context - Runtime-attested source identity.
2144
- * @returns The canonical structured dispatch result.
2145
- */
2146
2165
  invoke(request: IntentRequest, context: IntentResolverContext): IntentResult | Promise<IntentResult>;
2147
- /** Report whether the runtime can currently satisfy `archetype`, and how. */
2148
2166
  available(archetype: string): IntentAvailability | Promise<IntentAvailability>;
2149
- /** Report availability for every archetype the runtime can currently satisfy. */
2150
- handlers(): IntentAvailability[] | Promise<IntentAvailability[]>;
2151
- /**
2152
- * Register for availability changes (a napplet installed/removed, or a default
2153
- * handler changed). The service forwards each change to served napplets as an
2154
- * `intent.changed` push. Returns an unsubscribe handle. Resolvers whose
2155
- * catalog never changes at runtime MAY omit this.
2156
- */
2167
+ handlers(): readonly IntentAvailability[] | Promise<readonly IntentAvailability[]>;
2157
2168
  onChanged?(listener: (availability: IntentAvailability) => void): () => void;
2158
2169
  }
2159
- /** Options for {@link createIntentService}. */
2170
+ /** Service dependencies including a source-bound verified catalog identity lookup. */
2160
2171
  interface IntentServiceOptions {
2161
- /** The intent resolver the shell uses to route archetypes. Required. */
2162
- resolver: IntentResolver;
2172
+ readonly resolver: IntentResolver;
2173
+ /** Maps an authenticated runtime window to its verified catalog ID. */
2174
+ readonly resolveSender: (windowId: string) => string | undefined;
2163
2175
  }
2164
2176
  /**
2165
- * Create the NAP-INTENT service handler.
2177
+ * Create the NAP-INTENT service. Request data does not carry a sender field;
2178
+ * unknown fields are rejected and the sender always comes from `resolveSender`.
2179
+ *
2180
+ * @param options - Resolver plus authenticated window-to-catalog identity lookup.
2181
+ * @returns A runtime service handler for `intent.*` messages.
2166
2182
  *
2167
- * @param options - Must provide an {@link IntentResolver}.
2168
- * @returns A `ServiceHandler` ready for `runtime.registerService('intent', handler)`.
2169
- * @throws If `options.resolver` is missing.
2183
+ * @example
2184
+ * ```ts
2185
+ * runtime.registerService('intent', createIntentService({
2186
+ * resolver,
2187
+ * resolveSender: (windowId) => verifiedCatalogIdForWindow(windowId),
2188
+ * }));
2189
+ * ```
2170
2190
  */
2171
2191
  declare function createIntentService(options: IntentServiceOptions): ServiceHandler;
2172
2192
 
2173
- /**
2174
- * catalog-intent-resolver.ts — NAP-INTENT concrete {@link IntentResolver}.
2175
- *
2176
- * A reference resolver backed by installed, verified NIP-5A manifest
2177
- * archetype/convention tags plus host-supplied user policy. Catalog order and
2178
- * payload contents never select a handler.
2179
- *
2180
- * Selection policy:
2181
- * 1. Filter installed candidates by declared action and convention support.
2182
- * 2. Require positive host authorization for an explicit handler dTag.
2183
- * 3. Otherwise use an explicit chooser, a compatible user default, the sole
2184
- * compatible candidate, or an injected chooser.
2185
- * 4. Reject ambiguity when no chooser policy exists.
2186
- *
2187
- * The catalog, defaults, chooser, authorization hook, and target controller are
2188
- * injected, so this resolver has no shell, manifest, or DOM dependency.
2189
- *
2190
- * @packageDocumentation
2191
- */
2193
+ /** Verified-manifest NAP-INTENT catalog resolution. */
2192
2194
 
2193
- /** The exact manifest-derived conventions a napplet fulfills for one archetype. */
2195
+ /** Exact contracts fulfilled by a catalog entry for one role. */
2194
2196
  interface IntentArchetypeSupport {
2195
- /** Verbs derived from this napplet's accepted conventions. */
2196
- actions: string[];
2197
- /** Stable queryless convention identities declared by the manifest. */
2198
- conventions: string[];
2197
+ readonly contracts: readonly IntentContract[];
2199
2198
  }
2200
- /**
2201
- * One installed napplet's intent surface, derived from its signed NIP-5A
2202
- * manifest. Keyed by archetype slug so a single napplet can fulfill several
2203
- * roles.
2204
- */
2199
+ /** A verified installed napplet, keyed by a runtime-assigned opaque catalog ID. */
2205
2200
  interface IntentCatalogEntry {
2206
- /** The napplet's dTag. */
2207
- dTag: string;
2208
- /** Human-readable title from the manifest. */
2209
- title?: string;
2210
- /** Archetype slug to exact manifest-derived support. */
2211
- archetypes: Record<string, IntentArchetypeSupport>;
2201
+ readonly id: string;
2202
+ readonly title?: string;
2203
+ readonly archetypes: Readonly<Record<string, IntentArchetypeSupport>>;
2212
2204
  }
2213
- /** Exact values dispatched to one selected intent target. */
2205
+ /** Immutable delivery values retained by the target controller after acceptance. */
2214
2206
  interface IntentDispatchParams {
2215
- /** Selected target napplet dTag. */
2216
2207
  readonly handler: string;
2217
- /** Runtime-attested source napplet dTag. */
2218
2208
  readonly sender: string;
2219
- /** Requested target archetype. */
2220
2209
  readonly archetype: string;
2221
- /** Requested action. */
2222
2210
  readonly action: string;
2223
- /** Selected stable convention used to deliver the payload. */
2224
2211
  readonly convention: string;
2225
- /** Opaque convention payload. */
2226
2212
  readonly payload?: unknown;
2227
- /** Copied target lifecycle hints. */
2228
2213
  readonly behavior?: Readonly<IntentBehavior>;
2214
+ /** Authenticated host-only source correlation. Never serialize into delivery. */
2215
+ readonly sourceWindowId?: string;
2229
2216
  }
2230
- /** Result returned by a host after creating/focusing and dispatching to a target. */
2231
- interface IntentTargetDispatch {
2232
- /** Shell-assigned target window identifier. */
2233
- readonly windowId: string;
2217
+ /** Retained work observable by the host without a second source result. */
2218
+ interface IntentTargetAcceptance {
2219
+ readonly completion: Promise<void>;
2234
2220
  }
2235
- /** Host controller that owns target lifecycle and convention delivery policy. */
2221
+ /** Owns target lifecycle and retains delivery before returning to the source. */
2236
2222
  interface IntentTargetController {
2237
- /**
2238
- * Create or focus the selected target, wait until it can receive the
2239
- * convention, then enqueue delivery through the host's ordinary carrier.
2240
- *
2241
- * @param params - Immutable selected target and dispatch values.
2242
- * @returns The created/focused target identity.
2243
- */
2244
- dispatch(params: IntentDispatchParams): IntentTargetDispatch | Promise<IntentTargetDispatch>;
2223
+ accept(params: IntentDispatchParams): IntentTargetAcceptance;
2245
2224
  }
2246
- /** Options for {@link createCatalogIntentResolver}. */
2225
+ /** Catalog, user-policy, and lifecycle hooks for the reference resolver. */
2247
2226
  interface CatalogIntentResolverOptions {
2248
- /** Return the installed-napplet catalog sourced from signed manifests. */
2249
- loadCatalog(): IntentCatalogEntry[] | Promise<IntentCatalogEntry[]>;
2250
- /** Target controller that creates/readies the selected target and dispatches its convention. */
2227
+ loadCatalog(): readonly IntentCatalogEntry[] | Promise<readonly IntentCatalogEntry[]>;
2251
2228
  targets: IntentTargetController;
2252
- /**
2253
- * Return the user's default handler dTag for an archetype.
2254
- *
2255
- * @param archetype - Normalized archetype slug.
2256
- * @returns The user-selected default dTag, or `undefined`.
2257
- */
2258
2229
  getDefaultHandler?(archetype: string): string | undefined;
2259
- /**
2260
- * Ask user policy to select one exact-compatible candidate.
2261
- *
2262
- * @param archetype - Normalized archetype slug.
2263
- * @param candidates - Only candidates with an exact matching contract.
2264
- * @param sender - Runtime-attested source napplet dTag.
2265
- * @returns A candidate dTag, or `undefined` when the user cancels.
2266
- */
2267
- chooseHandler?(archetype: string, candidates: IntentCandidate[], sender: string): string | undefined | Promise<string | undefined>;
2268
- /**
2269
- * Authorize a caller's explicit handler dTag preference.
2270
- *
2271
- * @param sender - Runtime-attested source napplet dTag.
2272
- * @param handler - Explicit requested handler dTag.
2273
- * @param request - Normalized intent request.
2274
- * @param candidate - Installed exact-compatible candidate.
2275
- * @returns `true` only when explicit targeting is user-authorized.
2276
- */
2277
- authorizeExplicitHandler?(sender: string, handler: string, request: IntentRequest, candidate: IntentCandidate): boolean | Promise<boolean>;
2230
+ chooseHandler?(archetype: string, candidates: readonly IntentCandidate[], sender: string): string | undefined | Promise<string | undefined>;
2231
+ authorizeExplicitHandler?(sender: string, handler: string, request: IntentRequest, candidate: IntentCandidate, context?: IntentResolverContext): boolean | Promise<boolean>;
2232
+ /** Resolve a valid recommendation only to an already compatible verified entry. */
2233
+ resolveHandlerHint?(hint: IntentHandlerHint, candidates: readonly IntentCandidate[]): string | undefined | Promise<string | undefined>;
2278
2234
  }
2279
- /**
2280
- * A {@link IntentResolver} backed by a catalog, with a host hook to announce
2281
- * catalog/default changes.
2282
- */
2283
2235
  interface CatalogIntentResolver extends IntentResolver {
2284
- /**
2285
- * Announce that the catalog or default handler for `archetype` changed.
2286
- *
2287
- * @param archetype - Changed archetype slug.
2288
- * @returns Nothing.
2289
- */
2290
2236
  notifyChanged(archetype: string): void;
2291
2237
  }
2292
2238
  /**
2293
- * Create a catalog-backed NAP-INTENT resolver.
2239
+ * Create a catalog-backed resolver from verified manifest contracts.
2294
2240
  *
2295
- * @param options - Catalog loader and target controller plus optional user
2296
- * default, chooser, and explicit-handler authorization hooks.
2297
- * @returns A catalog-backed resolver.
2298
- * @throws If required catalog or target-controller options are missing.
2241
+ * @param options - Verified catalog, selection policy, and target lifecycle hooks.
2242
+ * @returns A resolver suitable for {@link createIntentService}.
2299
2243
  *
2300
2244
  * @example
2301
2245
  * ```ts
2302
2246
  * const resolver = createCatalogIntentResolver({
2303
- * loadCatalog: () => installedNapplets,
2304
- * targets: { dispatch: (params) => openAndDispatch(params) },
2305
- * getDefaultHandler: (archetype) => userDefaults[archetype],
2247
+ * loadCatalog: () => installedCatalog,
2248
+ * targets: { accept: (params) => ({ completion: deliverToTarget(params) }) },
2306
2249
  * });
2307
2250
  * ```
2308
2251
  */
@@ -2311,7 +2254,7 @@ declare function createCatalogIntentResolver(options: CatalogIntentResolverOptio
2311
2254
  /**
2312
2255
  * manifest-intent-catalog.ts — signed-manifest → NAP-INTENT catalog adapter.
2313
2256
  *
2314
- * Adapts a resolved NIP-5A/5D napplet manifest's archetype tags into an
2257
+ * Adapts a resolved NIP-5D manifest's normalized routing declarations into an
2315
2258
  * {@link IntentCatalogEntry} — the shape `createCatalogIntentResolver.loadCatalog`
2316
2259
  * consumes. This lets NAP-INTENT availability and handler candidacy flow from
2317
2260
  * verified manifest tags rather than host-injected catalog data.
@@ -2331,24 +2274,25 @@ declare function createCatalogIntentResolver(options: CatalogIntentResolverOptio
2331
2274
  * resolved manifest without importing `@kehto/nip`.
2332
2275
  */
2333
2276
  interface ManifestArchetypeInput {
2334
- /** The napplet's `d` identifier. */
2335
- dTag: string;
2277
+ /** Publisher/kind-safe catalog identifier derived from the verified event. */
2278
+ catalogId: string;
2336
2279
  /** Optional human-readable title from the manifest. */
2337
2280
  title?: string;
2338
2281
  /**
2339
- * Ordered convention contracts from the manifest's `archetype` tags.
2282
+ * Normalized current z/i combinations or exact legacy archetype pairs.
2340
2283
  */
2341
2284
  archetypes: Array<{
2342
2285
  slug: string;
2343
2286
  convention: string;
2287
+ params: string[];
2344
2288
  }>;
2345
2289
  }
2346
2290
  /**
2347
2291
  * Map a resolved napplet manifest's archetype data into an
2348
2292
  * {@link IntentCatalogEntry}.
2349
2293
  *
2350
- * Repeated slugs group into one support record; action and convention arrays
2351
- * remain stable and deduplicated.
2294
+ * Repeated slugs group into one support record; exact contracts and their
2295
+ * parameter arrays remain stable and deduplicated.
2352
2296
  *
2353
2297
  * @param manifest - A resolved manifest's structural archetype data.
2354
2298
  * @returns The `IntentCatalogEntry` for `createCatalogIntentResolver`.
@@ -2356,15 +2300,14 @@ interface ManifestArchetypeInput {
2356
2300
  * @example
2357
2301
  * ```ts
2358
2302
  * manifestToIntentCatalogEntry({
2359
- * dTag: 'profile-viewer',
2303
+ * catalogId: 'nip5d:35129:publisher:profile-viewer',
2360
2304
  * title: 'Profile',
2361
- * archetypes: [{ slug: 'profile', convention: 'napplet:profile/open' }],
2305
+ * archetypes: [{ slug: 'profile', convention: 'napplet:profile/open', params: ['pubkey'] }],
2362
2306
  * });
2363
- * // → { dTag: 'profile-viewer', title: 'Profile',
2364
- * // archetypes: { profile: {
2365
- * // actions: ['open'],
2366
- * // conventions: ['napplet:profile/open'],
2367
- * // } } }
2307
+ * // → { id: 'nip5d:35129:publisher:profile-viewer', title: 'Profile',
2308
+ * // archetypes: { profile: { contracts: [
2309
+ * // { convention: 'napplet:profile/open', params: ['pubkey'] },
2310
+ * // ] } } }
2368
2311
  * ```
2369
2312
  */
2370
2313
  declare function manifestToIntentCatalogEntry(manifest: ManifestArchetypeInput): IntentCatalogEntry;
@@ -2854,4 +2797,4 @@ interface FsService extends ServiceHandler {
2854
2797
  */
2855
2798
  declare function createFsService(options: FsServiceOptions): FsService;
2856
2799
 
2857
- export { type BleServiceContext, type BleServiceOptions, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type CommonServiceContext, type CommonServiceOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type ConfigSettingsContext, type CoordinatedRelayOptions, type CordnCodecResult, type CordnCoordinatorClient, type CordnCoordinatorSubscription, type CordnDmAdapterOptions, type CordnDmClient, type CordnGroupMessage, type CordnRelayCoordinatorOptions, type CountRequest, type CountResult, type CountServiceOptions, type DmAdapter, DmMemoryStore, type DmRelayPool, type DmService, type DmServiceOptions, type FsBackend, type FsBackendChange, type FsBackendWatch, type FsService, FsServiceError, type FsServiceOptions, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentCatalogEntry, type IntentDispatchParams, type IntentResolver, type IntentResolverContext, type IntentServiceOptions, type IntentTargetController, type IntentTargetDispatch, type KeysServiceOptions, type LinkOpenContext, type LinkServiceOptions, type ListsServiceContext, type ListsServiceOptions, type ManifestArchetypeInput, type MaybePromise, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NdrDmAdapterOptions, type NdrRelayTransport, type NdrRelayTransportOptions, type NdrRumorLike, type NdrRuntimeLike, type Nip17DmAdapterOptions, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyInteractionMessage, type NotifyPresentation, type NotifyServiceOptions, type OutboxEventOptions, type OutboxEventResult, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxQueryStream, type OutboxQueryStreamSink, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceErrorCode, type ResourceFetchInit, type ResourceInfoContext, type ResourceInfoProvider, type ResourceService, ResourceServiceError, type ResourceServiceOptions, type SerialServiceContext, type SerialServiceOptions, type SignEvent, type StreamingOutboxRouter, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadInfo, type UploadInfoContext, type UploadInfoProvider, type UploadRail, type UploadRailInfo, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, type WebrtcServiceContext, type WebrtcServiceOptions, createBleService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createCommonService, createConfigService, createCoordinatedRelay, createCordnDmAdapter, createCordnRelayCoordinatorClient, createCountService, createDmService, createFsService, createHttpUploader, createIdentityService, createIntentService, createKeysService, createLinkService, createListsService, createMediaService, createNdrDmAdapter, createNdrRelayTransport, createNip17DmAdapter, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createSerialService, createThemeService, createUploadService, createWebrtcService, manifestToIntentCatalogEntry, resolveConfigValues, validateConfigSchema };
2800
+ export { type BleServiceContext, type BleServiceOptions, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type CommonServiceContext, type CommonServiceOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type ConfigSettingsContext, type CoordinatedRelayOptions, type CordnCodecResult, type CordnCoordinatorClient, type CordnCoordinatorSubscription, type CordnDmAdapterOptions, type CordnDmClient, type CordnGroupMessage, type CordnRelayCoordinatorOptions, type CountRequest, type CountResult, type CountServiceOptions, type DmAdapter, DmMemoryStore, type DmRelayPool, type DmService, type DmServiceOptions, type FsBackend, type FsBackendChange, type FsBackendWatch, type FsService, FsServiceError, type FsServiceOptions, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentContract, type IntentDelivery, type IntentDispatchParams, type IntentHandlerHint, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentTargetAcceptance, type IntentTargetController, type KeysServiceOptions, type LinkOpenContext, type LinkServiceOptions, type ListsServiceContext, type ListsServiceOptions, type ManifestArchetypeInput, type MaybePromise, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NdrDmAdapterOptions, type NdrRelayTransport, type NdrRelayTransportOptions, type NdrRumorLike, type NdrRuntimeLike, type Nip17DmAdapterOptions, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyInteractionMessage, type NotifyPresentation, type NotifyServiceOptions, type OutboxEventOptions, type OutboxEventResult, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxQueryStream, type OutboxQueryStreamSink, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceErrorCode, type ResourceFetchInit, type ResourceInfoContext, type ResourceInfoProvider, type ResourceService, ResourceServiceError, type ResourceServiceOptions, type SerialServiceContext, type SerialServiceOptions, type SignEvent, type StreamingOutboxRouter, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadInfo, type UploadInfoContext, type UploadInfoProvider, type UploadRail, type UploadRailInfo, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, type WebrtcServiceContext, type WebrtcServiceOptions, createBleService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createCommonService, createConfigService, createCoordinatedRelay, createCordnDmAdapter, createCordnRelayCoordinatorClient, createCountService, createDmService, createFsService, createHttpUploader, createIdentityService, createIntentService, createKeysService, createLinkService, createListsService, createMediaService, createNdrDmAdapter, createNdrRelayTransport, createNip17DmAdapter, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createSerialService, createThemeService, createUploadService, createWebrtcService, manifestToIntentCatalogEntry, resolveConfigValues, validateConfigSchema };