@widgetic/workflows 0.2.15 → 0.2.16
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/README.md +117 -3
- package/dist/api/types.d.ts +17 -0
- package/dist/api/workflowsApi.d.ts +12 -1
- package/dist/api/workflowsApi.js +37 -0
- package/dist/assistant/assistantEvents.d.ts +44 -2
- package/dist/assistant/assistantEvents.js +58 -2
- package/dist/assistant/assistantReferences.d.ts +66 -0
- package/dist/assistant/assistantReferences.js +109 -0
- package/dist/assistant/assistantSaveMode.d.ts +15 -3
- package/dist/assistant/assistantSaveMode.js +16 -2
- package/dist/assistant/assistantSeed.d.ts +55 -0
- package/dist/assistant/assistantSeed.js +90 -0
- package/dist/assistant/assistantStream.js +81 -3
- package/dist/assistant/assistantSuggest.d.ts +18 -0
- package/dist/assistant/assistantSuggest.js +21 -0
- package/dist/assistant/assistantTurns.d.ts +75 -0
- package/dist/assistant/assistantTurns.js +56 -0
- package/dist/assistant/attachmentUploads.d.ts +42 -0
- package/dist/assistant/attachmentUploads.js +69 -0
- package/dist/assistant/canvasLink.d.ts +30 -0
- package/dist/assistant/canvasLink.js +51 -0
- package/dist/assistant/compositionMention.d.ts +18 -0
- package/dist/assistant/compositionMention.js +47 -0
- package/dist/assistant/liveData.d.ts +150 -0
- package/dist/assistant/liveData.js +286 -0
- package/dist/assistant/mcpMention.d.ts +20 -0
- package/dist/assistant/mcpMention.js +30 -0
- package/dist/assistant/mentionEntries.d.ts +39 -0
- package/dist/assistant/mentionEntries.js +69 -0
- package/dist/assistant/planFlow.d.ts +26 -0
- package/dist/assistant/planFlow.js +57 -0
- package/dist/assistant/templateDestinations.d.ts +37 -0
- package/dist/assistant/templateDestinations.js +64 -0
- package/dist/assistant/types.d.ts +99 -2
- package/dist/assistant/workflowPlanViewModel.d.ts +13 -2
- package/dist/assistant/workflowPlanViewModel.js +9 -1
- package/dist/components/Workflows.svelte +7 -1
- package/dist/components/WorkflowsWorkspace.svelte +29 -1
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +3 -0
- package/dist/components/assistant/AssistantPlanStepRow.svelte +56 -0
- package/dist/components/assistant/AssistantPlanStepRow.svelte.d.ts +9 -0
- package/dist/components/assistant/CompositionMentionMenu.svelte +135 -0
- package/dist/components/assistant/CompositionMentionMenu.svelte.d.ts +9 -0
- package/dist/components/assistant/DataPreviewCard.svelte +108 -0
- package/dist/components/assistant/DataPreviewCard.svelte.d.ts +7 -0
- package/dist/components/assistant/PlanBindingsBlock.svelte +200 -0
- package/dist/components/assistant/PlanBindingsBlock.svelte.d.ts +14 -0
- package/dist/components/assistant/TemplateProjectCard.svelte +81 -0
- package/dist/components/assistant/TemplateProjectCard.svelte.d.ts +14 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte +1045 -147
- package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +5 -0
- package/dist/components/canvas/CanvasContextMenu.svelte +199 -0
- package/dist/components/canvas/CanvasContextMenu.svelte.d.ts +16 -0
- package/dist/components/canvas/CompositionNodeView.svelte +7 -2
- package/dist/components/canvas/ConditionNodeView.svelte +5 -1
- package/dist/components/canvas/HandlePoint.svelte +25 -3
- package/dist/components/canvas/WorkflowCanvas.svelte +351 -12
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +12 -1
- package/dist/components/canvas/altDragDuplicateController.d.ts +29 -0
- package/dist/components/canvas/altDragDuplicateController.js +92 -0
- package/dist/components/canvas/connectionSnapController.d.ts +29 -0
- package/dist/components/canvas/connectionSnapController.js +182 -0
- package/dist/components/canvas/spacePanController.d.ts +16 -0
- package/dist/components/canvas/spacePanController.js +103 -0
- package/dist/components/editor/EditorCanvasArea.svelte +98 -4
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +5 -0
- package/dist/components/editor/EditorTopBar.svelte +53 -42
- package/dist/components/editor/WorkflowEditor.svelte +74 -41
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
- package/dist/components/editor/WorkflowNameControl.svelte +9 -8
- package/dist/components/editor/WorkflowNameControl.svelte.d.ts +3 -1
- package/dist/components/list/WorkflowList.svelte +34 -20
- package/dist/components/list/WorkflowList.svelte.d.ts +5 -0
- package/dist/components/panel/CompositionForm.svelte +3 -2
- package/dist/components/panel/CompositionPicker.svelte +15 -20
- package/dist/components/panel/CompositionPicker.svelte.d.ts +2 -2
- package/dist/components/panel/CompositionSelect.svelte +4 -4
- package/dist/components/panel/CompositionSelect.svelte.d.ts +2 -2
- package/dist/components/ui/icons.d.ts +8 -0
- package/dist/components/ui/icons.js +24 -1
- package/dist/editor/autoLayout.d.ts +38 -0
- package/dist/editor/autoLayout.js +403 -0
- package/dist/editor/blockClipboard.svelte.d.ts +9 -0
- package/dist/editor/blockClipboard.svelte.js +24 -0
- package/dist/editor/blockCopy.d.ts +39 -0
- package/dist/editor/blockCopy.js +137 -0
- package/dist/editor/canvasMenu.d.ts +45 -0
- package/dist/editor/canvasMenu.js +68 -0
- package/dist/editor/connectionSnap.d.ts +90 -0
- package/dist/editor/connectionSnap.js +98 -0
- package/dist/editor/editorState.svelte.d.ts +122 -13
- package/dist/editor/editorState.svelte.js +262 -22
- package/dist/editor/graphIssues.d.ts +5 -0
- package/dist/editor/graphIssues.js +18 -0
- package/dist/editor/graphModel.d.ts +6 -1
- package/dist/editor/graphModel.js +8 -1
- package/dist/editor/keyHints.d.ts +21 -0
- package/dist/editor/keyHints.js +30 -0
- package/dist/editor/listState.svelte.d.ts +4 -4
- package/dist/editor/staleGuard.d.ts +111 -0
- package/dist/editor/staleGuard.js +279 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +84 -1
- package/dist/i18n/messages.js +97 -4
- package/dist/index.d.ts +1 -0
- package/dist/types/index.d.ts +19 -2
- package/package.json +10 -10
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { filterCompositionOptions } from './compositionMention.js';
|
|
2
|
+
import { filterMcpOptions } from './mcpMention.js';
|
|
3
|
+
/** A key that is different for every row of the menu, whatever the kind. */
|
|
4
|
+
export function mentionEntryKey(entry) {
|
|
5
|
+
return `${entry.kind}:${entry.option.id}`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The rows of the menu for what the person typed after `@`: their Open MCPs first, then the compositions. The Open MCPs go first
|
|
9
|
+
* because there are few of them (a member keeps a handful) and the compositions can be fifty: put after them, the group would be
|
|
10
|
+
* out of sight behind a long scroll. Both groups are filtered by the same words, and a person with no Open MCP sees exactly the
|
|
11
|
+
* menu of compositions they saw before.
|
|
12
|
+
*/
|
|
13
|
+
export function buildMentionEntries(query, compositions, mcps) {
|
|
14
|
+
return [
|
|
15
|
+
...filterMcpOptions(mcps, query).map((option) => ({ kind: 'mcp', option })),
|
|
16
|
+
...filterCompositionOptions(compositions, query).map((option) => ({
|
|
17
|
+
kind: 'composition',
|
|
18
|
+
option
|
|
19
|
+
}))
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
/** Whether the menu has both kinds of row, which is when it labels its two groups (one group needs no label). */
|
|
23
|
+
export function mentionEntriesHaveTwoGroups(entries) {
|
|
24
|
+
return (entries.some((entry) => entry.kind === 'mcp') &&
|
|
25
|
+
entries.some((entry) => entry.kind === 'composition'));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a row can be picked. A composition always can. A server can once it is connected and has a tool switched on: a
|
|
29
|
+
* message that names a server the assistant cannot call would only cost the person a turn to be told so, so the menu shows
|
|
30
|
+
* such a server with the reason (`mentionEntryUnavailableKey`) and does not take the pick.
|
|
31
|
+
*/
|
|
32
|
+
export function mentionEntryIsSelectable(entry) {
|
|
33
|
+
if (entry.kind === 'composition')
|
|
34
|
+
return true;
|
|
35
|
+
return entry.option.status === 'connected' && entry.option.enabledToolCount > 0;
|
|
36
|
+
}
|
|
37
|
+
/** The words that say why a server cannot be picked yet, or `null` for a row that can be picked. */
|
|
38
|
+
export function mentionEntryUnavailableKey(entry) {
|
|
39
|
+
if (mentionEntryIsSelectable(entry) || entry.kind === 'composition')
|
|
40
|
+
return null;
|
|
41
|
+
switch (entry.option.status) {
|
|
42
|
+
case 'needs_sign_in':
|
|
43
|
+
return 'workflows.assistant.mentionMcpNeedsSignIn';
|
|
44
|
+
case 'error':
|
|
45
|
+
return 'workflows.assistant.mentionMcpNotReachable';
|
|
46
|
+
case 'pending':
|
|
47
|
+
return 'workflows.assistant.mentionMcpNotChecked';
|
|
48
|
+
case 'connected':
|
|
49
|
+
return 'workflows.assistant.mentionMcpNoTools';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** The row to highlight when the menu opens or its rows change: the first one that can be picked (0 when none can). */
|
|
53
|
+
export function firstSelectableIndex(entries) {
|
|
54
|
+
const index = entries.findIndex(mentionEntryIsSelectable);
|
|
55
|
+
return index === -1 ? 0 : index;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The row an arrow key moves the highlight to: the next one that can be picked in that direction, going round at the ends. A row
|
|
59
|
+
* that cannot be picked is passed over, so Enter never lands on one. When none can be picked the highlight stays where it is.
|
|
60
|
+
*/
|
|
61
|
+
export function nextSelectableIndex(entries, from, direction) {
|
|
62
|
+
const count = entries.length;
|
|
63
|
+
for (let step = 1; step <= count; step += 1) {
|
|
64
|
+
const index = (((from + direction * step) % count) + count) % count;
|
|
65
|
+
if (mentionEntryIsSelectable(entries[index]))
|
|
66
|
+
return index;
|
|
67
|
+
}
|
|
68
|
+
return from;
|
|
69
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The flow of a plan, as the plan card shows it: the widgets a visitor meets, in order, as chips with an arrow between them
|
|
3
|
+
* (the `flow` of the approve wire has the nodes and the edges, in no particular order).
|
|
4
|
+
*/
|
|
5
|
+
export interface PlanFlowNode {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PlanFlowEdge {
|
|
10
|
+
readonly from: string;
|
|
11
|
+
readonly to: string;
|
|
12
|
+
/** What moves the visitor on ("Presses Get started"); optional. */
|
|
13
|
+
readonly label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PlanFlow {
|
|
16
|
+
readonly nodes: readonly PlanFlowNode[];
|
|
17
|
+
readonly edges: readonly PlanFlowEdge[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The nodes in the order a visitor meets them: the walk starts at the first node nothing leads to and follows the edges
|
|
21
|
+
* (a node with two ways out is followed one way after the other, in the order the edges came). A node the walk does not
|
|
22
|
+
* reach (a loose one, or a loop with no start) comes after the others, in the order it was given. A node is listed once.
|
|
23
|
+
*/
|
|
24
|
+
export declare function orderPlanFlowNodes(flow: PlanFlow): PlanFlowNode[];
|
|
25
|
+
/** What moves a visitor from one step to the next, each phrase once, in the order of the edges ("Presses Get started"). */
|
|
26
|
+
export declare function planFlowTransitionLabels(flow: PlanFlow): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nodes in the order a visitor meets them: the walk starts at the first node nothing leads to and follows the edges
|
|
3
|
+
* (a node with two ways out is followed one way after the other, in the order the edges came). A node the walk does not
|
|
4
|
+
* reach (a loose one, or a loop with no start) comes after the others, in the order it was given. A node is listed once.
|
|
5
|
+
*/
|
|
6
|
+
export function orderPlanFlowNodes(flow) {
|
|
7
|
+
const nodesById = new Map();
|
|
8
|
+
for (const node of flow.nodes) {
|
|
9
|
+
if (!nodesById.has(node.id))
|
|
10
|
+
nodesById.set(node.id, node);
|
|
11
|
+
}
|
|
12
|
+
if (nodesById.size === 0)
|
|
13
|
+
return [];
|
|
14
|
+
const hasIncomingEdge = new Set();
|
|
15
|
+
for (const edge of flow.edges) {
|
|
16
|
+
if (nodesById.has(edge.from) && nodesById.has(edge.to) && edge.from !== edge.to)
|
|
17
|
+
hasIncomingEdge.add(edge.to);
|
|
18
|
+
}
|
|
19
|
+
// The first node nothing leads to is where the visitor starts (a loop with no such node starts at the first node given).
|
|
20
|
+
const firstNode = [...nodesById.values()][0];
|
|
21
|
+
const startingNode = [...nodesById.values()].find((node) => !hasIncomingEdge.has(node.id)) ?? firstNode;
|
|
22
|
+
const visitedIds = new Set();
|
|
23
|
+
const orderedNodes = [];
|
|
24
|
+
const queue = [startingNode.id];
|
|
25
|
+
while (queue.length > 0) {
|
|
26
|
+
const currentId = queue.shift();
|
|
27
|
+
if (visitedIds.has(currentId))
|
|
28
|
+
continue;
|
|
29
|
+
const currentNode = nodesById.get(currentId);
|
|
30
|
+
if (!currentNode)
|
|
31
|
+
continue;
|
|
32
|
+
visitedIds.add(currentId);
|
|
33
|
+
orderedNodes.push(currentNode);
|
|
34
|
+
for (const edge of flow.edges) {
|
|
35
|
+
if (edge.from === currentId && nodesById.has(edge.to) && !visitedIds.has(edge.to))
|
|
36
|
+
queue.push(edge.to);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const node of nodesById.values()) {
|
|
40
|
+
if (!visitedIds.has(node.id))
|
|
41
|
+
orderedNodes.push(node);
|
|
42
|
+
}
|
|
43
|
+
return orderedNodes;
|
|
44
|
+
}
|
|
45
|
+
/** What moves a visitor from one step to the next, each phrase once, in the order of the edges ("Presses Get started"). */
|
|
46
|
+
export function planFlowTransitionLabels(flow) {
|
|
47
|
+
const seenLabels = new Set();
|
|
48
|
+
const transitionLabels = [];
|
|
49
|
+
for (const edge of flow.edges) {
|
|
50
|
+
const label = edge.label?.trim() ?? '';
|
|
51
|
+
if (label === '' || seenLabels.has(label))
|
|
52
|
+
continue;
|
|
53
|
+
seenLabels.add(label);
|
|
54
|
+
transitionLabels.push(label);
|
|
55
|
+
}
|
|
56
|
+
return transitionLabels;
|
|
57
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the copies of a plan's template widgets go.
|
|
3
|
+
*
|
|
4
|
+
* A plan can use widgets from the template library. Approving it copies each of them into one of the person's projects.
|
|
5
|
+
* When they have more than one project they may add widgets to, the gateway sends the list next to the plan card (the
|
|
6
|
+
* `templateDestinations` of the `plan_card` event) and the panel asks which one. The list is not part of the plan: the plan is
|
|
7
|
+
* what is built, and it is signed; the project is the person's choice when they press Create workflow, sent back as
|
|
8
|
+
* `templateProjectId` and checked again by the gateway.
|
|
9
|
+
*
|
|
10
|
+
* Everything the panel needs to decide about that lives here as plain functions, so it is tested without a browser.
|
|
11
|
+
*/
|
|
12
|
+
/** One project the copies can go to. A project with no name has an empty `name`. */
|
|
13
|
+
export interface TemplateDestinationProject {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
}
|
|
17
|
+
/** The projects the person may add widgets to, oldest first, and the one the copies go to when they choose none. */
|
|
18
|
+
export interface TemplateDestinations {
|
|
19
|
+
readonly projects: readonly TemplateDestinationProject[];
|
|
20
|
+
readonly defaultProjectId: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The destinations of a `plan_card` event, or null when there is no choice to show: the event carried none, what it carried
|
|
24
|
+
* is not a list of projects, or fewer than two projects remain (one project is not a choice). The default must be one of the
|
|
25
|
+
* projects; when it is not, the first project is the default, which is where the gateway sends the copies too.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseTemplateDestinations(raw: unknown): TemplateDestinations | null;
|
|
28
|
+
/**
|
|
29
|
+
* The project the copies will go to now: the person's pick while it is still on the list, the default otherwise (nothing picked
|
|
30
|
+
* yet, or the pick belongs to a list the person no longer sees).
|
|
31
|
+
*/
|
|
32
|
+
export declare function effectiveTemplateProjectId(destinations: TemplateDestinations, pickedProjectId: string | null): string;
|
|
33
|
+
/**
|
|
34
|
+
* The `templateProjectId` an approve request carries: the project chosen for a plan that offered the choice, and nothing for a
|
|
35
|
+
* plan that did not (the gateway then files the copies where it always did).
|
|
36
|
+
*/
|
|
37
|
+
export declare function templateProjectIdForApproval(destinations: TemplateDestinations | null | undefined, pickedProjectId: string | null): string | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the copies of a plan's template widgets go.
|
|
3
|
+
*
|
|
4
|
+
* A plan can use widgets from the template library. Approving it copies each of them into one of the person's projects.
|
|
5
|
+
* When they have more than one project they may add widgets to, the gateway sends the list next to the plan card (the
|
|
6
|
+
* `templateDestinations` of the `plan_card` event) and the panel asks which one. The list is not part of the plan: the plan is
|
|
7
|
+
* what is built, and it is signed; the project is the person's choice when they press Create workflow, sent back as
|
|
8
|
+
* `templateProjectId` and checked again by the gateway.
|
|
9
|
+
*
|
|
10
|
+
* Everything the panel needs to decide about that lives here as plain functions, so it is tested without a browser.
|
|
11
|
+
*/
|
|
12
|
+
function readProject(raw) {
|
|
13
|
+
if (typeof raw !== 'object' || raw === null)
|
|
14
|
+
return null;
|
|
15
|
+
const { id, name } = raw;
|
|
16
|
+
if (typeof id !== 'string' || id.trim() === '')
|
|
17
|
+
return null;
|
|
18
|
+
return { id, name: typeof name === 'string' ? name : '' };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The destinations of a `plan_card` event, or null when there is no choice to show: the event carried none, what it carried
|
|
22
|
+
* is not a list of projects, or fewer than two projects remain (one project is not a choice). The default must be one of the
|
|
23
|
+
* projects; when it is not, the first project is the default, which is where the gateway sends the copies too.
|
|
24
|
+
*/
|
|
25
|
+
export function parseTemplateDestinations(raw) {
|
|
26
|
+
if (typeof raw !== 'object' || raw === null)
|
|
27
|
+
return null;
|
|
28
|
+
const { projects: rawProjects, defaultProjectId } = raw;
|
|
29
|
+
if (!Array.isArray(rawProjects))
|
|
30
|
+
return null;
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const projects = [];
|
|
33
|
+
for (const entry of rawProjects) {
|
|
34
|
+
const project = readProject(entry);
|
|
35
|
+
if (!project || seen.has(project.id))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(project.id);
|
|
38
|
+
projects.push(project);
|
|
39
|
+
}
|
|
40
|
+
const first = projects[0];
|
|
41
|
+
if (!first || projects.length < 2)
|
|
42
|
+
return null;
|
|
43
|
+
const defaultId = typeof defaultProjectId === 'string' && seen.has(defaultProjectId) ? defaultProjectId : first.id;
|
|
44
|
+
return { projects, defaultProjectId: defaultId };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The project the copies will go to now: the person's pick while it is still on the list, the default otherwise (nothing picked
|
|
48
|
+
* yet, or the pick belongs to a list the person no longer sees).
|
|
49
|
+
*/
|
|
50
|
+
export function effectiveTemplateProjectId(destinations, pickedProjectId) {
|
|
51
|
+
if (pickedProjectId !== null && destinations.projects.some((project) => project.id === pickedProjectId)) {
|
|
52
|
+
return pickedProjectId;
|
|
53
|
+
}
|
|
54
|
+
return destinations.defaultProjectId;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The `templateProjectId` an approve request carries: the project chosen for a plan that offered the choice, and nothing for a
|
|
58
|
+
* plan that did not (the gateway then files the copies where it always did).
|
|
59
|
+
*/
|
|
60
|
+
export function templateProjectIdForApproval(destinations, pickedProjectId) {
|
|
61
|
+
if (!destinations)
|
|
62
|
+
return undefined;
|
|
63
|
+
return effectiveTemplateProjectId(destinations, pickedProjectId);
|
|
64
|
+
}
|
|
@@ -1,20 +1,85 @@
|
|
|
1
1
|
export type WorkflowAssistantAuthHeaders = Record<string, string> | (() => Promise<Record<string, string>>);
|
|
2
|
+
/**
|
|
3
|
+
* What the panel gives the host while a file goes up. A host that has no use for either can ignore it: the chip then stays
|
|
4
|
+
* empty until the upload ends.
|
|
5
|
+
*/
|
|
6
|
+
export interface AssistantUploadOptions {
|
|
7
|
+
/** Called with the share uploaded, from 0 to 100, as the file goes up: the chip of the file fills as it grows. */
|
|
8
|
+
readonly onProgress?: (percentage: number) => void;
|
|
9
|
+
/** Aborted when the person removes the chip of a file that is still going up. */
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
}
|
|
2
12
|
/** Host wiring for the workflows assistant panel (optional: omitted = no panel). */
|
|
3
13
|
export interface WorkflowAssistantConfig {
|
|
4
14
|
readonly enabled: boolean;
|
|
5
15
|
readonly streamUrl: string;
|
|
6
16
|
readonly approveUrl: string;
|
|
7
17
|
readonly getAuthHeaders: WorkflowAssistantAuthHeaders;
|
|
8
|
-
readonly uploadFileToLibrary: (file: File) => Promise<{
|
|
18
|
+
readonly uploadFileToLibrary: (file: File, options?: AssistantUploadOptions) => Promise<{
|
|
9
19
|
mediaId: string;
|
|
10
20
|
fileName: string;
|
|
11
21
|
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Where the box of the assistant asks how to go on (`POST /workspaces/{workspaceId}/workflows/assistant/suggest`): the answer is a
|
|
24
|
+
* grey suggestion after what the person has typed, which Tab takes and typing on or Esc sends away. Without it the box suggests nothing.
|
|
25
|
+
*/
|
|
26
|
+
readonly suggestUrl?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Where the counts of what happened to the suggestions go (`POST /agent/composer/outcome`): how many were shown, taken, sent away.
|
|
29
|
+
* Counts only, never a word of the box. Without it nothing is reported (the box still suggests).
|
|
30
|
+
*/
|
|
31
|
+
readonly outcomeUrl?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the assistant is drawn as the Scribble Mascot (`@widgetic/brand`), as it is in the chat of the creator. On unless the
|
|
34
|
+
* host says `false`: then the panel draws the chat's plain round avatar, and the mascot's Three.js and WebGL are never started.
|
|
35
|
+
*/
|
|
36
|
+
readonly agentMascot?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Where the canvas of a widget the assistant builds opens, so the person can watch it being built in a tab of its own. Optional:
|
|
39
|
+
* left out, the Widgetic site's own `/canvas/{canvasId}` is used. Return the address for this canvas id.
|
|
40
|
+
*/
|
|
41
|
+
readonly canvasHref?: (canvasId: string) => string;
|
|
42
|
+
}
|
|
43
|
+
import type { CompositionReference } from './compositionMention.js';
|
|
44
|
+
import type { AssistantPlanBindingCard, PlanBindingWire } from './liveData.js';
|
|
45
|
+
import type { McpReference } from './mcpMention.js';
|
|
46
|
+
import type { TemplateDestinations } from './templateDestinations.js';
|
|
47
|
+
/**
|
|
48
|
+
* A composition that a message names with `@`. The assistant is told about it by its id when the message is sent, so a name that
|
|
49
|
+
* several compositions share still points at the one the person meant.
|
|
50
|
+
*/
|
|
51
|
+
export interface WorkflowAssistantCompositionReference {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
/** The name as it is written after the `@` in the message. */
|
|
54
|
+
readonly name: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What the host opens the assistant with: a first message that waits in the composer, not sent. The person reads it, changes it if
|
|
58
|
+
* they want to, and presses Send. (The page that sends people here from an idea, a template or a link is the host.)
|
|
59
|
+
*
|
|
60
|
+
* It belongs to one workflow, the one the host opened for it, and it is read when that workflow is opened. It is put in the composer
|
|
61
|
+
* once, when the assistant of that workflow is drawn for the first time: only if the composer is empty and the workflow has no
|
|
62
|
+
* conversation yet.
|
|
63
|
+
*/
|
|
64
|
+
export interface WorkflowAssistantSeed {
|
|
65
|
+
/** The workflow the seed is for. A seed for another workflow than the one that is open is not used. */
|
|
66
|
+
readonly workflowId: string;
|
|
67
|
+
/** The message to put in the composer. A mention of a composition is written `@Name`. */
|
|
68
|
+
readonly message: string;
|
|
69
|
+
/**
|
|
70
|
+
* The compositions the message names. Each goes along with the message when it is sent, for as long as its `@Name` is still in the
|
|
71
|
+
* text (a person who takes a mention out stops pointing at that composition). At most 10, the most the assistant accepts.
|
|
72
|
+
*/
|
|
73
|
+
readonly compositionReferences?: ReadonlyArray<WorkflowAssistantCompositionReference>;
|
|
12
74
|
}
|
|
13
75
|
export type AssistantMessageRole = 'user' | 'assistant';
|
|
14
76
|
export interface AssistantTranscriptMessage {
|
|
15
77
|
readonly id: string;
|
|
16
78
|
readonly role: AssistantMessageRole;
|
|
17
79
|
readonly text: string;
|
|
80
|
+
readonly compositionReferences?: readonly CompositionReference[];
|
|
81
|
+
/** The Open MCPs the person picked with @ in this message (only the id and the name they saw). */
|
|
82
|
+
readonly mcpReferences?: readonly McpReference[];
|
|
18
83
|
}
|
|
19
84
|
export interface AssistantQuestionCardState {
|
|
20
85
|
readonly cardId: string;
|
|
@@ -32,7 +97,7 @@ export interface AssistantPlanApproveWire {
|
|
|
32
97
|
readonly summary: string;
|
|
33
98
|
readonly steps: ReadonlyArray<{
|
|
34
99
|
id: string;
|
|
35
|
-
kind: 'reuse' | 'create';
|
|
100
|
+
kind: 'reuse' | 'create' | 'template';
|
|
36
101
|
widgetId?: string;
|
|
37
102
|
widgetName: string;
|
|
38
103
|
role: string;
|
|
@@ -57,6 +122,11 @@ export interface AssistantPlanApproveWire {
|
|
|
57
122
|
mediaId: string;
|
|
58
123
|
fileName: string;
|
|
59
124
|
}>;
|
|
125
|
+
/**
|
|
126
|
+
* The live data the plan gives to compositions, as signed: absent when the plan has none. The card shows them
|
|
127
|
+
* (`AssistantPlanCardState.bindings`); this is the part that goes back on approval, untouched.
|
|
128
|
+
*/
|
|
129
|
+
readonly dataBindings?: readonly PlanBindingWire[];
|
|
60
130
|
}
|
|
61
131
|
export interface AssistantPlanCardState {
|
|
62
132
|
readonly planId: string;
|
|
@@ -70,12 +140,39 @@ export interface AssistantPlanCardState {
|
|
|
70
140
|
status: 'waiting' | 'creating' | 'done' | 'failed';
|
|
71
141
|
/** Why a step failed, in a sentence the gateway wrote for the person; empty for the other states. */
|
|
72
142
|
detail?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The canvas the step's widget is built on: opening it shows the build running. Known once the build has started; never set for a
|
|
145
|
+
* widget the person already had, which has no build to watch.
|
|
146
|
+
*/
|
|
147
|
+
canvasId?: string;
|
|
73
148
|
}>;
|
|
74
149
|
readonly credits: number;
|
|
75
150
|
readonly widgetsToCreate: number;
|
|
151
|
+
/**
|
|
152
|
+
* The live data of the plan, one block for each composition that is given a call of an Open MCP. Absent (or empty) for a plan
|
|
153
|
+
* that has none; a plan that has some needs the person's yes (`exposureAcknowledged`) when it is approved.
|
|
154
|
+
*/
|
|
155
|
+
readonly bindings?: ReadonlyArray<AssistantPlanBindingCard>;
|
|
156
|
+
/**
|
|
157
|
+
* Where the copies of the plan's template widgets can go, sent with the plan when the person has more than one project they
|
|
158
|
+
* may add widgets to. Absent when there is nothing to choose; the card of the choice is shown only when it is present. It is
|
|
159
|
+
* not part of the signed plan (`planWire`): the chosen project goes back beside it.
|
|
160
|
+
*/
|
|
161
|
+
readonly templateDestinations?: TemplateDestinations;
|
|
76
162
|
}
|
|
77
163
|
export interface AssistantAttachmentChip {
|
|
164
|
+
/** Names the attachment while it uploads: two files can have the same file name. */
|
|
165
|
+
readonly id: string;
|
|
78
166
|
readonly mediaId: string;
|
|
79
167
|
readonly fileName: string;
|
|
80
168
|
readonly state: 'uploading' | 'ready' | 'error';
|
|
169
|
+
/** The share uploaded, from 0 to 100. The chip draws it as its background only while `state` is 'uploading'. */
|
|
170
|
+
readonly progress: number;
|
|
171
|
+
/**
|
|
172
|
+
* The word that names the file after a `#` in the box (`#hero_banner`), given when the file is attached and never repeated by
|
|
173
|
+
* another file of the draft. The draft only: it is not stored, and a file attached in another chat has its own.
|
|
174
|
+
*/
|
|
175
|
+
readonly label?: string;
|
|
176
|
+
/** A picture of the file, an address the browser made for it (revoked when the chat starts over). Pictures only. */
|
|
177
|
+
readonly previewUrl?: string;
|
|
81
178
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { type PlanBindingWire } from './liveData.js';
|
|
2
|
+
import type { TemplateDestinations } from './templateDestinations.js';
|
|
1
3
|
export interface WorkflowPlanWireStep {
|
|
2
4
|
id: string;
|
|
3
|
-
|
|
5
|
+
/** `template` is a widget of the template library, copied into a project of the person when the plan is approved. */
|
|
6
|
+
kind: 'reuse' | 'create' | 'template';
|
|
4
7
|
widgetId?: string;
|
|
5
8
|
widgetName: string;
|
|
6
9
|
role: string;
|
|
@@ -31,8 +34,16 @@ export interface WorkflowPlanWire {
|
|
|
31
34
|
mediaId: string;
|
|
32
35
|
fileName: string;
|
|
33
36
|
}>;
|
|
37
|
+
/** The live data the plan gives to compositions; left out by the gateway when the plan has none. */
|
|
38
|
+
dataBindings?: PlanBindingWire[];
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The plan card the panel shows. `templateDestinations` (where the plan's template copies can go) comes beside the plan, not in it:
|
|
42
|
+
* the plan is signed and sent back as it came, the destinations are only what the card of the choice shows.
|
|
43
|
+
*/
|
|
44
|
+
export declare function mapWorkflowPlanWireToCard(plan: WorkflowPlanWire, templateDestinations?: TemplateDestinations | null): {
|
|
45
|
+
templateDestinations?: TemplateDestinations | undefined;
|
|
46
|
+
bindings?: import("./liveData.js").AssistantPlanBindingCard[] | undefined;
|
|
36
47
|
planId: string;
|
|
37
48
|
planToken: string;
|
|
38
49
|
planWire: WorkflowPlanWire;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { bindingCardOf } from './liveData.js';
|
|
2
|
+
/**
|
|
3
|
+
* The plan card the panel shows. `templateDestinations` (where the plan's template copies can go) comes beside the plan, not in it:
|
|
4
|
+
* the plan is signed and sent back as it came, the destinations are only what the card of the choice shows.
|
|
5
|
+
*/
|
|
6
|
+
export function mapWorkflowPlanWireToCard(plan, templateDestinations) {
|
|
2
7
|
const planWire = { ...plan, planToken: plan.planToken ?? '' };
|
|
3
8
|
return {
|
|
4
9
|
planId: plan.planId,
|
|
@@ -13,5 +18,8 @@ export function mapWorkflowPlanWireToCard(plan) {
|
|
|
13
18
|
label: `${step.widgetName} — ${step.role}`,
|
|
14
19
|
status: 'waiting',
|
|
15
20
|
})),
|
|
21
|
+
// Left out for a plan with no live data, so a card of an ordinary plan is what it always was.
|
|
22
|
+
...(plan.dataBindings?.length ? { bindings: plan.dataBindings.map(bindingCardOf) } : {}),
|
|
23
|
+
...(templateDestinations ? { templateDestinations } : {}),
|
|
16
24
|
};
|
|
17
25
|
}
|
|
@@ -48,7 +48,10 @@
|
|
|
48
48
|
onError,
|
|
49
49
|
fetchImplementation,
|
|
50
50
|
assistant = null,
|
|
51
|
-
|
|
51
|
+
assistantSeed = null,
|
|
52
|
+
onAssistantSeedApplied,
|
|
53
|
+
initialListPage = null,
|
|
54
|
+
recentSearchesKey = ''
|
|
52
55
|
}: WorkflowsProps = $props();
|
|
53
56
|
|
|
54
57
|
// Why stores and effects below instead of `$derived`: the design system's language (`update()`) and direction
|
|
@@ -110,7 +113,10 @@
|
|
|
110
113
|
{onShowEmbedCode}
|
|
111
114
|
{presence}
|
|
112
115
|
{assistant}
|
|
116
|
+
{assistantSeed}
|
|
117
|
+
{onAssistantSeedApplied}
|
|
113
118
|
{initialListPage}
|
|
119
|
+
{recentSearchesKey}
|
|
114
120
|
onError={reportToPage}
|
|
115
121
|
/>
|
|
116
122
|
{/key}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { untrack } from 'svelte';
|
|
13
13
|
import { provideWorkflowsApi } from '../api/apiContext.js';
|
|
14
14
|
import { createWorkflowsApi } from '../api/workflowsApi.js';
|
|
15
|
+
import { seedForWorkflow } from '../assistant/assistantSeed.js';
|
|
15
16
|
import type { WorkflowsError, WorkflowsProps } from '../types/index.js';
|
|
16
17
|
import { workflowsError } from '../utils/logger.js';
|
|
17
18
|
import WorkflowEditor from './editor/WorkflowEditor.svelte';
|
|
@@ -27,8 +28,11 @@
|
|
|
27
28
|
onShowEmbedCode?: WorkflowsProps['onShowEmbedCode'];
|
|
28
29
|
presence?: WorkflowsProps['presence'];
|
|
29
30
|
assistant?: WorkflowsProps['assistant'];
|
|
31
|
+
assistantSeed?: WorkflowsProps['assistantSeed'];
|
|
32
|
+
onAssistantSeedApplied?: WorkflowsProps['onAssistantSeedApplied'];
|
|
30
33
|
onError: (error: WorkflowsError) => void;
|
|
31
34
|
initialListPage?: WorkflowsProps['initialListPage'];
|
|
35
|
+
recentSearchesKey?: WorkflowsProps['recentSearchesKey'];
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
let {
|
|
@@ -41,8 +45,11 @@
|
|
|
41
45
|
onShowEmbedCode,
|
|
42
46
|
presence = false,
|
|
43
47
|
assistant = null,
|
|
48
|
+
assistantSeed = null,
|
|
49
|
+
onAssistantSeedApplied,
|
|
44
50
|
onError,
|
|
45
|
-
initialListPage = null
|
|
51
|
+
initialListPage = null,
|
|
52
|
+
recentSearchesKey = ''
|
|
46
53
|
}: Props = $props();
|
|
47
54
|
|
|
48
55
|
// The client keeps what it was made with: a new workspace is a new screen, so reading the props once is what is meant.
|
|
@@ -59,6 +66,24 @@
|
|
|
59
66
|
/** The workflow that is open: what the page says, until the person opens or leaves one. */
|
|
60
67
|
let openId = $derived(workflowId ?? null);
|
|
61
68
|
|
|
69
|
+
/**
|
|
70
|
+
* The first message the page left waiting for the assistant, when it is for the workflow that is open (a seed for another one,
|
|
71
|
+
* or one that is not a seed, is nothing). The editor of that workflow reads it once, when it is made (the workflow is opened).
|
|
72
|
+
*/
|
|
73
|
+
let seedOfOpenWorkflow = $derived(seedForWorkflow(assistantSeed, openId));
|
|
74
|
+
|
|
75
|
+
/** The assistant of a workflow took the seed in: the page may stop holding it. A handler of the page that throws changes nothing here. */
|
|
76
|
+
function tellPageSeedWasApplied(appliedWorkflowId: string): void {
|
|
77
|
+
try {
|
|
78
|
+
onAssistantSeedApplied?.(appliedWorkflowId);
|
|
79
|
+
} catch (handlerError) {
|
|
80
|
+
workflowsError(
|
|
81
|
+
`The onAssistantSeedApplied handler of the page threw: ${handlerError instanceof Error ? handlerError.message : String(handlerError)}`,
|
|
82
|
+
handlerError
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
function open(id: string | null): void {
|
|
63
88
|
openId = id;
|
|
64
89
|
try {
|
|
@@ -85,6 +110,8 @@
|
|
|
85
110
|
onshowembedcode={onShowEmbedCode}
|
|
86
111
|
{presence}
|
|
87
112
|
{assistant}
|
|
113
|
+
assistantSeed={seedOfOpenWorkflow}
|
|
114
|
+
onassistantseedapplied={tellPageSeedWasApplied}
|
|
88
115
|
/>
|
|
89
116
|
{/key}
|
|
90
117
|
</div>
|
|
@@ -94,6 +121,7 @@
|
|
|
94
121
|
<WorkflowList
|
|
95
122
|
{workspaceId}
|
|
96
123
|
{initialListPage}
|
|
124
|
+
{recentSearchesKey}
|
|
97
125
|
onopen={(id) => open(id)}
|
|
98
126
|
onerror={onError}
|
|
99
127
|
onshowembedcode={onShowEmbedCode}
|
|
@@ -9,8 +9,11 @@ interface Props {
|
|
|
9
9
|
onShowEmbedCode?: WorkflowsProps['onShowEmbedCode'];
|
|
10
10
|
presence?: WorkflowsProps['presence'];
|
|
11
11
|
assistant?: WorkflowsProps['assistant'];
|
|
12
|
+
assistantSeed?: WorkflowsProps['assistantSeed'];
|
|
13
|
+
onAssistantSeedApplied?: WorkflowsProps['onAssistantSeedApplied'];
|
|
12
14
|
onError: (error: WorkflowsError) => void;
|
|
13
15
|
initialListPage?: WorkflowsProps['initialListPage'];
|
|
16
|
+
recentSearchesKey?: WorkflowsProps['recentSearchesKey'];
|
|
14
17
|
}
|
|
15
18
|
declare const WorkflowsWorkspace: import("svelte").Component<Props, {}, "">;
|
|
16
19
|
type WorkflowsWorkspace = ReturnType<typeof WorkflowsWorkspace>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
One step of the plan card: the widget's name and where its build stands, and, once the build has started, the link that opens the
|
|
3
|
+
widget's canvas in a tab of its own, so the person watches it being built (and can take it over there).
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { canvasLinkOfStep } from '../../assistant/canvasLink.js';
|
|
7
|
+
import type { AssistantPlanCardState, WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
8
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
step: AssistantPlanCardState['steps'][number];
|
|
12
|
+
/** The page's own address for a canvas (`WorkflowAssistantConfig.canvasHref`); left out, the site's `/canvas/{id}`. */
|
|
13
|
+
canvasHref?: WorkflowAssistantConfig['canvasHref'];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { step, canvasHref }: Props = $props();
|
|
17
|
+
|
|
18
|
+
const { t } = useWorkflowsLanguage();
|
|
19
|
+
|
|
20
|
+
/** The link that opens the step's canvas, or null while it has none (not started, a widget the person had, failed). */
|
|
21
|
+
const canvasLink = $derived(canvasLinkOfStep(step, canvasHref));
|
|
22
|
+
|
|
23
|
+
function planStepStatusLabel(status: 'waiting' | 'creating' | 'done' | 'failed'): string {
|
|
24
|
+
switch (status) {
|
|
25
|
+
case 'waiting':
|
|
26
|
+
return $t('workflows.assistant.stepWaiting');
|
|
27
|
+
case 'creating':
|
|
28
|
+
return $t('workflows.assistant.stepCreating');
|
|
29
|
+
case 'done':
|
|
30
|
+
return $t('workflows.assistant.stepDone');
|
|
31
|
+
case 'failed':
|
|
32
|
+
return $t('workflows.assistant.stepFailed');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<li class="flex flex-col gap-0.5 text-caption text-muted-foreground">
|
|
38
|
+
<span>{step.label} — {planStepStatusLabel(step.status)}</span>
|
|
39
|
+
{#if canvasLink}
|
|
40
|
+
<!-- A tab of its own: the build already runs there, and the person can take it over. -->
|
|
41
|
+
<!-- The address is the page's own (`canvasHref`) or the site's `/canvas/{id}`: a package has no router of the app to resolve it with. -->
|
|
42
|
+
<!-- eslint-disable svelte/no-navigation-without-resolve -->
|
|
43
|
+
<a
|
|
44
|
+
class="w-fit text-primary underline underline-offset-2"
|
|
45
|
+
href={canvasLink.href}
|
|
46
|
+
target="_blank"
|
|
47
|
+
rel="noopener noreferrer"
|
|
48
|
+
>
|
|
49
|
+
{$t(canvasLink.labelKey)}
|
|
50
|
+
</a>
|
|
51
|
+
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
|
52
|
+
{/if}
|
|
53
|
+
{#if step.status === 'failed' && step.detail}
|
|
54
|
+
<span class="text-destructive">{step.detail}</span>
|
|
55
|
+
{/if}
|
|
56
|
+
</li>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AssistantPlanCardState, WorkflowAssistantConfig } from '../../assistant/types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
step: AssistantPlanCardState['steps'][number];
|
|
4
|
+
/** The page's own address for a canvas (`WorkflowAssistantConfig.canvasHref`); left out, the site's `/canvas/{id}`. */
|
|
5
|
+
canvasHref?: WorkflowAssistantConfig['canvasHref'];
|
|
6
|
+
}
|
|
7
|
+
declare const AssistantPlanStepRow: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type AssistantPlanStepRow = ReturnType<typeof AssistantPlanStepRow>;
|
|
9
|
+
export default AssistantPlanStepRow;
|