prompt-language-shell 0.5.2 → 0.6.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.
- package/dist/config/ANSWER.md +4 -0
- package/dist/config/CONFIG.md +4 -2
- package/dist/config/PLAN.md +23 -0
- package/dist/config/VALIDATE.md +12 -11
- package/dist/services/anthropic.js +49 -4
- package/dist/services/components.js +56 -66
- package/dist/services/configuration.js +169 -13
- package/dist/services/messages.js +22 -0
- package/dist/services/queue.js +2 -2
- package/dist/services/refinement.js +37 -0
- package/dist/services/task-router.js +141 -0
- package/dist/types/types.js +0 -1
- package/dist/ui/Answer.js +18 -27
- package/dist/ui/Command.js +44 -27
- package/dist/ui/Component.js +23 -50
- package/dist/ui/Config.js +77 -55
- package/dist/ui/Confirm.js +17 -11
- package/dist/ui/Execute.js +66 -45
- package/dist/ui/Feedback.js +1 -1
- package/dist/ui/Introspect.js +26 -23
- package/dist/ui/Main.js +71 -100
- package/dist/ui/Message.js +1 -1
- package/dist/ui/Plan.js +54 -32
- package/dist/ui/Refinement.js +6 -7
- package/dist/ui/Report.js +1 -1
- package/dist/ui/UserQuery.js +6 -0
- package/dist/ui/Validate.js +49 -19
- package/dist/ui/Welcome.js +1 -1
- package/dist/ui/Workflow.js +132 -0
- package/package.json +1 -1
- package/dist/handlers/answer.js +0 -21
- package/dist/handlers/command.js +0 -34
- package/dist/handlers/config.js +0 -88
- package/dist/handlers/execute.js +0 -46
- package/dist/handlers/execution.js +0 -140
- package/dist/handlers/introspect.js +0 -21
- package/dist/handlers/plan.js +0 -79
- package/dist/types/handlers.js +0 -1
- package/dist/ui/AnswerDisplay.js +0 -8
- package/dist/ui/Column.js +0 -7
package/dist/config/ANSWER.md
CHANGED
|
@@ -42,6 +42,8 @@ Provide a direct, helpful answer following these strict formatting rules:
|
|
|
42
42
|
- Break long sentences naturally at phrase boundaries
|
|
43
43
|
- If the answer requires more than 4 lines, prioritize the most essential
|
|
44
44
|
information
|
|
45
|
+
- **Do NOT use citation tags** like `<cite>` or any HTML/XML markup
|
|
46
|
+
- Provide direct answers in plain text only
|
|
45
47
|
|
|
46
48
|
## Examples
|
|
47
49
|
|
|
@@ -112,8 +114,10 @@ They enable cleaner, more reusable component logic.
|
|
|
112
114
|
❌ Including unnecessary details
|
|
113
115
|
❌ Using overly technical jargon without explanation
|
|
114
116
|
❌ Repeating the question in the answer
|
|
117
|
+
❌ Using citation tags like `<cite>` or any HTML/XML markup
|
|
115
118
|
|
|
116
119
|
✅ Direct, concise answers
|
|
117
120
|
✅ Proper line breaks at natural phrase boundaries
|
|
118
121
|
✅ Essential information only
|
|
119
122
|
✅ Clear, accessible language
|
|
123
|
+
✅ Plain text only - no markup tags
|
package/dist/config/CONFIG.md
CHANGED
|
@@ -7,7 +7,8 @@ based on their query.
|
|
|
7
7
|
## Input
|
|
8
8
|
|
|
9
9
|
You will receive:
|
|
10
|
-
- `configStructure`: Object mapping config keys to descriptions (e.g., {"anthropic.key": "Anthropic API key"})
|
|
10
|
+
- `configStructure`: Object mapping config keys to descriptions (e.g., {"anthropic.key": "Anthropic API key", "settings.debug": "Debug mode (optional)"})
|
|
11
|
+
- `configuredKeys`: Array of keys that exist in the user's config file (e.g., ["anthropic.key", "anthropic.model", "settings.debug"])
|
|
11
12
|
- `query`: User's request (e.g., "app", "mode", "anthropic", or empty)
|
|
12
13
|
|
|
13
14
|
## Task
|
|
@@ -18,7 +19,8 @@ Determine which config keys the user wants to configure and return them as tasks
|
|
|
18
19
|
|
|
19
20
|
### Query: "app" or empty/unclear
|
|
20
21
|
- Return all **required** config keys (those needed for the app to work)
|
|
21
|
-
- Also include any
|
|
22
|
+
- Also include any keys marked as "(optional)" that appear in `configuredKeys` (optional settings that exist in user's config file)
|
|
23
|
+
- Also include any keys marked as "(discovered)" (they exist in user's config file but aren't in schema)
|
|
22
24
|
- Required keys: `anthropic.key`, `anthropic.model`
|
|
23
25
|
|
|
24
26
|
### Query: "mode"
|
package/dist/config/PLAN.md
CHANGED
|
@@ -280,6 +280,29 @@ Examples that should be aborted as offensive:
|
|
|
280
280
|
- Requests to create malware or exploit vulnerabilities
|
|
281
281
|
- Requests with offensive, discriminatory, or abusive language
|
|
282
282
|
|
|
283
|
+
**CRITICAL: Distinguishing Questions from Actions**
|
|
284
|
+
|
|
285
|
+
User requests fall into two categories:
|
|
286
|
+
|
|
287
|
+
1. **Information requests (questions)** - Must use question keywords:
|
|
288
|
+
- "explain", "answer", "describe", "tell me", "say", "what is", "what are",
|
|
289
|
+
"how does", "how do", "find", "search", "lookup"
|
|
290
|
+
- Example: "pls explain TypeScript" → answer type
|
|
291
|
+
- Example: "pls what is the weather" → answer type
|
|
292
|
+
|
|
293
|
+
2. **Action requests (commands)** - Must match available skills:
|
|
294
|
+
- Verbs like "test", "deploy", "process", "backup", "sync"
|
|
295
|
+
- If verb matches a skill → use that skill
|
|
296
|
+
- If verb does NOT match any skill → use "ignore" type
|
|
297
|
+
- Example: "pls test" with no test skill → ignore type
|
|
298
|
+
- Example: "pls reverberate" with no reverberate skill → ignore type
|
|
299
|
+
- Example: "pls shut down" with no shutdown skill → ignore type
|
|
300
|
+
|
|
301
|
+
**Critical rule:** Requests using action verbs that don't match question
|
|
302
|
+
keywords AND don't match any available skills should ALWAYS be classified
|
|
303
|
+
as "ignore" type. Do NOT try to infer or create generic execute tasks for
|
|
304
|
+
unrecognized verbs.
|
|
305
|
+
|
|
283
306
|
**For requests with clear intent:**
|
|
284
307
|
|
|
285
308
|
1. **Introspection requests** - Use "introspect" type when request asks about
|
package/dist/config/VALIDATE.md
CHANGED
|
@@ -29,12 +29,12 @@ For each CONFIG task, create a natural language description that:
|
|
|
29
29
|
|
|
30
30
|
## Description Format
|
|
31
31
|
|
|
32
|
-
**Format:** "Brief description" (
|
|
32
|
+
**Format:** "Brief description" (DO NOT include {config.path}!)
|
|
33
33
|
|
|
34
34
|
The description should:
|
|
35
35
|
- Start with what the config value represents (e.g., "Path to...", "URL for...", "Name of...")
|
|
36
36
|
- Be SHORT and direct - no extra details or variant explanations
|
|
37
|
-
-
|
|
37
|
+
- NEVER include the config path in curly brackets like {config.path}
|
|
38
38
|
|
|
39
39
|
## Examples
|
|
40
40
|
|
|
@@ -50,7 +50,7 @@ The description should:
|
|
|
50
50
|
message: ""
|
|
51
51
|
tasks: [
|
|
52
52
|
{
|
|
53
|
-
action: "Path to Alpha repository
|
|
53
|
+
action: "Path to Alpha repository",
|
|
54
54
|
type: "config",
|
|
55
55
|
params: { key: "project.alpha.repo" }
|
|
56
56
|
}
|
|
@@ -69,7 +69,7 @@ tasks: [
|
|
|
69
69
|
message: ""
|
|
70
70
|
tasks: [
|
|
71
71
|
{
|
|
72
|
-
action: "Staging environment URL
|
|
72
|
+
action: "Staging environment URL",
|
|
73
73
|
type: "config",
|
|
74
74
|
params: { key: "env.staging.url" }
|
|
75
75
|
}
|
|
@@ -88,7 +88,7 @@ tasks: [
|
|
|
88
88
|
message: ""
|
|
89
89
|
tasks: [
|
|
90
90
|
{
|
|
91
|
-
action: "Path to Beta workspace
|
|
91
|
+
action: "Path to Beta workspace",
|
|
92
92
|
type: "config",
|
|
93
93
|
params: { key: "workspace.beta.path" }
|
|
94
94
|
}
|
|
@@ -98,10 +98,10 @@ tasks: [
|
|
|
98
98
|
## Guidelines
|
|
99
99
|
|
|
100
100
|
1. **Use skill context**: Read the skill's Description section to understand what the variant represents
|
|
101
|
-
2. **Be specific**: Don't just say "Repository path" - say "Alpha
|
|
102
|
-
3. **Add helpful details**: Include information from the description
|
|
103
|
-
4. **Keep it concise**: One
|
|
104
|
-
5. **
|
|
101
|
+
2. **Be specific**: Don't just say "Repository path" - say "Path to Alpha repository"
|
|
102
|
+
3. **Add helpful details**: Include information from the description when relevant
|
|
103
|
+
4. **Keep it concise**: One brief phrase that clearly explains what's needed
|
|
104
|
+
5. **Never include the path**: Do not append `{config.path}` - it's shown separately in debug mode
|
|
105
105
|
|
|
106
106
|
## Common Config Types
|
|
107
107
|
|
|
@@ -122,7 +122,7 @@ Return a message field (can be empty string) and an array of CONFIG tasks:
|
|
|
122
122
|
message: ""
|
|
123
123
|
tasks: [
|
|
124
124
|
{
|
|
125
|
-
action: "Natural description
|
|
125
|
+
action: "Natural description without config path",
|
|
126
126
|
type: "config",
|
|
127
127
|
params: { key: "config.path" }
|
|
128
128
|
},
|
|
@@ -136,4 +136,5 @@ tasks: [
|
|
|
136
136
|
- All tasks must include params.key with the config path
|
|
137
137
|
- Descriptions should be helpful and contextual, not just technical
|
|
138
138
|
- Use information from Available Skills section to provide context
|
|
139
|
-
- Keep descriptions to one
|
|
139
|
+
- Keep descriptions to one brief phrase (3-6 words)
|
|
140
|
+
- NEVER include the config path in the action/description - it's shown separately
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import { getAvailableConfigStructure, } from './configuration.js';
|
|
2
|
+
import { getAvailableConfigStructure, getConfiguredKeys, } from './configuration.js';
|
|
3
3
|
import { formatSkillsForPrompt, loadSkills } from './skills.js';
|
|
4
4
|
import { toolRegistry } from './tool-registry.js';
|
|
5
|
+
/**
|
|
6
|
+
* Wraps text to ensure no line exceeds the specified width.
|
|
7
|
+
* Breaks at word boundaries to maintain readability.
|
|
8
|
+
*/
|
|
9
|
+
function wrapText(text, maxWidth) {
|
|
10
|
+
const words = text.split(/\s+/);
|
|
11
|
+
const lines = [];
|
|
12
|
+
let currentLine = '';
|
|
13
|
+
for (const word of words) {
|
|
14
|
+
// If adding this word would exceed max width, start a new line
|
|
15
|
+
if (currentLine.length > 0 &&
|
|
16
|
+
currentLine.length + 1 + word.length > maxWidth) {
|
|
17
|
+
lines.push(currentLine);
|
|
18
|
+
currentLine = word;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
currentLine = currentLine.length > 0 ? `${currentLine} ${word}` : word;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Add the last line if not empty
|
|
25
|
+
if (currentLine.length > 0) {
|
|
26
|
+
lines.push(currentLine);
|
|
27
|
+
}
|
|
28
|
+
return lines.join('\n');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Removes citation tags and other markup from answer text.
|
|
32
|
+
* Web search responses may include <cite> tags that should be stripped.
|
|
33
|
+
* Also wraps text to ensure lines don't exceed 80 characters.
|
|
34
|
+
*/
|
|
35
|
+
export function cleanAnswerText(text) {
|
|
36
|
+
// Remove citation tags like <cite index="1-1">content</cite>
|
|
37
|
+
// Replace with just the content
|
|
38
|
+
let cleaned = text.replace(/<cite[^>]*>(.*?)<\/cite>/g, '$1');
|
|
39
|
+
// Remove any other XML/HTML tags that might appear
|
|
40
|
+
cleaned = cleaned.replace(/<[^>]+>/g, '');
|
|
41
|
+
// Normalize whitespace, converting all whitespace to single spaces
|
|
42
|
+
cleaned = cleaned.replace(/\s+/g, ' ').trim();
|
|
43
|
+
// Wrap text to 80 characters per line
|
|
44
|
+
cleaned = wrapText(cleaned, 80);
|
|
45
|
+
return cleaned;
|
|
46
|
+
}
|
|
5
47
|
export class AnthropicService {
|
|
6
48
|
client;
|
|
7
49
|
model;
|
|
@@ -27,9 +69,12 @@ export class AnthropicService {
|
|
|
27
69
|
// Add config structure for config tool only
|
|
28
70
|
if (toolName === 'config') {
|
|
29
71
|
const configStructure = getAvailableConfigStructure();
|
|
72
|
+
const configuredKeys = getConfiguredKeys();
|
|
30
73
|
const configSection = '\n\n## Available Configuration\n\n' +
|
|
31
74
|
'Config structure (key: description):\n' +
|
|
32
|
-
JSON.stringify(configStructure, null, 2)
|
|
75
|
+
JSON.stringify(configStructure, null, 2) +
|
|
76
|
+
'\n\nConfigured keys (keys that exist in config file):\n' +
|
|
77
|
+
JSON.stringify(configuredKeys, null, 2);
|
|
33
78
|
systemPrompt += configSection;
|
|
34
79
|
}
|
|
35
80
|
// Build tools array - add web search for answer tool
|
|
@@ -67,7 +112,7 @@ export class AnthropicService {
|
|
|
67
112
|
return {
|
|
68
113
|
message: '',
|
|
69
114
|
tasks: [],
|
|
70
|
-
answer: textContent.text,
|
|
115
|
+
answer: cleanAnswerText(textContent.text),
|
|
71
116
|
};
|
|
72
117
|
}
|
|
73
118
|
}
|
|
@@ -111,7 +156,7 @@ export class AnthropicService {
|
|
|
111
156
|
return {
|
|
112
157
|
message: '',
|
|
113
158
|
tasks: [],
|
|
114
|
-
answer: input.answer,
|
|
159
|
+
answer: cleanAnswerText(input.answer),
|
|
115
160
|
};
|
|
116
161
|
}
|
|
117
162
|
// Handle plan and introspect tool responses
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
3
|
import { ComponentName } from '../types/types.js';
|
|
3
|
-
import {
|
|
4
|
+
import { parse as parseYaml } from 'yaml';
|
|
5
|
+
import { getConfigPath, getConfigSchema, loadConfig, } from './configuration.js';
|
|
4
6
|
import { getConfirmationMessage } from './messages.js';
|
|
5
7
|
import { StepType } from '../ui/Config.js';
|
|
6
|
-
export function markAsDone(component) {
|
|
7
|
-
return { ...component, state: { ...component.state, done: true } };
|
|
8
|
-
}
|
|
9
8
|
export function createWelcomeDefinition(app) {
|
|
10
9
|
return {
|
|
11
10
|
id: randomUUID(),
|
|
@@ -58,27 +57,43 @@ function getValidator(definition) {
|
|
|
58
57
|
export function createConfigStepsFromSchema(keys) {
|
|
59
58
|
const schema = getConfigSchema();
|
|
60
59
|
let currentConfig = null;
|
|
60
|
+
let rawConfig = null;
|
|
61
|
+
// Load validated config (may fail if config has validation errors)
|
|
61
62
|
try {
|
|
62
63
|
currentConfig = loadConfig();
|
|
63
64
|
}
|
|
64
65
|
catch {
|
|
65
|
-
// Config doesn't exist
|
|
66
|
+
// Config doesn't exist or has validation errors, use defaults
|
|
67
|
+
}
|
|
68
|
+
// Load raw config separately (for discovered keys not in schema)
|
|
69
|
+
try {
|
|
70
|
+
const configFile = getConfigPath();
|
|
71
|
+
if (existsSync(configFile)) {
|
|
72
|
+
const content = readFileSync(configFile, 'utf-8');
|
|
73
|
+
rawConfig = parseYaml(content);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Config file doesn't exist or can't be parsed
|
|
66
78
|
}
|
|
67
79
|
return keys.map((key) => {
|
|
68
80
|
// Check if key is in schema (built-in config)
|
|
69
81
|
if (!(key in schema)) {
|
|
70
|
-
// Key is not in schema - it's from a skill
|
|
71
|
-
// Create a simple text step with
|
|
82
|
+
// Key is not in schema - it's from a skill or discovered config
|
|
83
|
+
// Create a simple text step with the full path as description
|
|
72
84
|
const keyParts = key.split('.');
|
|
73
85
|
const shortKey = keyParts[keyParts.length - 1];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
// Load current value if it exists (use rawConfig since discovered keys aren't in validated config)
|
|
87
|
+
const currentValue = getConfigValue(rawConfig, key);
|
|
88
|
+
const value = currentValue !== undefined && typeof currentValue === 'string'
|
|
89
|
+
? currentValue
|
|
90
|
+
: null;
|
|
77
91
|
return {
|
|
78
|
-
description:
|
|
92
|
+
description: key,
|
|
79
93
|
key: shortKey,
|
|
94
|
+
path: key,
|
|
80
95
|
type: StepType.Text,
|
|
81
|
-
value
|
|
96
|
+
value,
|
|
82
97
|
validate: () => true, // Accept any string for now
|
|
83
98
|
};
|
|
84
99
|
}
|
|
@@ -98,6 +113,7 @@ export function createConfigStepsFromSchema(keys) {
|
|
|
98
113
|
return {
|
|
99
114
|
description: definition.description,
|
|
100
115
|
key: shortKey,
|
|
116
|
+
path: key,
|
|
101
117
|
type: StepType.Text,
|
|
102
118
|
value,
|
|
103
119
|
validate: getValidator(definition),
|
|
@@ -112,6 +128,7 @@ export function createConfigStepsFromSchema(keys) {
|
|
|
112
128
|
return {
|
|
113
129
|
description: definition.description,
|
|
114
130
|
key: shortKey,
|
|
131
|
+
path: key,
|
|
115
132
|
type: StepType.Text,
|
|
116
133
|
value,
|
|
117
134
|
validate: getValidator(definition),
|
|
@@ -127,6 +144,7 @@ export function createConfigStepsFromSchema(keys) {
|
|
|
127
144
|
return {
|
|
128
145
|
description: definition.description,
|
|
129
146
|
key: shortKey,
|
|
147
|
+
path: key,
|
|
130
148
|
type: StepType.Selection,
|
|
131
149
|
options: definition.values.map((value) => ({
|
|
132
150
|
label: value,
|
|
@@ -143,10 +161,11 @@ export function createConfigStepsFromSchema(keys) {
|
|
|
143
161
|
return {
|
|
144
162
|
description: definition.description,
|
|
145
163
|
key: shortKey,
|
|
164
|
+
path: key,
|
|
146
165
|
type: StepType.Selection,
|
|
147
166
|
options: [
|
|
148
|
-
{ label: '
|
|
149
|
-
{ label: '
|
|
167
|
+
{ label: 'yes', value: 'true' },
|
|
168
|
+
{ label: 'no', value: 'false' },
|
|
150
169
|
],
|
|
151
170
|
defaultIndex: currentBool !== undefined ? (currentBool ? 0 : 1) : 0,
|
|
152
171
|
validate: getValidator(definition),
|
|
@@ -159,7 +178,7 @@ export function createConfigDefinition(onFinished, onAborted) {
|
|
|
159
178
|
return {
|
|
160
179
|
id: randomUUID(),
|
|
161
180
|
name: ComponentName.Config,
|
|
162
|
-
state: {
|
|
181
|
+
state: {},
|
|
163
182
|
props: {
|
|
164
183
|
steps: createConfigSteps(),
|
|
165
184
|
onFinished,
|
|
@@ -174,7 +193,7 @@ export function createConfigDefinitionWithKeys(keys, onFinished, onAborted) {
|
|
|
174
193
|
return {
|
|
175
194
|
id: randomUUID(),
|
|
176
195
|
name: ComponentName.Config,
|
|
177
|
-
state: {
|
|
196
|
+
state: {},
|
|
178
197
|
props: {
|
|
179
198
|
steps: createConfigStepsFromSchema(keys),
|
|
180
199
|
onFinished,
|
|
@@ -182,29 +201,22 @@ export function createConfigDefinitionWithKeys(keys, onFinished, onAborted) {
|
|
|
182
201
|
},
|
|
183
202
|
};
|
|
184
203
|
}
|
|
185
|
-
export function createCommandDefinition(command, service
|
|
204
|
+
export function createCommandDefinition(command, service) {
|
|
186
205
|
return {
|
|
187
206
|
id: randomUUID(),
|
|
188
207
|
name: ComponentName.Command,
|
|
189
|
-
state: {
|
|
190
|
-
done: false,
|
|
191
|
-
isLoading: true,
|
|
192
|
-
},
|
|
208
|
+
state: {},
|
|
193
209
|
props: {
|
|
194
210
|
command,
|
|
195
211
|
service,
|
|
196
|
-
onError,
|
|
197
|
-
onComplete,
|
|
198
|
-
onAborted,
|
|
199
212
|
},
|
|
200
213
|
};
|
|
201
214
|
}
|
|
202
|
-
export function createPlanDefinition(message, tasks,
|
|
215
|
+
export function createPlanDefinition(message, tasks, onSelectionConfirmed) {
|
|
203
216
|
return {
|
|
204
217
|
id: randomUUID(),
|
|
205
218
|
name: ComponentName.Plan,
|
|
206
219
|
state: {
|
|
207
|
-
done: false,
|
|
208
220
|
highlightedIndex: null,
|
|
209
221
|
currentDefineGroupIndex: 0,
|
|
210
222
|
completedSelections: [],
|
|
@@ -213,7 +225,6 @@ export function createPlanDefinition(message, tasks, onAborted, onSelectionConfi
|
|
|
213
225
|
message,
|
|
214
226
|
tasks,
|
|
215
227
|
onSelectionConfirmed,
|
|
216
|
-
onAborted,
|
|
217
228
|
},
|
|
218
229
|
};
|
|
219
230
|
}
|
|
@@ -240,7 +251,7 @@ export function createRefinement(text, onAborted) {
|
|
|
240
251
|
return {
|
|
241
252
|
id: randomUUID(),
|
|
242
253
|
name: ComponentName.Refinement,
|
|
243
|
-
state: {
|
|
254
|
+
state: {},
|
|
244
255
|
props: {
|
|
245
256
|
text,
|
|
246
257
|
onAborted,
|
|
@@ -251,7 +262,7 @@ export function createConfirmDefinition(onConfirmed, onCancelled) {
|
|
|
251
262
|
return {
|
|
252
263
|
id: randomUUID(),
|
|
253
264
|
name: ComponentName.Confirm,
|
|
254
|
-
state: {
|
|
265
|
+
state: {},
|
|
255
266
|
props: {
|
|
256
267
|
message: getConfirmationMessage(),
|
|
257
268
|
onConfirmed,
|
|
@@ -259,20 +270,14 @@ export function createConfirmDefinition(onConfirmed, onCancelled) {
|
|
|
259
270
|
},
|
|
260
271
|
};
|
|
261
272
|
}
|
|
262
|
-
export function createIntrospectDefinition(tasks, service
|
|
273
|
+
export function createIntrospectDefinition(tasks, service) {
|
|
263
274
|
return {
|
|
264
275
|
id: randomUUID(),
|
|
265
276
|
name: ComponentName.Introspect,
|
|
266
|
-
state: {
|
|
267
|
-
done: false,
|
|
268
|
-
isLoading: true,
|
|
269
|
-
},
|
|
277
|
+
state: {},
|
|
270
278
|
props: {
|
|
271
279
|
tasks,
|
|
272
280
|
service,
|
|
273
|
-
onError,
|
|
274
|
-
onComplete,
|
|
275
|
-
onAborted,
|
|
276
281
|
},
|
|
277
282
|
};
|
|
278
283
|
}
|
|
@@ -286,49 +291,37 @@ export function createReportDefinition(message, capabilities) {
|
|
|
286
291
|
},
|
|
287
292
|
};
|
|
288
293
|
}
|
|
289
|
-
export function createAnswerDefinition(question, service
|
|
294
|
+
export function createAnswerDefinition(question, service) {
|
|
290
295
|
return {
|
|
291
296
|
id: randomUUID(),
|
|
292
297
|
name: ComponentName.Answer,
|
|
293
|
-
state: {
|
|
294
|
-
done: false,
|
|
295
|
-
isLoading: true,
|
|
296
|
-
},
|
|
298
|
+
state: {},
|
|
297
299
|
props: {
|
|
298
300
|
question,
|
|
299
301
|
service,
|
|
300
|
-
onError,
|
|
301
|
-
onComplete,
|
|
302
|
-
onAborted,
|
|
303
|
-
},
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
export function createAnswerDisplayDefinition(answer) {
|
|
307
|
-
return {
|
|
308
|
-
id: randomUUID(),
|
|
309
|
-
name: ComponentName.AnswerDisplay,
|
|
310
|
-
props: {
|
|
311
|
-
answer,
|
|
312
302
|
},
|
|
313
303
|
};
|
|
314
304
|
}
|
|
315
305
|
export function isStateless(component) {
|
|
316
306
|
return !('state' in component);
|
|
317
307
|
}
|
|
318
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Mark a component as done. Returns the component to be added to timeline.
|
|
310
|
+
* Components use handlers.updateState to save their state before completion,
|
|
311
|
+
* so this function simply returns the component as-is.
|
|
312
|
+
*/
|
|
313
|
+
export function markAsDone(component) {
|
|
314
|
+
// State already updated via handlers.updateState
|
|
315
|
+
return component;
|
|
316
|
+
}
|
|
317
|
+
export function createExecuteDefinition(tasks, service) {
|
|
319
318
|
return {
|
|
320
319
|
id: randomUUID(),
|
|
321
320
|
name: ComponentName.Execute,
|
|
322
|
-
state: {
|
|
323
|
-
done: false,
|
|
324
|
-
isLoading: true,
|
|
325
|
-
},
|
|
321
|
+
state: {},
|
|
326
322
|
props: {
|
|
327
323
|
tasks,
|
|
328
324
|
service,
|
|
329
|
-
onError,
|
|
330
|
-
onComplete,
|
|
331
|
-
onAborted,
|
|
332
325
|
},
|
|
333
326
|
};
|
|
334
327
|
}
|
|
@@ -336,10 +329,7 @@ export function createValidateDefinition(missingConfig, userRequest, service, on
|
|
|
336
329
|
return {
|
|
337
330
|
id: randomUUID(),
|
|
338
331
|
name: ComponentName.Validate,
|
|
339
|
-
state: {
|
|
340
|
-
done: false,
|
|
341
|
-
isLoading: true,
|
|
342
|
-
},
|
|
332
|
+
state: {},
|
|
343
333
|
props: {
|
|
344
334
|
missingConfig,
|
|
345
335
|
userRequest,
|