@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,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KSA SDK Builders
|
|
3
|
+
*
|
|
4
|
+
* Fluent API for defining KSAs with full TypeScript type safety.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { defineKSA, fn, service, primitive } from '@lakitu/sdk';
|
|
9
|
+
*
|
|
10
|
+
* export const webKSA = defineKSA('web')
|
|
11
|
+
* .description('Web search and content extraction')
|
|
12
|
+
* .category('skills')
|
|
13
|
+
* .group('research')
|
|
14
|
+
* .fn('search', fn()
|
|
15
|
+
* .description('Search the web')
|
|
16
|
+
* .param('query', { type: 'string', required: true })
|
|
17
|
+
* .param('maxResults', { type: 'number', default: 10 })
|
|
18
|
+
* .returns<SearchResult[]>()
|
|
19
|
+
* .impl(service('services.Valyu.internal.search')
|
|
20
|
+
* .mapArgs(({ query, maxResults }) => ({ query, maxResults, fastMode: true }))
|
|
21
|
+
* .mapResult(r => r.results || [])
|
|
22
|
+
* )
|
|
23
|
+
* )
|
|
24
|
+
* .build();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Service Builder
|
|
29
|
+
// ============================================================================
|
|
30
|
+
export class ServiceBuilder {
|
|
31
|
+
_path;
|
|
32
|
+
_mapArgs;
|
|
33
|
+
_mapResult;
|
|
34
|
+
constructor(path) {
|
|
35
|
+
this._path = path;
|
|
36
|
+
}
|
|
37
|
+
/** Map input arguments to service arguments */
|
|
38
|
+
mapArgs(mapper) {
|
|
39
|
+
this._mapArgs = mapper;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/** Map service result to function return type */
|
|
43
|
+
mapResult(mapper) {
|
|
44
|
+
this._mapResult = mapper;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
build() {
|
|
48
|
+
return {
|
|
49
|
+
type: "service",
|
|
50
|
+
path: this._path,
|
|
51
|
+
mapArgs: this._mapArgs,
|
|
52
|
+
mapResult: this._mapResult,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Create a service implementation */
|
|
57
|
+
export function service(path) {
|
|
58
|
+
return new ServiceBuilder(path);
|
|
59
|
+
}
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// Primitive Builder
|
|
62
|
+
// ============================================================================
|
|
63
|
+
/** Create a primitive implementation */
|
|
64
|
+
export function primitive(name) {
|
|
65
|
+
return { type: "primitive", name };
|
|
66
|
+
}
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Composite Builder
|
|
69
|
+
// ============================================================================
|
|
70
|
+
export class CompositeBuilder {
|
|
71
|
+
_steps = [];
|
|
72
|
+
/** Call another KSA function */
|
|
73
|
+
call(fnPath, args, as) {
|
|
74
|
+
this._steps.push({ call: fnPath, args, as });
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/** Return a value */
|
|
78
|
+
return(value) {
|
|
79
|
+
this._steps.push({ return: value });
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
build() {
|
|
83
|
+
return { type: "composite", steps: this._steps };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Create a composite implementation */
|
|
87
|
+
export function composite() {
|
|
88
|
+
return new CompositeBuilder();
|
|
89
|
+
}
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Function Builder
|
|
92
|
+
// ============================================================================
|
|
93
|
+
export class FunctionBuilder {
|
|
94
|
+
_description = "";
|
|
95
|
+
_params = {};
|
|
96
|
+
_impl;
|
|
97
|
+
_returns;
|
|
98
|
+
/** Set function description */
|
|
99
|
+
description(desc) {
|
|
100
|
+
this._description = desc;
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/** Add a parameter */
|
|
104
|
+
param(name, def) {
|
|
105
|
+
this._params[name] = def;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/** Set return type info */
|
|
109
|
+
returns(typeInfo) {
|
|
110
|
+
this._returns = typeInfo;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/** Set implementation */
|
|
114
|
+
impl(implementation) {
|
|
115
|
+
if (implementation instanceof ServiceBuilder) {
|
|
116
|
+
this._impl = implementation.build();
|
|
117
|
+
}
|
|
118
|
+
else if (implementation instanceof CompositeBuilder) {
|
|
119
|
+
this._impl = implementation.build();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this._impl = implementation;
|
|
123
|
+
}
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
build(name) {
|
|
127
|
+
if (!this._impl) {
|
|
128
|
+
throw new Error(`Function "${name}" has no implementation`);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
name,
|
|
132
|
+
description: this._description,
|
|
133
|
+
params: this._params,
|
|
134
|
+
impl: this._impl,
|
|
135
|
+
returns: this._returns,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Create a function builder */
|
|
140
|
+
export function fn() {
|
|
141
|
+
return new FunctionBuilder();
|
|
142
|
+
}
|
|
143
|
+
// ============================================================================
|
|
144
|
+
// KSA Builder
|
|
145
|
+
// ============================================================================
|
|
146
|
+
export class KSABuilder {
|
|
147
|
+
_name;
|
|
148
|
+
_description = "";
|
|
149
|
+
_category = "skills";
|
|
150
|
+
_group;
|
|
151
|
+
_icon;
|
|
152
|
+
_functions = [];
|
|
153
|
+
constructor(name) {
|
|
154
|
+
this._name = name;
|
|
155
|
+
}
|
|
156
|
+
/** Set KSA description */
|
|
157
|
+
description(desc) {
|
|
158
|
+
this._description = desc;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/** Set KSA category */
|
|
162
|
+
category(cat) {
|
|
163
|
+
this._category = cat;
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
/** Set KSA group (subcategory) */
|
|
167
|
+
group(grp) {
|
|
168
|
+
this._group = grp;
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
/** Set KSA icon (MDI icon name) */
|
|
172
|
+
icon(ico) {
|
|
173
|
+
this._icon = ico;
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
/** Add a function to the KSA */
|
|
177
|
+
fn(name, builder) {
|
|
178
|
+
this._functions.push(builder.build(name));
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
/** Build the KSA definition */
|
|
182
|
+
build() {
|
|
183
|
+
return {
|
|
184
|
+
name: this._name,
|
|
185
|
+
description: this._description,
|
|
186
|
+
category: this._category,
|
|
187
|
+
group: this._group,
|
|
188
|
+
icon: this._icon,
|
|
189
|
+
functions: this._functions,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Create a KSA builder */
|
|
194
|
+
export function defineKSA(name) {
|
|
195
|
+
return new KSABuilder(name);
|
|
196
|
+
}
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// Registry Builder
|
|
199
|
+
// ============================================================================
|
|
200
|
+
/** Create a registry from KSA definitions */
|
|
201
|
+
export function createRegistry(...ksas) {
|
|
202
|
+
const registry = new Map();
|
|
203
|
+
for (const ksa of ksas) {
|
|
204
|
+
registry.set(ksa.name, ksa);
|
|
205
|
+
}
|
|
206
|
+
return registry;
|
|
207
|
+
}
|
|
208
|
+
/** Get a function from a registry */
|
|
209
|
+
export function getFunction(registry, ksaName, fnName) {
|
|
210
|
+
const ksa = registry.get(ksaName);
|
|
211
|
+
if (!ksa)
|
|
212
|
+
return undefined;
|
|
213
|
+
return ksa.functions.find((f) => f.name === fnName);
|
|
214
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lakitu KSA SDK
|
|
3
|
+
*
|
|
4
|
+
* Type-safe SDK for defining KSAs (Knowledge, Skills, and Abilities).
|
|
5
|
+
* KSAs are capability modules that AI agents can use via code execution.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineKSA, fn, service } from '@lakitu/sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Define a KSA
|
|
12
|
+
* export const myKSA = defineKSA('myKsa')
|
|
13
|
+
* .description('My custom KSA')
|
|
14
|
+
* .category('skills')
|
|
15
|
+
* .fn('doSomething', fn()
|
|
16
|
+
* .description('Does something')
|
|
17
|
+
* .param('input', { type: 'string', required: true })
|
|
18
|
+
* .impl(service('services.MyService.internal.action')
|
|
19
|
+
* .mapArgs(({ input }) => ({ data: input }))
|
|
20
|
+
* )
|
|
21
|
+
* )
|
|
22
|
+
* .build();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
export type { ParamType, ParamDef, KSACategory, KSADef, KSADefinition, FunctionDef, Implementation, ServiceImpl, PrimitiveImpl, CompositeImpl, CompositeStep, StepContext, ConfigField, ConfigFieldOption, KSAConfig, ExecutionContext, ExecutionResult, KSARegistry, } from "./types";
|
|
28
|
+
export { defineKSA, KSABuilder, fn, FunctionBuilder, service, ServiceBuilder, primitive, composite, CompositeBuilder, createRegistry, getFunction, } from "./builders";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,YAAY,EAEV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,aAAa,EACb,WAAW,EAGX,cAAc,EACd,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EAGX,WAAW,EACX,iBAAiB,EACjB,SAAS,EAGT,gBAAgB,EAChB,eAAe,EAGf,WAAW,GACZ,MAAM,SAAS,CAAC;AAMjB,OAAO,EAEL,SAAS,EACT,UAAU,EAGV,EAAE,EACF,eAAe,EAGf,OAAO,EACP,cAAc,EACd,SAAS,EACT,SAAS,EACT,gBAAgB,EAGhB,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lakitu KSA SDK
|
|
3
|
+
*
|
|
4
|
+
* Type-safe SDK for defining KSAs (Knowledge, Skills, and Abilities).
|
|
5
|
+
* KSAs are capability modules that AI agents can use via code execution.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineKSA, fn, service } from '@lakitu/sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Define a KSA
|
|
12
|
+
* export const myKSA = defineKSA('myKsa')
|
|
13
|
+
* .description('My custom KSA')
|
|
14
|
+
* .category('skills')
|
|
15
|
+
* .fn('doSomething', fn()
|
|
16
|
+
* .description('Does something')
|
|
17
|
+
* .param('input', { type: 'string', required: true })
|
|
18
|
+
* .impl(service('services.MyService.internal.action')
|
|
19
|
+
* .mapArgs(({ input }) => ({ data: input }))
|
|
20
|
+
* )
|
|
21
|
+
* )
|
|
22
|
+
* .build();
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Builders
|
|
29
|
+
// ============================================================================
|
|
30
|
+
export {
|
|
31
|
+
// KSA builder
|
|
32
|
+
defineKSA, KSABuilder,
|
|
33
|
+
// Function builder
|
|
34
|
+
fn, FunctionBuilder,
|
|
35
|
+
// Implementation builders
|
|
36
|
+
service, ServiceBuilder, primitive, composite, CompositeBuilder,
|
|
37
|
+
// Registry utilities
|
|
38
|
+
createRegistry, getFunction, } from "./builders";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KSA SDK Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the type-safe KSA builder system.
|
|
5
|
+
*/
|
|
6
|
+
export type ParamType = "string" | "number" | "boolean" | "array" | "object";
|
|
7
|
+
export interface ParamDef<T = unknown> {
|
|
8
|
+
type: ParamType;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
default?: T;
|
|
11
|
+
description?: string;
|
|
12
|
+
enum?: string[];
|
|
13
|
+
}
|
|
14
|
+
export type InferParamType<P extends ParamDef> = P["type"] extends "string" ? string : P["type"] extends "number" ? number : P["type"] extends "boolean" ? boolean : P["type"] extends "array" ? unknown[] : P["type"] extends "object" ? Record<string, unknown> : unknown;
|
|
15
|
+
/** Service implementation - calls cloud Convex via gateway */
|
|
16
|
+
export interface ServiceImpl<TArgs = unknown, TResult = unknown> {
|
|
17
|
+
type: "service";
|
|
18
|
+
path: string;
|
|
19
|
+
mapArgs?: (args: TArgs) => Record<string, unknown>;
|
|
20
|
+
mapResult?: (result: unknown) => TResult;
|
|
21
|
+
}
|
|
22
|
+
/** Primitive implementation - uses local capabilities */
|
|
23
|
+
export interface PrimitiveImpl {
|
|
24
|
+
type: "primitive";
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
/** Composite step for chaining operations */
|
|
28
|
+
export interface CompositeStep {
|
|
29
|
+
call?: string;
|
|
30
|
+
args?: Record<string, unknown> | ((ctx: StepContext) => Record<string, unknown>);
|
|
31
|
+
as?: string;
|
|
32
|
+
return?: unknown | ((ctx: StepContext) => unknown);
|
|
33
|
+
}
|
|
34
|
+
export interface StepContext {
|
|
35
|
+
vars: Record<string, unknown>;
|
|
36
|
+
args: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** Composite implementation - chains multiple operations */
|
|
39
|
+
export interface CompositeImpl {
|
|
40
|
+
type: "composite";
|
|
41
|
+
steps: CompositeStep[];
|
|
42
|
+
}
|
|
43
|
+
export type Implementation = ServiceImpl | PrimitiveImpl | CompositeImpl;
|
|
44
|
+
export interface FunctionDef<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
params: Record<string, ParamDef>;
|
|
48
|
+
impl: Implementation;
|
|
49
|
+
returns?: {
|
|
50
|
+
type: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
};
|
|
53
|
+
_argsType?: TArgs;
|
|
54
|
+
_resultType?: TResult;
|
|
55
|
+
}
|
|
56
|
+
export type KSACategory = "core" | "skills" | "deliverables";
|
|
57
|
+
export interface KSADef {
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
category: KSACategory;
|
|
61
|
+
group?: string;
|
|
62
|
+
icon?: string;
|
|
63
|
+
functions: FunctionDef[];
|
|
64
|
+
}
|
|
65
|
+
export interface ConfigFieldOption {
|
|
66
|
+
value: string | number | boolean;
|
|
67
|
+
label: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ConfigField {
|
|
70
|
+
type: "string" | "number" | "boolean" | "select" | "multiselect" | "textarea" | "array";
|
|
71
|
+
label: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
placeholder?: string;
|
|
74
|
+
options?: ConfigFieldOption[];
|
|
75
|
+
min?: number;
|
|
76
|
+
max?: number;
|
|
77
|
+
default: unknown;
|
|
78
|
+
}
|
|
79
|
+
export interface KSAConfig {
|
|
80
|
+
configSchema?: Record<string, ConfigField>;
|
|
81
|
+
defaults?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
export interface KSADefinition extends KSADef, KSAConfig {
|
|
84
|
+
isBuiltIn: boolean;
|
|
85
|
+
userId?: string;
|
|
86
|
+
orgId?: string;
|
|
87
|
+
version?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface ExecutionContext {
|
|
90
|
+
threadId?: string;
|
|
91
|
+
cardId?: string;
|
|
92
|
+
workspaceId?: string;
|
|
93
|
+
config?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
export interface ExecutionResult<T = unknown> {
|
|
96
|
+
success: boolean;
|
|
97
|
+
data?: T;
|
|
98
|
+
error?: string;
|
|
99
|
+
duration?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface KSARegistry {
|
|
102
|
+
ksas: Map<string, KSADef>;
|
|
103
|
+
getKSA(name: string): KSADef | undefined;
|
|
104
|
+
getFunction(ksaName: string, fnName: string): FunctionDef | undefined;
|
|
105
|
+
listKSAs(category?: KSACategory): KSADef[];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../sdk/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAA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AC,EAAE,MAAM,CAAC;CACnB;AAMD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE,CAAC;CAC5C"}
|
package/ksa/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Lakitu KSAs (Knowledge, Skills, and Abilities)
|
|
2
|
+
|
|
3
|
+
> **Why "KSA"?** The terms "tools" and "skills" are overloaded in AI agent codebases.
|
|
4
|
+
> Every framework (AI SDK, MCP, Claude, OpenCode) uses them differently.
|
|
5
|
+
> **KSA** is a distinct term that won't be confused with other implementations.
|
|
6
|
+
|
|
7
|
+
## What is a KSA?
|
|
8
|
+
|
|
9
|
+
A KSA is a comprehensive capability module that combines:
|
|
10
|
+
|
|
11
|
+
- **Knowledge**: Documentation and context (like MCP descriptions)
|
|
12
|
+
- **Skills**: Executable TypeScript functions (like tool implementations)
|
|
13
|
+
- **Abilities**: What the agent can accomplish (like Claude skills guidance)
|
|
14
|
+
|
|
15
|
+
KSAs are designed for **code execution** - the agent imports and calls them directly.
|
|
16
|
+
|
|
17
|
+
## Quick Reference
|
|
18
|
+
|
|
19
|
+
### System KSAs (Local Operations)
|
|
20
|
+
|
|
21
|
+
| KSA | Functions | Import |
|
|
22
|
+
|-----|-----------|--------|
|
|
23
|
+
| **file** | `read`, `write`, `edit`, `glob`, `grep`, `ls` | `from './ksa/file'` |
|
|
24
|
+
| **browser** | `open`, `screenshot`, `click`, `type`, `getText`, `getHtml` | `from './ksa/browser'` |
|
|
25
|
+
| **beads** | `create`, `update`, `close`, `list`, `getReady`, `get` | `from './ksa/beads'` |
|
|
26
|
+
| **pdf** | `generate` | `from './ksa/pdf'` |
|
|
27
|
+
|
|
28
|
+
### Research KSAs (Gateway Operations)
|
|
29
|
+
|
|
30
|
+
| KSA | Functions | Import |
|
|
31
|
+
|-----|-----------|--------|
|
|
32
|
+
| **web** | `search`, `scrape`, `news` | `from './ksa/web'` |
|
|
33
|
+
| **news** | `search`, `trending`, `breakingNews`, `monitorBrand`, `analyzeSentiment` | `from './ksa/news'` |
|
|
34
|
+
| **social** | `tiktokProfile`, `instagramProfile`, `twitterProfile`, `youtubeProfile`, `*Posts` | `from './ksa/social'` |
|
|
35
|
+
| **companies** | `enrichDomain`, `searchCompanies`, `findSimilar`, `getTechStack` | `from './ksa/companies'` |
|
|
36
|
+
| **email** | `send`, `sendText`, `sendHtml`, `sendWithAttachment`, `sendTemplate` | `from './ksa/email'` |
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
The agent writes TypeScript that imports from KSAs:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { search, scrape } from './ksa/web';
|
|
44
|
+
import { write } from './ksa/file';
|
|
45
|
+
import { generate } from './ksa/pdf';
|
|
46
|
+
|
|
47
|
+
// Research a topic
|
|
48
|
+
const results = await search('AI news 2025');
|
|
49
|
+
|
|
50
|
+
// Get detailed content
|
|
51
|
+
const content = await scrape(results[0].url);
|
|
52
|
+
|
|
53
|
+
// Save as PDF
|
|
54
|
+
await generate(content.markdown, 'ai-report', 'AI News Report');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## How KSAs Differ From...
|
|
58
|
+
|
|
59
|
+
| Concept | What It Is | How KSA Differs |
|
|
60
|
+
|---------|------------|-----------------|
|
|
61
|
+
| **AI SDK tool()** | JSON schema + execute function for tool calling | KSA is plain TypeScript, no JSON schema |
|
|
62
|
+
| **MCP Tool** | Server-defined capability with protocol | KSA is local files, no protocol overhead |
|
|
63
|
+
| **Claude Skill** | Prompt-based capability guidance | KSA includes actual executable code |
|
|
64
|
+
| **Function Call** | LLM generates JSON to call function | KSA: LLM generates code that imports & calls |
|
|
65
|
+
|
|
66
|
+
## KSA File Examples
|
|
67
|
+
|
|
68
|
+
### Web Research
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { search, scrape, news } from './ksa/web';
|
|
72
|
+
|
|
73
|
+
// Search the web
|
|
74
|
+
const results = await search('TypeScript best practices');
|
|
75
|
+
for (const r of results) {
|
|
76
|
+
console.log(`${r.title}: ${r.url}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Get content from a URL
|
|
80
|
+
const content = await scrape('https://example.com/article');
|
|
81
|
+
console.log(content.markdown);
|
|
82
|
+
|
|
83
|
+
// Get recent news
|
|
84
|
+
const articles = await news('AI', 5);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### File Operations
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { read, write, edit, glob, grep } from './ksa/file';
|
|
91
|
+
|
|
92
|
+
// Read a file
|
|
93
|
+
const content = await read('/home/user/workspace/README.md');
|
|
94
|
+
|
|
95
|
+
// Write a file
|
|
96
|
+
await write('/home/user/workspace/output.txt', 'Hello, world!');
|
|
97
|
+
|
|
98
|
+
// Edit a file (find and replace)
|
|
99
|
+
await edit('/home/user/workspace/config.ts', 'debug: false', 'debug: true');
|
|
100
|
+
|
|
101
|
+
// Find TypeScript files
|
|
102
|
+
const tsFiles = await glob('**/*.ts');
|
|
103
|
+
|
|
104
|
+
// Search for patterns
|
|
105
|
+
const todos = await grep('TODO:');
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### PDF Generation
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { generate } from './ksa/pdf';
|
|
112
|
+
|
|
113
|
+
await generate(`# Quarterly Report
|
|
114
|
+
|
|
115
|
+
## Summary
|
|
116
|
+
Key findings from this quarter...
|
|
117
|
+
|
|
118
|
+
## Metrics
|
|
119
|
+
- Revenue: $1.2M
|
|
120
|
+
- Growth: 15%
|
|
121
|
+
`, 'quarterly-report', 'Q4 2025 Report');
|
|
122
|
+
|
|
123
|
+
// Creates /home/user/artifacts/quarterly-report.pdf
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Task Tracking
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { create, update, close, list, getReady } from './ksa/beads';
|
|
130
|
+
|
|
131
|
+
// Create a task
|
|
132
|
+
const id = await create({
|
|
133
|
+
title: 'Implement search feature',
|
|
134
|
+
type: 'feature',
|
|
135
|
+
priority: 1,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Update status
|
|
139
|
+
await update(id, { status: 'in_progress' });
|
|
140
|
+
|
|
141
|
+
// List open tasks
|
|
142
|
+
const tasks = await list({ status: 'open' });
|
|
143
|
+
|
|
144
|
+
// Get ready tasks (no blockers)
|
|
145
|
+
const ready = await getReady();
|
|
146
|
+
|
|
147
|
+
// Close when done
|
|
148
|
+
await close(id, 'Search feature implemented and tested');
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Browser Automation
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { open, screenshot, click, type, getText } from './ksa/browser';
|
|
155
|
+
|
|
156
|
+
// Open a page
|
|
157
|
+
await open('https://example.com');
|
|
158
|
+
|
|
159
|
+
// Take a screenshot
|
|
160
|
+
const { path } = await screenshot('homepage');
|
|
161
|
+
|
|
162
|
+
// Interact with elements
|
|
163
|
+
await click('button.login');
|
|
164
|
+
await type('input[name="email"]', 'user@example.com');
|
|
165
|
+
|
|
166
|
+
// Get page content
|
|
167
|
+
const text = await getText();
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Working Directories
|
|
171
|
+
|
|
172
|
+
| Path | Purpose |
|
|
173
|
+
|------|---------|
|
|
174
|
+
| `/home/user/workspace/` | Working directory for code and files |
|
|
175
|
+
| `/home/user/artifacts/` | Persistent outputs (PDFs, screenshots) |
|
|
176
|
+
| `/home/user/ksa/` | KSA modules (read-only) |
|
|
177
|
+
|
|
178
|
+
## Adding New KSAs
|
|
179
|
+
|
|
180
|
+
### Two Types of KSAs
|
|
181
|
+
|
|
182
|
+
1. **Gateway KSAs** - Call Convex services via cloud gateway (research, data, external APIs)
|
|
183
|
+
2. **Local KSAs** - Operate locally in sandbox (filesystem, bash, local binaries)
|
|
184
|
+
|
|
185
|
+
### Quick Start
|
|
186
|
+
|
|
187
|
+
1. Copy the appropriate template from `ksa/_templates/`:
|
|
188
|
+
- `gateway-ksa.template.ts` for Gateway KSAs
|
|
189
|
+
- `local-ksa.template.ts` for Local KSAs
|
|
190
|
+
|
|
191
|
+
2. Create your KSA file:
|
|
192
|
+
```bash
|
|
193
|
+
cp ksa/_templates/gateway-ksa.template.ts ksa/myservice.ts
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
3. Implement your functions:
|
|
197
|
+
- For gateway KSAs: use `callGateway()` from `./_shared/gateway`
|
|
198
|
+
- For local KSAs: use `fs`, `exec`, etc.
|
|
199
|
+
|
|
200
|
+
4. Add to `ksa/index.ts`:
|
|
201
|
+
```typescript
|
|
202
|
+
// Add export
|
|
203
|
+
export * as myservice from "./myservice";
|
|
204
|
+
|
|
205
|
+
// Add to registry
|
|
206
|
+
{
|
|
207
|
+
name: "myservice",
|
|
208
|
+
description: "What this KSA does",
|
|
209
|
+
category: "research", // or "data", "create", "system", "ai"
|
|
210
|
+
functions: ["func1", "func2"],
|
|
211
|
+
importPath: "./ksa/myservice",
|
|
212
|
+
},
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Gateway KSA Example
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { callGateway } from "./_shared/gateway";
|
|
219
|
+
|
|
220
|
+
export async function getData(query: string) {
|
|
221
|
+
return callGateway("services.MyService.internal.call", {
|
|
222
|
+
endpoint: "/v1/data",
|
|
223
|
+
params: { q: query },
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Local KSA Example
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import { exec } from "child_process";
|
|
232
|
+
import { promisify } from "util";
|
|
233
|
+
|
|
234
|
+
const execAsync = promisify(exec);
|
|
235
|
+
|
|
236
|
+
export async function runTool(arg: string) {
|
|
237
|
+
const { stdout } = await execAsync(`my-tool ${arg}`);
|
|
238
|
+
return stdout.trim();
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Mapping Services to KSAs
|
|
243
|
+
|
|
244
|
+
When creating KSAs from existing `convex/services/`:
|
|
245
|
+
|
|
246
|
+
| Service | KSA | Category |
|
|
247
|
+
|---------|-----|----------|
|
|
248
|
+
| Valyu | web | research |
|
|
249
|
+
| APITube | news | research |
|
|
250
|
+
| ScrapeCreators | social | research |
|
|
251
|
+
| TheCompanies | companies | data |
|
|
252
|
+
| SendGrid | email | create |
|
|
253
|
+
| DataForSEO | seo | research |
|
|
254
|
+
| ScrapeDo | web | research |
|
|
255
|
+
| WhatCMS | cms | data |
|
|
256
|
+
|
|
257
|
+
### Best Practices
|
|
258
|
+
|
|
259
|
+
1. **Type-first** - Define types based on service types, simplified for agent use
|
|
260
|
+
2. **JSDoc everything** - The agent learns from your documentation
|
|
261
|
+
3. **Include examples** - Show real usage in @example blocks
|
|
262
|
+
4. **Handle errors gracefully** - Return null/empty instead of throwing when appropriate
|
|
263
|
+
5. **Keep it focused** - Each KSA should do one thing well
|