@positronic/core 0.0.62 → 0.0.64

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.
Files changed (47) hide show
  1. package/dist/src/dsl/brain-state-machine.js +1 -5
  2. package/dist/src/dsl/builder/brain.js +23 -8
  3. package/dist/src/dsl/constants.js +0 -1
  4. package/dist/src/dsl/example-webhook.js +8 -9
  5. package/dist/src/dsl/execution/constants.js +0 -3
  6. package/dist/src/dsl/execution/event-stream.js +249 -146
  7. package/dist/src/dsl/webhook.js +3 -2
  8. package/dist/src/index.js +5 -0
  9. package/dist/src/tools/index.js +11 -6
  10. package/dist/src/ui/generate-page-html.js +15 -3
  11. package/dist/src/ui/parse-form-data.js +102 -0
  12. package/dist/src/validate-webhook-token.js +17 -0
  13. package/dist/types/clients/types.d.ts +0 -5
  14. package/dist/types/clients/types.d.ts.map +1 -1
  15. package/dist/types/dsl/brain-state-machine.d.ts +0 -6
  16. package/dist/types/dsl/brain-state-machine.d.ts.map +1 -1
  17. package/dist/types/dsl/brain.d.ts +2 -2
  18. package/dist/types/dsl/brain.d.ts.map +1 -1
  19. package/dist/types/dsl/builder/brain.d.ts +9 -16
  20. package/dist/types/dsl/builder/brain.d.ts.map +1 -1
  21. package/dist/types/dsl/constants.d.ts +0 -1
  22. package/dist/types/dsl/constants.d.ts.map +1 -1
  23. package/dist/types/dsl/definitions/blocks.d.ts +19 -12
  24. package/dist/types/dsl/definitions/blocks.d.ts.map +1 -1
  25. package/dist/types/dsl/definitions/events.d.ts +1 -8
  26. package/dist/types/dsl/definitions/events.d.ts.map +1 -1
  27. package/dist/types/dsl/definitions/steps.d.ts +1 -1
  28. package/dist/types/dsl/definitions/steps.d.ts.map +1 -1
  29. package/dist/types/dsl/example-webhook.d.ts +1 -1
  30. package/dist/types/dsl/example-webhook.d.ts.map +1 -1
  31. package/dist/types/dsl/execution/constants.d.ts +0 -4
  32. package/dist/types/dsl/execution/constants.d.ts.map +1 -1
  33. package/dist/types/dsl/execution/event-stream.d.ts +3 -1
  34. package/dist/types/dsl/execution/event-stream.d.ts.map +1 -1
  35. package/dist/types/dsl/webhook.d.ts +4 -1
  36. package/dist/types/dsl/webhook.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +4 -1
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/tools/index.d.ts +6 -0
  40. package/dist/types/tools/index.d.ts.map +1 -1
  41. package/dist/types/ui/generate-page-html.d.ts +13 -0
  42. package/dist/types/ui/generate-page-html.d.ts.map +1 -1
  43. package/dist/types/ui/parse-form-data.d.ts +12 -0
  44. package/dist/types/ui/parse-form-data.d.ts.map +1 -0
  45. package/dist/types/validate-webhook-token.d.ts +10 -0
  46. package/dist/types/validate-webhook-token.d.ts.map +1 -0
  47. package/package.json +1 -1
@@ -436,10 +436,6 @@ var stepStatus = reduce(function(ctx, param) {
436
436
  brains: newBrains
437
437
  });
438
438
  });
439
- // stepRetry is a no-op - we just let the event pass through
440
- var stepRetry = reduce(function(ctx) {
441
- return ctx;
442
- });
443
439
  // passthrough is now a no-op - we just let the event pass through
444
440
  var passthrough = function() {
445
441
  return reduce(function(ctx) {
@@ -568,7 +564,7 @@ var makeBrainMachine = function(initialContext) {
568
564
  transition(BRAIN_EVENTS.PAUSED, 'paused', pauseBrain), // Webhook -> waiting (for non-agent webhooks)
569
565
  transition(BRAIN_EVENTS.WEBHOOK, 'waiting', webhookPause), // Webhook response (for resume from non-agent webhook)
570
566
  transition(BRAIN_EVENTS.WEBHOOK_RESPONSE, 'running', webhookResponse), // Step events
571
- transition(BRAIN_EVENTS.STEP_START, 'running', startStep), transition(BRAIN_EVENTS.STEP_COMPLETE, 'running', completeStep), transition(BRAIN_EVENTS.STEP_STATUS, 'running', stepStatus), transition(BRAIN_EVENTS.STEP_RETRY, 'running', stepRetry), // Batch chunk complete - stays in running, accumulates results
567
+ transition(BRAIN_EVENTS.STEP_START, 'running', startStep), transition(BRAIN_EVENTS.STEP_COMPLETE, 'running', completeStep), transition(BRAIN_EVENTS.STEP_STATUS, 'running', stepStatus), // Batch chunk complete - stays in running, accumulates results
572
568
  transition(BRAIN_EVENTS.BATCH_CHUNK_COMPLETE, 'running', batchChunkComplete), // AGENT_START transitions to the agentLoop state
573
569
  transition(BRAIN_EVENTS.AGENT_START, 'agentLoop', agentStart)),
574
570
  // Explicit agent loop state - isolates agent execution logic
@@ -417,6 +417,11 @@ export var Brain = /*#__PURE__*/ function() {
417
417
  type: 'guard',
418
418
  title: block.title
419
419
  };
420
+ } else if (block.type === 'wait') {
421
+ return {
422
+ type: 'wait',
423
+ title: block.title
424
+ };
420
425
  } else {
421
426
  // block.type === 'brain'
422
427
  return {
@@ -547,6 +552,18 @@ export var Brain = /*#__PURE__*/ function() {
547
552
  return this.nextBrain();
548
553
  }
549
554
  },
555
+ {
556
+ key: "wait",
557
+ value: function wait(title, action) {
558
+ var waitBlock = {
559
+ type: 'wait',
560
+ title: title,
561
+ action: action
562
+ };
563
+ this.blocks.push(waitBlock);
564
+ return this.nextBrain();
565
+ }
566
+ },
550
567
  {
551
568
  key: "guard",
552
569
  value: function guard(predicate, title) {
@@ -668,13 +685,12 @@ export var Brain = /*#__PURE__*/ function() {
668
685
  },
669
686
  batchConfig: {
670
687
  over: batchConfig.over,
671
- maxRetries: batchConfig.maxRetries,
672
688
  error: batchConfig.error,
673
689
  template: config.template,
674
690
  schema: outputSchema.schema,
675
691
  schemaName: outputSchema.name,
676
692
  client: config.client,
677
- chunkSize: batchConfig.chunkSize
693
+ concurrency: batchConfig.concurrency
678
694
  }
679
695
  };
680
696
  this.blocks.push(promptBlock1);
@@ -739,8 +755,8 @@ export var Brain = /*#__PURE__*/ function() {
739
755
  * - `webhook`: Pre-configured WebhookRegistration for form submissions
740
756
  *
741
757
  * The brain author is responsible for notifying users about the page (via Slack,
742
- * email, etc.) and using `waitFor` to pause until the form is submitted.
743
- * Form data arrives in the `response` parameter of the step after `waitFor`.
758
+ * email, etc.) and using `.wait()` to pause until the form is submitted.
759
+ * Form data arrives in the `response` parameter of the step after `.wait()`.
744
760
  *
745
761
  * @example
746
762
  * ```typescript
@@ -753,12 +769,11 @@ export var Brain = /*#__PURE__*/ function() {
753
769
  * comments: z.string(),
754
770
  * }),
755
771
  * })
756
- * .step('Notify and Wait', async ({ state, page, slack }) => {
757
- * // Notify user however you want
772
+ * .step('Notify', async ({ state, page, slack }) => {
758
773
  * await slack.post('#general', `Please fill out: ${page.url}`);
759
- * // Wait for form submission
760
- * return { state, waitFor: [page.webhook] };
774
+ * return state;
761
775
  * })
776
+ * .wait('Wait for submission', ({ page }) => page.webhook)
762
777
  * .step('Process Feedback', ({ state, response }) => ({
763
778
  * ...state,
764
779
  * // response is typed: { rating: number, comments: string }
@@ -5,7 +5,6 @@ export var BRAIN_EVENTS = {
5
5
  RESTART: 'brain:restart',
6
6
  STEP_START: 'step:start',
7
7
  STEP_COMPLETE: 'step:complete',
8
- STEP_RETRY: 'step:retry',
9
8
  STEP_STATUS: 'step:status',
10
9
  ERROR: 'brain:error',
11
10
  COMPLETE: 'brain:complete',
@@ -238,15 +238,14 @@ export var emailWebhook = createWebhook('email', z.object({
238
238
  });
239
239
  var myBrain = brain('My Brain').step('My Step', function(param) {
240
240
  var state = param.state;
241
- return {
242
- state: _object_spread({
243
- cool: 'thing'
244
- }, state),
245
- waitFor: [
246
- slackWebhook('thread-123'),
247
- emailWebhook('email-456')
248
- ]
249
- };
241
+ return _object_spread({
242
+ cool: 'thing'
243
+ }, state);
244
+ }).wait('Wait for response', function() {
245
+ return [
246
+ slackWebhook('thread-123'),
247
+ emailWebhook('email-456')
248
+ ];
250
249
  }).step('My Step 2', function(param) {
251
250
  var state = param.state, response = param.response;
252
251
  if (response) {
@@ -9,6 +9,3 @@
9
9
  * Default system prompt prepended to all agent steps.
10
10
  * Explains the headless nature of Positronic Brains.
11
11
  */ export var DEFAULT_AGENT_SYSTEM_PROMPT = "## You Are a Positronic Brain\n\nYou are running as an automated agent in a headless workflow. This is NOT a chat interface - there is no user watching your text output.\n\n**To communicate with users, you MUST use tool calls.** Look at your available tools and use them to send messages, notifications, or create pages for user interaction.\n\n## Tool Execution\n- Tools execute sequentially in the order you call them\n- Webhook-triggering tools pause execution until the webhook fires\n- Terminal tools (like 'done') end the agent immediately\n\n## Resumption\nWhen resuming after a webhook, that response appears as the tool result in your conversation history.";
12
- /**
13
- * Maximum number of retries for step execution.
14
- */ export var MAX_RETRIES = 1;