@flowdrop/flowdrop 2.0.0-beta.1 → 2.0.0-beta.11
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/CHANGELOG.md +210 -0
- package/MIGRATION-2.0.md +173 -3
- package/README.md +5 -5
- package/dist/adapters/WorkflowAdapter.js +4 -5
- package/dist/adapters/agentspec/AgentSpecAdapter.js +3 -3
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.js +1 -1
- package/dist/chat/commandClassifier.d.ts +11 -0
- package/dist/chat/commandClassifier.js +20 -0
- package/dist/chat/historyBuilder.d.ts +39 -0
- package/dist/chat/historyBuilder.js +82 -0
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/index.js +2 -1
- package/dist/chat/responseParser.js +16 -12
- package/dist/commands/executor.js +51 -26
- package/dist/commands/parser.d.ts +12 -0
- package/dist/commands/parser.js +33 -6
- package/dist/commands/storeIntegration.svelte.js +11 -1
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +547 -386
- package/dist/components/App.svelte.d.ts +16 -8
- package/dist/components/Button.stories.svelte +65 -0
- package/dist/components/Button.stories.svelte.d.ts +19 -0
- package/dist/components/Button.svelte +62 -0
- package/dist/components/Button.svelte.d.ts +24 -0
- package/dist/components/CanvasIconButton.svelte +76 -0
- package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
- package/dist/components/ConfigForm.svelte +194 -565
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +9 -1
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/EditorStatusBar.stories.svelte +44 -0
- package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
- package/dist/components/EditorStatusBar.svelte +99 -0
- package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
- package/dist/components/IconButton.svelte +80 -0
- package/dist/components/IconButton.svelte.d.ts +30 -0
- package/dist/components/Input.svelte +74 -0
- package/dist/components/Input.svelte.d.ts +17 -0
- package/dist/components/LogoWordmark.svelte +113 -0
- package/dist/components/LogoWordmark.svelte.d.ts +26 -0
- package/dist/components/Navbar.svelte +17 -63
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +21 -126
- package/dist/components/NodeSwapPicker.svelte +12 -30
- package/dist/components/PipelineStatus.svelte +6 -1
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.svelte +4 -14
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +0 -5
- package/dist/components/SettingsPanel.svelte +33 -6
- package/dist/components/Textarea.svelte +39 -0
- package/dist/components/Textarea.svelte.d.ts +12 -0
- package/dist/components/ThemeToggle.svelte +15 -94
- package/dist/components/UniversalNode.svelte +36 -4
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +71 -54
- package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
- package/dist/components/chat/AIChatPanel.svelte +49 -8
- package/dist/components/chat/CommandPreview.svelte +10 -1
- package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
- package/dist/components/console/ConsoleInput.svelte +3 -3
- package/dist/components/console/ConsoleOutput.svelte +2 -2
- package/dist/components/form/FormArray.svelte +37 -173
- package/dist/components/form/FormAutocomplete.svelte +18 -15
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +18 -42
- package/dist/components/form/FormFieldLight.svelte +52 -48
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +8 -5
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +280 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +63 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +6 -4
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +27 -6
- package/dist/components/form/FormToggle.svelte.d.ts +5 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/resolveFieldType.d.ts +24 -0
- package/dist/components/form/resolveFieldType.js +55 -0
- package/dist/components/icons/CloseIcon.svelte +6 -0
- package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CommandLineIcon.svelte +15 -0
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuIcon.svelte +4 -0
- package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuOpenIcon.svelte +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
- package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
- package/dist/components/interrupt/InterruptBubble.svelte +11 -12
- package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
- package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
- package/dist/components/layouts/MainLayout.svelte +4 -5
- package/dist/components/nodes/AtomNode.svelte +62 -76
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +117 -164
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +72 -98
- package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
- package/dist/components/nodes/NodeConfigButton.svelte +86 -0
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +76 -85
- package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
- package/dist/components/nodes/SimpleNode.svelte +59 -133
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +110 -164
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +62 -124
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +92 -103
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +132 -191
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +316 -27
- package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
- package/dist/components/playground/ControlPanel.svelte +22 -0
- package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
- package/dist/components/playground/InputCollector.svelte +11 -48
- package/dist/components/playground/PipelineKanbanView.svelte +6 -4
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +20 -3
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +6 -4
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +292 -28
- package/dist/components/playground/Playground.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundApp.svelte +6 -1
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundModal.svelte +5 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundStudio.svelte +7 -6
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
- package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/config/endpoints.d.ts +71 -1
- package/dist/config/endpoints.js +46 -5
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.js +2 -6
- package/dist/display/index.d.ts +6 -1
- package/dist/display/index.js +9 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/form/full.d.ts +2 -1
- package/dist/form/full.js +4 -1
- package/dist/form/index.d.ts +0 -1
- package/dist/form/index.js +3 -2
- package/dist/helpers/workflowEditorHelper.d.ts +4 -2
- package/dist/helpers/workflowEditorHelper.js +8 -8
- package/dist/messages/defaults.d.ts +98 -0
- package/dist/messages/defaults.js +58 -1
- package/dist/messages/index.d.ts +1 -1
- package/dist/messages/index.js +1 -1
- package/dist/openapi/v1/openapi.yaml +35 -23
- package/dist/playground/commands/args.d.ts +32 -0
- package/dist/playground/commands/args.js +50 -0
- package/dist/playground/commands/dispatch.d.ts +143 -0
- package/dist/playground/commands/dispatch.js +162 -0
- package/dist/playground/commands/index.d.ts +14 -0
- package/dist/playground/commands/index.js +10 -0
- package/dist/playground/commands/parser.d.ts +38 -0
- package/dist/playground/commands/parser.js +163 -0
- package/dist/playground/commands/registry.d.ts +42 -0
- package/dist/playground/commands/registry.js +122 -0
- package/dist/playground/commands/suggest.d.ts +37 -0
- package/dist/playground/commands/suggest.js +46 -0
- package/dist/playground/commands/types.d.ts +111 -0
- package/dist/playground/commands/types.js +15 -0
- package/dist/playground/index.d.ts +21 -2
- package/dist/playground/index.js +27 -2
- package/dist/playground/mount.d.ts +19 -5
- package/dist/playground/mount.js +16 -8
- package/dist/playground/runAction.d.ts +48 -0
- package/dist/playground/runAction.js +31 -0
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -39
- package/dist/registry/builtinNodes.js +6 -53
- package/dist/registry/nodeComponentRegistry.d.ts +2 -1
- package/dist/schemas/v1/workflow.schema.json +16 -14
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -2
- package/dist/services/apiVariableService.js +12 -26
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +4 -3
- package/dist/services/chatService.js +13 -18
- package/dist/services/dynamicSchemaService.d.ts +31 -4
- package/dist/services/dynamicSchemaService.js +62 -33
- package/dist/services/historyService.d.ts +30 -8
- package/dist/services/historyService.js +51 -15
- package/dist/services/interruptService.d.ts +7 -6
- package/dist/services/interruptService.js +19 -21
- package/dist/services/pipelineSignalService.d.ts +97 -0
- package/dist/services/pipelineSignalService.js +94 -0
- package/dist/services/playgroundService.d.ts +21 -8
- package/dist/services/playgroundService.js +45 -25
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/workflowLaunchService.d.ts +74 -0
- package/dist/services/workflowLaunchService.js +74 -0
- package/dist/skins/drafter.d.ts +30 -0
- package/dist/skins/drafter.js +198 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/stores/apiContext.d.ts +11 -0
- package/dist/stores/apiContext.js +15 -0
- package/dist/stores/categoriesStore.svelte.js +0 -1
- package/dist/stores/historyStore.svelte.d.ts +17 -3
- package/dist/stores/historyStore.svelte.js +30 -3
- package/dist/stores/instanceContainer.svelte.js +5 -0
- package/dist/stores/playgroundStore.svelte.js +1 -3
- package/dist/stores/settingsStore.svelte.d.ts +13 -0
- package/dist/stores/settingsStore.svelte.js +32 -0
- package/dist/stores/workflowStore.svelte.d.ts +42 -5
- package/dist/stores/workflowStore.svelte.js +109 -32
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +18 -1
- package/dist/svelte-app.js +75 -110
- package/dist/themes/drafter.d.ts +2 -0
- package/dist/themes/drafter.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +8 -2
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/chat.d.ts +5 -1
- package/dist/types/events.d.ts +18 -0
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +84 -29
- package/dist/types/index.js +0 -1
- package/dist/types/settings.d.ts +28 -1
- package/dist/types/settings.js +6 -3
- package/dist/types/skin.d.ts +1 -1
- package/dist/types/theme.d.ts +16 -2
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/canvasSelection.d.ts +25 -0
- package/dist/utils/canvasSelection.js +37 -0
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +23 -0
- package/dist/utils/connections.js +20 -56
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/nodeFormSchema.d.ts +51 -0
- package/dist/utils/nodeFormSchema.js +87 -0
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.js +3 -6
- package/dist/utils/nodeTypes.js +1 -1
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +2 -1
|
@@ -37,8 +37,8 @@ info:
|
|
|
37
37
|
email: shibinkidd@gmail.com
|
|
38
38
|
url: https://www.drupal.org/project/issues/flowdrop?categories=All
|
|
39
39
|
servers:
|
|
40
|
-
- url: http://localhost:
|
|
41
|
-
description: Local development server
|
|
40
|
+
- url: http://localhost:7104/api/flowdrop
|
|
41
|
+
description: Local development server
|
|
42
42
|
- url: https://flowdrop.ddev.site/api/flowdrop
|
|
43
43
|
description: Local Drupal server
|
|
44
44
|
security:
|
|
@@ -250,7 +250,7 @@ paths:
|
|
|
250
250
|
value:
|
|
251
251
|
success: true
|
|
252
252
|
data:
|
|
253
|
-
-
|
|
253
|
+
- node_type_id: openai_chat_executor
|
|
254
254
|
name: OpenAI Chat
|
|
255
255
|
description: Chat completion using OpenAI's GPT models
|
|
256
256
|
category: ai
|
|
@@ -563,7 +563,7 @@ paths:
|
|
|
563
563
|
config:
|
|
564
564
|
placeholder: Enter your question
|
|
565
565
|
metadata:
|
|
566
|
-
|
|
566
|
+
node_type_id: text_input
|
|
567
567
|
name: Text Input
|
|
568
568
|
description: Text input field for user data
|
|
569
569
|
category: inputs
|
|
@@ -2550,10 +2550,12 @@ components:
|
|
|
2550
2550
|
for user-defined input/output handles
|
|
2551
2551
|
- **gateway**: Supports `config.branches` for conditional branching paths
|
|
2552
2552
|
|
|
2553
|
-
##
|
|
2553
|
+
## Port order + exposure
|
|
2554
2554
|
|
|
2555
|
-
|
|
2556
|
-
|
|
2555
|
+
Render order and exposure are controlled per instance via `config.ports`
|
|
2556
|
+
(a per-direction ordered list of `{id, exposed?}`), over each port's metadata
|
|
2557
|
+
`displayOrder` / `exposedByDefault` defaults. Order is cosmetic; a not-exposed
|
|
2558
|
+
port is hidden, not wireable, and not runtime-overridable.
|
|
2557
2559
|
NodeExecutionStatus:
|
|
2558
2560
|
type: string
|
|
2559
2561
|
enum:
|
|
@@ -3213,6 +3215,26 @@ components:
|
|
|
3213
3215
|
example: Parsed JSON response from the HTTP request
|
|
3214
3216
|
defaultValue:
|
|
3215
3217
|
description: Default value used when no connection provides data
|
|
3218
|
+
exposedByDefault:
|
|
3219
|
+
type: boolean
|
|
3220
|
+
default: true
|
|
3221
|
+
description: |
|
|
3222
|
+
Whether the port is exposed when the instance sets no explicit exposure
|
|
3223
|
+
for it (in `data.config.ports`). Defaults to true — a missing override
|
|
3224
|
+
reads as exposed. Reserved ports that ship hidden until an author opts in
|
|
3225
|
+
(e.g. the `error` output) carry false. In v2 exposure is semantic: a
|
|
3226
|
+
not-exposed port is hidden on the canvas, not wireable, and not
|
|
3227
|
+
runtime-overridable.
|
|
3228
|
+
displayOrder:
|
|
3229
|
+
type: integer
|
|
3230
|
+
default: 0
|
|
3231
|
+
description: |
|
|
3232
|
+
Default sort weight for the port's render position, ascending; ties
|
|
3233
|
+
break on declaration order. Author-declared ports default to 0. Reserved
|
|
3234
|
+
ports (the `error` output and `trigger`/`tool` control ports) need no
|
|
3235
|
+
value — the renderer sinks them to the bottom automatically; set this
|
|
3236
|
+
only to override that. Cosmetic only. The instance's `config.ports`
|
|
3237
|
+
order overrides this when present.
|
|
3216
3238
|
schema:
|
|
3217
3239
|
$ref: '#/components/schemas/PortDataSchema'
|
|
3218
3240
|
description: |
|
|
@@ -3449,13 +3471,6 @@ components:
|
|
|
3449
3471
|
|
|
3450
3472
|
Instance-level settings take precedence over type-level defaults.
|
|
3451
3473
|
properties:
|
|
3452
|
-
hideUnconnectedHandles:
|
|
3453
|
-
type: boolean
|
|
3454
|
-
description: |
|
|
3455
|
-
Show/hide unconnected handles (ports) to reduce visual noise.
|
|
3456
|
-
When true, only ports with active connections are displayed.
|
|
3457
|
-
Useful for nodes with many optional ports.
|
|
3458
|
-
example: true
|
|
3459
3474
|
atom:
|
|
3460
3475
|
$ref: '#/components/schemas/AtomUIConfig'
|
|
3461
3476
|
style:
|
|
@@ -3492,7 +3507,6 @@ components:
|
|
|
3492
3507
|
additionalProperties: true
|
|
3493
3508
|
example:
|
|
3494
3509
|
ui:
|
|
3495
|
-
hideUnconnectedHandles: true
|
|
3496
3510
|
style:
|
|
3497
3511
|
opacity: 0.8
|
|
3498
3512
|
agentspec:component_type: llm_node
|
|
@@ -3514,10 +3528,11 @@ components:
|
|
|
3514
3528
|
## Extensions Support
|
|
3515
3529
|
|
|
3516
3530
|
The `extensions` property allows storing UI settings and 3rd party data:
|
|
3517
|
-
- Use `extensions.ui.
|
|
3531
|
+
- Use `extensions.ui.style` for custom per-node styling
|
|
3518
3532
|
- Use namespaced keys for custom integrations (e.g., "myapp:settings")
|
|
3533
|
+
(Port order + exposure live in `config.ports`, not here.)
|
|
3519
3534
|
properties:
|
|
3520
|
-
|
|
3535
|
+
node_type_id:
|
|
3521
3536
|
type: string
|
|
3522
3537
|
description: Node type unique identifier
|
|
3523
3538
|
example: calculator
|
|
@@ -3607,7 +3622,7 @@ components:
|
|
|
3607
3622
|
Default extension properties for all instances of this node type.
|
|
3608
3623
|
Can be overridden at the instance level via WorkflowNode.data.extensions.
|
|
3609
3624
|
required:
|
|
3610
|
-
-
|
|
3625
|
+
- node_type_id
|
|
3611
3626
|
- name
|
|
3612
3627
|
- description
|
|
3613
3628
|
- category
|
|
@@ -3801,7 +3816,7 @@ components:
|
|
|
3801
3816
|
description: Node instance UUID
|
|
3802
3817
|
type:
|
|
3803
3818
|
type: string
|
|
3804
|
-
description: Node type ID (references NodeMetadata.
|
|
3819
|
+
description: Node type ID (references NodeMetadata.node_type_id)
|
|
3805
3820
|
example: calculator
|
|
3806
3821
|
position:
|
|
3807
3822
|
$ref: '#/components/schemas/Position'
|
|
@@ -3825,9 +3840,6 @@ components:
|
|
|
3825
3840
|
error:
|
|
3826
3841
|
type: string
|
|
3827
3842
|
description: Error message if node execution failed
|
|
3828
|
-
nodeId:
|
|
3829
|
-
type: string
|
|
3830
|
-
description: Alternative node ID
|
|
3831
3843
|
executionInfo:
|
|
3832
3844
|
$ref: '#/components/schemas/NodeExecutionInfo'
|
|
3833
3845
|
extensions:
|
|
@@ -3838,8 +3850,8 @@ components:
|
|
|
3838
3850
|
Use for instance-specific UI states or custom data.
|
|
3839
3851
|
|
|
3840
3852
|
Common use cases:
|
|
3841
|
-
- `extensions.ui.hideUnconnectedHandles`: Hide ports without connections
|
|
3842
3853
|
- `extensions.ui.style`: Custom styling for this node instance
|
|
3854
|
+
(Port order + exposure live in `config.ports`, not here.)
|
|
3843
3855
|
required:
|
|
3844
3856
|
- label
|
|
3845
3857
|
- config
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Argument Parsing
|
|
3
|
+
*
|
|
4
|
+
* Turns `/run --topic=foo --tone=formal` into named launch inputs.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately thin: the client does **not** validate these. A workflow's
|
|
7
|
+
* launch inputs are declared server-side as a manifest, and the backend already
|
|
8
|
+
* gates them — unknown keys and wrong types are refused there, with per-input
|
|
9
|
+
* error locators. Re-implementing that here would create a second, divergent
|
|
10
|
+
* schema and reject inputs the backend would have accepted.
|
|
11
|
+
*
|
|
12
|
+
* @module playground/commands/args
|
|
13
|
+
*/
|
|
14
|
+
/** Result of reading flags off a command's argument list. */
|
|
15
|
+
export interface ParsedArgs {
|
|
16
|
+
/** Named `--key=value` inputs, in source order. */
|
|
17
|
+
inputs: Record<string, string>;
|
|
18
|
+
/** Tokens that were not flags, joined — used as free text (e.g. a reason). */
|
|
19
|
+
rest: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse `--key=value` flags out of a token list.
|
|
23
|
+
*
|
|
24
|
+
* Supported forms:
|
|
25
|
+
* - `--key=value` — the canonical form
|
|
26
|
+
* - `--key value` — two tokens, when the next token is not itself a flag
|
|
27
|
+
* - `--key` — a bare flag, treated as the string `"true"`
|
|
28
|
+
*
|
|
29
|
+
* Values arrive already unquoted by the tokenizer, so `--topic="Q2 revenue"`
|
|
30
|
+
* yields `{topic: 'Q2 revenue'}`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseArgs(tokens: readonly string[]): ParsedArgs;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Argument Parsing
|
|
3
|
+
*
|
|
4
|
+
* Turns `/run --topic=foo --tone=formal` into named launch inputs.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately thin: the client does **not** validate these. A workflow's
|
|
7
|
+
* launch inputs are declared server-side as a manifest, and the backend already
|
|
8
|
+
* gates them — unknown keys and wrong types are refused there, with per-input
|
|
9
|
+
* error locators. Re-implementing that here would create a second, divergent
|
|
10
|
+
* schema and reject inputs the backend would have accepted.
|
|
11
|
+
*
|
|
12
|
+
* @module playground/commands/args
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Parse `--key=value` flags out of a token list.
|
|
16
|
+
*
|
|
17
|
+
* Supported forms:
|
|
18
|
+
* - `--key=value` — the canonical form
|
|
19
|
+
* - `--key value` — two tokens, when the next token is not itself a flag
|
|
20
|
+
* - `--key` — a bare flag, treated as the string `"true"`
|
|
21
|
+
*
|
|
22
|
+
* Values arrive already unquoted by the tokenizer, so `--topic="Q2 revenue"`
|
|
23
|
+
* yields `{topic: 'Q2 revenue'}`.
|
|
24
|
+
*/
|
|
25
|
+
export function parseArgs(tokens) {
|
|
26
|
+
const inputs = {};
|
|
27
|
+
const rest = [];
|
|
28
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
29
|
+
const token = tokens[i];
|
|
30
|
+
if (!token.startsWith('--') || token.length <= 2) {
|
|
31
|
+
rest.push(token);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const body = token.slice(2);
|
|
35
|
+
const equals = body.indexOf('=');
|
|
36
|
+
if (equals !== -1) {
|
|
37
|
+
inputs[body.slice(0, equals)] = body.slice(equals + 1);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// `--key value`, unless the next token is another flag.
|
|
41
|
+
const next = tokens[i + 1];
|
|
42
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
43
|
+
inputs[body] = next;
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
inputs[body] = 'true';
|
|
48
|
+
}
|
|
49
|
+
return { inputs, rest: rest.join(' ') };
|
|
50
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground Slash Command Dispatch
|
|
3
|
+
*
|
|
4
|
+
* Maps a parsed command onto the session operations the host already provides.
|
|
5
|
+
*
|
|
6
|
+
* Two invariants live here:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Commands never become session messages.** A `/stop` that posted a user
|
|
9
|
+
* message would pollute the `history` the backend feeds into the next turn's
|
|
10
|
+
* chat input — control traffic would come back as conversation. Feedback is
|
|
11
|
+
* returned to the caller as a {@link CommandOutcome} for transient display.
|
|
12
|
+
* 2. **Availability is checked before dispatch.** An unavailable command
|
|
13
|
+
* reports that it is unsupported rather than calling an endpoint the host
|
|
14
|
+
* never configured.
|
|
15
|
+
*
|
|
16
|
+
* @module playground/commands/dispatch
|
|
17
|
+
*/
|
|
18
|
+
import type { EndpointConfig } from '../../config/endpoints.js';
|
|
19
|
+
import type { SignalResult } from '../../services/pipelineSignalService.js';
|
|
20
|
+
import type { LaunchResult } from '../../services/workflowLaunchService.js';
|
|
21
|
+
import type { CommandLabels, CommandOutcome, SlashCommand } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* The session operations a command can invoke.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately expressed as callbacks rather than a service import: the host
|
|
26
|
+
* component already owns error handling, polling teardown and store updates for
|
|
27
|
+
* each of these, and duplicating that here would create a second, subtly
|
|
28
|
+
* different code path for the same operations.
|
|
29
|
+
*/
|
|
30
|
+
export interface CommandHandlers {
|
|
31
|
+
createSession: () => Promise<void>;
|
|
32
|
+
deleteSession: (sessionId: string) => Promise<void>;
|
|
33
|
+
stopExecution: () => Promise<void>;
|
|
34
|
+
resetSession: () => Promise<void>;
|
|
35
|
+
/** Send an operator signal to a specific pipeline. */
|
|
36
|
+
sendSignal: (signal: 'pause' | 'resume' | 'cancel', pipelineId: string, reason?: string) => Promise<SignalResult>;
|
|
37
|
+
/** Launch a run with named inputs and no chat message. */
|
|
38
|
+
launchWorkflow: (inputs: Record<string, string>) => Promise<LaunchResult>;
|
|
39
|
+
}
|
|
40
|
+
/** Everything dispatch needs to know about the current surface. */
|
|
41
|
+
export interface CommandContext {
|
|
42
|
+
config: EndpointConfig | null;
|
|
43
|
+
/** Current session id, or null when none is active. */
|
|
44
|
+
sessionId: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The pipeline signals should target — the run the user means by "this run".
|
|
47
|
+
*
|
|
48
|
+
* Resolved by the caller from the active run (pinned if the user pinned one,
|
|
49
|
+
* otherwise the latest *main* run). Sub-flow runs must never appear here:
|
|
50
|
+
* pausing what looks like "the run" has to pause the root, not whichever
|
|
51
|
+
* inner iteration happens to be on screen.
|
|
52
|
+
*/
|
|
53
|
+
pipelineId: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* A signal already awaiting acknowledgement on {@link pipelineId}, if any.
|
|
56
|
+
*
|
|
57
|
+
* Backends reject a second signal on the same pipeline, so the client
|
|
58
|
+
* disables rather than firing a request that is guaranteed to be refused —
|
|
59
|
+
* a slash command is exactly the frantic-double-submit surface that guard
|
|
60
|
+
* exists for.
|
|
61
|
+
*/
|
|
62
|
+
pendingSignal?: {
|
|
63
|
+
pipelineId: string;
|
|
64
|
+
signal: string;
|
|
65
|
+
} | null;
|
|
66
|
+
handlers: CommandHandlers;
|
|
67
|
+
/** Message accessors, passed in so this module stays free of Svelte context. */
|
|
68
|
+
messages: CommandMessages;
|
|
69
|
+
}
|
|
70
|
+
/** The message shapes dispatch needs. Mirrors `m().playground.commands`. */
|
|
71
|
+
export interface CommandMessages {
|
|
72
|
+
/** Display text per command, for `/help`. */
|
|
73
|
+
catalog: CommandLabels;
|
|
74
|
+
unavailable: (p: {
|
|
75
|
+
name: string;
|
|
76
|
+
}) => string;
|
|
77
|
+
needsSession: (p: {
|
|
78
|
+
name: string;
|
|
79
|
+
}) => string;
|
|
80
|
+
helpHeading: string;
|
|
81
|
+
helpEscapeHint: string;
|
|
82
|
+
stopped: string;
|
|
83
|
+
reset: string;
|
|
84
|
+
created: string;
|
|
85
|
+
deleted: string;
|
|
86
|
+
failed: (p: {
|
|
87
|
+
name: string;
|
|
88
|
+
error: string;
|
|
89
|
+
}) => string;
|
|
90
|
+
needsRun: (p: {
|
|
91
|
+
name: string;
|
|
92
|
+
}) => string;
|
|
93
|
+
signalPending: (p: {
|
|
94
|
+
signal: string;
|
|
95
|
+
}) => string;
|
|
96
|
+
pauseRequested: string;
|
|
97
|
+
resumeRequested: string;
|
|
98
|
+
cancelRequested: string;
|
|
99
|
+
refusedTerminal: (p: {
|
|
100
|
+
name: string;
|
|
101
|
+
}) => string;
|
|
102
|
+
refusedDuplicate: string;
|
|
103
|
+
refusedNotPaused: string;
|
|
104
|
+
refusedNotFound: string;
|
|
105
|
+
refusedForbidden: (p: {
|
|
106
|
+
name: string;
|
|
107
|
+
}) => string;
|
|
108
|
+
refusedOther: (p: {
|
|
109
|
+
name: string;
|
|
110
|
+
error: string;
|
|
111
|
+
}) => string;
|
|
112
|
+
runStarted: string;
|
|
113
|
+
runInvalidInput: (p: {
|
|
114
|
+
error: string;
|
|
115
|
+
}) => string;
|
|
116
|
+
runInvalidWorkflow: (p: {
|
|
117
|
+
error: string;
|
|
118
|
+
}) => string;
|
|
119
|
+
runInvalidWorkflowDetail: (p: {
|
|
120
|
+
locator: string;
|
|
121
|
+
message: string;
|
|
122
|
+
}) => string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Execute a parsed command.
|
|
126
|
+
*
|
|
127
|
+
* Never throws: every failure is reported as an `error` outcome so the composer
|
|
128
|
+
* has something to show. Callers render the outcome transiently and discard it.
|
|
129
|
+
*/
|
|
130
|
+
export declare function dispatchCommand(command: SlashCommand, context: CommandContext): Promise<CommandOutcome>;
|
|
131
|
+
/**
|
|
132
|
+
* Turn a launch result into user-facing feedback.
|
|
133
|
+
*
|
|
134
|
+
* The two failure modes are kept apart deliberately: bad *inputs* are the
|
|
135
|
+
* caller's to fix, while an invalid stored *workflow* is an authoring problem
|
|
136
|
+
* nothing about the command can address. Collapsing them would send users
|
|
137
|
+
* hunting through their arguments for a fault that is in the graph.
|
|
138
|
+
*
|
|
139
|
+
* Exported because the Run button and auto-run launch through the same service
|
|
140
|
+
* and must report identically — a launch failure should not look like one thing
|
|
141
|
+
* from a command and another from a button.
|
|
142
|
+
*/
|
|
143
|
+
export declare function describeLaunchResult(result: LaunchResult, messages: CommandMessages): CommandOutcome;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground Slash Command Dispatch
|
|
3
|
+
*
|
|
4
|
+
* Maps a parsed command onto the session operations the host already provides.
|
|
5
|
+
*
|
|
6
|
+
* Two invariants live here:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Commands never become session messages.** A `/stop` that posted a user
|
|
9
|
+
* message would pollute the `history` the backend feeds into the next turn's
|
|
10
|
+
* chat input — control traffic would come back as conversation. Feedback is
|
|
11
|
+
* returned to the caller as a {@link CommandOutcome} for transient display.
|
|
12
|
+
* 2. **Availability is checked before dispatch.** An unavailable command
|
|
13
|
+
* reports that it is unsupported rather than calling an endpoint the host
|
|
14
|
+
* never configured.
|
|
15
|
+
*
|
|
16
|
+
* @module playground/commands/dispatch
|
|
17
|
+
*/
|
|
18
|
+
import { getAvailableCommands, isCommandAvailable, SIGNAL_COMMANDS } from './registry.js';
|
|
19
|
+
import { parseArgs } from './args.js';
|
|
20
|
+
/** Commands that cannot do anything useful without an active session. */
|
|
21
|
+
const REQUIRES_SESSION = new Set(['stop', 'reset', 'delete']);
|
|
22
|
+
/**
|
|
23
|
+
* Execute a parsed command.
|
|
24
|
+
*
|
|
25
|
+
* Never throws: every failure is reported as an `error` outcome so the composer
|
|
26
|
+
* has something to show. Callers render the outcome transiently and discard it.
|
|
27
|
+
*/
|
|
28
|
+
export async function dispatchCommand(command, context) {
|
|
29
|
+
const { name } = command;
|
|
30
|
+
const { config, sessionId, pipelineId, pendingSignal, handlers, messages } = context;
|
|
31
|
+
if (!isCommandAvailable(name, config)) {
|
|
32
|
+
return { status: 'error', message: messages.unavailable({ name }) };
|
|
33
|
+
}
|
|
34
|
+
if (REQUIRES_SESSION.has(name) && !sessionId) {
|
|
35
|
+
return { status: 'error', message: messages.needsSession({ name }) };
|
|
36
|
+
}
|
|
37
|
+
if (SIGNAL_COMMANDS.has(name)) {
|
|
38
|
+
if (!pipelineId) {
|
|
39
|
+
return { status: 'error', message: messages.needsRun({ name }) };
|
|
40
|
+
}
|
|
41
|
+
if (pendingSignal && pendingSignal.pipelineId === pipelineId) {
|
|
42
|
+
return {
|
|
43
|
+
status: 'error',
|
|
44
|
+
message: messages.signalPending({ signal: pendingSignal.signal })
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
switch (name) {
|
|
50
|
+
case 'help':
|
|
51
|
+
return { status: 'info', message: buildHelp(config, messages) };
|
|
52
|
+
case 'new':
|
|
53
|
+
await handlers.createSession();
|
|
54
|
+
return { status: 'ok', message: messages.created };
|
|
55
|
+
case 'stop':
|
|
56
|
+
await handlers.stopExecution();
|
|
57
|
+
return { status: 'ok', message: messages.stopped };
|
|
58
|
+
case 'reset':
|
|
59
|
+
await handlers.resetSession();
|
|
60
|
+
return { status: 'ok', message: messages.reset };
|
|
61
|
+
case 'delete':
|
|
62
|
+
await handlers.deleteSession(sessionId);
|
|
63
|
+
return { status: 'ok', message: messages.deleted };
|
|
64
|
+
case 'run': {
|
|
65
|
+
// Named inputs only; loose words are ignored rather than smuggled in as
|
|
66
|
+
// a fake message. `/run` exists precisely to not post one.
|
|
67
|
+
const { inputs } = parseArgs(command.args);
|
|
68
|
+
return describeLaunchResult(await handlers.launchWorkflow(inputs), messages);
|
|
69
|
+
}
|
|
70
|
+
case 'pause':
|
|
71
|
+
case 'resume':
|
|
72
|
+
case 'cancel': {
|
|
73
|
+
const result = await handlers.sendSignal(name, pipelineId, command.args.join(' ') || undefined);
|
|
74
|
+
return describeSignalResult(name, result, messages);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
80
|
+
return { status: 'error', message: messages.failed({ name, error }) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Turn a signal result into user-facing feedback.
|
|
85
|
+
*
|
|
86
|
+
* Accepted signals report **requested**, never done. Backends observe signals
|
|
87
|
+
* cooperatively — the reference implementation polls between job steps, so the
|
|
88
|
+
* step in flight always finishes first. Rendering "Paused" on acceptance would
|
|
89
|
+
* be a lie precisely when the current step is slow, which is exactly when
|
|
90
|
+
* someone reaches for `/pause`. The status poll flips it to the real state.
|
|
91
|
+
*/
|
|
92
|
+
function describeSignalResult(name, result, messages) {
|
|
93
|
+
if (result.status === 'unsupported') {
|
|
94
|
+
return { status: 'error', message: messages.unavailable({ name }) };
|
|
95
|
+
}
|
|
96
|
+
if (result.status === 'accepted') {
|
|
97
|
+
const requested = {
|
|
98
|
+
pause: messages.pauseRequested,
|
|
99
|
+
resume: messages.resumeRequested,
|
|
100
|
+
cancel: messages.cancelRequested
|
|
101
|
+
}[name];
|
|
102
|
+
return { status: 'info', message: requested };
|
|
103
|
+
}
|
|
104
|
+
switch (result.reason) {
|
|
105
|
+
case 'terminal':
|
|
106
|
+
return { status: 'error', message: messages.refusedTerminal({ name }) };
|
|
107
|
+
case 'duplicate':
|
|
108
|
+
return { status: 'error', message: messages.refusedDuplicate };
|
|
109
|
+
case 'not-paused':
|
|
110
|
+
return { status: 'error', message: messages.refusedNotPaused };
|
|
111
|
+
case 'not-found':
|
|
112
|
+
return { status: 'error', message: messages.refusedNotFound };
|
|
113
|
+
case 'forbidden':
|
|
114
|
+
return { status: 'error', message: messages.refusedForbidden({ name }) };
|
|
115
|
+
default:
|
|
116
|
+
return {
|
|
117
|
+
status: 'error',
|
|
118
|
+
message: messages.refusedOther({ name, error: result.message })
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Turn a launch result into user-facing feedback.
|
|
124
|
+
*
|
|
125
|
+
* The two failure modes are kept apart deliberately: bad *inputs* are the
|
|
126
|
+
* caller's to fix, while an invalid stored *workflow* is an authoring problem
|
|
127
|
+
* nothing about the command can address. Collapsing them would send users
|
|
128
|
+
* hunting through their arguments for a fault that is in the graph.
|
|
129
|
+
*
|
|
130
|
+
* Exported because the Run button and auto-run launch through the same service
|
|
131
|
+
* and must report identically — a launch failure should not look like one thing
|
|
132
|
+
* from a command and another from a button.
|
|
133
|
+
*/
|
|
134
|
+
export function describeLaunchResult(result, messages) {
|
|
135
|
+
switch (result.status) {
|
|
136
|
+
case 'launched':
|
|
137
|
+
return { status: 'ok', message: messages.runStarted };
|
|
138
|
+
case 'unsupported':
|
|
139
|
+
return { status: 'error', message: messages.unavailable({ name: 'run' }) };
|
|
140
|
+
case 'invalid-input':
|
|
141
|
+
return { status: 'error', message: messages.runInvalidInput({ error: result.message }) };
|
|
142
|
+
case 'invalid-workflow': {
|
|
143
|
+
// Surface the backend's own per-error locators rather than a summary —
|
|
144
|
+
// they name the offending parameter, which is the only actionable part.
|
|
145
|
+
const details = result.errors.map((e) => messages.runInvalidWorkflowDetail({ locator: e.locator ?? '', message: e.message }));
|
|
146
|
+
return {
|
|
147
|
+
status: 'error',
|
|
148
|
+
message: [messages.runInvalidWorkflow({ error: result.message }), ...details].join('\n')
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
case 'failed':
|
|
152
|
+
return { status: 'error', message: messages.failed({ name: 'run', error: result.message }) };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Build help text from what is actually available here, not from the full
|
|
157
|
+
* command list — so a backend without session reset never advertises `/reset`.
|
|
158
|
+
*/
|
|
159
|
+
function buildHelp(config, messages) {
|
|
160
|
+
const lines = getAvailableCommands(config).map((d) => `${messages.catalog[d.name].usage} — ${messages.catalog[d.name].summary}`);
|
|
161
|
+
return [messages.helpHeading, ...lines, '', messages.helpEscapeHint].join('\n');
|
|
162
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground slash commands — the composer's out-of-band control lane.
|
|
3
|
+
*
|
|
4
|
+
* @module playground/commands
|
|
5
|
+
*/
|
|
6
|
+
export type { SlashCommand, SlashCommandName, SlashCommandDescriptor, CommandLabel, CommandLabels, ParseResult, CommandOutcome } from './types.js';
|
|
7
|
+
export type { CommandHandlers, CommandContext, CommandMessages } from './dispatch.js';
|
|
8
|
+
export type { ParsedArgs } from './args.js';
|
|
9
|
+
export type { CommandSuggestion } from './suggest.js';
|
|
10
|
+
export { suggestCommands } from './suggest.js';
|
|
11
|
+
export { parseSlashCommand, isKnownCommand, isCommandInput, tokenize } from './parser.js';
|
|
12
|
+
export { parseArgs } from './args.js';
|
|
13
|
+
export { dispatchCommand, describeLaunchResult } from './dispatch.js';
|
|
14
|
+
export { COMMAND_NAMES, COMMAND_DESCRIPTORS, SIGNAL_COMMANDS, getDescriptor, getAvailableCommands, isCommandAvailable } from './registry.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground slash commands — the composer's out-of-band control lane.
|
|
3
|
+
*
|
|
4
|
+
* @module playground/commands
|
|
5
|
+
*/
|
|
6
|
+
export { suggestCommands } from './suggest.js';
|
|
7
|
+
export { parseSlashCommand, isKnownCommand, isCommandInput, tokenize } from './parser.js';
|
|
8
|
+
export { parseArgs } from './args.js';
|
|
9
|
+
export { dispatchCommand, describeLaunchResult } from './dispatch.js';
|
|
10
|
+
export { COMMAND_NAMES, COMMAND_DESCRIPTORS, SIGNAL_COMMANDS, getDescriptor, getAvailableCommands, isCommandAvailable } from './registry.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playground Slash Command Parser
|
|
3
|
+
*
|
|
4
|
+
* Pure, synchronous, dependency-free: given composer input, decide whether it
|
|
5
|
+
* is a command, a message, or a typo. No network, no store, no config — so the
|
|
6
|
+
* escape rule and the command grammar can be tested in isolation.
|
|
7
|
+
*
|
|
8
|
+
* @module playground/commands/parser
|
|
9
|
+
*/
|
|
10
|
+
import type { ParseResult, SlashCommandName } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Split a command body into tokens, keeping quoted runs together.
|
|
13
|
+
*
|
|
14
|
+
* Needed because launch arguments carry real prose — `/run --topic="Q2 revenue"`
|
|
15
|
+
* is one argument, not two. Both quote styles are accepted so a value can
|
|
16
|
+
* contain the other, and a quote may open mid-token (`--topic="a b"`) since
|
|
17
|
+
* that is how flags are naturally written.
|
|
18
|
+
*
|
|
19
|
+
* An unterminated quote runs to end of input rather than failing: the user is
|
|
20
|
+
* mid-typing, and refusing to parse would make the composer feel broken.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tokenize(body: string): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse composer input into a command, a message, or an unknown-command error.
|
|
25
|
+
*
|
|
26
|
+
* Unknown commands are **not** forwarded as messages. A typo like `/stpo` must
|
|
27
|
+
* not silently launch a pipeline with `/stpo` as its input — the whole point of
|
|
28
|
+
* the lane is that control traffic and pipeline data never cross.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseSlashCommand(input: string): ParseResult;
|
|
31
|
+
/** Type guard narrowing an arbitrary string to a known command name. */
|
|
32
|
+
export declare function isKnownCommand(name: string): name is SlashCommandName;
|
|
33
|
+
/**
|
|
34
|
+
* True when input would be routed to the control plane rather than sent as a
|
|
35
|
+
* message. Used by the composer to keep commands submittable while a run is in
|
|
36
|
+
* flight (when plain text is not).
|
|
37
|
+
*/
|
|
38
|
+
export declare function isCommandInput(input: string): boolean;
|