@poncho-ai/sdk 0.2.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/.turbo/turbo-build.log +14 -0
- package/.turbo/turbo-test.log +14 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +389 -0
- package/dist/index.js +226 -0
- package/package.json +42 -0
- package/src/config-registry.ts +263 -0
- package/src/index.ts +108 -0
- package/test/sdk.test.ts +20 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
> @poncho-ai/sdk@0.2.0 build /Users/cesar/Dev/latitude/poncho-ai/packages/sdk
|
|
3
|
+
> tsup src/index.ts --format esm --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Target: es2022
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m5.65 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 40ms
|
|
12
|
+
[34mDTS[39m Build start
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 937ms
|
|
14
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.57 KB[39m
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
> @poncho-ai/sdk@0.1.0 test /Users/cesar/Dev/latitude/agentl/packages/sdk
|
|
3
|
+
> vitest
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[7m[1m[36m RUN [39m[22m[27m [36mv1.6.1[39m [90m/Users/cesar/Dev/latitude/agentl/packages/sdk[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m test/sdk.test.ts [2m ([22m[2m1 test[22m[2m)[22m[90m 2[2mms[22m[39m
|
|
9
|
+
|
|
10
|
+
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
|
+
[2m Tests [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
12
|
+
[2m Start at [22m 12:05:57
|
|
13
|
+
[2m Duration [22m 475ms[2m (transform 97ms, setup 0ms, collect 90ms, tests 2ms, environment 0ms, prepare 102ms)[22m
|
|
14
|
+
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @poncho-ai/sdk
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Initial release of Poncho - an open framework for building and deploying AI agents.
|
|
8
|
+
- `@poncho-ai/sdk`: Core types and utilities for building Poncho skills
|
|
9
|
+
- `@poncho-ai/harness`: Agent execution runtime with conversation loop, tool dispatch, and streaming
|
|
10
|
+
- `@poncho-ai/client`: TypeScript client for calling deployed Poncho agents
|
|
11
|
+
- `@poncho-ai/cli`: CLI for building and deploying AI agents
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Latitude
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
type OnboardingScope = "light" | "full";
|
|
2
|
+
type FeatureDomain = "model" | "storage" | "memory" | "auth" | "telemetry" | "mcp";
|
|
3
|
+
type OnboardingFieldTarget = "agent" | "config" | "env";
|
|
4
|
+
type OnboardingFieldKind = "select" | "boolean" | "string" | "number";
|
|
5
|
+
type OnboardingFieldCondition = {
|
|
6
|
+
fieldId: string;
|
|
7
|
+
equals?: string | number | boolean;
|
|
8
|
+
oneOf?: Array<string | number | boolean>;
|
|
9
|
+
};
|
|
10
|
+
type OnboardingOption = {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
envVars?: string[];
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
16
|
+
type OnboardingField = {
|
|
17
|
+
id: string;
|
|
18
|
+
domain: FeatureDomain;
|
|
19
|
+
target: OnboardingFieldTarget;
|
|
20
|
+
path: string;
|
|
21
|
+
kind: OnboardingFieldKind;
|
|
22
|
+
scopes: OnboardingScope[];
|
|
23
|
+
label: string;
|
|
24
|
+
prompt: string;
|
|
25
|
+
defaultValue: string | number | boolean;
|
|
26
|
+
options?: OnboardingOption[];
|
|
27
|
+
envVars?: string[];
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
secret?: boolean;
|
|
30
|
+
dependsOn?: OnboardingFieldCondition;
|
|
31
|
+
};
|
|
32
|
+
declare const ONBOARDING_FIELDS: readonly [{
|
|
33
|
+
readonly id: "model.provider";
|
|
34
|
+
readonly domain: "model";
|
|
35
|
+
readonly target: "agent";
|
|
36
|
+
readonly path: "model.provider";
|
|
37
|
+
readonly kind: "select";
|
|
38
|
+
readonly scopes: ["light", "full"];
|
|
39
|
+
readonly label: "Model provider";
|
|
40
|
+
readonly prompt: "Choose a model provider";
|
|
41
|
+
readonly defaultValue: "anthropic";
|
|
42
|
+
readonly options: [{
|
|
43
|
+
readonly value: "anthropic";
|
|
44
|
+
readonly label: "Anthropic";
|
|
45
|
+
readonly envVars: ["ANTHROPIC_API_KEY"];
|
|
46
|
+
}, {
|
|
47
|
+
readonly value: "openai";
|
|
48
|
+
readonly label: "OpenAI";
|
|
49
|
+
readonly envVars: ["OPENAI_API_KEY"];
|
|
50
|
+
}];
|
|
51
|
+
}, {
|
|
52
|
+
readonly id: "env.ANTHROPIC_API_KEY";
|
|
53
|
+
readonly domain: "model";
|
|
54
|
+
readonly target: "env";
|
|
55
|
+
readonly path: "ANTHROPIC_API_KEY";
|
|
56
|
+
readonly kind: "string";
|
|
57
|
+
readonly scopes: ["light", "full"];
|
|
58
|
+
readonly label: "Anthropic API key";
|
|
59
|
+
readonly prompt: "Anthropic API key";
|
|
60
|
+
readonly defaultValue: "";
|
|
61
|
+
readonly placeholder: "sk-ant-...";
|
|
62
|
+
readonly secret: true;
|
|
63
|
+
readonly dependsOn: {
|
|
64
|
+
readonly fieldId: "model.provider";
|
|
65
|
+
readonly equals: "anthropic";
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
readonly id: "env.OPENAI_API_KEY";
|
|
69
|
+
readonly domain: "model";
|
|
70
|
+
readonly target: "env";
|
|
71
|
+
readonly path: "OPENAI_API_KEY";
|
|
72
|
+
readonly kind: "string";
|
|
73
|
+
readonly scopes: ["light", "full"];
|
|
74
|
+
readonly label: "OpenAI API key";
|
|
75
|
+
readonly prompt: "OpenAI API key";
|
|
76
|
+
readonly defaultValue: "";
|
|
77
|
+
readonly placeholder: "sk-...";
|
|
78
|
+
readonly secret: true;
|
|
79
|
+
readonly dependsOn: {
|
|
80
|
+
readonly fieldId: "model.provider";
|
|
81
|
+
readonly equals: "openai";
|
|
82
|
+
};
|
|
83
|
+
}, {
|
|
84
|
+
readonly id: "storage.provider";
|
|
85
|
+
readonly domain: "storage";
|
|
86
|
+
readonly target: "config";
|
|
87
|
+
readonly path: "storage.provider";
|
|
88
|
+
readonly kind: "select";
|
|
89
|
+
readonly scopes: ["light", "full"];
|
|
90
|
+
readonly label: "Storage provider";
|
|
91
|
+
readonly prompt: "Choose storage provider for conversations and memory";
|
|
92
|
+
readonly defaultValue: "local";
|
|
93
|
+
readonly options: [{
|
|
94
|
+
readonly value: "memory";
|
|
95
|
+
readonly label: "In-memory only";
|
|
96
|
+
}, {
|
|
97
|
+
readonly value: "local";
|
|
98
|
+
readonly label: "Local file storage";
|
|
99
|
+
}, {
|
|
100
|
+
readonly value: "redis";
|
|
101
|
+
readonly label: "Redis";
|
|
102
|
+
readonly envVars: ["REDIS_URL"];
|
|
103
|
+
}, {
|
|
104
|
+
readonly value: "upstash";
|
|
105
|
+
readonly label: "Upstash REST";
|
|
106
|
+
readonly envVars: ["UPSTASH_REDIS_REST_URL", "UPSTASH_REDIS_REST_TOKEN"];
|
|
107
|
+
}, {
|
|
108
|
+
readonly value: "dynamodb";
|
|
109
|
+
readonly label: "DynamoDB";
|
|
110
|
+
readonly envVars: ["PONCHO_DYNAMODB_TABLE"];
|
|
111
|
+
}];
|
|
112
|
+
}, {
|
|
113
|
+
readonly id: "storage.url";
|
|
114
|
+
readonly domain: "storage";
|
|
115
|
+
readonly target: "config";
|
|
116
|
+
readonly path: "storage.url";
|
|
117
|
+
readonly kind: "string";
|
|
118
|
+
readonly scopes: ["full"];
|
|
119
|
+
readonly label: "Storage URL";
|
|
120
|
+
readonly prompt: "Storage URL";
|
|
121
|
+
readonly defaultValue: "";
|
|
122
|
+
readonly dependsOn: {
|
|
123
|
+
readonly fieldId: "storage.provider";
|
|
124
|
+
readonly oneOf: ["redis", "upstash"];
|
|
125
|
+
};
|
|
126
|
+
}, {
|
|
127
|
+
readonly id: "storage.token";
|
|
128
|
+
readonly domain: "storage";
|
|
129
|
+
readonly target: "config";
|
|
130
|
+
readonly path: "storage.token";
|
|
131
|
+
readonly kind: "string";
|
|
132
|
+
readonly scopes: ["full"];
|
|
133
|
+
readonly label: "Storage token";
|
|
134
|
+
readonly prompt: "Storage token";
|
|
135
|
+
readonly defaultValue: "";
|
|
136
|
+
readonly dependsOn: {
|
|
137
|
+
readonly fieldId: "storage.provider";
|
|
138
|
+
readonly equals: "upstash";
|
|
139
|
+
};
|
|
140
|
+
}, {
|
|
141
|
+
readonly id: "storage.table";
|
|
142
|
+
readonly domain: "storage";
|
|
143
|
+
readonly target: "config";
|
|
144
|
+
readonly path: "storage.table";
|
|
145
|
+
readonly kind: "string";
|
|
146
|
+
readonly scopes: ["full"];
|
|
147
|
+
readonly label: "DynamoDB table";
|
|
148
|
+
readonly prompt: "DynamoDB table name";
|
|
149
|
+
readonly defaultValue: "";
|
|
150
|
+
readonly dependsOn: {
|
|
151
|
+
readonly fieldId: "storage.provider";
|
|
152
|
+
readonly equals: "dynamodb";
|
|
153
|
+
};
|
|
154
|
+
}, {
|
|
155
|
+
readonly id: "storage.region";
|
|
156
|
+
readonly domain: "storage";
|
|
157
|
+
readonly target: "config";
|
|
158
|
+
readonly path: "storage.region";
|
|
159
|
+
readonly kind: "string";
|
|
160
|
+
readonly scopes: ["full"];
|
|
161
|
+
readonly label: "DynamoDB region";
|
|
162
|
+
readonly prompt: "DynamoDB region (optional)";
|
|
163
|
+
readonly defaultValue: "";
|
|
164
|
+
readonly dependsOn: {
|
|
165
|
+
readonly fieldId: "storage.provider";
|
|
166
|
+
readonly equals: "dynamodb";
|
|
167
|
+
};
|
|
168
|
+
}, {
|
|
169
|
+
readonly id: "storage.memory.enabled";
|
|
170
|
+
readonly domain: "memory";
|
|
171
|
+
readonly target: "config";
|
|
172
|
+
readonly path: "storage.memory.enabled";
|
|
173
|
+
readonly kind: "boolean";
|
|
174
|
+
readonly scopes: ["light", "full"];
|
|
175
|
+
readonly label: "Enable memory tools";
|
|
176
|
+
readonly prompt: "Enable memory tools (memory_get, memory_update, conversation_recall)?";
|
|
177
|
+
readonly defaultValue: true;
|
|
178
|
+
}, {
|
|
179
|
+
readonly id: "storage.memory.maxRecallConversations";
|
|
180
|
+
readonly domain: "memory";
|
|
181
|
+
readonly target: "config";
|
|
182
|
+
readonly path: "storage.memory.maxRecallConversations";
|
|
183
|
+
readonly kind: "number";
|
|
184
|
+
readonly scopes: ["full"];
|
|
185
|
+
readonly label: "Max recall conversations";
|
|
186
|
+
readonly prompt: "Max conversations scanned by conversation_recall";
|
|
187
|
+
readonly defaultValue: 20;
|
|
188
|
+
readonly dependsOn: {
|
|
189
|
+
readonly fieldId: "storage.memory.enabled";
|
|
190
|
+
readonly equals: true;
|
|
191
|
+
};
|
|
192
|
+
}, {
|
|
193
|
+
readonly id: "auth.required";
|
|
194
|
+
readonly domain: "auth";
|
|
195
|
+
readonly target: "config";
|
|
196
|
+
readonly path: "auth.required";
|
|
197
|
+
readonly kind: "boolean";
|
|
198
|
+
readonly scopes: ["light", "full"];
|
|
199
|
+
readonly label: "Require auth";
|
|
200
|
+
readonly prompt: "Require auth for API requests?";
|
|
201
|
+
readonly defaultValue: false;
|
|
202
|
+
}, {
|
|
203
|
+
readonly id: "auth.type";
|
|
204
|
+
readonly domain: "auth";
|
|
205
|
+
readonly target: "config";
|
|
206
|
+
readonly path: "auth.type";
|
|
207
|
+
readonly kind: "select";
|
|
208
|
+
readonly scopes: ["full"];
|
|
209
|
+
readonly label: "Auth type";
|
|
210
|
+
readonly prompt: "Auth type";
|
|
211
|
+
readonly defaultValue: "bearer";
|
|
212
|
+
readonly options: [{
|
|
213
|
+
readonly value: "bearer";
|
|
214
|
+
readonly label: "Bearer token";
|
|
215
|
+
}, {
|
|
216
|
+
readonly value: "header";
|
|
217
|
+
readonly label: "Custom header";
|
|
218
|
+
}, {
|
|
219
|
+
readonly value: "custom";
|
|
220
|
+
readonly label: "Custom validate() function";
|
|
221
|
+
}];
|
|
222
|
+
readonly dependsOn: {
|
|
223
|
+
readonly fieldId: "auth.required";
|
|
224
|
+
readonly equals: true;
|
|
225
|
+
};
|
|
226
|
+
}, {
|
|
227
|
+
readonly id: "auth.headerName";
|
|
228
|
+
readonly domain: "auth";
|
|
229
|
+
readonly target: "config";
|
|
230
|
+
readonly path: "auth.headerName";
|
|
231
|
+
readonly kind: "string";
|
|
232
|
+
readonly scopes: ["full"];
|
|
233
|
+
readonly label: "Header name";
|
|
234
|
+
readonly prompt: "Header name (for auth type=header)";
|
|
235
|
+
readonly defaultValue: "x-poncho-key";
|
|
236
|
+
readonly dependsOn: {
|
|
237
|
+
readonly fieldId: "auth.type";
|
|
238
|
+
readonly equals: "header";
|
|
239
|
+
};
|
|
240
|
+
}, {
|
|
241
|
+
readonly id: "telemetry.enabled";
|
|
242
|
+
readonly domain: "telemetry";
|
|
243
|
+
readonly target: "config";
|
|
244
|
+
readonly path: "telemetry.enabled";
|
|
245
|
+
readonly kind: "boolean";
|
|
246
|
+
readonly scopes: ["light", "full"];
|
|
247
|
+
readonly label: "Enable telemetry";
|
|
248
|
+
readonly prompt: "Enable telemetry?";
|
|
249
|
+
readonly defaultValue: true;
|
|
250
|
+
}, {
|
|
251
|
+
readonly id: "telemetry.otlp";
|
|
252
|
+
readonly domain: "telemetry";
|
|
253
|
+
readonly target: "config";
|
|
254
|
+
readonly path: "telemetry.otlp";
|
|
255
|
+
readonly kind: "string";
|
|
256
|
+
readonly scopes: ["full"];
|
|
257
|
+
readonly label: "OTLP endpoint";
|
|
258
|
+
readonly prompt: "OTLP endpoint (optional)";
|
|
259
|
+
readonly defaultValue: "";
|
|
260
|
+
readonly dependsOn: {
|
|
261
|
+
readonly fieldId: "telemetry.enabled";
|
|
262
|
+
readonly equals: true;
|
|
263
|
+
};
|
|
264
|
+
}];
|
|
265
|
+
declare const FEATURE_DOMAIN_ORDER: readonly FeatureDomain[];
|
|
266
|
+
declare const fieldsForScope: (scope: OnboardingScope) => OnboardingField[];
|
|
267
|
+
|
|
268
|
+
type JsonSchema = {
|
|
269
|
+
type?: string;
|
|
270
|
+
description?: string;
|
|
271
|
+
properties?: Record<string, JsonSchema>;
|
|
272
|
+
required?: string[];
|
|
273
|
+
items?: JsonSchema;
|
|
274
|
+
enum?: Array<string | number | boolean | null>;
|
|
275
|
+
additionalProperties?: boolean | JsonSchema;
|
|
276
|
+
[key: string]: unknown;
|
|
277
|
+
};
|
|
278
|
+
type Role = "system" | "user" | "assistant" | "tool";
|
|
279
|
+
interface Message {
|
|
280
|
+
role: Role;
|
|
281
|
+
content: string;
|
|
282
|
+
metadata?: {
|
|
283
|
+
id?: string;
|
|
284
|
+
timestamp?: number;
|
|
285
|
+
tokenCount?: number;
|
|
286
|
+
step?: number;
|
|
287
|
+
toolActivity?: string[];
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
interface ToolContext {
|
|
291
|
+
runId: string;
|
|
292
|
+
agentId: string;
|
|
293
|
+
step: number;
|
|
294
|
+
workingDir: string;
|
|
295
|
+
parameters: Record<string, unknown>;
|
|
296
|
+
}
|
|
297
|
+
type ToolHandler<TInput extends Record<string, unknown>, TOutput> = (input: TInput, context: ToolContext) => Promise<TOutput> | TOutput;
|
|
298
|
+
interface ToolDefinition<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> {
|
|
299
|
+
name: string;
|
|
300
|
+
description: string;
|
|
301
|
+
inputSchema: JsonSchema;
|
|
302
|
+
outputSchema?: JsonSchema;
|
|
303
|
+
timeout?: number;
|
|
304
|
+
retries?: number;
|
|
305
|
+
isolated?: boolean;
|
|
306
|
+
requiresApproval?: boolean;
|
|
307
|
+
handler: ToolHandler<TInput, TOutput>;
|
|
308
|
+
}
|
|
309
|
+
declare const defineTool: <TInput extends Record<string, unknown>, TOutput = unknown>(definition: ToolDefinition<TInput, TOutput>) => ToolDefinition<TInput, TOutput>;
|
|
310
|
+
|
|
311
|
+
interface RunInput {
|
|
312
|
+
task: string;
|
|
313
|
+
parameters?: Record<string, unknown>;
|
|
314
|
+
messages?: Message[];
|
|
315
|
+
}
|
|
316
|
+
interface TokenUsage {
|
|
317
|
+
input: number;
|
|
318
|
+
output: number;
|
|
319
|
+
cached: number;
|
|
320
|
+
}
|
|
321
|
+
interface RunResult {
|
|
322
|
+
status: "completed" | "error" | "cancelled";
|
|
323
|
+
response?: string;
|
|
324
|
+
steps: number;
|
|
325
|
+
tokens: TokenUsage;
|
|
326
|
+
duration: number;
|
|
327
|
+
}
|
|
328
|
+
interface AgentFailure {
|
|
329
|
+
code: string;
|
|
330
|
+
message: string;
|
|
331
|
+
details?: Record<string, unknown>;
|
|
332
|
+
}
|
|
333
|
+
type AgentEvent = {
|
|
334
|
+
type: "run:started";
|
|
335
|
+
runId: string;
|
|
336
|
+
agentId: string;
|
|
337
|
+
} | {
|
|
338
|
+
type: "run:completed";
|
|
339
|
+
runId: string;
|
|
340
|
+
result: RunResult;
|
|
341
|
+
} | {
|
|
342
|
+
type: "run:error";
|
|
343
|
+
runId: string;
|
|
344
|
+
error: AgentFailure;
|
|
345
|
+
} | {
|
|
346
|
+
type: "step:started";
|
|
347
|
+
step: number;
|
|
348
|
+
} | {
|
|
349
|
+
type: "step:completed";
|
|
350
|
+
step: number;
|
|
351
|
+
duration: number;
|
|
352
|
+
} | {
|
|
353
|
+
type: "model:request";
|
|
354
|
+
tokens: number;
|
|
355
|
+
} | {
|
|
356
|
+
type: "model:chunk";
|
|
357
|
+
content: string;
|
|
358
|
+
} | {
|
|
359
|
+
type: "model:response";
|
|
360
|
+
usage: TokenUsage;
|
|
361
|
+
} | {
|
|
362
|
+
type: "tool:started";
|
|
363
|
+
tool: string;
|
|
364
|
+
input: unknown;
|
|
365
|
+
} | {
|
|
366
|
+
type: "tool:completed";
|
|
367
|
+
tool: string;
|
|
368
|
+
output: unknown;
|
|
369
|
+
duration: number;
|
|
370
|
+
} | {
|
|
371
|
+
type: "tool:error";
|
|
372
|
+
tool: string;
|
|
373
|
+
error: string;
|
|
374
|
+
recoverable: boolean;
|
|
375
|
+
} | {
|
|
376
|
+
type: "tool:approval:required";
|
|
377
|
+
tool: string;
|
|
378
|
+
input: unknown;
|
|
379
|
+
approvalId: string;
|
|
380
|
+
} | {
|
|
381
|
+
type: "tool:approval:granted";
|
|
382
|
+
approvalId: string;
|
|
383
|
+
} | {
|
|
384
|
+
type: "tool:approval:denied";
|
|
385
|
+
approvalId: string;
|
|
386
|
+
reason?: string;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
export { type AgentEvent, type AgentFailure, FEATURE_DOMAIN_ORDER, type FeatureDomain, type JsonSchema, type Message, ONBOARDING_FIELDS, type OnboardingField, type OnboardingFieldCondition, type OnboardingFieldKind, type OnboardingFieldTarget, type OnboardingOption, type OnboardingScope, type Role, type RunInput, type RunResult, type TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, defineTool, fieldsForScope };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// src/config-registry.ts
|
|
2
|
+
var ONBOARDING_FIELDS = [
|
|
3
|
+
{
|
|
4
|
+
id: "model.provider",
|
|
5
|
+
domain: "model",
|
|
6
|
+
target: "agent",
|
|
7
|
+
path: "model.provider",
|
|
8
|
+
kind: "select",
|
|
9
|
+
scopes: ["light", "full"],
|
|
10
|
+
label: "Model provider",
|
|
11
|
+
prompt: "Choose a model provider",
|
|
12
|
+
defaultValue: "anthropic",
|
|
13
|
+
options: [
|
|
14
|
+
{ value: "anthropic", label: "Anthropic", envVars: ["ANTHROPIC_API_KEY"] },
|
|
15
|
+
{ value: "openai", label: "OpenAI", envVars: ["OPENAI_API_KEY"] }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "env.ANTHROPIC_API_KEY",
|
|
20
|
+
domain: "model",
|
|
21
|
+
target: "env",
|
|
22
|
+
path: "ANTHROPIC_API_KEY",
|
|
23
|
+
kind: "string",
|
|
24
|
+
scopes: ["light", "full"],
|
|
25
|
+
label: "Anthropic API key",
|
|
26
|
+
prompt: "Anthropic API key",
|
|
27
|
+
defaultValue: "",
|
|
28
|
+
placeholder: "sk-ant-...",
|
|
29
|
+
secret: true,
|
|
30
|
+
dependsOn: { fieldId: "model.provider", equals: "anthropic" }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "env.OPENAI_API_KEY",
|
|
34
|
+
domain: "model",
|
|
35
|
+
target: "env",
|
|
36
|
+
path: "OPENAI_API_KEY",
|
|
37
|
+
kind: "string",
|
|
38
|
+
scopes: ["light", "full"],
|
|
39
|
+
label: "OpenAI API key",
|
|
40
|
+
prompt: "OpenAI API key",
|
|
41
|
+
defaultValue: "",
|
|
42
|
+
placeholder: "sk-...",
|
|
43
|
+
secret: true,
|
|
44
|
+
dependsOn: { fieldId: "model.provider", equals: "openai" }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "storage.provider",
|
|
48
|
+
domain: "storage",
|
|
49
|
+
target: "config",
|
|
50
|
+
path: "storage.provider",
|
|
51
|
+
kind: "select",
|
|
52
|
+
scopes: ["light", "full"],
|
|
53
|
+
label: "Storage provider",
|
|
54
|
+
prompt: "Choose storage provider for conversations and memory",
|
|
55
|
+
defaultValue: "local",
|
|
56
|
+
options: [
|
|
57
|
+
{ value: "memory", label: "In-memory only" },
|
|
58
|
+
{ value: "local", label: "Local file storage" },
|
|
59
|
+
{ value: "redis", label: "Redis", envVars: ["REDIS_URL"] },
|
|
60
|
+
{
|
|
61
|
+
value: "upstash",
|
|
62
|
+
label: "Upstash REST",
|
|
63
|
+
envVars: ["UPSTASH_REDIS_REST_URL", "UPSTASH_REDIS_REST_TOKEN"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: "dynamodb",
|
|
67
|
+
label: "DynamoDB",
|
|
68
|
+
envVars: ["PONCHO_DYNAMODB_TABLE"]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "storage.url",
|
|
74
|
+
domain: "storage",
|
|
75
|
+
target: "config",
|
|
76
|
+
path: "storage.url",
|
|
77
|
+
kind: "string",
|
|
78
|
+
scopes: ["full"],
|
|
79
|
+
label: "Storage URL",
|
|
80
|
+
prompt: "Storage URL",
|
|
81
|
+
defaultValue: "",
|
|
82
|
+
dependsOn: { fieldId: "storage.provider", oneOf: ["redis", "upstash"] }
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "storage.token",
|
|
86
|
+
domain: "storage",
|
|
87
|
+
target: "config",
|
|
88
|
+
path: "storage.token",
|
|
89
|
+
kind: "string",
|
|
90
|
+
scopes: ["full"],
|
|
91
|
+
label: "Storage token",
|
|
92
|
+
prompt: "Storage token",
|
|
93
|
+
defaultValue: "",
|
|
94
|
+
dependsOn: { fieldId: "storage.provider", equals: "upstash" }
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "storage.table",
|
|
98
|
+
domain: "storage",
|
|
99
|
+
target: "config",
|
|
100
|
+
path: "storage.table",
|
|
101
|
+
kind: "string",
|
|
102
|
+
scopes: ["full"],
|
|
103
|
+
label: "DynamoDB table",
|
|
104
|
+
prompt: "DynamoDB table name",
|
|
105
|
+
defaultValue: "",
|
|
106
|
+
dependsOn: { fieldId: "storage.provider", equals: "dynamodb" }
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "storage.region",
|
|
110
|
+
domain: "storage",
|
|
111
|
+
target: "config",
|
|
112
|
+
path: "storage.region",
|
|
113
|
+
kind: "string",
|
|
114
|
+
scopes: ["full"],
|
|
115
|
+
label: "DynamoDB region",
|
|
116
|
+
prompt: "DynamoDB region (optional)",
|
|
117
|
+
defaultValue: "",
|
|
118
|
+
dependsOn: { fieldId: "storage.provider", equals: "dynamodb" }
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "storage.memory.enabled",
|
|
122
|
+
domain: "memory",
|
|
123
|
+
target: "config",
|
|
124
|
+
path: "storage.memory.enabled",
|
|
125
|
+
kind: "boolean",
|
|
126
|
+
scopes: ["light", "full"],
|
|
127
|
+
label: "Enable memory tools",
|
|
128
|
+
prompt: "Enable memory tools (memory_get, memory_update, conversation_recall)?",
|
|
129
|
+
defaultValue: true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "storage.memory.maxRecallConversations",
|
|
133
|
+
domain: "memory",
|
|
134
|
+
target: "config",
|
|
135
|
+
path: "storage.memory.maxRecallConversations",
|
|
136
|
+
kind: "number",
|
|
137
|
+
scopes: ["full"],
|
|
138
|
+
label: "Max recall conversations",
|
|
139
|
+
prompt: "Max conversations scanned by conversation_recall",
|
|
140
|
+
defaultValue: 20,
|
|
141
|
+
dependsOn: { fieldId: "storage.memory.enabled", equals: true }
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "auth.required",
|
|
145
|
+
domain: "auth",
|
|
146
|
+
target: "config",
|
|
147
|
+
path: "auth.required",
|
|
148
|
+
kind: "boolean",
|
|
149
|
+
scopes: ["light", "full"],
|
|
150
|
+
label: "Require auth",
|
|
151
|
+
prompt: "Require auth for API requests?",
|
|
152
|
+
defaultValue: false
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "auth.type",
|
|
156
|
+
domain: "auth",
|
|
157
|
+
target: "config",
|
|
158
|
+
path: "auth.type",
|
|
159
|
+
kind: "select",
|
|
160
|
+
scopes: ["full"],
|
|
161
|
+
label: "Auth type",
|
|
162
|
+
prompt: "Auth type",
|
|
163
|
+
defaultValue: "bearer",
|
|
164
|
+
options: [
|
|
165
|
+
{ value: "bearer", label: "Bearer token" },
|
|
166
|
+
{ value: "header", label: "Custom header" },
|
|
167
|
+
{ value: "custom", label: "Custom validate() function" }
|
|
168
|
+
],
|
|
169
|
+
dependsOn: { fieldId: "auth.required", equals: true }
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: "auth.headerName",
|
|
173
|
+
domain: "auth",
|
|
174
|
+
target: "config",
|
|
175
|
+
path: "auth.headerName",
|
|
176
|
+
kind: "string",
|
|
177
|
+
scopes: ["full"],
|
|
178
|
+
label: "Header name",
|
|
179
|
+
prompt: "Header name (for auth type=header)",
|
|
180
|
+
defaultValue: "x-poncho-key",
|
|
181
|
+
dependsOn: { fieldId: "auth.type", equals: "header" }
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: "telemetry.enabled",
|
|
185
|
+
domain: "telemetry",
|
|
186
|
+
target: "config",
|
|
187
|
+
path: "telemetry.enabled",
|
|
188
|
+
kind: "boolean",
|
|
189
|
+
scopes: ["light", "full"],
|
|
190
|
+
label: "Enable telemetry",
|
|
191
|
+
prompt: "Enable telemetry?",
|
|
192
|
+
defaultValue: true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: "telemetry.otlp",
|
|
196
|
+
domain: "telemetry",
|
|
197
|
+
target: "config",
|
|
198
|
+
path: "telemetry.otlp",
|
|
199
|
+
kind: "string",
|
|
200
|
+
scopes: ["full"],
|
|
201
|
+
label: "OTLP endpoint",
|
|
202
|
+
prompt: "OTLP endpoint (optional)",
|
|
203
|
+
defaultValue: "",
|
|
204
|
+
dependsOn: { fieldId: "telemetry.enabled", equals: true }
|
|
205
|
+
}
|
|
206
|
+
];
|
|
207
|
+
var FEATURE_DOMAIN_ORDER = [
|
|
208
|
+
"model",
|
|
209
|
+
"storage",
|
|
210
|
+
"memory",
|
|
211
|
+
"auth",
|
|
212
|
+
"telemetry",
|
|
213
|
+
"mcp"
|
|
214
|
+
];
|
|
215
|
+
var fieldsForScope = (scope) => ONBOARDING_FIELDS.filter(
|
|
216
|
+
(field) => field.scopes.includes(scope)
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// src/index.ts
|
|
220
|
+
var defineTool = (definition) => definition;
|
|
221
|
+
export {
|
|
222
|
+
FEATURE_DOMAIN_ORDER,
|
|
223
|
+
ONBOARDING_FIELDS,
|
|
224
|
+
defineTool,
|
|
225
|
+
fieldsForScope
|
|
226
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@poncho-ai/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Core types and utilities for building Poncho skills",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/latitude-dev/poncho-ai.git",
|
|
8
|
+
"directory": "packages/sdk"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"zod": "^3.22.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsup": "^8.0.0",
|
|
27
|
+
"vitest": "^1.4.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"ai",
|
|
31
|
+
"agent",
|
|
32
|
+
"sdk",
|
|
33
|
+
"tools"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
38
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"lint": "eslint src/"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
export type OnboardingScope = "light" | "full";
|
|
2
|
+
|
|
3
|
+
export type FeatureDomain =
|
|
4
|
+
| "model"
|
|
5
|
+
| "storage"
|
|
6
|
+
| "memory"
|
|
7
|
+
| "auth"
|
|
8
|
+
| "telemetry"
|
|
9
|
+
| "mcp";
|
|
10
|
+
|
|
11
|
+
export type OnboardingFieldTarget = "agent" | "config" | "env";
|
|
12
|
+
|
|
13
|
+
export type OnboardingFieldKind = "select" | "boolean" | "string" | "number";
|
|
14
|
+
|
|
15
|
+
export type OnboardingFieldCondition = {
|
|
16
|
+
fieldId: string;
|
|
17
|
+
equals?: string | number | boolean;
|
|
18
|
+
oneOf?: Array<string | number | boolean>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type OnboardingOption = {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
envVars?: string[];
|
|
25
|
+
description?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type OnboardingField = {
|
|
29
|
+
id: string;
|
|
30
|
+
domain: FeatureDomain;
|
|
31
|
+
target: OnboardingFieldTarget;
|
|
32
|
+
path: string;
|
|
33
|
+
kind: OnboardingFieldKind;
|
|
34
|
+
scopes: OnboardingScope[];
|
|
35
|
+
label: string;
|
|
36
|
+
prompt: string;
|
|
37
|
+
defaultValue: string | number | boolean;
|
|
38
|
+
options?: OnboardingOption[];
|
|
39
|
+
envVars?: string[];
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
secret?: boolean;
|
|
42
|
+
dependsOn?: OnboardingFieldCondition;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const ONBOARDING_FIELDS = [
|
|
46
|
+
{
|
|
47
|
+
id: "model.provider",
|
|
48
|
+
domain: "model",
|
|
49
|
+
target: "agent",
|
|
50
|
+
path: "model.provider",
|
|
51
|
+
kind: "select",
|
|
52
|
+
scopes: ["light", "full"],
|
|
53
|
+
label: "Model provider",
|
|
54
|
+
prompt: "Choose a model provider",
|
|
55
|
+
defaultValue: "anthropic",
|
|
56
|
+
options: [
|
|
57
|
+
{ value: "anthropic", label: "Anthropic", envVars: ["ANTHROPIC_API_KEY"] },
|
|
58
|
+
{ value: "openai", label: "OpenAI", envVars: ["OPENAI_API_KEY"] },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "env.ANTHROPIC_API_KEY",
|
|
63
|
+
domain: "model",
|
|
64
|
+
target: "env",
|
|
65
|
+
path: "ANTHROPIC_API_KEY",
|
|
66
|
+
kind: "string",
|
|
67
|
+
scopes: ["light", "full"],
|
|
68
|
+
label: "Anthropic API key",
|
|
69
|
+
prompt: "Anthropic API key",
|
|
70
|
+
defaultValue: "",
|
|
71
|
+
placeholder: "sk-ant-...",
|
|
72
|
+
secret: true,
|
|
73
|
+
dependsOn: { fieldId: "model.provider", equals: "anthropic" },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "env.OPENAI_API_KEY",
|
|
77
|
+
domain: "model",
|
|
78
|
+
target: "env",
|
|
79
|
+
path: "OPENAI_API_KEY",
|
|
80
|
+
kind: "string",
|
|
81
|
+
scopes: ["light", "full"],
|
|
82
|
+
label: "OpenAI API key",
|
|
83
|
+
prompt: "OpenAI API key",
|
|
84
|
+
defaultValue: "",
|
|
85
|
+
placeholder: "sk-...",
|
|
86
|
+
secret: true,
|
|
87
|
+
dependsOn: { fieldId: "model.provider", equals: "openai" },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "storage.provider",
|
|
91
|
+
domain: "storage",
|
|
92
|
+
target: "config",
|
|
93
|
+
path: "storage.provider",
|
|
94
|
+
kind: "select",
|
|
95
|
+
scopes: ["light", "full"],
|
|
96
|
+
label: "Storage provider",
|
|
97
|
+
prompt: "Choose storage provider for conversations and memory",
|
|
98
|
+
defaultValue: "local",
|
|
99
|
+
options: [
|
|
100
|
+
{ value: "memory", label: "In-memory only" },
|
|
101
|
+
{ value: "local", label: "Local file storage" },
|
|
102
|
+
{ value: "redis", label: "Redis", envVars: ["REDIS_URL"] },
|
|
103
|
+
{
|
|
104
|
+
value: "upstash",
|
|
105
|
+
label: "Upstash REST",
|
|
106
|
+
envVars: ["UPSTASH_REDIS_REST_URL", "UPSTASH_REDIS_REST_TOKEN"],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
value: "dynamodb",
|
|
110
|
+
label: "DynamoDB",
|
|
111
|
+
envVars: ["PONCHO_DYNAMODB_TABLE"],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "storage.url",
|
|
117
|
+
domain: "storage",
|
|
118
|
+
target: "config",
|
|
119
|
+
path: "storage.url",
|
|
120
|
+
kind: "string",
|
|
121
|
+
scopes: ["full"],
|
|
122
|
+
label: "Storage URL",
|
|
123
|
+
prompt: "Storage URL",
|
|
124
|
+
defaultValue: "",
|
|
125
|
+
dependsOn: { fieldId: "storage.provider", oneOf: ["redis", "upstash"] },
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "storage.token",
|
|
129
|
+
domain: "storage",
|
|
130
|
+
target: "config",
|
|
131
|
+
path: "storage.token",
|
|
132
|
+
kind: "string",
|
|
133
|
+
scopes: ["full"],
|
|
134
|
+
label: "Storage token",
|
|
135
|
+
prompt: "Storage token",
|
|
136
|
+
defaultValue: "",
|
|
137
|
+
dependsOn: { fieldId: "storage.provider", equals: "upstash" },
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "storage.table",
|
|
141
|
+
domain: "storage",
|
|
142
|
+
target: "config",
|
|
143
|
+
path: "storage.table",
|
|
144
|
+
kind: "string",
|
|
145
|
+
scopes: ["full"],
|
|
146
|
+
label: "DynamoDB table",
|
|
147
|
+
prompt: "DynamoDB table name",
|
|
148
|
+
defaultValue: "",
|
|
149
|
+
dependsOn: { fieldId: "storage.provider", equals: "dynamodb" },
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "storage.region",
|
|
153
|
+
domain: "storage",
|
|
154
|
+
target: "config",
|
|
155
|
+
path: "storage.region",
|
|
156
|
+
kind: "string",
|
|
157
|
+
scopes: ["full"],
|
|
158
|
+
label: "DynamoDB region",
|
|
159
|
+
prompt: "DynamoDB region (optional)",
|
|
160
|
+
defaultValue: "",
|
|
161
|
+
dependsOn: { fieldId: "storage.provider", equals: "dynamodb" },
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "storage.memory.enabled",
|
|
165
|
+
domain: "memory",
|
|
166
|
+
target: "config",
|
|
167
|
+
path: "storage.memory.enabled",
|
|
168
|
+
kind: "boolean",
|
|
169
|
+
scopes: ["light", "full"],
|
|
170
|
+
label: "Enable memory tools",
|
|
171
|
+
prompt: "Enable memory tools (memory_get, memory_update, conversation_recall)?",
|
|
172
|
+
defaultValue: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "storage.memory.maxRecallConversations",
|
|
176
|
+
domain: "memory",
|
|
177
|
+
target: "config",
|
|
178
|
+
path: "storage.memory.maxRecallConversations",
|
|
179
|
+
kind: "number",
|
|
180
|
+
scopes: ["full"],
|
|
181
|
+
label: "Max recall conversations",
|
|
182
|
+
prompt: "Max conversations scanned by conversation_recall",
|
|
183
|
+
defaultValue: 20,
|
|
184
|
+
dependsOn: { fieldId: "storage.memory.enabled", equals: true },
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: "auth.required",
|
|
188
|
+
domain: "auth",
|
|
189
|
+
target: "config",
|
|
190
|
+
path: "auth.required",
|
|
191
|
+
kind: "boolean",
|
|
192
|
+
scopes: ["light", "full"],
|
|
193
|
+
label: "Require auth",
|
|
194
|
+
prompt: "Require auth for API requests?",
|
|
195
|
+
defaultValue: false,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "auth.type",
|
|
199
|
+
domain: "auth",
|
|
200
|
+
target: "config",
|
|
201
|
+
path: "auth.type",
|
|
202
|
+
kind: "select",
|
|
203
|
+
scopes: ["full"],
|
|
204
|
+
label: "Auth type",
|
|
205
|
+
prompt: "Auth type",
|
|
206
|
+
defaultValue: "bearer",
|
|
207
|
+
options: [
|
|
208
|
+
{ value: "bearer", label: "Bearer token" },
|
|
209
|
+
{ value: "header", label: "Custom header" },
|
|
210
|
+
{ value: "custom", label: "Custom validate() function" },
|
|
211
|
+
],
|
|
212
|
+
dependsOn: { fieldId: "auth.required", equals: true },
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: "auth.headerName",
|
|
216
|
+
domain: "auth",
|
|
217
|
+
target: "config",
|
|
218
|
+
path: "auth.headerName",
|
|
219
|
+
kind: "string",
|
|
220
|
+
scopes: ["full"],
|
|
221
|
+
label: "Header name",
|
|
222
|
+
prompt: "Header name (for auth type=header)",
|
|
223
|
+
defaultValue: "x-poncho-key",
|
|
224
|
+
dependsOn: { fieldId: "auth.type", equals: "header" },
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "telemetry.enabled",
|
|
228
|
+
domain: "telemetry",
|
|
229
|
+
target: "config",
|
|
230
|
+
path: "telemetry.enabled",
|
|
231
|
+
kind: "boolean",
|
|
232
|
+
scopes: ["light", "full"],
|
|
233
|
+
label: "Enable telemetry",
|
|
234
|
+
prompt: "Enable telemetry?",
|
|
235
|
+
defaultValue: true,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
id: "telemetry.otlp",
|
|
239
|
+
domain: "telemetry",
|
|
240
|
+
target: "config",
|
|
241
|
+
path: "telemetry.otlp",
|
|
242
|
+
kind: "string",
|
|
243
|
+
scopes: ["full"],
|
|
244
|
+
label: "OTLP endpoint",
|
|
245
|
+
prompt: "OTLP endpoint (optional)",
|
|
246
|
+
defaultValue: "",
|
|
247
|
+
dependsOn: { fieldId: "telemetry.enabled", equals: true },
|
|
248
|
+
},
|
|
249
|
+
] as const satisfies readonly OnboardingField[];
|
|
250
|
+
|
|
251
|
+
export const FEATURE_DOMAIN_ORDER: readonly FeatureDomain[] = [
|
|
252
|
+
"model",
|
|
253
|
+
"storage",
|
|
254
|
+
"memory",
|
|
255
|
+
"auth",
|
|
256
|
+
"telemetry",
|
|
257
|
+
"mcp",
|
|
258
|
+
] as const;
|
|
259
|
+
|
|
260
|
+
export const fieldsForScope = (scope: OnboardingScope): OnboardingField[] =>
|
|
261
|
+
ONBOARDING_FIELDS.filter((field) =>
|
|
262
|
+
(field.scopes as readonly OnboardingScope[]).includes(scope),
|
|
263
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export type JsonSchema = {
|
|
2
|
+
type?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
properties?: Record<string, JsonSchema>;
|
|
5
|
+
required?: string[];
|
|
6
|
+
items?: JsonSchema;
|
|
7
|
+
enum?: Array<string | number | boolean | null>;
|
|
8
|
+
additionalProperties?: boolean | JsonSchema;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Role = "system" | "user" | "assistant" | "tool";
|
|
13
|
+
|
|
14
|
+
export interface Message {
|
|
15
|
+
role: Role;
|
|
16
|
+
content: string;
|
|
17
|
+
metadata?: {
|
|
18
|
+
id?: string;
|
|
19
|
+
timestamp?: number;
|
|
20
|
+
tokenCount?: number;
|
|
21
|
+
step?: number;
|
|
22
|
+
toolActivity?: string[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ToolContext {
|
|
27
|
+
runId: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
step: number;
|
|
30
|
+
workingDir: string;
|
|
31
|
+
parameters: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ToolHandler<TInput extends Record<string, unknown>, TOutput> = (
|
|
35
|
+
input: TInput,
|
|
36
|
+
context: ToolContext,
|
|
37
|
+
) => Promise<TOutput> | TOutput;
|
|
38
|
+
|
|
39
|
+
export interface ToolDefinition<
|
|
40
|
+
TInput extends Record<string, unknown> = Record<string, unknown>,
|
|
41
|
+
TOutput = unknown,
|
|
42
|
+
> {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: JsonSchema;
|
|
46
|
+
outputSchema?: JsonSchema;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
retries?: number;
|
|
49
|
+
isolated?: boolean;
|
|
50
|
+
requiresApproval?: boolean;
|
|
51
|
+
handler: ToolHandler<TInput, TOutput>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const defineTool = <
|
|
55
|
+
TInput extends Record<string, unknown>,
|
|
56
|
+
TOutput = unknown,
|
|
57
|
+
>(
|
|
58
|
+
definition: ToolDefinition<TInput, TOutput>,
|
|
59
|
+
): ToolDefinition<TInput, TOutput> => definition;
|
|
60
|
+
|
|
61
|
+
export * from "./config-registry.js";
|
|
62
|
+
|
|
63
|
+
export interface RunInput {
|
|
64
|
+
task: string;
|
|
65
|
+
parameters?: Record<string, unknown>;
|
|
66
|
+
messages?: Message[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TokenUsage {
|
|
70
|
+
input: number;
|
|
71
|
+
output: number;
|
|
72
|
+
cached: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface RunResult {
|
|
76
|
+
status: "completed" | "error" | "cancelled";
|
|
77
|
+
response?: string;
|
|
78
|
+
steps: number;
|
|
79
|
+
tokens: TokenUsage;
|
|
80
|
+
duration: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface AgentFailure {
|
|
84
|
+
code: string;
|
|
85
|
+
message: string;
|
|
86
|
+
details?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type AgentEvent =
|
|
90
|
+
| { type: "run:started"; runId: string; agentId: string }
|
|
91
|
+
| { type: "run:completed"; runId: string; result: RunResult }
|
|
92
|
+
| { type: "run:error"; runId: string; error: AgentFailure }
|
|
93
|
+
| { type: "step:started"; step: number }
|
|
94
|
+
| { type: "step:completed"; step: number; duration: number }
|
|
95
|
+
| { type: "model:request"; tokens: number }
|
|
96
|
+
| { type: "model:chunk"; content: string }
|
|
97
|
+
| { type: "model:response"; usage: TokenUsage }
|
|
98
|
+
| { type: "tool:started"; tool: string; input: unknown }
|
|
99
|
+
| { type: "tool:completed"; tool: string; output: unknown; duration: number }
|
|
100
|
+
| { type: "tool:error"; tool: string; error: string; recoverable: boolean }
|
|
101
|
+
| {
|
|
102
|
+
type: "tool:approval:required";
|
|
103
|
+
tool: string;
|
|
104
|
+
input: unknown;
|
|
105
|
+
approvalId: string;
|
|
106
|
+
}
|
|
107
|
+
| { type: "tool:approval:granted"; approvalId: string }
|
|
108
|
+
| { type: "tool:approval:denied"; approvalId: string; reason?: string };
|
package/test/sdk.test.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { defineTool } from "../src/index.js";
|
|
3
|
+
|
|
4
|
+
describe("defineTool", () => {
|
|
5
|
+
it("returns the same tool definition", () => {
|
|
6
|
+
const tool = defineTool({
|
|
7
|
+
name: "echo",
|
|
8
|
+
description: "Echoes text",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: { text: { type: "string" } },
|
|
12
|
+
required: ["text"],
|
|
13
|
+
},
|
|
14
|
+
handler: async (input) => ({ text: input.text }),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(tool.name).toBe("echo");
|
|
18
|
+
expect(tool.description).toBe("Echoes text");
|
|
19
|
+
});
|
|
20
|
+
});
|