@positronic/core 0.0.53 → 0.0.55
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/dist/src/dsl/execution/event-stream.js +5 -3
- package/dist/src/index.js +1 -1
- package/dist/src/tools/index.js +69 -6
- package/dist/types/dsl/execution/event-stream.d.ts.map +1 -1
- package/dist/types/dsl/types.d.ts +2 -2
- package/dist/types/dsl/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools/index.d.ts +99 -6
- package/dist/types/tools/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1082,7 +1082,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1082
1082
|
key: "executeAgent",
|
|
1083
1083
|
value: function executeAgent(step) {
|
|
1084
1084
|
return _wrap_async_generator(function() {
|
|
1085
|
-
var block, prevState, _this_defaultTools, defaultTools, _this_components, components, _this_options, config, _config_tools, mergedTools, messages, resumeContext, _this_options1, _this_options2, _this_options3, totalTokens, iteration, _this_options4, toolsForClient, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, toolDef, tool, systemPrompt, response, _this_options5, _this_options6, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, toolCall, _this_options7, tool1, _this_options8, toolResult, waitForResult, webhooks, _this_options9, _this_options10, _this_options11, err;
|
|
1085
|
+
var block, prevState, _this_defaultTools, defaultTools, _this_components, components, _this_options, config, _config_tools, mergedTools, messages, resumeContext, _this_options1, _this_options2, _config_prompt, prompt, _this_options3, totalTokens, iteration, _this_options4, toolsForClient, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, toolDef, tool, systemPrompt, response, _this_options5, _this_options6, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, toolCall, _this_options7, tool1, _this_options8, toolResult, waitForResult, webhooks, _this_options9, _this_options10, _this_options11, err;
|
|
1086
1086
|
return _ts_generator(this, function(_state) {
|
|
1087
1087
|
switch(_state.label){
|
|
1088
1088
|
case 0:
|
|
@@ -1154,6 +1154,8 @@ export var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1154
1154
|
6
|
|
1155
1155
|
];
|
|
1156
1156
|
case 4:
|
|
1157
|
+
// Use "Begin." as default prompt if not provided
|
|
1158
|
+
prompt = (_config_prompt = config.prompt) !== null && _config_prompt !== void 0 ? _config_prompt : 'Begin.';
|
|
1157
1159
|
// Emit agent start event (only for fresh starts)
|
|
1158
1160
|
return [
|
|
1159
1161
|
4,
|
|
@@ -1161,7 +1163,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1161
1163
|
type: BRAIN_EVENTS.AGENT_START,
|
|
1162
1164
|
stepTitle: step.block.title,
|
|
1163
1165
|
stepId: step.id,
|
|
1164
|
-
prompt:
|
|
1166
|
+
prompt: prompt,
|
|
1165
1167
|
system: config.system,
|
|
1166
1168
|
options: (_this_options3 = this.options) !== null && _this_options3 !== void 0 ? _this_options3 : {},
|
|
1167
1169
|
brainRunId: this.brainRunId
|
|
@@ -1173,7 +1175,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
|
|
|
1173
1175
|
messages = [
|
|
1174
1176
|
{
|
|
1175
1177
|
role: 'user',
|
|
1176
|
-
content:
|
|
1178
|
+
content: prompt
|
|
1177
1179
|
}
|
|
1178
1180
|
];
|
|
1179
1181
|
_state.label = 6;
|
package/dist/src/index.js
CHANGED
|
@@ -12,6 +12,6 @@ export { createResources } from './resources/resources.js';
|
|
|
12
12
|
export { createWebhook } from './dsl/webhook.js';
|
|
13
13
|
export { RESOURCE_TYPES } from './resources/resources.js';
|
|
14
14
|
// Default tools
|
|
15
|
-
export { defaultTools, generateUI } from './tools/index.js';
|
|
15
|
+
export { createTool, defaultTools, generateUI, consoleLog, done } from './tools/index.js';
|
|
16
16
|
// Brain state machine
|
|
17
17
|
export { createBrainExecutionMachine, createBrainMachine, sendEvent, getDepth, isTopLevel, getCurrentStep, getBrainStack, getBrainRunId, getExecutionState, getPendingWebhooks, getError, getCompletedSteps } from './dsl/brain-state-machine.js';
|
package/dist/src/tools/index.js
CHANGED
|
@@ -120,13 +120,36 @@ function _ts_generator(thisArg, body) {
|
|
|
120
120
|
}
|
|
121
121
|
import { z } from 'zod';
|
|
122
122
|
import { createWebhook } from '../dsl/webhook.js';
|
|
123
|
+
/**
|
|
124
|
+
* Helper function to create tools with proper type inference.
|
|
125
|
+
*
|
|
126
|
+
* This avoids the need to manually specify types on the execute function -
|
|
127
|
+
* TypeScript will infer them from the inputSchema.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const sendNotification = createTool({
|
|
132
|
+
* description: 'Send a push notification',
|
|
133
|
+
* inputSchema: z.object({
|
|
134
|
+
* message: z.string().describe('The notification message'),
|
|
135
|
+
* clickUrl: z.string().optional().describe('URL to open on click'),
|
|
136
|
+
* }),
|
|
137
|
+
* execute: async ({ message, clickUrl }) => { // Types inferred!
|
|
138
|
+
* await ntfy.send(message, clickUrl);
|
|
139
|
+
* return { sent: true };
|
|
140
|
+
* },
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/ export function createTool(config) {
|
|
144
|
+
return config;
|
|
145
|
+
}
|
|
123
146
|
/**
|
|
124
147
|
* Default generateUI tool - gets enriched with component metadata at runtime.
|
|
125
148
|
*
|
|
126
149
|
* This tool allows the LLM to generate a UI and wait for user response.
|
|
127
150
|
* The actual component list and descriptions are injected at runtime
|
|
128
151
|
* based on the components registered with .withComponents().
|
|
129
|
-
*/ export var generateUI = {
|
|
152
|
+
*/ export var generateUI = createTool({
|
|
130
153
|
description: 'Generate a UI to display to the user and wait for their response',
|
|
131
154
|
inputSchema: z.object({
|
|
132
155
|
component: z.string().describe('The component name to render'),
|
|
@@ -157,17 +180,55 @@ import { createWebhook } from '../dsl/webhook.js';
|
|
|
157
180
|
waitFor: uiWebhook('pending')
|
|
158
181
|
};
|
|
159
182
|
}
|
|
160
|
-
};
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Console log tool - useful for debugging and logging information during agent execution.
|
|
186
|
+
*/ export var consoleLog = createTool({
|
|
187
|
+
description: 'Log a message to the console for debugging or informational purposes',
|
|
188
|
+
inputSchema: z.object({
|
|
189
|
+
message: z.string().describe('The message to log'),
|
|
190
|
+
level: z.enum([
|
|
191
|
+
'info',
|
|
192
|
+
'warn',
|
|
193
|
+
'error'
|
|
194
|
+
]).optional().describe('Log level (defaults to info)')
|
|
195
|
+
}),
|
|
196
|
+
execute: function(param) {
|
|
197
|
+
var message = param.message, _param_level = param.level, level = _param_level === void 0 ? 'info' : _param_level;
|
|
198
|
+
var logFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.log;
|
|
199
|
+
logFn("[Agent] ".concat(message));
|
|
200
|
+
return {
|
|
201
|
+
logged: true
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
/**
|
|
206
|
+
* Done tool - a simple terminal tool for completing agent execution.
|
|
207
|
+
* The result becomes part of the brain state.
|
|
208
|
+
*/ export var done = createTool({
|
|
209
|
+
description: 'Complete the task and return a result',
|
|
210
|
+
inputSchema: z.object({
|
|
211
|
+
result: z.string().describe('The final result or summary of the completed task')
|
|
212
|
+
}),
|
|
213
|
+
terminal: true
|
|
214
|
+
});
|
|
161
215
|
/**
|
|
162
216
|
* Default tools bundle.
|
|
163
217
|
*
|
|
164
|
-
* Use with .withTools(
|
|
165
|
-
* Tools can be extended or overridden in
|
|
218
|
+
* Use with createBrain's defaultTools option or .withTools() to include
|
|
219
|
+
* standard tools in your brain. Tools can be extended or overridden in
|
|
220
|
+
* individual agent steps.
|
|
166
221
|
*
|
|
167
222
|
* @example
|
|
168
223
|
* ```typescript
|
|
169
|
-
* import {
|
|
224
|
+
* import { createBrain, defaultTools } from '@positronic/core';
|
|
225
|
+
*
|
|
226
|
+
* export const brain = createBrain({
|
|
227
|
+
* components,
|
|
228
|
+
* defaultTools,
|
|
229
|
+
* });
|
|
170
230
|
*
|
|
231
|
+
* // Or with the builder pattern:
|
|
171
232
|
* const myBrain = brain('my-brain')
|
|
172
233
|
* .withTools(defaultTools)
|
|
173
234
|
* .brain('agent', ({ tools }) => ({
|
|
@@ -177,5 +238,7 @@ import { createWebhook } from '../dsl/webhook.js';
|
|
|
177
238
|
* }));
|
|
178
239
|
* ```
|
|
179
240
|
*/ export var defaultTools = {
|
|
180
|
-
generateUI: generateUI
|
|
241
|
+
generateUI: generateUI,
|
|
242
|
+
consoleLog: consoleLog,
|
|
243
|
+
done: done
|
|
181
244
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../../../../src/dsl/execution/event-stream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAc,SAAS,EAAiC,MAAM,aAAa,CAAC;AAO3G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAqC,MAAM,0BAA0B,CAAC;AAEzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAOlF,qBAAa,gBAAgB,CAC3B,QAAQ,SAAS,UAAU,GAAG,UAAU,EACxC,MAAM,SAAS,KAAK,GAAG,MAAM,EAC7B,SAAS,SAAS,MAAM,GAAG,MAAM;IAEjC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,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E,SAAS,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;KAC1C;IA8EI,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAgIpC,WAAW;YAwLX,YAAY;IAyQ3B;;;OAGG;YACY,aAAa;IAyF5B,OAAO,CAAE,YAAY;CAoBtB"}
|
|
@@ -80,8 +80,8 @@ export interface AgentTool<TInput extends z.ZodSchema = z.ZodSchema> {
|
|
|
80
80
|
export interface AgentConfig<TTools extends Record<string, AgentTool> = Record<string, AgentTool>> {
|
|
81
81
|
/** System prompt for the LLM */
|
|
82
82
|
system?: string;
|
|
83
|
-
/** Initial user prompt to start the conversation */
|
|
84
|
-
prompt
|
|
83
|
+
/** Initial user prompt to start the conversation. If omitted, uses "Begin." */
|
|
84
|
+
prompt?: string;
|
|
85
85
|
/** Tools available to the LLM. Optional - merged with withTools defaults */
|
|
86
86
|
tools?: TTools;
|
|
87
87
|
/** Safety valve - exit if cumulative tokens exceed this limit */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AACpC,MAAM,MAAM,UAAU,GAAG;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS;CAAE,CAAC;AACzD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D;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CAAC;AAGhB;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC5C,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type { PagesService, Page, PageCreateOptions } from './dsl/pages.js';
|
|
|
17
17
|
export type { Manifest as ResourceManifest, Entry as ResourceEntry, ResourceType, } from './resources/resources.js';
|
|
18
18
|
export { RESOURCE_TYPES } from './resources/resources.js';
|
|
19
19
|
export type { AgentStartEvent, AgentIterationEvent, AgentToolCallEvent, AgentToolResultEvent, AgentAssistantMessageEvent, AgentCompleteEvent, AgentTokenLimitEvent, AgentWebhookEvent, WebhookResponseEvent, } from './dsl/definitions/events.js';
|
|
20
|
-
export { defaultTools, generateUI } from './tools/index.js';
|
|
20
|
+
export { createTool, defaultTools, generateUI, consoleLog, done } from './tools/index.js';
|
|
21
21
|
export type { UIComponent } from './ui/types.js';
|
|
22
22
|
export { createBrainExecutionMachine, createBrainMachine, sendEvent, getDepth, isTopLevel, getCurrentStep, getBrainStack, getBrainRunId, getExecutionState, getPendingWebhooks, getError, getCompletedSteps, } from './dsl/brain-state-machine.js';
|
|
23
23
|
export type { BrainStateMachine, BrainExecutionContext, BrainStackEntry, RunningBrain, StepInfo, ExecutionState, CreateMachineOptions, } from './dsl/brain-state-machine.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;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E,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,YAAY,EACV,QAAQ,IAAI,gBAAgB,EAC5B,KAAK,IAAI,aAAa,EACtB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG1F,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,oBAAoB,GACrB,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { AgentTool } from '../dsl/types.js';
|
|
2
|
+
import type { AgentTool, AgentToolWaitFor } from '../dsl/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to create tools with proper type inference.
|
|
5
|
+
*
|
|
6
|
+
* This avoids the need to manually specify types on the execute function -
|
|
7
|
+
* TypeScript will infer them from the inputSchema.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const sendNotification = createTool({
|
|
12
|
+
* description: 'Send a push notification',
|
|
13
|
+
* inputSchema: z.object({
|
|
14
|
+
* message: z.string().describe('The notification message'),
|
|
15
|
+
* clickUrl: z.string().optional().describe('URL to open on click'),
|
|
16
|
+
* }),
|
|
17
|
+
* execute: async ({ message, clickUrl }) => { // Types inferred!
|
|
18
|
+
* await ntfy.send(message, clickUrl);
|
|
19
|
+
* return { sent: true };
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTool<T extends z.ZodSchema>(config: {
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: T;
|
|
27
|
+
execute?: (input: z.infer<T>) => unknown | Promise<unknown> | AgentToolWaitFor | Promise<AgentToolWaitFor>;
|
|
28
|
+
terminal?: boolean;
|
|
29
|
+
}): AgentTool<T>;
|
|
3
30
|
/**
|
|
4
31
|
* Default generateUI tool - gets enriched with component metadata at runtime.
|
|
5
32
|
*
|
|
@@ -7,17 +34,57 @@ import type { AgentTool } from '../dsl/types.js';
|
|
|
7
34
|
* The actual component list and descriptions are injected at runtime
|
|
8
35
|
* based on the components registered with .withComponents().
|
|
9
36
|
*/
|
|
10
|
-
export declare const generateUI: AgentTool
|
|
37
|
+
export declare const generateUI: AgentTool<z.ZodObject<{
|
|
38
|
+
component: z.ZodString;
|
|
39
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
component: string;
|
|
42
|
+
props: Record<string, unknown>;
|
|
43
|
+
}, {
|
|
44
|
+
component: string;
|
|
45
|
+
props: Record<string, unknown>;
|
|
46
|
+
}>>;
|
|
47
|
+
/**
|
|
48
|
+
* Console log tool - useful for debugging and logging information during agent execution.
|
|
49
|
+
*/
|
|
50
|
+
export declare const consoleLog: AgentTool<z.ZodObject<{
|
|
51
|
+
message: z.ZodString;
|
|
52
|
+
level: z.ZodOptional<z.ZodEnum<["info", "warn", "error"]>>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
message: string;
|
|
55
|
+
level?: "error" | "info" | "warn" | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
message: string;
|
|
58
|
+
level?: "error" | "info" | "warn" | undefined;
|
|
59
|
+
}>>;
|
|
60
|
+
/**
|
|
61
|
+
* Done tool - a simple terminal tool for completing agent execution.
|
|
62
|
+
* The result becomes part of the brain state.
|
|
63
|
+
*/
|
|
64
|
+
export declare const done: AgentTool<z.ZodObject<{
|
|
65
|
+
result: z.ZodString;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
result: string;
|
|
68
|
+
}, {
|
|
69
|
+
result: string;
|
|
70
|
+
}>>;
|
|
11
71
|
/**
|
|
12
72
|
* Default tools bundle.
|
|
13
73
|
*
|
|
14
|
-
* Use with .withTools(
|
|
15
|
-
* Tools can be extended or overridden in
|
|
74
|
+
* Use with createBrain's defaultTools option or .withTools() to include
|
|
75
|
+
* standard tools in your brain. Tools can be extended or overridden in
|
|
76
|
+
* individual agent steps.
|
|
16
77
|
*
|
|
17
78
|
* @example
|
|
18
79
|
* ```typescript
|
|
19
|
-
* import {
|
|
80
|
+
* import { createBrain, defaultTools } from '@positronic/core';
|
|
81
|
+
*
|
|
82
|
+
* export const brain = createBrain({
|
|
83
|
+
* components,
|
|
84
|
+
* defaultTools,
|
|
85
|
+
* });
|
|
20
86
|
*
|
|
87
|
+
* // Or with the builder pattern:
|
|
21
88
|
* const myBrain = brain('my-brain')
|
|
22
89
|
* .withTools(defaultTools)
|
|
23
90
|
* .brain('agent', ({ tools }) => ({
|
|
@@ -28,6 +95,32 @@ export declare const generateUI: AgentTool;
|
|
|
28
95
|
* ```
|
|
29
96
|
*/
|
|
30
97
|
export declare const defaultTools: {
|
|
31
|
-
generateUI: AgentTool<z.
|
|
98
|
+
generateUI: AgentTool<z.ZodObject<{
|
|
99
|
+
component: z.ZodString;
|
|
100
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
component: string;
|
|
103
|
+
props: Record<string, unknown>;
|
|
104
|
+
}, {
|
|
105
|
+
component: string;
|
|
106
|
+
props: Record<string, unknown>;
|
|
107
|
+
}>>;
|
|
108
|
+
consoleLog: AgentTool<z.ZodObject<{
|
|
109
|
+
message: z.ZodString;
|
|
110
|
+
level: z.ZodOptional<z.ZodEnum<["info", "warn", "error"]>>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
message: string;
|
|
113
|
+
level?: "error" | "info" | "warn" | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
message: string;
|
|
116
|
+
level?: "error" | "info" | "warn" | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
done: AgentTool<z.ZodObject<{
|
|
119
|
+
result: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
result: string;
|
|
122
|
+
}, {
|
|
123
|
+
result: string;
|
|
124
|
+
}>>;
|
|
32
125
|
};
|
|
33
126
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3G,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,SAAS,CAAC,CAAC,CAAC,CAEf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;;;;;;;;;GAwBrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;GAWrB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;GAMf,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIxB,CAAC"}
|