@minionry/sdk 0.4.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ export * from './types.js';
2
+ export * from './transport.js';
3
+ export * from './protocol.js';
4
+ export { createProvider } from './provider.js';
5
+ export { createMockTransport, mock } from './transports/mock.js';
6
+ export type { MockConfig, MockToolCallOptions, MockToolsController, MockToolSummary, } from './transports/mock.js';
7
+ export { connectPostMessage, createPostMessageTransport } from './transports/post-message.js';
8
+ export type { PostMessageTransportOptions } from './transports/post-message.js';
9
+ export { installKeyboardForwarding } from './keyboard.js';
10
+ export type { KeyboardForwardingOptions } from './keyboard.js';
11
+ export { announceProvider, detect } from './detect.js';
12
+ export type { DetectOptions } from './detect.js';
13
+ export { createOfflineCache } from './cache.js';
14
+ export type { OfflineCache, OfflineCacheEntry, OfflineCacheOptions, SwrOptions } from './cache.js';
15
+ export declare const SDK_VERSION = "0.4.23";
16
+ export declare const PROVIDER_API_VERSION = "1";
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './types.js';
2
+ export * from './transport.js';
3
+ export * from './protocol.js';
4
+ export { createProvider } from './provider.js';
5
+ export { createMockTransport, mock } from './transports/mock.js';
6
+ export { connectPostMessage, createPostMessageTransport } from './transports/post-message.js';
7
+ export { installKeyboardForwarding } from './keyboard.js';
8
+ export { announceProvider, detect } from './detect.js';
9
+ export { createOfflineCache } from './cache.js';
10
+ export const SDK_VERSION = '0.4.23';
11
+ export const PROVIDER_API_VERSION = '1';
@@ -0,0 +1,6 @@
1
+ import type { Transport } from './transport.js';
2
+ export interface KeyboardForwardingOptions {
3
+ target?: Document | HTMLElement;
4
+ shouldKeep?(event: KeyboardEvent): boolean;
5
+ }
6
+ export declare function installKeyboardForwarding(transport: Transport, options?: KeyboardForwardingOptions): () => void;
@@ -0,0 +1,39 @@
1
+ const TEXT_INPUT_TYPES = new Set([
2
+ 'text', 'search', 'url', 'tel', 'email', 'password', 'number', 'date',
3
+ 'datetime-local', 'month', 'time', 'week',
4
+ ]);
5
+ function isTextEntry(target) {
6
+ if (!target || typeof target.tagName !== 'string')
7
+ return false;
8
+ const element = target;
9
+ if (element.isContentEditable)
10
+ return true;
11
+ const tag = element.tagName;
12
+ if (tag === 'TEXTAREA' || tag === 'SELECT')
13
+ return true;
14
+ if (tag === 'INPUT')
15
+ return TEXT_INPUT_TYPES.has(element.type.toLowerCase());
16
+ return false;
17
+ }
18
+ export function installKeyboardForwarding(transport, options = {}) {
19
+ if (typeof transport.sendKeydown !== 'function')
20
+ return () => { };
21
+ if (typeof document === 'undefined')
22
+ return () => { };
23
+ const target = options.target ?? document;
24
+ const onKeyDown = (event) => {
25
+ const keyboardEvent = event;
26
+ if (keyboardEvent.defaultPrevented)
27
+ return;
28
+ if (keyboardEvent.isComposing || keyboardEvent.keyCode === 229)
29
+ return;
30
+ const hasModifier = keyboardEvent.metaKey || keyboardEvent.ctrlKey || keyboardEvent.altKey;
31
+ if (!hasModifier && isTextEntry(keyboardEvent.target))
32
+ return;
33
+ if (options.shouldKeep?.(keyboardEvent))
34
+ return;
35
+ transport.sendKeydown?.(keyboardEvent);
36
+ };
37
+ target.addEventListener('keydown', onKeyDown);
38
+ return () => target.removeEventListener('keydown', onKeyDown);
39
+ }
@@ -0,0 +1,61 @@
1
+ import type { SdkEventFrame, SdkNotificationFrame, SdkResponseFrame, SdkToolCallFrame } from './transport.js';
2
+ import type { MinionryProvider } from './types.js';
3
+ export declare const SDK_PROTOCOL_VERSION = 1;
4
+ export declare const MINIONRY_FRAME_PREFIX = "minionry:";
5
+ export declare const SDK_HELLO_TYPE = "minionry:hello";
6
+ export declare const HOST_CONNECT_TYPE = "minionry:connect";
7
+ export declare const SDK_CONNECT_ACK_TYPE = "minionry:connect-ack";
8
+ export interface SdkHelloFrame {
9
+ type: typeof SDK_HELLO_TYPE;
10
+ sdkVersion: number;
11
+ }
12
+ export interface HostConnectFrame {
13
+ type: typeof HOST_CONNECT_TYPE;
14
+ sdkVersion: typeof SDK_PROTOCOL_VERSION;
15
+ nonce: string;
16
+ }
17
+ export interface SdkConnectAckFrame {
18
+ type: typeof SDK_CONNECT_ACK_TYPE;
19
+ nonce: string;
20
+ }
21
+ export declare const SDK_REQUEST_TYPE = "minionry:request";
22
+ export declare const SDK_RESPONSE_TYPE = "minionry:response";
23
+ export declare const SDK_EVENT_TYPE = "minionry:event";
24
+ export declare const SDK_NOTIFICATION_TYPE = "minionry:notification";
25
+ export declare const SDK_TOOL_CALL_TYPE = "minionry:tool-call";
26
+ export declare const SDK_KEYDOWN_TYPE = "minionry:keydown";
27
+ export interface SdkRequestWireFrame {
28
+ type: typeof SDK_REQUEST_TYPE;
29
+ requestId: string;
30
+ method: string;
31
+ params?: unknown;
32
+ }
33
+ export type SdkResponseWireFrame = SdkResponseFrame & {
34
+ type: typeof SDK_RESPONSE_TYPE;
35
+ };
36
+ export type SdkEventWireFrame = SdkEventFrame & {
37
+ type: typeof SDK_EVENT_TYPE;
38
+ };
39
+ export type SdkNotificationWireFrame = SdkNotificationFrame & {
40
+ type: typeof SDK_NOTIFICATION_TYPE;
41
+ };
42
+ export type SdkToolCallWireFrame = SdkToolCallFrame & {
43
+ type: typeof SDK_TOOL_CALL_TYPE;
44
+ };
45
+ export interface SdkKeydownWireFrame {
46
+ type: typeof SDK_KEYDOWN_TYPE;
47
+ code: string;
48
+ key: string;
49
+ altKey: boolean;
50
+ ctrlKey: boolean;
51
+ metaKey: boolean;
52
+ shiftKey: boolean;
53
+ isComposing?: boolean;
54
+ }
55
+ export declare const CDP_BINDING_NAME = "__minionryBinding";
56
+ export declare const CDP_MESSAGE_EVENT = "minionry#message";
57
+ export declare const MINIONRY_ANNOUNCE_EVENT = "minionry#announce";
58
+ export declare const MINIONRY_REQUEST_EVENT = "minionry#request";
59
+ export interface MinionryAnnounceDetail {
60
+ provider: MinionryProvider;
61
+ }
@@ -0,0 +1,15 @@
1
+ export const SDK_PROTOCOL_VERSION = 1;
2
+ export const MINIONRY_FRAME_PREFIX = 'minionry:';
3
+ export const SDK_HELLO_TYPE = 'minionry:hello';
4
+ export const HOST_CONNECT_TYPE = 'minionry:connect';
5
+ export const SDK_CONNECT_ACK_TYPE = 'minionry:connect-ack';
6
+ export const SDK_REQUEST_TYPE = 'minionry:request';
7
+ export const SDK_RESPONSE_TYPE = 'minionry:response';
8
+ export const SDK_EVENT_TYPE = 'minionry:event';
9
+ export const SDK_NOTIFICATION_TYPE = 'minionry:notification';
10
+ export const SDK_TOOL_CALL_TYPE = 'minionry:tool-call';
11
+ export const SDK_KEYDOWN_TYPE = 'minionry:keydown';
12
+ export const CDP_BINDING_NAME = '__minionryBinding';
13
+ export const CDP_MESSAGE_EVENT = 'minionry#message';
14
+ export const MINIONRY_ANNOUNCE_EVENT = 'minionry#announce';
15
+ export const MINIONRY_REQUEST_EVENT = 'minionry#request';
@@ -0,0 +1,3 @@
1
+ import type { MinionryProvider } from './types.js';
2
+ import type { Transport } from './transport.js';
3
+ export declare function createProvider(transport: Transport): MinionryProvider;