@positronic/core 0.0.54 → 0.0.56

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.
@@ -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, description, componentList, systemPrompt, response, _this_options5, _this_options6, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, toolCall, _this_options7, tool1, _this_options8, _this_options9, toolContext, toolResult, waitForResult, webhooks, _this_options10, _this_options11, _this_options12, 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: config.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: config.prompt
1178
+ content: prompt
1177
1179
  }
1178
1180
  ];
1179
1181
  _state.label = 6;
@@ -1213,8 +1215,18 @@ export var BrainEventStream = /*#__PURE__*/ function() {
1213
1215
  for(_iterator = Object.entries(mergedTools)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1214
1216
  _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], toolDef = _step_value[1];
1215
1217
  tool = toolDef;
1218
+ description = tool.description;
1219
+ // Enrich generateUI description with available component information
1220
+ if (name === 'generateUI' && components && Object.keys(components).length > 0) {
1221
+ componentList = Object.entries(components).map(function(param) {
1222
+ var _param = _sliced_to_array(param, 2), compName = _param[0], comp = _param[1];
1223
+ var desc = comp.description.split('\n')[0]; // First line only
1224
+ return "- ".concat(compName, ": ").concat(desc);
1225
+ }).join('\n');
1226
+ description = "Generate a UI page to display to the user and wait for their response.\n\n" + "Available components:\n".concat(componentList, "\n\n") + "Call this tool with a prompt describing the UI you want to create. " + "The system will use an LLM to generate the appropriate component layout.";
1227
+ }
1216
1228
  toolsForClient[name] = {
1217
- description: tool.description,
1229
+ description: description,
1218
1230
  inputSchema: tool.inputSchema
1219
1231
  };
1220
1232
  }
@@ -1382,9 +1394,22 @@ export var BrainEventStream = /*#__PURE__*/ function() {
1382
1394
  3,
1383
1395
  28
1384
1396
  ];
1397
+ toolContext = {
1398
+ state: this.currentState,
1399
+ options: (_this_options9 = this.options) !== null && _this_options9 !== void 0 ? _this_options9 : {},
1400
+ client: this.client,
1401
+ resources: this.resources,
1402
+ response: this.currentResponse,
1403
+ page: this.currentPage,
1404
+ pages: this.pages,
1405
+ env: this.env,
1406
+ components: this.components,
1407
+ brainRunId: this.brainRunId,
1408
+ stepId: step.id
1409
+ };
1385
1410
  return [
1386
1411
  4,
1387
- _await_async_generator(tool1.execute(toolCall.args))
1412
+ _await_async_generator(tool1.execute(toolCall.args, toolContext))
1388
1413
  ];
1389
1414
  case 23:
1390
1415
  toolResult = _state.sent();
@@ -1407,7 +1432,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
1407
1432
  toolCallId: toolCall.toolCallId,
1408
1433
  toolName: toolCall.toolName,
1409
1434
  input: toolCall.args,
1410
- options: (_this_options9 = this.options) !== null && _this_options9 !== void 0 ? _this_options9 : {},
1435
+ options: (_this_options10 = this.options) !== null && _this_options10 !== void 0 ? _this_options10 : {},
1411
1436
  brainRunId: this.brainRunId
1412
1437
  }
1413
1438
  ];
@@ -1424,7 +1449,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
1424
1449
  identifier: w.identifier
1425
1450
  };
1426
1451
  }),
1427
- options: (_this_options10 = this.options) !== null && _this_options10 !== void 0 ? _this_options10 : {},
1452
+ options: (_this_options11 = this.options) !== null && _this_options11 !== void 0 ? _this_options11 : {},
1428
1453
  brainRunId: this.brainRunId
1429
1454
  }
1430
1455
  ];
@@ -1444,7 +1469,7 @@ export var BrainEventStream = /*#__PURE__*/ function() {
1444
1469
  toolName: toolCall.toolName,
1445
1470
  toolCallId: toolCall.toolCallId,
1446
1471
  result: toolResult,
1447
- options: (_this_options11 = this.options) !== null && _this_options11 !== void 0 ? _this_options11 : {},
1472
+ options: (_this_options12 = this.options) !== null && _this_options12 !== void 0 ? _this_options12 : {},
1448
1473
  brainRunId: this.brainRunId
1449
1474
  }
1450
1475
  ];
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';
@@ -119,55 +119,166 @@ function _ts_generator(thisArg, body) {
119
119
  }
120
120
  }
121
121
  import { z } from 'zod';
122
- import { createWebhook } from '../dsl/webhook.js';
122
+ import { generateUI as generateUICore } from '../ui/generate-ui.js';
123
+ import { generatePageHtml } from '../ui/generate-page-html.js';
123
124
  /**
124
- * Default generateUI tool - gets enriched with component metadata at runtime.
125
+ * Helper function to create tools with proper type inference.
125
126
  *
126
- * This tool allows the LLM to generate a UI and wait for user response.
127
- * The actual component list and descriptions are injected at runtime
128
- * based on the components registered with .withComponents().
127
+ * This avoids the need to manually specify types on the execute function -
128
+ * TypeScript will infer them from the inputSchema.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const sendNotification = createTool({
133
+ * description: 'Send a push notification',
134
+ * inputSchema: z.object({
135
+ * message: z.string().describe('The notification message'),
136
+ * clickUrl: z.string().optional().describe('URL to open on click'),
137
+ * }),
138
+ * execute: async ({ message, clickUrl }, context) => {
139
+ * await ntfy.send(message, clickUrl);
140
+ * return { sent: true };
141
+ * },
142
+ * });
143
+ * ```
144
+ */ export function createTool(config) {
145
+ return config;
146
+ }
147
+ var generateUIInputSchema = z.object({
148
+ prompt: z.string().describe('Instructions for what UI to generate. Describe the form fields, layout, and purpose. ' + 'Be specific about what data you want to collect from the user.')
149
+ });
150
+ /**
151
+ * Generate UI tool - creates an interactive UI page and waits for user response.
152
+ *
153
+ * This tool:
154
+ * 1. Uses an LLM to generate a UI page based on your prompt
155
+ * 2. Creates an HTML page with the generated components
156
+ * 3. Pauses agent execution until the user submits the form
157
+ * 4. Returns the form data as the tool result when resumed
158
+ *
159
+ * Requires components and pages to be configured via createBrain or withComponents().
160
+ *
161
+ * The description is enriched at runtime with available component information.
129
162
  */ export var generateUI = {
130
- description: 'Generate a UI to display to the user and wait for their response',
131
- inputSchema: z.object({
132
- component: z.string().describe('The component name to render'),
133
- props: z.record(z.unknown()).describe('Props to pass to the component')
134
- }),
135
- execute: function execute(input) {
136
- // Return waitFor to pause execution until user responds
137
- // The actual webhook handling is done by the runtime
138
- var uiWebhook = createWebhook('ui-response', z.object({
139
- userResponse: z.unknown()
140
- }), function() {
141
- return _async_to_generator(function() {
142
- return _ts_generator(this, function(_state) {
143
- return [
144
- 2,
145
- {
146
- type: 'webhook',
147
- identifier: 'pending',
148
- response: {
149
- userResponse: null
163
+ description: 'Generate a UI page to display to the user and wait for their response. ' + 'Available components will be listed in the system prompt. ' + 'After the page is created, execution pauses until the user submits the form.',
164
+ inputSchema: generateUIInputSchema,
165
+ execute: function execute(input, context) {
166
+ return _async_to_generator(function() {
167
+ var components, pages, client, state, env, brainRunId, stepId, uiResult, placementCount, webhookIdentifier, formAction, html, page, webhook;
168
+ return _ts_generator(this, function(_state) {
169
+ switch(_state.label){
170
+ case 0:
171
+ components = context.components, pages = context.pages, client = context.client, state = context.state, env = context.env, brainRunId = context.brainRunId, stepId = context.stepId;
172
+ if (!components || Object.keys(components).length === 0) {
173
+ throw new Error('generateUI requires components to be configured. ' + 'Use createBrain({ components }) or brain.withComponents() to register UI components.');
174
+ }
175
+ if (!pages) {
176
+ throw new Error('generateUI requires pages service to be configured. ' + 'This is typically provided by the backend runtime.');
177
+ }
178
+ return [
179
+ 4,
180
+ generateUICore({
181
+ client: client,
182
+ prompt: input.prompt,
183
+ components: components,
184
+ data: state
185
+ })
186
+ ];
187
+ case 1:
188
+ uiResult = _state.sent();
189
+ if (!uiResult.rootId) {
190
+ placementCount = uiResult.placements.length;
191
+ if (placementCount === 0) {
192
+ throw new Error("UI generation failed - no components were generated. " + "The LLM may not have understood the prompt. Try being more specific.");
193
+ } else {
194
+ throw new Error("UI generation failed - no root component found. " + "".concat(placementCount, " component(s) were placed but all have a parentId."));
150
195
  }
151
196
  }
152
- ];
153
- });
154
- })();
155
- });
197
+ // Create unique identifier for the webhook
198
+ webhookIdentifier = "".concat(brainRunId, "-").concat(stepId, "-generateui-").concat(Date.now());
199
+ // Build form action URL
200
+ formAction = "".concat(env.origin, "/webhooks/system/ui-form?identifier=").concat(encodeURIComponent(webhookIdentifier));
201
+ // Generate HTML page
202
+ html = generatePageHtml({
203
+ placements: uiResult.placements,
204
+ rootId: uiResult.rootId,
205
+ data: state,
206
+ title: 'Generated Form',
207
+ formAction: formAction
208
+ });
209
+ return [
210
+ 4,
211
+ pages.create(html)
212
+ ];
213
+ case 2:
214
+ page = _state.sent();
215
+ // Create webhook registration for form submission
216
+ webhook = {
217
+ slug: 'ui-form',
218
+ identifier: webhookIdentifier,
219
+ schema: z.record(z.unknown())
220
+ };
221
+ // Return URL and waitFor - the URL is included so it can be logged/emitted
222
+ return [
223
+ 2,
224
+ {
225
+ url: page.url,
226
+ waitFor: webhook
227
+ }
228
+ ];
229
+ }
230
+ });
231
+ })();
232
+ }
233
+ };
234
+ /**
235
+ * Console log tool - useful for debugging and logging information during agent execution.
236
+ */ export var consoleLog = createTool({
237
+ description: 'Log a message to the console for debugging or informational purposes',
238
+ inputSchema: z.object({
239
+ message: z.string().describe('The message to log'),
240
+ level: z.enum([
241
+ 'info',
242
+ 'warn',
243
+ 'error'
244
+ ]).optional().describe('Log level (defaults to info)')
245
+ }),
246
+ execute: function(param) {
247
+ var message = param.message, _param_level = param.level, level = _param_level === void 0 ? 'info' : _param_level;
248
+ var logFn = level === 'error' ? console.error : level === 'warn' ? console.warn : console.log;
249
+ logFn("[Agent] ".concat(message));
156
250
  return {
157
- waitFor: uiWebhook('pending')
251
+ logged: true
158
252
  };
159
253
  }
160
- };
254
+ });
255
+ /**
256
+ * Done tool - a simple terminal tool for completing agent execution.
257
+ * The result becomes part of the brain state.
258
+ */ export var done = createTool({
259
+ description: 'Complete the task and return a result',
260
+ inputSchema: z.object({
261
+ result: z.string().describe('The final result or summary of the completed task')
262
+ }),
263
+ terminal: true
264
+ });
161
265
  /**
162
266
  * Default tools bundle.
163
267
  *
164
- * Use with .withTools(defaultTools) to include standard tools in your brain.
165
- * Tools can be extended or overridden in individual agent steps.
268
+ * Use with createBrain's defaultTools option or .withTools() to include
269
+ * standard tools in your brain. Tools can be extended or overridden in
270
+ * individual agent steps.
166
271
  *
167
272
  * @example
168
273
  * ```typescript
169
- * import { brain, defaultTools } from '@positronic/core';
274
+ * import { createBrain, defaultTools } from '@positronic/core';
275
+ *
276
+ * export const brain = createBrain({
277
+ * components,
278
+ * defaultTools,
279
+ * });
170
280
  *
281
+ * // Or with the builder pattern:
171
282
  * const myBrain = brain('my-brain')
172
283
  * .withTools(defaultTools)
173
284
  * .brain('agent', ({ tools }) => ({
@@ -177,5 +288,7 @@ import { createWebhook } from '../dsl/webhook.js';
177
288
  * }));
178
289
  * ```
179
290
  */ export var defaultTools = {
180
- generateUI: generateUI
291
+ generateUI: generateUI,
292
+ consoleLog: consoleLog,
293
+ done: done
181
294
  };
@@ -1,9 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import type { ObjectGenerator } from '../../clients/types.js';
3
- import type { State, JsonObject, RuntimeEnv, AgentTool, AgentConfig, RetryConfig } from '../types.js';
3
+ import type { State, JsonObject, AgentTool, AgentConfig, RetryConfig, StepContext } from '../types.js';
4
4
  import type { Resources } from '../../resources/resources.js';
5
5
  import type { ExtractWebhookResponses } from '../webhook.js';
6
- import type { PagesService } from '../pages.js';
7
6
  import type { UIComponent } from '../../ui/types.js';
8
7
  import type { BrainEvent } from '../definitions/events.js';
9
8
  import type { BrainStructure } from '../definitions/steps.js';
@@ -58,16 +57,7 @@ export declare class Brain<TOptions extends JsonObject = JsonObject, TState exte
58
57
  * ```
59
58
  */
60
59
  withTools<TTools extends Record<string, AgentTool>>(tools: TTools): Brain<TOptions, TState, TServices, TResponse, TPage>;
61
- step<TNewState extends State, TWaitFor extends readonly any[] = readonly []>(title: string, action: (params: {
62
- state: TState;
63
- options: TOptions;
64
- client: ObjectGenerator;
65
- resources: Resources;
66
- response: TResponse;
67
- page: TPage;
68
- pages?: PagesService;
69
- env: RuntimeEnv;
70
- } & TServices) => TNewState | Promise<TNewState> | {
60
+ step<TNewState extends State, TWaitFor extends readonly any[] = readonly []>(title: string, action: (params: StepContext<TState, TOptions, TResponse, TPage> & TServices) => TNewState | Promise<TNewState> | {
71
61
  state: TNewState;
72
62
  waitFor: TWaitFor;
73
63
  } | Promise<{
@@ -80,18 +70,10 @@ export declare class Brain<TOptions extends JsonObject = JsonObject, TState exte
80
70
  services: TServices;
81
71
  }) => TNewState, initialState?: State | ((state: TState) => State)): Brain<TOptions, TNewState, TServices, TResponse, undefined>;
82
72
  brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TNewState extends State = TState>(title: string, config: AgentConfig<TTools>): Brain<TOptions, TNewState, TServices, TResponse, undefined>;
83
- brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TNewState extends State = TState>(title: string, configFn: (params: {
84
- state: TState;
85
- options: TOptions;
73
+ brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TNewState extends State = TState>(title: string, configFn: (params: StepContext<TState, TOptions, TResponse, TPage> & TServices & {
74
+ /** Default tools available for agent steps */
86
75
  tools: Record<string, AgentTool>;
87
- components: Record<string, UIComponent<any>>;
88
- client: ObjectGenerator;
89
- resources: Resources;
90
- response: TResponse;
91
- page: TPage;
92
- pages?: PagesService;
93
- env: RuntimeEnv;
94
- } & TServices) => AgentConfig<TTools> | Promise<AgentConfig<TTools>>): Brain<TOptions, TNewState, TServices, TResponse, undefined>;
76
+ }) => AgentConfig<TTools> | Promise<AgentConfig<TTools>>): Brain<TOptions, TNewState, TServices, TResponse, undefined>;
95
77
  prompt<TResponseKey extends string & {
96
78
  readonly brand?: unique symbol;
97
79
  }, TSchema extends z.ZodObject<any>, TNewState extends State = TState & {
@@ -185,16 +167,7 @@ export declare function brain<TOptions extends JsonObject = JsonObject, TState e
185
167
  description?: string;
186
168
  }): Brain<TOptions, TState, TServices>;
187
169
  export declare function brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TState extends State = object>(title: string, config: AgentConfig<TTools>): Brain<JsonObject, TState, object, undefined, undefined>;
188
- export declare function brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TState extends State = object>(title: string, configFn: (params: {
189
- state: object;
190
- options: JsonObject;
170
+ export declare function brain<TTools extends Record<string, AgentTool> = Record<string, AgentTool>, TState extends State = object>(title: string, configFn: (params: StepContext<object, JsonObject, undefined, undefined> & {
191
171
  tools: Record<string, AgentTool>;
192
- components: Record<string, UIComponent<any>>;
193
- client: ObjectGenerator;
194
- resources: Resources;
195
- response: undefined;
196
- page: undefined;
197
- pages?: PagesService;
198
- env: RuntimeEnv;
199
172
  }) => AgentConfig<TTools> | Promise<AgentConfig<TTools>>): Brain<JsonObject, TState, object, undefined, undefined>;
200
173
  //# sourceMappingURL=brain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../../src/dsl/builder/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,C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,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAClC,KACE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GACtD,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC"}
@@ -1,13 +1,10 @@
1
1
  import { Brain } from './builder/brain.js';
2
- import type { AgentConfig, AgentTool, RuntimeEnv } from './types.js';
3
- import type { ObjectGenerator } from '../clients/types.js';
4
- import type { Resources } from '../resources/resources.js';
5
- import type { PagesService } from './pages.js';
2
+ import type { AgentConfig, AgentTool, StepContext } from './types.js';
6
3
  import type { UIComponent } from '../ui/types.js';
7
4
  /**
8
5
  * Configuration for creating a project-level brain function.
9
6
  */
10
- export interface CreateBrainConfig<TServices extends object = {}, TComponents extends Record<string, UIComponent<any>> = {}, TTools extends Record<string, AgentTool> = {}> {
7
+ export interface CreateBrainConfig<TServices extends object = {}, TComponents extends Record<string, UIComponent<any>> = {}, TTools extends Record<string, AgentTool<any>> = {}> {
11
8
  /** Services available to all brains (e.g., slack, gmail, database clients) */
12
9
  services?: TServices;
13
10
  /** UI components for generative UI steps */
@@ -57,19 +54,10 @@ export interface CreateBrainConfig<TServices extends object = {}, TComponents ex
57
54
  * }));
58
55
  * ```
59
56
  */
60
- export declare function createBrain<TServices extends object = {}, TComponents extends Record<string, UIComponent<any>> = {}, TTools extends Record<string, AgentTool> = {}>(config: CreateBrainConfig<TServices, TComponents, TTools>): {
61
- <T extends Record<string, AgentTool>>(title: string, configFn: (params: {
62
- state: object;
63
- options: {};
57
+ export declare function createBrain<TServices extends object = {}, TComponents extends Record<string, UIComponent<any>> = {}, TTools extends Record<string, AgentTool<any>> = {}>(config: CreateBrainConfig<TServices, TComponents, TTools>): {
58
+ <T extends Record<string, AgentTool>>(title: string, configFn: (params: StepContext<object, {}, undefined, undefined> & TServices & {
64
59
  tools: TTools extends {} ? Record<string, AgentTool> : TTools;
65
- components: TComponents extends {} ? Record<string, UIComponent<any>> : TComponents;
66
- client: ObjectGenerator;
67
- resources: Resources;
68
- response: undefined;
69
- page: undefined;
70
- pages?: PagesService;
71
- env: RuntimeEnv;
72
- } & TServices) => AgentConfig<T> | Promise<AgentConfig<T>>): Brain<{}, object, TServices, undefined, undefined>;
60
+ }) => AgentConfig<T> | Promise<AgentConfig<T>>): Brain<{}, object, TServices, undefined, undefined>;
73
61
  <T extends Record<string, AgentTool>>(title: string, config: AgentConfig<T>): Brain<{}, object, TServices, undefined, undefined>;
74
62
  (title: string): Brain<{}, object, TServices, undefined, undefined>;
75
63
  (config: {
@@ -1 +1 @@
1
- {"version":3,"file":"create-brain.d.ts","sourceRoot":"","sources":["../../../src/dsl/create-brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAChC,SAAS,SAAS,MAAM,GAAG,EAAE,EAC7B,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EACzD,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE;IAE7C,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,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or {
54
54
  waitFor: WebhookRegistration<z.ZodSchema> | WebhookRegistration<z.ZodSchema>[];
55
55
  }
56
+ /**
57
+ * Context passed to step actions, agent config functions, and tool execute functions.
58
+ * This is the same context available throughout brain execution.
59
+ *
60
+ * Generic parameters allow type-safe access to state, options, response, and page.
61
+ * For tools (which are defined statically), use the non-generic defaults.
62
+ */
63
+ export interface StepContext<TState = object, TOptions = JsonObject, TResponse = JsonObject | undefined, TPage = import('./definitions/brain-types.js').GeneratedPage | undefined> {
64
+ /** Current brain state */
65
+ state: TState;
66
+ /** Brain options */
67
+ options: TOptions;
68
+ /** The LLM client for making AI calls */
69
+ client: import('../clients/types.js').ObjectGenerator;
70
+ /** Resource loader for accessing brain resources */
71
+ resources: import('../resources/resources.js').Resources;
72
+ /** Webhook response data (when resuming after a webhook) */
73
+ response: TResponse;
74
+ /** Generated page from a previous UI step */
75
+ page: TPage;
76
+ /** Page service for creating UI pages */
77
+ pages?: import('./pages.js').PagesService;
78
+ /** Runtime environment (origin, secrets) */
79
+ env: RuntimeEnv;
80
+ /** UI components available for generateUI */
81
+ components?: Record<string, import('../ui/types.js').UIComponent<any>>;
82
+ /** Current brain run ID (for creating unique webhook identifiers) */
83
+ brainRunId: string;
84
+ /** Current step ID (for creating unique webhook identifiers) */
85
+ stepId: string;
86
+ }
56
87
  /**
57
88
  * A tool definition for use in agent steps.
58
89
  * Compatible with Vercel AI SDK tool format, extended with Positronic-specific properties.
@@ -66,8 +97,10 @@ export interface AgentTool<TInput extends z.ZodSchema = z.ZodSchema> {
66
97
  * Execute function for the tool.
67
98
  * Can return a result directly, or { waitFor: webhook(...) } to suspend execution.
68
99
  * Not required for terminal tools.
100
+ * @param input - The validated input from the LLM
101
+ * @param context - Runtime context with access to client, pages, state, etc.
69
102
  */
70
- execute?: (input: z.infer<TInput>) => Promise<unknown | AgentToolWaitFor> | unknown | AgentToolWaitFor;
103
+ execute?: (input: z.infer<TInput>, context: StepContext) => Promise<unknown | AgentToolWaitFor> | unknown | AgentToolWaitFor;
71
104
  /**
72
105
  * If true, calling this tool ends the agent.
73
106
  * The tool's input becomes the agent result (merged into state).
@@ -80,8 +113,8 @@ export interface AgentTool<TInput extends z.ZodSchema = z.ZodSchema> {
80
113
  export interface AgentConfig<TTools extends Record<string, AgentTool> = Record<string, AgentTool>> {
81
114
  /** System prompt for the LLM */
82
115
  system?: string;
83
- /** Initial user prompt to start the conversation */
84
- prompt: string;
116
+ /** Initial user prompt to start the conversation. If omitted, uses "Begin." */
117
+ prompt?: string;
85
118
  /** Tools available to the LLM. Optional - merged with withTools defaults */
86
119
  tools?: TTools;
87
120
  /** 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;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;CAEvB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,G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,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;KAC1E,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC,CAAA;KAAE,GAC3E,CAAC,SAAS,CAAC,CAAC,SAAS,GACnB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACV,KAAK,GACP,KAAK;CACV,CAAC,MAAM,MAAM,CAAC,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"}
@@ -6,7 +6,7 @@ export { STATUS, BRAIN_EVENTS } from './dsl/constants.js';
6
6
  export type { Adapter } from './adapters/types.js';
7
7
  export type { BrainEvent, SerializedStep, InitialRunParams, RerunParams, BrainStartEvent, BrainCompleteEvent, BrainErrorEvent, StepStatusEvent, StepStartedEvent, StepCompletedEvent, StepRetryEvent, BrainStructure, BrainConfig, GeneratedPage, } from './dsl/brain.js';
8
8
  export type { ObjectGenerator, Message, ToolMessage } from './clients/types.js';
9
- export type { State, RuntimeEnv, Secrets, AgentTool, AgentConfig, AgentMessage, AgentToolWaitFor, ExtractTerminalInput, RetryConfig, } from './dsl/types.js';
9
+ export type { State, RuntimeEnv, Secrets, AgentTool, AgentConfig, AgentMessage, AgentToolWaitFor, StepContext, ExtractTerminalInput, RetryConfig, } from './dsl/types.js';
10
10
  export { applyPatches } from './dsl/json-patch.js';
11
11
  export { z } from 'zod';
12
12
  export type { ResourceLoader } from './resources/resource-loader.js';
@@ -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;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAA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BAAkB,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,23 +1,94 @@
1
1
  import { z } from 'zod';
2
- import type { AgentTool } from '../dsl/types.js';
2
+ import type { AgentTool, AgentToolWaitFor, StepContext } from '../dsl/types.js';
3
3
  /**
4
- * Default generateUI tool - gets enriched with component metadata at runtime.
4
+ * Helper function to create tools with proper type inference.
5
5
  *
6
- * This tool allows the LLM to generate a UI and wait for user response.
7
- * The actual component list and descriptions are injected at runtime
8
- * based on the components registered with .withComponents().
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 }, context) => {
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>, context: StepContext) => unknown | Promise<unknown> | AgentToolWaitFor | Promise<AgentToolWaitFor>;
28
+ terminal?: boolean;
29
+ }): AgentTool<T>;
30
+ declare const generateUIInputSchema: z.ZodObject<{
31
+ prompt: z.ZodString;
32
+ }, "strip", z.ZodTypeAny, {
33
+ prompt: string;
34
+ }, {
35
+ prompt: string;
36
+ }>;
37
+ /**
38
+ * Generate UI tool - creates an interactive UI page and waits for user response.
39
+ *
40
+ * This tool:
41
+ * 1. Uses an LLM to generate a UI page based on your prompt
42
+ * 2. Creates an HTML page with the generated components
43
+ * 3. Pauses agent execution until the user submits the form
44
+ * 4. Returns the form data as the tool result when resumed
45
+ *
46
+ * Requires components and pages to be configured via createBrain or withComponents().
47
+ *
48
+ * The description is enriched at runtime with available component information.
49
+ */
50
+ export declare const generateUI: AgentTool<typeof generateUIInputSchema>;
51
+ /**
52
+ * Console log tool - useful for debugging and logging information during agent execution.
9
53
  */
10
- export declare const generateUI: AgentTool;
54
+ export declare const consoleLog: AgentTool<z.ZodObject<{
55
+ message: z.ZodString;
56
+ level: z.ZodOptional<z.ZodEnum<["info", "warn", "error"]>>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ message: string;
59
+ level?: "error" | "info" | "warn" | undefined;
60
+ }, {
61
+ message: string;
62
+ level?: "error" | "info" | "warn" | undefined;
63
+ }>>;
64
+ /**
65
+ * Done tool - a simple terminal tool for completing agent execution.
66
+ * The result becomes part of the brain state.
67
+ */
68
+ export declare const done: AgentTool<z.ZodObject<{
69
+ result: z.ZodString;
70
+ }, "strip", z.ZodTypeAny, {
71
+ result: string;
72
+ }, {
73
+ result: string;
74
+ }>>;
11
75
  /**
12
76
  * Default tools bundle.
13
77
  *
14
- * Use with .withTools(defaultTools) to include standard tools in your brain.
15
- * Tools can be extended or overridden in individual agent steps.
78
+ * Use with createBrain's defaultTools option or .withTools() to include
79
+ * standard tools in your brain. Tools can be extended or overridden in
80
+ * individual agent steps.
16
81
  *
17
82
  * @example
18
83
  * ```typescript
19
- * import { brain, defaultTools } from '@positronic/core';
84
+ * import { createBrain, defaultTools } from '@positronic/core';
85
+ *
86
+ * export const brain = createBrain({
87
+ * components,
88
+ * defaultTools,
89
+ * });
20
90
  *
91
+ * // Or with the builder pattern:
21
92
  * const myBrain = brain('my-brain')
22
93
  * .withTools(defaultTools)
23
94
  * .brain('agent', ({ tools }) => ({
@@ -28,6 +99,30 @@ export declare const generateUI: AgentTool;
28
99
  * ```
29
100
  */
30
101
  export declare const defaultTools: {
31
- generateUI: AgentTool<z.ZodType<any, z.ZodTypeDef, any>>;
102
+ generateUI: AgentTool<z.ZodObject<{
103
+ prompt: z.ZodString;
104
+ }, "strip", z.ZodTypeAny, {
105
+ prompt: string;
106
+ }, {
107
+ prompt: string;
108
+ }>>;
109
+ consoleLog: AgentTool<z.ZodObject<{
110
+ message: z.ZodString;
111
+ level: z.ZodOptional<z.ZodEnum<["info", "warn", "error"]>>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ message: string;
114
+ level?: "error" | "info" | "warn" | undefined;
115
+ }, {
116
+ message: string;
117
+ level?: "error" | "info" | "warn" | undefined;
118
+ }>>;
119
+ done: AgentTool<z.ZodObject<{
120
+ result: z.ZodString;
121
+ }, "strip", z.ZodTypeAny, {
122
+ result: string;
123
+ }, {
124
+ result: string;
125
+ }>>;
32
126
  };
127
+ export {};
33
128
  //# 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,EAAoB,MAAM,iBAAiB,CAAC;AAGnE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAwBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY;;CAExB,CAAC"}
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,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKhF;;;;;;;;;;;;;;;;;;;;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,CACR,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,WAAW,KACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,SAAS,CAAC,CAAC,CAAC,CAEf;AAED,QAAA,MAAM,qBAAqB;;;;;;EAKzB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,OAAO,qBAAqB,CA4E9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;GAWrB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;GAMf,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;CAIxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positronic/core",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },