@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,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KSA Registry - Auto-generated for Lakitu
|
|
3
|
+
*
|
|
4
|
+
* DO NOT EDIT MANUALLY - run `bun generate:ksa`
|
|
5
|
+
*
|
|
6
|
+
* Generated at: 2026-01-17T17:36:27.662Z
|
|
7
|
+
*
|
|
8
|
+
* This file is generated from the source of truth at:
|
|
9
|
+
* packages/lakitu/ksa/*.ts
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Types (defined inline for sandbox compatibility)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
export type KSACategory = "core" | "skills" | "deliverables";
|
|
17
|
+
export type KSAGroup = "research";
|
|
18
|
+
|
|
19
|
+
export interface KSAInfo {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
category: KSACategory;
|
|
23
|
+
group?: KSAGroup;
|
|
24
|
+
functions: string[];
|
|
25
|
+
importPath: string;
|
|
26
|
+
servicePaths: string[];
|
|
27
|
+
isLocal: boolean;
|
|
28
|
+
icon?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Generated Registry
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
export const KSA_REGISTRY: KSAInfo[] = [
|
|
36
|
+
{
|
|
37
|
+
name: "browser",
|
|
38
|
+
description: "Browser Skills Functions for browser automation. Uses the agent-browser CLI for headless browser control.",
|
|
39
|
+
category: "skills" as const,
|
|
40
|
+
functions: ["open", "screenshot", "click", "type", "getHtml", "getText", "closeBrowser"],
|
|
41
|
+
importPath: "./ksa/browser",
|
|
42
|
+
servicePaths: [],
|
|
43
|
+
isLocal: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "brandscan",
|
|
47
|
+
description: "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.",
|
|
48
|
+
category: "skills" as const,
|
|
49
|
+
functions: ["lookupBrand", "searchBrands", "getBrandFromLibrary", "getBrandData", "getBrandSummary", "listBrands", "getBrandByDomain", "listBrandAssets", "listBrandProducts", "listBrandAds"],
|
|
50
|
+
importPath: "./ksa/brandscan",
|
|
51
|
+
servicePaths: ["features.brands.agentBrandLookup.lookupBrand", "features.brands.agentBrandLookup.searchBrands", "features.brands.agentBrandLookup.getBrandFromLibrary", "features.brands.agentBrandLookup.listBrandAssets", "features.brands.agentBrandLookup.listBrandProducts", "features.brands.agentBrandLookup.listBrandAds", "features.brands.core.crud.get", "features.brands.core.products.getBrandIntelligenceSummary", "features.brands.core.crud.list", "features.brands.core.crud.getByDomain"],
|
|
52
|
+
isLocal: false,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "boardDSL",
|
|
56
|
+
description: "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.",
|
|
57
|
+
category: "skills" as const,
|
|
58
|
+
functions: ["createBoardFromYAML", "validateBoardYAML"],
|
|
59
|
+
importPath: "./ksa/boardDSL",
|
|
60
|
+
servicePaths: ["internal.features.kanban.boards.createInternal", "internal.features.kanban.boards.addTaskInternal", "internal.features.kanban.boards.updateTriggerInternal"],
|
|
61
|
+
isLocal: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "social",
|
|
65
|
+
description: "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.",
|
|
66
|
+
category: "skills" as const,
|
|
67
|
+
functions: ["tiktokProfile", "instagramProfile", "youtubeProfile", "twitterProfile", "linkedinProfile", "tiktokPosts", "instagramPosts", "twitterPosts", "searchSocial"],
|
|
68
|
+
importPath: "./ksa/social",
|
|
69
|
+
servicePaths: ["services.ScrapeCreators.internal.call"],
|
|
70
|
+
isLocal: false,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "news",
|
|
74
|
+
description: "News KSA - Knowledge, Skills, and Abilities Advanced news research and monitoring via APITube. Supports entity tracking, sentiment analysis, brand monitoring.",
|
|
75
|
+
category: "skills" as const,
|
|
76
|
+
functions: ["search", "trending", "breakingNews", "monitorBrand", "monitorOrganization", "analyzeSentiment", "compareTopics"],
|
|
77
|
+
importPath: "./ksa/news",
|
|
78
|
+
servicePaths: ["services.APITube.internal.call"],
|
|
79
|
+
isLocal: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "boards",
|
|
83
|
+
description: "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.",
|
|
84
|
+
category: "skills" as const,
|
|
85
|
+
functions: ["listBoards", "getBoard", "createBoard", "setTrigger", "addCard", "runCard", "getCardStatus", "waitForCard", "stopCard", "getCompletedCards", "listTemplates", "getTemplate", "createBoardFromTemplate"],
|
|
86
|
+
importPath: "./ksa/boards",
|
|
87
|
+
servicePaths: ["features.kanban.boards.list", "features.kanban.boards.get", "features.kanban.templates.createBoardFromTemplate", "internal.features.kanban.boards.createInternal", "internal.features.kanban.boards.addTaskInternal", "internal.features.kanban.boards.updateTriggerInternal", "internal.features.kanban.boards.createCardInternal", "agent.workflows.agentBoard.startCardExecution", "features.kanban.boards.getCard", "features.kanban.boards.stopCard", "features.kanban.boards.getCompletedCards", "features.kanban.templates.listTemplates", "features.kanban.templates.getTemplate"],
|
|
88
|
+
isLocal: false,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "beads",
|
|
92
|
+
description: "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.",
|
|
93
|
+
category: "core" as const,
|
|
94
|
+
functions: ["create", "update", "close", "list", "getReady", "get"],
|
|
95
|
+
importPath: "./ksa/beads",
|
|
96
|
+
servicePaths: [],
|
|
97
|
+
isLocal: true,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "pdf",
|
|
101
|
+
description: "PDF Skills Functions for generating PDF documents from markdown. PDFs are automatically uploaded to cloud storage after generation.",
|
|
102
|
+
category: "deliverables" as const,
|
|
103
|
+
functions: ["generate"],
|
|
104
|
+
importPath: "./ksa/pdf",
|
|
105
|
+
servicePaths: ["internal.agent.workflows.crudThreads.saveThreadArtifact", "features.kanban.artifacts.saveArtifactWithBackup"],
|
|
106
|
+
isLocal: false,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "web",
|
|
110
|
+
description: "Web KSA - Knowledge, Skills, and Abilities Functions for web search and content extraction. Import and use these in your code.",
|
|
111
|
+
category: "skills" as const,
|
|
112
|
+
functions: ["search", "scrape", "news", "brandNews", "webResearch"],
|
|
113
|
+
importPath: "./ksa/web",
|
|
114
|
+
servicePaths: ["services.Valyu.internal.search", "services.Valyu.internal.contents", "services.APITube.internal.call"],
|
|
115
|
+
isLocal: false,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "artifacts",
|
|
119
|
+
description: "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",
|
|
120
|
+
category: "core" as const,
|
|
121
|
+
functions: ["setGatewayConfig", "saveArtifact", "readArtifact", "listArtifacts"],
|
|
122
|
+
importPath: "./ksa/artifacts",
|
|
123
|
+
servicePaths: ["internal.agent.workflows.crudThreads.saveThreadArtifact", "features.kanban.artifacts.saveArtifactWithBackup", "features.kanban.artifacts.getArtifact", "internal.agent.workflows.crudThreads.listThreadArtifactsInternal", "features.kanban.artifacts.listCardArtifacts", "internal.features.workspaces.internal.getCanvasInternal", "internal.features.workspaces.internal.saveCanvasInternal"],
|
|
124
|
+
isLocal: false,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "workspaces",
|
|
128
|
+
description: "Workspaces KSA - Knowledge, Skills, and Abilities Create and manage design workspaces with canvas tools. Workspaces contain frames, designs, and collaborative elements.",
|
|
129
|
+
category: "skills" as const,
|
|
130
|
+
functions: ["listWorkspaces", "createWorkspace", "getWorkspace", "updateWorkspaceName", "deleteWorkspace", "getCanvas", "saveCanvas", "addCanvasElement", "removeCanvasElement", "updateCanvasElement", "addConnection", "listDesigns", "saveDesign"],
|
|
131
|
+
importPath: "./ksa/workspaces",
|
|
132
|
+
servicePaths: ["features.workspaces.workspaces.list", "features.workspaces.workspaces.create", "features.workspaces.workspaces.get", "features.workspaces.workspaces.updateName", "features.workspaces.workspaces.remove", "features.workspaces.canvas.get", "features.workspaces.canvas.save", "features.workspaces.designs.listDesigns", "features.workspaces.designs.saveDesign"],
|
|
133
|
+
isLocal: false,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "logger",
|
|
137
|
+
description: "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\"); ```",
|
|
138
|
+
category: "skills" as const,
|
|
139
|
+
functions: ["logPlan", "logThinking", "logTask", "logSearch", "logSource", "logFile", "logTool", "createProgress"],
|
|
140
|
+
importPath: "./ksa/logger",
|
|
141
|
+
servicePaths: [],
|
|
142
|
+
isLocal: true,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "file",
|
|
146
|
+
description: "File Skills Functions for reading, writing, and searching files. These operate on the local filesystem in the sandbox.",
|
|
147
|
+
category: "core" as const,
|
|
148
|
+
functions: ["read", "write", "edit", "glob", "grep", "ls"],
|
|
149
|
+
importPath: "./ksa/file",
|
|
150
|
+
servicePaths: [],
|
|
151
|
+
isLocal: true,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "frames",
|
|
155
|
+
description: "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.",
|
|
156
|
+
category: "skills" as const,
|
|
157
|
+
functions: ["createFrame", "getFrame", "listFrames", "updateFrame", "deleteFrame", "generateFrame", "createPage", "getPage", "listPages", "updatePage", "getTemplates", "getAdSpecs", "snapshotFrame", "rollbackFrame", "trackView", "trackConversion"],
|
|
158
|
+
importPath: "./ksa/frames",
|
|
159
|
+
servicePaths: ["internal.features.frames.internal.createFrameInternal", "internal.features.frames.internal.getFrameInternal", "internal.features.frames.internal.listFramesInternal", "internal.features.frames.internal.updateFrameInternal", "internal.features.frames.internal.deleteFrameInternal", "internal.features.frames.internal.createPageInternal", "internal.features.frames.internal.getPageInternal", "internal.features.frames.internal.listPagesInternal", "internal.features.frames.internal.updatePageInternal", "internal.features.frames.internal.snapshotFrameInternal", "internal.features.frames.internal.rollbackFrameInternal", "internal.features.workspaces.internal.getCanvasInternal", "internal.features.workspaces.internal.saveCanvasInternal", "services.OpenRouter.internal.chat", "features.frames.templates.listTemplates", "features.frames.ads.getAdSpecs", "features.frames.analytics.trackView", "features.frames.analytics.trackConversion"],
|
|
160
|
+
isLocal: false,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "ads",
|
|
164
|
+
description: "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.",
|
|
165
|
+
category: "skills" as const,
|
|
166
|
+
functions: ["searchMetaCompanies", "getMetaAdsByPageId", "searchMetaAds", "searchGoogleAds", "searchAllAds"],
|
|
167
|
+
importPath: "./ksa/ads",
|
|
168
|
+
servicePaths: ["services.ScrapeCreators.internal.call"],
|
|
169
|
+
isLocal: false,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "context",
|
|
173
|
+
description: "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.",
|
|
174
|
+
category: "core" as const,
|
|
175
|
+
functions: ["setGatewayConfig", "getContext", "getVariable", "setVariable"],
|
|
176
|
+
importPath: "./ksa/context",
|
|
177
|
+
servicePaths: ["features.kanban.executor.getCardContext", "features.kanban.executor.setVariable"],
|
|
178
|
+
isLocal: false,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "companies",
|
|
182
|
+
description: "Companies KSA - Knowledge, Skills, and Abilities Enrich and lookup company information including: - Domain/website enrichment - Company search - Industry classification - Employee counts, funding, tech stack",
|
|
183
|
+
category: "skills" as const,
|
|
184
|
+
functions: ["enrichDomain", "enrichCompany", "bulkEnrich", "searchCompanies", "findSimilar", "companiesByTech", "getTechStack"],
|
|
185
|
+
importPath: "./ksa/companies",
|
|
186
|
+
servicePaths: ["services.TheCompanies.internal.call"],
|
|
187
|
+
isLocal: false,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "email",
|
|
191
|
+
description: "Email KSA - Knowledge, Skills, and Abilities Send emails via SendGrid. Supports: - Plain text and HTML emails - Multiple recipients (to, cc, bcc) - Attachments - Templates",
|
|
192
|
+
category: "deliverables" as const,
|
|
193
|
+
functions: ["send", "sendText", "sendHtml", "sendWithAttachment", "sendTemplate", "sendBulk"],
|
|
194
|
+
importPath: "./ksa/email",
|
|
195
|
+
servicePaths: ["services.SendGrid.internal.send"],
|
|
196
|
+
isLocal: false,
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// Discovery functions
|
|
202
|
+
// ============================================================================
|
|
203
|
+
|
|
204
|
+
export const getAllKSAs = () => KSA_REGISTRY;
|
|
205
|
+
|
|
206
|
+
export const getKSAsByCategory = (category: KSACategory) =>
|
|
207
|
+
KSA_REGISTRY.filter((k) => k.category === category);
|
|
208
|
+
|
|
209
|
+
export const getKSA = (name: string) =>
|
|
210
|
+
KSA_REGISTRY.find((k) => k.name === name);
|
|
211
|
+
|
|
212
|
+
export const getKSAsByNames = (names: string[]) =>
|
|
213
|
+
KSA_REGISTRY.filter((k) => names.includes(k.name));
|
|
214
|
+
|
|
215
|
+
export const searchKSAs = (keyword: string) => {
|
|
216
|
+
const lower = keyword.toLowerCase();
|
|
217
|
+
return KSA_REGISTRY.filter(
|
|
218
|
+
(k) =>
|
|
219
|
+
k.name.toLowerCase().includes(lower) ||
|
|
220
|
+
k.description.toLowerCase().includes(lower) ||
|
|
221
|
+
k.functions.some((f) => f.toLowerCase().includes(lower))
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** Names of core KSAs that are always available */
|
|
226
|
+
export const CORE_KSAS = KSA_REGISTRY.filter((k) => k.category === "core").map((k) => k.name);
|
|
227
|
+
|
|
228
|
+
// ============================================================================
|
|
229
|
+
// Policy Functions
|
|
230
|
+
// ============================================================================
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get allowed service paths for a set of KSA names.
|
|
234
|
+
* Used by gateway to enforce access control.
|
|
235
|
+
*/
|
|
236
|
+
export function getServicePathsForKSAs(ksaNames: string[]): string[] {
|
|
237
|
+
const paths = new Set<string>();
|
|
238
|
+
for (const name of ksaNames) {
|
|
239
|
+
const ksa = getKSA(name);
|
|
240
|
+
if (ksa) {
|
|
241
|
+
for (const path of ksa.servicePaths) {
|
|
242
|
+
paths.add(path);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return Array.from(paths);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Check if a service path is allowed for the given KSAs.
|
|
251
|
+
*/
|
|
252
|
+
export function isServicePathAllowed(path: string, allowedKSAs: string[]): boolean {
|
|
253
|
+
// Core KSAs are always allowed
|
|
254
|
+
const allAllowed = [...CORE_KSAS, ...allowedKSAs];
|
|
255
|
+
const allowedPaths = getServicePathsForKSAs(allAllowed);
|
|
256
|
+
return allowedPaths.some((p) => path.startsWith(p) || p.startsWith(path));
|
|
257
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KSA Config Reader
|
|
3
|
+
*
|
|
4
|
+
* Utility for reading KSA configurations from environment variables.
|
|
5
|
+
* Used by KSA implementations in the sandbox to access user-configured settings.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { getKSAConfig } from './_shared/configReader';
|
|
9
|
+
*
|
|
10
|
+
* const config = getKSAConfig('web');
|
|
11
|
+
* const depth = config.depth || 'quick';
|
|
12
|
+
* const maxResults = depth === 'thorough' ? 15 : 8;
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { CONFIG_DEFAULTS } from "./configSchemas";
|
|
16
|
+
|
|
17
|
+
// Cache parsed configs to avoid repeated JSON parsing
|
|
18
|
+
let configCache: Record<string, Record<string, unknown>> | null = null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Parse skill configs from environment variable
|
|
22
|
+
*/
|
|
23
|
+
function parseSkillConfigs(): Record<string, Record<string, unknown>> {
|
|
24
|
+
if (configCache) return configCache;
|
|
25
|
+
|
|
26
|
+
const envValue = process.env.SKILL_CONFIGS;
|
|
27
|
+
if (!envValue) {
|
|
28
|
+
configCache = {};
|
|
29
|
+
return configCache;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
configCache = JSON.parse(envValue);
|
|
34
|
+
return configCache || {};
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.warn("[configReader] Failed to parse SKILL_CONFIGS:", e);
|
|
37
|
+
configCache = {};
|
|
38
|
+
return configCache;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get configuration for a specific KSA
|
|
44
|
+
*
|
|
45
|
+
* Returns user config merged with defaults.
|
|
46
|
+
* If no config is set, returns defaults only.
|
|
47
|
+
*
|
|
48
|
+
* @param ksaName - Name of the KSA (e.g., 'web', 'social')
|
|
49
|
+
* @returns Configuration object with all settings
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const webConfig = getKSAConfig('web');
|
|
53
|
+
* // { depth: 'thorough', searchType: 'all', fastMode: true, ... }
|
|
54
|
+
*/
|
|
55
|
+
export function getKSAConfig<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
56
|
+
ksaName: string
|
|
57
|
+
): T {
|
|
58
|
+
const allConfigs = parseSkillConfigs();
|
|
59
|
+
const userConfig = allConfigs[ksaName] || {};
|
|
60
|
+
const defaults = CONFIG_DEFAULTS[ksaName] || {};
|
|
61
|
+
|
|
62
|
+
return { ...defaults, ...userConfig } as T;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific config value for a KSA
|
|
67
|
+
*
|
|
68
|
+
* @param ksaName - Name of the KSA
|
|
69
|
+
* @param key - Config key to retrieve
|
|
70
|
+
* @param defaultValue - Fallback if not set
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const depth = getConfigValue('web', 'depth', 'quick');
|
|
74
|
+
*/
|
|
75
|
+
export function getConfigValue<T>(
|
|
76
|
+
ksaName: string,
|
|
77
|
+
key: string,
|
|
78
|
+
defaultValue: T
|
|
79
|
+
): T {
|
|
80
|
+
const config = getKSAConfig(ksaName);
|
|
81
|
+
return (config[key] as T) ?? defaultValue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get user instructions for a KSA
|
|
86
|
+
*
|
|
87
|
+
* Returns the custom instructions string if set, empty string otherwise.
|
|
88
|
+
*
|
|
89
|
+
* @param ksaName - Name of the KSA
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const instructions = getInstructions('web');
|
|
93
|
+
* // "Focus on enterprise clients"
|
|
94
|
+
*/
|
|
95
|
+
export function getInstructions(ksaName: string): string {
|
|
96
|
+
return getConfigValue(ksaName, "instructions", "");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Check if a platform is enabled for social KSA
|
|
101
|
+
*
|
|
102
|
+
* @param platform - Platform name (instagram, tiktok, etc.)
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* if (isPlatformEnabled('instagram')) {
|
|
106
|
+
* // fetch Instagram data
|
|
107
|
+
* }
|
|
108
|
+
*/
|
|
109
|
+
export function isPlatformEnabled(platform: string): boolean {
|
|
110
|
+
const config = getKSAConfig("social");
|
|
111
|
+
const platforms = (config.platforms as string[]) || [];
|
|
112
|
+
return platforms.includes(platform);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get enabled platforms for social KSA
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const platforms = getEnabledPlatforms();
|
|
120
|
+
* // ['instagram', 'tiktok']
|
|
121
|
+
*/
|
|
122
|
+
export function getEnabledPlatforms(): string[] {
|
|
123
|
+
const config = getKSAConfig("social");
|
|
124
|
+
return (config.platforms as string[]) || ["instagram", "tiktok"];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get web search options based on config
|
|
129
|
+
*
|
|
130
|
+
* Returns options object ready to pass to Valyu search.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* const searchOptions = getWebSearchOptions();
|
|
134
|
+
* const results = await search(query, searchOptions);
|
|
135
|
+
*/
|
|
136
|
+
export function getWebSearchOptions(): {
|
|
137
|
+
maxResults: number;
|
|
138
|
+
searchType: string;
|
|
139
|
+
fastMode: boolean;
|
|
140
|
+
includedSources?: string[];
|
|
141
|
+
excludedSources?: string[];
|
|
142
|
+
} {
|
|
143
|
+
const config = getKSAConfig("web");
|
|
144
|
+
|
|
145
|
+
const depth = (config.depth as string) || "quick";
|
|
146
|
+
const maxResults = depth === "thorough" ? 15 : 8;
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
maxResults,
|
|
150
|
+
searchType: (config.searchType as string) || "all",
|
|
151
|
+
fastMode: (config.fastMode as boolean) ?? true,
|
|
152
|
+
includedSources:
|
|
153
|
+
(config.includeSources as string[])?.length > 0
|
|
154
|
+
? (config.includeSources as string[])
|
|
155
|
+
: undefined,
|
|
156
|
+
excludedSources:
|
|
157
|
+
(config.excludeSources as string[])?.length > 0
|
|
158
|
+
? (config.excludeSources as string[])
|
|
159
|
+
: undefined,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get artifacts validation config
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* const validation = getArtifactsValidation();
|
|
168
|
+
* if (validation.required && artifacts.length === 0) {
|
|
169
|
+
* throw new Error('At least one artifact is required');
|
|
170
|
+
* }
|
|
171
|
+
*/
|
|
172
|
+
export function getArtifactsValidation(): {
|
|
173
|
+
required: boolean;
|
|
174
|
+
minLength: number;
|
|
175
|
+
format: string;
|
|
176
|
+
} {
|
|
177
|
+
const config = getKSAConfig("artifacts");
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
required: (config.validationRequired as boolean) ?? false,
|
|
181
|
+
minLength: (config.validationMinLength as number) ?? 0,
|
|
182
|
+
format: (config.validationFormat as string) || "any",
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get email config
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* const emailConfig = getEmailConfig();
|
|
191
|
+
* if (emailConfig.sandboxMode) {
|
|
192
|
+
* console.log('Email would be sent:', emailData);
|
|
193
|
+
* }
|
|
194
|
+
*/
|
|
195
|
+
export function getEmailConfig(): {
|
|
196
|
+
fromName: string;
|
|
197
|
+
replyTo?: string;
|
|
198
|
+
sandboxMode: boolean;
|
|
199
|
+
defaultTemplateId?: string;
|
|
200
|
+
} {
|
|
201
|
+
const config = getKSAConfig("email");
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
fromName: (config.fromName as string) || "Agent",
|
|
205
|
+
replyTo: (config.replyTo as string) || undefined,
|
|
206
|
+
sandboxMode: (config.sandboxMode as boolean) ?? true,
|
|
207
|
+
defaultTemplateId: (config.defaultTemplateId as string) || undefined,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Get PDF config
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* const pdfConfig = getPdfConfig();
|
|
216
|
+
* await generatePdf(content, { template: pdfConfig.template });
|
|
217
|
+
*/
|
|
218
|
+
export function getPdfConfig(): {
|
|
219
|
+
template: string;
|
|
220
|
+
pageSize: string;
|
|
221
|
+
includeTableOfContents: boolean;
|
|
222
|
+
} {
|
|
223
|
+
const config = getKSAConfig("pdf");
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
template: (config.template as string) || "report",
|
|
227
|
+
pageSize: (config.pageSize as string) || "letter",
|
|
228
|
+
includeTableOfContents: (config.includeTableOfContents as boolean) ?? true,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get companies enrichment config
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* const companyConfig = getCompaniesConfig();
|
|
237
|
+
* const data = await enrichCompany(domain, { level: companyConfig.enrichmentLevel });
|
|
238
|
+
*/
|
|
239
|
+
export function getCompaniesConfig(): {
|
|
240
|
+
enrichmentLevel: string;
|
|
241
|
+
includeTechStack: boolean;
|
|
242
|
+
sources: string[];
|
|
243
|
+
} {
|
|
244
|
+
const config = getKSAConfig("companies");
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
enrichmentLevel: (config.enrichmentLevel as string) || "basic",
|
|
248
|
+
includeTechStack: (config.includeTechStack as boolean) ?? false,
|
|
249
|
+
sources: (config.sources as string[]) || ["domain"],
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Clear config cache (useful for testing)
|
|
255
|
+
*/
|
|
256
|
+
export function clearConfigCache(): void {
|
|
257
|
+
configCache = null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// =============================================================================
|
|
261
|
+
// Framework Config (Local DB Integration)
|
|
262
|
+
// =============================================================================
|
|
263
|
+
|
|
264
|
+
import {
|
|
265
|
+
FRAMEWORK_DEFAULTS,
|
|
266
|
+
type FrameworkConfig,
|
|
267
|
+
} from "./configSchemas";
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get framework config for a specific KSA.
|
|
271
|
+
* Framework config controls automatic local DB behaviors like caching and tracking.
|
|
272
|
+
*
|
|
273
|
+
* @param ksaName - Name of the KSA (optional, for KSA-specific overrides)
|
|
274
|
+
* @returns Framework configuration
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* const frameworkConfig = getFrameworkConfigForKSA('file');
|
|
278
|
+
* if (frameworkConfig.trackFileState) {
|
|
279
|
+
* // Track file access
|
|
280
|
+
* }
|
|
281
|
+
*/
|
|
282
|
+
export function getFrameworkConfigForKSA(ksaName?: string): FrameworkConfig {
|
|
283
|
+
const allConfigs = parseSkillConfigs();
|
|
284
|
+
|
|
285
|
+
// Check for KSA-specific framework overrides
|
|
286
|
+
const ksaConfig = ksaName ? allConfigs[ksaName] || {} : {};
|
|
287
|
+
|
|
288
|
+
// Check for global framework config
|
|
289
|
+
const frameworkConfig = allConfigs._framework || {};
|
|
290
|
+
|
|
291
|
+
// Merge: defaults < global framework < KSA-specific
|
|
292
|
+
return {
|
|
293
|
+
...FRAMEWORK_DEFAULTS,
|
|
294
|
+
...frameworkConfig,
|
|
295
|
+
// Only include framework-relevant fields from KSA config
|
|
296
|
+
...(ksaConfig.cacheResults !== undefined && { cacheResults: ksaConfig.cacheResults }),
|
|
297
|
+
...(ksaConfig.cacheTTLMs !== undefined && { cacheTTLMs: ksaConfig.cacheTTLMs }),
|
|
298
|
+
...(ksaConfig.trackCalls !== undefined && { trackCalls: ksaConfig.trackCalls }),
|
|
299
|
+
...(ksaConfig.trackFileState !== undefined && { trackFileState: ksaConfig.trackFileState }),
|
|
300
|
+
...(ksaConfig.persistToSession !== undefined && { persistToSession: ksaConfig.persistToSession }),
|
|
301
|
+
} as FrameworkConfig;
|
|
302
|
+
}
|