@morphllm/subagents 0.1.3 → 0.1.5
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/README.md +15 -25
- package/dist/base-client-B7fgl_Wg.d.mts +30 -0
- package/dist/base-client-C6pbtqLX.d.ts +30 -0
- package/dist/core/index.d.mts +4 -30
- package/dist/core/index.d.ts +4 -30
- package/dist/docx/index.d.mts +193 -11
- package/dist/docx/index.d.ts +193 -11
- package/dist/docx/index.js +156 -402
- package/dist/docx/index.js.map +1 -1
- package/dist/docx/index.mjs +156 -402
- package/dist/docx/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +164 -263
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -263
- package/dist/index.mjs.map +1 -1
- package/dist/pdf/index.d.mts +1 -1
- package/dist/pdf/index.d.ts +1 -1
- package/dist/pdf/index.js.map +1 -1
- package/dist/pdf/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/core/index.ts +1 -1
- package/src/docx/agent.ts +134 -274
- package/src/docx/client.ts +58 -1
- package/src/docx/index.ts +1 -1
- package/src/docx/types.ts +146 -2
- package/src/index.ts +3 -3
- package/src/pdf/index.ts +1 -1
package/dist/docx/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseClient
|
|
2
|
-
import { a as BaseClientOptions
|
|
1
|
+
import { B as BaseClient } from '../base-client-C6pbtqLX.js';
|
|
2
|
+
import { a as BaseClientOptions } from '../types-D9rS2MQq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Types for DOCX subagent
|
|
@@ -16,7 +16,61 @@ interface ReadResponse {
|
|
|
16
16
|
paragraphs: number;
|
|
17
17
|
}
|
|
18
18
|
/** Edit operation types */
|
|
19
|
-
type EditOperationType = 'add_comment' | 'reply_comment' | 'resolve_comment' | 'delete_comment' | 'insert_text' | 'insert_paragraph' | 'propose_deletion';
|
|
19
|
+
type EditOperationType = 'add_comment' | 'reply_comment' | 'resolve_comment' | 'delete_comment' | 'insert_text' | 'insert_paragraph' | 'propose_deletion' | 'reject_insertion' | 'restore_deletion' | 'enable_track_changes';
|
|
20
|
+
/** Build operation types (for document creation) */
|
|
21
|
+
type BuildOperationType = 'add_heading' | 'add_paragraph' | 'add_table' | 'add_image' | 'add_list_item' | 'add_hyperlink' | 'add_page_break' | 'add_section_break' | 'add_header' | 'add_footer' | 'add_page_numbers' | 'setup_styles';
|
|
22
|
+
/** Build operation payload */
|
|
23
|
+
interface BuildOperation {
|
|
24
|
+
type: BuildOperationType;
|
|
25
|
+
text?: string;
|
|
26
|
+
level?: number;
|
|
27
|
+
style?: string;
|
|
28
|
+
alignment?: 'left' | 'center' | 'right' | 'justify';
|
|
29
|
+
bold?: boolean;
|
|
30
|
+
italic?: boolean;
|
|
31
|
+
font_size?: number;
|
|
32
|
+
font_name?: string;
|
|
33
|
+
color?: string;
|
|
34
|
+
space_before?: number;
|
|
35
|
+
space_after?: number;
|
|
36
|
+
headers?: string[];
|
|
37
|
+
rows?: string[][];
|
|
38
|
+
header_bg_color?: string;
|
|
39
|
+
image_url?: string;
|
|
40
|
+
image_data?: string;
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
list_type?: 'bullet' | 'number';
|
|
44
|
+
url?: string;
|
|
45
|
+
position?: 'header' | 'footer';
|
|
46
|
+
format_string?: string;
|
|
47
|
+
section_index?: number;
|
|
48
|
+
base_font?: string;
|
|
49
|
+
base_size?: number;
|
|
50
|
+
heading_font?: string;
|
|
51
|
+
primary_color?: string;
|
|
52
|
+
break_type?: 'next_page' | 'continuous' | 'even_page' | 'odd_page';
|
|
53
|
+
}
|
|
54
|
+
/** Response from create operations */
|
|
55
|
+
interface CreateResponse {
|
|
56
|
+
doc_id: string;
|
|
57
|
+
message: string;
|
|
58
|
+
}
|
|
59
|
+
/** Response from build operations */
|
|
60
|
+
interface BuildResponse {
|
|
61
|
+
results: string[];
|
|
62
|
+
doc_id: string;
|
|
63
|
+
}
|
|
64
|
+
/** Document info response */
|
|
65
|
+
interface DocumentInfoResponse {
|
|
66
|
+
paragraphs: number;
|
|
67
|
+
tables: number;
|
|
68
|
+
sections: number;
|
|
69
|
+
title: string;
|
|
70
|
+
author: string;
|
|
71
|
+
created: string;
|
|
72
|
+
modified: string;
|
|
73
|
+
}
|
|
20
74
|
/** Edit operation payload */
|
|
21
75
|
interface EditOperation {
|
|
22
76
|
type: EditOperationType;
|
|
@@ -49,10 +103,76 @@ interface DocxClientOptions extends BaseClientOptions {
|
|
|
49
103
|
apiUrl?: string;
|
|
50
104
|
}
|
|
51
105
|
/** DOCX agent options */
|
|
52
|
-
interface DocxAgentOptions
|
|
106
|
+
interface DocxAgentOptions {
|
|
107
|
+
/** Base URL for the API. Defaults to api.subagents.com/v1 */
|
|
108
|
+
baseUrl?: string;
|
|
109
|
+
/** API key (optional, not required for public endpoints) */
|
|
110
|
+
apiKey?: string;
|
|
53
111
|
/** Current document ID */
|
|
54
112
|
documentId?: string;
|
|
55
113
|
}
|
|
114
|
+
/** Chat message */
|
|
115
|
+
interface Message {
|
|
116
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
117
|
+
content: string;
|
|
118
|
+
tool_call_id?: string;
|
|
119
|
+
tool_calls?: ToolCall[];
|
|
120
|
+
}
|
|
121
|
+
/** Tool call in a message */
|
|
122
|
+
interface ToolCall {
|
|
123
|
+
id: string;
|
|
124
|
+
type: 'function';
|
|
125
|
+
function: {
|
|
126
|
+
name: string;
|
|
127
|
+
arguments: string;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Chat completion response (non-streaming) */
|
|
131
|
+
interface ChatCompletionResponse {
|
|
132
|
+
id: string;
|
|
133
|
+
object: 'chat.completion';
|
|
134
|
+
created: number;
|
|
135
|
+
model: string;
|
|
136
|
+
choices: {
|
|
137
|
+
index: number;
|
|
138
|
+
message: {
|
|
139
|
+
role: 'assistant';
|
|
140
|
+
content: string | null;
|
|
141
|
+
tool_calls?: ToolCall[];
|
|
142
|
+
};
|
|
143
|
+
finish_reason: string;
|
|
144
|
+
}[];
|
|
145
|
+
usage?: {
|
|
146
|
+
prompt_tokens: number;
|
|
147
|
+
completion_tokens: number;
|
|
148
|
+
total_tokens: number;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Stream chunk */
|
|
152
|
+
interface StreamChunk {
|
|
153
|
+
id?: string;
|
|
154
|
+
object?: string;
|
|
155
|
+
created?: number;
|
|
156
|
+
model?: string;
|
|
157
|
+
choices?: {
|
|
158
|
+
index: number;
|
|
159
|
+
delta: {
|
|
160
|
+
role?: string;
|
|
161
|
+
content?: string;
|
|
162
|
+
tool_calls?: {
|
|
163
|
+
index: number;
|
|
164
|
+
id?: string;
|
|
165
|
+
type?: string;
|
|
166
|
+
function?: {
|
|
167
|
+
name?: string;
|
|
168
|
+
arguments?: string;
|
|
169
|
+
};
|
|
170
|
+
}[];
|
|
171
|
+
};
|
|
172
|
+
finish_reason?: string | null;
|
|
173
|
+
}[];
|
|
174
|
+
error?: string;
|
|
175
|
+
}
|
|
56
176
|
|
|
57
177
|
/**
|
|
58
178
|
* DocxClient - HTTP client for DOCX document API
|
|
@@ -85,26 +205,88 @@ declare class DocxClient extends BaseClient {
|
|
|
85
205
|
* Delete a document from storage.
|
|
86
206
|
*/
|
|
87
207
|
deleteDocument(docId: string): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Create a new empty DOCX document.
|
|
210
|
+
*/
|
|
211
|
+
create(title?: string): Promise<CreateResponse>;
|
|
212
|
+
/**
|
|
213
|
+
* Execute build operations on a document (add content).
|
|
214
|
+
*/
|
|
215
|
+
build(docId: string, operations: BuildOperation[]): Promise<BuildResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Get document information.
|
|
218
|
+
*/
|
|
219
|
+
getInfo(docId: string): Promise<DocumentInfoResponse>;
|
|
220
|
+
/**
|
|
221
|
+
* Add a heading to the document.
|
|
222
|
+
*/
|
|
223
|
+
addHeading(docId: string, text: string, level?: number): Promise<BuildResponse>;
|
|
224
|
+
/**
|
|
225
|
+
* Add a paragraph to the document.
|
|
226
|
+
*/
|
|
227
|
+
addParagraph(docId: string, text: string, options?: Partial<BuildOperation>): Promise<BuildResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* Add a table to the document.
|
|
230
|
+
*/
|
|
231
|
+
addTable(docId: string, headers: string[], rows: string[][]): Promise<BuildResponse>;
|
|
232
|
+
/**
|
|
233
|
+
* Add page numbers to the document.
|
|
234
|
+
*/
|
|
235
|
+
addPageNumbers(docId: string, format?: string): Promise<BuildResponse>;
|
|
88
236
|
}
|
|
89
237
|
|
|
90
238
|
/**
|
|
91
239
|
* DocxAgent - AI agent for DOCX document editing
|
|
92
240
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
241
|
+
* OpenAI Agents SDK compatible client for morph-docx.
|
|
242
|
+
* Talks to api.subagents.com/v1/chat/completions with model "morph-docx".
|
|
95
243
|
*/
|
|
96
244
|
|
|
97
|
-
declare class DocxAgent
|
|
245
|
+
declare class DocxAgent {
|
|
246
|
+
private baseUrl;
|
|
247
|
+
private apiKey;
|
|
98
248
|
private documentId?;
|
|
99
249
|
constructor(options?: DocxAgentOptions);
|
|
100
|
-
protected getDefaultModel(): string;
|
|
101
|
-
protected getDefaultInstructions(): string;
|
|
102
|
-
protected getTools(): Tool[];
|
|
103
250
|
/** Set the current document ID */
|
|
104
251
|
setDocument(docId: string): void;
|
|
105
252
|
/** Get current document ID */
|
|
106
253
|
getDocumentId(): string | undefined;
|
|
107
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Send a chat completion request (non-streaming).
|
|
256
|
+
* This runs the full agent loop on the server and returns the final response.
|
|
257
|
+
*/
|
|
258
|
+
chat(messages: Message[]): Promise<ChatCompletionResponse>;
|
|
259
|
+
/**
|
|
260
|
+
* Send a streaming chat completion request.
|
|
261
|
+
* Returns an async generator that yields chunks as they arrive.
|
|
262
|
+
*/
|
|
263
|
+
chatStream(messages: Message[]): AsyncGenerator<StreamChunk>;
|
|
264
|
+
/**
|
|
265
|
+
* Helper: Simple completion that returns just the content string.
|
|
266
|
+
*/
|
|
267
|
+
complete(userMessage: string): Promise<string>;
|
|
268
|
+
/**
|
|
269
|
+
* Create an OpenAI-compatible client configuration.
|
|
270
|
+
* Use this with the OpenAI SDK or OpenAI Agents SDK.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* import OpenAI from 'openai';
|
|
275
|
+
* import { DocxAgent } from 'subagents/docx';
|
|
276
|
+
*
|
|
277
|
+
* const agent = new DocxAgent();
|
|
278
|
+
* const openai = new OpenAI(agent.getOpenAIConfig());
|
|
279
|
+
*
|
|
280
|
+
* const response = await openai.chat.completions.create({
|
|
281
|
+
* model: 'morph-docx',
|
|
282
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
getOpenAIConfig(): {
|
|
287
|
+
baseURL: string;
|
|
288
|
+
apiKey: string;
|
|
289
|
+
};
|
|
108
290
|
}
|
|
109
291
|
|
|
110
292
|
export { type DocumentInfo, DocxAgent, type DocxAgentOptions, DocxClient, type DocxClientOptions, type EditOperation, type EditOperationType, type EditResponse, type ReadResponse, type ValidateResponse };
|