@lakitu/sdk 0.1.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.
- package/README.md +166 -0
- package/convex/_generated/api.d.ts +45 -0
- package/convex/_generated/api.js +23 -0
- package/convex/_generated/dataModel.d.ts +58 -0
- package/convex/_generated/server.d.ts +143 -0
- package/convex/_generated/server.js +93 -0
- package/convex/cloud/CLAUDE.md +238 -0
- package/convex/cloud/_generated/api.ts +84 -0
- package/convex/cloud/_generated/component.ts +861 -0
- package/convex/cloud/_generated/dataModel.ts +60 -0
- package/convex/cloud/_generated/server.ts +156 -0
- package/convex/cloud/convex.config.ts +16 -0
- package/convex/cloud/index.ts +29 -0
- package/convex/cloud/intentSchema/generate.ts +447 -0
- package/convex/cloud/intentSchema/index.ts +16 -0
- package/convex/cloud/intentSchema/types.ts +418 -0
- package/convex/cloud/ksaPolicy.ts +554 -0
- package/convex/cloud/mail.ts +92 -0
- package/convex/cloud/schema.ts +322 -0
- package/convex/cloud/utils/kanbanContext.ts +229 -0
- package/convex/cloud/workflows/agentBoard.ts +451 -0
- package/convex/cloud/workflows/agentPrompt.ts +272 -0
- package/convex/cloud/workflows/agentThread.ts +374 -0
- package/convex/cloud/workflows/compileSandbox.ts +146 -0
- package/convex/cloud/workflows/crudBoard.ts +217 -0
- package/convex/cloud/workflows/crudKSAs.ts +262 -0
- package/convex/cloud/workflows/crudLorobeads.ts +371 -0
- package/convex/cloud/workflows/crudSkills.ts +205 -0
- package/convex/cloud/workflows/crudThreads.ts +708 -0
- package/convex/cloud/workflows/lifecycleSandbox.ts +1396 -0
- package/convex/cloud/workflows/sandboxConvex.ts +1046 -0
- package/convex/sandbox/README.md +90 -0
- package/convex/sandbox/_generated/api.d.ts +2934 -0
- package/convex/sandbox/_generated/api.js +23 -0
- package/convex/sandbox/_generated/dataModel.d.ts +60 -0
- package/convex/sandbox/_generated/server.d.ts +143 -0
- package/convex/sandbox/_generated/server.js +93 -0
- package/convex/sandbox/actions/bash.ts +130 -0
- package/convex/sandbox/actions/browser.ts +282 -0
- package/convex/sandbox/actions/file.ts +336 -0
- package/convex/sandbox/actions/lsp.ts +325 -0
- package/convex/sandbox/actions/pdf.ts +119 -0
- package/convex/sandbox/agent/codeExecLoop.ts +535 -0
- package/convex/sandbox/agent/decisions.ts +284 -0
- package/convex/sandbox/agent/index.ts +515 -0
- package/convex/sandbox/agent/subagents.ts +651 -0
- package/convex/sandbox/brandResearch/index.ts +417 -0
- package/convex/sandbox/context/index.ts +7 -0
- package/convex/sandbox/context/session.ts +402 -0
- package/convex/sandbox/convex.config.ts +17 -0
- package/convex/sandbox/index.ts +51 -0
- package/convex/sandbox/nodeActions/codeExec.ts +130 -0
- package/convex/sandbox/planning/beads.ts +187 -0
- package/convex/sandbox/planning/index.ts +8 -0
- package/convex/sandbox/planning/sync.ts +194 -0
- package/convex/sandbox/prompts/codeExec.ts +852 -0
- package/convex/sandbox/prompts/modes.ts +231 -0
- package/convex/sandbox/prompts/system.ts +142 -0
- package/convex/sandbox/schema.ts +510 -0
- package/convex/sandbox/state/artifacts.ts +99 -0
- package/convex/sandbox/state/checkpoints.ts +341 -0
- package/convex/sandbox/state/files.ts +383 -0
- package/convex/sandbox/state/index.ts +10 -0
- package/convex/sandbox/state/verification.actions.ts +268 -0
- package/convex/sandbox/state/verification.ts +101 -0
- package/convex/sandbox/tsconfig.json +25 -0
- package/convex/sandbox/utils/codeExecHelpers.ts +52 -0
- package/dist/cli/commands/build.d.ts +19 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +223 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +148 -0
- package/dist/cli/commands/publish.d.ts +12 -0
- package/dist/cli/commands/publish.d.ts.map +1 -0
- package/dist/cli/commands/publish.js +33 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +40 -0
- package/dist/sdk/builders.d.ts +104 -0
- package/dist/sdk/builders.d.ts.map +1 -0
- package/dist/sdk/builders.js +214 -0
- package/dist/sdk/index.d.ts +29 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +38 -0
- package/dist/sdk/types.d.ts +107 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +6 -0
- package/ksa/README.md +263 -0
- package/ksa/_generated/REFERENCE.md +2954 -0
- package/ksa/_generated/registry.ts +257 -0
- package/ksa/_shared/configReader.ts +302 -0
- package/ksa/_shared/configSchemas.ts +649 -0
- package/ksa/_shared/gateway.ts +175 -0
- package/ksa/_shared/ksaBehaviors.ts +411 -0
- package/ksa/_shared/ksaProxy.ts +248 -0
- package/ksa/_shared/localDb.ts +302 -0
- package/ksa/index.ts +134 -0
- package/package.json +93 -0
- package/runtime/browser/agent-browser.ts +330 -0
- package/runtime/entrypoint.ts +194 -0
- package/runtime/lsp/manager.ts +366 -0
- package/runtime/pdf/pdf-generator.ts +50 -0
- package/runtime/pdf/renderer.ts +357 -0
- package/runtime/pdf/schema.ts +97 -0
- package/runtime/services/file-watcher.ts +191 -0
- package/template/build.ts +307 -0
- package/template/e2b/Dockerfile +69 -0
- package/template/e2b/e2b.toml +13 -0
- package/template/e2b/prebuild.sh +68 -0
- package/template/e2b/start.sh +14 -0
|
@@ -0,0 +1,2954 @@
|
|
|
1
|
+
# KSA Reference Documentation
|
|
2
|
+
|
|
3
|
+
> Auto-generated from KSA source files.
|
|
4
|
+
> Generated at: 2026-01-17T17:36:27.663Z
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Core KSAs (Always Available)
|
|
8
|
+
|
|
9
|
+
### beads
|
|
10
|
+
|
|
11
|
+
Beads KSA - Knowledge, Skills, and Abilities Task planning and tracking for agent workflows. Use beads to break down work into trackable tasks, track progress, and coordinate retries. OPTIMIZATION: update() and close() use fire-and-forget by default to reduce latency. Set { blocking: true } for synchronous behavior.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { create, update, close, list, getReady, get } from './ksa/beads';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### `create()`
|
|
18
|
+
|
|
19
|
+
Create a new task for tracking work.
|
|
20
|
+
|
|
21
|
+
**Parameters:**
|
|
22
|
+
|
|
23
|
+
- `options`: `CreateOptions` - Task creation options
|
|
24
|
+
|
|
25
|
+
**Returns:** `Promise<CreateResult>`
|
|
26
|
+
|
|
27
|
+
**Example:**
|
|
28
|
+
```typescript
|
|
29
|
+
const task = await create({
|
|
30
|
+
title: 'Research market trends',
|
|
31
|
+
type: 'task',
|
|
32
|
+
priority: 1,
|
|
33
|
+
});
|
|
34
|
+
console.log(`Created task: ${task.id}`);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
#### `update()`
|
|
40
|
+
|
|
41
|
+
Update an existing task. Uses fire-and-forget by default for speed. Set blocking: true to wait.
|
|
42
|
+
|
|
43
|
+
**Parameters:**
|
|
44
|
+
|
|
45
|
+
- `id`: `string` - Task ID
|
|
46
|
+
|
|
47
|
+
- `options`: `UpdateOptions` - Fields to update
|
|
48
|
+
|
|
49
|
+
**Returns:** `Promise<void>`
|
|
50
|
+
|
|
51
|
+
**Example:**
|
|
52
|
+
```typescript
|
|
53
|
+
// Non-blocking (default) - faster
|
|
54
|
+
update('task-1', { status: 'in_progress' });
|
|
55
|
+
|
|
56
|
+
// Blocking - wait for confirmation
|
|
57
|
+
await update('task-1', { status: 'in_progress', blocking: true });
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
#### `close()`
|
|
63
|
+
|
|
64
|
+
Close a task as completed. Uses fire-and-forget by default for speed.
|
|
65
|
+
|
|
66
|
+
**Parameters:**
|
|
67
|
+
|
|
68
|
+
- `id`: `string` - Task ID
|
|
69
|
+
|
|
70
|
+
- `reason`: `string` (optional) - Optional completion reason
|
|
71
|
+
|
|
72
|
+
- `options`: `CloseOptions` (optional) - Optional settings (blocking: true to wait)
|
|
73
|
+
|
|
74
|
+
**Returns:** `Promise<void>`
|
|
75
|
+
|
|
76
|
+
**Example:**
|
|
77
|
+
```typescript
|
|
78
|
+
// Non-blocking (default) - faster
|
|
79
|
+
close('task-1', 'Successfully generated report');
|
|
80
|
+
|
|
81
|
+
// Blocking - wait for confirmation
|
|
82
|
+
await close('task-1', 'Done', { blocking: true });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#### `list()`
|
|
88
|
+
|
|
89
|
+
List tasks with optional filters.
|
|
90
|
+
|
|
91
|
+
**Parameters:**
|
|
92
|
+
|
|
93
|
+
- `options`: `{
|
|
94
|
+
status?: IssueStatus;
|
|
95
|
+
type?: IssueType;
|
|
96
|
+
}` (optional) - Filter options
|
|
97
|
+
|
|
98
|
+
**Returns:** `Promise<Issue[]>`
|
|
99
|
+
|
|
100
|
+
**Example:**
|
|
101
|
+
```typescript
|
|
102
|
+
const openTasks = await list({ status: 'open' });
|
|
103
|
+
console.log(`${openTasks.length} tasks remaining`);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
#### `getReady()`
|
|
109
|
+
|
|
110
|
+
Get tasks ready to work on (open and unblocked).
|
|
111
|
+
|
|
112
|
+
**Returns:** `Promise<Issue[]>`
|
|
113
|
+
|
|
114
|
+
**Example:**
|
|
115
|
+
```typescript
|
|
116
|
+
const ready = await getReady();
|
|
117
|
+
if (ready.length > 0) {
|
|
118
|
+
console.log(`Next task: ${ready[0].title}`);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
#### `get()`
|
|
125
|
+
|
|
126
|
+
Get a single task by ID.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
|
|
130
|
+
- `id`: `string` - Task ID
|
|
131
|
+
|
|
132
|
+
**Returns:** `Promise<Issue | null>`
|
|
133
|
+
|
|
134
|
+
**Example:**
|
|
135
|
+
```typescript
|
|
136
|
+
const task = await get('task-1');
|
|
137
|
+
if (task) {
|
|
138
|
+
console.log(`Task status: ${task.status}`);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### artifacts
|
|
145
|
+
|
|
146
|
+
Artifacts KSA - Knowledge, Skills, and Abilities Save and retrieve artifacts that persist across sandbox sessions. Use this to create outputs that will be available after the agent finishes. CATEGORY: core
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { setGatewayConfig, saveArtifact, readArtifact, listArtifacts } from './ksa/artifacts';
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### `setGatewayConfig()`
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
**Parameters:**
|
|
157
|
+
|
|
158
|
+
- `config`: `{
|
|
159
|
+
convexUrl: string;
|
|
160
|
+
jwt: string;
|
|
161
|
+
cardId?: string;
|
|
162
|
+
}` -
|
|
163
|
+
|
|
164
|
+
**Returns:** `void`
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
#### `saveArtifact()`
|
|
169
|
+
|
|
170
|
+
Save an artifact to the cloud. Use this for markdown, JSON, CSV, or text files. For PDFs, use the `pdf.generate()` function instead. For emails, use the `email.send()` function instead.
|
|
171
|
+
|
|
172
|
+
**Parameters:**
|
|
173
|
+
|
|
174
|
+
- `params`: `SaveArtifactParams` - Name, type, content, and optional metadata
|
|
175
|
+
|
|
176
|
+
**Returns:** `Promise<SaveResult>`
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
```typescript
|
|
180
|
+
// Save a markdown report
|
|
181
|
+
const result = await saveArtifact({
|
|
182
|
+
name: 'competitive-analysis.md',
|
|
183
|
+
type: 'markdown',
|
|
184
|
+
content: '# Competitive Analysis\n\n## Overview\n...',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (result.success) {
|
|
188
|
+
console.log(`Saved: ${result.name} (${result.id})`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Save JSON data
|
|
192
|
+
await saveArtifact({
|
|
193
|
+
name: 'research-data.json',
|
|
194
|
+
type: 'json',
|
|
195
|
+
content: JSON.stringify(data, null, 2),
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
#### `readArtifact()`
|
|
202
|
+
|
|
203
|
+
Read an artifact by its ID. Use this to access documents created in earlier stages.
|
|
204
|
+
|
|
205
|
+
**Parameters:**
|
|
206
|
+
|
|
207
|
+
- `artifactId`: `string` - ID of the artifact (from context artifacts list)
|
|
208
|
+
|
|
209
|
+
**Returns:** `Promise<ReadResult>`
|
|
210
|
+
|
|
211
|
+
**Example:**
|
|
212
|
+
```typescript
|
|
213
|
+
const report = await readArtifact('abc123');
|
|
214
|
+
if (report.success) {
|
|
215
|
+
console.log(report.content);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
#### `listArtifacts()`
|
|
222
|
+
|
|
223
|
+
List all artifacts for the current context (thread or card). For threads: Shows artifacts saved in this chat thread. For cards: Shows artifacts from all stages.
|
|
224
|
+
|
|
225
|
+
**Returns:** `Promise<ListResult>`
|
|
226
|
+
|
|
227
|
+
**Example:**
|
|
228
|
+
```typescript
|
|
229
|
+
const { artifacts } = await listArtifacts();
|
|
230
|
+
for (const art of artifacts) {
|
|
231
|
+
console.log(`${art.name} (${art.type})`);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
### file
|
|
238
|
+
|
|
239
|
+
File Skills Functions for reading, writing, and searching files. These operate on the local filesystem in the sandbox.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { read, write, edit, glob, grep, ls } from './ksa/file';
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### `read()`
|
|
246
|
+
|
|
247
|
+
Read a file's contents.
|
|
248
|
+
|
|
249
|
+
**Parameters:**
|
|
250
|
+
|
|
251
|
+
- `filePath`: `string` - Path to the file
|
|
252
|
+
|
|
253
|
+
**Returns:** `Promise<string>`
|
|
254
|
+
|
|
255
|
+
**Example:**
|
|
256
|
+
```typescript
|
|
257
|
+
const content = await read('/home/user/workspace/package.json');
|
|
258
|
+
const pkg = JSON.parse(content);
|
|
259
|
+
console.log(pkg.name);
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
#### `write()`
|
|
265
|
+
|
|
266
|
+
Write content to a file. Creates the file if it doesn't exist.
|
|
267
|
+
|
|
268
|
+
**Parameters:**
|
|
269
|
+
|
|
270
|
+
- `filePath`: `string` - Path to the file
|
|
271
|
+
|
|
272
|
+
- `content`: `string` - Content to write
|
|
273
|
+
|
|
274
|
+
**Returns:** `Promise<void>`
|
|
275
|
+
|
|
276
|
+
**Example:**
|
|
277
|
+
```typescript
|
|
278
|
+
await write('/home/user/workspace/output.txt', 'Hello, world!');
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
#### `edit()`
|
|
284
|
+
|
|
285
|
+
Edit a file by replacing text.
|
|
286
|
+
|
|
287
|
+
**Parameters:**
|
|
288
|
+
|
|
289
|
+
- `filePath`: `string` - Path to the file
|
|
290
|
+
|
|
291
|
+
- `oldText`: `string` - Text to find (must be unique in file)
|
|
292
|
+
|
|
293
|
+
- `newText`: `string` - Text to replace with
|
|
294
|
+
|
|
295
|
+
**Returns:** `Promise<void>`
|
|
296
|
+
|
|
297
|
+
**Example:**
|
|
298
|
+
```typescript
|
|
299
|
+
await edit('/home/user/workspace/config.ts',
|
|
300
|
+
'debug: false',
|
|
301
|
+
'debug: true'
|
|
302
|
+
);
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
#### `glob()`
|
|
308
|
+
|
|
309
|
+
Find files matching a glob pattern.
|
|
310
|
+
|
|
311
|
+
**Parameters:**
|
|
312
|
+
|
|
313
|
+
- `pattern`: `string` - Glob pattern (e.g., "**\/*.ts")
|
|
314
|
+
|
|
315
|
+
- `cwd`: `any` (optional) - Directory to search in (default: /home/user/workspace)
|
|
316
|
+
|
|
317
|
+
**Returns:** `Promise<string[]>`
|
|
318
|
+
|
|
319
|
+
**Example:**
|
|
320
|
+
```typescript
|
|
321
|
+
const tsFiles = await glob('**\/*.ts');
|
|
322
|
+
console.log(`Found ${tsFiles.length} TypeScript files`);
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
#### `grep()`
|
|
328
|
+
|
|
329
|
+
Search file contents for a pattern.
|
|
330
|
+
|
|
331
|
+
**Parameters:**
|
|
332
|
+
|
|
333
|
+
- `pattern`: `string` - Regex pattern to search for
|
|
334
|
+
|
|
335
|
+
- `cwd`: `any` (optional) - Directory to search in (default: /home/user/workspace)
|
|
336
|
+
|
|
337
|
+
**Returns:** `Promise<Array<{ file: string; line: number; content: string }>>`
|
|
338
|
+
|
|
339
|
+
**Example:**
|
|
340
|
+
```typescript
|
|
341
|
+
const matches = await grep('TODO:');
|
|
342
|
+
for (const m of matches) {
|
|
343
|
+
console.log(`${m.file}:${m.line}: ${m.content}`);
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
#### `ls()`
|
|
350
|
+
|
|
351
|
+
List directory contents.
|
|
352
|
+
|
|
353
|
+
**Parameters:**
|
|
354
|
+
|
|
355
|
+
- `dirPath`: `string` - Path to directory
|
|
356
|
+
|
|
357
|
+
**Returns:** `Promise<string[]>`
|
|
358
|
+
|
|
359
|
+
**Example:**
|
|
360
|
+
```typescript
|
|
361
|
+
const files = await ls('/home/user/workspace');
|
|
362
|
+
console.log(files);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
### context
|
|
368
|
+
|
|
369
|
+
Context KSA - Knowledge, Skills, and Abilities Manage card context and variables that persist across stages. Use this to read the current context and set variables for later stages.
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { setGatewayConfig, getContext, getVariable, setVariable } from './ksa/context';
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
#### `setGatewayConfig()`
|
|
376
|
+
|
|
377
|
+
Set the gateway config for cloud operations. Called by the runtime when starting a session.
|
|
378
|
+
|
|
379
|
+
**Parameters:**
|
|
380
|
+
|
|
381
|
+
- `config`: `{
|
|
382
|
+
convexUrl: string;
|
|
383
|
+
jwt: string;
|
|
384
|
+
cardId?: string;
|
|
385
|
+
}` -
|
|
386
|
+
|
|
387
|
+
**Returns:** `void`
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
#### `getContext()`
|
|
392
|
+
|
|
393
|
+
Get the current card's context. Includes variables set by previous stages and artifact references.
|
|
394
|
+
|
|
395
|
+
**Returns:** `Promise<CardContext>`
|
|
396
|
+
|
|
397
|
+
**Example:**
|
|
398
|
+
```typescript
|
|
399
|
+
const ctx = await getContext();
|
|
400
|
+
console.log(`Card: ${ctx.cardId}`);
|
|
401
|
+
console.log(`Variables: ${JSON.stringify(ctx.variables)}`);
|
|
402
|
+
console.log(`Artifacts: ${ctx.artifactCount}`);
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
#### `getVariable()`
|
|
408
|
+
|
|
409
|
+
Get a specific variable from the card context. Convenience wrapper around getContext().
|
|
410
|
+
|
|
411
|
+
**Parameters:**
|
|
412
|
+
|
|
413
|
+
- `key`: `string` - Variable name
|
|
414
|
+
|
|
415
|
+
**Returns:** `Promise<unknown>`
|
|
416
|
+
|
|
417
|
+
**Example:**
|
|
418
|
+
```typescript
|
|
419
|
+
const audience = await getVariable('targetAudience');
|
|
420
|
+
if (audience) {
|
|
421
|
+
console.log(`Target: ${audience}`);
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
#### `setVariable()`
|
|
428
|
+
|
|
429
|
+
Set a variable in the card context. Variables persist across stages, so later stages can access them.
|
|
430
|
+
|
|
431
|
+
**Parameters:**
|
|
432
|
+
|
|
433
|
+
- `key`: `string` - Variable name
|
|
434
|
+
|
|
435
|
+
- `value`: `unknown` - Variable value (any JSON-serializable value)
|
|
436
|
+
|
|
437
|
+
**Returns:** `Promise<SetVariableResult>`
|
|
438
|
+
|
|
439
|
+
**Example:**
|
|
440
|
+
```typescript
|
|
441
|
+
// Set a string variable
|
|
442
|
+
await setVariable('targetAudience', 'enterprise developers');
|
|
443
|
+
|
|
444
|
+
// Set an object variable
|
|
445
|
+
await setVariable('researchFindings', {
|
|
446
|
+
competitors: ['A', 'B', 'C'],
|
|
447
|
+
marketSize: '$10B',
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// Set a list variable
|
|
451
|
+
await setVariable('keyInsights', [
|
|
452
|
+
'Market is growing 20% YoY',
|
|
453
|
+
'Main competitor has 45% share',
|
|
454
|
+
]);
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
## Skills KSAs (Research & Data)
|
|
460
|
+
|
|
461
|
+
### browser
|
|
462
|
+
|
|
463
|
+
Browser Skills Functions for browser automation. Uses the agent-browser CLI for headless browser control.
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
import { open, screenshot, click, type, getHtml, getText, closeBrowser } from './ksa/browser';
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### `open()`
|
|
470
|
+
|
|
471
|
+
Open a URL in the browser.
|
|
472
|
+
|
|
473
|
+
**Parameters:**
|
|
474
|
+
|
|
475
|
+
- `url`: `string` - URL to navigate to
|
|
476
|
+
|
|
477
|
+
**Returns:** `Promise<BrowserResult>`
|
|
478
|
+
|
|
479
|
+
**Example:**
|
|
480
|
+
```typescript
|
|
481
|
+
await open('https://example.com');
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
#### `screenshot()`
|
|
487
|
+
|
|
488
|
+
Take a screenshot of the current page.
|
|
489
|
+
|
|
490
|
+
**Parameters:**
|
|
491
|
+
|
|
492
|
+
- `name`: `any` (optional) - Optional filename (default: screenshot)
|
|
493
|
+
|
|
494
|
+
**Returns:** `Promise<Screenshot>`
|
|
495
|
+
|
|
496
|
+
**Example:**
|
|
497
|
+
```typescript
|
|
498
|
+
const { path } = await screenshot('homepage');
|
|
499
|
+
// Saves to /home/user/artifacts/homepage.png
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
#### `click()`
|
|
505
|
+
|
|
506
|
+
Click an element on the page.
|
|
507
|
+
|
|
508
|
+
**Parameters:**
|
|
509
|
+
|
|
510
|
+
- `selector`: `string` - CSS selector for element to click
|
|
511
|
+
|
|
512
|
+
**Returns:** `Promise<BrowserResult>`
|
|
513
|
+
|
|
514
|
+
**Example:**
|
|
515
|
+
```typescript
|
|
516
|
+
await click('button.submit');
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
#### `type()`
|
|
522
|
+
|
|
523
|
+
Type text into an input field.
|
|
524
|
+
|
|
525
|
+
**Parameters:**
|
|
526
|
+
|
|
527
|
+
- `selector`: `string` - CSS selector for input element
|
|
528
|
+
|
|
529
|
+
- `text`: `string` - Text to type
|
|
530
|
+
|
|
531
|
+
**Returns:** `Promise<BrowserResult>`
|
|
532
|
+
|
|
533
|
+
**Example:**
|
|
534
|
+
```typescript
|
|
535
|
+
await type('input[name="search"]', 'hello world');
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
#### `getHtml()`
|
|
541
|
+
|
|
542
|
+
Get the current page's HTML content.
|
|
543
|
+
|
|
544
|
+
**Returns:** `Promise<string>`
|
|
545
|
+
|
|
546
|
+
**Example:**
|
|
547
|
+
```typescript
|
|
548
|
+
const html = await getHtml();
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
#### `getText()`
|
|
554
|
+
|
|
555
|
+
Get the current page's text content.
|
|
556
|
+
|
|
557
|
+
**Returns:** `Promise<string>`
|
|
558
|
+
|
|
559
|
+
**Example:**
|
|
560
|
+
```typescript
|
|
561
|
+
const text = await getText();
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
#### `closeBrowser()`
|
|
567
|
+
|
|
568
|
+
Close the browser session.
|
|
569
|
+
|
|
570
|
+
**Returns:** `Promise<void>`
|
|
571
|
+
|
|
572
|
+
**Example:**
|
|
573
|
+
```typescript
|
|
574
|
+
await close();
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
### brandscan
|
|
580
|
+
|
|
581
|
+
Brand Lookup KSA - Knowledge, Skills, and Abilities Lightweight brand lookups for AI agents. Uses existing brand library data or fast API lookups. IMPORTANT: This KSA does NOT trigger full brand scans. Full scans involve web crawling and can take minutes. For agent tasks, use these lightweight lookups instead.
|
|
582
|
+
|
|
583
|
+
```typescript
|
|
584
|
+
import { lookupBrand, searchBrands, getBrandFromLibrary, getBrandData, getBrandSummary, listBrands, getBrandByDomain } from './ksa/brandscan';
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
#### `lookupBrand()`
|
|
588
|
+
|
|
589
|
+
Look up basic brand information - SAFE FOR AGENTS. This function: - Checks the brand library first (instant) - Falls back to lightweight API lookup (Brand.dev, TheCompanies) - NEVER triggers web crawling or full brand scans - Returns in seconds, not minutes
|
|
590
|
+
|
|
591
|
+
**Parameters:**
|
|
592
|
+
|
|
593
|
+
- `domain`: `string` - The domain to look up (e.g., 'anthropic.com')
|
|
594
|
+
|
|
595
|
+
**Returns:** `Promise<BrandLite | null>`
|
|
596
|
+
|
|
597
|
+
**Example:**
|
|
598
|
+
```typescript
|
|
599
|
+
const brand = await lookupBrand('anthropic.com');
|
|
600
|
+
if (brand) {
|
|
601
|
+
console.log(`${brand.name} - ${brand.industry}`);
|
|
602
|
+
console.log(`Founded: ${brand.yearFounded}`);
|
|
603
|
+
console.log(`Source: ${brand.source}`); // 'library' or 'api'
|
|
604
|
+
}
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
#### `searchBrands()`
|
|
610
|
+
|
|
611
|
+
Search for brands by name - SAFE FOR AGENTS. Returns a list of matching brands with basic info. Use this when you have a company name but not a domain.
|
|
612
|
+
|
|
613
|
+
**Parameters:**
|
|
614
|
+
|
|
615
|
+
- `query`: `string` - The brand name to search for
|
|
616
|
+
|
|
617
|
+
- `limit`: `any` (optional) - Maximum results (default: 5)
|
|
618
|
+
|
|
619
|
+
**Returns:** `Promise<BrandSearchResult[]>`
|
|
620
|
+
|
|
621
|
+
**Example:**
|
|
622
|
+
```typescript
|
|
623
|
+
const results = await searchBrands('Nike');
|
|
624
|
+
for (const r of results) {
|
|
625
|
+
console.log(`${r.name} - ${r.domain}`);
|
|
626
|
+
}
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
#### `getBrandFromLibrary()`
|
|
632
|
+
|
|
633
|
+
Get brand from library only - SAFE FOR AGENTS. Only returns brands that exist in the library. Returns null if brand hasn't been scanned yet. Use this when you specifically need library data.
|
|
634
|
+
|
|
635
|
+
**Parameters:**
|
|
636
|
+
|
|
637
|
+
- `domain`: `string` - The domain to look up
|
|
638
|
+
|
|
639
|
+
**Returns:** `Promise<BrandLite | null>`
|
|
640
|
+
|
|
641
|
+
**Example:**
|
|
642
|
+
```typescript
|
|
643
|
+
const brand = await getBrandFromLibrary('anthropic.com');
|
|
644
|
+
if (brand) {
|
|
645
|
+
console.log('Found in library:', brand.name);
|
|
646
|
+
} else {
|
|
647
|
+
console.log('Brand not yet scanned');
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
#### `getBrandData()`
|
|
654
|
+
|
|
655
|
+
Get full brand data from library - READ ONLY. Returns complete brand data including styleguide, products, and ads. Only works for brands that have been scanned and added to the library.
|
|
656
|
+
|
|
657
|
+
**Parameters:**
|
|
658
|
+
|
|
659
|
+
- `brandId`: `string` - The brand ID
|
|
660
|
+
|
|
661
|
+
**Returns:** `Promise<BrandData>`
|
|
662
|
+
|
|
663
|
+
**Example:**
|
|
664
|
+
```typescript
|
|
665
|
+
const brand = await getBrandData(brandId);
|
|
666
|
+
console.log('Brand:', brand.name);
|
|
667
|
+
console.log('Colors:', brand.styleguide?.colors);
|
|
668
|
+
console.log('Products:', brand.products?.length);
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
#### `getBrandSummary()`
|
|
674
|
+
|
|
675
|
+
Get brand intelligence summary - READ ONLY. Lighter weight than full data, returns counts.
|
|
676
|
+
|
|
677
|
+
**Parameters:**
|
|
678
|
+
|
|
679
|
+
- `brandId`: `string` - The brand ID
|
|
680
|
+
|
|
681
|
+
**Returns:** `Promise<{
|
|
682
|
+
brandId: string;
|
|
683
|
+
name: string;
|
|
684
|
+
domain: string;
|
|
685
|
+
productCount: number;
|
|
686
|
+
assetCount: number;
|
|
687
|
+
adCount: number;
|
|
688
|
+
socialPostCount: number;
|
|
689
|
+
}>`
|
|
690
|
+
|
|
691
|
+
**Example:**
|
|
692
|
+
```typescript
|
|
693
|
+
const summary = await getBrandSummary(brandId);
|
|
694
|
+
console.log(`${summary.productCount} products, ${summary.adCount} ads`);
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
#### `listBrands()`
|
|
700
|
+
|
|
701
|
+
List all brands in the library - READ ONLY.
|
|
702
|
+
|
|
703
|
+
**Returns:** `Promise<BrandData[]>`
|
|
704
|
+
|
|
705
|
+
**Example:**
|
|
706
|
+
```typescript
|
|
707
|
+
const brands = await listBrands();
|
|
708
|
+
for (const b of brands) {
|
|
709
|
+
console.log(`${b.name} (${b.domain})`);
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
#### `getBrandByDomain()`
|
|
716
|
+
|
|
717
|
+
Get brand by domain from library - READ ONLY.
|
|
718
|
+
|
|
719
|
+
**Parameters:**
|
|
720
|
+
|
|
721
|
+
- `domain`: `string` - The domain to look up
|
|
722
|
+
|
|
723
|
+
**Returns:** `Promise<BrandData | null>`
|
|
724
|
+
|
|
725
|
+
**Example:**
|
|
726
|
+
```typescript
|
|
727
|
+
const brand = await getBrandByDomain('anthropic.com');
|
|
728
|
+
if (brand) {
|
|
729
|
+
console.log('Found:', brand.name);
|
|
730
|
+
}
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
### boardDSL
|
|
736
|
+
|
|
737
|
+
Board DSL KSA - Create boards from YAML definitions Instead of making multiple API calls, define your entire board in YAML and create it atomically with a single function call.
|
|
738
|
+
|
|
739
|
+
```typescript
|
|
740
|
+
import { createBoardFromYAML, validateBoardYAML } from './ksa/boardDSL';
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
#### `createBoardFromYAML()`
|
|
744
|
+
|
|
745
|
+
Create a board from a YAML definition. This is the PREFERRED way to create boards. Write your board as YAML, then call this function to create it atomically.
|
|
746
|
+
|
|
747
|
+
**Parameters:**
|
|
748
|
+
|
|
749
|
+
- `yamlContent`: `string` - YAML string defining the board
|
|
750
|
+
|
|
751
|
+
**Returns:** `Promise<string>`
|
|
752
|
+
|
|
753
|
+
**Example:**
|
|
754
|
+
```typescript
|
|
755
|
+
const boardId = await createBoardFromYAML(`
|
|
756
|
+
name: Research Pipeline
|
|
757
|
+
description: Automated research workflow
|
|
758
|
+
|
|
759
|
+
trigger:
|
|
760
|
+
name: Research Request
|
|
761
|
+
methods:
|
|
762
|
+
prompt: true
|
|
763
|
+
chat:
|
|
764
|
+
systemPrompt: Research the given topic thoroughly
|
|
765
|
+
placeholder: What would you like me to research?
|
|
766
|
+
images: true
|
|
767
|
+
files: true
|
|
768
|
+
urls: true
|
|
769
|
+
|
|
770
|
+
stages:
|
|
771
|
+
- name: Gather Sources
|
|
772
|
+
type: agent
|
|
773
|
+
goals:
|
|
774
|
+
- Find 5-10 authoritative sources
|
|
775
|
+
- Include academic papers if relevant
|
|
776
|
+
- Verify source credibility
|
|
777
|
+
skills:
|
|
778
|
+
- web
|
|
779
|
+
- news
|
|
780
|
+
- pdf
|
|
781
|
+
deliverables:
|
|
782
|
+
- name: Source List
|
|
783
|
+
type: artifact
|
|
784
|
+
description: Curated list of sources with summaries
|
|
785
|
+
|
|
786
|
+
- name: Synthesize Findings
|
|
787
|
+
type: agent
|
|
788
|
+
goals:
|
|
789
|
+
- Extract key insights from each source
|
|
790
|
+
- Identify patterns and contradictions
|
|
791
|
+
- Create coherent narrative
|
|
792
|
+
skills:
|
|
793
|
+
- context
|
|
794
|
+
- artifacts
|
|
795
|
+
deliverables:
|
|
796
|
+
- name: Research Report
|
|
797
|
+
type: report
|
|
798
|
+
description: Comprehensive analysis of findings
|
|
799
|
+
|
|
800
|
+
- name: Review
|
|
801
|
+
type: human
|
|
802
|
+
goals:
|
|
803
|
+
- Verify accuracy
|
|
804
|
+
- Request clarifications if needed
|
|
805
|
+
`);
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
#### `validateBoardYAML()`
|
|
811
|
+
|
|
812
|
+
Validate a YAML board definition without creating it. Use this to check for errors before creating.
|
|
813
|
+
|
|
814
|
+
**Parameters:**
|
|
815
|
+
|
|
816
|
+
- `yamlContent`: `string` - YAML string to validate
|
|
817
|
+
|
|
818
|
+
**Returns:** `{
|
|
819
|
+
valid: boolean;
|
|
820
|
+
errors: string[];
|
|
821
|
+
summary?: {
|
|
822
|
+
name: string;
|
|
823
|
+
stageCount: number;
|
|
824
|
+
hasTrigger: boolean;
|
|
825
|
+
triggerMethods: string[];
|
|
826
|
+
};
|
|
827
|
+
}`
|
|
828
|
+
|
|
829
|
+
**Example:**
|
|
830
|
+
```typescript
|
|
831
|
+
const result = validateBoardYAML(yaml);
|
|
832
|
+
if (result.valid) {
|
|
833
|
+
console.log('Board definition is valid!');
|
|
834
|
+
console.log('Summary:', result.summary);
|
|
835
|
+
} else {
|
|
836
|
+
console.log('Errors:', result.errors);
|
|
837
|
+
}
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
### social
|
|
843
|
+
|
|
844
|
+
Social Media KSA - Knowledge, Skills, and Abilities Scrape and analyze social media profiles and content across platforms. Supports: TikTok, Instagram, YouTube, Twitter/X, LinkedIn, Facebook, Reddit, and more.
|
|
845
|
+
|
|
846
|
+
```typescript
|
|
847
|
+
import { tiktokProfile, instagramProfile, youtubeProfile, twitterProfile, linkedinProfile, tiktokPosts, instagramPosts, twitterPosts, searchSocial } from './ksa/social';
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
#### `tiktokProfile()`
|
|
851
|
+
|
|
852
|
+
Get a TikTok user profile.
|
|
853
|
+
|
|
854
|
+
**Parameters:**
|
|
855
|
+
|
|
856
|
+
- `username`: `string` - TikTok username (without @)
|
|
857
|
+
|
|
858
|
+
**Returns:** `Promise<SocialProfile>`
|
|
859
|
+
|
|
860
|
+
**Example:**
|
|
861
|
+
```typescript
|
|
862
|
+
const profile = await tiktokProfile('charlidamelio');
|
|
863
|
+
console.log(`${profile.displayName}: ${profile.followers} followers`);
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
#### `instagramProfile()`
|
|
869
|
+
|
|
870
|
+
Get an Instagram user profile.
|
|
871
|
+
|
|
872
|
+
**Parameters:**
|
|
873
|
+
|
|
874
|
+
- `username`: `string` - Instagram username
|
|
875
|
+
|
|
876
|
+
**Returns:** `Promise<SocialProfile>`
|
|
877
|
+
|
|
878
|
+
**Example:**
|
|
879
|
+
```typescript
|
|
880
|
+
const profile = await instagramProfile('instagram');
|
|
881
|
+
console.log(`${profile.displayName}: ${profile.followers} followers`);
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
#### `youtubeProfile()`
|
|
887
|
+
|
|
888
|
+
Get a YouTube channel profile.
|
|
889
|
+
|
|
890
|
+
**Parameters:**
|
|
891
|
+
|
|
892
|
+
- `channelId`: `string` - YouTube channel ID or handle
|
|
893
|
+
|
|
894
|
+
**Returns:** `Promise<SocialProfile>`
|
|
895
|
+
|
|
896
|
+
**Example:**
|
|
897
|
+
```typescript
|
|
898
|
+
const profile = await youtubeProfile('@MrBeast');
|
|
899
|
+
console.log(`${profile.displayName}: ${profile.followers} subscribers`);
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
#### `twitterProfile()`
|
|
905
|
+
|
|
906
|
+
Get a Twitter/X user profile.
|
|
907
|
+
|
|
908
|
+
**Parameters:**
|
|
909
|
+
|
|
910
|
+
- `username`: `string` - Twitter username (without @)
|
|
911
|
+
|
|
912
|
+
**Returns:** `Promise<SocialProfile>`
|
|
913
|
+
|
|
914
|
+
**Example:**
|
|
915
|
+
```typescript
|
|
916
|
+
const profile = await twitterProfile('elonmusk');
|
|
917
|
+
console.log(`${profile.displayName}: ${profile.followers} followers`);
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
#### `linkedinProfile()`
|
|
923
|
+
|
|
924
|
+
Get a LinkedIn user or company profile.
|
|
925
|
+
|
|
926
|
+
**Parameters:**
|
|
927
|
+
|
|
928
|
+
- `handle`: `string` - LinkedIn username or company URL slug
|
|
929
|
+
|
|
930
|
+
- `type`: `"person" | "company"` (optional) - 'person' or 'company'
|
|
931
|
+
|
|
932
|
+
**Returns:** `Promise<SocialProfile>`
|
|
933
|
+
|
|
934
|
+
**Example:**
|
|
935
|
+
```typescript
|
|
936
|
+
const profile = await linkedinProfile('microsoft', 'company');
|
|
937
|
+
console.log(`${profile.displayName}: ${profile.followers} followers`);
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
#### `tiktokPosts()`
|
|
943
|
+
|
|
944
|
+
Get recent posts from a TikTok user.
|
|
945
|
+
|
|
946
|
+
**Parameters:**
|
|
947
|
+
|
|
948
|
+
- `username`: `string` - TikTok username
|
|
949
|
+
|
|
950
|
+
- `limit`: `any` (optional) - Maximum posts to return (default: 10)
|
|
951
|
+
|
|
952
|
+
**Returns:** `Promise<SocialPost[]>`
|
|
953
|
+
|
|
954
|
+
**Example:**
|
|
955
|
+
```typescript
|
|
956
|
+
const posts = await tiktokPosts('charlidamelio', 5);
|
|
957
|
+
for (const post of posts) {
|
|
958
|
+
console.log(`${post.views} views: ${post.text?.slice(0, 50)}`);
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
#### `instagramPosts()`
|
|
965
|
+
|
|
966
|
+
Get recent posts from an Instagram user.
|
|
967
|
+
|
|
968
|
+
**Parameters:**
|
|
969
|
+
|
|
970
|
+
- `username`: `string` - Instagram username
|
|
971
|
+
|
|
972
|
+
- `limit`: `any` (optional) - Maximum posts to return (default: 10)
|
|
973
|
+
|
|
974
|
+
**Returns:** `Promise<SocialPost[]>`
|
|
975
|
+
|
|
976
|
+
**Example:**
|
|
977
|
+
```typescript
|
|
978
|
+
const posts = await instagramPosts('instagram', 5);
|
|
979
|
+
for (const post of posts) {
|
|
980
|
+
console.log(`${post.likes} likes: ${post.text?.slice(0, 50)}`);
|
|
981
|
+
}
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
#### `twitterPosts()`
|
|
987
|
+
|
|
988
|
+
Get recent tweets from a Twitter/X user.
|
|
989
|
+
|
|
990
|
+
**Parameters:**
|
|
991
|
+
|
|
992
|
+
- `username`: `string` - Twitter username
|
|
993
|
+
|
|
994
|
+
- `limit`: `any` (optional) - Maximum tweets to return (default: 10)
|
|
995
|
+
|
|
996
|
+
**Returns:** `Promise<SocialPost[]>`
|
|
997
|
+
|
|
998
|
+
**Example:**
|
|
999
|
+
```typescript
|
|
1000
|
+
const tweets = await twitterPosts('elonmusk', 5);
|
|
1001
|
+
for (const tweet of tweets) {
|
|
1002
|
+
console.log(`${tweet.likes} likes: ${tweet.text?.slice(0, 50)}`);
|
|
1003
|
+
}
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
#### `searchSocial()`
|
|
1009
|
+
|
|
1010
|
+
Search for social media content across platforms.
|
|
1011
|
+
|
|
1012
|
+
**Parameters:**
|
|
1013
|
+
|
|
1014
|
+
- `query`: `string` - Search query
|
|
1015
|
+
|
|
1016
|
+
- `platform`: `"tiktok" | "instagram" | "twitter" | "youtube"` - Platform to search (tiktok, instagram, twitter, youtube)
|
|
1017
|
+
|
|
1018
|
+
- `limit`: `any` (optional) - Maximum results (default: 10)
|
|
1019
|
+
|
|
1020
|
+
**Returns:** `Promise<SocialSearchResult>`
|
|
1021
|
+
|
|
1022
|
+
**Example:**
|
|
1023
|
+
```typescript
|
|
1024
|
+
const results = await searchSocial('AI news', 'twitter', 10);
|
|
1025
|
+
for (const post of results.posts) {
|
|
1026
|
+
console.log(`[${post.author}] ${post.text?.slice(0, 50)}`);
|
|
1027
|
+
}
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
### news
|
|
1033
|
+
|
|
1034
|
+
News KSA - Knowledge, Skills, and Abilities Advanced news research and monitoring via APITube. Supports entity tracking, sentiment analysis, brand monitoring.
|
|
1035
|
+
|
|
1036
|
+
```typescript
|
|
1037
|
+
import { search, trending, breakingNews, monitorBrand, monitorOrganization, analyzeSentiment, compareTopics } from './ksa/news';
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
#### `search()`
|
|
1041
|
+
|
|
1042
|
+
Search for news articles with advanced filtering.
|
|
1043
|
+
|
|
1044
|
+
**Parameters:**
|
|
1045
|
+
|
|
1046
|
+
- `options`: `NewsSearchOptions` - Search options
|
|
1047
|
+
|
|
1048
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1049
|
+
|
|
1050
|
+
**Example:**
|
|
1051
|
+
```typescript
|
|
1052
|
+
const articles = await search({
|
|
1053
|
+
query: 'artificial intelligence',
|
|
1054
|
+
category: 'science',
|
|
1055
|
+
sentiment: 'positive',
|
|
1056
|
+
limit: 20
|
|
1057
|
+
});
|
|
1058
|
+
for (const a of articles) {
|
|
1059
|
+
console.log(`[${a.sentiment?.polarity}] ${a.title}`);
|
|
1060
|
+
}
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
#### `trending()`
|
|
1066
|
+
|
|
1067
|
+
Get trending news by category.
|
|
1068
|
+
|
|
1069
|
+
**Parameters:**
|
|
1070
|
+
|
|
1071
|
+
- `category`: `NewsCategory` - News category
|
|
1072
|
+
|
|
1073
|
+
- `limit`: `any` (optional) - Maximum articles (default: 10)
|
|
1074
|
+
|
|
1075
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1076
|
+
|
|
1077
|
+
**Example:**
|
|
1078
|
+
```typescript
|
|
1079
|
+
const tech = await trending('science', 10);
|
|
1080
|
+
for (const a of tech) {
|
|
1081
|
+
console.log(`${a.title} (${a.source.name})`);
|
|
1082
|
+
}
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
#### `breakingNews()`
|
|
1088
|
+
|
|
1089
|
+
Get breaking news (most recent high-quality articles).
|
|
1090
|
+
|
|
1091
|
+
**Parameters:**
|
|
1092
|
+
|
|
1093
|
+
- `limit`: `any` (optional) - Maximum articles (default: 10)
|
|
1094
|
+
|
|
1095
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1096
|
+
|
|
1097
|
+
**Example:**
|
|
1098
|
+
```typescript
|
|
1099
|
+
const breaking = await breakingNews(5);
|
|
1100
|
+
for (const a of breaking) {
|
|
1101
|
+
console.log(`[${a.publishedAt}] ${a.title}`);
|
|
1102
|
+
}
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
#### `monitorBrand()`
|
|
1108
|
+
|
|
1109
|
+
Monitor news about a brand.
|
|
1110
|
+
|
|
1111
|
+
**Parameters:**
|
|
1112
|
+
|
|
1113
|
+
- `brandName`: `string` - Brand name to monitor
|
|
1114
|
+
|
|
1115
|
+
- `options`: `{
|
|
1116
|
+
sentiment?: "positive" | "negative" | "neutral";
|
|
1117
|
+
days?: number;
|
|
1118
|
+
limit?: number;
|
|
1119
|
+
}` (optional) - Additional options
|
|
1120
|
+
|
|
1121
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1122
|
+
|
|
1123
|
+
**Example:**
|
|
1124
|
+
```typescript
|
|
1125
|
+
const articles = await monitorBrand('Apple', { sentiment: 'negative', days: 7 });
|
|
1126
|
+
console.log(`Found ${articles.length} negative articles about Apple`);
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
#### `monitorOrganization()`
|
|
1132
|
+
|
|
1133
|
+
Monitor news about an organization.
|
|
1134
|
+
|
|
1135
|
+
**Parameters:**
|
|
1136
|
+
|
|
1137
|
+
- `orgName`: `string` - Organization name
|
|
1138
|
+
|
|
1139
|
+
- `options`: `{
|
|
1140
|
+
sentiment?: "positive" | "negative" | "neutral";
|
|
1141
|
+
days?: number;
|
|
1142
|
+
limit?: number;
|
|
1143
|
+
}` (optional) - Additional options
|
|
1144
|
+
|
|
1145
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1146
|
+
|
|
1147
|
+
**Example:**
|
|
1148
|
+
```typescript
|
|
1149
|
+
const articles = await monitorOrganization('Microsoft');
|
|
1150
|
+
for (const a of articles) {
|
|
1151
|
+
console.log(`${a.title} - ${a.sentiment?.polarity}`);
|
|
1152
|
+
}
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
#### `analyzeSentiment()`
|
|
1158
|
+
|
|
1159
|
+
Get sentiment distribution for a topic.
|
|
1160
|
+
|
|
1161
|
+
**Parameters:**
|
|
1162
|
+
|
|
1163
|
+
- `query`: `string` - Search query
|
|
1164
|
+
|
|
1165
|
+
- `days`: `any` (optional) - Number of days to analyze (default: 7)
|
|
1166
|
+
|
|
1167
|
+
**Returns:** `Promise<{ positive: number; negative: number; neutral: number; total: number }>`
|
|
1168
|
+
|
|
1169
|
+
**Example:**
|
|
1170
|
+
```typescript
|
|
1171
|
+
const sentiment = await analyzeSentiment('climate change', 30);
|
|
1172
|
+
console.log(`Positive: ${sentiment.positive}%`);
|
|
1173
|
+
console.log(`Negative: ${sentiment.negative}%`);
|
|
1174
|
+
console.log(`Neutral: ${sentiment.neutral}%`);
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
#### `compareTopics()`
|
|
1180
|
+
|
|
1181
|
+
Compare news coverage between two topics.
|
|
1182
|
+
|
|
1183
|
+
**Parameters:**
|
|
1184
|
+
|
|
1185
|
+
- `topic1`: `string` - First topic
|
|
1186
|
+
|
|
1187
|
+
- `topic2`: `string` - Second topic
|
|
1188
|
+
|
|
1189
|
+
- `days`: `any` (optional) - Number of days (default: 7)
|
|
1190
|
+
|
|
1191
|
+
**Returns:** `Promise<{
|
|
1192
|
+
topic1: { query: string; count: number; avgSentiment: number };
|
|
1193
|
+
topic2: { query: string; count: number; avgSentiment: number };
|
|
1194
|
+
}>`
|
|
1195
|
+
|
|
1196
|
+
**Example:**
|
|
1197
|
+
```typescript
|
|
1198
|
+
const comparison = await compareTopics('electric vehicles', 'hydrogen cars', 30);
|
|
1199
|
+
console.log(`EV articles: ${comparison.topic1.count}`);
|
|
1200
|
+
console.log(`H2 articles: ${comparison.topic2.count}`);
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
### boards
|
|
1206
|
+
|
|
1207
|
+
Boards KSA - Knowledge, Skills, and Abilities Manage and execute kanban boards programmatically. Use this to create boards, add cards, and trigger automated execution. IMPORTANT: When creating boards, ALWAYS design appropriate stages. Each stage needs: name, stageType ('agent' or 'human'), and optionally goals.
|
|
1208
|
+
|
|
1209
|
+
```typescript
|
|
1210
|
+
import { listBoards, getBoard, createBoard, setTrigger, addCard, runCard, getCardStatus, waitForCard, stopCard, getCompletedCards, listTemplates, getTemplate, createBoardFromTemplate } from './ksa/boards';
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
#### `listBoards()`
|
|
1214
|
+
|
|
1215
|
+
List all boards accessible to the current user.
|
|
1216
|
+
|
|
1217
|
+
**Parameters:**
|
|
1218
|
+
|
|
1219
|
+
- `orgId`: `string` (optional) - Optional organization ID to filter by
|
|
1220
|
+
|
|
1221
|
+
**Returns:** `Promise<Board[]>`
|
|
1222
|
+
|
|
1223
|
+
**Example:**
|
|
1224
|
+
```typescript
|
|
1225
|
+
const boards = await listBoards();
|
|
1226
|
+
for (const b of boards) {
|
|
1227
|
+
console.log(`${b.name} - ${b.stages.length} stages`);
|
|
1228
|
+
}
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
#### `getBoard()`
|
|
1234
|
+
|
|
1235
|
+
Get a board with its stages and configuration.
|
|
1236
|
+
|
|
1237
|
+
**Parameters:**
|
|
1238
|
+
|
|
1239
|
+
- `boardId`: `string` - The board ID
|
|
1240
|
+
|
|
1241
|
+
**Returns:** `Promise<Board | null>`
|
|
1242
|
+
|
|
1243
|
+
**Example:**
|
|
1244
|
+
```typescript
|
|
1245
|
+
const board = await getBoard('abc123');
|
|
1246
|
+
console.log(`${board.name} has ${board.stages.length} stages`);
|
|
1247
|
+
```
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
#### `createBoard()`
|
|
1252
|
+
|
|
1253
|
+
Create a new board with optional custom stages.
|
|
1254
|
+
|
|
1255
|
+
**Parameters:**
|
|
1256
|
+
|
|
1257
|
+
- `name`: `string` - Board name
|
|
1258
|
+
|
|
1259
|
+
- `options`: `{
|
|
1260
|
+
description?: string;
|
|
1261
|
+
template?: string;
|
|
1262
|
+
stages?: StageConfig[];
|
|
1263
|
+
trigger?: TriggerConfig;
|
|
1264
|
+
workspaceMode?: "per_card" | "shared";
|
|
1265
|
+
}` (optional) - Optional configuration including stages
|
|
1266
|
+
|
|
1267
|
+
**Returns:** `Promise<string>`
|
|
1268
|
+
|
|
1269
|
+
**Example:**
|
|
1270
|
+
```typescript
|
|
1271
|
+
// Create a simple board with default stages (Backlog, In Progress, Done)
|
|
1272
|
+
const boardId = await createBoard('My Board');
|
|
1273
|
+
|
|
1274
|
+
// Create a board with custom stages
|
|
1275
|
+
const boardId = await createBoard('Content Pipeline', {
|
|
1276
|
+
stages: [
|
|
1277
|
+
{ name: 'Research', stageType: 'agent', goals: ['Find 5 sources'] },
|
|
1278
|
+
{ name: 'Write', stageType: 'agent', skills: ['web', 'pdf'] },
|
|
1279
|
+
{ name: 'Review', stageType: 'human' }
|
|
1280
|
+
]
|
|
1281
|
+
});
|
|
1282
|
+
|
|
1283
|
+
// Create from a template
|
|
1284
|
+
const boardId = await createBoard('My Research', { template: 'research-report' });
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
#### `setTrigger()`
|
|
1290
|
+
|
|
1291
|
+
Set the trigger configuration for a board. Triggers define how cards are created on the board.
|
|
1292
|
+
|
|
1293
|
+
**Parameters:**
|
|
1294
|
+
|
|
1295
|
+
- `boardId`: `string` - The board ID
|
|
1296
|
+
|
|
1297
|
+
- `trigger`: `TriggerConfig` - The trigger configuration
|
|
1298
|
+
|
|
1299
|
+
**Returns:** `Promise<void>`
|
|
1300
|
+
|
|
1301
|
+
**Example:**
|
|
1302
|
+
```typescript
|
|
1303
|
+
// Set a chat-based trigger
|
|
1304
|
+
await setTrigger(boardId, {
|
|
1305
|
+
name: 'Chat Trigger',
|
|
1306
|
+
methods: { prompt: true, webform: false, webhook: false, mcp: false },
|
|
1307
|
+
chat: {
|
|
1308
|
+
images: { enabled: true, maxSize: '10MB' },
|
|
1309
|
+
files: { enabled: true, maxSize: '25MB', types: ['pdf', 'docx'] },
|
|
1310
|
+
urls: { enabled: true, scrape: true },
|
|
1311
|
+
systemPrompt: 'You are analyzing brand data...',
|
|
1312
|
+
startWithPlan: true,
|
|
1313
|
+
},
|
|
1314
|
+
form: { fields: [] },
|
|
1315
|
+
});
|
|
1316
|
+
```
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
#### `addCard()`
|
|
1321
|
+
|
|
1322
|
+
Add a card to a board.
|
|
1323
|
+
|
|
1324
|
+
**Parameters:**
|
|
1325
|
+
|
|
1326
|
+
- `boardId`: `string` - The board ID
|
|
1327
|
+
|
|
1328
|
+
- `taskId`: `string` - Unique task identifier
|
|
1329
|
+
|
|
1330
|
+
- `name`: `string` - Card name/title
|
|
1331
|
+
|
|
1332
|
+
- `options`: `{
|
|
1333
|
+
data?: Record<string, unknown>;
|
|
1334
|
+
autoRun?: boolean;
|
|
1335
|
+
}` (optional) - Optional card configuration
|
|
1336
|
+
|
|
1337
|
+
**Returns:** `Promise<string>`
|
|
1338
|
+
|
|
1339
|
+
**Example:**
|
|
1340
|
+
```typescript
|
|
1341
|
+
const cardId = await addCard(boardId, 'task-001', 'Research AI trends', {
|
|
1342
|
+
data: { topic: 'generative AI', depth: 'thorough' },
|
|
1343
|
+
autoRun: true
|
|
1344
|
+
});
|
|
1345
|
+
```
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
#### `runCard()`
|
|
1350
|
+
|
|
1351
|
+
Run a card through the board pipeline. Triggers execution starting from the current stage.
|
|
1352
|
+
|
|
1353
|
+
**Parameters:**
|
|
1354
|
+
|
|
1355
|
+
- `cardId`: `string` - The card ID to execute
|
|
1356
|
+
|
|
1357
|
+
**Returns:** `Promise<BoardExecutionResult>`
|
|
1358
|
+
|
|
1359
|
+
**Example:**
|
|
1360
|
+
```typescript
|
|
1361
|
+
const result = await runCard(cardId);
|
|
1362
|
+
if (result.status === 'completed') {
|
|
1363
|
+
console.log('Artifacts:', result.artifacts);
|
|
1364
|
+
}
|
|
1365
|
+
```
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
#### `getCardStatus()`
|
|
1370
|
+
|
|
1371
|
+
Get the current status of a card.
|
|
1372
|
+
|
|
1373
|
+
**Parameters:**
|
|
1374
|
+
|
|
1375
|
+
- `cardId`: `string` - The card ID
|
|
1376
|
+
|
|
1377
|
+
**Returns:** `Promise<CardStatus>`
|
|
1378
|
+
|
|
1379
|
+
**Example:**
|
|
1380
|
+
```typescript
|
|
1381
|
+
const status = await getCardStatus(cardId);
|
|
1382
|
+
console.log(`Card is ${status.status} at stage ${status.stageName}`);
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
#### `waitForCard()`
|
|
1388
|
+
|
|
1389
|
+
Wait for a card to complete execution. Polls the card status until it completes, fails, or times out.
|
|
1390
|
+
|
|
1391
|
+
**Parameters:**
|
|
1392
|
+
|
|
1393
|
+
- `cardId`: `string` - The card ID
|
|
1394
|
+
|
|
1395
|
+
- `timeoutMs`: `any` (optional) - Maximum wait time in milliseconds (default: 5 minutes)
|
|
1396
|
+
|
|
1397
|
+
**Returns:** `Promise<BoardExecutionResult>`
|
|
1398
|
+
|
|
1399
|
+
**Example:**
|
|
1400
|
+
```typescript
|
|
1401
|
+
// Wait up to 10 minutes for completion
|
|
1402
|
+
const result = await waitForCard(cardId, 600000);
|
|
1403
|
+
if (result.status === 'completed') {
|
|
1404
|
+
console.log('Done! Artifacts:', result.artifacts);
|
|
1405
|
+
}
|
|
1406
|
+
```
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
#### `stopCard()`
|
|
1411
|
+
|
|
1412
|
+
Stop a running card.
|
|
1413
|
+
|
|
1414
|
+
**Parameters:**
|
|
1415
|
+
|
|
1416
|
+
- `cardId`: `string` - The card ID to stop
|
|
1417
|
+
|
|
1418
|
+
**Returns:** `Promise<void>`
|
|
1419
|
+
|
|
1420
|
+
**Example:**
|
|
1421
|
+
```typescript
|
|
1422
|
+
await stopCard(cardId);
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
#### `getCompletedCards()`
|
|
1428
|
+
|
|
1429
|
+
Get cards that have completed execution.
|
|
1430
|
+
|
|
1431
|
+
**Parameters:**
|
|
1432
|
+
|
|
1433
|
+
- `boardId`: `string` - The board ID
|
|
1434
|
+
|
|
1435
|
+
- `limit`: `any` (optional) - Maximum cards to return (default: 10)
|
|
1436
|
+
|
|
1437
|
+
**Returns:** `Promise<Card[]>`
|
|
1438
|
+
|
|
1439
|
+
**Example:**
|
|
1440
|
+
```typescript
|
|
1441
|
+
const completed = await getCompletedCards(boardId, 5);
|
|
1442
|
+
for (const card of completed) {
|
|
1443
|
+
console.log(`${card.name} - completed`);
|
|
1444
|
+
}
|
|
1445
|
+
```
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
#### `listTemplates()`
|
|
1450
|
+
|
|
1451
|
+
List available board templates. Templates provide pre-configured workflows for common use cases.
|
|
1452
|
+
|
|
1453
|
+
**Parameters:**
|
|
1454
|
+
|
|
1455
|
+
- `category`: `string` (optional) - Optional category filter
|
|
1456
|
+
|
|
1457
|
+
**Returns:** `Promise<BoardTemplate[]>`
|
|
1458
|
+
|
|
1459
|
+
**Example:**
|
|
1460
|
+
```typescript
|
|
1461
|
+
const templates = await listTemplates();
|
|
1462
|
+
for (const t of templates) {
|
|
1463
|
+
console.log(`${t.name}: ${t.description}`);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// Filter by category
|
|
1467
|
+
const researchTemplates = await listTemplates('research');
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
#### `getTemplate()`
|
|
1473
|
+
|
|
1474
|
+
Get details of a specific template including its stages.
|
|
1475
|
+
|
|
1476
|
+
**Parameters:**
|
|
1477
|
+
|
|
1478
|
+
- `templateId`: `string` - The template ID
|
|
1479
|
+
|
|
1480
|
+
**Returns:** `Promise<{
|
|
1481
|
+
id: string;
|
|
1482
|
+
name: string;
|
|
1483
|
+
description: string;
|
|
1484
|
+
stages: Array<{
|
|
1485
|
+
name: string;
|
|
1486
|
+
stageType: "agent" | "human";
|
|
1487
|
+
description: string;
|
|
1488
|
+
skills: Array<{ id: string; name: string; icon: string }>;
|
|
1489
|
+
deliverables: Array<{ id: string; type: string; name: string }>;
|
|
1490
|
+
goals: Array<{ id: string; text: string; done: boolean }>;
|
|
1491
|
+
}>;
|
|
1492
|
+
} | null>`
|
|
1493
|
+
|
|
1494
|
+
**Example:**
|
|
1495
|
+
```typescript
|
|
1496
|
+
const template = await getTemplate('research-report');
|
|
1497
|
+
console.log(`${template.name} has ${template.stages.length} stages`);
|
|
1498
|
+
```
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
#### `createBoardFromTemplate()`
|
|
1503
|
+
|
|
1504
|
+
Create a board from a template. This is a shortcut for createBoard with template option. Available templates: - 'research-report': Research a topic and generate PDF report - 'content-pipeline': Create blog posts/articles with outline→draft→polish flow - 'data-analysis': Process data, analyze, and generate insights report - 'competitor-research': Research competitors and create competitive analysis - 'social-monitoring': Monitor social media mentions and sentiment
|
|
1505
|
+
|
|
1506
|
+
**Parameters:**
|
|
1507
|
+
|
|
1508
|
+
- `templateId`: `string` - The template ID to use
|
|
1509
|
+
|
|
1510
|
+
- `name`: `string` (optional) - Optional custom name for the board
|
|
1511
|
+
|
|
1512
|
+
**Returns:** `Promise<string>`
|
|
1513
|
+
|
|
1514
|
+
**Example:**
|
|
1515
|
+
```typescript
|
|
1516
|
+
// Create a research board
|
|
1517
|
+
const boardId = await createBoardFromTemplate('research-report', 'AI Trends Research');
|
|
1518
|
+
|
|
1519
|
+
// Create a content pipeline
|
|
1520
|
+
const boardId = await createBoardFromTemplate('content-pipeline', 'Q4 Blog Posts');
|
|
1521
|
+
```
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
### web
|
|
1526
|
+
|
|
1527
|
+
Web KSA - Knowledge, Skills, and Abilities Functions for web search and content extraction. Import and use these in your code.
|
|
1528
|
+
|
|
1529
|
+
```typescript
|
|
1530
|
+
import { search, scrape, news, brandNews, webResearch } from './ksa/web';
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
#### `search()`
|
|
1534
|
+
|
|
1535
|
+
Search the web for information.
|
|
1536
|
+
|
|
1537
|
+
**Parameters:**
|
|
1538
|
+
|
|
1539
|
+
- `query`: `string` - Search query string
|
|
1540
|
+
|
|
1541
|
+
- `options`: `{
|
|
1542
|
+
maxResults?: number;
|
|
1543
|
+
type?: 'all' | 'web' | 'news' | 'academic';
|
|
1544
|
+
}` (optional) - Optional search configuration
|
|
1545
|
+
|
|
1546
|
+
**Returns:** `Promise<SearchResult[]>`
|
|
1547
|
+
|
|
1548
|
+
**Example:**
|
|
1549
|
+
```typescript
|
|
1550
|
+
const results = await search('TypeScript best practices 2025');
|
|
1551
|
+
for (const r of results) {
|
|
1552
|
+
console.log(`${r.title}: ${r.url}`);
|
|
1553
|
+
}
|
|
1554
|
+
```
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
#### `scrape()`
|
|
1559
|
+
|
|
1560
|
+
Extract clean content from a URL.
|
|
1561
|
+
|
|
1562
|
+
**Parameters:**
|
|
1563
|
+
|
|
1564
|
+
- `url`: `string` - URL to scrape
|
|
1565
|
+
|
|
1566
|
+
**Returns:** `Promise<ScrapedContent>`
|
|
1567
|
+
|
|
1568
|
+
**Example:**
|
|
1569
|
+
```typescript
|
|
1570
|
+
const content = await scrape('https://example.com/article');
|
|
1571
|
+
console.log(content.markdown);
|
|
1572
|
+
```
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
#### `news()`
|
|
1577
|
+
|
|
1578
|
+
Search for recent news articles using Valyu (recommended for research).
|
|
1579
|
+
|
|
1580
|
+
**Parameters:**
|
|
1581
|
+
|
|
1582
|
+
- `query`: `string` - News search query
|
|
1583
|
+
|
|
1584
|
+
- `limit`: `any` (optional) - Maximum articles to return (default: 10)
|
|
1585
|
+
|
|
1586
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1587
|
+
|
|
1588
|
+
**Example:**
|
|
1589
|
+
```typescript
|
|
1590
|
+
const articles = await news('AI regulation');
|
|
1591
|
+
for (const a of articles) {
|
|
1592
|
+
console.log(`[${a.source}] ${a.title}`);
|
|
1593
|
+
}
|
|
1594
|
+
```
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
#### `brandNews()`
|
|
1599
|
+
|
|
1600
|
+
Monitor brand mentions in news (uses APITube for brand-specific tracking). Use this for tracking specific brand/company mentions, not general research.
|
|
1601
|
+
|
|
1602
|
+
**Parameters:**
|
|
1603
|
+
|
|
1604
|
+
- `brandQuery`: `string` - Brand or company name to monitor
|
|
1605
|
+
|
|
1606
|
+
- `limit`: `any` (optional) - Maximum articles to return (default: 10)
|
|
1607
|
+
|
|
1608
|
+
**Returns:** `Promise<NewsArticle[]>`
|
|
1609
|
+
|
|
1610
|
+
**Example:**
|
|
1611
|
+
```typescript
|
|
1612
|
+
const mentions = await brandNews('Anthropic');
|
|
1613
|
+
for (const m of mentions) {
|
|
1614
|
+
console.log(`[${m.source}] ${m.title}`);
|
|
1615
|
+
}
|
|
1616
|
+
```
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
#### `webResearch()`
|
|
1621
|
+
|
|
1622
|
+
Comprehensive web research combining search and news. Use this for thorough research on a topic.
|
|
1623
|
+
|
|
1624
|
+
**Parameters:**
|
|
1625
|
+
|
|
1626
|
+
- `query`: `string` - Research topic
|
|
1627
|
+
|
|
1628
|
+
- `options`: `{
|
|
1629
|
+
depth?: 'quick' | 'thorough';
|
|
1630
|
+
includeNews?: boolean;
|
|
1631
|
+
}` (optional) - Research options
|
|
1632
|
+
|
|
1633
|
+
**Returns:** `Promise<{
|
|
1634
|
+
sources: SearchResult[];
|
|
1635
|
+
articles: NewsArticle[];
|
|
1636
|
+
}>`
|
|
1637
|
+
|
|
1638
|
+
**Example:**
|
|
1639
|
+
```typescript
|
|
1640
|
+
const research = await webResearch('multi-agent AI systems', { depth: 'thorough' });
|
|
1641
|
+
console.log('Articles:', research.articles.length);
|
|
1642
|
+
console.log('Sources:', research.sources.length);
|
|
1643
|
+
```
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
### workspaces
|
|
1648
|
+
|
|
1649
|
+
Workspaces KSA - Knowledge, Skills, and Abilities Create and manage design workspaces with canvas tools. Workspaces contain frames, designs, and collaborative elements.
|
|
1650
|
+
|
|
1651
|
+
```typescript
|
|
1652
|
+
import { listWorkspaces, createWorkspace, getWorkspace, updateWorkspaceName, deleteWorkspace, getCanvas, saveCanvas, addCanvasElement, removeCanvasElement, updateCanvasElement, addConnection, listDesigns, saveDesign } from './ksa/workspaces';
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
#### `listWorkspaces()`
|
|
1656
|
+
|
|
1657
|
+
List all workspaces.
|
|
1658
|
+
|
|
1659
|
+
**Parameters:**
|
|
1660
|
+
|
|
1661
|
+
- `orgId`: `string` (optional) - Optional organization ID to filter by
|
|
1662
|
+
|
|
1663
|
+
**Returns:** `Promise<Workspace[]>`
|
|
1664
|
+
|
|
1665
|
+
**Example:**
|
|
1666
|
+
```typescript
|
|
1667
|
+
const workspaces = await listWorkspaces();
|
|
1668
|
+
for (const ws of workspaces) {
|
|
1669
|
+
console.log(`${ws.name} - ${ws.canvas?.elements.length || 0} elements`);
|
|
1670
|
+
}
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
#### `createWorkspace()`
|
|
1676
|
+
|
|
1677
|
+
Create a new workspace.
|
|
1678
|
+
|
|
1679
|
+
**Parameters:**
|
|
1680
|
+
|
|
1681
|
+
- `name`: `string` - Workspace name
|
|
1682
|
+
|
|
1683
|
+
- `orgId`: `string` (optional) - Optional organization ID
|
|
1684
|
+
|
|
1685
|
+
**Returns:** `Promise<string>`
|
|
1686
|
+
|
|
1687
|
+
**Example:**
|
|
1688
|
+
```typescript
|
|
1689
|
+
const workspaceId = await createWorkspace('Q1 Campaign Designs');
|
|
1690
|
+
```
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
#### `getWorkspace()`
|
|
1695
|
+
|
|
1696
|
+
Get workspace details.
|
|
1697
|
+
|
|
1698
|
+
**Parameters:**
|
|
1699
|
+
|
|
1700
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1701
|
+
|
|
1702
|
+
**Returns:** `Promise<Workspace | null>`
|
|
1703
|
+
|
|
1704
|
+
**Example:**
|
|
1705
|
+
```typescript
|
|
1706
|
+
const workspace = await getWorkspace(workspaceId);
|
|
1707
|
+
console.log(`Canvas has ${workspace.canvas?.elements.length} elements`);
|
|
1708
|
+
```
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
#### `updateWorkspaceName()`
|
|
1713
|
+
|
|
1714
|
+
Update workspace name.
|
|
1715
|
+
|
|
1716
|
+
**Parameters:**
|
|
1717
|
+
|
|
1718
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1719
|
+
|
|
1720
|
+
- `name`: `string` - New workspace name
|
|
1721
|
+
|
|
1722
|
+
**Returns:** `Promise<void>`
|
|
1723
|
+
|
|
1724
|
+
**Example:**
|
|
1725
|
+
```typescript
|
|
1726
|
+
await updateWorkspaceName(workspaceId, 'Rebranded Workspace');
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
#### `deleteWorkspace()`
|
|
1732
|
+
|
|
1733
|
+
Delete a workspace.
|
|
1734
|
+
|
|
1735
|
+
**Parameters:**
|
|
1736
|
+
|
|
1737
|
+
- `workspaceId`: `string` - The workspace ID to delete
|
|
1738
|
+
|
|
1739
|
+
**Returns:** `Promise<void>`
|
|
1740
|
+
|
|
1741
|
+
**Example:**
|
|
1742
|
+
```typescript
|
|
1743
|
+
await deleteWorkspace(workspaceId);
|
|
1744
|
+
```
|
|
1745
|
+
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
#### `getCanvas()`
|
|
1749
|
+
|
|
1750
|
+
Get the canvas state for a workspace.
|
|
1751
|
+
|
|
1752
|
+
**Parameters:**
|
|
1753
|
+
|
|
1754
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1755
|
+
|
|
1756
|
+
**Returns:** `Promise<CanvasState | null>`
|
|
1757
|
+
|
|
1758
|
+
**Example:**
|
|
1759
|
+
```typescript
|
|
1760
|
+
const canvas = await getCanvas(workspaceId);
|
|
1761
|
+
for (const el of canvas?.elements || []) {
|
|
1762
|
+
console.log(`${el.data.nodeType}: ${el.data.label}`);
|
|
1763
|
+
}
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
#### `saveCanvas()`
|
|
1769
|
+
|
|
1770
|
+
Save/update the canvas state.
|
|
1771
|
+
|
|
1772
|
+
**Parameters:**
|
|
1773
|
+
|
|
1774
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1775
|
+
|
|
1776
|
+
- `canvas`: `CanvasState` - The canvas state to save
|
|
1777
|
+
|
|
1778
|
+
**Returns:** `Promise<void>`
|
|
1779
|
+
|
|
1780
|
+
**Example:**
|
|
1781
|
+
```typescript
|
|
1782
|
+
await saveCanvas(workspaceId, {
|
|
1783
|
+
version: '1.0',
|
|
1784
|
+
elements: [...],
|
|
1785
|
+
connections: [],
|
|
1786
|
+
viewport: { offset: { x: 0, y: 0 }, zoom: 1 }
|
|
1787
|
+
});
|
|
1788
|
+
```
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
#### `addCanvasElement()`
|
|
1793
|
+
|
|
1794
|
+
Add an element to the workspace canvas.
|
|
1795
|
+
|
|
1796
|
+
**Parameters:**
|
|
1797
|
+
|
|
1798
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1799
|
+
|
|
1800
|
+
- `element`: `CanvasElement` - The element to add
|
|
1801
|
+
|
|
1802
|
+
**Returns:** `Promise<string>`
|
|
1803
|
+
|
|
1804
|
+
**Example:**
|
|
1805
|
+
```typescript
|
|
1806
|
+
const elementId = await addCanvasElement(workspaceId, {
|
|
1807
|
+
id: crypto.randomUUID(),
|
|
1808
|
+
position: { x: 100, y: 100 },
|
|
1809
|
+
size: { width: 400, height: 300 },
|
|
1810
|
+
data: {
|
|
1811
|
+
nodeType: 'frame',
|
|
1812
|
+
label: 'Hero Section',
|
|
1813
|
+
frameId: 'frame-123'
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
```
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
#### `removeCanvasElement()`
|
|
1821
|
+
|
|
1822
|
+
Remove an element from the canvas.
|
|
1823
|
+
|
|
1824
|
+
**Parameters:**
|
|
1825
|
+
|
|
1826
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1827
|
+
|
|
1828
|
+
- `elementId`: `string` - The element ID to remove
|
|
1829
|
+
|
|
1830
|
+
**Returns:** `Promise<void>`
|
|
1831
|
+
|
|
1832
|
+
**Example:**
|
|
1833
|
+
```typescript
|
|
1834
|
+
await removeCanvasElement(workspaceId, elementId);
|
|
1835
|
+
```
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
|
|
1839
|
+
#### `updateCanvasElement()`
|
|
1840
|
+
|
|
1841
|
+
Update an element's properties.
|
|
1842
|
+
|
|
1843
|
+
**Parameters:**
|
|
1844
|
+
|
|
1845
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1846
|
+
|
|
1847
|
+
- `elementId`: `string` - The element ID
|
|
1848
|
+
|
|
1849
|
+
- `updates`: `Partial<CanvasElement>` - Properties to update
|
|
1850
|
+
|
|
1851
|
+
**Returns:** `Promise<void>`
|
|
1852
|
+
|
|
1853
|
+
**Example:**
|
|
1854
|
+
```typescript
|
|
1855
|
+
await updateCanvasElement(workspaceId, elementId, {
|
|
1856
|
+
position: { x: 200, y: 200 },
|
|
1857
|
+
data: { label: 'Updated Label' }
|
|
1858
|
+
});
|
|
1859
|
+
```
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
#### `addConnection()`
|
|
1864
|
+
|
|
1865
|
+
Add a connection between two elements.
|
|
1866
|
+
|
|
1867
|
+
**Parameters:**
|
|
1868
|
+
|
|
1869
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1870
|
+
|
|
1871
|
+
- `connection`: `Connection` - The connection to add
|
|
1872
|
+
|
|
1873
|
+
**Returns:** `Promise<string>`
|
|
1874
|
+
|
|
1875
|
+
**Example:**
|
|
1876
|
+
```typescript
|
|
1877
|
+
const connId = await addConnection(workspaceId, {
|
|
1878
|
+
id: crypto.randomUUID(),
|
|
1879
|
+
source: 'element-1',
|
|
1880
|
+
target: 'element-2'
|
|
1881
|
+
});
|
|
1882
|
+
```
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
#### `listDesigns()`
|
|
1887
|
+
|
|
1888
|
+
List designs in a workspace.
|
|
1889
|
+
|
|
1890
|
+
**Parameters:**
|
|
1891
|
+
|
|
1892
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1893
|
+
|
|
1894
|
+
**Returns:** `Promise<Design[]>`
|
|
1895
|
+
|
|
1896
|
+
**Example:**
|
|
1897
|
+
```typescript
|
|
1898
|
+
const designs = await listDesigns(workspaceId);
|
|
1899
|
+
```
|
|
1900
|
+
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
#### `saveDesign()`
|
|
1904
|
+
|
|
1905
|
+
Save a design.
|
|
1906
|
+
|
|
1907
|
+
**Parameters:**
|
|
1908
|
+
|
|
1909
|
+
- `workspaceId`: `string` - The workspace ID
|
|
1910
|
+
|
|
1911
|
+
- `design`: `Omit<Design, "_id" | "_creationTime" | "workspaceId">` - The design data
|
|
1912
|
+
|
|
1913
|
+
**Returns:** `Promise<string>`
|
|
1914
|
+
|
|
1915
|
+
**Example:**
|
|
1916
|
+
```typescript
|
|
1917
|
+
const designId = await saveDesign(workspaceId, {
|
|
1918
|
+
name: 'Homepage V1',
|
|
1919
|
+
slug: 'homepage-v1',
|
|
1920
|
+
elements: [...],
|
|
1921
|
+
status: 'draft'
|
|
1922
|
+
});
|
|
1923
|
+
```
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
### logger
|
|
1928
|
+
|
|
1929
|
+
Logger KSA - Knowledge, Skills, and Abilities for Semantic Logging Provides clean, user-friendly logging functions that emit structured logs for beautiful UI display using ai-elements components. Usage in agent code: ```typescript import { log, logPlan, logTask, logThinking, logSearch, logSource } from './ksa/logger'; // Simple log log.info("Starting analysis..."); // Planning logPlan("Research Project", "Gathering information about the topic", [ { title: "Search web", status: "complete" }, { title: "Analyze results", status: "active" }, { title: "Generate report", status: "pending" }, ]); // Task completion logTask("Collected 5 data sources", true); // Thinking/reasoning logThinking("Evaluating which sources are most relevant..."); // Search results logSearch("Web research", [ { title: "Article 1", url: "https://...", description: "..." }, ]); // Sources/citations logSource("Wikipedia", "https://wikipedia.org/...", "Background information"); ```
|
|
1930
|
+
|
|
1931
|
+
```typescript
|
|
1932
|
+
import { logPlan, logThinking, logTask, logSearch, logSource, logFile, logTool, createProgress } from './ksa/logger';
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1935
|
+
#### `logPlan()`
|
|
1936
|
+
|
|
1937
|
+
Log an execution plan with steps. Renders as a Plan component in the UI.
|
|
1938
|
+
|
|
1939
|
+
**Parameters:**
|
|
1940
|
+
|
|
1941
|
+
- `title`: `string` -
|
|
1942
|
+
|
|
1943
|
+
- `description`: `string` -
|
|
1944
|
+
|
|
1945
|
+
- `steps`: `PlanStep[]` -
|
|
1946
|
+
|
|
1947
|
+
**Returns:** `void`
|
|
1948
|
+
|
|
1949
|
+
**Example:**
|
|
1950
|
+
```typescript
|
|
1951
|
+
logPlan("Research Task", "Gathering market intelligence", [
|
|
1952
|
+
{ title: "Search competitors", status: "complete" },
|
|
1953
|
+
{ title: "Analyze pricing", status: "active" },
|
|
1954
|
+
{ title: "Generate report", status: "pending" },
|
|
1955
|
+
]);
|
|
1956
|
+
```
|
|
1957
|
+
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
#### `logThinking()`
|
|
1961
|
+
|
|
1962
|
+
Log a thinking/reasoning step. Renders as a ChainOfThought step in the UI.
|
|
1963
|
+
|
|
1964
|
+
**Parameters:**
|
|
1965
|
+
|
|
1966
|
+
- `message`: `string` -
|
|
1967
|
+
|
|
1968
|
+
- `description`: `string` (optional) -
|
|
1969
|
+
|
|
1970
|
+
**Returns:** `void`
|
|
1971
|
+
|
|
1972
|
+
**Example:**
|
|
1973
|
+
```typescript
|
|
1974
|
+
logThinking("Analyzing the data patterns to identify trends...");
|
|
1975
|
+
```
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
#### `logTask()`
|
|
1980
|
+
|
|
1981
|
+
Log a task as in-progress or completed. Renders as a Queue item in the UI.
|
|
1982
|
+
|
|
1983
|
+
**Parameters:**
|
|
1984
|
+
|
|
1985
|
+
- `label`: `string` -
|
|
1986
|
+
|
|
1987
|
+
- `completed`: `boolean` (optional) -
|
|
1988
|
+
|
|
1989
|
+
- `description`: `string` (optional) -
|
|
1990
|
+
|
|
1991
|
+
**Returns:** `void`
|
|
1992
|
+
|
|
1993
|
+
**Example:**
|
|
1994
|
+
```typescript
|
|
1995
|
+
logTask("Fetching user data", false); // In progress
|
|
1996
|
+
logTask("Fetched 150 records", true); // Completed
|
|
1997
|
+
```
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
#### `logSearch()`
|
|
2002
|
+
|
|
2003
|
+
Log search results. Renders as ChainOfThoughtSearchResults in the UI.
|
|
2004
|
+
|
|
2005
|
+
**Parameters:**
|
|
2006
|
+
|
|
2007
|
+
- `label`: `string` -
|
|
2008
|
+
|
|
2009
|
+
- `results`: `SearchResult[]` -
|
|
2010
|
+
|
|
2011
|
+
**Returns:** `void`
|
|
2012
|
+
|
|
2013
|
+
**Example:**
|
|
2014
|
+
```typescript
|
|
2015
|
+
logSearch("Market research", [
|
|
2016
|
+
{ title: "Industry Report 2024", url: "https://...", description: "..." },
|
|
2017
|
+
{ title: "Competitor Analysis", url: "https://...", description: "..." },
|
|
2018
|
+
]);
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
|
|
2022
|
+
|
|
2023
|
+
#### `logSource()`
|
|
2024
|
+
|
|
2025
|
+
Log a source/citation. Renders in the Sources component in the UI.
|
|
2026
|
+
|
|
2027
|
+
**Parameters:**
|
|
2028
|
+
|
|
2029
|
+
- `title`: `string` -
|
|
2030
|
+
|
|
2031
|
+
- `url`: `string` -
|
|
2032
|
+
|
|
2033
|
+
- `description`: `string` (optional) -
|
|
2034
|
+
|
|
2035
|
+
**Returns:** `void`
|
|
2036
|
+
|
|
2037
|
+
**Example:**
|
|
2038
|
+
```typescript
|
|
2039
|
+
logSource("Wikipedia", "https://en.wikipedia.org/...", "Background context");
|
|
2040
|
+
```
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
#### `logFile()`
|
|
2045
|
+
|
|
2046
|
+
Log a file operation. Renders with file icon in the UI.
|
|
2047
|
+
|
|
2048
|
+
**Parameters:**
|
|
2049
|
+
|
|
2050
|
+
- `operation`: `'read' | 'write' | 'edit'` -
|
|
2051
|
+
|
|
2052
|
+
- `path`: `string` -
|
|
2053
|
+
|
|
2054
|
+
- `label`: `string` -
|
|
2055
|
+
|
|
2056
|
+
**Returns:** `void`
|
|
2057
|
+
|
|
2058
|
+
**Example:**
|
|
2059
|
+
```typescript
|
|
2060
|
+
logFile("read", "/path/to/file.txt", "Reading configuration");
|
|
2061
|
+
logFile("write", "/output/report.pdf", "Generated PDF report");
|
|
2062
|
+
```
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
#### `logTool()`
|
|
2067
|
+
|
|
2068
|
+
Log a tool/action execution. Renders with tool icon in the UI.
|
|
2069
|
+
|
|
2070
|
+
**Parameters:**
|
|
2071
|
+
|
|
2072
|
+
- `toolName`: `string` -
|
|
2073
|
+
|
|
2074
|
+
- `label`: `string` -
|
|
2075
|
+
|
|
2076
|
+
- `details`: `string` (optional) -
|
|
2077
|
+
|
|
2078
|
+
**Returns:** `void`
|
|
2079
|
+
|
|
2080
|
+
**Example:**
|
|
2081
|
+
```typescript
|
|
2082
|
+
logTool("browser", "Taking screenshot of dashboard");
|
|
2083
|
+
logTool("api", "Calling external service");
|
|
2084
|
+
```
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
#### `createProgress()`
|
|
2089
|
+
|
|
2090
|
+
Create a progress tracker for multi-step operations.
|
|
2091
|
+
|
|
2092
|
+
**Parameters:**
|
|
2093
|
+
|
|
2094
|
+
- `title`: `string` -
|
|
2095
|
+
|
|
2096
|
+
- `totalSteps`: `number` -
|
|
2097
|
+
|
|
2098
|
+
**Returns:** `void`
|
|
2099
|
+
|
|
2100
|
+
**Example:**
|
|
2101
|
+
```typescript
|
|
2102
|
+
const progress = createProgress("Data Processing", 4);
|
|
2103
|
+
progress.step("Loading data");
|
|
2104
|
+
progress.step("Cleaning data");
|
|
2105
|
+
progress.step("Analyzing patterns");
|
|
2106
|
+
progress.complete("Processing complete");
|
|
2107
|
+
```
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
### frames
|
|
2112
|
+
|
|
2113
|
+
Frames KSA - Knowledge, Skills, and Abilities Create and manage visual frames (HTML/Tailwind/Svelte components). Frames are stored in Convex and rendered via SecureFrame in sandboxed iframes.
|
|
2114
|
+
|
|
2115
|
+
```typescript
|
|
2116
|
+
import { createFrame, getFrame, listFrames, updateFrame, deleteFrame, generateFrame, createPage, getPage, listPages, updatePage, getTemplates, getAdSpecs, snapshotFrame, rollbackFrame, trackView, trackConversion } from './ksa/frames';
|
|
2117
|
+
```
|
|
2118
|
+
|
|
2119
|
+
#### `createFrame()`
|
|
2120
|
+
|
|
2121
|
+
Create a new frame.
|
|
2122
|
+
|
|
2123
|
+
**Parameters:**
|
|
2124
|
+
|
|
2125
|
+
- `workspaceId`: `string` - The workspace ID
|
|
2126
|
+
|
|
2127
|
+
- `options`: `{
|
|
2128
|
+
name: string;
|
|
2129
|
+
code: string;
|
|
2130
|
+
codeType?: "html" | "svelte" | "htmx" | "tailwind";
|
|
2131
|
+
dimensions?: { width: number; height: number };
|
|
2132
|
+
adMeta?: Frame["adMeta"];
|
|
2133
|
+
sectionMeta?: Frame["sectionMeta"];
|
|
2134
|
+
cssVariables?: Record<string, string>;
|
|
2135
|
+
}` - Frame configuration
|
|
2136
|
+
|
|
2137
|
+
**Returns:** `Promise<string>`
|
|
2138
|
+
|
|
2139
|
+
**Example:**
|
|
2140
|
+
```typescript
|
|
2141
|
+
const frameId = await createFrame(workspaceId, {
|
|
2142
|
+
name: 'Call to Action',
|
|
2143
|
+
code: '<div class="bg-blue-600 text-white p-8 rounded-lg">...</div>',
|
|
2144
|
+
codeType: 'tailwind',
|
|
2145
|
+
dimensions: { width: 800, height: 400 }
|
|
2146
|
+
});
|
|
2147
|
+
```
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
#### `getFrame()`
|
|
2152
|
+
|
|
2153
|
+
Get a frame by ID.
|
|
2154
|
+
|
|
2155
|
+
**Parameters:**
|
|
2156
|
+
|
|
2157
|
+
- `frameId`: `string` - The frame ID
|
|
2158
|
+
|
|
2159
|
+
**Returns:** `Promise<Frame | null>`
|
|
2160
|
+
|
|
2161
|
+
**Example:**
|
|
2162
|
+
```typescript
|
|
2163
|
+
const frame = await getFrame(frameId);
|
|
2164
|
+
console.log(`${frame.name}: ${frame.codeType}`);
|
|
2165
|
+
```
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
#### `listFrames()`
|
|
2170
|
+
|
|
2171
|
+
List frames in a workspace.
|
|
2172
|
+
|
|
2173
|
+
**Parameters:**
|
|
2174
|
+
|
|
2175
|
+
- `workspaceId`: `string` - The workspace ID
|
|
2176
|
+
|
|
2177
|
+
**Returns:** `Promise<Frame[]>`
|
|
2178
|
+
|
|
2179
|
+
**Example:**
|
|
2180
|
+
```typescript
|
|
2181
|
+
const frames = await listFrames(workspaceId);
|
|
2182
|
+
for (const f of frames) {
|
|
2183
|
+
console.log(`${f.name} (${f.codeType}) - ${f.status}`);
|
|
2184
|
+
}
|
|
2185
|
+
```
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
#### `updateFrame()`
|
|
2190
|
+
|
|
2191
|
+
Update a frame.
|
|
2192
|
+
|
|
2193
|
+
**Parameters:**
|
|
2194
|
+
|
|
2195
|
+
- `frameId`: `string` - The frame ID
|
|
2196
|
+
|
|
2197
|
+
- `updates`: `{
|
|
2198
|
+
name?: string;
|
|
2199
|
+
code?: string;
|
|
2200
|
+
codeType?: "html" | "svelte" | "htmx" | "tailwind";
|
|
2201
|
+
dimensions?: { width: number; height: number };
|
|
2202
|
+
status?: "draft" | "published" | "archived";
|
|
2203
|
+
cssVariables?: Record<string, string>;
|
|
2204
|
+
}` - Properties to update
|
|
2205
|
+
|
|
2206
|
+
**Returns:** `Promise<void>`
|
|
2207
|
+
|
|
2208
|
+
**Example:**
|
|
2209
|
+
```typescript
|
|
2210
|
+
await updateFrame(frameId, {
|
|
2211
|
+
name: 'Updated Hero',
|
|
2212
|
+
code: '<section>...</section>',
|
|
2213
|
+
status: 'published'
|
|
2214
|
+
});
|
|
2215
|
+
```
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
2219
|
+
#### `deleteFrame()`
|
|
2220
|
+
|
|
2221
|
+
Delete a frame.
|
|
2222
|
+
|
|
2223
|
+
**Parameters:**
|
|
2224
|
+
|
|
2225
|
+
- `frameId`: `string` - The frame ID to delete
|
|
2226
|
+
|
|
2227
|
+
**Returns:** `Promise<void>`
|
|
2228
|
+
|
|
2229
|
+
**Example:**
|
|
2230
|
+
```typescript
|
|
2231
|
+
await deleteFrame(frameId);
|
|
2232
|
+
```
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
#### `generateFrame()`
|
|
2237
|
+
|
|
2238
|
+
Generate a frame from a description using AI. Creates HTML/Tailwind code based on the natural language description.
|
|
2239
|
+
|
|
2240
|
+
**Parameters:**
|
|
2241
|
+
|
|
2242
|
+
- `workspaceId`: `string` - The workspace ID
|
|
2243
|
+
|
|
2244
|
+
- `description`: `string` - Natural language description of the desired frame
|
|
2245
|
+
|
|
2246
|
+
- `options`: `{
|
|
2247
|
+
style?: "modern" | "minimal" | "bold" | "corporate";
|
|
2248
|
+
dimensions?: { width: number; height: number };
|
|
2249
|
+
codeType?: "html" | "tailwind" | "svelte";
|
|
2250
|
+
}` (optional) - Optional generation settings
|
|
2251
|
+
|
|
2252
|
+
**Returns:** `Promise<string>`
|
|
2253
|
+
|
|
2254
|
+
**Example:**
|
|
2255
|
+
```typescript
|
|
2256
|
+
const frameId = await generateFrame(workspaceId,
|
|
2257
|
+
'A modern hero section with a gradient background from purple to blue, ' +
|
|
2258
|
+
'centered white text with a headline and subheadline, and a glowing CTA button'
|
|
2259
|
+
);
|
|
2260
|
+
```
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
#### `createPage()`
|
|
2265
|
+
|
|
2266
|
+
Create a page (container for multiple frames).
|
|
2267
|
+
|
|
2268
|
+
**Parameters:**
|
|
2269
|
+
|
|
2270
|
+
- `workspaceId`: `string` - The workspace ID
|
|
2271
|
+
|
|
2272
|
+
- `options`: `{
|
|
2273
|
+
title: string;
|
|
2274
|
+
pageType?: "landing" | "multi";
|
|
2275
|
+
frameRefs?: Array<{ frameId: string; order: number }>;
|
|
2276
|
+
}` - Page configuration
|
|
2277
|
+
|
|
2278
|
+
**Returns:** `Promise<string>`
|
|
2279
|
+
|
|
2280
|
+
**Example:**
|
|
2281
|
+
```typescript
|
|
2282
|
+
const pageId = await createPage(workspaceId, {
|
|
2283
|
+
title: 'Landing Page',
|
|
2284
|
+
pageType: 'landing',
|
|
2285
|
+
frameRefs: [
|
|
2286
|
+
{ frameId: heroFrameId, order: 0 },
|
|
2287
|
+
{ frameId: featuresFrameId, order: 1 }
|
|
2288
|
+
]
|
|
2289
|
+
});
|
|
2290
|
+
```
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
#### `getPage()`
|
|
2295
|
+
|
|
2296
|
+
Get a page by ID.
|
|
2297
|
+
|
|
2298
|
+
**Parameters:**
|
|
2299
|
+
|
|
2300
|
+
- `pageId`: `string` - The page ID
|
|
2301
|
+
|
|
2302
|
+
**Returns:** `Promise<Page | null>`
|
|
2303
|
+
|
|
2304
|
+
**Example:**
|
|
2305
|
+
```typescript
|
|
2306
|
+
const page = await getPage(pageId);
|
|
2307
|
+
console.log(`${page.title} has ${page.frameRefs.length} frames`);
|
|
2308
|
+
```
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
#### `listPages()`
|
|
2313
|
+
|
|
2314
|
+
List pages in a workspace.
|
|
2315
|
+
|
|
2316
|
+
**Parameters:**
|
|
2317
|
+
|
|
2318
|
+
- `workspaceId`: `string` - The workspace ID
|
|
2319
|
+
|
|
2320
|
+
**Returns:** `Promise<Page[]>`
|
|
2321
|
+
|
|
2322
|
+
**Example:**
|
|
2323
|
+
```typescript
|
|
2324
|
+
const pages = await listPages(workspaceId);
|
|
2325
|
+
```
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
#### `updatePage()`
|
|
2330
|
+
|
|
2331
|
+
Update a page.
|
|
2332
|
+
|
|
2333
|
+
**Parameters:**
|
|
2334
|
+
|
|
2335
|
+
- `pageId`: `string` - The page ID
|
|
2336
|
+
|
|
2337
|
+
- `updates`: `{
|
|
2338
|
+
title?: string;
|
|
2339
|
+
frameRefs?: Array<{ frameId: string; order: number }>;
|
|
2340
|
+
isPublished?: boolean;
|
|
2341
|
+
status?: "draft" | "published" | "archived";
|
|
2342
|
+
}` - Properties to update
|
|
2343
|
+
|
|
2344
|
+
**Returns:** `Promise<void>`
|
|
2345
|
+
|
|
2346
|
+
**Example:**
|
|
2347
|
+
```typescript
|
|
2348
|
+
await updatePage(pageId, {
|
|
2349
|
+
title: 'Updated Landing Page',
|
|
2350
|
+
frameRefs: [{ frameId: newHeroId, order: 0 }],
|
|
2351
|
+
isPublished: true
|
|
2352
|
+
});
|
|
2353
|
+
```
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
#### `getTemplates()`
|
|
2358
|
+
|
|
2359
|
+
Get available frame templates.
|
|
2360
|
+
|
|
2361
|
+
**Returns:** `Promise<FrameTemplate[]>`
|
|
2362
|
+
|
|
2363
|
+
**Example:**
|
|
2364
|
+
```typescript
|
|
2365
|
+
const templates = await getTemplates();
|
|
2366
|
+
for (const t of templates) {
|
|
2367
|
+
console.log(`${t.name} (${t.category})`);
|
|
2368
|
+
}
|
|
2369
|
+
```
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
#### `getAdSpecs()`
|
|
2374
|
+
|
|
2375
|
+
Get ad specifications for different platforms.
|
|
2376
|
+
|
|
2377
|
+
**Parameters:**
|
|
2378
|
+
|
|
2379
|
+
- `platform`: `string` (optional) - Optional platform to filter by
|
|
2380
|
+
|
|
2381
|
+
**Returns:** `Promise<AdSpec[]>`
|
|
2382
|
+
|
|
2383
|
+
**Example:**
|
|
2384
|
+
```typescript
|
|
2385
|
+
const specs = await getAdSpecs('meta');
|
|
2386
|
+
for (const s of specs) {
|
|
2387
|
+
console.log(`${s.format}: ${s.width}x${s.height}`);
|
|
2388
|
+
}
|
|
2389
|
+
```
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
#### `snapshotFrame()`
|
|
2394
|
+
|
|
2395
|
+
Create a version snapshot of a frame.
|
|
2396
|
+
|
|
2397
|
+
**Parameters:**
|
|
2398
|
+
|
|
2399
|
+
- `frameId`: `string` - The frame ID
|
|
2400
|
+
|
|
2401
|
+
**Returns:** `Promise<string>`
|
|
2402
|
+
|
|
2403
|
+
**Example:**
|
|
2404
|
+
```typescript
|
|
2405
|
+
const versionId = await snapshotFrame(frameId);
|
|
2406
|
+
```
|
|
2407
|
+
|
|
2408
|
+
|
|
2409
|
+
|
|
2410
|
+
#### `rollbackFrame()`
|
|
2411
|
+
|
|
2412
|
+
Rollback a frame to a previous version.
|
|
2413
|
+
|
|
2414
|
+
**Parameters:**
|
|
2415
|
+
|
|
2416
|
+
- `versionId`: `string` - The version ID to rollback to
|
|
2417
|
+
|
|
2418
|
+
**Returns:** `Promise<void>`
|
|
2419
|
+
|
|
2420
|
+
**Example:**
|
|
2421
|
+
```typescript
|
|
2422
|
+
await rollbackFrame(versionId);
|
|
2423
|
+
```
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
#### `trackView()`
|
|
2428
|
+
|
|
2429
|
+
Track a view on a frame (for analytics).
|
|
2430
|
+
|
|
2431
|
+
**Parameters:**
|
|
2432
|
+
|
|
2433
|
+
- `frameId`: `string` - The frame ID
|
|
2434
|
+
|
|
2435
|
+
**Returns:** `Promise<void>`
|
|
2436
|
+
|
|
2437
|
+
**Example:**
|
|
2438
|
+
```typescript
|
|
2439
|
+
await trackView(frameId);
|
|
2440
|
+
```
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
#### `trackConversion()`
|
|
2445
|
+
|
|
2446
|
+
Track a conversion on a frame (for analytics).
|
|
2447
|
+
|
|
2448
|
+
**Parameters:**
|
|
2449
|
+
|
|
2450
|
+
- `frameId`: `string` - The frame ID
|
|
2451
|
+
|
|
2452
|
+
**Returns:** `Promise<void>`
|
|
2453
|
+
|
|
2454
|
+
**Example:**
|
|
2455
|
+
```typescript
|
|
2456
|
+
await trackConversion(frameId);
|
|
2457
|
+
```
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
### ads
|
|
2462
|
+
|
|
2463
|
+
Ads KSA - Knowledge, Skills, and Abilities Search and analyze advertising data from Meta Ad Library and Google Ads Transparency. Provides access to competitor ad creative, copy, and targeting data.
|
|
2464
|
+
|
|
2465
|
+
```typescript
|
|
2466
|
+
import { searchMetaCompanies, getMetaAdsByPageId, searchMetaAds, searchGoogleAds, searchAllAds } from './ksa/ads';
|
|
2467
|
+
```
|
|
2468
|
+
|
|
2469
|
+
#### `searchMetaCompanies()`
|
|
2470
|
+
|
|
2471
|
+
Search for companies/pages in the Meta Ad Library.
|
|
2472
|
+
|
|
2473
|
+
**Parameters:**
|
|
2474
|
+
|
|
2475
|
+
- `query`: `string` - Brand or company name to search
|
|
2476
|
+
|
|
2477
|
+
**Returns:** `Promise<MetaCompany[]>`
|
|
2478
|
+
|
|
2479
|
+
**Example:**
|
|
2480
|
+
```typescript
|
|
2481
|
+
const companies = await searchMetaCompanies('Liquid Death');
|
|
2482
|
+
console.log(companies[0].name, companies[0].pageId);
|
|
2483
|
+
```
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
#### `getMetaAdsByPageId()`
|
|
2488
|
+
|
|
2489
|
+
Get all ads for a specific Meta/Facebook page.
|
|
2490
|
+
|
|
2491
|
+
**Parameters:**
|
|
2492
|
+
|
|
2493
|
+
- `pageId`: `string` - Facebook Page ID (from searchMetaCompanies)
|
|
2494
|
+
|
|
2495
|
+
- `options`: `{
|
|
2496
|
+
status?: "active" | "inactive" | "all";
|
|
2497
|
+
maxAds?: number;
|
|
2498
|
+
}` (optional) - Optional filters
|
|
2499
|
+
|
|
2500
|
+
**Returns:** `Promise<MetaAd[]>`
|
|
2501
|
+
|
|
2502
|
+
**Example:**
|
|
2503
|
+
```typescript
|
|
2504
|
+
const companies = await searchMetaCompanies('Liquid Death');
|
|
2505
|
+
const ads = await getMetaAdsByPageId(companies[0].pageId);
|
|
2506
|
+
console.log(`Found ${ads.length} ads`);
|
|
2507
|
+
```
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
#### `searchMetaAds()`
|
|
2512
|
+
|
|
2513
|
+
Search for Meta ads by brand name (convenience function). Combines searchMetaCompanies + getMetaAdsByPageId.
|
|
2514
|
+
|
|
2515
|
+
**Parameters:**
|
|
2516
|
+
|
|
2517
|
+
- `brandName`: `string` - Brand or company name
|
|
2518
|
+
|
|
2519
|
+
- `options`: `{
|
|
2520
|
+
status?: "active" | "inactive" | "all";
|
|
2521
|
+
maxAds?: number;
|
|
2522
|
+
}` (optional) - Optional filters
|
|
2523
|
+
|
|
2524
|
+
**Returns:** `Promise<AdSearchResult>`
|
|
2525
|
+
|
|
2526
|
+
**Example:**
|
|
2527
|
+
```typescript
|
|
2528
|
+
const result = await searchMetaAds('Liquid Death');
|
|
2529
|
+
console.log(`${result.company?.name}: ${result.ads.length} ads`);
|
|
2530
|
+
for (const ad of result.ads.slice(0, 5)) {
|
|
2531
|
+
console.log(`- ${ad.body?.substring(0, 100)}...`);
|
|
2532
|
+
}
|
|
2533
|
+
```
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
#### `searchGoogleAds()`
|
|
2538
|
+
|
|
2539
|
+
Search for Google ads by domain.
|
|
2540
|
+
|
|
2541
|
+
**Parameters:**
|
|
2542
|
+
|
|
2543
|
+
- `domain`: `string` - Advertiser domain (e.g., 'liquiddeath.com')
|
|
2544
|
+
|
|
2545
|
+
- `options`: `{
|
|
2546
|
+
region?: string;
|
|
2547
|
+
maxAds?: number;
|
|
2548
|
+
}` (optional) - Optional filters
|
|
2549
|
+
|
|
2550
|
+
**Returns:** `Promise<GoogleAdSearchResult>`
|
|
2551
|
+
|
|
2552
|
+
**Example:**
|
|
2553
|
+
```typescript
|
|
2554
|
+
const result = await searchGoogleAds('liquiddeath.com');
|
|
2555
|
+
console.log(`Found ${result.ads.length} Google ads`);
|
|
2556
|
+
```
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
|
|
2560
|
+
#### `searchAllAds()`
|
|
2561
|
+
|
|
2562
|
+
Search for ads across both Meta and Google platforms.
|
|
2563
|
+
|
|
2564
|
+
**Parameters:**
|
|
2565
|
+
|
|
2566
|
+
- `brandName`: `string` - Brand name for Meta search
|
|
2567
|
+
|
|
2568
|
+
- `domain`: `string` (optional) - Domain for Google search (optional, derived from brand if not provided)
|
|
2569
|
+
|
|
2570
|
+
- `options`: `{
|
|
2571
|
+
maxAds?: number;
|
|
2572
|
+
metaOnly?: boolean;
|
|
2573
|
+
googleOnly?: boolean;
|
|
2574
|
+
}` (optional) - Search options
|
|
2575
|
+
|
|
2576
|
+
**Returns:** `Promise<{
|
|
2577
|
+
meta: AdSearchResult;
|
|
2578
|
+
google: GoogleAdSearchResult;
|
|
2579
|
+
}>`
|
|
2580
|
+
|
|
2581
|
+
**Example:**
|
|
2582
|
+
```typescript
|
|
2583
|
+
const { meta, google } = await searchAllAds('Liquid Death', 'liquiddeath.com');
|
|
2584
|
+
console.log(`Meta: ${meta.ads.length} ads, Google: ${google.ads.length} ads`);
|
|
2585
|
+
```
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
### companies
|
|
2590
|
+
|
|
2591
|
+
Companies KSA - Knowledge, Skills, and Abilities Enrich and lookup company information including: - Domain/website enrichment - Company search - Industry classification - Employee counts, funding, tech stack
|
|
2592
|
+
|
|
2593
|
+
```typescript
|
|
2594
|
+
import { enrichDomain, enrichCompany, bulkEnrich, searchCompanies, findSimilar, companiesByTech, getTechStack } from './ksa/companies';
|
|
2595
|
+
```
|
|
2596
|
+
|
|
2597
|
+
#### `enrichDomain()`
|
|
2598
|
+
|
|
2599
|
+
Enrich a domain with company information.
|
|
2600
|
+
|
|
2601
|
+
**Parameters:**
|
|
2602
|
+
|
|
2603
|
+
- `domain`: `string` - Company domain (e.g., 'stripe.com')
|
|
2604
|
+
|
|
2605
|
+
**Returns:** `Promise<Company>`
|
|
2606
|
+
|
|
2607
|
+
**Example:**
|
|
2608
|
+
```typescript
|
|
2609
|
+
const company = await enrichDomain('stripe.com');
|
|
2610
|
+
console.log(`${company.name}: ${company.employeeRange} employees`);
|
|
2611
|
+
console.log(`Industry: ${company.industry}`);
|
|
2612
|
+
```
|
|
2613
|
+
|
|
2614
|
+
|
|
2615
|
+
|
|
2616
|
+
#### `enrichCompany()`
|
|
2617
|
+
|
|
2618
|
+
Enrich a company by name.
|
|
2619
|
+
|
|
2620
|
+
**Parameters:**
|
|
2621
|
+
|
|
2622
|
+
- `name`: `string` - Company name
|
|
2623
|
+
|
|
2624
|
+
**Returns:** `Promise<Company>`
|
|
2625
|
+
|
|
2626
|
+
**Example:**
|
|
2627
|
+
```typescript
|
|
2628
|
+
const company = await enrichCompany('Stripe');
|
|
2629
|
+
console.log(`Domain: ${company.domain}`);
|
|
2630
|
+
console.log(`Founded: ${company.foundedYear}`);
|
|
2631
|
+
```
|
|
2632
|
+
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
#### `bulkEnrich()`
|
|
2636
|
+
|
|
2637
|
+
Bulk enrich multiple domains.
|
|
2638
|
+
|
|
2639
|
+
**Parameters:**
|
|
2640
|
+
|
|
2641
|
+
- `domains`: `string[]` - Array of domains to enrich
|
|
2642
|
+
|
|
2643
|
+
**Returns:** `Promise<Company[]>`
|
|
2644
|
+
|
|
2645
|
+
**Example:**
|
|
2646
|
+
```typescript
|
|
2647
|
+
const companies = await bulkEnrich(['stripe.com', 'notion.so', 'figma.com']);
|
|
2648
|
+
for (const c of companies) {
|
|
2649
|
+
console.log(`${c.name}: ${c.industry}`);
|
|
2650
|
+
}
|
|
2651
|
+
```
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
#### `searchCompanies()`
|
|
2656
|
+
|
|
2657
|
+
Search for companies by various criteria.
|
|
2658
|
+
|
|
2659
|
+
**Parameters:**
|
|
2660
|
+
|
|
2661
|
+
- `options`: `{
|
|
2662
|
+
query?: string;
|
|
2663
|
+
industry?: string;
|
|
2664
|
+
country?: string;
|
|
2665
|
+
state?: string;
|
|
2666
|
+
city?: string;
|
|
2667
|
+
employeeMin?: number;
|
|
2668
|
+
employeeMax?: number;
|
|
2669
|
+
revenueMin?: string;
|
|
2670
|
+
revenueMax?: string;
|
|
2671
|
+
techStack?: string[];
|
|
2672
|
+
limit?: number;
|
|
2673
|
+
page?: number;
|
|
2674
|
+
}` - Search options
|
|
2675
|
+
|
|
2676
|
+
**Returns:** `Promise<CompanySearchResult>`
|
|
2677
|
+
|
|
2678
|
+
**Example:**
|
|
2679
|
+
```typescript
|
|
2680
|
+
const results = await searchCompanies({
|
|
2681
|
+
industry: 'SaaS',
|
|
2682
|
+
employeeMin: 50,
|
|
2683
|
+
employeeMax: 500,
|
|
2684
|
+
country: 'US'
|
|
2685
|
+
});
|
|
2686
|
+
for (const c of results.companies) {
|
|
2687
|
+
console.log(`${c.name} (${c.domain}): ${c.employeeRange}`);
|
|
2688
|
+
}
|
|
2689
|
+
```
|
|
2690
|
+
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
#### `findSimilar()`
|
|
2694
|
+
|
|
2695
|
+
Find similar companies to a given domain.
|
|
2696
|
+
|
|
2697
|
+
**Parameters:**
|
|
2698
|
+
|
|
2699
|
+
- `domain`: `string` - Reference company domain
|
|
2700
|
+
|
|
2701
|
+
- `limit`: `any` (optional) - Maximum results (default: 10)
|
|
2702
|
+
|
|
2703
|
+
**Returns:** `Promise<Company[]>`
|
|
2704
|
+
|
|
2705
|
+
**Example:**
|
|
2706
|
+
```typescript
|
|
2707
|
+
const similar = await findSimilar('stripe.com', 5);
|
|
2708
|
+
for (const c of similar) {
|
|
2709
|
+
console.log(`${c.name}: ${c.description?.slice(0, 50)}`);
|
|
2710
|
+
}
|
|
2711
|
+
```
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
#### `companiesByTech()`
|
|
2716
|
+
|
|
2717
|
+
Get companies using a specific technology.
|
|
2718
|
+
|
|
2719
|
+
**Parameters:**
|
|
2720
|
+
|
|
2721
|
+
- `technology`: `string` - Technology name (e.g., 'React', 'Stripe', 'AWS')
|
|
2722
|
+
|
|
2723
|
+
- `options`: `{
|
|
2724
|
+
country?: string;
|
|
2725
|
+
employeeMin?: number;
|
|
2726
|
+
limit?: number;
|
|
2727
|
+
}` (optional) - Additional filters
|
|
2728
|
+
|
|
2729
|
+
**Returns:** `Promise<Company[]>`
|
|
2730
|
+
|
|
2731
|
+
**Example:**
|
|
2732
|
+
```typescript
|
|
2733
|
+
const companies = await companiesByTech('Stripe', { country: 'US', limit: 20 });
|
|
2734
|
+
console.log(`Found ${companies.length} companies using Stripe`);
|
|
2735
|
+
```
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
|
|
2739
|
+
#### `getTechStack()`
|
|
2740
|
+
|
|
2741
|
+
Get company tech stack.
|
|
2742
|
+
|
|
2743
|
+
**Parameters:**
|
|
2744
|
+
|
|
2745
|
+
- `domain`: `string` - Company domain
|
|
2746
|
+
|
|
2747
|
+
**Returns:** `Promise<string[]>`
|
|
2748
|
+
|
|
2749
|
+
**Example:**
|
|
2750
|
+
```typescript
|
|
2751
|
+
const tech = await getTechStack('stripe.com');
|
|
2752
|
+
console.log('Technologies:', tech.join(', '));
|
|
2753
|
+
```
|
|
2754
|
+
|
|
2755
|
+
|
|
2756
|
+
|
|
2757
|
+
## Deliverables KSAs (Output Formats)
|
|
2758
|
+
|
|
2759
|
+
### pdf
|
|
2760
|
+
|
|
2761
|
+
PDF Skills Functions for generating PDF documents from markdown. PDFs are automatically uploaded to cloud storage after generation.
|
|
2762
|
+
|
|
2763
|
+
```typescript
|
|
2764
|
+
import { generate } from './ksa/pdf';
|
|
2765
|
+
```
|
|
2766
|
+
|
|
2767
|
+
#### `generate()`
|
|
2768
|
+
|
|
2769
|
+
Generate a PDF from markdown content. The PDF is: 1. Generated locally using the generate-pdf CLI 2. Automatically uploaded to cloud storage (thread or card artifacts)
|
|
2770
|
+
|
|
2771
|
+
**Parameters:**
|
|
2772
|
+
|
|
2773
|
+
- `params`: `GenerateParams` - Object with filename, content, and optional title
|
|
2774
|
+
|
|
2775
|
+
**Returns:** `Promise<PdfResult>`
|
|
2776
|
+
|
|
2777
|
+
**Example:**
|
|
2778
|
+
```typescript
|
|
2779
|
+
const result = await generate({
|
|
2780
|
+
filename: 'competitive-analysis',
|
|
2781
|
+
content: '# Competitive Analysis\n\n## Overview\n...',
|
|
2782
|
+
title: 'Competitive Analysis Report'
|
|
2783
|
+
});
|
|
2784
|
+
|
|
2785
|
+
if (result.success) {
|
|
2786
|
+
console.log(`PDF uploaded: ${result.name} (${result.artifactId})`);
|
|
2787
|
+
}
|
|
2788
|
+
```
|
|
2789
|
+
|
|
2790
|
+
|
|
2791
|
+
|
|
2792
|
+
### email
|
|
2793
|
+
|
|
2794
|
+
Email KSA - Knowledge, Skills, and Abilities Send emails via SendGrid. Supports: - Plain text and HTML emails - Multiple recipients (to, cc, bcc) - Attachments - Templates
|
|
2795
|
+
|
|
2796
|
+
```typescript
|
|
2797
|
+
import { send, sendText, sendHtml, sendWithAttachment, sendTemplate, sendBulk } from './ksa/email';
|
|
2798
|
+
```
|
|
2799
|
+
|
|
2800
|
+
#### `send()`
|
|
2801
|
+
|
|
2802
|
+
Send an email.
|
|
2803
|
+
|
|
2804
|
+
**Parameters:**
|
|
2805
|
+
|
|
2806
|
+
- `options`: `EmailOptions` - Email options
|
|
2807
|
+
|
|
2808
|
+
**Returns:** `Promise<EmailResult>`
|
|
2809
|
+
|
|
2810
|
+
**Example:**
|
|
2811
|
+
```typescript
|
|
2812
|
+
await send({
|
|
2813
|
+
to: 'user@example.com',
|
|
2814
|
+
subject: 'Hello from the agent',
|
|
2815
|
+
text: 'This is a test email sent by the AI agent.'
|
|
2816
|
+
});
|
|
2817
|
+
```
|
|
2818
|
+
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
#### `sendText()`
|
|
2822
|
+
|
|
2823
|
+
Send a simple text email.
|
|
2824
|
+
|
|
2825
|
+
**Parameters:**
|
|
2826
|
+
|
|
2827
|
+
- `to`: `string` - Recipient email
|
|
2828
|
+
|
|
2829
|
+
- `subject`: `string` - Email subject
|
|
2830
|
+
|
|
2831
|
+
- `body`: `string` - Email body text
|
|
2832
|
+
|
|
2833
|
+
**Returns:** `Promise<EmailResult>`
|
|
2834
|
+
|
|
2835
|
+
**Example:**
|
|
2836
|
+
```typescript
|
|
2837
|
+
await sendText('user@example.com', 'Task Complete', 'Your report is ready.');
|
|
2838
|
+
```
|
|
2839
|
+
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
#### `sendHtml()`
|
|
2843
|
+
|
|
2844
|
+
Send an HTML email.
|
|
2845
|
+
|
|
2846
|
+
**Parameters:**
|
|
2847
|
+
|
|
2848
|
+
- `to`: `string` - Recipient email
|
|
2849
|
+
|
|
2850
|
+
- `subject`: `string` - Email subject
|
|
2851
|
+
|
|
2852
|
+
- `html`: `string` - HTML body
|
|
2853
|
+
|
|
2854
|
+
**Returns:** `Promise<EmailResult>`
|
|
2855
|
+
|
|
2856
|
+
**Example:**
|
|
2857
|
+
```typescript
|
|
2858
|
+
await sendHtml('user@example.com', 'Report', '<h1>Monthly Report</h1><p>...</p>');
|
|
2859
|
+
```
|
|
2860
|
+
|
|
2861
|
+
|
|
2862
|
+
|
|
2863
|
+
#### `sendWithAttachment()`
|
|
2864
|
+
|
|
2865
|
+
Send an email with an attachment.
|
|
2866
|
+
|
|
2867
|
+
**Parameters:**
|
|
2868
|
+
|
|
2869
|
+
- `to`: `string` - Recipient email
|
|
2870
|
+
|
|
2871
|
+
- `subject`: `string` - Email subject
|
|
2872
|
+
|
|
2873
|
+
- `body`: `string` - Email body
|
|
2874
|
+
|
|
2875
|
+
- `attachment`: `{
|
|
2876
|
+
content: string;
|
|
2877
|
+
filename: string;
|
|
2878
|
+
type?: string;
|
|
2879
|
+
}` - Attachment details
|
|
2880
|
+
|
|
2881
|
+
**Returns:** `Promise<EmailResult>`
|
|
2882
|
+
|
|
2883
|
+
**Example:**
|
|
2884
|
+
```typescript
|
|
2885
|
+
import { read } from './ksa/file';
|
|
2886
|
+
|
|
2887
|
+
// Read file as base64
|
|
2888
|
+
const pdfContent = await read('/home/user/artifacts/report.pdf', { encoding: 'base64' });
|
|
2889
|
+
|
|
2890
|
+
await sendWithAttachment(
|
|
2891
|
+
'user@example.com',
|
|
2892
|
+
'Your Report',
|
|
2893
|
+
'Please find the report attached.',
|
|
2894
|
+
{
|
|
2895
|
+
content: pdfContent,
|
|
2896
|
+
filename: 'report.pdf',
|
|
2897
|
+
type: 'application/pdf'
|
|
2898
|
+
}
|
|
2899
|
+
);
|
|
2900
|
+
```
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
#### `sendTemplate()`
|
|
2905
|
+
|
|
2906
|
+
Send an email using a SendGrid template.
|
|
2907
|
+
|
|
2908
|
+
**Parameters:**
|
|
2909
|
+
|
|
2910
|
+
- `to`: `string` - Recipient email
|
|
2911
|
+
|
|
2912
|
+
- `templateId`: `string` - SendGrid template ID
|
|
2913
|
+
|
|
2914
|
+
- `data`: `Record<string, any>` - Dynamic template data
|
|
2915
|
+
|
|
2916
|
+
- `subject`: `string` (optional) - Optional subject override
|
|
2917
|
+
|
|
2918
|
+
**Returns:** `Promise<EmailResult>`
|
|
2919
|
+
|
|
2920
|
+
**Example:**
|
|
2921
|
+
```typescript
|
|
2922
|
+
await sendTemplate(
|
|
2923
|
+
'user@example.com',
|
|
2924
|
+
'd-abc123...',
|
|
2925
|
+
{ name: 'John', orderNumber: '12345' }
|
|
2926
|
+
);
|
|
2927
|
+
```
|
|
2928
|
+
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
#### `sendBulk()`
|
|
2932
|
+
|
|
2933
|
+
Send emails to multiple recipients.
|
|
2934
|
+
|
|
2935
|
+
**Parameters:**
|
|
2936
|
+
|
|
2937
|
+
- `recipients`: `string[]` - Array of recipient emails
|
|
2938
|
+
|
|
2939
|
+
- `subject`: `string` - Email subject
|
|
2940
|
+
|
|
2941
|
+
- `body`: `string` - Email body
|
|
2942
|
+
|
|
2943
|
+
**Returns:** `Promise<EmailResult>`
|
|
2944
|
+
|
|
2945
|
+
**Example:**
|
|
2946
|
+
```typescript
|
|
2947
|
+
await sendBulk(
|
|
2948
|
+
['user1@example.com', 'user2@example.com'],
|
|
2949
|
+
'Team Update',
|
|
2950
|
+
'Here is the weekly team update...'
|
|
2951
|
+
);
|
|
2952
|
+
```
|
|
2953
|
+
|
|
2954
|
+
|