@mcp-b/react-components 0.57.1 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card-BPkXIkBz.d.ts +46 -0
- package/dist/{CodeBlock-Bl-q7wMc.js → CodeBlock-Bs_Z03eC.js} +2 -1
- package/dist/{CodeBlock-CPotpyyM.d.ts → CodeBlock-DYp5V_4O.d.ts} +1 -1
- package/dist/{EmployeeChrome-CN99SVfF.d.ts → EmployeeChrome-DsdIek0l.d.ts} +2 -10
- package/dist/ExecutionBoard-DHfMvKlB.d.ts +64 -0
- package/dist/ExecutionResult-BSZsUbrL.js +279 -0
- package/dist/{FileTree-CfOhUyp3.js → FileTree-DyLBn7O_.js} +1 -1
- package/dist/{ManagerOffice-CMJ7laGe.js → ManagerOffice-C8AQcaXs.js} +5 -20
- package/dist/{McpConnectorForm-BPWCo9bU.d.ts → McpConnectorForm-D4bY-lm_.d.ts} +1 -1
- package/dist/{McpPluginCatalog-uSh0gGeY.d.ts → McpPluginCatalog-2FZDLCeK.d.ts} +2 -2
- package/dist/{SetupChecklist-BiWQkKEq.js → SetupChecklist-CKQ-mKYt.js} +2 -2
- package/dist/{ThinkRoutine-DGlKJbIy.d.ts → ThinkRoutine-DoZjbzyn.d.ts} +15 -3
- package/dist/{Workspace-Cr-aGDfx.d.ts → Workspace-iCkXvQRJ.d.ts} +1 -1
- package/dist/WorkspaceConcept-ByaG-kBq.d.ts +38 -0
- package/dist/WorkspaceExecutionTable-DNhj6YDX.d.ts +239 -0
- package/dist/{WorkspaceFile-DiwiJEwO.d.ts → WorkspaceFile-DkIZKoK6.d.ts} +1 -1
- package/dist/{WorkspaceFileView-CCe_o79q.js → WorkspaceFileView-M2jC2P4p.js} +217 -139
- package/dist/components/agents-sdk/AgentActivity.js +1 -1
- package/dist/components/agents-sdk/AgentChat.js +10 -10
- package/dist/components/agents-sdk/BrowserLiveScreen.js +1 -1
- package/dist/components/agents-sdk/BrowserLiveView.js +1 -1
- package/dist/components/agents-sdk/BrowserReplay.js +1 -1
- package/dist/components/agents-sdk/BrowserRunPanel.js +1 -1
- package/dist/components/agents-sdk/EmployeeApp.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeApp.js +3 -7
- package/dist/components/agents-sdk/EmployeeChat.js +4 -4
- package/dist/components/agents-sdk/EmployeeChrome.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeChrome.js +78 -63
- package/dist/components/agents-sdk/EmployeeSchedules.d.ts +6 -3
- package/dist/components/agents-sdk/EmployeeSchedules.js +12 -10
- package/dist/components/agents-sdk/EmployeeStartScreen.d.ts +2 -2
- package/dist/components/agents-sdk/EmployeeStartScreen.js +3 -3
- package/dist/components/agents-sdk/ExecutionBoard.d.ts +2 -0
- package/dist/components/agents-sdk/ExecutionBoard.js +648 -0
- package/dist/components/agents-sdk/ManagerAccountActions.js +2 -2
- package/dist/components/agents-sdk/ManagerOffice.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOffice.js +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.d.ts +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.js +4 -3
- package/dist/components/agents-sdk/McpConnectionRequest.d.ts +1 -1
- package/dist/components/agents-sdk/McpConnectionRequest.js +2 -2
- package/dist/components/agents-sdk/McpConnectorForm.d.ts +1 -1
- package/dist/components/agents-sdk/McpConnectorForm.js +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.d.ts +1 -1
- package/dist/components/agents-sdk/McpPluginCatalog.js +17 -8
- package/dist/components/agents-sdk/McpServerIcon.d.ts +1 -1
- package/dist/components/agents-sdk/McpServerPicker.d.ts +2 -2
- package/dist/components/agents-sdk/McpServerPicker.js +2 -2
- package/dist/components/agents-sdk/ModelEndpointDialog.js +1 -1
- package/dist/components/agents-sdk/ModelSelector.js +4 -4
- package/dist/components/agents-sdk/PromptInputApproval.js +1 -1
- package/dist/components/agents-sdk/PromptInputCommands.js +1 -1
- package/dist/components/agents-sdk/SubagentRunIndicator.js +1 -1
- package/dist/components/agents-sdk/SubagentRunPanel.js +2 -2
- package/dist/components/agents-sdk/SubagentRunSelector.js +1 -1
- package/dist/components/agents-sdk/ThinkChatActivity.js +2 -2
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +238 -209
- package/dist/components/agents-sdk/ThinkExecutionDetail.js +14 -35
- package/dist/components/agents-sdk/ThinkExecutionStatus.js +1 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +3 -3
- package/dist/components/agents-sdk/ThinkRecoveryNotice.js +1 -1
- package/dist/components/agents-sdk/ThinkRoutine.d.ts +2 -2
- package/dist/components/agents-sdk/ThinkRoutineActions.d.ts +2 -2
- package/dist/components/agents-sdk/ThinkRoutineActions.js +25 -15
- package/dist/components/agents-sdk/ThinkRoutineBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/ThinkRoutineBrowser.js +2 -2
- package/dist/components/agents-sdk/ThinkRoutineDetail.d.ts +5 -2
- package/dist/components/agents-sdk/ThinkRoutineDetail.js +13 -7
- package/dist/components/agents-sdk/ThinkRoutineForm.d.ts +23 -6
- package/dist/components/agents-sdk/ThinkRoutineForm.js +521 -214
- package/dist/components/agents-sdk/ThinkRoutineRuns.js +1 -1
- package/dist/components/agents-sdk/ThinkThreadPicker.js +2 -2
- package/dist/components/agents-sdk/TypeSafeConnectionDialog.d.ts +10 -0
- package/dist/components/agents-sdk/TypeSafeConnectionDialog.js +34 -0
- package/dist/components/agents-sdk/WorkbenchBack.js +1 -1
- package/dist/components/agents-sdk/Workspace.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.js +1 -1
- package/dist/components/agents-sdk/WorkspaceConcept.d.ts +2 -37
- package/dist/components/agents-sdk/WorkspaceCorrespondence.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceCorrespondence.js +7 -6
- package/dist/components/agents-sdk/WorkspaceExecution.d.ts +2 -92
- package/dist/components/agents-sdk/WorkspaceExecution.js +650 -133
- package/dist/components/agents-sdk/WorkspaceExecutionTable.d.ts +2 -0
- package/dist/components/agents-sdk/WorkspaceExecutionTable.js +824 -0
- package/dist/components/agents-sdk/WorkspaceExplorer.d.ts +3 -1
- package/dist/components/agents-sdk/WorkspaceExplorer.js +4 -3
- package/dist/components/agents-sdk/WorkspaceFile.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceFileView.d.ts +4 -2
- package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
- package/dist/components/agents-sdk/WorkspaceHeader.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLive.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceMountManager.js +1 -1
- package/dist/components/agents-sdk/WorkspaceProject.d.ts +2 -2
- package/dist/components/agents-sdk/WorkspaceProject.js +6 -5
- package/dist/components/agents-sdk/WorkspaceUserScript.d.ts +1 -1
- package/dist/components/agents-sdk/WorkspaceUserScript.js +5 -4
- package/dist/components/ai-sdk/Activity.js +1 -1
- package/dist/components/ai-sdk/AgentChatStartScreen.js +1 -1
- package/dist/components/ai-sdk/Approval.js +2 -2
- package/dist/components/ai-sdk/Artifact.js +1 -1
- package/dist/components/ai-sdk/ChainOfThought.d.ts +1 -1
- package/dist/components/ai-sdk/ChainOfThought.js +1 -1
- package/dist/components/ai-sdk/Checkpoint.js +1 -1
- package/dist/components/ai-sdk/CodeBlock.d.ts +1 -1
- package/dist/components/ai-sdk/CodeBlock.js +1 -1
- package/dist/components/ai-sdk/ComposerLink.js +1 -1
- package/dist/components/ai-sdk/ConnectedAppCards.d.ts +1 -1
- package/dist/components/ai-sdk/ConnectedAppCards.js +3 -3
- package/dist/components/ai-sdk/Context.js +1 -1
- package/dist/components/ai-sdk/Conversation.js +1 -1
- package/dist/components/ai-sdk/Goal.js +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.d.ts +1 -1
- package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
- package/dist/components/ai-sdk/Message.js +2 -2
- package/dist/components/ai-sdk/MessageScroller.js +1 -1
- package/dist/components/ai-sdk/MessageScrollerVirtual.js +1 -1
- package/dist/components/ai-sdk/Plan.js +1 -1
- package/dist/components/ai-sdk/PromptInput.js +6 -6
- package/dist/components/ai-sdk/Queue.js +1 -1
- package/dist/components/ai-sdk/Reasoning.js +1 -1
- package/dist/components/ai-sdk/Sources.js +1 -1
- package/dist/components/ai-sdk/Task.js +1 -1
- package/dist/components/extension/ChatGptSignInScreen.js +2 -2
- package/dist/components/extension/CodexModelSelector.js +2 -2
- package/dist/components/extension/ConversationTabPicker.js +2 -2
- package/dist/components/foundations/Card.d.ts +2 -45
- package/dist/components/foundations/Checkbox.js +1 -1
- package/dist/components/foundations/Collapsible.js +1 -1
- package/dist/components/foundations/ContextMenu.js +1 -1
- package/dist/components/foundations/Menubar.js +1 -1
- package/dist/components/foundations/SearchField.js +1 -1
- package/dist/components/foundations/Select.js +1 -1
- package/dist/components/foundations/Stepper.js +1 -1
- package/dist/components/foundations/Toast.js +1 -1
- package/dist/components/foundations/icons.d.ts +2 -2
- package/dist/components/foundations/icons.js +2 -2
- package/dist/components/general-purpose/AccountSignInDialog.js +1 -1
- package/dist/components/general-purpose/Commit.js +2 -2
- package/dist/components/general-purpose/EnvironmentVariables.js +2 -2
- package/dist/components/general-purpose/FileTree.js +1 -1
- package/dist/components/general-purpose/PricingPlanCard.js +2 -2
- package/dist/components/general-purpose/PricingUsageCalculator.js +2 -2
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +1 -1
- package/dist/components/general-purpose/SettingsFormDialog.js +2 -2
- package/dist/components/general-purpose/SetupChecklist.js +1 -1
- package/dist/components/general-purpose/Terminal.js +2 -2
- package/dist/components/general-purpose/TestResults.js +1 -1
- package/dist/components/general-purpose/ThemeModeControl.js +1 -1
- package/dist/components/general-purpose/WebPreview.js +2 -2
- package/dist/components/nanites/AgentConnection.js +2 -2
- package/dist/components/nanites/AgentToolDetail.js +1 -1
- package/dist/{copy-button-CSDuDfdP.js → copy-button-M4sAp9xS.js} +1 -1
- package/dist/execution-result-DWVmm-bL.js +80 -0
- package/dist/{icons-CUuD7iEh.d.ts → icons-Dj6id76o.d.ts} +2 -1
- package/dist/{icons-cuEtsgj9.js → icons-DvlrWt54.js} +4 -3
- package/dist/{mcp-server-catalog-DgA9BnL0.d.ts → mcp-server-catalog-kaMWaSAL.d.ts} +3 -1
- package/dist/styles/app-top-bar.css +2 -1
- package/dist/styles/base.css +1 -0
- package/dist/styles/chatgpt-sign-in-screen.css +8 -14
- package/dist/styles/description-list.css +12 -9
- package/dist/styles/execution-board.css +383 -0
- package/dist/styles/index.css +3 -0
- package/dist/styles/mcp-plugin-catalog.css +8 -7
- package/dist/styles/message-scroller.css +8 -0
- package/dist/styles/think-chat-tool-panels.css +1 -2
- package/dist/styles/think-execution-workbench.css +1 -12
- package/dist/styles/think-routine.css +39 -41
- package/dist/styles/workspace-concepts.css +441 -17
- package/dist/styles/workspace-explorer.css +18 -4
- package/dist/utils/mcp-server-catalog.d.ts +2 -2
- package/dist/utils/mcp-server-catalog.js +18 -1
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/{workspace-assets-Bg7XhPsk.js → workspace-assets-DVn0d-fN.js} +24 -81
- package/dist/workspace-delete-DfloiBWp.js +80 -0
- package/package.json +3 -2
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { t as cx } from "../../class-names-BiMDVpUo.js";
|
|
2
|
-
import { K as SpinnerIcon,
|
|
2
|
+
import { K as SpinnerIcon, T as InfoIcon, d as CheckIcon, f as ChevronDownIcon, r as ArrowLeftIcon, tt as WarningIcon } from "../../icons-DvlrWt54.js";
|
|
3
3
|
import { Button } from "../foundations/Button.js";
|
|
4
|
-
import { a as formatErrorMessage } from "../../format-CWaZEp5o.js";
|
|
5
4
|
import { Field } from "../foundations/Field.js";
|
|
6
5
|
import { Form } from "../foundations/Form.js";
|
|
7
6
|
import { Textarea } from "../foundations/Textarea.js";
|
|
7
|
+
import { IconButton } from "../foundations/IconButton.js";
|
|
8
|
+
import { a as formatErrorMessage } from "../../format-CWaZEp5o.js";
|
|
9
|
+
import { Select } from "../foundations/Select.js";
|
|
8
10
|
import { AppTopBar } from "../general-purpose/AppTopBar.js";
|
|
9
11
|
import { Fieldset } from "../foundations/Fieldset.js";
|
|
10
|
-
import {
|
|
12
|
+
import { t as executionErrorSummary } from "../../execution-result-DWVmm-bL.js";
|
|
13
|
+
import { a as httpUrl, t as FaviconMark } from "../../workspace-assets-DVn0d-fN.js";
|
|
14
|
+
import { t as ExecutionResult } from "../../ExecutionResult-BSZsUbrL.js";
|
|
11
15
|
import { Checkbox } from "../foundations/Checkbox.js";
|
|
12
16
|
import { CheckboxGroup } from "../foundations/CheckboxGroup.js";
|
|
13
17
|
import { Combobox } from "../foundations/Combobox.js";
|
|
@@ -88,6 +92,31 @@ function wallClockTime(schedule) {
|
|
|
88
92
|
const pad = (value) => String(value).padStart(2, "0");
|
|
89
93
|
return `${pad(schedule.hour)}:${pad(schedule.minute)}`;
|
|
90
94
|
}
|
|
95
|
+
function scheduleDefaults(schedule) {
|
|
96
|
+
const intervalMs = schedule?.kind === "interval" ? schedule.intervalMs : void 0;
|
|
97
|
+
const wallClock = schedule?.kind === "wall-clock" ? schedule : void 0;
|
|
98
|
+
const selectedDays = wallClock?.days;
|
|
99
|
+
return {
|
|
100
|
+
kind: schedule ? scheduleKindOf(schedule) : "daily",
|
|
101
|
+
intervalEvery: intervalMs === void 0 ? 1 : intervalMs % 36e5 === 0 ? intervalMs / 36e5 : intervalMs / 6e4,
|
|
102
|
+
intervalUnit: intervalMs !== void 0 && intervalMs % 36e5 !== 0 ? "minute" : "hour",
|
|
103
|
+
time: wallClock ? wallClockTime(wallClock) : "09:00",
|
|
104
|
+
timezone: wallClock?.timezone ?? BROWSER_TIMEZONE,
|
|
105
|
+
days: selectedDays && typeof selectedDays !== "string" ? WEEKDAYS.filter((day) => selectedDays.includes(day.dayNumber)).map((day) => day.token) : ["mon"]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function serializeSchedule({ kind, intervalEvery, intervalUnit, time, timezone, days }) {
|
|
109
|
+
if (kind === "interval") {
|
|
110
|
+
if (intervalEvery === null || !Number.isSafeInteger(intervalEvery) || intervalEvery < 1) return null;
|
|
111
|
+
return `every ${intervalEvery} ${intervalUnit}${intervalEvery === 1 ? "" : "s"}`;
|
|
112
|
+
}
|
|
113
|
+
if (kind === "weekly") {
|
|
114
|
+
if (days.length === 0) return null;
|
|
115
|
+
return `every week on ${WEEKDAYS.filter((day) => days.includes(day.token)).map((day) => day.token).join(",")} at ${time} in ${timezone}`;
|
|
116
|
+
}
|
|
117
|
+
if (kind === "weekdays") return `every weekday at ${time} in ${timezone}`;
|
|
118
|
+
return `every day at ${time} in ${timezone}`;
|
|
119
|
+
}
|
|
91
120
|
function timezoneOptions() {
|
|
92
121
|
return [.../* @__PURE__ */ new Set([
|
|
93
122
|
BROWSER_TIMEZONE,
|
|
@@ -99,17 +128,28 @@ function timezoneOptions() {
|
|
|
99
128
|
}));
|
|
100
129
|
}
|
|
101
130
|
const TIMEZONE_OPTIONS = timezoneOptions();
|
|
102
|
-
function RoutineSelect({ label, onValueChange, options, value }) {
|
|
131
|
+
function RoutineSelect({ disabled, description, label, name, onValueChange, options, value }) {
|
|
103
132
|
return /* @__PURE__ */ jsx("div", {
|
|
104
133
|
className: "think-routine__select-field",
|
|
105
134
|
children: /* @__PURE__ */ jsxs(Select.Root, {
|
|
135
|
+
disabled,
|
|
136
|
+
name,
|
|
106
137
|
items: options,
|
|
107
138
|
value,
|
|
108
139
|
onValueChange: (nextValue) => {
|
|
109
140
|
if (typeof nextValue === "string") onValueChange(nextValue);
|
|
110
141
|
},
|
|
111
142
|
children: [
|
|
112
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ jsxs("div", {
|
|
144
|
+
className: "think-routine__input-label",
|
|
145
|
+
children: [/* @__PURE__ */ jsx(Select.Label, { children: label }), description ? /* @__PURE__ */ jsx(IconButton, {
|
|
146
|
+
label: `About ${label}`,
|
|
147
|
+
tooltip: description,
|
|
148
|
+
variant: "ghost",
|
|
149
|
+
color: "neutral",
|
|
150
|
+
children: /* @__PURE__ */ jsx(InfoIcon, {})
|
|
151
|
+
}) : null]
|
|
152
|
+
}),
|
|
113
153
|
/* @__PURE__ */ jsxs(Select.Trigger, { children: [/* @__PURE__ */ jsx(Select.Value, {}), /* @__PURE__ */ jsx(Select.Icon, {})] }),
|
|
114
154
|
/* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
|
|
115
155
|
sideOffset: 4,
|
|
@@ -122,26 +162,194 @@ function RoutineSelect({ label, onValueChange, options, value }) {
|
|
|
122
162
|
})
|
|
123
163
|
});
|
|
124
164
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
165
|
+
function RoutineTableSource({ table, scripts }) {
|
|
166
|
+
if (!table) return null;
|
|
167
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
168
|
+
className: "think-routine__table-source",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx("p", { children: "Run once for each table row" }),
|
|
171
|
+
/* @__PURE__ */ jsx(RoutineTableOrigin, {
|
|
172
|
+
table,
|
|
173
|
+
scripts
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ jsx("p", {
|
|
176
|
+
className: "think-routine__input-help",
|
|
177
|
+
children: "script" in table.source ? "Reads current rows for each scheduled run" : "data" in table.source ? "Repeats these rows on schedule" : "Uses this saved file for each scheduled run"
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function RoutineTableOrigin({ table, scripts }) {
|
|
183
|
+
if ("data" in table.source && table.source.data.source) {
|
|
184
|
+
const source = table.source.data.source;
|
|
185
|
+
const href = source.href ? httpUrl(source.href) : void 0;
|
|
186
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
187
|
+
className: "sigvelo-cluster",
|
|
188
|
+
children: [/* @__PURE__ */ jsx(FaviconMark, { href }), href ? /* @__PURE__ */ jsx("a", {
|
|
189
|
+
href,
|
|
190
|
+
target: "_blank",
|
|
191
|
+
rel: "noreferrer",
|
|
192
|
+
children: source.label
|
|
193
|
+
}) : source.label]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if ("path" in table.source) return /* @__PURE__ */ jsx("p", { children: [/\.json$/iu.test(table.source.path) ? "Saved table" : table.source.path.split("/").at(-1), table.source.sheet].filter(Boolean).join(" · ") });
|
|
197
|
+
if ("script" in table.source) {
|
|
198
|
+
const path = table.source.script.path;
|
|
199
|
+
return /* @__PURE__ */ jsx("p", { children: scripts.find((script) => script.path === path)?.name ?? "Connected table" });
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ jsx("p", { children: "Saved table" });
|
|
202
|
+
}
|
|
203
|
+
function RoutineScriptParameter({ parameter, value, setArgument }) {
|
|
204
|
+
const help = [parameter.description, parameter.required ? "Required by the workflow." : void 0].filter(Boolean).join(" ");
|
|
205
|
+
if (value !== void 0 && (typeof value === "object" || typeof value !== parameter.type)) return null;
|
|
206
|
+
return /* @__PURE__ */ jsx(Field.Root, {
|
|
207
|
+
name: parameter.name,
|
|
208
|
+
children: /* @__PURE__ */ jsx(RoutineParameterControl, {
|
|
209
|
+
parameter,
|
|
210
|
+
value,
|
|
211
|
+
help,
|
|
212
|
+
setArgument
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function RoutineParameterControl({ parameter, value, help, setArgument }) {
|
|
217
|
+
if (parameter.type !== "boolean") return /* @__PURE__ */ jsx(RoutineValueParameter, {
|
|
218
|
+
parameter,
|
|
219
|
+
value,
|
|
220
|
+
help,
|
|
221
|
+
setArgument
|
|
222
|
+
});
|
|
223
|
+
return /* @__PURE__ */ jsx(RoutineSelect, {
|
|
224
|
+
label: parameter.label,
|
|
225
|
+
description: help || void 0,
|
|
226
|
+
name: parameter.name,
|
|
227
|
+
value: value === void 0 ? "" : String(value),
|
|
228
|
+
options: [
|
|
229
|
+
{
|
|
230
|
+
label: parameter.required ? "Choose an option" : "Use workflow default",
|
|
231
|
+
value: ""
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: "Yes",
|
|
235
|
+
value: "true"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: "No",
|
|
239
|
+
value: "false"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
onValueChange: (nextValue) => setArgument(parameter.name, nextValue === "" ? void 0 : nextValue === "true")
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function RoutineValueParameter({ parameter, value, help, setArgument }) {
|
|
246
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
247
|
+
className: "think-routine__input-label",
|
|
248
|
+
children: [/* @__PURE__ */ jsx(Field.Label, { children: parameter.label }), help ? /* @__PURE__ */ jsx(IconButton, {
|
|
249
|
+
label: `About ${parameter.label}`,
|
|
250
|
+
tooltip: help,
|
|
251
|
+
variant: "ghost",
|
|
252
|
+
color: "neutral",
|
|
253
|
+
children: /* @__PURE__ */ jsx(InfoIcon, {})
|
|
254
|
+
}) : null]
|
|
255
|
+
}), /* @__PURE__ */ jsx(Field.Control, {
|
|
256
|
+
name: parameter.name,
|
|
257
|
+
type: parameter.type === "number" ? "number" : "text",
|
|
258
|
+
step: parameter.type === "number" ? "any" : void 0,
|
|
259
|
+
value: value === void 0 ? "" : String(value),
|
|
260
|
+
autoComplete: "off",
|
|
261
|
+
placeholder: parameter.required ? void 0 : "Use workflow default",
|
|
262
|
+
onChange: (event) => {
|
|
263
|
+
const nextValue = event.currentTarget.value;
|
|
264
|
+
setArgument(parameter.name, nextValue === "" ? void 0 : parameter.type === "number" ? Number(nextValue) : nextValue);
|
|
265
|
+
}
|
|
266
|
+
})] });
|
|
267
|
+
}
|
|
268
|
+
function RoutineWeeklyDays({ days, setDays, daysError, setDaysError, daysDescriptionId, daysErrorId, firstDayRef }) {
|
|
269
|
+
return /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
270
|
+
variant: "plain",
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsx(Fieldset.Legend, { children: "Days" }),
|
|
273
|
+
/* @__PURE__ */ jsx(Fieldset.Description, {
|
|
274
|
+
id: daysDescriptionId,
|
|
275
|
+
children: "Select at least one day."
|
|
276
|
+
}),
|
|
277
|
+
/* @__PURE__ */ jsx(CheckboxGroup, {
|
|
278
|
+
layout: "grid",
|
|
279
|
+
value: days,
|
|
280
|
+
"aria-describedby": `${daysDescriptionId}${daysError ? ` ${daysErrorId}` : ""}`,
|
|
281
|
+
"aria-invalid": daysError || void 0,
|
|
282
|
+
onValueChange: (nextDays) => {
|
|
283
|
+
setDays(nextDays);
|
|
284
|
+
if (nextDays.length > 0) setDaysError(false);
|
|
285
|
+
},
|
|
286
|
+
children: WEEKDAYS.map((day) => /* @__PURE__ */ jsxs(CheckboxGroup.Item, { children: [/* @__PURE__ */ jsx(CheckboxGroup.Icon, { children: /* @__PURE__ */ jsx(Checkbox.Root, {
|
|
287
|
+
ref: day.token === "mon" ? firstDayRef : void 0,
|
|
288
|
+
value: day.token,
|
|
289
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {})
|
|
290
|
+
}) }), /* @__PURE__ */ jsx(CheckboxGroup.Content, { children: /* @__PURE__ */ jsx(CheckboxGroup.Title, { children: day.label }) })] }, day.token))
|
|
291
|
+
}),
|
|
292
|
+
daysError ? /* @__PURE__ */ jsx(Field.Errors, {
|
|
293
|
+
id: daysErrorId,
|
|
294
|
+
errors: ["Select at least one day."]
|
|
295
|
+
}) : null
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function RoutineScriptFields({ scriptPath, setScriptPath, scriptsLoading, scriptsError, scripts, scriptOptions, table, selectedScript, scriptArgs, setArgument, retainedArgs }) {
|
|
300
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
301
|
+
/* @__PURE__ */ jsx(RoutineSelect, {
|
|
302
|
+
label: "Workflow",
|
|
303
|
+
value: scriptPath,
|
|
304
|
+
disabled: scriptsLoading,
|
|
305
|
+
options: [{
|
|
306
|
+
label: scriptsLoading ? "Loading workflows…" : "Choose a workflow",
|
|
307
|
+
value: ""
|
|
308
|
+
}, ...scriptOptions],
|
|
309
|
+
onValueChange: setScriptPath
|
|
310
|
+
}),
|
|
311
|
+
scriptsError ? /* @__PURE__ */ jsx(Field.Errors, { errors: [executionErrorSummary(scriptsError)] }) : null,
|
|
312
|
+
!scriptsLoading && !scriptsError && scripts.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
313
|
+
className: "think-routine__input-help",
|
|
314
|
+
children: "Ask Rook to create a workflow first."
|
|
315
|
+
}) : null,
|
|
316
|
+
/* @__PURE__ */ jsx(RoutineTableSource, {
|
|
317
|
+
table,
|
|
318
|
+
scripts
|
|
319
|
+
}),
|
|
320
|
+
selectedScript?.parameters.filter((parameter) => !table?.columns[parameter.name]).map((parameter) => /* @__PURE__ */ jsx(RoutineScriptParameter, {
|
|
321
|
+
parameter,
|
|
322
|
+
value: scriptArgs[parameter.name],
|
|
323
|
+
setArgument
|
|
324
|
+
}, parameter.name)),
|
|
325
|
+
Object.keys(retainedArgs).length > 0 ? /* @__PURE__ */ jsxs("details", {
|
|
326
|
+
className: "think-routine__saved-inputs",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ jsx("summary", { children: "Saved inputs" }),
|
|
329
|
+
/* @__PURE__ */ jsx(ExecutionResult, {
|
|
330
|
+
result: retainedArgs,
|
|
331
|
+
showSummary: false
|
|
332
|
+
}),
|
|
333
|
+
/* @__PURE__ */ jsx("p", {
|
|
334
|
+
className: "think-routine__input-help",
|
|
335
|
+
children: "These inputs are preserved. Ask Rook to change them."
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
}) : null
|
|
339
|
+
] });
|
|
340
|
+
}
|
|
341
|
+
function useRoutineSchedule(initialSchedule) {
|
|
342
|
+
const defaults = React.useMemo(() => scheduleDefaults(initialSchedule), [initialSchedule]);
|
|
343
|
+
const [scheduleKind, setScheduleKind] = React.useState(defaults.kind);
|
|
344
|
+
const [intervalEvery, setIntervalEvery] = React.useState(defaults.intervalEvery);
|
|
345
|
+
const [intervalUnit, setIntervalUnit] = React.useState(defaults.intervalUnit);
|
|
346
|
+
const [time, setTime] = React.useState(defaults.time);
|
|
347
|
+
const [timezone, setTimezone] = React.useState(defaults.timezone);
|
|
348
|
+
const [timezoneInput, setTimezoneInput] = React.useState(defaults.timezone);
|
|
349
|
+
const [days, setDays] = React.useState(defaults.days);
|
|
138
350
|
const [daysError, setDaysError] = React.useState(false);
|
|
139
351
|
const [timezoneError, setTimezoneError] = React.useState(false);
|
|
140
|
-
const [busy, setBusy] = React.useState(false);
|
|
141
|
-
const [error, setError] = React.useState(null);
|
|
142
|
-
const titleId = React.useId();
|
|
143
352
|
const timezoneLabelId = React.useId();
|
|
144
|
-
const timezoneDescriptionId = React.useId();
|
|
145
353
|
const timezoneErrorId = React.useId();
|
|
146
354
|
const intervalLabelId = React.useId();
|
|
147
355
|
const daysDescriptionId = React.useId();
|
|
@@ -157,28 +365,289 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
157
365
|
value: timezone
|
|
158
366
|
}, [availableTimezoneOptions, timezone]);
|
|
159
367
|
function value() {
|
|
160
|
-
if (
|
|
161
|
-
let schedule;
|
|
162
|
-
if (scheduleKind === "interval") {
|
|
163
|
-
if (!Number.isSafeInteger(intervalEvery) || (intervalEvery ?? 0) < 1) return null;
|
|
164
|
-
const every = intervalEvery;
|
|
165
|
-
schedule = `every ${every} ${intervalUnit}${every === 1 ? "" : "s"}`;
|
|
166
|
-
} else if (timezoneInput !== selectedTimezone.label) {
|
|
368
|
+
if (scheduleKind !== "interval" && timezoneInput !== selectedTimezone.label) {
|
|
167
369
|
setTimezoneError(true);
|
|
168
370
|
queueMicrotask(() => timezoneInputRef.current?.focus());
|
|
169
371
|
return null;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
372
|
+
}
|
|
373
|
+
if (scheduleKind === "weekly" && days.length === 0) {
|
|
374
|
+
setDaysError(true);
|
|
375
|
+
queueMicrotask(() => firstDayRef.current?.focus());
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
const schedule = serializeSchedule({
|
|
379
|
+
kind: scheduleKind,
|
|
380
|
+
intervalEvery,
|
|
381
|
+
intervalUnit,
|
|
382
|
+
time,
|
|
383
|
+
timezone,
|
|
384
|
+
days
|
|
385
|
+
});
|
|
386
|
+
if (!schedule) return null;
|
|
387
|
+
return schedule;
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
scheduleKind,
|
|
391
|
+
setScheduleKind,
|
|
392
|
+
intervalEvery,
|
|
393
|
+
setIntervalEvery,
|
|
394
|
+
intervalUnit,
|
|
395
|
+
setIntervalUnit,
|
|
396
|
+
time,
|
|
397
|
+
setTime,
|
|
398
|
+
setTimezone,
|
|
399
|
+
timezoneInput,
|
|
400
|
+
setTimezoneInput,
|
|
401
|
+
days,
|
|
402
|
+
setDays,
|
|
403
|
+
daysError,
|
|
404
|
+
setDaysError,
|
|
405
|
+
timezoneError,
|
|
406
|
+
setTimezoneError,
|
|
407
|
+
timezoneLabelId,
|
|
408
|
+
timezoneErrorId,
|
|
409
|
+
intervalLabelId,
|
|
410
|
+
daysDescriptionId,
|
|
411
|
+
daysErrorId,
|
|
412
|
+
firstDayRef,
|
|
413
|
+
timezoneInputRef,
|
|
414
|
+
availableTimezoneOptions,
|
|
415
|
+
selectedTimezone,
|
|
416
|
+
value
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function RoutineScheduleFields({ editor }) {
|
|
420
|
+
const { scheduleKind, setScheduleKind, intervalEvery, setIntervalEvery, intervalUnit, setIntervalUnit, time, setTime, setTimezone, timezoneInput, setTimezoneInput, days, setDays, daysError, setDaysError, timezoneError, setTimezoneError, timezoneLabelId, timezoneErrorId, intervalLabelId, daysDescriptionId, daysErrorId, firstDayRef, timezoneInputRef, availableTimezoneOptions, selectedTimezone } = editor;
|
|
421
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RoutineSelect, {
|
|
422
|
+
label: "Repeats",
|
|
423
|
+
value: scheduleKind,
|
|
424
|
+
options: SCHEDULE_KIND_OPTIONS,
|
|
425
|
+
onValueChange: setScheduleKind
|
|
426
|
+
}), scheduleKind === "interval" ? /* @__PURE__ */ jsxs("div", {
|
|
427
|
+
className: "think-routine__form-row",
|
|
428
|
+
children: [/* @__PURE__ */ jsxs(Field.Root, {
|
|
429
|
+
name: "interval",
|
|
430
|
+
children: [/* @__PURE__ */ jsx(Field.Label, {
|
|
431
|
+
id: intervalLabelId,
|
|
432
|
+
children: "Every"
|
|
433
|
+
}), /* @__PURE__ */ jsx(NumberField.Root, {
|
|
434
|
+
value: intervalEvery,
|
|
435
|
+
min: 1,
|
|
436
|
+
step: 1,
|
|
437
|
+
onValueChange: setIntervalEvery,
|
|
438
|
+
children: /* @__PURE__ */ jsxs(NumberField.Group, { children: [
|
|
439
|
+
/* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
440
|
+
"aria-label": "Decrease interval",
|
|
441
|
+
children: "−"
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx(NumberField.Input, {
|
|
444
|
+
name: "interval",
|
|
445
|
+
required: true,
|
|
446
|
+
"aria-labelledby": intervalLabelId
|
|
447
|
+
}),
|
|
448
|
+
/* @__PURE__ */ jsx(NumberField.Increment, {
|
|
449
|
+
"aria-label": "Increase interval",
|
|
450
|
+
children: "+"
|
|
451
|
+
})
|
|
452
|
+
] })
|
|
453
|
+
})]
|
|
454
|
+
}), /* @__PURE__ */ jsx(RoutineSelect, {
|
|
455
|
+
label: "Unit",
|
|
456
|
+
value: intervalUnit,
|
|
457
|
+
options: INTERVAL_UNIT_OPTIONS,
|
|
458
|
+
onValueChange: setIntervalUnit
|
|
459
|
+
})]
|
|
460
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [scheduleKind === "weekly" ? /* @__PURE__ */ jsx(RoutineWeeklyDays, {
|
|
461
|
+
days,
|
|
462
|
+
setDays,
|
|
463
|
+
daysError,
|
|
464
|
+
setDaysError,
|
|
465
|
+
daysDescriptionId,
|
|
466
|
+
daysErrorId,
|
|
467
|
+
firstDayRef
|
|
468
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
469
|
+
className: "think-routine__form-row",
|
|
470
|
+
children: [/* @__PURE__ */ jsxs(Field.Root, {
|
|
471
|
+
name: "time",
|
|
472
|
+
children: [
|
|
473
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "Time" }),
|
|
474
|
+
/* @__PURE__ */ jsx(Field.Control, {
|
|
475
|
+
name: "time",
|
|
476
|
+
type: "time",
|
|
477
|
+
value: time,
|
|
478
|
+
required: true,
|
|
479
|
+
onChange: (event) => setTime(event.currentTarget.value)
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsx(Field.Error, {
|
|
482
|
+
match: "valueMissing",
|
|
483
|
+
children: "Time is required"
|
|
484
|
+
})
|
|
485
|
+
]
|
|
486
|
+
}), /* @__PURE__ */ jsxs(Field.Root, {
|
|
487
|
+
name: "timezone",
|
|
488
|
+
invalid: timezoneError,
|
|
489
|
+
children: [
|
|
490
|
+
/* @__PURE__ */ jsx(Field.Label, {
|
|
491
|
+
id: timezoneLabelId,
|
|
492
|
+
children: "Time zone"
|
|
493
|
+
}),
|
|
494
|
+
/* @__PURE__ */ jsxs(Combobox.Root, {
|
|
495
|
+
items: availableTimezoneOptions,
|
|
496
|
+
value: selectedTimezone,
|
|
497
|
+
inputValue: timezoneInput,
|
|
498
|
+
onInputValueChange: (nextInput) => {
|
|
499
|
+
setTimezoneInput(nextInput);
|
|
500
|
+
if (nextInput === selectedTimezone.label) setTimezoneError(false);
|
|
501
|
+
},
|
|
502
|
+
onValueChange: (option) => {
|
|
503
|
+
if (!option) return;
|
|
504
|
+
setTimezone(option.value);
|
|
505
|
+
setTimezoneInput(option.label);
|
|
506
|
+
setTimezoneError(false);
|
|
507
|
+
},
|
|
508
|
+
children: [/* @__PURE__ */ jsxs(Combobox.InputGroup, { children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
509
|
+
ref: timezoneInputRef,
|
|
510
|
+
name: "timezone",
|
|
511
|
+
required: true,
|
|
512
|
+
"aria-invalid": timezoneError || void 0,
|
|
513
|
+
"aria-labelledby": timezoneLabelId,
|
|
514
|
+
"aria-describedby": timezoneError ? timezoneErrorId : void 0
|
|
515
|
+
}), /* @__PURE__ */ jsx(Combobox.Trigger, {
|
|
516
|
+
"aria-label": "Open time zone list",
|
|
517
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
518
|
+
})] }), /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
519
|
+
sideOffset: 4,
|
|
520
|
+
children: /* @__PURE__ */ jsxs(Combobox.Popup, { children: [/* @__PURE__ */ jsx(Combobox.List, { children: (option) => /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
521
|
+
value: option,
|
|
522
|
+
children: [/* @__PURE__ */ jsx(Combobox.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }), option.label]
|
|
523
|
+
}, option.value) }), /* @__PURE__ */ jsx(Combobox.Empty, { children: "No matching time zones." })] })
|
|
524
|
+
}) })]
|
|
525
|
+
}),
|
|
526
|
+
timezoneError ? /* @__PURE__ */ jsx(Field.Errors, {
|
|
527
|
+
id: timezoneErrorId,
|
|
528
|
+
errors: ["Select a valid time zone from the list."]
|
|
529
|
+
}) : null
|
|
530
|
+
]
|
|
531
|
+
})]
|
|
532
|
+
})] })] });
|
|
533
|
+
}
|
|
534
|
+
function useRoutineTask(routine, initialScript, scripts) {
|
|
535
|
+
const initialInvocation = routine ? "script" in routine.task ? routine.task.script : void 0 : initialScript;
|
|
536
|
+
const initialPath = initialInvocation?.path ?? "";
|
|
537
|
+
const [mode, setMode] = React.useState(initialPath ? "script" : "prompt");
|
|
538
|
+
const [prompt, setPrompt] = React.useState(routine && "prompt" in routine.task ? routine.task.prompt : "");
|
|
539
|
+
const [scriptPath, setScriptPath] = React.useState(initialPath);
|
|
540
|
+
const [argumentsByPath, setArgumentsByPath] = React.useState(() => initialInvocation ? { [initialInvocation.path]: initialInvocation.args ?? {} } : {});
|
|
541
|
+
const table = scriptPath === initialInvocation?.path ? initialInvocation.table : void 0;
|
|
542
|
+
const selectedScript = scripts.find((script) => script.path === scriptPath);
|
|
543
|
+
const scriptArgs = argumentsByPath[scriptPath] ?? {};
|
|
544
|
+
const scriptOptions = scripts.map((script) => ({
|
|
545
|
+
label: script.name,
|
|
546
|
+
value: script.path
|
|
547
|
+
}));
|
|
548
|
+
if (scriptPath && !selectedScript) scriptOptions.unshift({
|
|
549
|
+
label: "Saved workflow (unavailable)",
|
|
550
|
+
value: scriptPath
|
|
551
|
+
});
|
|
552
|
+
const retainedArgs = Object.fromEntries(Object.entries(scriptArgs).filter(([name, value]) => !selectedScript?.parameters.some((parameter) => parameter.name === name && typeof value === parameter.type)));
|
|
553
|
+
function setArgument(name, value) {
|
|
554
|
+
setArgumentsByPath((current) => {
|
|
555
|
+
const args = { ...current[scriptPath] };
|
|
556
|
+
if (value === void 0) delete args[name];
|
|
557
|
+
else args[name] = value;
|
|
558
|
+
return {
|
|
559
|
+
...current,
|
|
560
|
+
[scriptPath]: args
|
|
561
|
+
};
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function value() {
|
|
565
|
+
if (mode === "prompt") return prompt.trim() ? { prompt: prompt.trim() } : null;
|
|
566
|
+
if (!scriptPath.trim()) return null;
|
|
567
|
+
return { script: {
|
|
568
|
+
path: scriptPath,
|
|
569
|
+
args: scriptArgs,
|
|
570
|
+
...table ? { table } : {}
|
|
571
|
+
} };
|
|
572
|
+
}
|
|
573
|
+
return {
|
|
574
|
+
mode,
|
|
575
|
+
setMode,
|
|
576
|
+
prompt,
|
|
577
|
+
setPrompt,
|
|
578
|
+
scriptPath,
|
|
579
|
+
setScriptPath,
|
|
580
|
+
table,
|
|
581
|
+
selectedScript,
|
|
582
|
+
scriptArgs,
|
|
583
|
+
scriptOptions,
|
|
584
|
+
retainedArgs,
|
|
585
|
+
setArgument,
|
|
586
|
+
value
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function RoutineTaskFields({ task, scripts, scriptsLoading, scriptsError }) {
|
|
590
|
+
const { mode, setMode, prompt, setPrompt, scriptPath, setScriptPath, table, selectedScript, scriptArgs, scriptOptions, retainedArgs, setArgument } = task;
|
|
591
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RoutineSelect, {
|
|
592
|
+
label: "Run",
|
|
593
|
+
value: mode,
|
|
594
|
+
onValueChange: setMode,
|
|
595
|
+
options: [{
|
|
596
|
+
label: "Agent instructions",
|
|
597
|
+
value: "prompt"
|
|
598
|
+
}, {
|
|
599
|
+
label: "Saved workflow",
|
|
600
|
+
value: "script"
|
|
601
|
+
}]
|
|
602
|
+
}), mode === "script" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(RoutineScriptFields, {
|
|
603
|
+
scriptPath,
|
|
604
|
+
setScriptPath,
|
|
605
|
+
scriptsLoading,
|
|
606
|
+
scriptsError,
|
|
607
|
+
scripts,
|
|
608
|
+
scriptOptions,
|
|
609
|
+
table,
|
|
610
|
+
selectedScript,
|
|
611
|
+
scriptArgs,
|
|
612
|
+
setArgument,
|
|
613
|
+
retainedArgs
|
|
614
|
+
}) }) : /* @__PURE__ */ jsxs(Field.Root, {
|
|
615
|
+
name: "prompt",
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ jsx(Field.Label, { children: "Instructions" }),
|
|
618
|
+
/* @__PURE__ */ jsx(Field.Control, {
|
|
619
|
+
render: /* @__PURE__ */ jsx(Textarea, { rows: 8 }),
|
|
620
|
+
name: "prompt",
|
|
621
|
+
value: prompt,
|
|
622
|
+
required: true,
|
|
623
|
+
placeholder: "Review open pull requests, summarize blockers, and draft a concise project update.",
|
|
624
|
+
onChange: (event) => setPrompt(event.currentTarget.value)
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ jsx(Field.Error, {
|
|
627
|
+
match: "valueMissing",
|
|
628
|
+
children: "Instructions are required"
|
|
629
|
+
})
|
|
630
|
+
]
|
|
631
|
+
})] });
|
|
632
|
+
}
|
|
633
|
+
/** Create/edit surface for scheduled instructions or a saved workflow. */
|
|
634
|
+
function ThinkRoutineForm({ cancelLink, cancelLabel = "Back to schedules", className, routine, initialScript, scripts = [], scriptsLoading = false, scriptsError, onSubmit, ref, ...props }) {
|
|
635
|
+
const initialSchedule = routine?.parsedSchedule;
|
|
636
|
+
const editing = routine !== void 0;
|
|
637
|
+
const [name, setName] = React.useState(routine?.name ?? "");
|
|
638
|
+
const task = useRoutineTask(routine, initialScript, scripts);
|
|
639
|
+
const scheduleEditor = useRoutineSchedule(initialSchedule);
|
|
640
|
+
const [busy, setBusy] = React.useState(false);
|
|
641
|
+
const [error, setError] = React.useState(null);
|
|
642
|
+
function value() {
|
|
643
|
+
if (!name.trim()) return null;
|
|
644
|
+
const taskValue = task.value();
|
|
645
|
+
if (!taskValue) return null;
|
|
646
|
+
const schedule = scheduleEditor.value();
|
|
647
|
+
if (!schedule) return null;
|
|
179
648
|
return {
|
|
180
649
|
name: name.trim(),
|
|
181
|
-
|
|
650
|
+
...taskValue,
|
|
182
651
|
schedule
|
|
183
652
|
};
|
|
184
653
|
}
|
|
@@ -191,7 +660,7 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
191
660
|
try {
|
|
192
661
|
await onSubmit(nextValue);
|
|
193
662
|
} catch (nextError) {
|
|
194
|
-
setError(formatErrorMessage(nextError));
|
|
663
|
+
setError(executionErrorSummary(formatErrorMessage(nextError)));
|
|
195
664
|
} finally {
|
|
196
665
|
setBusy(false);
|
|
197
666
|
}
|
|
@@ -204,7 +673,7 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
204
673
|
/* @__PURE__ */ jsxs(AppTopBar.Root, {
|
|
205
674
|
"aria-label": "Schedule editor controls",
|
|
206
675
|
children: [cancelLink ? /* @__PURE__ */ jsx(AppTopBar.Leading, { children: /* @__PURE__ */ jsx(AppTopBar.Link, {
|
|
207
|
-
label:
|
|
676
|
+
label: cancelLabel,
|
|
208
677
|
render: cancelLink,
|
|
209
678
|
children: /* @__PURE__ */ jsx(ArrowLeftIcon, {})
|
|
210
679
|
}) }) : null, /* @__PURE__ */ jsx(AppTopBar.Title, { children: editing ? "Edit schedule" : "New schedule" })]
|
|
@@ -214,23 +683,10 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
214
683
|
role: "alert",
|
|
215
684
|
children: [/* @__PURE__ */ jsx(WarningIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", { children: error })]
|
|
216
685
|
}) : null,
|
|
217
|
-
/* @__PURE__ */
|
|
686
|
+
/* @__PURE__ */ jsx("main", {
|
|
218
687
|
className: "think-routine-form think-routine__create",
|
|
219
|
-
"aria-
|
|
220
|
-
children:
|
|
221
|
-
className: "think-routine__create-header",
|
|
222
|
-
children: /* @__PURE__ */ jsxs("div", { children: [
|
|
223
|
-
/* @__PURE__ */ jsx("p", {
|
|
224
|
-
className: "think-routine__eyebrow",
|
|
225
|
-
children: editing ? "Edit schedule" : "New schedule"
|
|
226
|
-
}),
|
|
227
|
-
/* @__PURE__ */ jsx("h1", {
|
|
228
|
-
id: titleId,
|
|
229
|
-
children: "What should run automatically?"
|
|
230
|
-
}),
|
|
231
|
-
/* @__PURE__ */ jsx("p", { children: "Each run starts a new conversation with these instructions." })
|
|
232
|
-
] })
|
|
233
|
-
}), /* @__PURE__ */ jsxs(Form, {
|
|
688
|
+
"aria-label": editing ? "Edit schedule" : "New schedule",
|
|
689
|
+
children: /* @__PURE__ */ jsxs(Form, {
|
|
234
690
|
className: "think-routine__form",
|
|
235
691
|
validationMode: "onBlur",
|
|
236
692
|
onSubmit: submit,
|
|
@@ -253,162 +709,13 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
253
709
|
})
|
|
254
710
|
]
|
|
255
711
|
}),
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
/* @__PURE__ */ jsx(Field.Control, {
|
|
262
|
-
render: /* @__PURE__ */ jsx(Textarea, { rows: 8 }),
|
|
263
|
-
name: "prompt",
|
|
264
|
-
value: prompt,
|
|
265
|
-
required: true,
|
|
266
|
-
placeholder: "Review open pull requests, summarize blockers, and draft a concise project update.",
|
|
267
|
-
onChange: (event) => setPrompt(event.currentTarget.value)
|
|
268
|
-
}),
|
|
269
|
-
/* @__PURE__ */ jsx(Field.Error, {
|
|
270
|
-
match: "valueMissing",
|
|
271
|
-
children: "Instructions are required"
|
|
272
|
-
})
|
|
273
|
-
]
|
|
274
|
-
}),
|
|
275
|
-
/* @__PURE__ */ jsx(RoutineSelect, {
|
|
276
|
-
label: "Repeats",
|
|
277
|
-
value: scheduleKind,
|
|
278
|
-
options: SCHEDULE_KIND_OPTIONS,
|
|
279
|
-
onValueChange: setScheduleKind
|
|
712
|
+
/* @__PURE__ */ jsx(RoutineTaskFields, {
|
|
713
|
+
task,
|
|
714
|
+
scripts,
|
|
715
|
+
scriptsLoading,
|
|
716
|
+
scriptsError
|
|
280
717
|
}),
|
|
281
|
-
|
|
282
|
-
className: "think-routine__form-row",
|
|
283
|
-
children: [/* @__PURE__ */ jsxs(Field.Root, {
|
|
284
|
-
name: "interval",
|
|
285
|
-
children: [/* @__PURE__ */ jsx(Field.Label, {
|
|
286
|
-
id: intervalLabelId,
|
|
287
|
-
children: "Every"
|
|
288
|
-
}), /* @__PURE__ */ jsx(NumberField.Root, {
|
|
289
|
-
value: intervalEvery,
|
|
290
|
-
min: 1,
|
|
291
|
-
step: 1,
|
|
292
|
-
onValueChange: setIntervalEvery,
|
|
293
|
-
children: /* @__PURE__ */ jsxs(NumberField.Group, { children: [
|
|
294
|
-
/* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
295
|
-
"aria-label": "Decrease interval",
|
|
296
|
-
children: "−"
|
|
297
|
-
}),
|
|
298
|
-
/* @__PURE__ */ jsx(NumberField.Input, {
|
|
299
|
-
name: "interval",
|
|
300
|
-
required: true,
|
|
301
|
-
"aria-labelledby": intervalLabelId
|
|
302
|
-
}),
|
|
303
|
-
/* @__PURE__ */ jsx(NumberField.Increment, {
|
|
304
|
-
"aria-label": "Increase interval",
|
|
305
|
-
children: "+"
|
|
306
|
-
})
|
|
307
|
-
] })
|
|
308
|
-
})]
|
|
309
|
-
}), /* @__PURE__ */ jsx(RoutineSelect, {
|
|
310
|
-
label: "Unit",
|
|
311
|
-
value: intervalUnit,
|
|
312
|
-
options: INTERVAL_UNIT_OPTIONS,
|
|
313
|
-
onValueChange: setIntervalUnit
|
|
314
|
-
})]
|
|
315
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [scheduleKind === "weekly" ? /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
316
|
-
variant: "plain",
|
|
317
|
-
children: [
|
|
318
|
-
/* @__PURE__ */ jsx(Fieldset.Legend, { children: "Days" }),
|
|
319
|
-
/* @__PURE__ */ jsx(Fieldset.Description, {
|
|
320
|
-
id: daysDescriptionId,
|
|
321
|
-
children: "Select at least one day."
|
|
322
|
-
}),
|
|
323
|
-
/* @__PURE__ */ jsx(CheckboxGroup, {
|
|
324
|
-
layout: "grid",
|
|
325
|
-
value: days,
|
|
326
|
-
"aria-describedby": `${daysDescriptionId}${daysError ? ` ${daysErrorId}` : ""}`,
|
|
327
|
-
"aria-invalid": daysError || void 0,
|
|
328
|
-
onValueChange: (nextDays) => {
|
|
329
|
-
setDays(nextDays);
|
|
330
|
-
if (nextDays.length > 0) setDaysError(false);
|
|
331
|
-
},
|
|
332
|
-
children: WEEKDAYS.map((day) => /* @__PURE__ */ jsxs(CheckboxGroup.Item, { children: [/* @__PURE__ */ jsx(CheckboxGroup.Icon, { children: /* @__PURE__ */ jsx(Checkbox.Root, {
|
|
333
|
-
ref: day.token === "mon" ? firstDayRef : void 0,
|
|
334
|
-
value: day.token,
|
|
335
|
-
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {})
|
|
336
|
-
}) }), /* @__PURE__ */ jsx(CheckboxGroup.Content, { children: /* @__PURE__ */ jsx(CheckboxGroup.Title, { children: day.label }) })] }, day.token))
|
|
337
|
-
}),
|
|
338
|
-
daysError ? /* @__PURE__ */ jsx(Field.Errors, {
|
|
339
|
-
id: daysErrorId,
|
|
340
|
-
errors: ["Select at least one day."]
|
|
341
|
-
}) : null
|
|
342
|
-
]
|
|
343
|
-
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
344
|
-
className: "think-routine__form-row",
|
|
345
|
-
children: [/* @__PURE__ */ jsxs(Field.Root, {
|
|
346
|
-
name: "time",
|
|
347
|
-
children: [
|
|
348
|
-
/* @__PURE__ */ jsx(Field.Label, { children: "Time" }),
|
|
349
|
-
/* @__PURE__ */ jsx(Field.Control, {
|
|
350
|
-
name: "time",
|
|
351
|
-
type: "time",
|
|
352
|
-
value: time,
|
|
353
|
-
required: true,
|
|
354
|
-
onChange: (event) => setTime(event.currentTarget.value)
|
|
355
|
-
}),
|
|
356
|
-
/* @__PURE__ */ jsx(Field.Error, {
|
|
357
|
-
match: "valueMissing",
|
|
358
|
-
children: "Time is required"
|
|
359
|
-
})
|
|
360
|
-
]
|
|
361
|
-
}), /* @__PURE__ */ jsxs(Field.Root, {
|
|
362
|
-
name: "timezone",
|
|
363
|
-
invalid: timezoneError,
|
|
364
|
-
children: [
|
|
365
|
-
/* @__PURE__ */ jsx(Field.Label, {
|
|
366
|
-
id: timezoneLabelId,
|
|
367
|
-
children: "Time zone"
|
|
368
|
-
}),
|
|
369
|
-
/* @__PURE__ */ jsx(Field.Description, {
|
|
370
|
-
id: timezoneDescriptionId,
|
|
371
|
-
children: "Search IANA zones, such as America/Chicago."
|
|
372
|
-
}),
|
|
373
|
-
/* @__PURE__ */ jsxs(Combobox.Root, {
|
|
374
|
-
items: availableTimezoneOptions,
|
|
375
|
-
value: selectedTimezone,
|
|
376
|
-
inputValue: timezoneInput,
|
|
377
|
-
onInputValueChange: (nextInput) => {
|
|
378
|
-
setTimezoneInput(nextInput);
|
|
379
|
-
if (nextInput === selectedTimezone.label) setTimezoneError(false);
|
|
380
|
-
},
|
|
381
|
-
onValueChange: (option) => {
|
|
382
|
-
if (!option) return;
|
|
383
|
-
setTimezone(option.value);
|
|
384
|
-
setTimezoneInput(option.label);
|
|
385
|
-
setTimezoneError(false);
|
|
386
|
-
},
|
|
387
|
-
children: [/* @__PURE__ */ jsxs(Combobox.InputGroup, { children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
388
|
-
ref: timezoneInputRef,
|
|
389
|
-
name: "timezone",
|
|
390
|
-
required: true,
|
|
391
|
-
"aria-invalid": timezoneError || void 0,
|
|
392
|
-
"aria-labelledby": timezoneLabelId,
|
|
393
|
-
"aria-describedby": `${timezoneDescriptionId}${timezoneError ? ` ${timezoneErrorId}` : ""}`
|
|
394
|
-
}), /* @__PURE__ */ jsx(Combobox.Trigger, {
|
|
395
|
-
"aria-label": "Open time zone list",
|
|
396
|
-
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
397
|
-
})] }), /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
398
|
-
sideOffset: 4,
|
|
399
|
-
children: /* @__PURE__ */ jsxs(Combobox.Popup, { children: [/* @__PURE__ */ jsx(Combobox.List, { children: (option) => /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
400
|
-
value: option,
|
|
401
|
-
children: [/* @__PURE__ */ jsx(Combobox.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }), option.label]
|
|
402
|
-
}, option.value) }), /* @__PURE__ */ jsx(Combobox.Empty, { children: "No matching time zones." })] })
|
|
403
|
-
}) })]
|
|
404
|
-
}),
|
|
405
|
-
timezoneError ? /* @__PURE__ */ jsx(Field.Errors, {
|
|
406
|
-
id: timezoneErrorId,
|
|
407
|
-
errors: ["Select a valid time zone from the list."]
|
|
408
|
-
}) : null
|
|
409
|
-
]
|
|
410
|
-
})]
|
|
411
|
-
})] })
|
|
718
|
+
/* @__PURE__ */ jsx(RoutineScheduleFields, { editor: scheduleEditor })
|
|
412
719
|
] }), /* @__PURE__ */ jsxs("footer", {
|
|
413
720
|
className: "think-routine__form-actions",
|
|
414
721
|
children: [cancelLink ? /* @__PURE__ */ jsx(Button, {
|
|
@@ -420,7 +727,7 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
420
727
|
children: "Cancel"
|
|
421
728
|
}) : null, /* @__PURE__ */ jsxs(Button, {
|
|
422
729
|
type: "submit",
|
|
423
|
-
disabled: busy,
|
|
730
|
+
disabled: busy || task.mode === "script" && !task.scriptPath,
|
|
424
731
|
children: [
|
|
425
732
|
busy ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : null,
|
|
426
733
|
" ",
|
|
@@ -428,7 +735,7 @@ function ThinkRoutineForm({ cancelLink, className, routine, onSubmit, ref, ...pr
|
|
|
428
735
|
]
|
|
429
736
|
})]
|
|
430
737
|
})]
|
|
431
|
-
})
|
|
738
|
+
})
|
|
432
739
|
})
|
|
433
740
|
]
|
|
434
741
|
});
|