@kehto/services 0.9.1 → 0.10.1

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
@@ -3,7 +3,7 @@
3
3
  Reference service handlers for the napplet protocol — audio, notifications, identity, relay pool, cache, keys, media, notify, theme.
4
4
 
5
5
  > **Alpha status:** Kehto is an early runtime implementation for a draft NIP-5D
6
- > protocol. NUB contracts and service envelopes are not final; treat these
6
+ > protocol. NAP contracts and service envelopes are not final; treat these
7
7
  > handlers as reference implementations for the current draft.
8
8
 
9
9
  ## Install
@@ -22,7 +22,7 @@ Current draft posture:
22
22
 
23
23
  - The v1.1 signer service is deleted outright. Its responsibilities split into two: read-only identity lookups go through `createIdentityService` (`getPublicKey`, `getRelays`, `getProfile`, `getFollows`, `getList`, `getZaps`, `getMutes`, `getBlocked`, `getBadges`); signing happens inside the shell as part of `relay.publish` / `relay.publishEncrypted` and is never exposed to napplets.
24
24
  - `createKeysService` and `createMediaService` ship real reference backends as of v1.4 (see the dedicated sections below). `createKeysService` attaches a document-level `keydown` listener by default and delivers `keys.action` push envelopes to registered napplets; `createMediaService` mirrors session metadata and playback state to `navigator.mediaSession` and emits `media.command` push envelopes on OS transport events. Both accept a host-bridge option (`HostKeysBridge` / `HostMediaBridge`) so Electron / Tauri / native shells can swap in OS-level backends without re-implementing the wire-protocol bookkeeping.
25
- - `createNotifyService` (NIP-5D `notify.*` NUB) coexists with the legacy `createNotificationService` (ifc-emit `notifications:*` channel). Both may be registered simultaneously while hosts migrate.
25
+ - `createNotifyService` (NIP-5D `notify.*` NAP) coexists with the legacy `createNotificationService` (ifc-emit `notifications:*` channel). Both may be registered simultaneously while hosts migrate.
26
26
 
27
27
  ## Quick Start
28
28
 
@@ -51,7 +51,7 @@ runtime.registerService(
51
51
 
52
52
  ## Keys Service
53
53
 
54
- Reference keyboard / chord backend for the `keys.*` NIP-5D NUB. By default attaches a single `document`-level `keydown` listener that matches incoming events against registered chord subscriptions and delivers a `keys.action` push envelope back to the owning napplet. Implement the [`HostKeysBridge`](#hostkeysbridge-interface) interface to swap in OS-level backends (Electron `globalShortcut`, Tauri `GlobalShortcut`).
54
+ Reference keyboard / chord backend for the `keys.*` NIP-5D NAP. By default attaches a single `document`-level `keydown` listener that matches incoming events against registered chord subscriptions and delivers a `keys.action` push envelope back to the owning napplet. Implement the [`HostKeysBridge`](#hostkeysbridge-interface) interface to swap in OS-level backends (Electron `globalShortcut`, Tauri `GlobalShortcut`).
55
55
 
56
56
  ### Factory
57
57
 
@@ -85,7 +85,7 @@ export interface HostKeysBridge {
85
85
  * - invoke `callback` exactly once per matching chord event (implementations
86
86
  * are responsible for any OS-autorepeat filtering)
87
87
  * - invoke `callback` synchronously during the event delivery
88
- * - accept the string chord format documented by @napplet/nub/keys
88
+ * - accept the string chord format documented by @napplet/nap/keys
89
89
  * (e.g. `'Ctrl+Shift+K'`, `'Cmd+P'`)
90
90
  */
91
91
  subscribe(chord: string, callback: (event: KeyboardEvent | HostKeyEvent) => void): () => void;
@@ -214,7 +214,7 @@ runtime.registerService('keys', keys);
214
214
 
215
215
  ## Media Service
216
216
 
217
- Reference media backend for the `media.*` NIP-5D NUB. By default mirrors session metadata + playback state to `navigator.mediaSession` via the DOM `MediaSession` API and installs `setActionHandler` callbacks that emit `media.command` push envelopes on OS transport events (play / pause / next / previous / seek). Implement the [`HostMediaBridge`](#hostmediabridge-interface) interface to swap in native backends (Electron bridge, MPRIS on Linux, MediaRemote on macOS).
217
+ Reference media backend for the `media.*` NIP-5D NAP. By default mirrors session metadata + playback state to `navigator.mediaSession` via the DOM `MediaSession` API and installs `setActionHandler` callbacks that emit `media.command` push envelopes on OS transport events (play / pause / next / previous / seek). Implement the [`HostMediaBridge`](#hostmediabridge-interface) interface to swap in native backends (Electron bridge, MPRIS on Linux, MediaRemote on macOS).
218
218
 
219
219
  ### Factory
220
220
 
@@ -344,31 +344,31 @@ runtime.registerService('media', createMediaService({ hostBridge: electronBridge
344
344
 
345
345
  Plug a `HostMediaBridge` when `navigator.mediaSession` is insufficient: Electron apps that need to route transport events through the main process (lock-screen integration on Windows, Now Playing integration on macOS), Linux shells that speak MPRIS over D-Bus, native mobile wrappers that forward to AVPlayer / ExoPlayer, or test harnesses that record action events without touching the DOM. The bridge owns metadata/state mirroring and OS action routing; the service retains per-session bookkeeping (sessionRegistry + per-window send handles) so `media.command` dispatch semantics stay identical across paths.
346
346
 
347
- A napplet drives this end to end via `@napplet/nub/media` — `mediaCreateSession({ owner: 'napplet', ... })`, `mediaReportState`, and `mediaOnCommand` against the real backend.
347
+ A napplet drives this end to end via `@napplet/nap/media` — `mediaCreateSession({ owner: 'napplet', ... })`, `mediaReportState`, and `mediaOnCommand` against the real backend.
348
348
 
349
349
  ## Public API
350
350
 
351
351
  Each factory returns a `ServiceHandler` registrable via `runtime.registerService()`. The bullets below note the current NIP-5D domain the handler owns and the ACL capability napplets need in order to reach it.
352
352
 
353
- ### Identity NUB
353
+ ### Identity NAP
354
354
  - `createIdentityService` — `identity.*` reads (`identity:read`). No signing surface; shell mediates signing internally.
355
355
 
356
- ### Notify NUB
356
+ ### Notify NAP
357
357
  - `createNotifyService` — canonical `notify.*` envelopes (`notify:send` / `notify:channel`).
358
358
  - `createNotificationService` — legacy ifc-emit `notifications:*` channel; coexists with `createNotifyService` until retired.
359
359
 
360
- ### Relay NUB
360
+ ### Relay NAP
361
361
  - `createRelayPoolService` — `relay.publish`, `relay.publishEncrypted`, `relay.subscribe` fan-out (`relay:read` / `relay:write`).
362
362
  - `createCacheService` — offline event cache (`cache:read` / `cache:write`).
363
363
  - `createCoordinatedRelay` — composite service that bundles relay-pool + cache with read-through behavior.
364
364
 
365
- ### Keys NUB
365
+ ### Keys NAP
366
366
  - `createKeysService` — `keys.registerAction` / `keys.unregisterAction` / `keys.forward` + `keys.action` push envelopes (`keys:forward`). Document-level chord listener by default; implement the `HostKeysBridge` interface to swap in Electron / Tauri / OS-level backends. See [Keys Service](#keys-service) for the full contract.
367
367
 
368
- ### Media NUB
368
+ ### Media NAP
369
369
  - `createMediaService` — owner-aware `media.session.create` / `update` / `destroy` / `media.state` / `media.capabilities` + `media.command` push envelopes (`media:control`). Napplet-owned sessions mirror to `navigator.mediaSession` by default; shell-owned creates are rejected until a host playback/fetch bridge is supplied. Implement the `HostMediaBridge` interface to swap in native backends. See [Media Service](#media-service) for the full contract.
370
370
 
371
- ### Theme NUB
371
+ ### Theme NAP
372
372
  - `createThemeService` — `theme.get` + `theme.changed` fan-out (`theme:read`). Returns a `ThemeService` with `publishTheme()` / `setTheme()` utilities for host-side updates.
373
373
 
374
374
  ### Audio (legacy ifc-emit)
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ServiceHandler, Signer } from '@kehto/runtime';
2
2
  import { NostrFilter, NostrEvent, EventTemplate } from '@napplet/core';
3
- import { MediaMetadata, MediaAction } from '@napplet/nub/media/types';
4
- export { MediaAction } from '@napplet/nub/media/types';
5
- import { NotifySendMessage } from '@napplet/nub/notify/types';
6
- import { Theme, ThemeChangedMessage } from '@napplet/nub/theme/types';
7
- import { ConfigSchemaErrorCode, ConfigValues, NappletConfigSchema } from '@napplet/nub/config/types';
3
+ import { MediaMetadata, MediaAction } from '@napplet/nap/media/types';
4
+ export { MediaAction } from '@napplet/nap/media/types';
5
+ import { NotifySendMessage } from '@napplet/nap/notify/types';
6
+ import { Theme, ThemeChangedMessage } from '@napplet/nap/theme/types';
7
+ import { ConfigSchemaErrorCode, ConfigValues, NappletConfigSchema } from '@napplet/nap/config/types';
8
8
  export { a as CvmCloseMessage, b as CvmCloseResultMessage, c as CvmDiscoverMessage, d as CvmDiscoverQuery, e as CvmDiscoverResultMessage, f as CvmEventMessage, g as CvmInboundMessage, h as CvmOutboundMessage, i as CvmRequestMessage, j as CvmRequestOptions, k as CvmRequestResultMessage, l as CvmServer, m as CvmServerRef, n as CvmService, o as CvmServiceOptions, C as CvmTransport, p as CvmTransportError, M as McpContentBlock, q as McpMessage, r as McpTool, s as McpToolResult, t as createCvmService } from './cvm-service-CXcOVQ0m.js';
9
9
 
10
10
  /**
@@ -187,7 +187,7 @@ declare function createNotificationService(options?: NotificationServiceOptions)
187
187
  * (An `identity.decrypt` capability was briefly added in v1.8 and removed as a
188
188
  * spec violation; decryption belongs to the runtime, inline over the wire.)
189
189
  *
190
- * Handles 9 identity.* request types from @napplet/nub/identity. getPublicKey
190
+ * Handles 9 identity.* request types from @napplet/nap/identity. getPublicKey
191
191
  * and getRelays return real values sourced from hooks.auth.getSigner(); the
192
192
  * remaining 7 (getProfile/getFollows/getList/getZaps/getMutes/getBlocked/
193
193
  * getBadges) are stub-level. Host apps plug real backends via
@@ -216,7 +216,7 @@ interface IdentityServiceOptions {
216
216
  /**
217
217
  * Create an identity service that handles NIP-5D identity.* envelope messages.
218
218
  *
219
- * Supports the 9 read-only identity.* request types from @napplet/nub/identity.
219
+ * Supports the 9 read-only identity.* request types from @napplet/nap/identity.
220
220
  * The two nostr-info queries (getPublicKey, getRelays) resolve through the
221
221
  * caller-supplied signer; the remaining 7 return default/empty payloads with
222
222
  * spec-correct envelope shapes so napplets always receive a result envelope.
@@ -472,7 +472,7 @@ declare function createCoordinatedRelay(options: CoordinatedRelayOptions): Servi
472
472
  /**
473
473
  * keys-service.ts — NIP-5D keys NUB reference document-level listener implementation.
474
474
  *
475
- * Handles the 3 napplet -> shell request types from @napplet/nub/keys:
475
+ * Handles the 3 napplet -> shell request types from @napplet/nap/keys:
476
476
  * - keys.forward -> invokes options.onForward (hotkey passthrough, fire-and-forget)
477
477
  * - keys.registerAction -> parses action.defaultKey into a chord spec, stores the
478
478
  * subscription in an in-memory registry keyed by actionId,
@@ -491,14 +491,14 @@ declare function createCoordinatedRelay(options: CoordinatedRelayOptions): Servi
491
491
  *
492
492
  * On each document keydown matching a registered action, the service
493
493
  * additionally emits a `keys.action` envelope to the action's owning napplet
494
- * via the per-window `send` callback — this is the canonical @napplet/nub/keys
494
+ * via the per-window `send` callback — this is the canonical @napplet/nap/keys
495
495
  * surface the SDK's `keys.onAction(...)` helper consumes. The shape is a
496
496
  * superset of `KeysActionMessage`: `{ type, actionId, chord }` where `chord`
497
497
  * is the parsed `{ ctrl, alt, shift, meta, key }` struct (extension field;
498
498
  * base shape unchanged, downstream SDKs that only read `{ type, actionId }`
499
499
  * ignore `chord` silently).
500
500
  *
501
- * Field-name translation: @napplet/nub/keys uses the compact
501
+ * Field-name translation: @napplet/nap/keys uses the compact
502
502
  * { ctrl, alt, shift, meta } form on the wire; the shell's HotkeyHooks
503
503
  * (packages/shell/src/types.ts) expects the DOM-compatible
504
504
  * { ctrlKey, altKey, shiftKey, metaKey } form. This service performs the
@@ -567,7 +567,7 @@ interface HostKeysBridge {
567
567
  * - invoke `callback` exactly once per matching chord event (implementations
568
568
  * are responsible for any OS-autorepeat filtering)
569
569
  * - invoke `callback` synchronously during the event delivery
570
- * - accept the string chord format documented by @napplet/nub/keys
570
+ * - accept the string chord format documented by @napplet/nap/keys
571
571
  * (e.g. `'Ctrl+Shift+K'`, `'Cmd+P'`)
572
572
  */
573
573
  subscribe(chord: string, callback: (event: KeyboardEvent | HostKeyEvent) => void): () => void;
@@ -639,7 +639,7 @@ interface KeysServiceOptions {
639
639
  */
640
640
  hostBridge?: HostKeysBridge;
641
641
  /**
642
- * Optional set of shell-reserved chords. Strings in the `@napplet/nub/keys`
642
+ * Optional set of shell-reserved chords. Strings in the `@napplet/nap/keys`
643
643
  * wire format (e.g. `'Ctrl+Shift+K'`, `'Cmd+P'`). When a napplet sends
644
644
  * `keys.forward` with a chord matching this set — or when a document
645
645
  * keydown matches a reserved chord — the service invokes `onForward`
@@ -748,7 +748,7 @@ declare function createBrowserMediaBridge(opts?: {
748
748
  * media-service.ts — NIP-5D media NUB reference service (navigator.mediaSession
749
749
  * reference implementation).
750
750
  *
751
- * Handles the napplet-owned subset of @napplet/nub/media:
751
+ * Handles the napplet-owned subset of @napplet/nap/media:
752
752
  * media.session.create (result), media.session.update, media.session.destroy,
753
753
  * media.state, media.capabilities.
754
754
  *
@@ -763,7 +763,7 @@ declare function createBrowserMediaBridge(opts?: {
763
763
  * napplet-supplied metadata to navigator.mediaSession.metadata via new MediaMetadata()
764
764
  * and installs setActionHandler callbacks for the 5 OS transport actions
765
765
  * (play / pause / nexttrack / previoustrack / seekto). Each callback emits a canonical
766
- * media.command envelope to the owning napplet — that is the @napplet/nub/media
766
+ * media.command envelope to the owning napplet — that is the @napplet/nap/media
767
767
  * MediaCommandMessage shape consumed by the SDK's mediaOnCommand() helper.
768
768
  *
769
769
  * NAP-MEDIA now distinguishes napplet-owned playback from shell-owned
@@ -794,7 +794,7 @@ declare function createBrowserMediaBridge(opts?: {
794
794
  *
795
795
  * Note: this is SEPARATE from packages/services/src/audio-service.ts, which
796
796
  * is the legacy ifc-topic-based audio source registry (audio:* topic events
797
- * over ifc.emit). media-service is the canonical @napplet/nub/media NIP-5D
797
+ * over ifc.emit). media-service is the canonical @napplet/nap/media NIP-5D
798
798
  * path and they coexist — audio-service continues to track audio sources for
799
799
  * shell UI, while media-service handles the NUB protocol envelope surface.
800
800
  *
@@ -963,7 +963,7 @@ interface MediaServiceOptions {
963
963
  * Create a media NUB service handler with navigator.mediaSession integration.
964
964
  *
965
965
  * Implements the 5 napplet->shell media.* request types defined in
966
- * `@napplet/nub/media`. Only `media.session.create` produces a reply
966
+ * `@napplet/nap/media`. Only `media.session.create` produces a reply
967
967
  * envelope (`media.session.create.result`) — the remaining four
968
968
  * (`session.update`, `session.destroy`, `state`, `capabilities`) are
969
969
  * fire-and-forget per the NUB spec.
@@ -993,7 +993,7 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
993
993
  /**
994
994
  * notify-service.ts — NIP-5D notify NUB reference service (stub-level).
995
995
  *
996
- * Handles the 5 napplet -> shell request types from `@napplet/nub/notify`:
996
+ * Handles the 5 napplet -> shell request types from `@napplet/nap/notify`:
997
997
  * - `notify.send` -> `notify.send.result` (shell-assigned id)
998
998
  * - `notify.dismiss` -> fire-and-forget
999
999
  * - `notify.badge` -> fire-and-forget
@@ -1008,9 +1008,9 @@ declare function createMediaService(options?: MediaServiceOptions): ServiceHandl
1008
1008
  * `packages/services/src/notification-service.ts`, which is the legacy
1009
1009
  * ifc-topic-based notification registry (operates on `ifc.emit` topics
1010
1010
  * under `notifications:*`). `notify-service.ts` is the canonical
1011
- * `@napplet/nub/notify` NIP-5D path and lives alongside the legacy module.
1011
+ * `@napplet/nap/notify` NIP-5D path and lives alongside the legacy module.
1012
1012
  * If the host app registers this service via
1013
- * `runtime.registerService('notify', ...)`, @napplet/nub/notify messages
1013
+ * `runtime.registerService('notify', ...)`, @napplet/nap/notify messages
1014
1014
  * land here; the legacy ifc-emit topic path remains untouched.
1015
1015
  *
1016
1016
  * Shell -> napplet push messages (`notify.action`, `notify.clicked`,
@@ -1054,7 +1054,7 @@ interface NotifyServiceOptions {
1054
1054
  /**
1055
1055
  * Create a stub-level notify service handler.
1056
1056
  *
1057
- * Answers the 5 napplet->shell request types from `@napplet/nub/notify`.
1057
+ * Answers the 5 napplet->shell request types from `@napplet/nap/notify`.
1058
1058
  * Does NOT implement a real backend (no DOM Notification API, no channel
1059
1059
  * registry, no permission prompt). Host apps replace this via
1060
1060
  * `runtime.registerService('notify', realHandler)` when a real backend is
@@ -1076,7 +1076,7 @@ declare function createNotifyService(options?: NotifyServiceOptions): ServiceHan
1076
1076
  /**
1077
1077
  * theme-service.ts — NIP-5D theme NUB reference service.
1078
1078
  *
1079
- * Handles the single napplet->shell request type from @napplet/nub/theme:
1079
+ * Handles the single napplet->shell request type from @napplet/nap/theme:
1080
1080
  * - `theme.get` -> `theme.get.result { theme }` (current theme)
1081
1081
  *
1082
1082
  * Exposes a host-facing `publishTheme(theme)` handle that:
@@ -1181,7 +1181,7 @@ declare function createThemeService(options?: ThemeServiceOptions): ThemeService
1181
1181
  * config-service.ts — NUB-CONFIG reference service (9th NUB domain, v1.7 Phase 39).
1182
1182
  *
1183
1183
  * Shell-side reference implementation for the canonical NUB-CONFIG wire
1184
- * protocol (`@napplet/nub/config`, published at `^0.3.0`). Handles the full
1184
+ * protocol (`@napplet/nap/config`, published at `^0.3.0`). Handles the full
1185
1185
  * 8-message discriminated union: 5 napplet→shell request types + 3
1186
1186
  * shell→napplet result/push types.
1187
1187
  *
@@ -1304,7 +1304,7 @@ interface ConfigService {
1304
1304
  /**
1305
1305
  * Create a NUB-CONFIG reference service.
1306
1306
  *
1307
- * Shell-writes, napplet-reads. Handles the full `@napplet/nub/config` wire
1307
+ * Shell-writes, napplet-reads. Handles the full `@napplet/nap/config` wire
1308
1308
  * protocol: `config.get` (correlated snapshot), `config.subscribe` /
1309
1309
  * `config.unsubscribe` (live push stream), `config.registerSchema` (optional
1310
1310
  * schema registration + Core Subset validation), `config.openSettings`
@@ -1343,7 +1343,7 @@ declare function createConfigService(options: ConfigServiceOptions): ConfigServi
1343
1343
  *
1344
1344
  * Shell-side reference implementation for the canonical NUB-RESOURCE wire
1345
1345
  * protocol (`internal-resource.ts` in @kehto/shell/src/types; kehto-internal
1346
- * model per PROJECT.md Decision #31 — diverges from upstream `@napplet/nub/
1346
+ * model per PROJECT.md Decision #31 — diverges from upstream `@napplet/nap/
1347
1347
  * resource` in field names + error vocabulary). Handles the canonical
1348
1348
  * 4-message protocol:
1349
1349
  * Inbound: resource.bytes, resource.cancel
@@ -2277,4 +2277,65 @@ interface CatalogIntentResolver extends IntentResolver {
2277
2277
  */
2278
2278
  declare function createCatalogIntentResolver(options: CatalogIntentResolverOptions): CatalogIntentResolver;
2279
2279
 
2280
- export { type AudioServiceOptions, type AudioSource, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, 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 IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceService, type ResourceServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadRail, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, createAudioService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createConfigService, createCoordinatedRelay, createHttpUploader, createIdentityService, createIntentService, createKeysService, createMediaService, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createThemeService, createUploadService };
2280
+ /**
2281
+ * manifest-intent-catalog.ts — signed-manifest → NAP-INTENT catalog adapter.
2282
+ *
2283
+ * Adapts a resolved NIP-5A/5D napplet manifest's archetype tags into an
2284
+ * {@link IntentCatalogEntry} — the shape `createCatalogIntentResolver.loadCatalog`
2285
+ * consumes. This lets NAP-INTENT availability and handler candidacy flow from
2286
+ * verified manifest tags rather than host-injected catalog data.
2287
+ *
2288
+ * To avoid a `@kehto/services → @kehto/nip` dependency cycle (services must stay
2289
+ * dependency-light and `@kehto/nip` is a lower-level NIP utility), the adapter
2290
+ * takes a minimal STRUCTURAL input {@link ManifestArchetypeInput} that the
2291
+ * `@kehto/nip/5d` `NappletManifest` satisfies by duck typing — callers pass
2292
+ * `resolved.manifest` directly without any package coupling.
2293
+ *
2294
+ * @packageDocumentation
2295
+ */
2296
+
2297
+ /**
2298
+ * The structural subset of `@kehto/nip/5d` `NappletManifest` the adapter needs.
2299
+ * Intentionally a duck-typed shape so the playground (or any caller) can pass a
2300
+ * resolved manifest without importing `@kehto/nip`.
2301
+ */
2302
+ interface ManifestArchetypeInput {
2303
+ /** The napplet's `d` identifier. */
2304
+ dTag: string;
2305
+ /** Optional human-readable title from the manifest. */
2306
+ title?: string;
2307
+ /**
2308
+ * Archetype slugs this napplet fulfills, from the manifest's `archetype` tags;
2309
+ * the optional `nap` is the recommended default wire protocol.
2310
+ */
2311
+ archetypes: Array<{
2312
+ slug: string;
2313
+ nap?: string;
2314
+ }>;
2315
+ }
2316
+ /**
2317
+ * Map a resolved napplet manifest's archetype data into an
2318
+ * {@link IntentCatalogEntry}.
2319
+ *
2320
+ * Each archetype `{ slug, nap }` becomes a keyed support record where `actions`
2321
+ * defaults to `['open']` (the NAP-INTENT default action — manifests do not
2322
+ * enumerate actions in this phase) and `protocols` is `[nap]` when a NAP-N is
2323
+ * present, else `[]`. Duplicate slugs keep the last occurrence.
2324
+ *
2325
+ * @param manifest - A resolved manifest's structural archetype data.
2326
+ * @returns The `IntentCatalogEntry` for `createCatalogIntentResolver`.
2327
+ *
2328
+ * @example
2329
+ * ```ts
2330
+ * manifestToIntentCatalogEntry({
2331
+ * dTag: 'profile-viewer',
2332
+ * title: 'Profile',
2333
+ * archetypes: [{ slug: 'profile', nap: 'NAP-1' }],
2334
+ * });
2335
+ * // → { dTag: 'profile-viewer', title: 'Profile',
2336
+ * // archetypes: { profile: { actions: ['open'], protocols: ['NAP-1'] } } }
2337
+ * ```
2338
+ */
2339
+ declare function manifestToIntentCatalogEntry(manifest: ManifestArchetypeInput): IntentCatalogEntry;
2340
+
2341
+ export { type AudioServiceOptions, type AudioSource, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, 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 IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type ManifestArchetypeInput, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceService, type ResourceServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadRail, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, createAudioService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createConfigService, createCoordinatedRelay, createHttpUploader, createIdentityService, createIntentService, createKeysService, createMediaService, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createThemeService, createUploadService, manifestToIntentCatalogEntry };
package/dist/index.js CHANGED
@@ -1366,7 +1366,7 @@ var DEFAULT_THEME = {
1366
1366
  primary: "#7aa2f7"
1367
1367
  }
1368
1368
  // fonts, background, title intentionally undefined — all optional per
1369
- // @napplet/nub/theme Theme interface.
1369
+ // @napplet/nap/theme Theme interface.
1370
1370
  };
1371
1371
  function createThemeService(options = {}) {
1372
1372
  let currentTheme = options.initialTheme ?? DEFAULT_THEME;
@@ -2617,6 +2617,23 @@ function createCatalogIntentResolver(options) {
2617
2617
  };
2618
2618
  }
2619
2619
 
2620
+ // src/manifest-intent-catalog.ts
2621
+ var DEFAULT_ACTIONS = ["open"];
2622
+ function manifestToIntentCatalogEntry(manifest) {
2623
+ const archetypes = {};
2624
+ for (const { slug, nap } of manifest.archetypes) {
2625
+ archetypes[slug] = {
2626
+ actions: [...DEFAULT_ACTIONS],
2627
+ protocols: nap ? [nap] : []
2628
+ };
2629
+ }
2630
+ return {
2631
+ dTag: manifest.dTag,
2632
+ ...manifest.title === void 0 ? {} : { title: manifest.title },
2633
+ archetypes
2634
+ };
2635
+ }
2636
+
2620
2637
  // src/cvm-service.ts
2621
2638
  var CVM_SERVICE_VERSION = "1.0.0";
2622
2639
  var CVM_DESCRIPTOR = {
@@ -2742,6 +2759,7 @@ export {
2742
2759
  createRelayPoolService,
2743
2760
  createResourceService,
2744
2761
  createThemeService,
2745
- createUploadService
2762
+ createUploadService,
2763
+ manifestToIntentCatalogEntry
2746
2764
  };
2747
2765
  //# sourceMappingURL=index.js.map