@clipbus/plugin-sdk 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/API.md +641 -0
  2. package/LICENSE +21 -0
  3. package/README.md +466 -0
  4. package/SPECIFICATION.md +355 -0
  5. package/dist/dom/autoFit.d.ts +15 -0
  6. package/dist/dom/consolePatch.d.ts +1 -0
  7. package/dist/dom/index.cjs +211 -0
  8. package/dist/dom/index.d.cts +6 -0
  9. package/dist/dom/index.d.ts +6 -0
  10. package/dist/dom/index.js +188 -0
  11. package/dist/dom/textInputState.d.ts +1 -0
  12. package/dist/dom/topicAdapter.d.ts +30 -0
  13. package/dist/generated/INDEX.runtime.generated.d.ts +6 -0
  14. package/dist/generated/INDEX.ui.generated.d.ts +4 -0
  15. package/dist/generated/capabilityClients.generated.d.ts +199 -0
  16. package/dist/generated/data.generated.d.ts +193 -0
  17. package/dist/generated/hostClients.generated.d.ts +38 -0
  18. package/dist/generated/runtime.actionResult.generated.d.ts +28 -0
  19. package/dist/generated/runtime.definePlugin.generated.d.ts +16 -0
  20. package/dist/generated/runtime.handlers.generated.d.ts +20 -0
  21. package/dist/generated/runtime.host.generated.d.ts +34 -0
  22. package/dist/generated/topicSubscribers.generated.d.ts +32 -0
  23. package/dist/generated/ui.bootstrap.generated.d.ts +15 -0
  24. package/dist/generated/ui.clipbus.generated.d.ts +79 -0
  25. package/dist/generated/wireConstants.generated.d.ts +3 -0
  26. package/dist/internal/capabilities.d.ts +31 -0
  27. package/dist/internal/index.cjs +68 -0
  28. package/dist/internal/index.d.ts +1 -0
  29. package/dist/internal/internalConsole.d.ts +7 -0
  30. package/dist/internal/ipcBus.d.ts +48 -0
  31. package/dist/internal/runtimeInvokeClient.d.ts +3 -0
  32. package/dist/internal/topic.d.ts +20 -0
  33. package/dist/runtime/defineMessage.d.ts +6 -0
  34. package/dist/runtime/index.cjs +163 -0
  35. package/dist/runtime/index.d.cts +4 -0
  36. package/dist/runtime/index.d.ts +4 -0
  37. package/dist/runtime/index.js +132 -0
  38. package/dist/shared/defineMessage.d.ts +7 -0
  39. package/dist/ui/defineMessage.d.ts +7 -0
  40. package/dist/ui/index.cjs +362 -0
  41. package/dist/ui/index.d.cts +4 -0
  42. package/dist/ui/index.d.ts +4 -0
  43. package/dist/ui/index.js +339 -0
  44. package/docs/README.md +34 -0
  45. package/docs/authoring.md +288 -0
  46. package/docs/capability-detection.md +105 -0
  47. package/docs/concepts.md +80 -0
  48. package/docs/entry.md +137 -0
  49. package/docs/faq.md +65 -0
  50. package/docs/item-context.md +186 -0
  51. package/docs/manifest.md +149 -0
  52. package/docs/permissions.md +32 -0
  53. package/docs/rpc.md +84 -0
  54. package/package.json +76 -0
@@ -0,0 +1,188 @@
1
+ // src/generated/wireConstants.generated.ts
2
+ var STRUCTURED_ERROR_PREFIX = "__clipbus_structured_error__:";
3
+ var CAPABILITY_UNSUPPORTED_ERROR_NAME = "PluginCapabilityUnsupported";
4
+
5
+ // src/internal/capabilities.ts
6
+ var CapabilityUnsupportedError = class extends Error {
7
+ capability;
8
+ constructor(capability) {
9
+ super(`Capability not supported by host: ${capability}`);
10
+ this.name = "CapabilityUnsupportedError";
11
+ this.capability = capability;
12
+ Object.setPrototypeOf(this, new.target.prototype);
13
+ }
14
+ };
15
+ function mapToCapabilityError(err, unsupportedName) {
16
+ if (err.name === unsupportedName) {
17
+ const cap = err.data?.capability ?? "";
18
+ return new CapabilityUnsupportedError(cap);
19
+ }
20
+ const m = /^Unknown method:\s*(.+)$/.exec(err.message);
21
+ if (m) return new CapabilityUnsupportedError(m[1]);
22
+ return err;
23
+ }
24
+
25
+ // src/internal/runtimeInvokeClient.ts
26
+ function parseReplyError(raw) {
27
+ const message = extractMessage(raw);
28
+ if (message.startsWith(STRUCTURED_ERROR_PREFIX)) {
29
+ const json = message.slice(STRUCTURED_ERROR_PREFIX.length);
30
+ try {
31
+ const parsed = JSON.parse(json);
32
+ const err = new Error(typeof parsed.message === "string" ? parsed.message : "");
33
+ if (typeof parsed.name === "string" && parsed.name.length > 0) {
34
+ err.name = parsed.name;
35
+ }
36
+ if (parsed.data !== void 0) {
37
+ err.data = parsed.data;
38
+ }
39
+ return mapToCapabilityError(err, CAPABILITY_UNSUPPORTED_ERROR_NAME);
40
+ } catch {
41
+ return new Error(message);
42
+ }
43
+ }
44
+ return mapToCapabilityError(new Error(message), CAPABILITY_UNSUPPORTED_ERROR_NAME);
45
+ }
46
+ function extractMessage(raw) {
47
+ if (typeof raw === "string") return raw;
48
+ if (raw instanceof Error) return raw.message;
49
+ if (raw && typeof raw === "object" && "message" in raw) {
50
+ const m = raw.message;
51
+ if (typeof m === "string") return m;
52
+ }
53
+ return String(raw);
54
+ }
55
+
56
+ // src/generated/capabilityClients.generated.ts
57
+ var HANDLER_NAME = "clipbusPluginCall";
58
+ async function callPluginMethod(method, payload) {
59
+ const handler = globalThis.webkit?.messageHandlers?.[HANDLER_NAME];
60
+ if (!handler) {
61
+ const err = new Error("clipbus." + method + " is only available inside a Clipbus plugin WebView");
62
+ err.name = "PluginHostBridgeUnavailable";
63
+ throw err;
64
+ }
65
+ const normalized = JSON.parse(JSON.stringify(payload));
66
+ let reply;
67
+ try {
68
+ reply = await handler.postMessage({ method, payload: normalized });
69
+ } catch (err) {
70
+ throw parseReplyError(err);
71
+ }
72
+ return reply;
73
+ }
74
+ var callWindowSetHeight = (payload) => callPluginMethod("window.setHeight", payload);
75
+ var callConsoleLog = (payload) => callPluginMethod("console.log", payload);
76
+ var callTextInputStateChanged = (payload) => callPluginMethod("textInput.stateChanged", payload);
77
+
78
+ // src/internal/internalConsole.ts
79
+ function pick(method) {
80
+ if (typeof globalThis === "undefined") return () => {
81
+ };
82
+ const g = globalThis;
83
+ const fn = g.console?.[method];
84
+ if (typeof fn !== "function") return () => {
85
+ };
86
+ return fn.bind(g.console);
87
+ }
88
+ var internalConsole = Object.freeze({
89
+ log: pick("log"),
90
+ warn: pick("warn"),
91
+ error: pick("error")
92
+ });
93
+
94
+ // src/dom/autoFit.ts
95
+ function autoFit(options) {
96
+ if (typeof window === "undefined" || typeof document === "undefined") {
97
+ return () => {
98
+ };
99
+ }
100
+ const min = options?.min ?? 0;
101
+ const max = options?.max ?? Infinity;
102
+ const target = options?.target ?? document.body;
103
+ let pending = false;
104
+ function post() {
105
+ if (pending) return;
106
+ pending = true;
107
+ requestAnimationFrame(() => {
108
+ pending = false;
109
+ const raw = target.scrollHeight;
110
+ const clamped = Math.min(max, Math.max(min, raw));
111
+ callWindowSetHeight({ height: clamped }).catch((err) => {
112
+ internalConsole.warn("[clipbus-sdk] autoFit: window.setHeight failed:", err);
113
+ });
114
+ });
115
+ }
116
+ const ro = new ResizeObserver(post);
117
+ ro.observe(target);
118
+ const mo = new MutationObserver(post);
119
+ mo.observe(target, { childList: true, subtree: true, characterData: true, attributes: true });
120
+ post();
121
+ return () => {
122
+ ro.disconnect();
123
+ mo.disconnect();
124
+ };
125
+ }
126
+
127
+ // src/dom/consolePatch.ts
128
+ var _patched = false;
129
+ var _inFlight = 0;
130
+ function patchConsole() {
131
+ if (_patched) return;
132
+ _patched = true;
133
+ const wrap = (level, original) => (...args) => {
134
+ original(...args);
135
+ if (_inFlight > 0) return;
136
+ _inFlight++;
137
+ Promise.resolve().then(() => callConsoleLog({ level, message: args.map(String).join(" ") })).catch((err) => {
138
+ internalConsole.warn("[clipbus-sdk] consolePatch: forward to host failed:", err);
139
+ }).finally(() => {
140
+ _inFlight--;
141
+ });
142
+ };
143
+ console.log = wrap("info", internalConsole.log);
144
+ console.warn = wrap("warn", internalConsole.warn);
145
+ console.error = wrap("error", internalConsole.error);
146
+ }
147
+
148
+ // src/dom/textInputState.ts
149
+ var _patched2 = false;
150
+ function patchTextInputState() {
151
+ if (_patched2 || typeof window === "undefined") return;
152
+ _patched2 = true;
153
+ let isFocused = false;
154
+ let isComposing = false;
155
+ function post() {
156
+ callTextInputStateChanged({ isFocused, isComposing }).catch((err) => {
157
+ internalConsole.warn("[clipbus-sdk] textInputState: dispatch failed:", err);
158
+ });
159
+ }
160
+ document.addEventListener("focusin", () => {
161
+ isFocused = true;
162
+ post();
163
+ });
164
+ document.addEventListener("focusout", () => {
165
+ isFocused = false;
166
+ post();
167
+ });
168
+ document.addEventListener("compositionstart", () => {
169
+ isComposing = true;
170
+ post();
171
+ });
172
+ document.addEventListener("compositionend", () => {
173
+ isComposing = false;
174
+ post();
175
+ });
176
+ }
177
+
178
+ // src/dom/topicAdapter.ts
179
+ function bindTopicTo(topic, set) {
180
+ set(topic.current());
181
+ return topic.on((value) => set(value));
182
+ }
183
+ export {
184
+ autoFit,
185
+ bindTopicTo,
186
+ patchConsole,
187
+ patchTextInputState
188
+ };
@@ -0,0 +1 @@
1
+ export declare function patchTextInputState(): void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Framework-agnostic helper for binding a SDK topic to any reactive state
3
+ * system (Vue, React, Svelte, plain callbacks, …).
4
+ *
5
+ * `Topic<T>` is the interface from sdk/src/internal/topic.ts.
6
+ * We intentionally replicate the minimal shape here (structural typing) so this
7
+ * file has zero runtime imports — it works equally well in Node test runners and
8
+ * browser bundles.
9
+ */
10
+ /** Minimal structural shape satisfied by Topic<T>. */
11
+ export interface TopicLike<T> {
12
+ current(): T | undefined;
13
+ on(listener: (value: T) => void): () => void;
14
+ }
15
+ /**
16
+ * Bind a topic to a setter function and return an unsubscribe handle.
17
+ *
18
+ * Calls `set` immediately with `topic.current()` (which may be `undefined` if
19
+ * the topic has not yet received a value), then subscribes `set` as a listener
20
+ * for future updates.
21
+ *
22
+ * Usage (Vue):
23
+ * ```ts
24
+ * const state = ref<T | undefined>(undefined);
25
+ * const unsub = bindTopicTo(topic, (v) => { state.value = v; });
26
+ * // later:
27
+ * unsub();
28
+ * ```
29
+ */
30
+ export declare function bindTopicTo<T>(topic: TopicLike<T>, set: (value: T | undefined) => void): () => void;
@@ -0,0 +1,6 @@
1
+ export { host } from './runtime.host.generated.js';
2
+ export { definePlugin } from './runtime.definePlugin.generated.js';
3
+ export { actionResult } from './runtime.actionResult.generated.js';
4
+ export type * from './data.generated.js';
5
+ export type * from './capabilityClients.generated.js';
6
+ export type * from './runtime.handlers.generated.js';
@@ -0,0 +1,4 @@
1
+ export { clipbus } from './ui.clipbus.generated.js';
2
+ export type * from './data.generated.js';
3
+ export type * from './capabilityClients.generated.js';
4
+ export { PluginContextError } from './ui.bootstrap.generated.js';
@@ -0,0 +1,199 @@
1
+ import type { PluginActionResult, PluginAttachmentMutationEntry, PluginConsoleLogLevel, PluginInfoPanelDocument, PluginSearchExtensionEntry } from './data.generated.js';
2
+ export interface PluginRuntimeInvokePayload {
3
+ key: string;
4
+ payload: unknown;
5
+ timeoutMs?: number;
6
+ }
7
+ export interface PluginRuntimeInvokeResponse {
8
+ response: unknown;
9
+ }
10
+ export interface PluginItemSetTagsPayload {
11
+ tags: string[];
12
+ }
13
+ export interface PluginItemSetTagsResponse {
14
+ tags: string[];
15
+ }
16
+ export interface PluginItemAddTagsPayload {
17
+ tags: string[];
18
+ }
19
+ export interface PluginItemAddTagsResponse {
20
+ tags: string[];
21
+ }
22
+ export interface PluginItemRemoveTagsPayload {
23
+ tags: string[];
24
+ }
25
+ export interface PluginItemRemoveTagsResponse {
26
+ tags: string[];
27
+ }
28
+ export interface PluginItemSetPinnedPayload {
29
+ pinned: boolean;
30
+ }
31
+ export interface PluginItemSetPinnedResponse {
32
+ pinned: boolean;
33
+ }
34
+ export interface PluginItemSetAttachmentsPayload {
35
+ owner: string;
36
+ attachmentType: string;
37
+ attachments: PluginAttachmentMutationEntry[];
38
+ }
39
+ export interface PluginItemSetAttachmentsResponse {
40
+ }
41
+ export interface PluginItemSetSearchExtensionPayload {
42
+ scope: string;
43
+ owner: string;
44
+ entries: PluginSearchExtensionEntry[];
45
+ }
46
+ export interface PluginItemSetSearchExtensionResponse {
47
+ }
48
+ export interface PluginItemMaterializeImagePathPayload {
49
+ }
50
+ export interface PluginItemMaterializeImagePathResponse {
51
+ path: string;
52
+ }
53
+ export interface PluginItemReadAttachmentPayload {
54
+ attachmentType: string;
55
+ attachmentKey: string;
56
+ }
57
+ export interface PluginItemReadAttachmentResponse {
58
+ payloadJson?: string;
59
+ }
60
+ export interface PluginAssetCurrentItemImageUrlPayload {
61
+ }
62
+ export interface PluginAssetCurrentItemImageUrlResponse {
63
+ url?: string;
64
+ }
65
+ export interface PluginAssetPathReferenceImageUrlPayload {
66
+ index: number;
67
+ }
68
+ export interface PluginAssetPathReferenceImageUrlResponse {
69
+ url?: string;
70
+ }
71
+ export interface PluginAssetRegisterImagePayload {
72
+ path: string;
73
+ }
74
+ export interface PluginAssetRegisterImageResponse {
75
+ url: string;
76
+ }
77
+ export interface PluginClipboardCopyTextPayload {
78
+ text: string;
79
+ }
80
+ export interface PluginClipboardCopyTextResponse {
81
+ }
82
+ export interface PluginNavigationOpenUrlPayload {
83
+ url: string;
84
+ }
85
+ export interface PluginNavigationOpenUrlResponse {
86
+ }
87
+ export interface PluginNavigationRevealInFinderPayload {
88
+ path: string;
89
+ }
90
+ export interface PluginNavigationRevealInFinderResponse {
91
+ }
92
+ export interface PluginNavigationOpenFilePathPayload {
93
+ path: string;
94
+ }
95
+ export interface PluginNavigationOpenFilePathResponse {
96
+ }
97
+ export interface PluginActionAllocateImageTempPathPayload {
98
+ formatHint: string;
99
+ }
100
+ export interface PluginActionAllocateImageTempPathResponse {
101
+ path: string;
102
+ }
103
+ export interface PluginActionSetButtonsPayload {
104
+ buttons: {
105
+ id: string;
106
+ title: string;
107
+ isEnabled?: boolean;
108
+ }[];
109
+ }
110
+ export interface PluginActionSetButtonsResponse {
111
+ }
112
+ export interface PluginActionCompletePayload {
113
+ result: PluginActionResult;
114
+ userMessage?: string;
115
+ }
116
+ export interface PluginActionCompleteResponse {
117
+ }
118
+ export interface PluginAttachmentRendererSetButtonsPayload {
119
+ buttons: {
120
+ id: string;
121
+ title: string;
122
+ isEnabled?: boolean;
123
+ }[];
124
+ }
125
+ export interface PluginAttachmentRendererSetButtonsResponse {
126
+ }
127
+ export interface PluginWindowSetHeightPayload {
128
+ height: number;
129
+ }
130
+ export interface PluginWindowSetHeightResponse {
131
+ }
132
+ export interface PluginWindowAutoFitPayload {
133
+ }
134
+ export interface PluginWindowAutoFitResponse {
135
+ }
136
+ export interface PluginInfoPanelOpenPayload {
137
+ document: PluginInfoPanelDocument;
138
+ }
139
+ export interface PluginInfoPanelOpenResponse {
140
+ panelID: string;
141
+ }
142
+ export interface PluginInfoPanelClosePayload {
143
+ panelID: string;
144
+ }
145
+ export interface PluginInfoPanelCloseResponse {
146
+ }
147
+ export interface PluginSettingsGetPayload {
148
+ key: string;
149
+ }
150
+ export interface PluginSettingsGetResponse {
151
+ value: unknown | null;
152
+ }
153
+ export interface PluginSettingsGetAllPayload {
154
+ }
155
+ export interface PluginSettingsGetAllResponse {
156
+ settings: Record<string, unknown>;
157
+ }
158
+ export interface PluginConsoleLogPayload {
159
+ level: PluginConsoleLogLevel;
160
+ message: string;
161
+ }
162
+ export interface PluginConsoleLogResponse {
163
+ }
164
+ export interface PluginTextInputStateChangedPayload {
165
+ isFocused: boolean;
166
+ isComposing: boolean;
167
+ }
168
+ export interface PluginTextInputStateChangedResponse {
169
+ }
170
+ export declare const CAPABILITY_METHOD_NAMES: readonly ["runtime.invoke", "item.setTags", "item.addTags", "item.removeTags", "item.setPinned", "item.setAttachments", "item.setSearchExtension", "item.materializeImagePath", "item.readAttachment", "asset.currentItemImageUrl", "asset.pathReferenceImageUrl", "asset.registerImage", "clipboard.copyText", "navigation.openUrl", "navigation.revealInFinder", "navigation.openFilePath", "action.allocateImageTempPath", "action.setButtons", "action.complete", "attachmentRenderer.setButtons", "window.setHeight", "window.autoFit", "infoPanel.open", "infoPanel.close", "settings.get", "settings.getAll", "console.log", "textInput.stateChanged"];
171
+ export type CapabilityMethodName = (typeof CAPABILITY_METHOD_NAMES)[number];
172
+ export declare const callRuntimeInvoke: (payload: PluginRuntimeInvokePayload) => Promise<PluginRuntimeInvokeResponse>;
173
+ export declare const callItemSetTags: (payload: PluginItemSetTagsPayload) => Promise<PluginItemSetTagsResponse>;
174
+ export declare const callItemAddTags: (payload: PluginItemAddTagsPayload) => Promise<PluginItemAddTagsResponse>;
175
+ export declare const callItemRemoveTags: (payload: PluginItemRemoveTagsPayload) => Promise<PluginItemRemoveTagsResponse>;
176
+ export declare const callItemSetPinned: (payload: PluginItemSetPinnedPayload) => Promise<PluginItemSetPinnedResponse>;
177
+ export declare const callItemSetAttachments: (payload: PluginItemSetAttachmentsPayload) => Promise<PluginItemSetAttachmentsResponse>;
178
+ export declare const callItemSetSearchExtension: (payload: PluginItemSetSearchExtensionPayload) => Promise<PluginItemSetSearchExtensionResponse>;
179
+ export declare const callItemMaterializeImagePath: () => Promise<PluginItemMaterializeImagePathResponse>;
180
+ export declare const callItemReadAttachment: (payload: PluginItemReadAttachmentPayload) => Promise<PluginItemReadAttachmentResponse>;
181
+ export declare const callAssetCurrentItemImageUrl: () => Promise<PluginAssetCurrentItemImageUrlResponse>;
182
+ export declare const callAssetPathReferenceImageUrl: (payload: PluginAssetPathReferenceImageUrlPayload) => Promise<PluginAssetPathReferenceImageUrlResponse>;
183
+ export declare const callAssetRegisterImage: (payload: PluginAssetRegisterImagePayload) => Promise<PluginAssetRegisterImageResponse>;
184
+ export declare const callClipboardCopyText: (payload: PluginClipboardCopyTextPayload) => Promise<PluginClipboardCopyTextResponse>;
185
+ export declare const callNavigationOpenUrl: (payload: PluginNavigationOpenUrlPayload) => Promise<PluginNavigationOpenUrlResponse>;
186
+ export declare const callNavigationRevealInFinder: (payload: PluginNavigationRevealInFinderPayload) => Promise<PluginNavigationRevealInFinderResponse>;
187
+ export declare const callNavigationOpenFilePath: (payload: PluginNavigationOpenFilePathPayload) => Promise<PluginNavigationOpenFilePathResponse>;
188
+ export declare const callActionAllocateImageTempPath: (payload: PluginActionAllocateImageTempPathPayload) => Promise<PluginActionAllocateImageTempPathResponse>;
189
+ export declare const callActionSetButtons: (payload: PluginActionSetButtonsPayload) => Promise<PluginActionSetButtonsResponse>;
190
+ export declare const callActionComplete: (payload: PluginActionCompletePayload) => Promise<PluginActionCompleteResponse>;
191
+ export declare const callAttachmentRendererSetButtons: (payload: PluginAttachmentRendererSetButtonsPayload) => Promise<PluginAttachmentRendererSetButtonsResponse>;
192
+ export declare const callWindowSetHeight: (payload: PluginWindowSetHeightPayload) => Promise<PluginWindowSetHeightResponse>;
193
+ export declare const callWindowAutoFit: () => Promise<PluginWindowAutoFitResponse>;
194
+ export declare const callInfoPanelOpen: (payload: PluginInfoPanelOpenPayload) => Promise<PluginInfoPanelOpenResponse>;
195
+ export declare const callInfoPanelClose: (payload: PluginInfoPanelClosePayload) => Promise<PluginInfoPanelCloseResponse>;
196
+ export declare const callSettingsGet: (payload: PluginSettingsGetPayload) => Promise<PluginSettingsGetResponse>;
197
+ export declare const callSettingsGetAll: () => Promise<PluginSettingsGetAllResponse>;
198
+ export declare const callConsoleLog: (payload: PluginConsoleLogPayload) => Promise<PluginConsoleLogResponse>;
199
+ export declare const callTextInputStateChanged: (payload: PluginTextInputStateChangedPayload) => Promise<PluginTextInputStateChangedResponse>;
@@ -0,0 +1,193 @@
1
+ export interface PluginAttachmentMutationEntry {
2
+ attachmentKey: string;
3
+ payloadJson: string;
4
+ syncScope: string;
5
+ createdAtMs?: number;
6
+ updatedAtMs?: number;
7
+ }
8
+ export interface PluginSearchExtensionEntry {
9
+ entryKey: string;
10
+ searchText: string;
11
+ label?: string;
12
+ updatedAtMs?: number;
13
+ }
14
+ export interface PluginActionResultText {
15
+ resultKind: 'text';
16
+ text: string;
17
+ }
18
+ export interface PluginActionResultImage {
19
+ resultKind: 'image';
20
+ imageTempPath: string;
21
+ imageFormatHint?: string;
22
+ }
23
+ export interface PluginActionResultNone {
24
+ resultKind: 'none';
25
+ }
26
+ export type PluginActionResult = PluginActionResultText | PluginActionResultImage | PluginActionResultNone;
27
+ export type PluginInfoPanelTextStyle = 'body' | 'mono' | 'muted';
28
+ export type PluginInfoPanelCodeLanguage = 'plain' | 'json';
29
+ export interface PluginInfoPanelField {
30
+ key: string;
31
+ value: string;
32
+ isMono?: boolean;
33
+ }
34
+ export interface PluginInfoPanelBlockLabel {
35
+ type: 'label';
36
+ text: string;
37
+ }
38
+ export interface PluginInfoPanelBlockText {
39
+ type: 'text';
40
+ text: string;
41
+ style: PluginInfoPanelTextStyle;
42
+ }
43
+ export interface PluginInfoPanelBlockCode {
44
+ type: 'code';
45
+ text: string;
46
+ language: PluginInfoPanelCodeLanguage;
47
+ }
48
+ export interface PluginInfoPanelBlockQrCode {
49
+ type: 'qrCode';
50
+ value: string;
51
+ }
52
+ export interface PluginInfoPanelBlockFields {
53
+ type: 'fields';
54
+ fields: PluginInfoPanelField[];
55
+ }
56
+ export interface PluginInfoPanelBlockTags {
57
+ type: 'tags';
58
+ tags: string[];
59
+ }
60
+ export interface PluginInfoPanelBlockDivider {
61
+ type: 'divider';
62
+ }
63
+ export type PluginInfoPanelBlock = PluginInfoPanelBlockLabel | PluginInfoPanelBlockText | PluginInfoPanelBlockCode | PluginInfoPanelBlockQrCode | PluginInfoPanelBlockFields | PluginInfoPanelBlockTags | PluginInfoPanelBlockDivider;
64
+ export interface PluginInfoPanelAction {
65
+ id: string;
66
+ label: string;
67
+ isPrimary?: boolean;
68
+ }
69
+ export interface PluginInfoPanelDocument {
70
+ icon?: string;
71
+ title: string;
72
+ subtitle?: string;
73
+ badges?: string[];
74
+ blocks: PluginInfoPanelBlock[];
75
+ actions: PluginInfoPanelAction[];
76
+ }
77
+ export type PluginConsoleLogLevel = 'debug' | 'info' | 'warn' | 'error';
78
+ export interface PluginClipboardItem {
79
+ id: string;
80
+ type: string;
81
+ tags: string[];
82
+ sourceAppID: string;
83
+ }
84
+ export interface PluginAttachmentEntry {
85
+ historyID: string;
86
+ owner: string;
87
+ attachmentType: string;
88
+ attachmentKey: string;
89
+ payloadJson: string;
90
+ }
91
+ export interface PluginAttachmentPayload {
92
+ item: PluginClipboardItem;
93
+ attachment: PluginAttachmentEntry;
94
+ }
95
+ export interface PluginThemeTokens {
96
+ surface: string;
97
+ surfaceElevated: string;
98
+ textPrimary: string;
99
+ textSecondary: string;
100
+ textTertiary: string;
101
+ accent: string;
102
+ accentContrast: string;
103
+ border: string;
104
+ divider: string;
105
+ success: string;
106
+ warning: string;
107
+ danger: string;
108
+ }
109
+ export interface PluginThemeTokenSnapshot {
110
+ scheme: string;
111
+ tokens: PluginThemeTokens;
112
+ }
113
+ export interface PluginPathEntry {
114
+ kind: 'file' | 'folder';
115
+ path: string;
116
+ displayName: string;
117
+ }
118
+ export interface PluginContentEnvelopeText {
119
+ kind: 'text';
120
+ text: string;
121
+ }
122
+ export interface PluginContentEnvelopeImage {
123
+ kind: 'image';
124
+ width: number;
125
+ height: number;
126
+ format: string;
127
+ bytes: number;
128
+ }
129
+ export interface PluginContentEnvelopePath_reference {
130
+ kind: 'path_reference';
131
+ entries: PluginPathEntry[];
132
+ }
133
+ export type PluginContentEnvelope = PluginContentEnvelopeText | PluginContentEnvelopeImage | PluginContentEnvelopePath_reference;
134
+ export interface PluginAttachmentRef {
135
+ attachmentType: string;
136
+ attachmentKey: string;
137
+ }
138
+ export interface PluginResolveAttachmentInput {
139
+ item: PluginClipboardItem;
140
+ content: PluginContentEnvelope;
141
+ attachments: PluginAttachmentRef[];
142
+ attachment: PluginAttachmentEntry;
143
+ }
144
+ export interface PluginActionButton {
145
+ id: string;
146
+ title: string;
147
+ isEnabled?: boolean;
148
+ }
149
+ export interface PluginAttachmentResolveResult {
150
+ shouldDisplay?: boolean;
151
+ displayName?: string;
152
+ tintHex?: string;
153
+ buttons?: PluginActionButton[];
154
+ }
155
+ export interface PluginDetectorInput {
156
+ item: PluginClipboardItem;
157
+ content: PluginContentEnvelope;
158
+ attachments: PluginAttachmentRef[];
159
+ }
160
+ export interface PluginDetectorSearchProjection {
161
+ scope: string;
162
+ searchText: string;
163
+ label?: string;
164
+ }
165
+ export interface PluginDetectorArtifact {
166
+ attachmentType: string;
167
+ attachmentKey: string;
168
+ payloadJson: string;
169
+ searchProjection?: PluginDetectorSearchProjection;
170
+ attachmentSyncScope?: string;
171
+ createdAtMs?: number;
172
+ updatedAtMs?: number;
173
+ }
174
+ export interface PluginResolveActionSessionInput {
175
+ item: PluginClipboardItem;
176
+ content: PluginContentEnvelope;
177
+ attachments: PluginAttachmentRef[];
178
+ }
179
+ export interface PluginActionResolveResult {
180
+ displayName?: string;
181
+ buttons: PluginActionButton[];
182
+ defaultButtonID?: string;
183
+ initialDraft: Record<string, unknown>;
184
+ }
185
+ export interface PluginAutoRunActionInput {
186
+ item: PluginClipboardItem;
187
+ content: PluginContentEnvelope;
188
+ attachments: PluginAttachmentRef[];
189
+ }
190
+ export interface PluginActionOperationResult {
191
+ result: PluginActionResult;
192
+ userMessage?: string;
193
+ }
@@ -0,0 +1,38 @@
1
+ import type { PluginActionAllocateImageTempPathPayload, PluginActionAllocateImageTempPathResponse, PluginAssetRegisterImagePayload, PluginAssetRegisterImageResponse, PluginClipboardCopyTextPayload, PluginClipboardCopyTextResponse, PluginConsoleLogPayload, PluginConsoleLogResponse, PluginItemAddTagsPayload, PluginItemAddTagsResponse, PluginItemMaterializeImagePathResponse, PluginItemReadAttachmentPayload, PluginItemReadAttachmentResponse, PluginItemRemoveTagsPayload, PluginItemRemoveTagsResponse, PluginItemSetAttachmentsPayload, PluginItemSetAttachmentsResponse, PluginItemSetPinnedPayload, PluginItemSetPinnedResponse, PluginItemSetSearchExtensionPayload, PluginItemSetSearchExtensionResponse, PluginItemSetTagsPayload, PluginItemSetTagsResponse, PluginNavigationOpenFilePathPayload, PluginNavigationOpenFilePathResponse, PluginNavigationOpenUrlPayload, PluginNavigationOpenUrlResponse, PluginNavigationRevealInFinderPayload, PluginNavigationRevealInFinderResponse, PluginSettingsGetAllResponse, PluginSettingsGetPayload, PluginSettingsGetResponse } from './capabilityClients.generated.js';
2
+ export interface IPCBus {
3
+ request<Req, Resp>(method: string, payload: Req): Promise<Resp>;
4
+ }
5
+ export interface HostClient {
6
+ action: {
7
+ allocateImageTempPath(payload: PluginActionAllocateImageTempPathPayload): Promise<PluginActionAllocateImageTempPathResponse>;
8
+ };
9
+ asset: {
10
+ registerImage(payload: PluginAssetRegisterImagePayload): Promise<PluginAssetRegisterImageResponse>;
11
+ };
12
+ clipboard: {
13
+ copyText(payload: PluginClipboardCopyTextPayload): Promise<PluginClipboardCopyTextResponse>;
14
+ };
15
+ console: {
16
+ log(payload: PluginConsoleLogPayload): Promise<PluginConsoleLogResponse>;
17
+ };
18
+ item: {
19
+ setTags(payload: PluginItemSetTagsPayload): Promise<PluginItemSetTagsResponse>;
20
+ addTags(payload: PluginItemAddTagsPayload): Promise<PluginItemAddTagsResponse>;
21
+ removeTags(payload: PluginItemRemoveTagsPayload): Promise<PluginItemRemoveTagsResponse>;
22
+ setPinned(payload: PluginItemSetPinnedPayload): Promise<PluginItemSetPinnedResponse>;
23
+ setAttachments(payload: PluginItemSetAttachmentsPayload): Promise<PluginItemSetAttachmentsResponse>;
24
+ setSearchExtension(payload: PluginItemSetSearchExtensionPayload): Promise<PluginItemSetSearchExtensionResponse>;
25
+ materializeImagePath(): Promise<PluginItemMaterializeImagePathResponse>;
26
+ readAttachment(payload: PluginItemReadAttachmentPayload): Promise<PluginItemReadAttachmentResponse>;
27
+ };
28
+ navigation: {
29
+ openUrl(payload: PluginNavigationOpenUrlPayload): Promise<PluginNavigationOpenUrlResponse>;
30
+ revealInFinder(payload: PluginNavigationRevealInFinderPayload): Promise<PluginNavigationRevealInFinderResponse>;
31
+ openFilePath(payload: PluginNavigationOpenFilePathPayload): Promise<PluginNavigationOpenFilePathResponse>;
32
+ };
33
+ settings: {
34
+ get(payload: PluginSettingsGetPayload): Promise<PluginSettingsGetResponse>;
35
+ getAll(): Promise<PluginSettingsGetAllResponse>;
36
+ };
37
+ }
38
+ export declare function createHostClient(bus: IPCBus): HostClient;
@@ -0,0 +1,28 @@
1
+ export interface ActionResultOptions {
2
+ userMessage?: string;
3
+ }
4
+ export declare const actionResult: {
5
+ text: (text: string, options?: ActionResultOptions) => {
6
+ result: {
7
+ resultKind: "text";
8
+ text: string;
9
+ };
10
+ userMessage: string | undefined;
11
+ };
12
+ image: (imageTempPath: string, options?: {
13
+ imageFormatHint?: string;
14
+ } & ActionResultOptions) => {
15
+ result: {
16
+ resultKind: "image";
17
+ imageTempPath: string;
18
+ imageFormatHint?: string;
19
+ };
20
+ userMessage: string | undefined;
21
+ };
22
+ none: (options?: ActionResultOptions) => {
23
+ result: {
24
+ resultKind: "none";
25
+ };
26
+ userMessage: string | undefined;
27
+ };
28
+ };