prompt-language-shell 0.8.2 → 0.8.6

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 (45) hide show
  1. package/dist/configuration/io.js +85 -0
  2. package/dist/configuration/messages.js +30 -0
  3. package/dist/configuration/schema.js +167 -0
  4. package/dist/configuration/transformation.js +55 -0
  5. package/dist/configuration/types.js +30 -0
  6. package/dist/configuration/validation.js +52 -0
  7. package/dist/execution/handlers.js +135 -0
  8. package/dist/execution/processing.js +35 -0
  9. package/dist/execution/reducer.js +148 -0
  10. package/dist/execution/types.js +12 -0
  11. package/dist/execution/validation.js +12 -0
  12. package/dist/index.js +1 -1
  13. package/dist/services/anthropic.js +43 -56
  14. package/dist/services/colors.js +2 -1
  15. package/dist/services/components.js +40 -24
  16. package/dist/services/config-labels.js +15 -15
  17. package/dist/services/filesystem.js +114 -0
  18. package/dist/services/loader.js +8 -5
  19. package/dist/services/logger.js +26 -1
  20. package/dist/services/messages.js +32 -1
  21. package/dist/services/parser.js +3 -1
  22. package/dist/services/refinement.js +10 -10
  23. package/dist/services/router.js +43 -27
  24. package/dist/services/skills.js +12 -11
  25. package/dist/services/validator.js +4 -3
  26. package/dist/types/guards.js +4 -6
  27. package/dist/types/handlers.js +1 -0
  28. package/dist/types/schemas.js +103 -0
  29. package/dist/types/types.js +1 -0
  30. package/dist/ui/Answer.js +38 -16
  31. package/dist/ui/Command.js +48 -22
  32. package/dist/ui/Component.js +147 -33
  33. package/dist/ui/Config.js +69 -78
  34. package/dist/ui/Confirm.js +34 -21
  35. package/dist/ui/Execute.js +151 -178
  36. package/dist/ui/Feedback.js +1 -0
  37. package/dist/ui/Introspect.js +54 -25
  38. package/dist/ui/Label.js +1 -1
  39. package/dist/ui/Main.js +10 -6
  40. package/dist/ui/Refinement.js +8 -1
  41. package/dist/ui/Schedule.js +76 -53
  42. package/dist/ui/Validate.js +77 -77
  43. package/dist/ui/Workflow.js +60 -61
  44. package/package.json +3 -2
  45. package/dist/services/configuration.js +0 -409
@@ -0,0 +1,103 @@
1
+ import { z } from 'zod';
2
+ import { Origin, TaskType } from './types.js';
3
+ /**
4
+ * Zod schema for TaskType enum values.
5
+ * Validates that task types match the expected enum values.
6
+ */
7
+ export const TaskTypeSchema = z.enum([
8
+ TaskType.Config,
9
+ TaskType.Schedule,
10
+ TaskType.Execute,
11
+ TaskType.Answer,
12
+ TaskType.Introspect,
13
+ TaskType.Report,
14
+ TaskType.Define,
15
+ TaskType.Ignore,
16
+ TaskType.Select,
17
+ TaskType.Discard,
18
+ TaskType.Group,
19
+ ]);
20
+ /**
21
+ * Zod schema for Origin enum values.
22
+ * Validates capability origin types.
23
+ */
24
+ export const OriginSchema = z.enum([
25
+ Origin.BuiltIn,
26
+ Origin.UserProvided,
27
+ Origin.Indirect,
28
+ ]);
29
+ /**
30
+ * Zod schema for base Task type.
31
+ * Validates task structure with required action and type fields.
32
+ */
33
+ export const TaskSchema = z.object({
34
+ action: z.string().min(1),
35
+ type: TaskTypeSchema,
36
+ params: z.record(z.string(), z.unknown()).optional(),
37
+ config: z.array(z.string()).optional(),
38
+ });
39
+ /**
40
+ * Zod schema for recursive ScheduledTask type.
41
+ * Uses z.lazy for self-referential subtasks validation.
42
+ */
43
+ export const ScheduledTaskSchema = z.object({
44
+ action: z.string().min(1),
45
+ type: TaskTypeSchema,
46
+ params: z.record(z.string(), z.unknown()).optional(),
47
+ config: z.array(z.string()).optional(),
48
+ subtasks: z.lazy(() => ScheduledTaskSchema.array()).optional(),
49
+ });
50
+ /**
51
+ * Zod schema for ExecuteCommand type.
52
+ * Validates shell command execution parameters.
53
+ */
54
+ export const ExecuteCommandSchema = z.object({
55
+ description: z.string().min(1),
56
+ command: z.string().min(1),
57
+ workdir: z.string().optional(),
58
+ timeout: z.number().int().positive().optional(),
59
+ critical: z.boolean().optional(),
60
+ });
61
+ /**
62
+ * Zod schema for Capability type.
63
+ * Validates skill and capability definitions.
64
+ */
65
+ export const CapabilitySchema = z.object({
66
+ name: z.string().min(1),
67
+ description: z.string().min(1),
68
+ origin: OriginSchema,
69
+ isIncomplete: z.boolean().optional(),
70
+ });
71
+ /**
72
+ * Zod schema for ComponentDefinition type.
73
+ * Flexible schema for debug component validation.
74
+ * Accepts both stateless and stateful component structures.
75
+ */
76
+ export const ComponentDefinitionSchema = z.object({
77
+ id: z.string(),
78
+ name: z.string(),
79
+ props: z.record(z.string(), z.unknown()),
80
+ state: z.record(z.string(), z.unknown()).optional(),
81
+ status: z.string().optional(),
82
+ });
83
+ /**
84
+ * Zod schema for CommandResult type.
85
+ * Validates LLM responses from execute, answer, and schedule tools.
86
+ */
87
+ export const CommandResultSchema = z.object({
88
+ message: z.string(),
89
+ summary: z.string().optional(),
90
+ tasks: z.array(ScheduledTaskSchema),
91
+ answer: z.string().optional(),
92
+ commands: z.array(ExecuteCommandSchema).optional(),
93
+ debug: z.array(ComponentDefinitionSchema).optional(),
94
+ });
95
+ /**
96
+ * Zod schema for IntrospectResult type.
97
+ * Validates LLM responses from introspect tool.
98
+ */
99
+ export const IntrospectResultSchema = z.object({
100
+ message: z.string(),
101
+ capabilities: z.array(CapabilitySchema),
102
+ debug: z.array(ComponentDefinitionSchema).optional(),
103
+ });
@@ -38,6 +38,7 @@ export var Origin;
38
38
  export var FeedbackType;
39
39
  (function (FeedbackType) {
40
40
  FeedbackType["Info"] = "info";
41
+ FeedbackType["Warning"] = "warning";
41
42
  FeedbackType["Succeeded"] = "succeeded";
42
43
  FeedbackType["Aborted"] = "aborted";
43
44
  FeedbackType["Failed"] = "failed";
package/dist/ui/Answer.js CHANGED
@@ -1,21 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Box, Text } from 'ink';
4
- import { ComponentStatus } from '../types/components.js';
4
+ import { ComponentStatus, } from '../types/components.js';
5
5
  import { Colors, getTextColor } from '../services/colors.js';
6
- import { addDebugToTimeline } from '../services/components.js';
7
6
  import { useInput } from '../services/keyboard.js';
8
7
  import { formatErrorMessage } from '../services/messages.js';
9
8
  import { withMinimumTime } from '../services/timing.js';
10
9
  import { Spinner } from './Spinner.js';
11
10
  const MINIMUM_PROCESSING_TIME = 400;
12
- export function Answer({ question, state, status, service, handlers, }) {
11
+ export const AnswerView = ({ question, state, status }) => {
12
+ const isActive = status === ComponentStatus.Active;
13
+ const { error, answer } = state;
14
+ const lines = answer ? answer.split('\n') : [];
15
+ return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [isActive && !answer && !error && (_jsxs(Box, { marginLeft: 1, children: [_jsx(Text, { color: getTextColor(isActive), children: "Finding answer. " }), _jsx(Spinner, {})] })), answer && (_jsxs(_Fragment, { children: [_jsx(Box, { marginLeft: 1, marginBottom: 1, children: _jsx(Text, { color: getTextColor(isActive), children: question }) }), _jsx(Box, { flexDirection: "column", paddingLeft: 3, children: lines.map((line, index) => (_jsx(Text, { color: getTextColor(isActive), children: line }, index))) })] })), error && (_jsx(Box, { marginTop: 1, marginLeft: 1, children: _jsxs(Text, { color: Colors.Status.Error, children: ["Error: ", error] }) }))] }));
16
+ };
17
+ /**
18
+ * Answer controller: Fetches answer from LLM
19
+ */
20
+ export function Answer({ question, status, service, requestHandlers, lifecycleHandlers, workflowHandlers, }) {
13
21
  const isActive = status === ComponentStatus.Active;
14
22
  const [error, setError] = useState(null);
15
- const [answer, setAnswer] = useState(state?.answer ?? null);
23
+ const [answer, setAnswer] = useState(null);
16
24
  useInput((input, key) => {
17
25
  if (key.escape && isActive) {
18
- handlers?.onAborted('answer');
26
+ requestHandlers.onAborted('answer');
19
27
  }
20
28
  }, { isActive });
21
29
  useEffect(() => {
@@ -30,26 +38,33 @@ export function Answer({ question, state, status, service, handlers, }) {
30
38
  const result = await withMinimumTime(() => svc.processWithTool(question, 'answer'), MINIMUM_PROCESSING_TIME);
31
39
  if (mounted) {
32
40
  // Add debug components to timeline if present
33
- addDebugToTimeline(result.debug, handlers);
41
+ if (result.debug?.length) {
42
+ workflowHandlers.addToTimeline(...result.debug);
43
+ }
34
44
  // Extract answer from result
35
45
  const answerText = result.answer || '';
36
46
  setAnswer(answerText);
37
- // Update component state so answer persists in timeline
38
- handlers?.updateState({
47
+ // Expose final state
48
+ const finalState = {
39
49
  answer: answerText,
40
- });
50
+ error: null,
51
+ };
52
+ requestHandlers.onCompleted(finalState);
41
53
  // Signal completion
42
- handlers?.completeActive();
54
+ lifecycleHandlers.completeActive();
43
55
  }
44
56
  }
45
57
  catch (err) {
46
58
  if (mounted) {
47
59
  const errorMessage = formatErrorMessage(err);
48
60
  setError(errorMessage);
49
- handlers?.updateState({
61
+ // Expose final state with error
62
+ const finalState = {
50
63
  error: errorMessage,
51
- });
52
- handlers?.onError(errorMessage);
64
+ answer: null,
65
+ };
66
+ requestHandlers.onCompleted(finalState);
67
+ requestHandlers.onError(errorMessage);
53
68
  }
54
69
  }
55
70
  }
@@ -57,7 +72,14 @@ export function Answer({ question, state, status, service, handlers, }) {
57
72
  return () => {
58
73
  mounted = false;
59
74
  };
60
- }, [question, isActive, service, handlers]);
61
- const lines = answer ? answer.split('\n') : [];
62
- return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [isActive && !answer && !error && (_jsxs(Box, { marginLeft: 1, children: [_jsx(Text, { color: getTextColor(isActive), children: "Finding answer. " }), _jsx(Spinner, {})] })), answer && (_jsxs(_Fragment, { children: [_jsx(Box, { marginLeft: 1, marginBottom: 1, children: _jsx(Text, { color: getTextColor(isActive), children: question }) }), _jsx(Box, { flexDirection: "column", paddingLeft: 3, children: lines.map((line, index) => (_jsx(Text, { color: getTextColor(isActive), children: line }, index))) })] })), error && (_jsx(Box, { marginTop: 1, marginLeft: 1, children: _jsxs(Text, { color: Colors.Status.Error, children: ["Error: ", error] }) }))] }));
75
+ }, [
76
+ question,
77
+ isActive,
78
+ service,
79
+ requestHandlers,
80
+ lifecycleHandlers,
81
+ workflowHandlers,
82
+ ]);
83
+ const state = { error, answer };
84
+ return _jsx(AnswerView, { question: question, state: state, status: status });
63
85
  }
@@ -1,10 +1,10 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Box, Text } from 'ink';
4
- import { ComponentStatus } from '../types/components.js';
4
+ import { ComponentStatus, } from '../types/components.js';
5
5
  import { TaskType } from '../types/types.js';
6
6
  import { Colors } from '../services/colors.js';
7
- import { addDebugToTimeline, createScheduleDefinition, } from '../services/components.js';
7
+ import { createScheduleDefinition } from '../services/components.js';
8
8
  import { useInput } from '../services/keyboard.js';
9
9
  import { formatErrorMessage } from '../services/messages.js';
10
10
  import { handleRefinement } from '../services/refinement.js';
@@ -13,12 +13,22 @@ import { ensureMinimumTime } from '../services/timing.js';
13
13
  import { Spinner } from './Spinner.js';
14
14
  import { UserQuery } from './UserQuery.js';
15
15
  const MIN_PROCESSING_TIME = 400; // purely for visual effect
16
- export function Command({ command, state, status, service, handlers, onAborted, }) {
16
+ export const CommandView = ({ command, state, status }) => {
17
17
  const isActive = status === ComponentStatus.Active;
18
- const [error, setError] = useState(state?.error ?? null);
18
+ const { error } = state;
19
+ return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [!isActive ? (_jsxs(UserQuery, { children: ["> pls ", command] })) : (_jsxs(Box, { marginLeft: 1, children: [_jsxs(Text, { color: Colors.Text.Active, children: ["> pls ", command] }), _jsx(Text, { children: " " }), _jsx(Spinner, {})] })), error && (_jsx(Box, { marginTop: 1, marginLeft: 1, children: _jsxs(Text, { color: Colors.Status.Error, children: ["Error: ", error] }) }))] }));
20
+ };
21
+ /**
22
+ * Command controller: Processes and routes command
23
+ */
24
+ export function Command({ command, status, service, requestHandlers, lifecycleHandlers, workflowHandlers, onAborted, }) {
25
+ const isActive = status === ComponentStatus.Active;
26
+ const [error, setError] = useState(null);
27
+ const [message, setMessage] = useState(null);
28
+ const [tasks, setTasks] = useState([]);
19
29
  useInput((_, key) => {
20
30
  if (key.escape && isActive) {
21
- handlers?.onAborted('request');
31
+ requestHandlers.onAborted('request');
22
32
  onAborted?.('request');
23
33
  }
24
34
  }, { isActive });
@@ -51,33 +61,37 @@ export function Command({ command, state, status, service, handlers, onAborted,
51
61
  const debugComponents = allConfig
52
62
  ? [...scheduleDebug, ...(result.debug || [])]
53
63
  : scheduleDebug;
54
- addDebugToTimeline(debugComponents, handlers);
55
- // Save result to state for timeline display
56
- handlers?.updateState({
64
+ if (debugComponents.length > 0) {
65
+ workflowHandlers.addToTimeline(...debugComponents);
66
+ }
67
+ // Update local state
68
+ setMessage(result.message);
69
+ setTasks(result.tasks);
70
+ // Expose final state
71
+ const finalState = {
72
+ error: null,
57
73
  message: result.message,
58
74
  tasks: result.tasks,
59
- });
75
+ };
76
+ requestHandlers.onCompleted(finalState);
60
77
  // Check if tasks contain DEFINE type (variant selection needed)
61
78
  const hasDefineTask = result.tasks.some((task) => task.type === TaskType.Define);
62
- if (!handlers) {
63
- return;
64
- }
65
79
  // Create Schedule definition
66
80
  const scheduleDefinition = createScheduleDefinition(result.message, result.tasks, hasDefineTask
67
81
  ? async (selectedTasks) => {
68
82
  // Refinement flow for DEFINE tasks
69
- await handleRefinement(selectedTasks, svc, command, handlers);
83
+ await handleRefinement(selectedTasks, svc, command, lifecycleHandlers, workflowHandlers, requestHandlers);
70
84
  }
71
85
  : undefined);
72
86
  if (hasDefineTask) {
73
87
  // DEFINE tasks: Move Command to timeline, add Schedule to queue
74
- handlers.completeActive();
75
- handlers.addToQueue(scheduleDefinition);
88
+ lifecycleHandlers.completeActive();
89
+ workflowHandlers.addToQueue(scheduleDefinition);
76
90
  }
77
91
  else {
78
92
  // No DEFINE tasks: Complete Command, then route to Confirm flow
79
- handlers.completeActive();
80
- routeTasksWithConfirm(result.tasks, result.message, svc, command, handlers, false);
93
+ lifecycleHandlers.completeActive();
94
+ routeTasksWithConfirm(result.tasks, result.message, svc, command, lifecycleHandlers, workflowHandlers, requestHandlers, false);
81
95
  }
82
96
  }
83
97
  }
@@ -86,10 +100,14 @@ export function Command({ command, state, status, service, handlers, onAborted,
86
100
  if (mounted) {
87
101
  const errorMessage = formatErrorMessage(err);
88
102
  setError(errorMessage);
89
- handlers?.updateState({
103
+ // Expose final state with error
104
+ const finalState = {
90
105
  error: errorMessage,
91
- });
92
- handlers?.onError(errorMessage);
106
+ message: null,
107
+ tasks: [],
108
+ };
109
+ requestHandlers.onCompleted(finalState);
110
+ requestHandlers.onError(errorMessage);
93
111
  }
94
112
  }
95
113
  }
@@ -97,6 +115,14 @@ export function Command({ command, state, status, service, handlers, onAborted,
97
115
  return () => {
98
116
  mounted = false;
99
117
  };
100
- }, [command, isActive, service, handlers]);
101
- return (_jsxs(Box, { alignSelf: "flex-start", flexDirection: "column", children: [!isActive ? (_jsxs(UserQuery, { children: ["> pls ", command] })) : (_jsxs(Box, { marginLeft: 1, children: [_jsxs(Text, { color: Colors.Text.Active, children: ["> pls ", command] }), _jsx(Text, { children: " " }), _jsx(Spinner, {})] })), error && (_jsx(Box, { marginTop: 1, marginLeft: 1, children: _jsxs(Text, { color: Colors.Status.Error, children: ["Error: ", error] }) }))] }));
118
+ }, [
119
+ command,
120
+ isActive,
121
+ service,
122
+ requestHandlers,
123
+ lifecycleHandlers,
124
+ workflowHandlers,
125
+ ]);
126
+ const state = { error, message, tasks };
127
+ return _jsx(CommandView, { command: command, state: state, status: status });
102
128
  }
@@ -1,49 +1,163 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { memo } from 'react';
3
3
  import { ComponentName } from '../types/types.js';
4
- import { Answer } from './Answer.js';
5
- import { Command } from './Command.js';
6
- import { Config } from './Config.js';
7
- import { Confirm } from './Confirm.js';
4
+ import { Answer, AnswerView } from './Answer.js';
5
+ import { Command, CommandView } from './Command.js';
6
+ import { Config, ConfigView } from './Config.js';
7
+ import { Confirm, ConfirmView } from './Confirm.js';
8
8
  import { Debug } from './Debug.js';
9
- import { Execute } from './Execute.js';
9
+ import { Execute, ExecuteView } from './Execute.js';
10
10
  import { Feedback } from './Feedback.js';
11
- import { Introspect } from './Introspect.js';
11
+ import { Introspect, IntrospectView } from './Introspect.js';
12
12
  import { Message } from './Message.js';
13
- import { Refinement } from './Refinement.js';
13
+ import { Refinement, RefinementView } from './Refinement.js';
14
14
  import { Report } from './Report.js';
15
- import { Schedule } from './Schedule.js';
16
- import { Validate } from './Validate.js';
15
+ import { Schedule, ScheduleView } from './Schedule.js';
16
+ import { Validate, ValidateView } from './Validate.js';
17
17
  import { Welcome } from './Welcome.js';
18
- export const Component = memo(function Component({ def, debug, }) {
18
+ /**
19
+ * Render a simple component (no lifecycle management)
20
+ */
21
+ export const SimpleComponent = memo(function SimpleComponent({ def, }) {
19
22
  switch (def.name) {
23
+ case ComponentName.Welcome: {
24
+ const { props, status } = def;
25
+ return _jsx(Welcome, { ...props, status: status });
26
+ }
27
+ case ComponentName.Feedback: {
28
+ const { props, status } = def;
29
+ return _jsx(Feedback, { ...props, status: status });
30
+ }
31
+ case ComponentName.Message: {
32
+ const { props, status } = def;
33
+ return _jsx(Message, { ...props, status: status });
34
+ }
35
+ case ComponentName.Debug: {
36
+ const { props, status } = def;
37
+ return _jsx(Debug, { ...props, status: status });
38
+ }
39
+ case ComponentName.Report: {
40
+ const { props, status } = def;
41
+ return _jsx(Report, { ...props, status: status });
42
+ }
43
+ default:
44
+ throw new Error(`Unknown simple component: ${def.name}`);
45
+ }
46
+ });
47
+ /**
48
+ * Render a managed component (controller with lifecycle management)
49
+ */
50
+ export const ControllerComponent = memo(function ControllerComponent({ def, debug, requestHandlers, lifecycleHandlers, workflowHandlers, }) {
51
+ switch (def.name) {
52
+ case ComponentName.Config: {
53
+ const { props: { steps, onFinished, onAborted }, status, } = def;
54
+ return (_jsx(Config, { steps: steps, onFinished: onFinished, onAborted: onAborted, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, status: status, debug: debug }));
55
+ }
56
+ case ComponentName.Command: {
57
+ const { props: { command, service, onAborted }, status, } = def;
58
+ return (_jsx(Command, { command: command, service: service, onAborted: onAborted, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, workflowHandlers: workflowHandlers, status: status }));
59
+ }
60
+ case ComponentName.Schedule: {
61
+ const { props: { message, tasks, onSelectionConfirmed }, status, } = def;
62
+ return (_jsx(Schedule, { message: message, tasks: tasks, onSelectionConfirmed: onSelectionConfirmed, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, status: status, debug: debug }));
63
+ }
64
+ case ComponentName.Refinement: {
65
+ const { props: { text, onAborted }, status, } = def;
66
+ return (_jsx(Refinement, { text: text, onAborted: onAborted, requestHandlers: requestHandlers, status: status }));
67
+ }
68
+ case ComponentName.Confirm: {
69
+ const { props: { message, onConfirmed, onCancelled }, status, } = def;
70
+ return (_jsx(Confirm, { message: message, onConfirmed: onConfirmed, onCancelled: onCancelled, requestHandlers: requestHandlers, status: status }));
71
+ }
72
+ case ComponentName.Introspect: {
73
+ const { props: { tasks, service, children }, status, } = def;
74
+ return (_jsx(Introspect, { tasks: tasks, service: service, children: children, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, workflowHandlers: workflowHandlers, status: status, debug: debug }));
75
+ }
76
+ case ComponentName.Answer: {
77
+ const { props: { question, service }, status, } = def;
78
+ return (_jsx(Answer, { question: question, service: service, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, workflowHandlers: workflowHandlers, status: status }));
79
+ }
80
+ case ComponentName.Validate: {
81
+ const { props: { missingConfig, userRequest, service, onError, onValidationComplete, onAborted, }, status, } = def;
82
+ return (_jsx(Validate, { missingConfig: missingConfig, userRequest: userRequest, service: service, onError: onError, onValidationComplete: onValidationComplete, onAborted: onAborted, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, workflowHandlers: workflowHandlers, status: status }));
83
+ }
84
+ case ComponentName.Execute: {
85
+ const { props: { tasks, service }, status, } = def;
86
+ return (_jsx(Execute, { tasks: tasks, service: service, requestHandlers: requestHandlers, lifecycleHandlers: lifecycleHandlers, workflowHandlers: workflowHandlers, status: status }));
87
+ }
88
+ default:
89
+ throw new Error(`Unknown managed component: ${def.name}`);
90
+ }
91
+ });
92
+ /**
93
+ * Render a managed component as View only (no Controller logic)
94
+ */
95
+ export const ViewComponent = memo(function ViewComponent({ def, }) {
96
+ switch (def.name) {
97
+ case ComponentName.Confirm: {
98
+ const { props: { message }, state, status, } = def;
99
+ return _jsx(ConfirmView, { message: message, state: state, status: status });
100
+ }
101
+ case ComponentName.Config: {
102
+ const { props: { steps }, state, status, } = def;
103
+ return _jsx(ConfigView, { steps: steps, state: state, status: status });
104
+ }
105
+ case ComponentName.Schedule: {
106
+ const { props: { message, tasks }, state, status, } = def;
107
+ return (_jsx(ScheduleView, { message: message, tasks: tasks, state: state, status: status }));
108
+ }
109
+ case ComponentName.Execute: {
110
+ const { props: { tasks }, state, status, } = def;
111
+ return _jsx(ExecuteView, { tasks: tasks, state: state, status: status });
112
+ }
113
+ case ComponentName.Answer: {
114
+ const { props: { question }, state, status, } = def;
115
+ return _jsx(AnswerView, { question: question, state: state, status: status });
116
+ }
117
+ case ComponentName.Command: {
118
+ const { props: { command }, state, status, } = def;
119
+ return _jsx(CommandView, { command: command, state: state, status: status });
120
+ }
121
+ case ComponentName.Introspect: {
122
+ const { props: { children }, state, status, } = def;
123
+ return (_jsx(IntrospectView, { state: state, status: status, children: children }));
124
+ }
125
+ case ComponentName.Validate: {
126
+ const { state, status } = def;
127
+ return _jsx(ValidateView, { state: state, status: status });
128
+ }
129
+ case ComponentName.Refinement: {
130
+ const { props: { text }, status, } = def;
131
+ return _jsx(RefinementView, { text: text, status: status });
132
+ }
133
+ default:
134
+ throw new Error(`Unknown managed component: ${def.name}`);
135
+ }
136
+ });
137
+ /**
138
+ * Render a component in the timeline (Views only for managed, as-is for simple)
139
+ */
140
+ export const TimelineComponent = ({ def, }) => {
141
+ switch (def.name) {
142
+ // Simple components render as-is
20
143
  case ComponentName.Welcome:
21
- return _jsx(Welcome, { ...def.props, status: def.status });
22
- case ComponentName.Config:
23
- return (_jsx(Config, { ...def.props, state: def.state, status: def.status, debug: debug }));
24
- case ComponentName.Command:
25
- return _jsx(Command, { ...def.props, state: def.state, status: def.status });
26
- case ComponentName.Schedule:
27
- return (_jsx(Schedule, { ...def.props, state: def.state, status: def.status, debug: debug }));
28
144
  case ComponentName.Feedback:
29
- return _jsx(Feedback, { ...def.props, status: def.status });
30
145
  case ComponentName.Message:
31
- return _jsx(Message, { ...def.props, status: def.status });
32
146
  case ComponentName.Debug:
33
- return _jsx(Debug, { ...def.props, status: def.status });
34
- case ComponentName.Refinement:
35
- return (_jsx(Refinement, { ...def.props, state: def.state, status: def.status }));
36
- case ComponentName.Confirm:
37
- return _jsx(Confirm, { ...def.props, state: def.state, status: def.status });
38
- case ComponentName.Introspect:
39
- return (_jsx(Introspect, { ...def.props, state: def.state, status: def.status, debug: debug }));
40
147
  case ComponentName.Report:
41
- return _jsx(Report, { ...def.props, status: def.status });
42
- case ComponentName.Answer:
43
- return _jsx(Answer, { ...def.props, state: def.state, status: def.status });
44
- case ComponentName.Execute:
45
- return _jsx(Execute, { ...def.props, state: def.state, status: def.status });
148
+ return _jsx(SimpleComponent, { def: def });
149
+ // Managed components render as Views
150
+ case ComponentName.Config:
151
+ case ComponentName.Command:
152
+ case ComponentName.Confirm:
153
+ case ComponentName.Schedule:
154
+ case ComponentName.Refinement:
46
155
  case ComponentName.Validate:
47
- return (_jsx(Validate, { ...def.props, state: def.state, status: def.status, debug: debug }));
156
+ case ComponentName.Execute:
157
+ case ComponentName.Answer:
158
+ case ComponentName.Introspect:
159
+ return _jsx(ViewComponent, { def: def });
160
+ default:
161
+ throw new Error('Unknown component type');
48
162
  }
49
- });
163
+ };