illuma-agents 1.0.47 → 1.0.49

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 (40) hide show
  1. package/dist/cjs/common/enum.cjs +0 -1
  2. package/dist/cjs/common/enum.cjs.map +1 -1
  3. package/dist/cjs/deepagents/DeepAgentBackend.cjs +170 -0
  4. package/dist/cjs/deepagents/DeepAgentBackend.cjs.map +1 -0
  5. package/dist/cjs/deepagents/DeepAgentRuntime.cjs +135 -0
  6. package/dist/cjs/deepagents/DeepAgentRuntime.cjs.map +1 -0
  7. package/dist/cjs/deepagents/types.cjs +29 -0
  8. package/dist/cjs/deepagents/types.cjs.map +1 -0
  9. package/dist/cjs/main.cjs +17 -3
  10. package/dist/cjs/main.cjs.map +1 -1
  11. package/dist/esm/common/enum.mjs +0 -1
  12. package/dist/esm/common/enum.mjs.map +1 -1
  13. package/dist/esm/deepagents/DeepAgentBackend.mjs +168 -0
  14. package/dist/esm/deepagents/DeepAgentBackend.mjs.map +1 -0
  15. package/dist/esm/deepagents/DeepAgentRuntime.mjs +132 -0
  16. package/dist/esm/deepagents/DeepAgentRuntime.mjs.map +1 -0
  17. package/dist/esm/deepagents/types.mjs +26 -0
  18. package/dist/esm/deepagents/types.mjs.map +1 -0
  19. package/dist/esm/main.mjs +4 -1
  20. package/dist/esm/main.mjs.map +1 -1
  21. package/dist/types/common/enum.d.ts +0 -1
  22. package/dist/types/deepagents/DeepAgentBackend.d.ts +82 -0
  23. package/dist/types/deepagents/DeepAgentRuntime.d.ts +46 -0
  24. package/dist/types/deepagents/index.d.ts +16 -0
  25. package/dist/types/deepagents/types.d.ts +105 -0
  26. package/dist/types/index.d.ts +1 -1
  27. package/package.json +2 -1
  28. package/src/common/enum.ts +0 -1
  29. package/src/deepagents/DeepAgentBackend.ts +214 -0
  30. package/src/deepagents/DeepAgentRuntime.ts +187 -0
  31. package/src/deepagents/index.ts +25 -0
  32. package/src/deepagents/types.ts +118 -0
  33. package/src/index.ts +3 -1
  34. package/src/specs/deepagents.test.ts +286 -0
  35. package/dist/cjs/tools/PresentationTool.cjs +0 -291
  36. package/dist/cjs/tools/PresentationTool.cjs.map +0 -1
  37. package/dist/esm/tools/PresentationTool.mjs +0 -288
  38. package/dist/esm/tools/PresentationTool.mjs.map +0 -1
  39. package/dist/types/tools/PresentationTool.d.ts +0 -2358
  40. package/src/tools/PresentationTool.ts +0 -356
@@ -1,356 +0,0 @@
1
- import { z } from 'zod';
2
- import { config } from 'dotenv';
3
- import fetch, { RequestInit } from 'node-fetch';
4
- import { HttpsProxyAgent } from 'https-proxy-agent';
5
- import { tool, DynamicStructuredTool } from '@langchain/core/tools';
6
- import { getEnvironmentVariable } from '@langchain/core/utils/env';
7
- import type * as t from '@/types';
8
- import { EnvVar, Constants } from '@/common';
9
- import { getCodeBaseURL } from './CodeExecutor';
10
-
11
- config();
12
-
13
- // =============================================================================
14
- // PRESENTATION TOOL CONSTANTS
15
- // =============================================================================
16
-
17
- const PRESENTATIONS_ENDPOINT = `${getCodeBaseURL()}/presentations/create`;
18
-
19
- // =============================================================================
20
- // SCHEMA DEFINITIONS
21
- // =============================================================================
22
-
23
- /**
24
- * Position and size model (matches code-executor PptxPositionModel)
25
- */
26
- const PositionSchema = z.object({
27
- left: z.number().describe('Left position in points'),
28
- top: z.number().describe('Top position in points'),
29
- width: z.number().describe('Width in points'),
30
- height: z.number().describe('Height in points'),
31
- });
32
-
33
- /**
34
- * Font styling model
35
- */
36
- const FontSchema = z.object({
37
- name: z.string().default('Arial').describe('Font family name'),
38
- size: z.number().default(16).describe('Font size in points'),
39
- italic: z.boolean().optional().describe('Italic text'),
40
- color: z.string().default('000000').describe('Hex color without #'),
41
- font_weight: z.number().optional().default(400).describe('400 = normal, 600+ = bold'),
42
- });
43
-
44
- /**
45
- * Fill/background color model
46
- */
47
- const FillSchema = z.object({
48
- color: z.string().describe('Hex color without #'),
49
- opacity: z.number().optional().default(1.0),
50
- });
51
-
52
- /**
53
- * Spacing/margin model
54
- */
55
- const SpacingSchema = z.object({
56
- top: z.number().default(0),
57
- bottom: z.number().default(0),
58
- left: z.number().default(0),
59
- right: z.number().default(0),
60
- });
61
-
62
- /**
63
- * Paragraph model
64
- */
65
- const ParagraphSchema = z.object({
66
- text: z.string().describe('Text content (can contain basic HTML like <b>, <i>)'),
67
- alignment: z.enum(['left', 'center', 'right', 'justify']).optional(),
68
- font: FontSchema.optional(),
69
- spacing: SpacingSchema.optional(),
70
- line_height: z.number().optional(),
71
- });
72
-
73
- /**
74
- * Picture source model
75
- */
76
- const PictureSchema = z.object({
77
- is_network: z.boolean().default(false).describe('True if path is a URL'),
78
- path: z.string().describe('Image file path or URL'),
79
- });
80
-
81
- /**
82
- * Object fit settings for images
83
- */
84
- const ObjectFitSchema = z.object({
85
- fit: z.enum(['contain', 'cover', 'fill']).optional(),
86
- focus: z.array(z.number()).optional().describe('Focus point [x%, y%]'),
87
- });
88
-
89
- /**
90
- * Text box shape
91
- */
92
- const TextBoxShapeSchema = z.object({
93
- shape_type: z.literal('textbox').default('textbox'),
94
- position: PositionSchema,
95
- paragraphs: z.array(ParagraphSchema).describe('Text paragraphs in the box'),
96
- margin: SpacingSchema.optional(),
97
- fill: FillSchema.optional(),
98
- text_wrap: z.boolean().optional().default(true),
99
- });
100
-
101
- /**
102
- * Auto shape (rectangle, rounded rectangle, etc.)
103
- */
104
- const AutoShapeSchema = z.object({
105
- shape_type: z.literal('autoshape').default('autoshape'),
106
- autoshape_type: z.string().default('RECTANGLE').describe('Shape type: RECTANGLE, ROUNDED_RECTANGLE, OVAL, etc.'),
107
- position: PositionSchema,
108
- paragraphs: z.array(ParagraphSchema).optional(),
109
- margin: SpacingSchema.optional(),
110
- fill: FillSchema.optional(),
111
- border_radius: z.number().optional(),
112
- });
113
-
114
- /**
115
- * Picture shape
116
- */
117
- const PictureShapeSchema = z.object({
118
- shape_type: z.literal('picture').default('picture'),
119
- position: PositionSchema,
120
- picture: PictureSchema,
121
- margin: SpacingSchema.optional(),
122
- clip: z.boolean().optional().default(true),
123
- opacity: z.number().optional(),
124
- shape: z.enum(['rectangle', 'circle']).optional(),
125
- object_fit: ObjectFitSchema.optional(),
126
- });
127
-
128
- /**
129
- * Connector/line shape
130
- */
131
- const ConnectorSchema = z.object({
132
- shape_type: z.literal('connector').default('connector'),
133
- connector_type: z.string().default('STRAIGHT').describe('STRAIGHT, ELBOW, CURVE'),
134
- position: PositionSchema,
135
- thickness: z.number().optional().default(0.5),
136
- color: z.string().optional().default('000000'),
137
- });
138
-
139
- /**
140
- * Union of all shape types
141
- */
142
- const ShapeSchema = z.discriminatedUnion('shape_type', [
143
- TextBoxShapeSchema,
144
- AutoShapeSchema,
145
- PictureShapeSchema,
146
- ConnectorSchema,
147
- ]);
148
-
149
- /**
150
- * Slide model
151
- */
152
- const SlideSchema = z.object({
153
- background: FillSchema.optional().describe('Slide background color'),
154
- note: z.string().optional().describe('Speaker notes for this slide'),
155
- shapes: z.array(ShapeSchema).describe('Shapes on this slide'),
156
- });
157
-
158
- /**
159
- * Brand settings for consistent theming
160
- */
161
- const BrandSettingsSchema = z.object({
162
- primary_color: z.string().default('000033').describe('Primary brand color'),
163
- secondary_color: z.string().default('666666').describe('Secondary color'),
164
- accent_color: z.string().default('0066CC').describe('Accent color'),
165
- background_color: z.string().default('FFFFFF').describe('Background color'),
166
- font_heading: z.string().default('Arial').describe('Heading font'),
167
- font_body: z.string().default('Arial').describe('Body font'),
168
- logo_url: z.string().optional().describe('Company logo URL'),
169
- company_name: z.string().optional().describe('Company name'),
170
- chart_colors: z.array(z.string()).optional().describe('Chart color palette'),
171
- });
172
-
173
- /**
174
- * Full presentation model
175
- */
176
- const PresentationSchema = z.object({
177
- name: z.string().optional().describe('Presentation name'),
178
- width: z.number().default(1280).describe('Slide width in points'),
179
- height: z.number().default(720).describe('Slide height in points'),
180
- slides: z.array(SlideSchema).describe('Array of slides'),
181
- shapes: z.array(ShapeSchema).optional().describe('Global shapes (on all slides)'),
182
- });
183
-
184
- /**
185
- * Main tool input schema
186
- */
187
- const CreatePresentationToolSchema = z.object({
188
- presentation: PresentationSchema.describe(
189
- 'The complete presentation structure with slides and shapes'
190
- ),
191
- brand: BrandSettingsSchema.optional().describe(
192
- 'Brand settings for consistent theming'
193
- ),
194
- });
195
-
196
- // =============================================================================
197
- // RESPONSE TYPES
198
- // =============================================================================
199
-
200
- interface CreatePresentationResult {
201
- success: boolean;
202
- file_id: string;
203
- filename: string;
204
- session_id: string;
205
- message?: string;
206
- }
207
-
208
- // =============================================================================
209
- // TOOL PARAMETERS
210
- // =============================================================================
211
-
212
- export interface PresentationToolParams {
213
- apiKey?: string;
214
- [EnvVar.CODE_API_KEY]?: string;
215
- user_id?: string;
216
- }
217
-
218
- // =============================================================================
219
- // TOOL CREATION
220
- // =============================================================================
221
-
222
- /**
223
- * Creates a presentation generation tool for LangChain agents.
224
- *
225
- * This tool allows agents to create PowerPoint presentations by providing
226
- * structured slide data. The presentation is generated by the code-executor
227
- * service and returned as a downloadable file.
228
- *
229
- * Architecture notes:
230
- * - Charts and complex visualizations should be rendered as images on the client
231
- * - The tool accepts image URLs/paths for chart/table screenshots
232
- * - Text boxes, shapes, and images are supported as native PPTX elements
233
- */
234
- function createPresentationTool(
235
- params: PresentationToolParams = {}
236
- ): DynamicStructuredTool<typeof CreatePresentationToolSchema> {
237
- const apiKey =
238
- params[EnvVar.CODE_API_KEY] ??
239
- params.apiKey ??
240
- getEnvironmentVariable(EnvVar.CODE_API_KEY) ??
241
- '';
242
-
243
- if (!apiKey) {
244
- throw new Error('No API key provided for presentation tool.');
245
- }
246
-
247
- const description = `
248
- Create a PowerPoint presentation from structured slide data.
249
-
250
- USE THIS TOOL WHEN:
251
- - User asks for a PowerPoint, PPTX, or presentation file
252
- - User wants to export content as a presentation
253
-
254
- SLIDE STRUCTURE:
255
- Each slide contains shapes: textbox, autoshape, picture, connector.
256
- - textbox: Text with paragraphs and formatting
257
- - autoshape: Colored shapes (rectangles, rounded rectangles) with optional text
258
- - picture: Images from URLs or file paths
259
- - connector: Lines and connectors
260
-
261
- STANDARD SLIDE DIMENSIONS:
262
- - Width: 1280 points (13.33 inches)
263
- - Height: 720 points (7.5 inches)
264
-
265
- LAYOUT TIPS:
266
- - Title: position ~{left: 80, top: 40, width: 1120, height: 80}
267
- - Content area: position ~{left: 80, top: 140, width: 1120, height: 520}
268
- - Leave margins of ~80 points on sides
269
-
270
- NOTES:
271
- - Charts/tables should be rendered as images and included via picture shapes
272
- - Use brand settings for consistent theming across slides
273
- - Generated file is auto-delivered to the user (no download links needed)
274
- `.trim();
275
-
276
- return tool<typeof CreatePresentationToolSchema>(
277
- async ({ presentation, brand }, config) => {
278
- const { session_id } = (config.toolCall ?? {}) as {
279
- session_id?: string;
280
- };
281
-
282
- const requestBody = {
283
- presentation,
284
- brand,
285
- session_id,
286
- };
287
-
288
- try {
289
- const fetchOptions: RequestInit = {
290
- method: 'POST',
291
- headers: {
292
- 'Content-Type': 'application/json',
293
- 'User-Agent': 'Ranger/1.0',
294
- 'X-API-Key': apiKey,
295
- },
296
- body: JSON.stringify(requestBody),
297
- };
298
-
299
- if (process.env.PROXY != null && process.env.PROXY !== '') {
300
- fetchOptions.agent = new HttpsProxyAgent(process.env.PROXY);
301
- }
302
-
303
- const response = await fetch(PRESENTATIONS_ENDPOINT, fetchOptions);
304
-
305
- if (!response.ok) {
306
- const errorText = await response.text();
307
- throw new Error(`Presentation creation failed: ${response.status} - ${errorText}`);
308
- }
309
-
310
- const result: CreatePresentationResult = await response.json();
311
-
312
- if (!result.success) {
313
- throw new Error(`Presentation creation failed: ${result.message}`);
314
- }
315
-
316
- const slideCount = presentation.slides.length;
317
- const formattedOutput = `
318
- Presentation created successfully!
319
- - Slides: ${slideCount}
320
- - File ID: ${result.file_id}
321
- - Filename: ${result.filename}
322
-
323
- The PowerPoint file is ready for download.
324
- `.trim();
325
-
326
- // Return content and artifact (like code executor)
327
- // The artifact contains file info for client-side handling
328
- return [
329
- formattedOutput,
330
- {
331
- session_id: result.session_id,
332
- file_id: result.file_id,
333
- filename: result.filename,
334
- type: 'presentation',
335
- files: [{
336
- id: result.file_id,
337
- name: result.filename,
338
- }],
339
- },
340
- ];
341
- } catch (error) {
342
- throw new Error(
343
- `Presentation creation error:\n\n${(error as Error | undefined)?.message}`
344
- );
345
- }
346
- },
347
- {
348
- name: Constants.CREATE_PRESENTATION,
349
- description,
350
- schema: CreatePresentationToolSchema,
351
- responseFormat: Constants.CONTENT_AND_ARTIFACT,
352
- }
353
- );
354
- }
355
-
356
- export { createPresentationTool, CreatePresentationToolSchema };