@positronic/core 0.0.77 → 0.0.78

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 (130) hide show
  1. package/dist/src/dsl/brain-runner.js +37 -182
  2. package/dist/src/dsl/brain-state-machine.js +58 -112
  3. package/dist/src/dsl/brain.js +1 -0
  4. package/dist/src/dsl/builder/brain.js +250 -412
  5. package/dist/src/dsl/builder/continuation.js +67 -0
  6. package/dist/src/dsl/constants.js +16 -17
  7. package/dist/src/dsl/create-brain.js +29 -45
  8. package/dist/src/dsl/example-webhook.js +1 -1
  9. package/dist/src/dsl/execution/constants.js +0 -4
  10. package/dist/src/dsl/execution/event-channel.js +77 -0
  11. package/dist/src/dsl/execution/event-stream.js +1625 -1474
  12. package/dist/src/dsl/signal-validation.js +0 -1
  13. package/dist/src/dsl/webhook.js +4 -1
  14. package/dist/src/files/event-wrapper.js +268 -0
  15. package/dist/src/files/index.js +1 -0
  16. package/dist/src/files/mime.js +31 -0
  17. package/dist/src/files/types.js +13 -0
  18. package/dist/src/index.js +10 -3
  19. package/dist/src/jsx-runtime.js +49 -0
  20. package/dist/src/memory/{scoped-memory.js → create-memory.js} +5 -5
  21. package/dist/src/plugins/collect-webhooks.js +49 -0
  22. package/dist/src/plugins/define-plugin.js +15 -0
  23. package/dist/src/plugins/index.js +1 -0
  24. package/dist/src/plugins/types.js +4 -0
  25. package/dist/src/store/types.js +2 -3
  26. package/dist/src/template/render-html.js +282 -0
  27. package/dist/src/template/render.js +357 -0
  28. package/dist/src/tools/index.js +88 -27
  29. package/dist/src/ui/generate-page-html.js +6 -6
  30. package/dist/src/ui/{generate-ui.js → generate-page.js} +24 -12
  31. package/dist/src/ui/parse-form-data.js +1 -11
  32. package/dist/src/ui/types.js +0 -123
  33. package/dist/src/yaml/data-validator.js +0 -27
  34. package/dist/src/yaml/type-inference.js +10 -9
  35. package/dist/types/clients/types.d.ts +15 -5
  36. package/dist/types/clients/types.d.ts.map +1 -1
  37. package/dist/types/dsl/brain-runner.d.ts +9 -14
  38. package/dist/types/dsl/brain-runner.d.ts.map +1 -1
  39. package/dist/types/dsl/brain-state-machine.d.ts +18 -28
  40. package/dist/types/dsl/brain-state-machine.d.ts.map +1 -1
  41. package/dist/types/dsl/brain.d.ts +3 -2
  42. package/dist/types/dsl/brain.d.ts.map +1 -1
  43. package/dist/types/dsl/builder/brain.d.ts +85 -228
  44. package/dist/types/dsl/builder/brain.d.ts.map +1 -1
  45. package/dist/types/dsl/builder/continuation.d.ts +16 -0
  46. package/dist/types/dsl/builder/continuation.d.ts.map +1 -0
  47. package/dist/types/dsl/constants.d.ts +12 -12
  48. package/dist/types/dsl/constants.d.ts.map +1 -1
  49. package/dist/types/dsl/create-brain.d.ts +17 -57
  50. package/dist/types/dsl/create-brain.d.ts.map +1 -1
  51. package/dist/types/dsl/definitions/blocks.d.ts +67 -66
  52. package/dist/types/dsl/definitions/blocks.d.ts.map +1 -1
  53. package/dist/types/dsl/definitions/brain-types.d.ts +8 -11
  54. package/dist/types/dsl/definitions/brain-types.d.ts.map +1 -1
  55. package/dist/types/dsl/definitions/events.d.ts +61 -56
  56. package/dist/types/dsl/definitions/events.d.ts.map +1 -1
  57. package/dist/types/dsl/definitions/run-params.d.ts +20 -21
  58. package/dist/types/dsl/definitions/run-params.d.ts.map +1 -1
  59. package/dist/types/dsl/definitions/steps.d.ts +1 -1
  60. package/dist/types/dsl/definitions/steps.d.ts.map +1 -1
  61. package/dist/types/dsl/example-webhook.d.ts +3 -3
  62. package/dist/types/dsl/example-webhook.d.ts.map +1 -1
  63. package/dist/types/dsl/execution/constants.d.ts +0 -5
  64. package/dist/types/dsl/execution/constants.d.ts.map +1 -1
  65. package/dist/types/dsl/execution/event-channel.d.ts +16 -0
  66. package/dist/types/dsl/execution/event-channel.d.ts.map +1 -0
  67. package/dist/types/dsl/execution/event-stream.d.ts +46 -34
  68. package/dist/types/dsl/execution/event-stream.d.ts.map +1 -1
  69. package/dist/types/dsl/signal-validation.d.ts.map +1 -1
  70. package/dist/types/dsl/types.d.ts +21 -83
  71. package/dist/types/dsl/types.d.ts.map +1 -1
  72. package/dist/types/dsl/webhook.d.ts +12 -2
  73. package/dist/types/dsl/webhook.d.ts.map +1 -1
  74. package/dist/types/files/event-wrapper.d.ts +20 -0
  75. package/dist/types/files/event-wrapper.d.ts.map +1 -0
  76. package/dist/types/files/index.d.ts +2 -0
  77. package/dist/types/files/index.d.ts.map +1 -0
  78. package/dist/types/files/mime.d.ts +2 -0
  79. package/dist/types/files/mime.d.ts.map +1 -0
  80. package/dist/types/files/types.d.ts +88 -0
  81. package/dist/types/files/types.d.ts.map +1 -0
  82. package/dist/types/index.d.ts +22 -13
  83. package/dist/types/index.d.ts.map +1 -1
  84. package/dist/types/jsx-runtime.d.ts +35 -0
  85. package/dist/types/jsx-runtime.d.ts.map +1 -0
  86. package/dist/types/memory/{scoped-memory.d.ts → create-memory.d.ts} +7 -7
  87. package/dist/types/memory/create-memory.d.ts.map +1 -0
  88. package/dist/types/memory/types.d.ts +4 -4
  89. package/dist/types/memory/types.d.ts.map +1 -1
  90. package/dist/types/plugins/collect-webhooks.d.ts +8 -0
  91. package/dist/types/plugins/collect-webhooks.d.ts.map +1 -0
  92. package/dist/types/plugins/define-plugin.d.ts +25 -0
  93. package/dist/types/plugins/define-plugin.d.ts.map +1 -0
  94. package/dist/types/plugins/index.d.ts +3 -0
  95. package/dist/types/plugins/index.d.ts.map +1 -0
  96. package/dist/types/plugins/types.d.ts +83 -0
  97. package/dist/types/plugins/types.d.ts.map +1 -0
  98. package/dist/types/store/index.d.ts +1 -1
  99. package/dist/types/store/index.d.ts.map +1 -1
  100. package/dist/types/store/types.d.ts +0 -8
  101. package/dist/types/store/types.d.ts.map +1 -1
  102. package/dist/types/template/render-html.d.ts +9 -0
  103. package/dist/types/template/render-html.d.ts.map +1 -0
  104. package/dist/types/template/render.d.ts +15 -0
  105. package/dist/types/template/render.d.ts.map +1 -0
  106. package/dist/types/tools/index.d.ts +39 -27
  107. package/dist/types/tools/index.d.ts.map +1 -1
  108. package/dist/types/ui/generate-page-html.d.ts +4 -6
  109. package/dist/types/ui/generate-page-html.d.ts.map +1 -1
  110. package/dist/types/ui/{generate-ui.d.ts → generate-page.d.ts} +6 -6
  111. package/dist/types/ui/generate-page.d.ts.map +1 -0
  112. package/dist/types/ui/parse-form-data.d.ts +1 -5
  113. package/dist/types/ui/parse-form-data.d.ts.map +1 -1
  114. package/dist/types/ui/types.d.ts +0 -49
  115. package/dist/types/ui/types.d.ts.map +1 -1
  116. package/dist/types/yaml/data-validator.d.ts +0 -5
  117. package/dist/types/yaml/data-validator.d.ts.map +1 -1
  118. package/dist/types/yaml/type-inference.d.ts +4 -2
  119. package/dist/types/yaml/type-inference.d.ts.map +1 -1
  120. package/dist/types/yaml/types.d.ts +0 -1
  121. package/dist/types/yaml/types.d.ts.map +1 -1
  122. package/package.json +5 -1
  123. package/dist/src/dsl/agent-messages.js +0 -5
  124. package/dist/src/ui/validate-form.js +0 -428
  125. package/dist/types/dsl/agent-messages.d.ts +0 -12
  126. package/dist/types/dsl/agent-messages.d.ts.map +0 -1
  127. package/dist/types/memory/scoped-memory.d.ts.map +0 -1
  128. package/dist/types/ui/generate-ui.d.ts.map +0 -1
  129. package/dist/types/ui/validate-form.d.ts +0 -45
  130. package/dist/types/ui/validate-form.d.ts.map +0 -1
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Simple async queue for passing events between a service (producer)
3
+ * and the event stream (consumer) during step execution.
4
+ *
5
+ * The event stream uses Promise.race between the step completing and
6
+ * channel.wait() to yield events mid-step without blocking.
7
+ */
8
+ export declare class EventChannel<T> {
9
+ private queue;
10
+ private waiter;
11
+ push(item: T): void;
12
+ /** Resolves when at least one item is in the queue, or immediately if non-empty */
13
+ wait(): Promise<void>;
14
+ drain(): T[];
15
+ }
16
+ //# sourceMappingURL=event-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-channel.d.ts","sourceRoot":"","sources":["../../../../src/dsl/execution/event-channel.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAA6B;IAE3C,IAAI,CAAC,IAAI,EAAE,CAAC;IAQZ,mFAAmF;IACnF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrB,KAAK,IAAI,CAAC,EAAE;CAKb"}
@@ -1,12 +1,14 @@
1
1
  import { z } from 'zod';
2
- import type { State, JsonObject, AgentTool } from '../types.js';
2
+ import type { State, JsonObject } from '../types.js';
3
+ import type { PagesService } from '../pages.js';
3
4
  import type { UIComponent } from '../../ui/types.js';
4
- import type { MemoryProvider } from '../../memory/types.js';
5
5
  import type { Store } from '../../store/types.js';
6
+ import type { FilesService } from '../../files/types.js';
7
+ import type { PluginAdapter, ConfiguredPlugin } from '../../plugins/types.js';
6
8
  import type { BrainEvent } from '../definitions/events.js';
7
9
  import type { Block } from '../definitions/blocks.js';
8
10
  import type { InitialRunParams, ResumeRunParams } from '../definitions/run-params.js';
9
- export declare class BrainEventStream<TOptions extends JsonObject = JsonObject, TState extends State = object, TServices extends object = object> {
11
+ export declare class BrainEventStream<TOptions extends JsonObject = JsonObject, TState extends State = object, TPlugins extends object = object> {
10
12
  private currentState;
11
13
  private steps;
12
14
  private currentStepIndex;
@@ -15,20 +17,21 @@ export declare class BrainEventStream<TOptions extends JsonObject = JsonObject,
15
17
  private description?;
16
18
  private client;
17
19
  private options;
18
- private services;
19
20
  private resources;
20
21
  private pages?;
21
22
  private env;
22
23
  private currentResponse;
23
24
  private currentPage;
24
- private resumeContext?;
25
+ private resume?;
25
26
  private components?;
26
- private defaultTools?;
27
- private extraTools?;
28
27
  private signalProvider?;
29
- private memoryProvider?;
30
- private scopedMemory?;
31
28
  private store?;
29
+ private files?;
30
+ private storeProvider?;
31
+ private pluginInjections;
32
+ private pluginAdapters;
33
+ private pluginConfigs;
34
+ private templateContext;
32
35
  private governor?;
33
36
  private currentUser;
34
37
  private guards;
@@ -38,46 +41,55 @@ export declare class BrainEventStream<TOptions extends JsonObject = JsonObject,
38
41
  constructor(params: (InitialRunParams<TOptions> | ResumeRunParams<TOptions>) & {
39
42
  title: string;
40
43
  description?: string;
41
- blocks: Block<any, any, TOptions, TServices, any, any>[];
42
- services: TServices;
44
+ blocks: Block<any, any, TOptions, TPlugins, any, any>[];
43
45
  components?: Record<string, UIComponent<any>>;
44
- defaultTools?: Record<string, AgentTool<any>>;
45
- extraTools?: Record<string, AgentTool<any>>;
46
- memoryProvider?: MemoryProvider;
46
+ files?: FilesService;
47
+ pages?: PagesService;
47
48
  store?: Store<any>;
48
49
  optionsSchema?: z.ZodSchema<any>;
50
+ pluginInjections?: Record<string, any>;
51
+ pluginAdapters?: PluginAdapter[];
52
+ pluginConfigs?: ConfiguredPlugin[];
49
53
  });
50
- /**
51
- * Find webhookResponse anywhere in the resumeContext tree (for nested brain resumes)
52
- */
53
- private findWebhookResponseInResumeContext;
54
54
  next(): AsyncGenerator<BrainEvent<TOptions>>;
55
+ private generate;
56
+ private stepStatusEvent;
57
+ /** Params forwarded to inner brain runs (nested .brain() and .map() steps). */
58
+ private get innerBrainParams();
55
59
  private buildStepContext;
56
60
  private executeStep;
57
- private executeAgent;
58
- /**
59
- * Execute an iterate prompt step, yielding one ITERATE_ITEM_COMPLETE
60
- * event per item. Between items, checks for PAUSE/KILL signals so
61
- * Cloudflare backends can restart the DO to reclaim memory.
62
- */
63
- private executeIteratePrompt;
64
61
  /**
65
- * Execute a nested brain iterate step. Runs the inner brain once per item
66
- * from the `over` list, collects [item, innerState] tuples under `outputKey`.
62
+ * Execute a prompt step. Either single-shot (generateObject) or
63
+ * iterative tool-calling loop (generateText) when `loop` is present.
67
64
  */
68
- private executeIterateBrain;
65
+ private executePrompt;
69
66
  /**
70
- * Execute an agent config iterate step. Runs the agent once per item
71
- * from the `over` list, collects [item, agentResult] tuples under `outputKey`.
67
+ * Shared prompt loop generator. Contains the core iteration logic:
68
+ * resume handling, signal checks, LLM calls, tool processing, and event emission.
69
+ *
70
+ * Yields all PROMPT_* events. When the done tool or a terminal tool fires,
71
+ * updates this.currentState, yields PROMPT_COMPLETE, and returns.
72
+ * The caller is responsible for calling completeStep().
73
+ *
74
+ * When a webhook suspension occurs and allowWebhookSuspension is true,
75
+ * yields PROMPT_WEBHOOK + WEBHOOK events and returns. If false, throws.
72
76
  */
73
- private executeIterateAgent;
77
+ private runPromptLoop;
74
78
  /**
75
- * Execute a UI generation step.
76
- * Generates UI components, renders to HTML, creates page, and sets up webhook.
79
+ * Execute a map step. Runs the inner brain once per item
80
+ * from the `over` list, collects [item, innerState] tuples under `outputKey`.
77
81
  */
78
- private executeUIStep;
82
+ private executeMap;
83
+ private buildFormAction;
84
+ private executePageStep;
79
85
  private executeWait;
80
86
  private executeGuard;
87
+ /**
88
+ * Run a prompt loop for a single map item. Delegates to the shared
89
+ * runPromptLoop generator, drains events (map doesn't forward prompt events),
90
+ * and extracts the result from the PROMPT_COMPLETE event.
91
+ */
92
+ private runMapPromptLoop;
81
93
  private completeStep;
82
94
  }
83
95
  //# sourceMappingURL=event-stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../../../../src/dsl/execution/event-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EAEV,SAAS,EAKV,MAAM,aAAa,CAAC;AAWrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,KAAK,EAMN,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,CAAC,gBAAgB;YAoBT,WAAW;IAsN1B;;;OAGG;YACY,aAAa;IAiE5B;;;;;;;;;;OAUG;YACY,aAAa;IAygB5B;;;OAGG;YACY,UAAU;IAmKzB,OAAO,CAAC,eAAe;YAWR,eAAe;YAiJf,WAAW;IAsD1B,OAAO,CAAE,YAAY;IAqDrB;;;;OAIG;YACW,gBAAgB;IAkC9B,OAAO,CAAE,YAAY;CAsBtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"signal-validation.d.ts","sourceRoot":"","sources":["../../../src/dsl/signal-validation.ts"],"names":[],"mappings":"AA8BA;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,sBAAsB,EACzC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,sBAAsB,CA4BxB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,sBAAsB,EACzC,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAmBV"}
1
+ {"version":3,"file":"signal-validation.d.ts","sourceRoot":"","sources":["../../../src/dsl/signal-validation.ts"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,sBAAsB,EACzC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,sBAAsB,CA4BxB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,sBAAsB,EACzC,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAmBV"}
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
2
  import type { WebhookRegistration } from './webhook.js';
3
- import type { ToolChoice } from '../clients/types.js';
4
3
  export type JsonPrimitive = string | number | boolean | null;
5
4
  export type JsonArray = JsonValue[];
6
5
  export type JsonObject = {
@@ -54,7 +53,7 @@ export type JsonPatch = {
54
53
  * Return type for tools that need to suspend execution and wait for an external event.
55
54
  * Supports single webhook or array of webhooks (first response wins).
56
55
  */
57
- export interface AgentToolWaitFor {
56
+ export interface ToolWaitFor {
58
57
  waitFor: WebhookRegistration<z.ZodSchema> | WebhookRegistration<z.ZodSchema>[];
59
58
  timeout?: number;
60
59
  }
@@ -62,10 +61,14 @@ export interface AgentToolWaitFor {
62
61
  * Context passed to step actions, agent config functions, and tool execute functions.
63
62
  * This is the same context available throughout brain execution.
64
63
  *
65
- * Generic parameters allow type-safe access to state, options, response, and page.
64
+ * Generic parameters allow type-safe access to state and options.
66
65
  * For tools (which are defined statically), use the non-generic defaults.
66
+ *
67
+ * Ephemeral data like `response` (from webhooks) and `page` (from page steps)
68
+ * is only available inside `.handle()` callbacks after `.wait()` and `.page()` `notify` callbacks,
69
+ * where it's injected via intersection types.
67
70
  */
68
- export interface StepContext<TState = object, TOptions = JsonObject, TResponse = JsonObject | undefined, TPage = import('./definitions/brain-types.js').GeneratedPage | undefined> {
71
+ export interface StepContext<TState = object, TOptions = JsonObject> {
69
72
  /** Current brain state */
70
73
  state: TState;
71
74
  /** Brain options */
@@ -74,30 +77,28 @@ export interface StepContext<TState = object, TOptions = JsonObject, TResponse =
74
77
  client: import('../clients/types.js').ObjectGenerator;
75
78
  /** Resource loader for accessing brain resources */
76
79
  resources: import('../resources/resources.js').Resources;
77
- /** Webhook response data (when resuming after a webhook) */
78
- response: TResponse;
79
- /** Generated page from a previous UI step */
80
- page: TPage;
81
- /** Page service for creating UI pages */
80
+ /** Page service for creating pages */
82
81
  pages: import('./pages.js').PagesService;
83
82
  /** Runtime environment (origin, secrets) */
84
83
  env: RuntimeEnv;
85
- /** UI components available for generateUI */
84
+ /** UI components available for generatePage */
86
85
  components?: Record<string, import('../ui/types.js').UIComponent<any>>;
87
86
  /** Current brain run ID (for creating unique webhook identifiers) */
88
87
  brainRunId: string;
89
88
  /** Current step ID (for creating unique webhook identifiers) */
90
89
  stepId: string;
91
- /** Scoped memory for storing and retrieving long-term memories */
92
- memory?: import('../memory/types.js').ScopedMemory;
93
90
  /** The authenticated user running this brain */
94
91
  currentUser: CurrentUser;
92
+ /** File storage service for creating, reading, and managing files. Present when the backend provides it. */
93
+ files?: import('../files/types.js').FilesService;
94
+ /** Typed key-value store — available when the brain calls withStore() */
95
+ store?: import('../store/types.js').Store<any>;
95
96
  }
96
97
  /**
97
- * A tool definition for use in agent steps.
98
+ * A tool definition for use in LLM tool-calling workflows.
98
99
  * Compatible with Vercel AI SDK tool format, extended with Positronic-specific properties.
99
100
  */
100
- export interface AgentTool<TInput extends z.ZodSchema = z.ZodSchema> {
101
+ export interface Tool<TInput extends z.ZodSchema = z.ZodSchema> {
101
102
  /** Description of what this tool does, helps the LLM understand when to use it */
102
103
  description: string;
103
104
  /** Zod schema defining the input parameters for this tool */
@@ -109,78 +110,18 @@ export interface AgentTool<TInput extends z.ZodSchema = z.ZodSchema> {
109
110
  * @param input - The validated input from the LLM
110
111
  * @param context - Runtime context with access to client, pages, state, etc.
111
112
  */
112
- execute?(input: z.infer<TInput>, context: StepContext): Promise<unknown | AgentToolWaitFor> | unknown | AgentToolWaitFor;
113
+ execute?(input: z.infer<TInput>, context: StepContext): Promise<unknown | ToolWaitFor> | unknown | ToolWaitFor;
113
114
  /**
114
- * If true, calling this tool ends the agent.
115
- * The tool's input becomes the agent result (merged into state).
115
+ * If true, calling this tool ends the workflow.
116
+ * The tool's input becomes the result (merged into state).
116
117
  */
117
118
  terminal?: boolean;
118
119
  }
119
- /**
120
- * Configuration for agent output schema.
121
- * When provided, generates a terminal tool from the schema and
122
- * namespaces the result in state under the specified key.
123
- */
124
- export interface AgentOutputSchema<TSchema extends z.ZodObject<any> = z.ZodObject<any>, TName extends string = string> {
125
- /** Zod schema defining the agent's output structure */
126
- schema: TSchema;
127
- /** Key name to store the result under in state (use `as const` for type inference) */
128
- name: TName;
129
- }
130
- /**
131
- * Configuration for an agent step.
132
- */
133
- export interface AgentConfig<TTools extends Record<string, AgentTool<any>> = Record<string, AgentTool<any>>, TOutputSchema extends AgentOutputSchema | undefined = undefined> {
134
- /** System prompt for the LLM */
135
- system?: string;
136
- /** Initial user prompt to start the conversation. If omitted, uses "Begin." */
137
- prompt?: string;
138
- /** Tools available to the LLM. Optional - merged with withTools defaults */
139
- tools?: TTools;
140
- /** Safety valve - exit if cumulative tokens exceed this limit */
141
- maxTokens?: number;
142
- /** Maximum number of agent loop iterations. Default: 100 */
143
- maxIterations?: number;
144
- /**
145
- * Output schema for structured agent output.
146
- * When provided, generates a terminal tool that validates output against the schema
147
- * and stores the result under state[outputSchema.name].
148
- */
149
- outputSchema?: TOutputSchema;
150
- /**
151
- * Tool choice configuration for LLM calls.
152
- * - 'auto': Model chooses whether to call tools
153
- * - 'required': Model must call a tool (default for agents)
154
- * - 'none': Model cannot call tools
155
- */
156
- toolChoice?: ToolChoice;
157
- }
158
- /**
159
- * Represents a single message in the agent conversation.
160
- */
161
- export interface AgentMessage {
162
- role: 'user' | 'assistant' | 'tool';
163
- content: string;
164
- /** For tool messages, the ID of the tool call this is responding to */
165
- toolCallId?: string;
166
- /** For tool messages, the name of the tool */
167
- toolName?: string;
168
- }
169
- /**
170
- * Helper type to extract the terminal tool's input type from a tools object.
171
- * Used for typing the result that gets merged into state.
172
- */
173
- export type ExtractTerminalInput<TTools extends Record<string, AgentTool<any>>> = {
174
- [K in keyof TTools]: TTools[K] extends {
175
- terminal: true;
176
- inputSchema: infer S;
177
- } ? S extends z.ZodSchema ? z.infer<S> : never : never;
178
- }[keyof TTools];
179
120
  /**
180
121
  * Signal types that can be sent to a running brain.
181
- * Signals are processed in priority order: KILL > PAUSE > WEBHOOK_RESPONSE > RESUME > USER_MESSAGE
122
+ * Signals are processed in priority order: KILL > PAUSE > WEBHOOK_RESPONSE > RESUME
182
123
  */
183
- export type SignalType = 'KILL' | 'PAUSE' | 'USER_MESSAGE' | 'RESUME' | 'WEBHOOK_RESPONSE';
124
+ export type SignalType = 'KILL' | 'PAUSE' | 'RESUME' | 'WEBHOOK_RESPONSE';
184
125
  /**
185
126
  * A signal that can be injected into a running brain's execution.
186
127
  */
@@ -188,9 +129,6 @@ export type BrainSignal = {
188
129
  type: 'KILL';
189
130
  } | {
190
131
  type: 'PAUSE';
191
- } | {
192
- type: 'USER_MESSAGE';
193
- content: string;
194
132
  } | {
195
133
  type: 'RESUME';
196
134
  } | {
@@ -207,7 +145,7 @@ export interface SignalProvider {
207
145
  * Signals should be consumed (deleted) when returned.
208
146
  *
209
147
  * @param filter - 'CONTROL' returns only KILL/PAUSE, 'WEBHOOK' returns only WEBHOOK_RESPONSE, 'ALL' includes all signal types
210
- * @returns Array of signals in priority order (KILL first, then PAUSE, then WEBHOOK_RESPONSE, then RESUME, then USER_MESSAGE)
148
+ * @returns Array of signals in priority order (KILL first, then PAUSE, then WEBHOOK_RESPONSE, then RESUME)
211
149
  */
212
150
  getSignals(filter: 'CONTROL' | 'WEBHOOK' | 'ALL'): Promise<BrainSignal[]>;
213
151
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK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M,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAC3E"}
@@ -12,8 +12,12 @@ export type SerializedWebhookRegistration = {
12
12
  };
13
13
  export type SerializedPageContext = {
14
14
  url: string;
15
- webhook: SerializedWebhookRegistration;
15
+ webhook?: SerializedWebhookRegistration;
16
16
  };
17
+ export interface WebhookTriggerConfig {
18
+ brain: string;
19
+ runAs: string;
20
+ }
17
21
  export type WebhookHandlerResult<TSchema extends z.ZodSchema = z.ZodSchema> = {
18
22
  type: 'verification';
19
23
  challenge: string;
@@ -21,14 +25,20 @@ export type WebhookHandlerResult<TSchema extends z.ZodSchema = z.ZodSchema> = {
21
25
  type: 'webhook';
22
26
  identifier: string;
23
27
  response: z.infer<TSchema>;
28
+ } | {
29
+ type: 'trigger';
30
+ response: z.infer<TSchema>;
31
+ } | {
32
+ type: 'ignore';
24
33
  };
25
34
  export interface WebhookFunction<TSchema extends z.ZodSchema = z.ZodSchema> {
26
35
  (identifier: string, token?: string): WebhookRegistration<TSchema>;
27
36
  handler: (request: Request) => Promise<WebhookHandlerResult<TSchema>>;
28
37
  slug: string;
29
38
  schema: TSchema;
39
+ triggers?: WebhookTriggerConfig;
30
40
  }
31
- export declare function createWebhook<TSchema extends z.ZodSchema>(slug: string, schema: TSchema, handler: (request: Request) => Promise<WebhookHandlerResult<TSchema>>): WebhookFunction<TSchema>;
41
+ export declare function createWebhook<TSchema extends z.ZodSchema>(slug: string, schema: TSchema, handler: (request: Request) => Promise<WebhookHandlerResult<TSchema>>, triggers?: WebhookTriggerConfig): WebhookFunction<TSchema>;
32
42
  type ExtractSchema<T> = T extends {
33
43
  schema: infer S;
34
44
  } ? S extends z.ZodSchema ? z.infer<S> : never : never;
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../src/dsl/webhook.ts"],"names":[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C9B,eAAe,CAAC,OAAO,CAAC,CAqB1B;AAGD,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACjD,CAAC,SAAS,CAAC,CAAC,SAAS,GACnB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACV,KAAK,GACP,KAAK,CAAC;AAGV,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAG9E,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,GAAG,MAAM,KAAK,CAAC,GACxE,KAAK,CAAC,MAAM,CAAC,SAAS,MAAM,IAAI,GAC9B,aAAa,CAAC,IAAI,CAAC,GACnB,KAAK,GACP,KAAK,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { FilesService } from './types.js';
2
+ import type { FileWriteStartEvent, FileWriteCompleteEvent } from '../dsl/definitions/events.js';
3
+ import type { JsonObject } from '../dsl/types.js';
4
+ type FileEvent = FileWriteStartEvent | FileWriteCompleteEvent;
5
+ /** Minimal interface — the wrapper only needs push(), not the full EventChannel */
6
+ interface EventSink {
7
+ push(event: FileEvent): void;
8
+ }
9
+ interface EventContext {
10
+ options: JsonObject;
11
+ brainRunId: string;
12
+ stepTitle: string;
13
+ }
14
+ /**
15
+ * Wraps a FilesService to push events onto a channel during write operations.
16
+ * The wrapper is transparent — same interface, brain authors see no change.
17
+ */
18
+ export declare function wrapFilesWithEvents(files: FilesService, channel: EventSink, ctx: EventContext): FilesService;
19
+ export {};
20
+ //# sourceMappingURL=event-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-wrapper.d.ts","sourceRoot":"","sources":["../../../src/files/event-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,KAAK,SAAS,GAAG,mBAAmB,GAAG,sBAAsB,CAAC;AAE9D,mFAAmF;AACnF,UAAU,SAAS;IACjB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CAC9B;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAqED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,SAAS,EAClB,GAAG,EAAE,YAAY,GAChB,YAAY,CAqBd"}
@@ -0,0 +1,2 @@
1
+ export type { FileInput, FileOptions, FileRef, FileHandle, FilesService, ZipBuilder, } from './types.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function guessMimeType(name: string): string;
2
+ //# sourceMappingURL=mime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../../src/files/mime.ts"],"names":[],"mappings":"AA0BA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Accepted input types for file write operations.
3
+ * - string: text content, written as UTF-8
4
+ * - Uint8Array: binary content
5
+ * - Response: fetch response — body is streamed, never fully buffered
6
+ * - ReadableStream: streamed directly to storage
7
+ * - FileHandle: another file — content is streamed from storage to storage
8
+ */
9
+ export type FileInput = string | Uint8Array | Response | ReadableStream | FileHandle;
10
+ /**
11
+ * Options for file operations.
12
+ * Scope controls where the file is stored and who can access it.
13
+ * All scopes are always per-user — files are never visible to other users.
14
+ */
15
+ export interface FileOptions {
16
+ /**
17
+ * - 'run': ephemeral, scoped to this brain run (cleaned up after run completes)
18
+ * - 'brain': persists across runs, scoped to this brain + user (default)
19
+ * - 'global': persists across runs AND across brains, scoped to user
20
+ */
21
+ scope?: 'run' | 'brain' | 'global';
22
+ }
23
+ /**
24
+ * Lightweight reference to a file. Stored in brain state to track files
25
+ * without serializing URLs (which are environment-dependent).
26
+ */
27
+ export interface FileRef {
28
+ name: string;
29
+ }
30
+ /**
31
+ * A lazy file handle. Created by files.open() — no I/O until you call a method.
32
+ * The `url` property is computed from the current origin, never stale.
33
+ */
34
+ export interface FileHandle {
35
+ /** The file name (identifier within its scope) */
36
+ name: string;
37
+ /** Public download URL, computed from current origin */
38
+ url: string;
39
+ /** Read file content as UTF-8 text (buffers into memory) */
40
+ read(): Promise<string>;
41
+ /** Read file content as binary (buffers into memory) */
42
+ readBytes(): Promise<Uint8Array>;
43
+ /**
44
+ * Write content to the file. Accepts multiple input types:
45
+ * - string or Uint8Array: written directly
46
+ * - Response: body is streamed (from fetch)
47
+ * - ReadableStream: streamed directly
48
+ * - FileHandle: content streamed from another file (R2-to-R2)
49
+ */
50
+ write(content: FileInput): Promise<FileRef>;
51
+ /** Check if the file exists in storage */
52
+ exists(): Promise<boolean>;
53
+ /** Delete the file from storage */
54
+ delete(): Promise<void>;
55
+ }
56
+ /**
57
+ * Streaming zip builder. Created by files.zip() — no I/O until write() is called.
58
+ * Content is streamed through a zip encoder and uploaded to storage via multipart upload.
59
+ * Peak memory: ~5MB part buffer + one in-flight chunk.
60
+ */
61
+ export interface ZipBuilder {
62
+ /** Add content to the zip. Same input types as file.write(). */
63
+ write(name: string, content: FileInput): Promise<void>;
64
+ /** Complete the zip and upload. Returns a ref to the zip file. */
65
+ finalize(): Promise<FileRef>;
66
+ }
67
+ /**
68
+ * Service for creating and managing files during brain execution.
69
+ * Available on the step context as `files`.
70
+ *
71
+ * Files are always scoped per-user. Default scope is 'brain' (persists across runs).
72
+ */
73
+ export interface FilesService {
74
+ /**
75
+ * Get a lazy file handle. No I/O — returns immediately.
76
+ * Use methods on the handle to read, write, or check existence.
77
+ */
78
+ open(name: string, options?: FileOptions): FileHandle;
79
+ /** Convenience: open(name, options).write(content) */
80
+ write(name: string, content: FileInput, options?: FileOptions): Promise<FileRef>;
81
+ /** List all files in the default scope */
82
+ list(): Promise<FileRef[]>;
83
+ /** Delete a file by name */
84
+ delete(name: string): Promise<void>;
85
+ /** Create a streaming zip builder. Returns synchronously — no I/O until write(). */
86
+ zip(name: string, options?: FileOptions): ZipBuilder;
87
+ }
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/files/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,UAAU,GACV,QAAQ,GACR,cAAc,GACd,UAAU,CAAC;AAEf;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IAEZ,4DAA4D;IAC5D,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,wDAAwD;IACxD,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE5C,0CAA0C;IAC1C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,mCAAmC;IACnC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,kEAAkE;IAClE,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAEtD,sDAAsD;IACtD,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,0CAA0C;IAC1C,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE3B,4BAA4B;IAC5B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC,oFAAoF;IACpF,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACtD"}
@@ -1,13 +1,19 @@
1
- export { Brain, brain } from './dsl/brain.js';
1
+ export { Brain, brain, Continuation } from './dsl/brain.js';
2
2
  export { BrainRunner } from './dsl/brain-runner.js';
3
3
  export { createBrain } from './dsl/create-brain.js';
4
4
  export type { CreateBrainConfig } from './dsl/create-brain.js';
5
5
  export { STATUS, BRAIN_EVENTS } from './dsl/constants.js';
6
6
  export type { Adapter } from './adapters/types.js';
7
- export type { BrainEvent, SerializedStep, InitialRunParams, ResumeRunParams, ResumeContext, BrainStartEvent, BrainCompleteEvent, BrainErrorEvent, StepStatusEvent, StepStartedEvent, StepCompletedEvent, BrainStructure, BrainConfig, GeneratedPage, } from './dsl/brain.js';
8
- export type { ObjectGenerator, Message, ToolMessage, ToolCall, ResponseMessage, ToolChoice, } from './clients/types.js';
9
- export type { State, CurrentUser, RuntimeEnv, Secrets, AgentTool, AgentConfig, AgentOutputSchema, AgentMessage, AgentToolWaitFor, StepContext, ExtractTerminalInput, SignalType, BrainSignal, SignalProvider, } from './dsl/types.js';
10
- export type { TemplateContext, IterateTemplateContext, } from './dsl/definitions/blocks.js';
7
+ export type { BrainEvent, SerializedStep, ResumeParams, InitialRunParams, ResumeRunParams, BrainStartEvent, BrainCompleteEvent, BrainErrorEvent, StepStatusEvent, StepStartedEvent, StepCompletedEvent, BrainStructure, BrainConfig, GeneratedPage, } from './dsl/brain.js';
8
+ export type { ObjectGenerator, Message, ToolMessage, ToolCall, ResponseMessage, ToolChoice, Attachment, } from './clients/types.js';
9
+ export type { State, CurrentUser, RuntimeEnv, Secrets, Tool, ToolWaitFor, StepContext, SignalType, BrainSignal, SignalProvider, } from './dsl/types.js';
10
+ export type { TemplateReturn } from './dsl/definitions/blocks.js';
11
+ export type { TemplateNode, TemplateChild } from './jsx-runtime.js';
12
+ export { Fragment, File, Resource, Form } from './jsx-runtime.js';
13
+ export { renderTemplate, isTemplateNode, resolveTemplate, buildTemplateContext, } from './template/render.js';
14
+ export type { TemplateContext } from './template/render.js';
15
+ export { renderHtml } from './template/render-html.js';
16
+ export type { RenderHtmlContext } from './template/render-html.js';
11
17
  export { applyPatches } from './dsl/json-patch.js';
12
18
  export { IterateResult } from './dsl/iterate-result.js';
13
19
  export { parseDuration } from './dsl/duration.js';
@@ -15,15 +21,19 @@ export { z } from 'zod';
15
21
  export type { ResourceLoader } from './resources/resource-loader.js';
16
22
  export { createResources, type Resources } from './resources/resources.js';
17
23
  export { createWebhook } from './dsl/webhook.js';
18
- export type { WebhookFunction, WebhookRegistration } from './dsl/webhook.js';
24
+ export type { WebhookFunction, WebhookRegistration, WebhookTriggerConfig, } from './dsl/webhook.js';
19
25
  export type { PagesService, Page, PageCreateOptions } from './dsl/pages.js';
20
26
  export type { Manifest as ResourceManifest, Entry as ResourceEntry, ResourceType, } from './resources/resources.js';
21
27
  export { RESOURCE_TYPES } from './resources/resources.js';
22
- export type { AgentStartEvent, AgentIterationEvent, AgentToolCallEvent, AgentToolResultEvent, AgentAssistantMessageEvent, AgentCompleteEvent, AgentTokenLimitEvent, AgentIterationLimitEvent, AgentWebhookEvent, AgentRawResponseMessageEvent, AgentUserMessageEvent, WebhookResponseEvent, BrainPausedEvent, IterateItemCompleteEvent, } from './dsl/definitions/events.js';
23
- export { createTool, defaultTools, defaultDoneSchema, generateUI, waitForWebhook, print, consoleLog, } from './tools/index.js';
24
- export type { Store, StoreProvider, PerUserField, InferStoreTypes, StoreContext, } from './store/types.js';
25
- export type { Memory, MemoryMessage, MemoryScope, MemorySearchOptions, MemoryAddOptions, MemoryProvider, ScopedMemory, } from './memory/types.js';
26
- export { createScopedMemory } from './memory/scoped-memory.js';
28
+ export type { WebhookResponseEvent, BrainPausedEvent, IterateItemCompleteEvent, FileWriteStartEvent, FileWriteCompleteEvent, PromptStartEvent, PromptIterationEvent, PromptToolCallEvent, PromptToolResultEvent, PromptAssistantMessageEvent, PromptCompleteEvent, PromptTokenLimitEvent, PromptIterationLimitEvent, PromptRawResponseMessageEvent, PromptWebhookEvent, } from './dsl/definitions/events.js';
29
+ export { createTool, defaultTools, generatePage, waitForWebhook, print, consoleLog, readFile, writeFile, } from './tools/index.js';
30
+ export type { Store, StoreProvider, PerUserField, InferStoreTypes, } from './store/types.js';
31
+ export { guessMimeType } from './files/mime.js';
32
+ export type { FileInput, FileOptions, FileRef, FileHandle, FilesService, ZipBuilder, } from './files/types.js';
33
+ export type { Memory, MemoryEntry, MemoryMessage, MemoryScope, MemorySearchOptions, MemoryAddOptions, MemoryProvider, } from './memory/types.js';
34
+ export { definePlugin } from './plugins/index.js';
35
+ export { collectPluginWebhooks } from './plugins/collect-webhooks.js';
36
+ export type { CreateContext, PluginAdapter, PluginCreateReturn, PluginDefinition, PluginInjection, PluginsFrom, PluginsFromArray, ConfiguredPlugin, ConfiguredPluginWithSetup, } from './plugins/index.js';
27
37
  export type { UIComponent } from './ui/types.js';
28
38
  export { generateFormToken } from './ui/generate-page-html.js';
29
39
  export { parseFormData } from './ui/parse-form-data.js';
@@ -31,6 +41,5 @@ export { validateWebhookToken } from './validate-webhook-token.js';
31
41
  export { createBrainExecutionMachine, createBrainMachine, sendEvent, reconstructBrainTree, brainMachineDefinition, } from './dsl/brain-state-machine.js';
32
42
  export { isSignalValid, getValidSignals } from './dsl/signal-validation.js';
33
43
  export type { MachineStateDefinition, SignalValidationResult, } from './dsl/signal-validation.js';
34
- export type { BrainStateMachine, BrainExecutionContext, BrainStackEntry, BrainEntry, ExecutionStackEntry, RunningBrain, StepInfo, ExecutionState, CreateMachineOptions, AgentContext, IterateContext, ExecutionNode, } from './dsl/brain-state-machine.js';
35
- export type { AgentResumeContext } from './dsl/agent-messages.js';
44
+ export type { BrainStateMachine, BrainExecutionContext, BrainStackEntry, BrainEntry, ExecutionStackEntry, RunningBrain, StepInfo, ExecutionState, CreateMachineOptions, IterateContext, PromptLoopContext, ExecutionNode, } from './dsl/brain-state-machine.js';
36
45
  //# sourceMappingURL=index.d.ts.map
@@ -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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