@mulmochat-plugin/summarize-pdf 0.2.0 → 0.3.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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SummarizePdf Tool Definition (Schema)
3
+ */
4
+ import type { ToolDefinition } from "gui-chat-protocol";
5
+ export declare const TOOL_NAME = "summarizePDF";
6
+ export declare const TOOL_DEFINITION: ToolDefinition;
@@ -4,5 +4,5 @@
4
4
  * This module exports the core plugin logic without UI components.
5
5
  * Import from "@mulmochat-plugin/summarize-pdf" or "@mulmochat-plugin/summarize-pdf/core"
6
6
  */
7
- export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileInputHandler, ClipboardImageInputHandler, UrlInputHandler, TextInputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, PdfToolData, PdfArgs, PdfJsonData, } from "./types";
7
+ export type { PdfToolData, PdfArgs, PdfJsonData } from "./types";
8
8
  export { TOOL_NAME, TOOL_DEFINITION, createUploadedPdfResult, executeSummarizePdf, pluginCore, } from "./plugin";
@@ -4,9 +4,9 @@
4
4
  * Contains the plugin logic without UI components.
5
5
  * Can be used by any framework (Vue, React, etc.)
6
6
  */
7
- import type { ToolPluginCore, ToolContext, ToolResult, ToolDefinition, PdfToolData, PdfArgs, PdfJsonData } from "./types";
8
- export declare const TOOL_NAME = "summarizePDF";
9
- export declare const TOOL_DEFINITION: ToolDefinition;
7
+ import type { ToolPluginCore, ToolContext, ToolResult } from "gui-chat-protocol";
8
+ import type { PdfToolData, PdfArgs, PdfJsonData } from "./types";
9
+ export { TOOL_NAME, TOOL_DEFINITION } from "./definition";
10
10
  /**
11
11
  * Create a ToolResult for an uploaded PDF file
12
12
  */
@@ -1,227 +1,9 @@
1
1
  /**
2
- * MulmoChat Plugin Core Types (Framework-agnostic)
2
+ * SummarizePdf Plugin Types
3
3
  *
4
- * These types can be used by any framework implementation (Vue, React, etc.)
4
+ * Plugin-specific types only.
5
+ * Common types are imported from gui-chat-protocol.
5
6
  */
6
- /**
7
- * Backend types that plugins can declare they use.
8
- * App layer manages actual provider/model settings for each type.
9
- */
10
- export type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
11
- /**
12
- * App interface provided to plugins via context.app
13
- * Contains backend functions and config accessors
14
- */
15
- export interface ToolContextApp extends Record<string, (...args: any[]) => any> {
16
- getConfig: <T = unknown>(key: string) => T | undefined;
17
- setConfig: (key: string, value: unknown) => void;
18
- }
19
- /**
20
- * Context passed to plugin execute function
21
- */
22
- export interface ToolContext {
23
- currentResult?: ToolResult<unknown> | null;
24
- app?: ToolContextApp;
25
- }
26
- /**
27
- * Result returned from plugin execution
28
- */
29
- export interface ToolResult<T = unknown, J = unknown> {
30
- toolName?: string;
31
- uuid?: string;
32
- message: string;
33
- title?: string;
34
- jsonData?: J;
35
- instructions?: string;
36
- instructionsRequired?: boolean;
37
- updating?: boolean;
38
- cancelled?: boolean;
39
- data?: T;
40
- viewState?: Record<string, unknown>;
41
- }
42
- /**
43
- * Complete tool result with required fields
44
- */
45
- export interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
46
- toolName: string;
47
- uuid: string;
48
- }
49
- /**
50
- * JSON Schema property definition for tool parameters
51
- */
52
- export interface JsonSchemaProperty {
53
- type?: string;
54
- description?: string;
55
- enum?: string[];
56
- items?: JsonSchemaProperty;
57
- minimum?: number;
58
- maximum?: number;
59
- minItems?: number;
60
- maxItems?: number;
61
- properties?: Record<string, JsonSchemaProperty>;
62
- required?: string[];
63
- additionalProperties?: boolean;
64
- oneOf?: JsonSchemaProperty[];
65
- [key: string]: unknown;
66
- }
67
- /**
68
- * Tool definition for OpenAI-compatible function calling
69
- */
70
- export interface ToolDefinition {
71
- type: "function";
72
- name: string;
73
- description: string;
74
- parameters?: {
75
- type: "object";
76
- properties: Record<string, JsonSchemaProperty>;
77
- required: string[];
78
- additionalProperties?: boolean;
79
- };
80
- }
81
- /**
82
- * API response from server start endpoint
83
- */
84
- export interface StartApiResponse {
85
- hasOpenAIApiKey?: boolean;
86
- hasAnthropicApiKey?: boolean;
87
- hasGoogleApiKey?: boolean;
88
- [key: string]: unknown;
89
- }
90
- /**
91
- * Sample arguments for testing
92
- */
93
- export interface ToolSample {
94
- name: string;
95
- args: Record<string, unknown>;
96
- }
97
- /**
98
- * File input handler
99
- */
100
- export interface FileInputHandler {
101
- type: "file";
102
- acceptedTypes: string[];
103
- handleInput: (fileData: string, fileName: string) => ToolResult<unknown, unknown>;
104
- }
105
- /**
106
- * Clipboard image input handler
107
- */
108
- export interface ClipboardImageInputHandler {
109
- type: "clipboard-image";
110
- handleInput: (imageData: string) => ToolResult<unknown, unknown>;
111
- }
112
- /**
113
- * URL input handler
114
- */
115
- export interface UrlInputHandler {
116
- type: "url";
117
- patterns?: string[];
118
- handleInput: (url: string) => ToolResult<unknown, unknown>;
119
- }
120
- /**
121
- * Text input handler
122
- */
123
- export interface TextInputHandler {
124
- type: "text";
125
- patterns?: string[];
126
- handleInput: (text: string) => ToolResult<unknown, unknown>;
127
- }
128
- /**
129
- * Union of all input handler types
130
- */
131
- export type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler;
132
- /**
133
- * Legacy file upload config (for backward compatibility)
134
- * @deprecated Use InputHandler instead
135
- */
136
- export interface FileUploadConfig {
137
- acceptedTypes: string[];
138
- handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
139
- }
140
- export type ConfigValue = string | number | boolean | string[];
141
- interface BaseFieldSchema {
142
- label: string;
143
- description?: string;
144
- required?: boolean;
145
- }
146
- export interface StringFieldSchema extends BaseFieldSchema {
147
- type: "string";
148
- placeholder?: string;
149
- minLength?: number;
150
- maxLength?: number;
151
- pattern?: string;
152
- }
153
- export interface NumberFieldSchema extends BaseFieldSchema {
154
- type: "number";
155
- min?: number;
156
- max?: number;
157
- step?: number;
158
- }
159
- export interface BooleanFieldSchema extends BaseFieldSchema {
160
- type: "boolean";
161
- }
162
- export interface SelectOption {
163
- value: string;
164
- label: string;
165
- description?: string;
166
- disabled?: boolean;
167
- }
168
- export interface SelectFieldSchema extends BaseFieldSchema {
169
- type: "select";
170
- options: SelectOption[];
171
- }
172
- export interface MultiSelectFieldSchema extends BaseFieldSchema {
173
- type: "multiselect";
174
- options: SelectOption[];
175
- minItems?: number;
176
- maxItems?: number;
177
- }
178
- export type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
179
- /**
180
- * Plugin configuration schema (JSON Schema based)
181
- */
182
- export interface PluginConfigSchema {
183
- key: string;
184
- defaultValue: ConfigValue;
185
- schema: ConfigFieldSchema;
186
- }
187
- /**
188
- * Standard props for View components
189
- */
190
- export interface ViewComponentProps<T = unknown, J = unknown> {
191
- selectedResult: ToolResultComplete<T, J>;
192
- sendTextMessage: (text?: string) => void;
193
- onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
194
- pluginConfigs?: Record<string, unknown>;
195
- }
196
- /**
197
- * Standard props for Preview components
198
- */
199
- export interface PreviewComponentProps<T = unknown, J = unknown> {
200
- result: ToolResultComplete<T, J>;
201
- isSelected?: boolean;
202
- onSelect?: () => void;
203
- }
204
- /**
205
- * Core plugin interface - framework agnostic
206
- * Does not include UI components
207
- */
208
- export interface ToolPluginCore<T = unknown, J = unknown, A extends object = object> {
209
- toolDefinition: ToolDefinition;
210
- execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
211
- generatingMessage: string;
212
- waitingMessage?: string;
213
- uploadMessage?: string;
214
- isEnabled: (startResponse?: StartApiResponse | null) => boolean;
215
- delayAfterExecution?: number;
216
- systemPrompt?: string;
217
- inputHandlers?: InputHandler[];
218
- /** @deprecated Use inputHandlers instead */
219
- fileUpload?: FileUploadConfig;
220
- /** New JSON Schema based config (framework-agnostic) */
221
- configSchema?: PluginConfigSchema;
222
- samples?: ToolSample[];
223
- backends?: BackendType[];
224
- }
225
7
  /** PDF tool data stored in result.data */
226
8
  export interface PdfToolData {
227
9
  pdfData: string;
@@ -237,4 +19,3 @@ export interface PdfJsonData {
237
19
  fileName: string;
238
20
  summary: string;
239
21
  }
240
- export {};
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="summarizePDF",n={type:"function",name:i,description:"Summarize the content of a currently selected PDF file using Claude.",parameters:{type:"object",properties:{prompt:{type:"string",description:"Instructions for Claude on how to summarize or analyze the PDF"}},required:["prompt"]}};function o(e,a){return{toolName:i,data:{pdfData:e,fileName:a},message:"",title:a}}const u=async(e,a)=>{const{prompt:l}=a,r=e.currentResult?.data;if(!r?.pdfData)return{message:"No PDF file available to summarize. Please select a PDF file first.",instructions:"Tell the user that no PDF file is currently selected and they need to upload a PDF file first."};if(!e.app?.summarizePdf)return{message:"summarizePdf function not available",instructions:"Tell the user that the PDF summarization failed."};try{const t=(await e.app.summarizePdf({prompt:l,pdfData:r.pdfData})).summary||"";return{data:{...r,summary:t},jsonData:{fileName:r.fileName,summary:t},message:"PDF summarized successfully",instructions:"Give the user a brief summary of the PDF.",instructionsRequired:!0,updating:!0}}catch(s){console.error("PDF summarization failed",s);const t=s instanceof Error?s.message:"Unknown error";return{message:`PDF summarization failed: ${t}`,instructions:`Tell the user that the PDF summarization failed with error: ${t}`}}},m={toolDefinition:n,execute:u,generatingMessage:"Summarizing PDF...",uploadMessage:"PDF file is available. Call 'summarizePDF' to see its summary",isEnabled:e=>!!e?.hasAnthropicApiKey,fileUpload:{acceptedTypes:["application/pdf"],handleUpload:o}};exports.TOOL_DEFINITION=n;exports.TOOL_NAME=i;exports.createUploadedPdfResult=o;exports.executeSummarizePdf=u;exports.pluginCore=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="summarizePDF",n={type:"function",name:i,description:"Summarize the content of a currently selected PDF file using Claude.",parameters:{type:"object",properties:{prompt:{type:"string",description:"Instructions for Claude on how to summarize or analyze the PDF"}},required:["prompt"]}};function o(e,a){return{toolName:i,data:{pdfData:e,fileName:a},message:"",title:a}}const u=async(e,a)=>{const{prompt:l}=a,r=e.currentResult?.data;if(!r?.pdfData)return{message:"No PDF file available to summarize. Please select a PDF file first.",instructions:"Tell the user that no PDF file is currently selected and they need to upload a PDF file first."};if(!e.app?.summarizePdf)return{message:"summarizePdf function not available",instructions:"Tell the user that the PDF summarization failed."};try{const t=(await e.app.summarizePdf({prompt:l,pdfData:r.pdfData})).summary||"";return{data:{...r,summary:t},jsonData:{fileName:r.fileName,summary:t},message:"PDF summarized successfully",instructions:"Give the user a brief summary of the PDF.",instructionsRequired:!0,updating:!0}}catch(s){console.error("PDF summarization failed",s);const t=s instanceof Error?s.message:"Unknown error";return{message:`PDF summarization failed: ${t}`,instructions:`Tell the user that the PDF summarization failed with error: ${t}`}}},m={toolDefinition:n,execute:u,generatingMessage:"Summarizing PDF...",uploadMessage:"PDF file is available. Call 'summarizePDF' to see its summary",isEnabled:e=>!!e?.hasAnthropicApiKey,inputHandlers:[{type:"file",acceptedTypes:["application/pdf"],handleInput:o}]};exports.TOOL_DEFINITION=n;exports.TOOL_NAME=i;exports.createUploadedPdfResult=o;exports.executeSummarizePdf=u;exports.pluginCore=m;
package/dist/core.js CHANGED
@@ -66,10 +66,13 @@ const l = async (e, a) => {
66
66
  generatingMessage: "Summarizing PDF...",
67
67
  uploadMessage: "PDF file is available. Call 'summarizePDF' to see its summary",
68
68
  isEnabled: (e) => !!e?.hasAnthropicApiKey,
69
- fileUpload: {
70
- acceptedTypes: ["application/pdf"],
71
- handleUpload: u
72
- }
69
+ inputHandlers: [
70
+ {
71
+ type: "file",
72
+ acceptedTypes: ["application/pdf"],
73
+ handleInput: u
74
+ }
75
+ ]
73
76
  };
74
77
  export {
75
78
  o as TOOL_DEFINITION,
@@ -1,4 +1,5 @@
1
- import type { ToolResult, PdfToolData } from "./types";
1
+ import type { ToolResult } from "gui-chat-protocol";
2
+ import type { PdfToolData } from "../core/types";
2
3
  type __VLS_Props = {
3
4
  result: ToolResult<PdfToolData>;
4
5
  };
@@ -1,4 +1,5 @@
1
- import type { ToolResult, PdfToolData } from "./types";
1
+ import type { ToolResult } from "gui-chat-protocol";
2
+ import type { PdfToolData } from "../core/types";
2
3
  type __VLS_Props = {
3
4
  selectedResult: ToolResult<PdfToolData>;
4
5
  };
@@ -5,18 +5,18 @@
5
5
  * Import from "@mulmochat-plugin/summarize-pdf/vue"
6
6
  */
7
7
  import "../style.css";
8
- import type { ToolPlugin, PdfToolData, PdfArgs, PdfJsonData } from "./types";
8
+ import type { ToolPlugin } from "gui-chat-protocol/vue";
9
+ import type { PdfToolData, PdfArgs, PdfJsonData } from "../core/types";
9
10
  import View from "./View.vue";
10
11
  import Preview from "./Preview.vue";
11
12
  /**
12
13
  * SummarizePdf plugin instance with Vue components
13
14
  */
14
15
  export declare const plugin: ToolPlugin<PdfToolData, PdfJsonData, PdfArgs>;
15
- export type { ToolPlugin, ToolPluginConfig } from "./types";
16
- export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, PdfToolData, PdfArgs, PdfJsonData, } from "./types";
16
+ export type { PdfToolData, PdfArgs, PdfJsonData } from "../core/types";
17
17
  export { TOOL_NAME, TOOL_DEFINITION, createUploadedPdfResult, executeSummarizePdf, pluginCore, } from "../core/plugin";
18
18
  export { View, Preview };
19
19
  declare const _default: {
20
- plugin: ToolPlugin<PdfToolData, PdfJsonData, PdfArgs>;
20
+ plugin: ToolPlugin<PdfToolData, PdfJsonData, PdfArgs, import("gui-chat-protocol/vue").InputHandler, Record<string, unknown>>;
21
21
  };
22
22
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmochat-plugin/summarize-pdf",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "PDF summarization plugin for MulmoChat",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -36,15 +36,18 @@
36
36
  "peerDependencies": {
37
37
  "vue": "^3.5.0"
38
38
  },
39
+ "dependencies": {
40
+ "gui-chat-protocol": "^0.0.1"
41
+ },
39
42
  "devDependencies": {
40
- "marked": "^12.0.0",
41
43
  "@tailwindcss/vite": "^4.1.18",
42
44
  "@typescript-eslint/eslint-plugin": "^8.53.0",
43
45
  "@typescript-eslint/parser": "^8.53.0",
44
46
  "@vitejs/plugin-vue": "^6.0.3",
45
47
  "eslint": "^9.39.2",
46
- "eslint-plugin-vue": "^10.6.2",
48
+ "eslint-plugin-vue": "^10.7.0",
47
49
  "globals": "^17.0.0",
50
+ "marked": "^17.0.1",
48
51
  "tailwindcss": "^4.1.18",
49
52
  "typescript": "~5.9.3",
50
53
  "vite": "^7.3.1",
@@ -1,32 +0,0 @@
1
- /**
2
- * MulmoChat Plugin Vue Types
3
- *
4
- * Vue-specific types that extend the core plugin interface.
5
- */
6
- import type { Component } from "vue";
7
- import type { ToolPluginCore } from "../core/types";
8
- type VueComponent = Component<any>;
9
- /**
10
- * Legacy Vue component-based config
11
- * @deprecated Use PluginConfigSchema instead
12
- */
13
- export interface ToolPluginConfig {
14
- key: string;
15
- defaultValue: unknown;
16
- component: VueComponent;
17
- }
18
- /**
19
- * Vue plugin interface - extends core with Vue components
20
- */
21
- export interface ToolPlugin<T = unknown, J = unknown, A extends object = object> extends ToolPluginCore<T, J, A> {
22
- /** Vue component for full view */
23
- viewComponent?: VueComponent;
24
- /** Vue component for preview/thumbnail */
25
- previewComponent?: VueComponent;
26
- /**
27
- * Legacy Vue component-based config (for backward compatibility)
28
- * @deprecated Use configSchema instead
29
- */
30
- config?: ToolPluginConfig;
31
- }
32
- export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileInputHandler, ClipboardImageInputHandler, UrlInputHandler, TextInputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, PdfToolData, PdfArgs, PdfJsonData, } from "../core/types";