@widgetic/workflows 0.2.15 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +117 -3
  2. package/dist/api/types.d.ts +17 -0
  3. package/dist/api/workflowsApi.d.ts +12 -1
  4. package/dist/api/workflowsApi.js +37 -0
  5. package/dist/assistant/assistantEvents.d.ts +44 -2
  6. package/dist/assistant/assistantEvents.js +58 -2
  7. package/dist/assistant/assistantReferences.d.ts +66 -0
  8. package/dist/assistant/assistantReferences.js +109 -0
  9. package/dist/assistant/assistantSaveMode.d.ts +15 -3
  10. package/dist/assistant/assistantSaveMode.js +16 -2
  11. package/dist/assistant/assistantSeed.d.ts +55 -0
  12. package/dist/assistant/assistantSeed.js +90 -0
  13. package/dist/assistant/assistantStream.js +81 -3
  14. package/dist/assistant/assistantSuggest.d.ts +18 -0
  15. package/dist/assistant/assistantSuggest.js +21 -0
  16. package/dist/assistant/assistantTurns.d.ts +75 -0
  17. package/dist/assistant/assistantTurns.js +56 -0
  18. package/dist/assistant/attachmentUploads.d.ts +42 -0
  19. package/dist/assistant/attachmentUploads.js +69 -0
  20. package/dist/assistant/canvasLink.d.ts +30 -0
  21. package/dist/assistant/canvasLink.js +51 -0
  22. package/dist/assistant/compositionMention.d.ts +18 -0
  23. package/dist/assistant/compositionMention.js +47 -0
  24. package/dist/assistant/liveData.d.ts +150 -0
  25. package/dist/assistant/liveData.js +286 -0
  26. package/dist/assistant/mcpMention.d.ts +20 -0
  27. package/dist/assistant/mcpMention.js +30 -0
  28. package/dist/assistant/mentionEntries.d.ts +39 -0
  29. package/dist/assistant/mentionEntries.js +69 -0
  30. package/dist/assistant/planFlow.d.ts +26 -0
  31. package/dist/assistant/planFlow.js +57 -0
  32. package/dist/assistant/templateDestinations.d.ts +37 -0
  33. package/dist/assistant/templateDestinations.js +64 -0
  34. package/dist/assistant/types.d.ts +99 -2
  35. package/dist/assistant/workflowPlanViewModel.d.ts +13 -2
  36. package/dist/assistant/workflowPlanViewModel.js +9 -1
  37. package/dist/components/Workflows.svelte +7 -1
  38. package/dist/components/WorkflowsEmptyState.svelte +8 -3
  39. package/dist/components/WorkflowsWorkspace.svelte +29 -1
  40. package/dist/components/WorkflowsWorkspace.svelte.d.ts +3 -0
  41. package/dist/components/assistant/AssistantPlanStepRow.svelte +56 -0
  42. package/dist/components/assistant/AssistantPlanStepRow.svelte.d.ts +9 -0
  43. package/dist/components/assistant/CompositionMentionMenu.svelte +135 -0
  44. package/dist/components/assistant/CompositionMentionMenu.svelte.d.ts +9 -0
  45. package/dist/components/assistant/DataPreviewCard.svelte +108 -0
  46. package/dist/components/assistant/DataPreviewCard.svelte.d.ts +7 -0
  47. package/dist/components/assistant/PlanBindingsBlock.svelte +200 -0
  48. package/dist/components/assistant/PlanBindingsBlock.svelte.d.ts +14 -0
  49. package/dist/components/assistant/TemplateProjectCard.svelte +81 -0
  50. package/dist/components/assistant/TemplateProjectCard.svelte.d.ts +14 -0
  51. package/dist/components/assistant/WorkflowAssistantPanel.svelte +1045 -147
  52. package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +5 -0
  53. package/dist/components/canvas/CanvasContextMenu.svelte +199 -0
  54. package/dist/components/canvas/CanvasContextMenu.svelte.d.ts +16 -0
  55. package/dist/components/canvas/CompositionNodeView.svelte +7 -2
  56. package/dist/components/canvas/ConditionNodeView.svelte +5 -1
  57. package/dist/components/canvas/HandlePoint.svelte +25 -3
  58. package/dist/components/canvas/WorkflowCanvas.svelte +351 -12
  59. package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +12 -1
  60. package/dist/components/canvas/altDragDuplicateController.d.ts +29 -0
  61. package/dist/components/canvas/altDragDuplicateController.js +92 -0
  62. package/dist/components/canvas/connectionSnapController.d.ts +29 -0
  63. package/dist/components/canvas/connectionSnapController.js +182 -0
  64. package/dist/components/canvas/spacePanController.d.ts +16 -0
  65. package/dist/components/canvas/spacePanController.js +103 -0
  66. package/dist/components/editor/EditorCanvasArea.svelte +98 -4
  67. package/dist/components/editor/EditorCanvasArea.svelte.d.ts +5 -0
  68. package/dist/components/editor/EditorTopBar.svelte +53 -42
  69. package/dist/components/editor/WorkflowEditor.svelte +74 -41
  70. package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
  71. package/dist/components/editor/WorkflowNameControl.svelte +9 -8
  72. package/dist/components/editor/WorkflowNameControl.svelte.d.ts +3 -1
  73. package/dist/components/list/WorkflowList.svelte +50 -26
  74. package/dist/components/list/WorkflowList.svelte.d.ts +5 -0
  75. package/dist/components/panel/CompositionForm.svelte +3 -2
  76. package/dist/components/panel/CompositionPicker.svelte +15 -20
  77. package/dist/components/panel/CompositionPicker.svelte.d.ts +2 -2
  78. package/dist/components/panel/CompositionSelect.svelte +4 -4
  79. package/dist/components/panel/CompositionSelect.svelte.d.ts +2 -2
  80. package/dist/components/ui/icons.d.ts +8 -0
  81. package/dist/components/ui/icons.js +24 -1
  82. package/dist/editor/autoLayout.d.ts +38 -0
  83. package/dist/editor/autoLayout.js +403 -0
  84. package/dist/editor/blockClipboard.svelte.d.ts +9 -0
  85. package/dist/editor/blockClipboard.svelte.js +24 -0
  86. package/dist/editor/blockCopy.d.ts +39 -0
  87. package/dist/editor/blockCopy.js +137 -0
  88. package/dist/editor/canvasMenu.d.ts +45 -0
  89. package/dist/editor/canvasMenu.js +68 -0
  90. package/dist/editor/connectionSnap.d.ts +90 -0
  91. package/dist/editor/connectionSnap.js +98 -0
  92. package/dist/editor/editorState.svelte.d.ts +122 -13
  93. package/dist/editor/editorState.svelte.js +262 -22
  94. package/dist/editor/graphIssues.d.ts +5 -0
  95. package/dist/editor/graphIssues.js +18 -0
  96. package/dist/editor/graphModel.d.ts +6 -1
  97. package/dist/editor/graphModel.js +8 -1
  98. package/dist/editor/keyHints.d.ts +21 -0
  99. package/dist/editor/keyHints.js +30 -0
  100. package/dist/editor/listState.svelte.d.ts +4 -4
  101. package/dist/editor/staleGuard.d.ts +111 -0
  102. package/dist/editor/staleGuard.js +279 -0
  103. package/dist/i18n/language.d.ts +3 -3
  104. package/dist/i18n/messages.d.ts +84 -1
  105. package/dist/i18n/messages.js +97 -4
  106. package/dist/index.d.ts +1 -0
  107. package/dist/types/index.d.ts +19 -2
  108. package/package.json +10 -10
@@ -0,0 +1,135 @@
1
+ <!--
2
+ Small menu of what the person can mention while they type @ in the assistant composer: their Open MCPs first, then their
3
+ compositions. Each composition row is the design's Picker Row: the composition's picture (or the composition icon when it has
4
+ none), its name, and whether its widget is published. An Open MCP row has the server's icon, its name, and its address; a
5
+ server that cannot be used yet (it needs signing in again, cannot be reached, has no tool switched on) says why in place of
6
+ its address and cannot be picked. The two groups are labelled only when both are there.
7
+ -->
8
+ <script lang="ts">
9
+ import { useWorkflowsLanguage } from '../../i18n/language.js';
10
+ import {
11
+ mentionEntriesHaveTwoGroups,
12
+ mentionEntryIsSelectable,
13
+ mentionEntryKey,
14
+ mentionEntryUnavailableKey,
15
+ type MentionEntry,
16
+ } from '../../assistant/mentionEntries.js';
17
+ import Icon from '../ui/Icon.svelte';
18
+
19
+ interface Props {
20
+ items: readonly MentionEntry[];
21
+ highlightIndex: number;
22
+ onselect: (entry: MentionEntry) => void;
23
+ }
24
+
25
+ interface MentionGroup {
26
+ kind: MentionEntry['kind'];
27
+ rows: Array<{ entry: MentionEntry; index: number }>;
28
+ }
29
+
30
+ let { items, highlightIndex, onselect }: Props = $props();
31
+
32
+ const { t } = useWorkflowsLanguage();
33
+ const listId = $props.id();
34
+
35
+ /** A picture that failed to load is left out and the row shows the composition icon instead (by composition id). */
36
+ let failedThumbnailIds = $state<ReadonlySet<string>>(new Set());
37
+
38
+ function markThumbnailFailed(compositionId: string): void {
39
+ failedThumbnailIds = new Set([...failedThumbnailIds, compositionId]);
40
+ }
41
+
42
+ // The rows in groups (Open MCPs, then compositions), each row with its place in the whole list, which the highlight is counted in.
43
+ const groups = $derived.by(() => {
44
+ const grouped: MentionGroup[] = [];
45
+ items.forEach((entry, index) => {
46
+ const last = grouped[grouped.length - 1];
47
+ if (last && last.kind === entry.kind) last.rows.push({ entry, index });
48
+ else grouped.push({ kind: entry.kind, rows: [{ entry, index }] });
49
+ });
50
+ return grouped;
51
+ });
52
+
53
+ // One group needs no label: the person sees only compositions (or only servers) and knows what they are.
54
+ const labelsGroups = $derived(mentionEntriesHaveTwoGroups(items));
55
+
56
+ function groupLabel(kind: MentionEntry['kind']): string {
57
+ return kind === 'mcp' ? $t('workflows.assistant.mentionGroupMcps') : $t('workflows.assistant.mentionGroupCompositions');
58
+ }
59
+
60
+ /** What the second line of an Open MCP row says: why it cannot be picked, or else the address that is called. */
61
+ function mcpCaption(entry: MentionEntry): string {
62
+ if (entry.kind !== 'mcp') return '';
63
+ const reasonKey = mentionEntryUnavailableKey(entry);
64
+ return reasonKey ? $t(reasonKey) : entry.option.host;
65
+ }
66
+ </script>
67
+
68
+ <div
69
+ class="absolute bottom-full z-20 mb-1 max-h-64 w-full min-w-[12rem] overflow-auto rounded-xl border border-border bg-popover p-1 shadow-md"
70
+ role="listbox"
71
+ aria-label={$t('workflows.assistant.mentionMenuLabel')}
72
+ id={listId}
73
+ >
74
+ {#if items.length === 0}
75
+ <p class="px-2 py-1.5 text-caption text-muted-foreground">{$t('workflows.assistant.mentionNone')}</p>
76
+ {:else}
77
+ <div class="flex flex-col gap-0.5">
78
+ {#each groups as group (group.kind)}
79
+ <div role="group" aria-label={groupLabel(group.kind)} class="flex flex-col gap-0.5">
80
+ {#if labelsGroups}
81
+ <p class="px-2 pt-1.5 text-caption text-muted-foreground" aria-hidden="true">{groupLabel(group.kind)}</p>
82
+ {/if}
83
+ {#each group.rows as row (mentionEntryKey(row.entry))}
84
+ {@const selectable = mentionEntryIsSelectable(row.entry)}
85
+ <button
86
+ type="button"
87
+ role="option"
88
+ aria-selected={row.index === highlightIndex}
89
+ aria-disabled={!selectable}
90
+ class="flex w-full min-w-0 items-center gap-3 rounded-lg px-2 py-1.5 text-start text-body text-foreground transition-colors {selectable
91
+ ? 'hover:bg-accent'
92
+ : 'cursor-not-allowed opacity-60'} {row.index === highlightIndex && selectable ? 'bg-accent' : ''}"
93
+ onmousedown={(event) => event.preventDefault()}
94
+ onclick={() => {
95
+ if (selectable) onselect(row.entry);
96
+ }}
97
+ >
98
+ {#if row.entry.kind === 'composition'}
99
+ {@const option = row.entry.option}
100
+ {#if option.thumbnailUrl && !failedThumbnailIds.has(option.id)}
101
+ <img
102
+ src={option.thumbnailUrl}
103
+ alt=""
104
+ loading="lazy"
105
+ draggable="false"
106
+ class="h-8 w-8 shrink-0 rounded-lg border border-border object-cover"
107
+ onerror={() => markThumbnailFailed(option.id)}
108
+ />
109
+ {:else}
110
+ <span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
111
+ <Icon name="composition" class="size-4" />
112
+ </span>
113
+ {/if}
114
+ <span class="flex min-w-0 flex-1 flex-col text-start">
115
+ <span class="text-body-medium truncate" dir="auto">{option.name}</span>
116
+ <span class="text-caption text-muted-foreground">
117
+ {option.published ? $t('workflows.block.publishedMeta') : $t('workflows.block.notPublished')}
118
+ </span>
119
+ </span>
120
+ {:else}
121
+ <span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
122
+ <Icon name="plugConnected" class="size-4" />
123
+ </span>
124
+ <span class="flex min-w-0 flex-1 flex-col text-start">
125
+ <span class="text-body-medium truncate" dir="auto">{row.entry.option.name}</span>
126
+ <span class="truncate text-caption text-muted-foreground" dir="auto">{mcpCaption(row.entry)}</span>
127
+ </span>
128
+ {/if}
129
+ </button>
130
+ {/each}
131
+ </div>
132
+ {/each}
133
+ </div>
134
+ {/if}
135
+ </div>
@@ -0,0 +1,9 @@
1
+ import { type MentionEntry } from '../../assistant/mentionEntries.js';
2
+ interface Props {
3
+ items: readonly MentionEntry[];
4
+ highlightIndex: number;
5
+ onselect: (entry: MentionEntry) => void;
6
+ }
7
+ declare const CompositionMentionMenu: import("svelte").Component<Props, {}, "">;
8
+ type CompositionMentionMenu = ReturnType<typeof CompositionMentionMenu>;
9
+ export default CompositionMentionMenu;
@@ -0,0 +1,108 @@
1
+ <!--
2
+ What one call of the person's Open MCP would show in a composition, for them to check before they approve it: the values of
3
+ the fields it fills, and the first rows of the list it fills. These are the person's own values and they are on this screen
4
+ only: the assistant is told which fields were filled and never what is in them, and the card says so.
5
+ -->
6
+ <script lang="ts">
7
+ import { useWorkflowsLanguage } from '../../i18n/language.js';
8
+ import type { AssistantDataPreview } from '../../assistant/liveData.js';
9
+ import Icon from '../ui/Icon.svelte';
10
+
11
+ interface Props {
12
+ preview: AssistantDataPreview;
13
+ }
14
+
15
+ let { preview }: Props = $props();
16
+
17
+ const { t } = useWorkflowsLanguage();
18
+
19
+ const hasListRows = $derived((preview.list?.rows.length ?? 0) > 0);
20
+ const isEmpty = $derived(preview.content.length === 0 && !hasListRows);
21
+ </script>
22
+
23
+ <section
24
+ class="flex flex-col gap-2 rounded-lg border border-border bg-background p-3"
25
+ aria-label={$t('workflows.assistant.previewTitle', { name: preview.compositionName })}
26
+ data-workflows-assistant-preview
27
+ >
28
+ <header class="flex items-start gap-2">
29
+ <span
30
+ class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground"
31
+ >
32
+ <Icon name="table" class="size-4" />
33
+ </span>
34
+ <div class="flex min-w-0 flex-1 flex-col">
35
+ <h4 class="text-body-medium text-foreground" dir="auto">
36
+ {$t('workflows.assistant.previewTitle', { name: preview.compositionName })}
37
+ </h4>
38
+ <p class="text-caption text-muted-foreground" dir="auto">
39
+ {$t('workflows.assistant.previewSource', {
40
+ tool: preview.tool,
41
+ server: preview.openMcpName
42
+ })}
43
+ </p>
44
+ </div>
45
+ </header>
46
+
47
+ {#if preview.content.length > 0}
48
+ <dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-caption">
49
+ {#each preview.content as field, fieldIndex (fieldIndex)}
50
+ <dt class="text-muted-foreground" dir="auto">{field.label}</dt>
51
+ <dd class="min-w-0 break-words text-foreground" dir="auto">{field.value}</dd>
52
+ {/each}
53
+ </dl>
54
+ {/if}
55
+
56
+ {#if preview.list && hasListRows}
57
+ <div class="overflow-auto rounded-lg border border-border">
58
+ <table class="w-full border-collapse text-caption">
59
+ <caption class="sr-only"
60
+ >{$t('workflows.assistant.previewTableLabel', { name: preview.compositionName })}</caption
61
+ >
62
+ <thead>
63
+ <tr class="bg-muted">
64
+ {#each preview.list.columns as column, columnIndex (columnIndex)}
65
+ <th
66
+ scope="col"
67
+ class="px-2 py-1 text-start font-medium text-muted-foreground"
68
+ dir="auto">{column.label}</th
69
+ >
70
+ {/each}
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+ {#each preview.list.rows as row, rowIndex (rowIndex)}
75
+ <tr class="border-t border-border">
76
+ {#each row as cell, cellIndex (cellIndex)}
77
+ <td class="px-2 py-1 text-start align-top text-foreground" dir="auto">{cell}</td>
78
+ {/each}
79
+ </tr>
80
+ {/each}
81
+ </tbody>
82
+ </table>
83
+ </div>
84
+ <p class="text-caption text-muted-foreground">
85
+ {$t('workflows.assistant.previewRowsInAll', { count: preview.list.rowCount })}
86
+ {#if preview.list.rowsLeftOut > 0}
87
+ {$t('workflows.assistant.previewRowsLeftOut', { count: preview.list.rowsLeftOut })}
88
+ {/if}
89
+ </p>
90
+ {/if}
91
+
92
+ {#if isEmpty}
93
+ <p class="text-caption text-muted-foreground">{$t('workflows.assistant.previewEmpty')}</p>
94
+ {/if}
95
+
96
+ {#if preview.dropped > 0 || preview.adjusted > 0}
97
+ <p class="text-caption text-muted-foreground">
98
+ {#if preview.dropped > 0}
99
+ {$t('workflows.assistant.previewDropped', { count: preview.dropped })}
100
+ {/if}
101
+ {#if preview.adjusted > 0}
102
+ {$t('workflows.assistant.previewAdjusted', { count: preview.adjusted })}
103
+ {/if}
104
+ </p>
105
+ {/if}
106
+
107
+ <p class="text-caption text-muted-foreground">{$t('workflows.assistant.previewPrivate')}</p>
108
+ </section>
@@ -0,0 +1,7 @@
1
+ import type { AssistantDataPreview } from '../../assistant/liveData.js';
2
+ interface Props {
3
+ preview: AssistantDataPreview;
4
+ }
5
+ declare const DataPreviewCard: import("svelte").Component<Props, {}, "">;
6
+ type DataPreviewCard = ReturnType<typeof DataPreviewCard>;
7
+ export default DataPreviewCard;
@@ -0,0 +1,200 @@
1
+ <!--
2
+ The live data of a plan, on the plan card: for each composition, the exact call of the person's Open MCP that is saved when they
3
+ approve, where each part of the answer goes, and how often the call is repeated, with the values that call would show. Below
4
+ them is the person's yes: the embed of a composition is public, so anyone who opens it sees what the call gives, and the
5
+ person says they understand that before the plan can be approved (the gateway refuses an approval without it).
6
+
7
+ Nothing here is the model's wording: the call and the mapping are the gateway's, signed with the plan, and what the card shows
8
+ is what is saved.
9
+ -->
10
+ <script lang="ts">
11
+ import { Checkbox } from '@widgetic/design-system/components';
12
+ import { useWorkflowsLanguage } from '../../i18n/language.js';
13
+ import type { WorkflowsMessageKey } from '../../i18n/messages.js';
14
+ import {
15
+ labelledMappingLines,
16
+ previewOfBinding,
17
+ type AssistantDataPreview,
18
+ type AssistantPlanBindingCard,
19
+ type BindingMappingLine
20
+ } from '../../assistant/liveData.js';
21
+ import DataPreviewCard from './DataPreviewCard.svelte';
22
+
23
+ interface Props {
24
+ bindings: readonly AssistantPlanBindingCard[];
25
+ /** The previews the person was shown; each binding finds the one that showed its first rows. */
26
+ previews: readonly AssistantDataPreview[];
27
+ /** Whether the person said they understand that the data is public: the plan card reads it to enable the approval. */
28
+ consent: boolean;
29
+ onConsentChange: (consent: boolean) => void;
30
+ /** True while the approval runs, and once it is over: the box is not changed then. */
31
+ disabled: boolean;
32
+ }
33
+
34
+ let { bindings, previews, consent, onConsentChange, disabled }: Props = $props();
35
+
36
+ const { t } = useWorkflowsLanguage();
37
+ // One id for the component (a component may ask for it once); the heading and the box take their own from it.
38
+ const instanceId = $props.id();
39
+ const headingId = `${instanceId}-heading`;
40
+ const consentId = `${instanceId}-consent`;
41
+
42
+ function statusLabel(binding: AssistantPlanBindingCard): string {
43
+ switch (binding.status) {
44
+ case 'waiting':
45
+ return $t('workflows.assistant.bindingWaiting');
46
+ case 'binding':
47
+ return $t('workflows.assistant.bindingBinding');
48
+ case 'done':
49
+ return binding.rows === undefined
50
+ ? $t('workflows.assistant.bindingDone')
51
+ : $t('workflows.assistant.bindingDoneRows', { count: binding.rows });
52
+ case 'failed':
53
+ return $t('workflows.assistant.bindingFailed');
54
+ }
55
+ }
56
+
57
+ /** What the server says about whether the tool only reads: said plainly, because the call is repeated on its own schedule. */
58
+ function readOnlyNoteKey(binding: AssistantPlanBindingCard): WorkflowsMessageKey {
59
+ if (binding.toolReadOnly === true) return 'workflows.assistant.bindingReadOnly';
60
+ if (binding.toolReadOnly === false) return 'workflows.assistant.bindingMayChange';
61
+ return 'workflows.assistant.bindingReadOnlyUnknown';
62
+ }
63
+
64
+ function hasArguments(binding: AssistantPlanBindingCard): boolean {
65
+ return binding.callText !== '' && binding.callText !== '{}';
66
+ }
67
+ </script>
68
+
69
+ {#snippet mappingTable(lines: readonly BindingMappingLine[], emptyPathMessage: WorkflowsMessageKey)}
70
+ <table class="w-full border-collapse text-caption">
71
+ <thead>
72
+ <tr>
73
+ <th scope="col" class="pb-1 pe-3 text-start font-medium text-muted-foreground">
74
+ {$t('workflows.assistant.bindingFieldHeading')}
75
+ </th>
76
+ <th scope="col" class="pb-1 text-start font-medium text-muted-foreground">
77
+ {$t('workflows.assistant.bindingSourceHeading')}
78
+ </th>
79
+ </tr>
80
+ </thead>
81
+ <tbody>
82
+ {#each lines as line, lineIndex (lineIndex)}
83
+ <tr class="border-t border-border">
84
+ <td class="py-1 pe-3 text-start align-top text-foreground" dir="auto">{line.field}</td>
85
+ <td class="py-1 text-start align-top text-muted-foreground break-words" dir="ltr">
86
+ {line.path === '' ? $t(emptyPathMessage) : line.path}
87
+ </td>
88
+ </tr>
89
+ {/each}
90
+ </tbody>
91
+ </table>
92
+ {/snippet}
93
+
94
+ <section
95
+ class="mt-2 flex flex-col gap-2 rounded-lg border border-border p-3"
96
+ aria-labelledby={headingId}
97
+ data-workflows-assistant-bindings
98
+ >
99
+ <h4 id={headingId} class="text-body-medium text-foreground">
100
+ {$t('workflows.assistant.liveDataTitle')}
101
+ </h4>
102
+ <p class="text-caption text-muted-foreground">{$t('workflows.assistant.liveDataIntro')}</p>
103
+
104
+ <ul class="flex flex-col gap-2">
105
+ {#each bindings as binding (binding.id)}
106
+ {@const preview = previewOfBinding(previews, binding)}
107
+ <li
108
+ class="flex flex-col gap-1.5 rounded-lg bg-muted p-2"
109
+ data-workflows-assistant-binding={binding.id}
110
+ >
111
+ <div class="flex items-start justify-between gap-2">
112
+ <span class="min-w-0 text-body-medium text-foreground" dir="auto"
113
+ >{binding.compositionName}</span
114
+ >
115
+ <span
116
+ class="shrink-0 text-caption {binding.status === 'failed'
117
+ ? 'text-destructive'
118
+ : 'text-muted-foreground'}"
119
+ >
120
+ {statusLabel(binding)}
121
+ </span>
122
+ </div>
123
+ <p class="text-caption text-muted-foreground" dir="auto">
124
+ {$t('workflows.assistant.bindingCall', {
125
+ tool: binding.tool,
126
+ server: binding.openMcpName,
127
+ host: binding.openMcpHost
128
+ })}
129
+ </p>
130
+ <p
131
+ class="text-caption {binding.toolReadOnly === false
132
+ ? 'text-destructive'
133
+ : 'text-muted-foreground'}"
134
+ >
135
+ {$t(readOnlyNoteKey(binding))}
136
+ </p>
137
+ <p class="text-caption text-muted-foreground">
138
+ {$t('workflows.assistant.bindingRefresh', { count: binding.ttlSeconds })}
139
+ </p>
140
+ {#if binding.status === 'failed' && binding.detail}
141
+ <p class="text-caption text-destructive" dir="auto">{binding.detail}</p>
142
+ {/if}
143
+
144
+ <details class="text-caption">
145
+ <summary class="cursor-pointer text-foreground"
146
+ >{$t('workflows.assistant.bindingCallDetails')}</summary
147
+ >
148
+ {#if hasArguments(binding)}
149
+ <pre
150
+ class="mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-background p-2 text-start text-foreground"
151
+ dir="ltr">{binding.callText}</pre>
152
+ {:else}
153
+ <p class="mt-1 text-muted-foreground">{$t('workflows.assistant.bindingNoArguments')}</p>
154
+ {/if}
155
+ </details>
156
+
157
+ <details class="text-caption">
158
+ <summary class="cursor-pointer text-foreground"
159
+ >{$t('workflows.assistant.bindingMappingDetails')}</summary
160
+ >
161
+ <div class="mt-1 flex flex-col gap-2 rounded-lg bg-background p-2">
162
+ {#if binding.mapping.content.length > 0}
163
+ {@render mappingTable(
164
+ labelledMappingLines(binding.mapping.content, preview?.content),
165
+ 'workflows.assistant.bindingWholeAnswer'
166
+ )}
167
+ {/if}
168
+ {#if binding.mapping.list}
169
+ <p class="flex flex-wrap gap-x-2 text-caption">
170
+ <span class="text-muted-foreground"
171
+ >{$t('workflows.assistant.bindingRowsHeading')}</span
172
+ >
173
+ <span class="break-words text-foreground" dir="ltr">
174
+ {binding.mapping.list.rowsPath === ''
175
+ ? $t('workflows.assistant.bindingWholeAnswer')
176
+ : binding.mapping.list.rowsPath}
177
+ </span>
178
+ </p>
179
+ {@render mappingTable(
180
+ labelledMappingLines(binding.mapping.list.columns, preview?.list?.columns),
181
+ 'workflows.assistant.bindingWholeRow'
182
+ )}
183
+ {/if}
184
+ </div>
185
+ </details>
186
+
187
+ {#if preview}
188
+ <DataPreviewCard {preview} />
189
+ {/if}
190
+ </li>
191
+ {/each}
192
+ </ul>
193
+
194
+ <div class="flex items-start gap-2">
195
+ <Checkbox id={consentId} checked={consent} onCheckedChange={onConsentChange} {disabled} />
196
+ <label for={consentId} class="min-w-0 flex-1 cursor-pointer text-caption text-foreground">
197
+ {$t('workflows.assistant.exposureConsent')}
198
+ </label>
199
+ </div>
200
+ </section>
@@ -0,0 +1,14 @@
1
+ import { type AssistantDataPreview, type AssistantPlanBindingCard } from '../../assistant/liveData.js';
2
+ interface Props {
3
+ bindings: readonly AssistantPlanBindingCard[];
4
+ /** The previews the person was shown; each binding finds the one that showed its first rows. */
5
+ previews: readonly AssistantDataPreview[];
6
+ /** Whether the person said they understand that the data is public: the plan card reads it to enable the approval. */
7
+ consent: boolean;
8
+ onConsentChange: (consent: boolean) => void;
9
+ /** True while the approval runs, and once it is over: the box is not changed then. */
10
+ disabled: boolean;
11
+ }
12
+ declare const PlanBindingsBlock: import("svelte").Component<Props, {}, "">;
13
+ type PlanBindingsBlock = ReturnType<typeof PlanBindingsBlock>;
14
+ export default PlanBindingsBlock;
@@ -0,0 +1,81 @@
1
+ <!--
2
+ The card that asks where the copies of a plan's template widgets go. It is shown when the person may add widgets to more than
3
+ one project; the copies go into the one chosen here. It is built like the design system's question card (the same option
4
+ rows, one per project), but has no button of its own: the choice is applied when the person presses Create workflow, and
5
+ until they choose, the first project (where the copies always went) is the chosen one.
6
+ -->
7
+ <script lang="ts">
8
+ import { OptionRow, moveFocusedIndex } from '@widgetic/design-system/components';
9
+ import type { TemplateDestinationProject } from '../../assistant/templateDestinations.js';
10
+ import { useWorkflowsLanguage } from '../../i18n/language.js';
11
+
12
+ interface Props {
13
+ /** The projects the person may add widgets to, oldest first. */
14
+ projects: readonly TemplateDestinationProject[];
15
+ /** The project the copies go to now. */
16
+ selectedProjectId: string;
17
+ /** The person chose a project. */
18
+ onSelect: (projectId: string) => void;
19
+ /** The plan is being carried out: the project can no longer change. */
20
+ disabled?: boolean;
21
+ }
22
+
23
+ let { projects, selectedProjectId, onSelect, disabled = false }: Props = $props();
24
+
25
+ const { t } = useWorkflowsLanguage();
26
+ const uniqueId = $props.id();
27
+ const titleId = `${uniqueId}-title`;
28
+
29
+ // The row that Tab reaches is the chosen one, as in any group of radio buttons.
30
+ const selectedIndex = $derived(
31
+ Math.max(
32
+ 0,
33
+ projects.findIndex((project) => project.id === selectedProjectId),
34
+ ),
35
+ );
36
+
37
+ /** A project the person never named has no name to show: it reads as an untitled project. */
38
+ function nameOf(project: TemplateDestinationProject): string {
39
+ return project.name.trim() !== '' ? project.name : $t('workflows.assistant.templateProjectUnnamed');
40
+ }
41
+
42
+ /** The arrow keys move the choice, as they do in a group of radio buttons: the next row is chosen and takes the focus. */
43
+ function handleRowKeydown(event: KeyboardEvent, index: number): void {
44
+ if (disabled) return;
45
+ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;
46
+ event.preventDefault();
47
+ const nextIndex = moveFocusedIndex(index, event.key === 'ArrowDown' ? 'down' : 'up', projects.length);
48
+ const nextProject = projects[nextIndex];
49
+ if (!nextProject) return;
50
+ onSelect(nextProject.id);
51
+ // The rows are the children of one group: the row that was reached is where to look for the next one.
52
+ const group = (event.currentTarget as HTMLElement | null)?.parentElement;
53
+ group?.querySelector<HTMLButtonElement>(`[data-template-project-index="${nextIndex}"]`)?.focus();
54
+ }
55
+ </script>
56
+
57
+ <section
58
+ class="flex flex-col gap-3 rounded-lg border border-border bg-background p-3"
59
+ aria-labelledby={titleId}
60
+ data-workflows-assistant-template-project
61
+ >
62
+ <header class="flex min-w-0 flex-col gap-0.5">
63
+ <h4 id={titleId} class="text-body font-medium text-foreground">
64
+ {$t('workflows.assistant.templateProjectTitle')}
65
+ </h4>
66
+ <p class="text-caption text-muted-foreground">{$t('workflows.assistant.templateProjectHint')}</p>
67
+ </header>
68
+ <div class="flex flex-col gap-1" role="radiogroup" aria-labelledby={titleId}>
69
+ {#each projects as project, index (project.id)}
70
+ <OptionRow
71
+ label={nameOf(project)}
72
+ selected={project.id === selectedProjectId}
73
+ {disabled}
74
+ data-template-project-index={index}
75
+ tabindex={index === selectedIndex ? 0 : -1}
76
+ onSelect={() => onSelect(project.id)}
77
+ onkeydown={(event: KeyboardEvent) => handleRowKeydown(event, index)}
78
+ />
79
+ {/each}
80
+ </div>
81
+ </section>
@@ -0,0 +1,14 @@
1
+ import type { TemplateDestinationProject } from '../../assistant/templateDestinations.js';
2
+ interface Props {
3
+ /** The projects the person may add widgets to, oldest first. */
4
+ projects: readonly TemplateDestinationProject[];
5
+ /** The project the copies go to now. */
6
+ selectedProjectId: string;
7
+ /** The person chose a project. */
8
+ onSelect: (projectId: string) => void;
9
+ /** The plan is being carried out: the project can no longer change. */
10
+ disabled?: boolean;
11
+ }
12
+ declare const TemplateProjectCard: import("svelte").Component<Props, {}, "">;
13
+ type TemplateProjectCard = ReturnType<typeof TemplateProjectCard>;
14
+ export default TemplateProjectCard;