@napplet/sdk 0.24.1 → 0.24.3

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/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { NostrEvent, Subscription, NostrFilter, RelayEventResult, EventTemplate, ResourceInfo, ResourceBytesItem, CvmDiscoverQuery, CvmServer, CvmServerRef, McpMessage, CvmRequestOptions, McpTool, McpToolResult, McpResource, McpResourceContent, IntentRequest, IntentResult, IntentAvailability, OutboxEventOptions, OutboxEventResult, OutboxQueryOptions, OutboxResult, OutboxSubscribeOptions, OutboxSubscription, OutboxPublishOptions, OutboxPublishResult, OutboxTarget, OutboxRelayPlan, UploadInfo, UploadRequest, UploadResult, UploadStatus, WebrtcOpenRequest, WebrtcOpenResult, WebrtcEvent, BleOpenRequest, BleOpenResult, BleService, BleAttribute, BleWriteOptions, BleEvent, CommonNip19EncodeInput, CommonNip19EncodeResult, CommonNip19DecodeResult, CommonProfileTarget, CommonProfileResult, CommonFollowsResult, CommonActionResult, CommonReaction, CommonReportTarget, CommonReportReason, CountFilter, CountOptions, CountResult, DmStatus, DmConversationQuery, DmConversationPage, DmMessageQuery, DmMessagePage, DmSendRequest, DmSendResult, DmSubscribeRequest, DmSubscription, DmOk, DmMessage, LinkOpenOptions, LinkOpenResult, ListSupport, ListRef, ListItem, ListOptions, ListMutationResult, SerialOpenRequest, SerialOpenResult, SerialEvent } from '@napplet/core';
1
+ import { NappletGlobal } from '@napplet/core';
2
2
  export { EventTemplate, NAP_DOMAINS, NapDomain, NappletMessage, NostrEvent, NostrFilter, RelayEventResult, RelayEventSidecar, Subscription } from '@napplet/core';
3
- import { MediaSessionCreate, MediaSessionResult, MediaMetadata, MediaState, MediaAction } from '@napplet/nap/media';
4
- export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNapMessage, MediaPlaybackOwner, MediaRequestMessage, MediaResultMessage, MediaSessionCreate, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionResult, MediaSessionUpdateMessage, MediaSourceRef, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCapabilities, mediaOnCommand, mediaOnControls, mediaOnState, mediaReportCapabilities, mediaReportState, mediaSendCommand, mediaUpdateSession } from '@napplet/nap/media';
5
3
  export { DOMAIN as RELAY_DOMAIN, RelayCloseMessage, RelayClosedMessage, RelayEoseMessage, RelayEventMessage, RelayInboundMessage, RelayMessage, RelayNapMessage, RelayOutboundMessage, RelayPublishEncryptedMessage, RelayPublishEncryptedResultMessage, RelayPublishMessage, RelayPublishResultMessage, RelayQueryMessage, RelayQueryResultMessage, RelaySubscribeMessage, installRelayShim, relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe } from '@napplet/nap/relay';
6
4
  export { Badge, DOMAIN as IDENTITY_DOMAIN, IdentityChangedMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetPublicKeyMessage, IdentityGetPublicKeyResultMessage, IdentityGetRelaysMessage, IdentityGetRelaysResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityMessage, IdentityNapMessage, RelayPermission as IdentityRelayPermission, IdentityRequestMessage, IdentityResultMessage, ProfileData, ZapReceipt, identityGetBadges, identityGetBlocked, identityGetFollows, identityGetList, identityGetMutes, identityGetProfile, identityGetPublicKey, identityGetRelays, identityGetZaps, identityOnChanged, installIdentityShim } from '@napplet/nap/identity';
7
5
  export { DOMAIN as STORAGE_DOMAIN, StorageGetMessage, StorageGetResultMessage, StorageKeysMessage, StorageKeysResultMessage, StorageMessage, StorageNapMessage, StorageRemoveMessage, StorageRemoveResultMessage, StorageRequestMessage, StorageResultMessage, StorageSetMessage, StorageSetResultMessage, installStorageShim, storageGetItem, storageInstanceGetItem, storageInstanceKeys, storageInstanceRemoveItem, storageInstanceSetItem, storageKeys, storageRemoveItem, storageSetItem } from '@napplet/nap/storage';
@@ -9,10 +7,11 @@ export { DOMAIN as INC_DOMAIN, IncChannelBroadcastMessage, IncChannelCloseMessag
9
7
  export { DOMAIN as IFC_DOMAIN, IfcChannelBroadcastMessage, IfcChannelCloseMessage, IfcChannelClosedMessage, IfcChannelEmitMessage, IfcChannelEventMessage, IfcChannelListMessage, IfcChannelListResultMessage, IfcChannelMessage, IfcChannelOpenMessage, IfcChannelOpenResultMessage, IfcEmitMessage, IfcEventMessage, IfcInboundMessage, IfcMessage, IfcNapMessage, IfcOutboundMessage, IfcSubscribeMessage, IfcSubscribeResultMessage, IfcTopicMessage, IfcUnsubscribeMessage, ifcEmit, ifcOn, installIfcShim } from '@napplet/nap/ifc';
10
8
  export { DOMAIN as THEME_DOMAIN, Theme, ThemeBackground, ThemeChangedMessage, ThemeColors, ThemeFont, ThemeGetMessage, ThemeGetResultMessage, ThemeMessage, ThemeNapMessage, ThemeRequestMessage, ThemeResultMessage, installThemeShim, themeGet, themeOnChanged } from '@napplet/nap/theme';
11
9
  export { Action, DOMAIN as KEYS_DOMAIN, KeyBinding, KeysActionMessage, KeysBindingsMessage, KeysForwardMessage, KeysMessage, KeysNapMessage, KeysRegisterActionMessage, KeysRegisterActionResultMessage, KeysRequestMessage, KeysResultMessage, KeysUnregisterActionMessage, RegisterResult, installKeysShim, keysOnAction, keysRegister, keysRegisterAction, keysUnregisterAction } from '@napplet/nap/keys';
10
+ export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaContextLink, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNapMessage, MediaNostrRef, MediaPlaybackOwner, MediaRequestMessage, MediaResultMessage, MediaSessionContext, MediaSessionCreate, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionResult, MediaSessionUpdateMessage, MediaSourceRef, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCapabilities, mediaOnCommand, mediaOnControls, mediaOnState, mediaReportCapabilities, mediaReportState, mediaSendCommand, mediaUpdateSession } from '@napplet/nap/media';
12
11
  export { DOMAIN as NOTIFY_DOMAIN, NotificationAction, NotificationChannel, NotificationPriority, NotifyActionMessage, NotifyBadgeMessage, NotifyChannelRegisterMessage, NotifyClickedMessage, NotifyControl, NotifyControlsMessage, NotifyDismissMessage, NotifyDismissedMessage, NotifyMessage, NotifyNapMessage, NotifyPermissionRequestMessage, NotifyPermissionResultMessage, NotifyRequestMessage, NotifyResultMessage, NotifySendMessage, NotifySendResultMessage, installNotifyShim, notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend } from '@napplet/nap/notify';
13
12
  export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNapMessage, ConfigOpenSettingsMessage, ConfigRegisterSchemaMessage, ConfigRegisterSchemaResultMessage, ConfigRequestMessage, ConfigResultMessage, ConfigSchema, ConfigSchemaErrorCode, ConfigSchemaErrorMessage, ConfigSubscribeMessage, ConfigUnsubscribeMessage, ConfigValues, ConfigValuesMessage, NappletConfigSchema, NappletConfigSchemaExtensions, installConfigShim } from '@napplet/nap/config';
14
13
  export { DOMAIN as RESOURCE_DOMAIN, ResourceBytesErrorItem, ResourceBytesErrorMessage, ResourceBytesItem, ResourceBytesManyErrorMessage, ResourceBytesManyMessage, ResourceBytesManyResultMessage, ResourceBytesMessage, ResourceBytesOkItem, ResourceBytesResultMessage, ResourceCancelMessage, ResourceErrorCode, ResourceMessage, ResourceNapMessage, ResourceRequestMessage, ResourceResultMessage, ResourceScheme, ResourceSidecarEntry, installResourceShim, resourceBytes, resourceBytesAsObjectURL, resourceBytesMany, resourceInfo } from '@napplet/nap/resource';
15
- export { DOMAIN as CVM_DOMAIN, CvmCloseMessage, CvmCloseResultMessage, CvmDiscoverMessage, CvmDiscoverQuery, CvmDiscoverResultMessage, CvmEventMessage, CvmInboundMessage, CvmMessage, CvmNapMessage, CvmOutboundMessage, CvmRequestMessage, CvmRequestOptions, CvmRequestResultMessage, CvmServer, CvmServerRef, McpBlobResourceContents, McpContentBlock, McpMessage, McpResource, McpResourceContent, McpTextResourceContents, McpTool, McpToolResult, cvmCallTool, cvmClose, cvmDiscover, cvmListResources, cvmListTools, cvmOnEvent, cvmReadResource, cvmRequest, installCvmShim } from '@napplet/nap/cvm';
14
+ export { DOMAIN as CVM_DOMAIN, CvmCloseMessage, CvmCloseResultMessage, CvmDiscoverMessage, CvmDiscoverQuery, CvmDiscoverResultMessage, CvmEventMessage, CvmInboundMessage, CvmMessage, CvmNapMessage, CvmOutboundMessage, CvmRegistryCallMessage, CvmRegistryCallOptions, CvmRegistryCallResultMessage, CvmRegistryDescribeMessage, CvmRegistryDescribeResultMessage, CvmRegistryEntry, CvmRegistryHasMessage, CvmRegistryHasResultMessage, CvmRegistryListMessage, CvmRegistryListResultMessage, CvmRegistryOptions, CvmRegistryQuery, CvmRegistryTool, CvmRequestMessage, CvmRequestOptions, CvmRequestResultMessage, CvmServer, CvmServerRef, JsonObject, JsonSchema, McpBlobResourceContents, McpContentBlock, McpMessage, McpResource, McpResourceContent, McpTextResourceContents, McpTool, McpToolResult, cvmCallTool, cvmClose, cvmDiscover, cvmListResources, cvmListTools, cvmOnEvent, cvmReadResource, cvmRegistryCall, cvmRegistryDescribe, cvmRegistryHas, cvmRegistryList, cvmRequest, installCvmShim } from '@napplet/nap/cvm';
16
15
  export { DOMAIN as OUTBOX_DOMAIN, OutboxCloseMessage, OutboxClosedMessage, OutboxEventMessage, OutboxEventOptions, OutboxEventResult, OutboxGetEventMessage, OutboxGetEventResultMessage, OutboxInboundMessage, OutboxMessage, OutboxNapMessage, OutboxOutboundMessage, OutboxPublishMessage, OutboxPublishOptions, OutboxPublishResult, OutboxPublishResultMessage, OutboxQueryMessage, OutboxQueryOptions, OutboxQueryResultMessage, OutboxRelayPlan, OutboxResolveRelaysMessage, OutboxResolveRelaysResultMessage, OutboxResult, OutboxSubscribeMessage, OutboxSubscribeOptions, OutboxSubscription, OutboxTarget, installOutboxShim, outboxGetEvent, outboxPublish, outboxQuery, outboxResolveRelays, outboxSubscribe } from '@napplet/nap/outbox';
17
16
  export { NostrTag, DOMAIN as UPLOAD_DOMAIN, UploadDimensions, UploadInboundMessage, UploadMessage, UploadNapMessage, UploadOutboundMessage, UploadRail, UploadRequest, UploadResult, UploadState, UploadStatus, UploadStatusChangedMessage, UploadStatusMessage, UploadStatusResultMessage, UploadUploadMessage, UploadUploadResultMessage, installUploadShim, uploadFile, uploadInfo, uploadOnStatus, uploadStatus } from '@napplet/nap/upload';
18
17
  export { DOMAIN as INTENT_DOMAIN, IntentAvailability, IntentAvailableMessage, IntentAvailableResultMessage, IntentBehavior, IntentCandidate, IntentChangedMessage, IntentContract, IntentHandlerPreference, IntentHandlersMessage, IntentHandlersResultMessage, IntentInboundMessage, IntentInvokeMessage, IntentInvokeResultMessage, IntentMessage, IntentNapMessage, IntentOutboundMessage, IntentRequest, IntentResult, installIntentShim, intentAvailable, intentHandlers, intentInvoke, intentOnChanged, intentOpen } from '@napplet/nap/intent';
@@ -23,7 +22,7 @@ export { DOMAIN as COUNT_DOMAIN, CountFilter, CountInboundMessage, CountMessage,
23
22
  export { DOMAIN as LISTS_DOMAIN, ListErrorCode, ListItem, ListItemType, ListItemVisibility, ListMutationResult, ListOptions, ListRef, ListSupport, ListsAddMessage, ListsAddResultMessage, ListsInboundMessage, ListsMessage, ListsNapMessage, ListsOutboundMessage, ListsRemoveMessage, ListsRemoveResultMessage, ListsSupportedMessage, ListsSupportedResultMessage, installListsShim, listsAdd, listsRemove, listsSupported } from '@napplet/nap/lists';
24
23
  export { DOMAIN as COMMON_DOMAIN, CommonActionResult, CommonDecodeNip19Message, CommonDecodeNip19ResultMessage, CommonEncodeNip19Message, CommonEncodeNip19ResultMessage, CommonEventReportTarget, CommonFollowMessage, CommonFollowResultMessage, CommonFollowsMessage, CommonFollowsResult, CommonFollowsResultMessage, CommonGetProfileMessage, CommonGetProfileResultMessage, CommonInboundMessage, CommonMessage, CommonNapMessage, CommonNip19DecodeResult, CommonNip19EncodeInput, CommonNip19EncodeResult, CommonNip19Type, CommonOutboundMessage, CommonProfileData, CommonProfileResult, CommonProfileTarget, CommonPubkeyReportTarget, CommonReactMessage, CommonReactResultMessage, CommonReaction, CommonReportMessage, CommonReportReason, CommonReportResultMessage, CommonReportTarget, CommonUnfollowMessage, CommonUnfollowResultMessage, commonDecodeNip19, commonEncodeNip19, commonFollow, commonFollows, commonGetProfile, commonReact, commonReport, commonUnfollow, installCommonShim } from '@napplet/nap/common';
25
24
  export { DOMAIN as SERIAL_DOMAIN, SerialCloseMessage, SerialCloseResultMessage, SerialEvent, SerialEventMessage, SerialInboundMessage, SerialMessage, SerialNapMessage, SerialOpenMessage, SerialOpenOptions, SerialOpenRequest, SerialOpenResult, SerialOpenResultMessage, SerialOutboundMessage, SerialPortFilter, SerialPortInfo, SerialSession, SerialState, SerialWriteMessage, SerialWriteResultMessage, installSerialShim, serialClose, serialOnEvent, serialOpen, serialWrite } from '@napplet/nap/serial';
26
- export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversationQuery, DmConversationsMessage, DmConversationsResultMessage, DmHexPubkey, DmInboundMessage, DmMessage, DmMessageEnvelope, DmMessageEventMessage, DmMessagePage, DmMessageQuery, DmMessageStatus, DmMessagesMessage, DmMessagesResultMessage, DmNapMessage, DmOk, DmOutboundMessage, DmPeer, DmSendMessage, DmSendRequest, DmSendResult, DmSendResultMessage, DmStatus, DmStatusMessage, DmStatusResultMessage, DmSubscribeMessage, DmSubscribeRequest, DmSubscribeResultMessage, DmSubscription, DmTimestamp, DmUnsubscribeMessage, DmUnsubscribeResultMessage, dmConversations, dmMessages, dmOnMessage, dmSend, dmStatus, dmSubscribe, dmUnsubscribe, installDmShim } from '@napplet/nap/dm';
25
+ export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversationQuery, DmConversationsMessage, DmConversationsResultMessage, DmError, DmHexPubkey, DmInboundMessage, DmMessage, DmMessageEnvelope, DmMessageEventMessage, DmMessagePage, DmMessageQuery, DmMessageStatus, DmMessagesMessage, DmMessagesResultMessage, DmNapMessage, DmOk, DmOutboundMessage, DmPeer, DmSendMessage, DmSendRequest, DmSendResult, DmSendResultMessage, DmStatus, DmStatusMessage, DmStatusResultMessage, DmSubscribeMessage, DmSubscribeRequest, DmSubscribeResultMessage, DmSubscription, DmTimestamp, DmUnsubscribeMessage, DmUnsubscribeResultMessage, dmConversations, dmMessages, dmOnMessage, dmSend, dmStatus, dmSubscribe, dmUnsubscribe, installDmShim } from '@napplet/nap/dm';
27
26
 
28
27
  /**
29
28
  * @napplet/sdk -- Relay, inter-napplet pubsub, and storage wrapper objects.
@@ -31,6 +30,7 @@ export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversation
31
30
  * @packageDocumentation
32
31
  */
33
32
 
33
+ type SdkDomain$5<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
34
34
  /**
35
35
  * NIP-01 relay operations: subscribe to events, publish events, one-shot queries.
36
36
  *
@@ -48,43 +48,7 @@ export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversation
48
48
  * );
49
49
  * ```
50
50
  */
51
- declare const relay: {
52
- /**
53
- * Open a live NIP-01 subscription through the shell's relay pool.
54
- * @param filters One or more NIP-01 subscription filters
55
- * @param onEvent Called for each matching event result
56
- * @param onEose Called when the shell signals end of stored events (EOSE)
57
- * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions
58
- * @returns A Subscription handle with a `close()` method
59
- */
60
- subscribe(filters: NostrFilter | NostrFilter[], onEvent: (result: RelayEventResult) => void, onEose: () => void, options?: {
61
- relay?: string;
62
- group?: string;
63
- }): Subscription;
64
- /**
65
- * Sign and publish a Nostr event through the shell.
66
- * @param template Unsigned event template
67
- * @param options Optional: `{ relay: true }` to publish via scoped relay
68
- * @returns The signed NostrEvent after successful publication
69
- */
70
- publish(template: EventTemplate, options?: {
71
- relay?: boolean;
72
- }): Promise<NostrEvent>;
73
- /**
74
- * Publish an encrypted Nostr event through the shell.
75
- * @param template Unsigned event template
76
- * @param recipient Hex-encoded recipient public key
77
- * @param encryption Encryption scheme: 'nip44' (default) or 'nip04'
78
- * @returns The signed encrypted NostrEvent after successful publication
79
- */
80
- publishEncrypted(template: EventTemplate, recipient: string, encryption?: "nip44" | "nip04"): Promise<NostrEvent>;
81
- /**
82
- * One-shot query: subscribe, collect events until EOSE, then resolve.
83
- * @param filters NIP-01 subscription filters
84
- * @returns Promise resolving to array of matching event results
85
- */
86
- query(filters: NostrFilter | NostrFilter[]): Promise<RelayEventResult[]>;
87
- };
51
+ declare const relay: SdkDomain$5<'relay'>;
88
52
  /**
89
53
  * Inter-napplet pubsub: broadcast and receive INC-PEER events through the shell.
90
54
  *
@@ -99,42 +63,12 @@ declare const relay: {
99
63
  * });
100
64
  * ```
101
65
  */
102
- declare const inc: {
103
- /**
104
- * Broadcast an INC-PEER event to other napplets via the shell.
105
- * @param topic The 't' tag value (e.g., 'profile:open')
106
- * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
107
- * @param content Event content (default: empty string)
108
- */
109
- emit(topic: string, extraTags?: string[][], content?: string): void;
110
- /**
111
- * Subscribe to INC-PEER events on a specific topic.
112
- * @param topic The 't' tag value to listen for
113
- * @param callback Called with `(payload, event)` for each matching event
114
- * @returns A Subscription handle with a `close()` method
115
- */
116
- on(topic: string, callback: (payload: unknown, event: NostrEvent) => void): Subscription;
117
- };
66
+ declare const inc: SdkDomain$5<'inc'>;
118
67
  /**
119
68
  * @deprecated Use {@link inc}. NAP-IFC was renamed to NAP-INC; this package
120
69
  * alias is kept only to ease downstream migration.
121
70
  */
122
- declare const ifc: {
123
- /**
124
- * Broadcast an INC-PEER event to other napplets via the shell.
125
- * @param topic The 't' tag value (e.g., 'profile:open')
126
- * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
127
- * @param content Event content (default: empty string)
128
- */
129
- emit(topic: string, extraTags?: string[][], content?: string): void;
130
- /**
131
- * Subscribe to INC-PEER events on a specific topic.
132
- * @param topic The 't' tag value to listen for
133
- * @param callback Called with `(payload, event)` for each matching event
134
- * @returns A Subscription handle with a `close()` method
135
- */
136
- on(topic: string, callback: (payload: unknown, event: NostrEvent) => void): Subscription;
137
- };
71
+ declare const ifc: SdkDomain$5<'inc'>;
138
72
  /**
139
73
  * Napplet-scoped storage: async localStorage-like API proxied through the shell.
140
74
  * Each napplet's storage is isolated by identity.
@@ -147,58 +81,7 @@ declare const ifc: {
147
81
  * const theme = await storage.getItem('theme'); // 'dark'
148
82
  * ```
149
83
  */
150
- declare const storage: {
151
- /**
152
- * Retrieve a stored value by key. Returns null if the key does not exist.
153
- * @param key The storage key
154
- * @returns The stored string value, or null if not found
155
- */
156
- getItem(key: string): Promise<string | null>;
157
- /**
158
- * Store a key-value pair.
159
- * @param key The storage key
160
- * @param value The string value to store
161
- */
162
- setItem(key: string, value: string): Promise<void>;
163
- /**
164
- * Remove a stored key.
165
- * @param key The storage key to remove
166
- */
167
- removeItem(key: string): Promise<void>;
168
- /**
169
- * List all keys stored by this napplet.
170
- * @returns Array of storage key strings
171
- */
172
- keys(): Promise<string[]>;
173
- /**
174
- * Per-instance storage: same surface as the shared methods, but scoped to this
175
- * napplet instance (sets `scope: "instance"` on the wire) rather than shared
176
- * across instances. Defer to NAP-STORAGE (napplet/naps) for scope semantics.
177
- */
178
- instance: {
179
- /**
180
- * Retrieve a per-instance value by key. Returns null if not found.
181
- * @param key The storage key
182
- */
183
- getItem(key: string): Promise<string | null>;
184
- /**
185
- * Store a per-instance key-value pair.
186
- * @param key The storage key
187
- * @param value The string value to store
188
- */
189
- setItem(key: string, value: string): Promise<void>;
190
- /**
191
- * Remove a per-instance key.
192
- * @param key The storage key to remove
193
- */
194
- removeItem(key: string): Promise<void>;
195
- /**
196
- * List all per-instance keys for this napplet instance.
197
- * @returns Array of storage key strings
198
- */
199
- keys(): Promise<string[]>;
200
- };
201
- };
84
+ declare const storage: SdkDomain$5<'storage'>;
202
85
 
203
86
  /**
204
87
  * @napplet/sdk -- Media session and notification wrapper objects.
@@ -206,6 +89,7 @@ declare const storage: {
206
89
  * @packageDocumentation
207
90
  */
208
91
 
92
+ type SdkDomain$4<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
209
93
  /**
210
94
  * Media session control: create sessions, report state and metadata,
211
95
  * declare capabilities, receive commands from the shell.
@@ -222,72 +106,7 @@ declare const storage: {
222
106
  * media.reportState(sessionId, { status: 'playing', position: 42.5 });
223
107
  * ```
224
108
  */
225
- declare const media: {
226
- /**
227
- * Create a new media session with the shell.
228
- * @param options Ownership-aware session options
229
- * @returns The shell result with canonical sessionId and owner, or error
230
- */
231
- createSession(options: MediaSessionCreate): Promise<MediaSessionResult>;
232
- /**
233
- * Update metadata for an existing session.
234
- * @param sessionId The session to update
235
- * @param metadata Partial metadata fields to update
236
- */
237
- updateSession(sessionId: string, metadata: Partial<MediaMetadata>): void;
238
- /**
239
- * Destroy a media session.
240
- * @param sessionId The session to destroy
241
- */
242
- destroySession(sessionId: string): void;
243
- /**
244
- * Report current playback state for a session.
245
- * @param sessionId The session to report state for
246
- * @param state Current playback state
247
- */
248
- reportState(sessionId: string, state: MediaState): void;
249
- /**
250
- * Declare which media actions the session currently supports.
251
- * @param sessionId The session to update capabilities for
252
- * @param actions Currently supported actions
253
- */
254
- reportCapabilities(sessionId: string, actions: MediaAction[]): void;
255
- /**
256
- * Send a command to the current playback owner.
257
- * @param sessionId The session to control
258
- * @param action The media action to request
259
- * @param value Optional value for seek/volume
260
- */
261
- sendCommand(sessionId: string, action: MediaAction, value?: number): void;
262
- /**
263
- * Listen for media commands from the shell.
264
- * @param sessionId The session to listen for commands on
265
- * @param callback Called with (action, value?) when a command is received
266
- * @returns A Subscription with `close()` to stop listening
267
- */
268
- onCommand(sessionId: string, callback: (action: MediaAction, value?: number) => void): Subscription;
269
- /**
270
- * Listen for shell-reported playback state for shell-owned sessions.
271
- * @param sessionId The session to listen for state on
272
- * @param callback Called with playback state
273
- * @returns A Subscription with `close()` to stop listening
274
- */
275
- onState(sessionId: string, callback: (state: MediaState) => void): Subscription;
276
- /**
277
- * Listen for shell-reported capabilities for shell-owned sessions.
278
- * @param sessionId The session to listen for capabilities on
279
- * @param callback Called with available actions
280
- * @returns A Subscription with `close()` to stop listening
281
- */
282
- onCapabilities(sessionId: string, callback: (actions: MediaAction[]) => void): Subscription;
283
- /**
284
- * Listen for the shell's media control list.
285
- * @param sessionId The session to associate controls with
286
- * @param callback Called with the shell's supported controls
287
- * @returns A Subscription with `close()` to stop listening
288
- */
289
- onControls(sessionId: string, callback: (controls: MediaAction[]) => void): Subscription;
290
- };
109
+ declare const media: SdkDomain$4<'media'>;
291
110
  /**
292
111
  * Shell-rendered notifications: send notifications, set badge counts,
293
112
  * register channels, request permission, listen for user interaction.
@@ -303,78 +122,7 @@ declare const media: {
303
122
  * notify.badge(3);
304
123
  * ```
305
124
  */
306
- declare const notify: {
307
- /**
308
- * Send a notification to the shell.
309
- * @param notification Notification payload (title required)
310
- * @returns The shell-assigned notificationId
311
- */
312
- send(notification: {
313
- title: string;
314
- body?: string;
315
- icon?: string;
316
- actions?: {
317
- id: string;
318
- label: string;
319
- }[];
320
- channel?: string;
321
- priority?: "low" | "normal" | "high" | "urgent";
322
- }): Promise<{
323
- notificationId: string;
324
- }>;
325
- /**
326
- * Dismiss a notification by ID.
327
- * @param notificationId The notification to dismiss
328
- */
329
- dismiss(notificationId: string): void;
330
- /**
331
- * Set the badge count for this napplet. Pass 0 to clear.
332
- * @param count Badge count
333
- */
334
- badge(count: number): void;
335
- /**
336
- * Register a notification channel.
337
- * @param channel Channel definition
338
- */
339
- registerChannel(channel: {
340
- channelId: string;
341
- label: string;
342
- description?: string;
343
- defaultPriority?: "low" | "normal" | "high" | "urgent";
344
- }): void;
345
- /**
346
- * Request permission to send notifications.
347
- * @param channel Optional channel to request permission for
348
- * @returns Whether permission was granted
349
- */
350
- requestPermission(channel?: string): Promise<{
351
- granted: boolean;
352
- }>;
353
- /**
354
- * Listen for action button clicks on notifications.
355
- * @param callback Called with (notificationId, actionId)
356
- * @returns A Subscription with `close()` to stop listening
357
- */
358
- onAction(callback: (notificationId: string, actionId: string) => void): Subscription;
359
- /**
360
- * Listen for notification body clicks.
361
- * @param callback Called with (notificationId)
362
- * @returns A Subscription with `close()` to stop listening
363
- */
364
- onClicked(callback: (notificationId: string) => void): Subscription;
365
- /**
366
- * Listen for notification dismissals.
367
- * @param callback Called with (notificationId, reason?)
368
- * @returns A Subscription with `close()` to stop listening
369
- */
370
- onDismissed(callback: (notificationId: string, reason?: string) => void): Subscription;
371
- /**
372
- * Listen for the shell's notification capability list.
373
- * @param callback Called with supported controls
374
- * @returns A Subscription with `close()` to stop listening
375
- */
376
- onControls(callback: (controls: ("toasts" | "badges" | "actions" | "channels" | "system")[]) => void): Subscription;
377
- };
125
+ declare const notify: SdkDomain$4<'notify'>;
378
126
 
379
127
  /**
380
128
  * @napplet/sdk -- Keyboard action and read-only identity wrapper objects.
@@ -382,6 +130,18 @@ declare const notify: {
382
130
  * @packageDocumentation
383
131
  */
384
132
 
133
+ type SdkDomain$3<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
134
+ interface KeysSdk extends SdkDomain$3<'keys'> {
135
+ register(action: {
136
+ id: string;
137
+ label: string;
138
+ defaultKey?: string;
139
+ }, handler: () => void): Promise<{
140
+ actionId: string;
141
+ binding?: string;
142
+ close: () => void;
143
+ }>;
144
+ }
385
145
  /**
386
146
  * Keyboard forwarding and action keybindings: register named actions the shell
387
147
  * can bind to keys, listen for shell-triggered actions locally.
@@ -401,64 +161,7 @@ declare const notify: {
401
161
  * });
402
162
  * ```
403
163
  */
404
- declare const keys: {
405
- /**
406
- * Declare a named action that the shell can bind to a key.
407
- * @param action The action to register (id, label, optional defaultKey)
408
- * @returns The assigned binding, if any
409
- */
410
- registerAction(action: {
411
- id: string;
412
- label: string;
413
- defaultKey?: string;
414
- }): Promise<{
415
- actionId: string;
416
- binding?: string;
417
- }>;
418
- /**
419
- * Remove a previously registered action.
420
- * @param actionId The action to unregister
421
- */
422
- unregisterAction(actionId: string): void;
423
- /**
424
- * Register a local handler for when a bound key is pressed.
425
- * @param actionId The action to listen for
426
- * @param callback Called when the action is triggered
427
- * @returns A Subscription with `close()` to stop listening
428
- */
429
- onAction(actionId: string, callback: () => void): Subscription;
430
- /**
431
- * Convenience: register a named action AND wire a local handler in one call.
432
- * Returns a handle whose `close()` both unregisters the action and removes
433
- * the onAction listener.
434
- *
435
- * @param action The action to register (id, label, optional defaultKey)
436
- * @param handler Called when the shell triggers this action
437
- * @returns The assigned binding plus a `close()` teardown function
438
- *
439
- * @example
440
- * ```ts
441
- * import { keys } from '@napplet/sdk';
442
- *
443
- * const handle = await keys.register(
444
- * { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },
445
- * () => saveDocument(),
446
- * );
447
- *
448
- * // Later, tear down both registration and listener:
449
- * handle.close();
450
- * ```
451
- */
452
- register(action: {
453
- id: string;
454
- label: string;
455
- defaultKey?: string;
456
- }, handler: () => void): Promise<{
457
- actionId: string;
458
- binding?: string;
459
- close: () => void;
460
- }>;
461
- };
164
+ declare const keys: KeysSdk;
462
165
  /**
463
166
  * Read-only user identity queries: public key, profile, follows, relays,
464
167
  * lists, zaps, mutes, blocked, badges.
@@ -472,84 +175,7 @@ declare const keys: {
472
175
  * const follows = await identity.getFollows();
473
176
  * ```
474
177
  */
475
- declare const identity: {
476
- /**
477
- * Get the user's hex-encoded public key. Always succeeds.
478
- * @returns Hex-encoded public key string
479
- */
480
- getPublicKey(): Promise<string>;
481
- /**
482
- * Listen for shell-pushed user identity changes.
483
- * @param handler Called with a hex pubkey, or "" when no user/signer is connected
484
- * @returns Subscription with close() to detach the handler
485
- */
486
- onChanged(handler: (pubkey: string) => void): Subscription;
487
- /**
488
- * Get the user's relay list (NIP-65).
489
- * @returns Record mapping relay URLs to read/write permissions
490
- */
491
- getRelays(): Promise<Record<string, {
492
- read: boolean;
493
- write: boolean;
494
- }>>;
495
- /**
496
- * Get the user's profile metadata (kind 0).
497
- * @returns Profile data, or null if not found
498
- */
499
- getProfile(): Promise<{
500
- name?: string;
501
- displayName?: string;
502
- about?: string;
503
- picture?: string;
504
- banner?: string;
505
- nip05?: string;
506
- lud16?: string;
507
- website?: string;
508
- } | null>;
509
- /**
510
- * Get the user's follow list (kind 3 contact list).
511
- * @returns Array of hex-encoded public keys
512
- */
513
- getFollows(): Promise<string[]>;
514
- /**
515
- * Get entries from a user's categorized list.
516
- * @param listType List category (e.g., "bookmarks", "interests", "pins")
517
- * @returns Array of list entry values
518
- */
519
- getList(listType: string): Promise<string[]>;
520
- /**
521
- * Get zap receipts sent to the user.
522
- * @returns Array of zap receipt objects
523
- */
524
- getZaps(): Promise<{
525
- eventId: string;
526
- sender: string;
527
- amount: number;
528
- content?: string;
529
- }[]>;
530
- /**
531
- * Get the user's mute list (kind 10000).
532
- * @returns Array of hex-encoded muted public keys
533
- */
534
- getMutes(): Promise<string[]>;
535
- /**
536
- * Get the user's block list.
537
- * @returns Array of hex-encoded blocked public keys
538
- */
539
- getBlocked(): Promise<string[]>;
540
- /**
541
- * Get badges awarded to the user (NIP-58).
542
- * @returns Array of badge objects
543
- */
544
- getBadges(): Promise<{
545
- id: string;
546
- name?: string;
547
- description?: string;
548
- image?: string;
549
- thumbs?: string[];
550
- awardedBy: string;
551
- }[]>;
552
- };
178
+ declare const identity: SdkDomain$3<'identity'>;
553
179
 
554
180
  /**
555
181
  * @napplet/sdk -- Declarative config and resource byte-fetch wrapper objects.
@@ -557,6 +183,7 @@ declare const identity: {
557
183
  * @packageDocumentation
558
184
  */
559
185
 
186
+ type SdkDomain$2<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
560
187
  /**
561
188
  * Per-napplet declarative configuration (NAP-CONFIG): register a schema,
562
189
  * read current values, subscribe to live updates, deep-link into the
@@ -576,101 +203,27 @@ declare const identity: {
576
203
  * config.openSettings({ section: 'appearance' });
577
204
  * ```
578
205
  */
579
- declare const config: {
580
- /**
581
- * Snapshot current validated + defaulted config values.
582
- * @returns A one-shot ConfigValues object.
583
- */
584
- get(): Promise<Record<string, unknown>>;
585
- /**
586
- * Subscribe to live configuration updates.
587
- * First delivery is an immediate snapshot; subsequent deliveries fire on change.
588
- * @param callback Invoked with the full ConfigValues on every change.
589
- * @returns A Subscription with close() to stop listening.
590
- */
591
- subscribe(callback: (values: Record<string, unknown>) => void): Subscription;
592
- /**
593
- * Request the shell open its settings UI for this napplet.
594
- * @param options Optional { section } to deep-link by x-napplet-section name.
595
- */
596
- openSettings(options?: {
597
- section?: string;
598
- }): void;
599
- /**
600
- * Register a napplet configuration schema at runtime (escape hatch;
601
- * prefer manifest-declared via @napplet/vite-plugin's configSchema option).
602
- * @param schema JSON Schema (draft-07+) describing the config surface.
603
- * @param version Optional `$version` migration hint.
604
- */
605
- registerSchema(schema: Record<string, unknown>, version?: number): Promise<void>;
606
- /**
607
- * Listen for schema-registration errors pushed by the shell
608
- * (manifest parse failure, no-schema on subscribe-before-schema, etc.).
609
- * @param callback Invoked with { code, error } on every push.
610
- * @returns A plain teardown function that detaches the listener.
611
- */
612
- onSchemaError(callback: (err: {
613
- code: string;
614
- error: string;
615
- }) => void): () => void;
616
- /**
617
- * Current schema snapshot (readonly). Populated from the
618
- * `<meta name="napplet-config-schema">` manifest tag at shim install,
619
- * updated on successful registerSchema responses.
620
- * @returns The registered schema, or null if none.
621
- */
622
- readonly schema: Record<string, unknown> | null;
623
- };
206
+ declare const config: SdkDomain$2<'config'>;
624
207
  /**
625
208
  * Browser-enforced byte-fetching primitive: napplets request bytes by URL,
626
209
  * shell fetches and returns a Blob. URL space is scheme-pluggable
627
- * (`data:`, `https:`, `blossom:`, `nostr:`).
210
+ * (`data:`, `https:`, `blossom:`, `htree:`, `nostr:`).
628
211
  *
629
212
  * @example
630
213
  * ```ts
631
214
  * import { resource } from '@napplet/sdk';
632
215
  *
633
216
  * const blob = await resource.bytes('https://example.com/avatar.png');
634
- * const items = await resource.bytesMany(['https://example.com/a.png']);
217
+ * const items = await resource.bytesMany([
218
+ * 'https://example.com/a.png',
219
+ * 'htree://example-root/path',
220
+ * ]);
635
221
  * const handle = resource.bytesAsObjectURL('blossom:abc123...');
636
222
  * imgEl.src = handle.url;
637
223
  * imgEl.onload = () => handle.revoke();
638
224
  * ```
639
225
  */
640
- declare const resource: {
641
- /**
642
- * Inspect resource schemes and coarse runtime policy limits.
643
- * @returns Promise resolving to advisory resource info.
644
- */
645
- info(): Promise<ResourceInfo>;
646
- /**
647
- * Fetch bytes for a URL through the shell's resource pipeline.
648
- * @param url URL identifying the resource (any registered scheme).
649
- * @returns Promise resolving to the fetched bytes as a Blob.
650
- */
651
- bytes(url: string, opts?: {
652
- signal?: AbortSignal;
653
- }): Promise<Blob>;
654
- /**
655
- * Fetch bytes for many URLs through one shell envelope.
656
- * @param urls Non-empty URL list.
657
- * @param opts Optional AbortController signal.
658
- * @returns Promise resolving to ordered per-URL result items.
659
- */
660
- bytesMany(urls: string[], opts?: {
661
- signal?: AbortSignal;
662
- }): Promise<ResourceBytesItem[]>;
663
- /**
664
- * Fetch bytes and return a managed object URL handle.
665
- * Call `revoke()` to release the underlying Blob URL.
666
- * @param url URL identifying the resource.
667
- * @returns Synchronous handle `{ url, revoke }`.
668
- */
669
- bytesAsObjectURL(url: string): {
670
- url: string;
671
- revoke: () => void;
672
- };
673
- };
226
+ declare const resource: SdkDomain$2<'resource'>;
674
227
 
675
228
  /**
676
229
  * @napplet/sdk -- ContextVM bridge, outbox routing, upload, intent, and WebRTC
@@ -679,6 +232,7 @@ declare const resource: {
679
232
  * @packageDocumentation
680
233
  */
681
234
 
235
+ type SdkDomain$1<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
682
236
  /**
683
237
  * Native ContextVM bridge (NAP-CVM): MCP-over-Nostr access mediated by the shell.
684
238
  * The shell owns ContextVM transport, signing, encryption, correlation, policy,
@@ -693,60 +247,7 @@ declare const resource: {
693
247
  * const result = await cvm.callTool(servers[0], tools[0].name, {});
694
248
  * ```
695
249
  */
696
- declare const cvm: {
697
- /**
698
- * Discover public ContextVM servers known to the shell.
699
- * @param query Optional discovery filter
700
- * @returns Promise resolving to the discovered servers
701
- */
702
- discover(query?: CvmDiscoverQuery): Promise<CvmServer[]>;
703
- /**
704
- * Send a raw MCP JSON-RPC message to a ContextVM server.
705
- * @param server Target ContextVM server
706
- * @param message MCP JSON-RPC message
707
- * @param options Optional per-request options
708
- * @returns Promise resolving to the MCP response message
709
- */
710
- request(server: CvmServerRef, message: McpMessage, options?: CvmRequestOptions): Promise<McpMessage>;
711
- /**
712
- * List the tools exposed by a ContextVM server (MCP `tools/list`).
713
- * @param server Target ContextVM server
714
- * @param options Optional per-request options
715
- */
716
- listTools(server: CvmServerRef, options?: CvmRequestOptions): Promise<McpTool[]>;
717
- /**
718
- * Call a tool on a ContextVM server (MCP `tools/call`).
719
- * @param server Target ContextVM server
720
- * @param name Tool name
721
- * @param args Tool arguments
722
- * @param options Optional per-request options
723
- */
724
- callTool(server: CvmServerRef, name: string, args?: Record<string, unknown>, options?: CvmRequestOptions): Promise<McpToolResult>;
725
- /**
726
- * List the resources exposed by a ContextVM server (MCP `resources/list`).
727
- * @param server Target ContextVM server
728
- * @param options Optional per-request options
729
- */
730
- listResources(server: CvmServerRef, options?: CvmRequestOptions): Promise<McpResource[]>;
731
- /**
732
- * Read a resource from a ContextVM server (MCP `resources/read`).
733
- * @param server Target ContextVM server
734
- * @param uri Resource URI
735
- * @param options Optional per-request options
736
- */
737
- readResource(server: CvmServerRef, uri: string, options?: CvmRequestOptions): Promise<McpResourceContent>;
738
- /**
739
- * Close shell-maintained session state for a server.
740
- * @param server Server whose session should be torn down
741
- */
742
- close(server: CvmServerRef): Promise<void>;
743
- /**
744
- * Listen for server-pushed MCP messages (`cvm.event`).
745
- * @param callback Called with `(server, message)` for each server event
746
- * @returns A Subscription with `close()` to stop listening
747
- */
748
- onEvent(callback: (server: CvmServerRef, message: McpMessage) => void): Subscription;
749
- };
250
+ declare const cvm: SdkDomain$1<'cvm'>;
750
251
  /**
751
252
  * Outbox-aware relay routing (NAP-OUTBOX): supply Nostr filters and intent and
752
253
  * let the shell discover the correct relays (NIP-65 write/read relays, fallbacks,
@@ -765,42 +266,7 @@ declare const cvm: {
765
266
  * sub.on('event', (result) => render(result.event, result.sidecar?.relayHints));
766
267
  * ```
767
268
  */
768
- declare const outbox: {
769
- /**
770
- * Fetch one event by ID through shell-owned outbox routing.
771
- * @param eventId Event id to fetch
772
- * @param options Optional author/relay hints and timeout
773
- * @returns Promise resolving to the outbox event result
774
- */
775
- getEvent(eventId: string, options?: OutboxEventOptions): Promise<OutboxEventResult>;
776
- /**
777
- * Perform a one-shot outbox-aware query.
778
- * @param filters NIP-01 filter or filters
779
- * @param options Optional query options
780
- * @returns Promise resolving to the outbox result
781
- */
782
- query(filters: NostrFilter | NostrFilter[], options?: OutboxQueryOptions): Promise<OutboxResult>;
783
- /**
784
- * Open a live outbox-aware subscription.
785
- * @param filters NIP-01 filter or filters
786
- * @param options Optional subscribe options
787
- * @returns An OutboxSubscription handle with `on(...)` and `close()`
788
- */
789
- subscribe(filters: NostrFilter | NostrFilter[], options?: OutboxSubscribeOptions): OutboxSubscription;
790
- /**
791
- * Publish a shell-signed event using outbox-aware relay fanout.
792
- * @param template Unsigned event template
793
- * @param options Optional publish options
794
- * @returns Promise resolving to the outbox publish result
795
- */
796
- publish(template: EventTemplate, options?: OutboxPublishOptions): Promise<OutboxPublishResult>;
797
- /**
798
- * Resolve the relay plan the shell would use for a read/write target.
799
- * @param target The read/write target
800
- * @returns Promise resolving to the relay plan
801
- */
802
- resolveRelays(target: OutboxTarget): Promise<OutboxRelayPlan>;
803
- };
269
+ declare const outbox: SdkDomain$1<'outbox'>;
804
270
  /**
805
271
  * Shell-mediated file/blob upload (NAP-UPLOAD): hand the shell raw bytes plus
806
272
  * upload intent; the shell selects a server, signs the rail authorization
@@ -816,31 +282,7 @@ declare const outbox: {
816
282
  * if (result.status === 'complete') attach(result.url, result.nip94);
817
283
  * ```
818
284
  */
819
- declare const upload: {
820
- /**
821
- * Inspect upload rails and coarse runtime policy limits.
822
- * @returns Promise resolving to advisory upload info.
823
- */
824
- info(): Promise<UploadInfo>;
825
- /**
826
- * Upload bytes through the shell's storage pipeline.
827
- * @param request The upload request (Blob/ArrayBuffer bytes + intent)
828
- * @returns Promise resolving to the initial upload result
829
- */
830
- upload(request: UploadRequest): Promise<UploadResult>;
831
- /**
832
- * Get the latest known status for a prior upload.
833
- * @param uploadId The shell-generated upload id
834
- * @returns Promise resolving to the latest status
835
- */
836
- status(uploadId: string): Promise<UploadStatus>;
837
- /**
838
- * Register for shell-pushed upload status updates.
839
- * @param handler Called with each new UploadStatus
840
- * @returns A Subscription with `close()` to stop listening
841
- */
842
- onStatus(handler: (status: UploadStatus) => void): Subscription;
843
- };
285
+ declare const upload: SdkDomain$1<'upload'>;
844
286
  /**
845
287
  * Archetype intent dispatch (NAP-INTENT): invoke another napplet by its role
846
288
  * without addressing it directly. The shell resolves the role to an installed
@@ -857,40 +299,7 @@ declare const upload: {
857
299
  * }
858
300
  * ```
859
301
  */
860
- declare const intent: {
861
- /**
862
- * Invoke a napplet by archetype.
863
- * @param request The intent request (archetype + action + payload + routing)
864
- * @returns Promise resolving to the invocation result
865
- */
866
- invoke(request: IntentRequest): Promise<IntentResult>;
867
- /**
868
- * Open a napplet by archetype (sugar for `action: "open"`).
869
- * @param archetype Role slug to open
870
- * @param payload Opaque payload (typed by the resolved protocol)
871
- * @param opts Extra request fields (protocol, handler, behavior)
872
- * @returns Promise resolving to the invocation result
873
- */
874
- open(archetype: string, payload?: unknown, opts?: Omit<IntentRequest, "archetype" | "action" | "payload">): Promise<IntentResult>;
875
- /**
876
- * Check whether the runtime can currently satisfy an archetype and expose the
877
- * manifest-derived contracts each candidate serves.
878
- * @param archetype Role slug to check
879
- * @returns Promise resolving to the archetype availability
880
- */
881
- available(archetype: string): Promise<IntentAvailability>;
882
- /**
883
- * Get availability for every archetype the runtime can satisfy.
884
- * @returns Promise resolving to availability for each satisfiable archetype
885
- */
886
- handlers(): Promise<IntentAvailability[]>;
887
- /**
888
- * Register for shell-pushed availability updates.
889
- * @param handler Called with each updated IntentAvailability
890
- * @returns A Subscription with `close()` to stop listening
891
- */
892
- onChanged(handler: (availability: IntentAvailability) => void): Subscription;
893
- };
302
+ declare const intent: SdkDomain$1<'intent'>;
894
303
  /**
895
304
  * Runtime-mediated WebRTC sessions (NAP-WEBRTC). The shell owns signaling,
896
305
  * signing/encryption, SDP, ICE, and peer-connection lifecycle; napplets exchange
@@ -904,32 +313,7 @@ declare const intent: {
904
313
  * await webrtc.send(session.id, { body: 'hello' });
905
314
  * ```
906
315
  */
907
- declare const webrtc: {
908
- /**
909
- * Open a runtime-owned WebRTC session.
910
- * @param request Session scope and channel/protocol labels
911
- * @returns Promise resolving to the opened session result
912
- */
913
- open(request: WebrtcOpenRequest): Promise<WebrtcOpenResult>;
914
- /**
915
- * Send an opaque application payload over a session.
916
- * @param sessionId WebRTC session id
917
- * @param payload Application payload
918
- */
919
- send(sessionId: string, payload: unknown): Promise<void>;
920
- /**
921
- * Close a WebRTC session.
922
- * @param sessionId WebRTC session id
923
- * @param reason Optional close reason
924
- */
925
- close(sessionId: string, reason?: string): Promise<void>;
926
- /**
927
- * Subscribe to runtime-pushed WebRTC events.
928
- * @param handler Event handler
929
- * @returns Subscription handle
930
- */
931
- onEvent(handler: (event: WebrtcEvent) => void): Subscription;
932
- };
316
+ declare const webrtc: SdkDomain$1<'webrtc'>;
933
317
 
934
318
  /**
935
319
  * @napplet/sdk -- Link, lists, common, BLE, and serial wrapper objects.
@@ -937,6 +321,7 @@ declare const webrtc: {
937
321
  * @packageDocumentation
938
322
  */
939
323
 
324
+ type SdkDomain<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
940
325
  /**
941
326
  * Shell-mediated link opening (NAP-LINK): ask the shell to open an external URL
942
327
  * for user-visible navigation. The shell owns prompting, policy, opener
@@ -949,15 +334,7 @@ declare const webrtc: {
949
334
  * const result = await link.open('https://example.com/post/123', { label: 'Read post' });
950
335
  * ```
951
336
  */
952
- declare const link: {
953
- /**
954
- * Request that the shell open an external URL for the user.
955
- * @param url Absolute URL to open
956
- * @param options Optional prompt/display hints
957
- * @returns Promise resolving to the shell's open/deny status
958
- */
959
- open(url: string, options?: LinkOpenOptions): Promise<LinkOpenResult>;
960
- };
337
+ declare const link: SdkDomain<'link'>;
961
338
  /**
962
339
  * Runtime-mediated event counts (NAP-COUNT): ask the runtime to count NIP-01
963
340
  * filter matches without returning matching event payloads. The runtime owns
@@ -971,15 +348,7 @@ declare const link: {
971
348
  * const result = await count.query({ kinds: [7], '#e': [eventId] });
972
349
  * ```
973
350
  */
974
- declare const count: {
975
- /**
976
- * Count events matching one or more NIP-01 filters.
977
- * @param filters One NIP-01 filter or a non-empty array of filters
978
- * @param options Optional approximation and HyperLogLog hints
979
- * @returns Promise resolving to the runtime count result
980
- */
981
- query(filters: CountFilter | CountFilter[], options?: CountOptions): Promise<CountResult>;
982
- };
351
+ declare const count: SdkDomain<'count'>;
983
352
  /**
984
353
  * Runtime-mediated NIP-51 list mutations (NAP-LISTS): add or remove semantic
985
354
  * items from supported NIP-51 lists while the runtime owns lookup, merge,
@@ -994,27 +363,7 @@ declare const count: {
994
363
  * ]);
995
364
  * ```
996
365
  */
997
- declare const lists: {
998
- /**
999
- * Return the NIP-51 list kinds/types this runtime supports.
1000
- * @returns Promise resolving to supported list descriptions
1001
- */
1002
- supported(): Promise<ListSupport[]>;
1003
- /**
1004
- * Add items to a runtime-supported NIP-51 list.
1005
- * @param list List reference by kind or derived type
1006
- * @param items Items to add
1007
- * @param options Optional create/metadata hints
1008
- */
1009
- add(list: ListRef, items: ListItem[], options?: ListOptions): Promise<ListMutationResult>;
1010
- /**
1011
- * Remove items from a runtime-supported NIP-51 list.
1012
- * @param list List reference by kind or derived type
1013
- * @param items Items to remove
1014
- * @param options Optional runtime hints
1015
- */
1016
- remove(list: ListRef, items: ListItem[], options?: ListOptions): Promise<ListMutationResult>;
1017
- };
366
+ declare const lists: SdkDomain<'lists'>;
1018
367
  /**
1019
368
  * Common social actions (NAP-COMMON): shell-mediated public NIP-19 helpers,
1020
369
  * profile lookup, follows, follow/unfollow, reactions, and reports. The shell
@@ -1029,59 +378,7 @@ declare const lists: {
1029
378
  * await common.react(noteId, '+');
1030
379
  * ```
1031
380
  */
1032
- declare const common: {
1033
- /**
1034
- * Encode a supported public NIP-19 value.
1035
- * @param input Structured NIP-19 encode input
1036
- * @returns Promise resolving to the shell encode result
1037
- */
1038
- encodeNip19(input: CommonNip19EncodeInput): Promise<CommonNip19EncodeResult>;
1039
- /**
1040
- * Decode a supported public NIP-19 value.
1041
- * @param value NIP-19 value to decode
1042
- * @returns Promise resolving to normalized decoded fields
1043
- */
1044
- decodeNip19(value: string): Promise<CommonNip19DecodeResult>;
1045
- /**
1046
- * Resolve a profile by hex pubkey, npub, or nprofile.
1047
- * @param target Profile target
1048
- * @returns Promise resolving to latest profile data when available
1049
- */
1050
- getProfile(target: CommonProfileTarget): Promise<CommonProfileResult>;
1051
- /**
1052
- * Return the shell user's followed pubkeys as hex.
1053
- * @returns Promise resolving to followed pubkeys
1054
- */
1055
- follows(): Promise<CommonFollowsResult>;
1056
- /**
1057
- * Ask the shell to follow one or more npub targets.
1058
- * @param pubkeys Npub targets to follow
1059
- * @returns Promise resolving to the action result
1060
- */
1061
- follow(...pubkeys: string[]): Promise<CommonActionResult>;
1062
- /**
1063
- * Ask the shell to unfollow one or more npub targets.
1064
- * @param pubkeys Npub targets to unfollow
1065
- * @returns Promise resolving to the action result
1066
- */
1067
- unfollow(...pubkeys: string[]): Promise<CommonActionResult>;
1068
- /**
1069
- * React to a native Nostr event.
1070
- * @param targetEventId Event id to react to
1071
- * @param reaction Reaction content
1072
- * @param customEmojiHref Optional custom emoji URL
1073
- * @returns Promise resolving to the action result
1074
- */
1075
- react(targetEventId: string, reaction: CommonReaction, customEmojiHref?: string): Promise<CommonActionResult>;
1076
- /**
1077
- * Report an event or pubkey with a NIP-56 reason.
1078
- * @param target Structured report target
1079
- * @param reason NIP-56 report reason
1080
- * @param text Report text
1081
- * @returns Promise resolving to the action result
1082
- */
1083
- report(target: CommonReportTarget, reason: CommonReportReason, text: string): Promise<CommonActionResult>;
1084
- };
381
+ declare const common: SdkDomain<'common'>;
1085
382
  /**
1086
383
  * Runtime-mediated Bluetooth LE/GATT sessions (NAP-BLE): ask the shell to
1087
384
  * select a user-approved BLE device, expose opaque sessions and GATT
@@ -1096,60 +393,7 @@ declare const common: {
1096
393
  * const services = await ble.services(session.id);
1097
394
  * ```
1098
395
  */
1099
- declare const ble: {
1100
- /**
1101
- * Ask the runtime to select and open a BLE session.
1102
- * @param request Device selection and optional service request
1103
- * @returns Promise resolving to the runtime-assigned BLE open result
1104
- */
1105
- open(request: BleOpenRequest): Promise<BleOpenResult>;
1106
- /**
1107
- * List exposed GATT services for a session.
1108
- * @param sessionId Runtime-assigned BLE session id
1109
- * @returns Promise resolving to exposed services
1110
- */
1111
- services(sessionId: string): Promise<BleService[]>;
1112
- /**
1113
- * Read a characteristic or descriptor value.
1114
- * @param sessionId Runtime-assigned BLE session id
1115
- * @param target GATT attribute target
1116
- * @returns Promise resolving to bytes
1117
- */
1118
- read(sessionId: string, target: BleAttribute): Promise<number[]>;
1119
- /**
1120
- * Write bytes to a characteristic or descriptor.
1121
- * @param sessionId Runtime-assigned BLE session id
1122
- * @param target GATT attribute target
1123
- * @param data Byte values to write
1124
- * @param options Optional write mode preference
1125
- * @returns Promise resolving after the runtime acknowledges the write
1126
- */
1127
- write(sessionId: string, target: BleAttribute, data: number[], options?: BleWriteOptions): Promise<void>;
1128
- /**
1129
- * Start notifications or indications for a characteristic.
1130
- * @param sessionId Runtime-assigned BLE session id
1131
- * @param target GATT characteristic target
1132
- */
1133
- subscribe(sessionId: string, target: BleAttribute): Promise<void>;
1134
- /**
1135
- * Stop notifications or indications for a characteristic.
1136
- * @param sessionId Runtime-assigned BLE session id
1137
- * @param target GATT characteristic target
1138
- */
1139
- unsubscribe(sessionId: string, target: BleAttribute): Promise<void>;
1140
- /**
1141
- * Close an open BLE session.
1142
- * @param sessionId Runtime-assigned BLE session id
1143
- * @param reason Optional reason for the close request
1144
- */
1145
- close(sessionId: string, reason?: string): Promise<void>;
1146
- /**
1147
- * Register for shell-pushed BLE events.
1148
- * @param handler Called with each BLE event
1149
- * @returns A Subscription with `close()` to stop listening
1150
- */
1151
- onEvent(handler: (event: BleEvent) => void): Subscription;
1152
- };
396
+ declare const ble: SdkDomain<'ble'>;
1153
397
  /**
1154
398
  * Runtime-mediated serial device access (NAP-SERIAL): ask the shell to select
1155
399
  * and open a user-approved serial session, write byte arrays to that session,
@@ -1164,34 +408,7 @@ declare const ble: {
1164
408
  * await serial.write(session.id, [112, 105, 110, 103, 10]);
1165
409
  * ```
1166
410
  */
1167
- declare const serial: {
1168
- /**
1169
- * Ask the runtime to select and open a serial session.
1170
- * @param request Filters, options, and optional chooser label
1171
- * @returns Promise resolving to the runtime-assigned serial open result
1172
- */
1173
- open(request: SerialOpenRequest): Promise<SerialOpenResult>;
1174
- /**
1175
- * Write bytes to an open serial session.
1176
- * @param sessionId Runtime-assigned serial session id
1177
- * @param data Byte values to write
1178
- * @returns Promise resolving after the runtime acknowledges the write
1179
- */
1180
- write(sessionId: string, data: Uint8Array | number[]): Promise<void>;
1181
- /**
1182
- * Close an open serial session.
1183
- * @param sessionId Runtime-assigned serial session id
1184
- * @param reason Optional reason for the close request
1185
- * @returns Promise resolving after the runtime acknowledges the close
1186
- */
1187
- close(sessionId: string, reason?: string): Promise<void>;
1188
- /**
1189
- * Register for shell-pushed serial events.
1190
- * @param handler Called with each serial event
1191
- * @returns A Subscription with `close()` to stop listening
1192
- */
1193
- onEvent(handler: (event: SerialEvent) => void): Subscription;
1194
- };
411
+ declare const serial: SdkDomain<'serial'>;
1195
412
  /**
1196
413
  * Runtime-mediated direct messages (NAP-DM): present DM UI while the runtime
1197
414
  * owns signing, encryption, relay routing, storage, key/session state, and
@@ -1205,48 +422,6 @@ declare const serial: {
1205
422
  * dm.onMessage((message) => render(message));
1206
423
  * ```
1207
424
  */
1208
- declare const dm: {
1209
- /**
1210
- * Get current DM availability and advisory runtime labels.
1211
- * @returns Promise resolving to the runtime DM status
1212
- */
1213
- status(): Promise<DmStatus>;
1214
- /**
1215
- * Fetch normalized conversations visible to this napplet.
1216
- * @param query Optional cursor and limit
1217
- * @returns Promise resolving to a page of conversations
1218
- */
1219
- conversations(query?: DmConversationQuery): Promise<DmConversationPage>;
1220
- /**
1221
- * Fetch normalized message history for one conversation.
1222
- * @param query Conversation id plus optional cursor and limit
1223
- * @returns Promise resolving to a page of messages
1224
- */
1225
- messages(query: DmMessageQuery): Promise<DmMessagePage>;
1226
- /**
1227
- * Ask the runtime to send a direct message.
1228
- * @param request Recipients, content, and optional conversation/client ids
1229
- * @returns Promise resolving to the normalized send result
1230
- */
1231
- send(request: DmSendRequest): Promise<DmSendResult>;
1232
- /**
1233
- * Start live delivery for one conversation or all visible conversations.
1234
- * @param request Optional conversation scope
1235
- * @returns Promise resolving to the runtime subscription id
1236
- */
1237
- subscribe(request?: DmSubscribeRequest): Promise<DmSubscription>;
1238
- /**
1239
- * Stop a live DM subscription.
1240
- * @param subscriptionId Runtime subscription id from subscribe()
1241
- * @returns Promise resolving to the runtime acknowledgement
1242
- */
1243
- unsubscribe(subscriptionId: string): Promise<DmOk>;
1244
- /**
1245
- * Register for shell-pushed `dm.message` deliveries.
1246
- * @param handler Called with each message and its runtime subscription id
1247
- * @returns A Subscription with `close()` to stop listening
1248
- */
1249
- onMessage(handler: (message: DmMessage, subscriptionId: string) => void): Subscription;
1250
- };
425
+ declare const dm: SdkDomain<'dm'>;
1251
426
 
1252
427
  export { ble, common, config, count, cvm, dm, identity, ifc, inc, intent, keys, link, lists, media, notify, outbox, relay, resource, serial, storage, upload, webrtc };