@statelyai/agent 2.0.0-next.1 → 2.0.0-next.2

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 (44) hide show
  1. package/.changeset/grumpy-dolphins-think.md +17 -0
  2. package/.changeset/old-teachers-tap.md +5 -0
  3. package/.changeset/pre.json +4 -1
  4. package/.changeset/smart-yaks-pull.md +23 -0
  5. package/CHANGELOG.md +40 -0
  6. package/dist/index.d.mts +55 -46
  7. package/dist/index.d.ts +55 -46
  8. package/dist/index.js +78 -50
  9. package/dist/index.mjs +81 -53
  10. package/examples/chatbot.ts +2 -2
  11. package/examples/cot.ts +6 -24
  12. package/examples/customer-service-sim.ts +3 -3
  13. package/examples/email.ts +9 -3
  14. package/examples/example.ts +2 -2
  15. package/examples/goal.ts +2 -2
  16. package/examples/joke.ts +2 -2
  17. package/examples/jugs.ts +4 -7
  18. package/examples/learn-from-feedback.ts +100 -0
  19. package/examples/number.ts +2 -2
  20. package/examples/raffle.ts +2 -2
  21. package/examples/river-crossing.ts +4 -7
  22. package/examples/simple.ts +13 -10
  23. package/examples/summary.ts +2 -5
  24. package/examples/support.ts +42 -38
  25. package/examples/ticTacToe.ts +46 -4
  26. package/examples/todo.ts +2 -2
  27. package/examples/tutor.ts +2 -2
  28. package/examples/verify.ts +2 -2
  29. package/examples/weather-agent.ts +141 -0
  30. package/examples/weather.ts +23 -23
  31. package/examples/word.ts +8 -6
  32. package/package.json +2 -1
  33. package/src/agent.test.ts +17 -15
  34. package/src/agent.ts +48 -35
  35. package/src/decide.test.ts +56 -8
  36. package/src/decide.ts +34 -24
  37. package/src/strategies/chainOfThought.ts +48 -0
  38. package/src/{planners → strategies}/shortestPath.test.ts +4 -7
  39. package/src/strategies/shortestPath.ts +173 -0
  40. package/src/{planners → strategies}/simple.ts +28 -18
  41. package/src/types.ts +62 -28
  42. package/src/utils.ts +12 -0
  43. package/src/planners/shortestPath.ts +0 -177
  44. package/src/strategies/chain-of-note.ts +0 -106
@@ -0,0 +1,17 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ planner -> strategy
6
+ agent.addPlan -> agent.addDecision
7
+ agent.getPlans -> agent.getDecisions
8
+
9
+ The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
10
+
11
+ ```diff
12
+ const agent = createAgent({
13
+ - planner: createSimplePlanner(),
14
+ + strategy: createSimpleStrategy(),
15
+ ...
16
+ });
17
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
@@ -7,7 +7,10 @@
7
7
  "changesets": [
8
8
  "cyan-carpets-perform",
9
9
  "fast-donkeys-argue",
10
+ "grumpy-dolphins-think",
10
11
  "light-hats-drive",
11
- "old-jobs-check"
12
+ "old-jobs-check",
13
+ "old-teachers-tap",
14
+ "smart-yaks-pull"
12
15
  ]
13
16
  }
@@ -0,0 +1,23 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
6
+
7
+ ```ts
8
+ const agent = createAgent({
9
+ // ...
10
+ events: {
11
+ PLAY: z.object({}).describe('Play a move'),
12
+ SKIP: z.object({}).describe('Skip a move'),
13
+ FORFEIT: z.object({}).describe('Forfeit the game'),
14
+ },
15
+ });
16
+
17
+ // ...
18
+ const decision = await agent.decide({
19
+ // Don't allow the agent to send `FORFEIT` or other events
20
+ allowedEvents: ['PLAY', 'SKIP'],
21
+ // ...
22
+ });
23
+ ```
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @statelyai/agent
2
2
 
3
+ ## 2.0.0-next.2
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4d870fe`](https://github.com/statelyai/agent/commit/4d870fe38ad0c906bafb2e0f6b2dabb745900ad3) Thanks [@davidkpiano](https://github.com/davidkpiano)! - planner -> strategy
8
+ agent.addPlan -> agent.addDecision
9
+ agent.getPlans -> agent.getDecisions
10
+
11
+ The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
12
+
13
+ ```diff
14
+ const agent = createAgent({
15
+ - planner: createSimplePlanner(),
16
+ + strategy: createSimpleStrategy(),
17
+ ...
18
+ });
19
+ ```
20
+
21
+ - [`f1189cb`](https://github.com/statelyai/agent/commit/f1189cb980e52fa909888d27d3300dcd913ea47f) Thanks [@davidkpiano](https://github.com/davidkpiano)! - For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
22
+
23
+ - [`7b16326`](https://github.com/statelyai/agent/commit/7b163266c61bfc8125ed4d00924680d932001e27) Thanks [@davidkpiano](https://github.com/davidkpiano)! - You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
24
+
25
+ ```ts
26
+ const agent = createAgent({
27
+ // ...
28
+ events: {
29
+ PLAY: z.object({}).describe("Play a move"),
30
+ SKIP: z.object({}).describe("Skip a move"),
31
+ FORFEIT: z.object({}).describe("Forfeit the game"),
32
+ },
33
+ });
34
+
35
+ // ...
36
+ const decision = await agent.decide({
37
+ // Don't allow the agent to send `FORFEIT` or other events
38
+ allowedEvents: ["PLAY", "SKIP"],
39
+ // ...
40
+ });
41
+ ```
42
+
3
43
  ## 2.0.0-next.1
4
44
 
5
45
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -13,14 +13,14 @@ type ZodContextMapping = {
13
13
  type GenerateTextOptions = Parameters<typeof generateText>[0];
14
14
  type StreamTextOptions = Parameters<typeof streamText>[0];
15
15
  type CostFunction<TEvent extends EventObject> = (path: AgentPath<TEvent>) => number;
16
- type AgentPlanInput<TEvent extends EventObject> = Omit<AgentGenerateTextOptions, 'prompt' | 'tools'> & {
16
+ type AgentDecideInput<TEvent extends EventObject> = Omit<AgentGenerateTextOptions, 'prompt' | 'tools'> & {
17
17
  /**
18
18
  * The currently observed state.
19
19
  */
20
20
  state: ObservedState;
21
21
  /**
22
22
  * The goal for the agent to accomplish.
23
- * The agent will create a plan based on this goal.
23
+ * The agent will make a decision based on this goal.
24
24
  */
25
25
  goal: string;
26
26
  /**
@@ -34,15 +34,15 @@ type AgentPlanInput<TEvent extends EventObject> = Omit<AgentGenerateTextOptions,
34
34
  */
35
35
  machine?: AnyStateMachine;
36
36
  /**
37
- * The previous plan.
37
+ * The previous decision made by the agent.
38
38
  */
39
- previousPlan?: AgentPlan<TEvent>;
39
+ prevDecision?: AgentDecision<TEvent>;
40
40
  /**
41
41
  * The total cost of the path to the goal state.
42
42
  */
43
43
  costFunction?: CostFunction<TEvent>;
44
44
  /**
45
- * The maximum number of attempts to generate a plan.
45
+ * The maximum number of attempts to make a decision.
46
46
  * Defaults to 2.
47
47
  */
48
48
  maxAttempts?: number;
@@ -60,14 +60,14 @@ type AgentPath<TEvent extends EventObject> = {
60
60
  steps: Array<AgentStep<TEvent>>;
61
61
  weight?: number;
62
62
  };
63
- type AgentPlan<TEvent extends EventObject> = {
63
+ type AgentDecision<TEvent extends EventObject> = {
64
64
  /**
65
- * The planner used to generate the plan
65
+ * The strategy used to generate the decision
66
66
  */
67
- planner: string;
67
+ strategy: string;
68
68
  goal: string;
69
69
  /**
70
- * The ending state of the plan.
70
+ * The ending state of the decision.
71
71
  */
72
72
  goalState: ObservedState | undefined;
73
73
  /**
@@ -117,17 +117,20 @@ type PromptTemplate<TEvents extends EventObject> = (data: {
117
117
  observations?: AgentObservation<any>[];
118
118
  feedback?: AgentFeedback[];
119
119
  messages?: AgentMessage[];
120
- plans?: AgentPlan<TEvents>[];
120
+ decisions?: AgentDecision<TEvents>[];
121
121
  }) => string;
122
- type AgentPlanner<T extends AnyAgent> = (agent: T, input: AgentPlanInput<T['types']['events']>) => Promise<AgentPlan<T['types']['events']> | undefined>;
122
+ type AgentStrategy<T extends AnyAgent> = (agent: T, input: AgentDecideInput<EventsFromAgent<T>>) => Promise<AgentDecision<EventsFromAgent<T>> | undefined>;
123
+ type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideOptions<T>, 'state'>;
123
124
  type AgentDecideOptions<T extends AnyAgent> = {
124
125
  goal: string;
125
- model?: LanguageModel;
126
126
  state: ObservedState;
127
+ context?: Record<string, any>;
127
128
  machine?: AnyStateMachine;
129
+ model?: LanguageModel;
128
130
  execute?: (event: AnyEventObject) => Promise<void>;
129
- planner?: AgentPlanner<T>;
131
+ strategy?: AgentStrategy<T>;
130
132
  events?: ZodEventMapping;
133
+ allowedEvents?: Array<EventsFromAgent<T>['type']>;
131
134
  /**
132
135
  * The maximum number of times the agent will attempt to make a decision.
133
136
  * Defaults to 2.
@@ -135,22 +138,20 @@ type AgentDecideOptions<T extends AnyAgent> = {
135
138
  maxAttempts?: number;
136
139
  } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
137
140
  interface AgentFeedback {
138
- goal?: string;
139
- observationId?: string;
141
+ goal: string;
142
+ observationId: string;
140
143
  /**
141
144
  * The message correlation that the feedback is relevant for
142
145
  */
143
146
  attributes: Record<string, any>;
144
- reward: number;
145
147
  timestamp: number;
146
148
  episodeId: string;
147
149
  }
148
150
  interface AgentFeedbackInput {
149
- goal?: string;
150
- observationId?: string;
151
- attributes?: Record<string, any>;
151
+ goal: string;
152
+ observationId: string;
153
+ attributes: Record<string, any>;
152
154
  timestamp?: number;
153
- reward?: number;
154
155
  }
155
156
  type AgentMessage = CoreMessage & {
156
157
  timestamp: number;
@@ -235,7 +236,7 @@ type AgentDecisionInput = {
235
236
  model?: LanguageModel;
236
237
  context?: Record<string, any>;
237
238
  } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
238
- type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<AgentPlan<TEvents> | undefined, AgentDecisionInput | string>;
239
+ type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<AgentDecision<TEvents> | undefined, AgentDecisionInput | string>;
239
240
  type AgentEmitted<TEvents extends EventObject> = {
240
241
  type: 'feedback';
241
242
  feedback: AgentFeedback;
@@ -246,8 +247,8 @@ type AgentEmitted<TEvents extends EventObject> = {
246
247
  type: 'message';
247
248
  message: AgentMessage;
248
249
  } | {
249
- type: 'plan';
250
- plan: AgentPlan<TEvents>;
250
+ type: 'decision';
251
+ decision: AgentDecision<TEvents>;
251
252
  };
252
253
  type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<AgentMemoryContext>, {
253
254
  type: 'agent.feedback';
@@ -259,8 +260,8 @@ type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<Age
259
260
  type: 'agent.message';
260
261
  message: AgentMessage;
261
262
  } | {
262
- type: 'agent.plan';
263
- plan: AgentPlan<TEvents>;
263
+ type: 'agent.decision';
264
+ decision: AgentDecision<TEvents>;
264
265
  }, any, // TODO: input
265
266
  any, AgentEmitted<TEvents>>;
266
267
  type EventsFromZodEventMapping<TEventSchemas extends ZodEventMapping> = Values<{
@@ -297,7 +298,7 @@ type ObservedStateFrom<TActor extends ActorRefLike> = Pick<SnapshotFrom<TActor>,
297
298
  type AgentMemoryContext = {
298
299
  observations: AgentObservation<any>[];
299
300
  messages: AgentMessage[];
300
- plans: AgentPlan<any>[];
301
+ decisions: AgentDecision<any>[];
301
302
  feedback: AgentFeedback[];
302
303
  };
303
304
  interface AgentLongTermMemory {
@@ -308,8 +309,15 @@ interface AgentLongTermMemory {
308
309
  type Compute<A extends any> = {
309
310
  [K in keyof A]: A[K];
310
311
  } & unknown;
312
+ type MaybePromise<T> = T | Promise<T>;
313
+ type EventsFromAgent<T extends AnyAgent> = T extends Agent<infer _, infer __, infer TEvents, infer ___> ? TEvents : never;
314
+ type TypesFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer TEventSchema> ? {
315
+ context: ContextFromZodContextMapping<TContextSchema>;
316
+ events: EventsFromZodEventMapping<TEventSchema>;
317
+ } : never;
318
+ type ContextFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer _TEventSchema> ? ContextFromZodContextMapping<TContextSchema> : never;
311
319
 
312
- declare function createAgent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>>({ id, description: description, model, events, context, planner, logic, }: {
320
+ declare function createAgent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>>({ id, description: description, model, events, context, episodeId, strategy, logic, }: {
313
321
  /**
314
322
  * The unique identifier for the agent.
315
323
  *
@@ -335,7 +343,7 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
335
343
  */
336
344
  events: TEventSchemas;
337
345
  context?: TContextSchema;
338
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
346
+ strategy?: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
339
347
  stringify?: typeof JSON.stringify;
340
348
  /**
341
349
  * A function that retrieves the agent's long term memory
@@ -346,7 +354,8 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
346
354
  */
347
355
  logic?: AgentLogic<TEvents>;
348
356
  model: LanguageModel;
349
- } & GenerateTextOptions): Agent<TContextSchema, TEventSchemas>;
357
+ episodeId?: string;
358
+ }): Agent<TContextSchema, TEventSchemas>;
350
359
  declare class Agent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>> extends Actor<AgentLogic<TEvents>> {
351
360
  /**
352
361
  * The name of the agent. All agents with the same name are related and
@@ -360,15 +369,11 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
360
369
  description?: string;
361
370
  events: TEventSchemas;
362
371
  context?: TContextSchema;
363
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
364
- types: {
365
- events: TEvents;
366
- context: Compute<TContext>;
367
- };
372
+ strategy: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
368
373
  model: LanguageModel;
369
374
  memory: AgentLongTermMemory | undefined;
370
375
  defaultOptions: AgentDecideOptions<AnyAgent> | undefined;
371
- constructor({ logic, id, name, description, model, events, context, planner, }: {
376
+ constructor({ logic, id, name, description, model, events, context, episodeId, strategy, }: {
372
377
  logic: AgentLogic<TEvents>;
373
378
  id?: string;
374
379
  name?: string;
@@ -376,12 +381,17 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
376
381
  model: GenerateTextOptions['model'];
377
382
  events: TEventSchemas;
378
383
  context?: TContextSchema;
379
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
384
+ strategy?: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
385
+ episodeId?: string;
380
386
  });
381
387
  /**
382
388
  * Called whenever the agent (LLM assistant) receives or sends a message.
383
389
  */
384
390
  onMessage(fn: (message: AgentMessage) => void): Subscription;
391
+ /**
392
+ * Called whenever the agent (LLM assistant) receives some feedback.
393
+ */
394
+ onFeedback(fn: (feedback: AgentFeedback) => void): Subscription;
385
395
  /**
386
396
  * Retrieves messages from the agent's short-term (local) memory.
387
397
  */
@@ -427,11 +437,10 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
427
437
  attributes: {
428
438
  [x: string]: any;
429
439
  };
430
- reward: number;
431
440
  timestamp: number;
432
441
  episodeId: string;
433
- goal?: string;
434
- observationId?: string;
442
+ goal: string;
443
+ observationId: string;
435
444
  };
436
445
  /**
437
446
  * Retrieves feedback from the agent's short-term (local) memory.
@@ -442,11 +451,11 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
442
451
  * Retrieves observations from the agent's short-term (local) memory.
443
452
  */
444
453
  getObservations(): AgentObservation<any>[];
445
- addPlan(plan: AgentPlan<TEvents>): void;
454
+ addDecision(decision: AgentDecision<TEvents>): void;
446
455
  /**
447
456
  * Retrieves strategies from the agent's short-term (local) memory.
448
457
  */
449
- getPlans(): AgentPlan<any>[];
458
+ getDecisions(): AgentDecision<any>[];
450
459
  /**
451
460
  * Interacts with this state machine actor by inspecting state transitions and storing them as observations.
452
461
  *
@@ -491,18 +500,18 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
491
500
  * actor.start();
492
501
  * ```
493
502
  */
494
- interact<TActor extends ActorRefLike>(actorRef: TActor, getInput: (observation: AgentObservation<TActor>) => AgentDecisionInput | undefined): Subscription;
503
+ interact<TActor extends ActorRefLike>(actorRef: TActor, getInput: (observation: AgentObservation<TActor>) => AgentInteractInput<this> | void): Subscription;
495
504
  observe<TActor extends ActorRefLike>(actorRef: TActor): Subscription;
496
505
  wrap(modelToWrap: LanguageModelV1): LanguageModelV1;
497
506
  /**
498
- * Resolves with an `AgentPlan` based on the information provided in the `options`, including:
507
+ * Resolves with an `AgentDecision` based on the information provided in the `options`, including:
499
508
  *
500
509
  * - The `goal` for the agent to achieve
501
510
  * - The observed current `state`
502
511
  * - The `machine` (e.g. a state machine) that specifies what can happen next
503
512
  * - Additional `context`
504
513
  */
505
- decide(opts: AgentDecideOptions<this>): Promise<AgentPlan<EventsFromZodEventMapping<this["events"]>> | undefined>;
514
+ decide(opts: AgentDecideOptions<this>): Promise<AgentDecision<EventsFromAgent<this>> | undefined>;
506
515
  }
507
516
 
508
517
  declare function fromTextStream<T extends AnyAgent>(agent: T, options?: AgentStreamTextOptions): ObservableActorLogic<{
@@ -514,6 +523,6 @@ declare function fromText<T extends AnyAgent>(agent: T, options?: AgentGenerateT
514
523
  context?: AgentGenerateTextOptions['context'];
515
524
  }>;
516
525
 
517
- declare function fromDecision(agent: AnyAgent, defaultInput?: AgentDecisionInput): AgentDecisionLogic<any>;
526
+ declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventsFromAgent<T>>): AgentDecisionLogic<any>;
518
527
 
519
- export { type AgentDecideOptions, type AgentDecisionInput, type AgentDecisionLogic, type AgentEmitted, type AgentFeedback, type AgentFeedbackInput, type AgentGenerateTextOptions, type AgentLogic, type AgentLongTermMemory, type AgentMemoryContext, type AgentMessage, type AgentMessageInput, type AgentObservation, type AgentObservationInput, type AgentPath, type AgentPlan, type AgentPlanInput, type AgentPlanner, type AgentStep, type AgentStreamTextOptions, type AnyAgent, type CommonTextOptions, type Compute, type ContextFromZodContextMapping, type CostFunction, type EventsFromZodEventMapping, type FromAgent, type GenerateTextOptions, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type ObservedState, type ObservedStateFrom, type PromptTemplate, type StreamTextOptions, type TransitionData, createAgent, fromDecision, fromText, fromTextStream };
528
+ export { type AgentDecideInput, type AgentDecideOptions, type AgentDecision, type AgentDecisionInput, type AgentDecisionLogic, type AgentEmitted, type AgentFeedback, type AgentFeedbackInput, type AgentGenerateTextOptions, type AgentInteractInput, type AgentLogic, type AgentLongTermMemory, type AgentMemoryContext, type AgentMessage, type AgentMessageInput, type AgentObservation, type AgentObservationInput, type AgentPath, type AgentStep, type AgentStrategy, type AgentStreamTextOptions, type AnyAgent, type CommonTextOptions, type Compute, type ContextFromAgent, type ContextFromZodContextMapping, type CostFunction, type EventsFromAgent, type EventsFromZodEventMapping, type FromAgent, type GenerateTextOptions, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type MaybePromise, type ObservedState, type ObservedStateFrom, type PromptTemplate, type StreamTextOptions, type TransitionData, type TypesFromAgent, createAgent, fromDecision, fromText, fromTextStream };