@mulmochat-plugin/summarize-pdf 0.1.2 → 0.2.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.
@@ -1,5 +1,4 @@
1
- import type { ToolResult } from "../common";
2
- import type { PdfToolData } from "./types";
1
+ import type { ToolResult, PdfToolData } from "./types";
3
2
  type __VLS_Props = {
4
3
  result: ToolResult<PdfToolData>;
5
4
  };
@@ -1,5 +1,4 @@
1
- import type { ToolResult } from "../common";
2
- import type { PdfToolData } from "./types";
1
+ import type { ToolResult, PdfToolData } from "./types";
3
2
  type __VLS_Props = {
4
3
  selectedResult: ToolResult<PdfToolData>;
5
4
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * MulmoChat SummarizePdf Plugin - Vue Implementation
3
+ *
4
+ * Full Vue plugin with UI components.
5
+ * Import from "@mulmochat-plugin/summarize-pdf/vue"
6
+ */
7
+ import "../style.css";
8
+ import type { ToolPlugin, PdfToolData, PdfArgs, PdfJsonData } from "./types";
9
+ import View from "./View.vue";
10
+ import Preview from "./Preview.vue";
11
+ /**
12
+ * SummarizePdf plugin instance with Vue components
13
+ */
14
+ 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";
17
+ export { TOOL_NAME, TOOL_DEFINITION, createUploadedPdfResult, executeSummarizePdf, pluginCore, } from "../core/plugin";
18
+ export { View, Preview };
19
+ declare const _default: {
20
+ plugin: ToolPlugin<PdfToolData, PdfJsonData, PdfArgs>;
21
+ };
22
+ export default _default;
@@ -0,0 +1,32 @@
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";
package/dist/vue.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./core.cjs"),e=require("vue"),_=require("marked"),g={class:"w-full h-full flex flex-col p-4"},x={class:"flex-1 w-full min-h-0"},y=["src"],N={key:0,class:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg flex-shrink-0"},h={class:"text-sm text-gray-700 dark:text-gray-300"},k={key:1,class:"mt-2 p-3 bg-white rounded-lg flex-shrink-0 max-h-64 overflow-y-auto border border-gray-200"},w=["innerHTML"],u=e.defineComponent({__name:"View",props:{selectedResult:{}},setup(d){const c=d,r=e.ref(null),l=e.ref("");e.watch(()=>c.selectedResult,t=>{t?.toolName===a.TOOL_NAME&&t.data&&(r.value=t.data,f(t))},{immediate:!0,deep:!0});const n=e.computed(()=>{const t=r.value?.summary;return t?_.marked(t):""});async function f(t){const o=t.data,i=t.uuid;if(o?.pdfData){if(!i){l.value=o.pdfData;return}try{const s=await fetch("/api/save-pdf",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pdfData:o.pdfData,uuid:i,fileName:o.fileName||"document.pdf"})});if(!s.ok)throw new Error("Failed to save PDF");const v=await s.json();l.value=v.pdfUrl}catch(s){console.error("Failed to save PDF to output folder:",s),l.value=o.pdfData}}}return(t,o)=>(e.openBlock(),e.createElementBlock("div",g,[e.createElementVNode("div",x,[l.value?(e.openBlock(),e.createElementBlock("iframe",{key:0,src:l.value,class:"w-full h-full border-0 rounded",title:"PDF Viewer"},null,8,y)):e.createCommentVNode("",!0)]),r.value?.fileName?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("p",h,[o[0]||(o[0]=e.createElementVNode("span",{class:"font-medium"},"File:",-1)),e.createTextVNode(" "+e.toDisplayString(r.value.fileName),1)])])):e.createCommentVNode("",!0),r.value?.summary?(e.openBlock(),e.createElementBlock("div",k,[o[1]||(o[1]=e.createElementVNode("p",{class:"text-sm font-medium text-gray-700 mb-2"},"Summary:",-1)),e.createElementVNode("div",{class:"markdown-content prose prose-sm prose-slate max-w-none",innerHTML:n.value},null,8,w)])):e.createCommentVNode("",!0)]))}}),E={class:"w-full h-32 bg-gray-200 dark:bg-gray-700 rounded flex items-center justify-center"},V={class:"text-center"},D={class:"text-xs mt-2 text-gray-600 dark:text-gray-300"},m=e.defineComponent({__name:"Preview",props:{result:{}},setup(d){const c=d,r=e.computed(()=>c.result.data);return(l,n)=>(e.openBlock(),e.createElementBlock("div",E,[e.createElementVNode("div",V,[n[0]||(n[0]=e.createElementVNode("svg",{class:"w-12 h-12 mx-auto text-red-500",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z","clip-rule":"evenodd"})],-1)),e.createElementVNode("p",D,e.toDisplayString(r.value?.fileName||"PDF"),1)])]))}}),p={...a.pluginCore,viewComponent:u,previewComponent:m},O={plugin:p};exports.TOOL_DEFINITION=a.TOOL_DEFINITION;exports.TOOL_NAME=a.TOOL_NAME;exports.createUploadedPdfResult=a.createUploadedPdfResult;exports.executeSummarizePdf=a.executeSummarizePdf;exports.pluginCore=a.pluginCore;exports.Preview=m;exports.View=u;exports.default=O;exports.plugin=p;
package/dist/vue.js ADDED
@@ -0,0 +1,121 @@
1
+ import { TOOL_NAME as g, pluginCore as h } from "./core.js";
2
+ import { TOOL_DEFINITION as z, createUploadedPdfResult as J, executeSummarizePdf as R } from "./core.js";
3
+ import { defineComponent as f, ref as p, watch as w, computed as v, createElementBlock as s, openBlock as l, createElementVNode as r, createCommentVNode as c, createTextVNode as k, toDisplayString as x } from "vue";
4
+ import { marked as D } from "marked";
5
+ const N = { class: "w-full h-full flex flex-col p-4" }, b = { class: "flex-1 w-full min-h-0" }, P = ["src"], F = {
6
+ key: 0,
7
+ class: "mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg flex-shrink-0"
8
+ }, T = { class: "text-sm text-gray-700 dark:text-gray-300" }, V = {
9
+ key: 1,
10
+ class: "mt-2 p-3 bg-white rounded-lg flex-shrink-0 max-h-64 overflow-y-auto border border-gray-200"
11
+ }, C = ["innerHTML"], O = /* @__PURE__ */ f({
12
+ __name: "View",
13
+ props: {
14
+ selectedResult: {}
15
+ },
16
+ setup(i) {
17
+ const u = i, a = p(null), o = p("");
18
+ w(
19
+ () => u.selectedResult,
20
+ (e) => {
21
+ e?.toolName === g && e.data && (a.value = e.data, _(e));
22
+ },
23
+ { immediate: !0, deep: !0 }
24
+ );
25
+ const n = v(() => {
26
+ const e = a.value?.summary;
27
+ return e ? D(e) : "";
28
+ });
29
+ async function _(e) {
30
+ const t = e.data, m = e.uuid;
31
+ if (t?.pdfData) {
32
+ if (!m) {
33
+ o.value = t.pdfData;
34
+ return;
35
+ }
36
+ try {
37
+ const d = await fetch("/api/save-pdf", {
38
+ method: "POST",
39
+ headers: {
40
+ "Content-Type": "application/json"
41
+ },
42
+ body: JSON.stringify({
43
+ pdfData: t.pdfData,
44
+ uuid: m,
45
+ fileName: t.fileName || "document.pdf"
46
+ })
47
+ });
48
+ if (!d.ok)
49
+ throw new Error("Failed to save PDF");
50
+ const y = await d.json();
51
+ o.value = y.pdfUrl;
52
+ } catch (d) {
53
+ console.error("Failed to save PDF to output folder:", d), o.value = t.pdfData;
54
+ }
55
+ }
56
+ }
57
+ return (e, t) => (l(), s("div", N, [
58
+ r("div", b, [
59
+ o.value ? (l(), s("iframe", {
60
+ key: 0,
61
+ src: o.value,
62
+ class: "w-full h-full border-0 rounded",
63
+ title: "PDF Viewer"
64
+ }, null, 8, P)) : c("", !0)
65
+ ]),
66
+ a.value?.fileName ? (l(), s("div", F, [
67
+ r("p", T, [
68
+ t[0] || (t[0] = r("span", { class: "font-medium" }, "File:", -1)),
69
+ k(" " + x(a.value.fileName), 1)
70
+ ])
71
+ ])) : c("", !0),
72
+ a.value?.summary ? (l(), s("div", V, [
73
+ t[1] || (t[1] = r("p", { class: "text-sm font-medium text-gray-700 mb-2" }, "Summary:", -1)),
74
+ r("div", {
75
+ class: "markdown-content prose prose-sm prose-slate max-w-none",
76
+ innerHTML: n.value
77
+ }, null, 8, C)
78
+ ])) : c("", !0)
79
+ ]));
80
+ }
81
+ }), S = { class: "w-full h-32 bg-gray-200 dark:bg-gray-700 rounded flex items-center justify-center" }, E = { class: "text-center" }, L = { class: "text-xs mt-2 text-gray-600 dark:text-gray-300" }, M = /* @__PURE__ */ f({
82
+ __name: "Preview",
83
+ props: {
84
+ result: {}
85
+ },
86
+ setup(i) {
87
+ const u = i, a = v(() => u.result.data);
88
+ return (o, n) => (l(), s("div", S, [
89
+ r("div", E, [
90
+ n[0] || (n[0] = r("svg", {
91
+ class: "w-12 h-12 mx-auto text-red-500",
92
+ fill: "currentColor",
93
+ viewBox: "0 0 20 20",
94
+ xmlns: "http://www.w3.org/2000/svg"
95
+ }, [
96
+ r("path", {
97
+ "fill-rule": "evenodd",
98
+ d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",
99
+ "clip-rule": "evenodd"
100
+ })
101
+ ], -1)),
102
+ r("p", L, x(a.value?.fileName || "PDF"), 1)
103
+ ])
104
+ ]));
105
+ }
106
+ }), $ = {
107
+ ...h,
108
+ viewComponent: O,
109
+ previewComponent: M
110
+ }, H = { plugin: $ };
111
+ export {
112
+ M as Preview,
113
+ z as TOOL_DEFINITION,
114
+ g as TOOL_NAME,
115
+ O as View,
116
+ J as createUploadedPdfResult,
117
+ H as default,
118
+ R as executeSummarizePdf,
119
+ $ as plugin,
120
+ h as pluginCore
121
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmochat-plugin/summarize-pdf",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "PDF summarization plugin for MulmoChat",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -12,6 +12,16 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./core": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "import": "./dist/core.js",
18
+ "require": "./dist/core.cjs"
19
+ },
20
+ "./vue": {
21
+ "types": "./dist/vue/index.d.ts",
22
+ "import": "./dist/vue.js",
23
+ "require": "./dist/vue.cjs"
24
+ },
15
25
  "./style.css": "./dist/style.css"
16
26
  },
17
27
  "files": [
@@ -1,6 +0,0 @@
1
- /**
2
- * MulmoChat Plugin Common
3
- *
4
- * Shared types and utilities for building MulmoChat plugins.
5
- */
6
- export type { ToolContext, ToolContextApp, ToolResult, ToolPlugin, ToolDefinition, JsonSchemaProperty, StartApiResponse, FileUploadConfig, ToolPluginConfig, ToolSample, } from "./types";
@@ -1,142 +0,0 @@
1
- /**
2
- * MulmoChat Plugin Common Types
3
- *
4
- * Core interfaces for building MulmoChat plugins.
5
- * These types are plugin-agnostic and can be used by any plugin implementation.
6
- */
7
- import type { Component } from "vue";
8
- /**
9
- * Backend types that plugins can declare they use.
10
- * App layer manages actual provider/model settings for each type.
11
- */
12
- export type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
13
- /**
14
- * App interface provided to plugins via context.app
15
- * Contains backend functions and config accessors
16
- */
17
- export interface ToolContextApp extends Record<string, (...args: any[]) => any> {
18
- getConfig: <T = unknown>(key: string) => T | undefined;
19
- setConfig: (key: string, value: unknown) => void;
20
- }
21
- /**
22
- * Context passed to plugin execute function
23
- */
24
- export interface ToolContext {
25
- currentResult?: ToolResult<unknown> | null;
26
- app?: ToolContextApp;
27
- }
28
- /**
29
- * Result returned from plugin execution
30
- */
31
- export interface ToolResult<T = unknown, J = unknown> {
32
- toolName?: string;
33
- uuid?: string;
34
- message: string;
35
- title?: string;
36
- jsonData?: J;
37
- instructions?: string;
38
- instructionsRequired?: boolean;
39
- updating?: boolean;
40
- cancelled?: boolean;
41
- data?: T;
42
- viewState?: Record<string, unknown>;
43
- }
44
- /**
45
- * JSON Schema property definition for tool parameters
46
- */
47
- export interface JsonSchemaProperty {
48
- type?: string;
49
- description?: string;
50
- enum?: string[];
51
- items?: JsonSchemaProperty;
52
- minimum?: number;
53
- maximum?: number;
54
- minItems?: number;
55
- maxItems?: number;
56
- properties?: Record<string, JsonSchemaProperty>;
57
- required?: string[];
58
- additionalProperties?: boolean;
59
- oneOf?: JsonSchemaProperty[];
60
- [key: string]: unknown;
61
- }
62
- /**
63
- * API response from server start endpoint
64
- */
65
- export interface StartApiResponse {
66
- hasOpenAIApiKey?: boolean;
67
- hasAnthropicApiKey?: boolean;
68
- hasGoogleApiKey?: boolean;
69
- [key: string]: unknown;
70
- }
71
- /**
72
- * Tool definition for OpenAI-compatible function calling
73
- */
74
- export interface ToolDefinition {
75
- type: "function";
76
- name: string;
77
- description: string;
78
- parameters?: {
79
- type: "object";
80
- properties: Record<string, JsonSchemaProperty>;
81
- required: string[];
82
- additionalProperties?: boolean;
83
- };
84
- }
85
- /**
86
- * File upload configuration
87
- */
88
- export interface FileUploadConfig {
89
- acceptedTypes: string[];
90
- handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
91
- }
92
- /**
93
- * Plugin configuration
94
- */
95
- export interface ToolPluginConfig {
96
- key: string;
97
- defaultValue: unknown;
98
- component: Component;
99
- }
100
- /**
101
- * Sample arguments for testing
102
- */
103
- export interface ToolSample {
104
- name: string;
105
- args: Record<string, unknown>;
106
- }
107
- /**
108
- * Main plugin interface
109
- * @template T - Type of data stored in result.data
110
- * @template J - Type of data stored in result.jsonData
111
- * @template A - Type of arguments passed to execute
112
- */
113
- export interface ToolPlugin<T = unknown, J = unknown, A extends object = object> {
114
- /** Tool definition for LLM function calling */
115
- toolDefinition: ToolDefinition;
116
- /** Execute the plugin with given context and arguments */
117
- execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
118
- /** Message shown while generating */
119
- generatingMessage: string;
120
- /** Message shown while waiting for user action */
121
- waitingMessage?: string;
122
- /** Message shown during file upload */
123
- uploadMessage?: string;
124
- /** Check if plugin is enabled based on server capabilities */
125
- isEnabled: (startResponse?: StartApiResponse | null) => boolean;
126
- /** Delay in ms after execution before proceeding */
127
- delayAfterExecution?: number;
128
- /** Vue component for full view */
129
- viewComponent?: Component;
130
- /** Vue component for preview/thumbnail */
131
- previewComponent?: Component;
132
- /** System prompt additions for this plugin */
133
- systemPrompt?: string;
134
- /** Optional file upload configuration */
135
- fileUpload?: FileUploadConfig;
136
- /** Optional plugin-specific configuration */
137
- config?: ToolPluginConfig;
138
- /** Optional sample arguments for testing */
139
- samples?: ToolSample[];
140
- /** Backend types this plugin uses (e.g., ["textLLM", "imageGen"]) */
141
- backends?: BackendType[];
142
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * MulmoChat SummarizePdf Plugin
3
- *
4
- * A plugin for summarizing PDF files using Claude.
5
- *
6
- * @example Basic usage
7
- * ```typescript
8
- * import { plugin } from "@mulmochat-plugin/summarize-pdf";
9
- * import "@mulmochat-plugin/summarize-pdf/style.css";
10
- * // Use plugin directly
11
- * ```
12
- */
13
- import type { ToolPlugin, ToolResult } from "../common";
14
- import type { PdfToolData, PdfArgs, PdfJsonData } from "./types";
15
- /**
16
- * Create a ToolResult for an uploaded PDF file
17
- */
18
- export declare function createUploadedPdfResult(pdfData: string, fileName: string): ToolResult<PdfToolData, PdfJsonData>;
19
- /**
20
- * SummarizePdf plugin instance
21
- */
22
- export declare const plugin: ToolPlugin<PdfToolData, PdfJsonData, PdfArgs>;
@@ -1,19 +0,0 @@
1
- /**
2
- * SummarizePdf Tool Definition
3
- */
4
- export declare const TOOL_NAME = "summarizePDF";
5
- export declare const TOOL_DEFINITION: {
6
- type: "function";
7
- name: string;
8
- description: string;
9
- parameters: {
10
- type: "object";
11
- properties: {
12
- prompt: {
13
- type: string;
14
- description: string;
15
- };
16
- };
17
- required: string[];
18
- };
19
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * SummarizePdf Types
3
- */
4
- /** PDF tool data stored in result.data */
5
- export interface PdfToolData {
6
- pdfData: string;
7
- fileName: string;
8
- summary?: string;
9
- }
10
- /** Arguments passed to the summarizePDF tool */
11
- export interface PdfArgs {
12
- prompt: string;
13
- }
14
- /** JSON data returned in result.jsonData */
15
- export interface PdfJsonData {
16
- fileName: string;
17
- summary: string;
18
- }