@spencerboucher/switchyard 0.25.0 → 0.26.0
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 +1 -1
- package/dist/bridge/switchyard-terminal.js +16 -0
- package/dist/catalog/worker.js +27 -3
- package/dist/policies/worker.js +27 -3
- package/dist/switchyard.mjs +123 -10
- package/package.json +1 -1
- package/web-dist/assets/{AutomationView-I80YGJ3M.js → AutomationView-BdmWs08y.js} +2 -2
- package/web-dist/assets/{AutomationView-I80YGJ3M.js.map → AutomationView-BdmWs08y.js.map} +1 -1
- package/web-dist/assets/{Checkbox-BdFQsqCG.js → Checkbox-9KyxtvcL.js} +2 -2
- package/web-dist/assets/{Checkbox-BdFQsqCG.js.map → Checkbox-9KyxtvcL.js.map} +1 -1
- package/web-dist/assets/{DangerZone-C6qU1pp7.js → DangerZone-CT2xbMEx.js} +2 -2
- package/web-dist/assets/{DangerZone-C6qU1pp7.js.map → DangerZone-CT2xbMEx.js.map} +1 -1
- package/web-dist/assets/{Field-DGV7eljt.js → Field-D4UpWJFx.js} +2 -2
- package/web-dist/assets/{Field-DGV7eljt.js.map → Field-D4UpWJFx.js.map} +1 -1
- package/web-dist/assets/{NavigationEditor-COtm2NQY.js → NavigationEditor-CcxVgkiR.js} +2 -2
- package/web-dist/assets/{NavigationEditor-COtm2NQY.js.map → NavigationEditor-CcxVgkiR.js.map} +1 -1
- package/web-dist/assets/{Overlay-hRkfpjK4.js → Overlay-Cfm4AZk1.js} +2 -2
- package/web-dist/assets/{Overlay-hRkfpjK4.js.map → Overlay-Cfm4AZk1.js.map} +1 -1
- package/web-dist/assets/{Priority-DL3f-tRD.js → Priority-DBLBg1FP.js} +2 -2
- package/web-dist/assets/{Priority-DL3f-tRD.js.map → Priority-DBLBg1FP.js.map} +1 -1
- package/web-dist/assets/{RadioCards-9YvqB3va.js → RadioCards-DoHz_a-g.js} +2 -2
- package/web-dist/assets/{RadioCards-9YvqB3va.js.map → RadioCards-DoHz_a-g.js.map} +1 -1
- package/web-dist/assets/{ScopeRepository-BPiPUjHi.js → ScopeRepository-Cg1lXFrM.js} +2 -2
- package/web-dist/assets/{ScopeRepository-BPiPUjHi.js.map → ScopeRepository-Cg1lXFrM.js.map} +1 -1
- package/web-dist/assets/{ScopeSelect-DmWCXeIf.js → ScopeSelect-DkEghnwv.js} +2 -2
- package/web-dist/assets/{ScopeSelect-DmWCXeIf.js.map → ScopeSelect-DkEghnwv.js.map} +1 -1
- package/web-dist/assets/{SegmentedControl-CefWecy1.js → SegmentedControl-D6SGXg_K.js} +2 -2
- package/web-dist/assets/{SegmentedControl-CefWecy1.js.map → SegmentedControl-D6SGXg_K.js.map} +1 -1
- package/web-dist/assets/{Select-CdANXO3X.js → Select-D41sYIWt.js} +2 -2
- package/web-dist/assets/{Select-CdANXO3X.js.map → Select-D41sYIWt.js.map} +1 -1
- package/web-dist/assets/{StructuredValue-BjKzgQDM.js → StructuredValue-aIPp-NIc.js} +3 -3
- package/web-dist/assets/{StructuredValue-BjKzgQDM.js.map → StructuredValue-aIPp-NIc.js.map} +1 -1
- package/web-dist/assets/{Switch-DrrWalaQ.js → Switch-D6hfPoPE.js} +2 -2
- package/web-dist/assets/{Switch-DrrWalaQ.js.map → Switch-D6hfPoPE.js.map} +1 -1
- package/web-dist/assets/{Tabs-Cvyw8P4s.js → Tabs-CRXYaXG7.js} +2 -2
- package/web-dist/assets/{Tabs-Cvyw8P4s.js.map → Tabs-CRXYaXG7.js.map} +1 -1
- package/web-dist/assets/{TextLink-DMi_ZI43.js → TextLink-DWXZwPZa.js} +2 -2
- package/web-dist/assets/{TextLink-DMi_ZI43.js.map → TextLink-DWXZwPZa.js.map} +1 -1
- package/web-dist/assets/{UINodeRenderer-CDPAUIOO.js → UINodeRenderer-BVjIBets.js} +3 -3
- package/web-dist/assets/UINodeRenderer-BVjIBets.js.map +1 -0
- package/web-dist/assets/{UnfilteredNote-CgsOTad1.js → UnfilteredNote-B7TY047m.js} +2 -2
- package/web-dist/assets/{UnfilteredNote-CgsOTad1.js.map → UnfilteredNote-B7TY047m.js.map} +1 -1
- package/web-dist/assets/{api-Dlk6L3Cu.js → api-C_h6nq6d.js} +2 -2
- package/web-dist/assets/{api-Dlk6L3Cu.js.map → api-C_h6nq6d.js.map} +1 -1
- package/web-dist/assets/{arrow-down-Cc6k_L7W.js → arrow-down-1LTpTi1H.js} +2 -2
- package/web-dist/assets/{arrow-down-Cc6k_L7W.js.map → arrow-down-1LTpTi1H.js.map} +1 -1
- package/web-dist/assets/{arrow-up-CW1a5Bhp.js → arrow-up-B4uK6ZGO.js} +2 -2
- package/web-dist/assets/{arrow-up-CW1a5Bhp.js.map → arrow-up-B4uK6ZGO.js.map} +1 -1
- package/web-dist/assets/{attention-AZ2a-mzO.js → attention--3lxyvUR.js} +2 -2
- package/web-dist/assets/{attention-AZ2a-mzO.js.map → attention--3lxyvUR.js.map} +1 -1
- package/web-dist/assets/{auth-Dzip9fVv.js → auth-BnOZcMwb.js} +2 -2
- package/web-dist/assets/{auth-Dzip9fVv.js.map → auth-BnOZcMwb.js.map} +1 -1
- package/web-dist/assets/{automations-BYFgPSs2.js → automations-D-OXGU7s.js} +2 -2
- package/web-dist/assets/{automations-BYFgPSs2.js.map → automations-D-OXGU7s.js.map} +1 -1
- package/web-dist/assets/{board-D2LALQcR.js → board-B2hNZFQA.js} +2 -2
- package/web-dist/assets/{board-D2LALQcR.js.map → board-B2hNZFQA.js.map} +1 -1
- package/web-dist/assets/{calendar-clock-CkYP2-Qf.js → calendar-clock-BPYJQFbH.js} +2 -2
- package/web-dist/assets/{calendar-clock-CkYP2-Qf.js.map → calendar-clock-BPYJQFbH.js.map} +1 -1
- package/web-dist/assets/chevron-right-CmbmRUFj.js +2 -0
- package/web-dist/assets/{chevron-right-Q-RTE0ar.js.map → chevron-right-CmbmRUFj.js.map} +1 -1
- package/web-dist/assets/code-wpUFOdpF.js +24 -0
- package/web-dist/assets/code-wpUFOdpF.js.map +1 -0
- package/web-dist/assets/{core.esm-yL4bmFrt.js → core.esm-kWS8EOvg.js} +2 -2
- package/web-dist/assets/{core.esm-yL4bmFrt.js.map → core.esm-kWS8EOvg.js.map} +1 -1
- package/web-dist/assets/{describe-B1R7Rpb3.js → describe-C6HLxXjb.js} +2 -2
- package/web-dist/assets/{describe-B1R7Rpb3.js.map → describe-C6HLxXjb.js.map} +1 -1
- package/web-dist/assets/{enroll-BJIkw0lm.js → enroll-ErV_s7ej.js} +2 -2
- package/web-dist/assets/{enroll-BJIkw0lm.js.map → enroll-ErV_s7ej.js.map} +1 -1
- package/web-dist/assets/{external-link-BHZxy4tb.js → external-link-fqMZHNsZ.js} +2 -2
- package/web-dist/assets/{external-link-BHZxy4tb.js.map → external-link-fqMZHNsZ.js.map} +1 -1
- package/web-dist/assets/{git-branch-C5Xwi6aW.js → git-branch-Bss2qoIr.js} +2 -2
- package/web-dist/assets/{git-branch-C5Xwi6aW.js.map → git-branch-Bss2qoIr.js.map} +1 -1
- package/web-dist/assets/{grip-vertical-kzr2x5pf.js → grip-vertical-DiopZ2MX.js} +2 -2
- package/web-dist/assets/{grip-vertical-kzr2x5pf.js.map → grip-vertical-DiopZ2MX.js.map} +1 -1
- package/web-dist/assets/{hand-DStB4fR7.js → hand-fz9o4rRo.js} +2 -2
- package/web-dist/assets/{hand-DStB4fR7.js.map → hand-fz9o4rRo.js.map} +1 -1
- package/web-dist/assets/{index-D3WBnjbc.js → index-BHIBqflQ.js} +4 -4
- package/web-dist/assets/{index-D3WBnjbc.js.map → index-BHIBqflQ.js.map} +1 -1
- package/web-dist/assets/index-CJ9yttLk.css +2 -0
- package/web-dist/assets/{link-2-Cny9mRKW.js → link-2-CM14Jk-Z.js} +2 -2
- package/web-dist/assets/{link-2-Cny9mRKW.js.map → link-2-CM14Jk-Z.js.map} +1 -1
- package/web-dist/assets/{logic-BOdOYgZ4.js → logic-C4E3wcuR.js} +2 -2
- package/web-dist/assets/{logic-BOdOYgZ4.js.map → logic-C4E3wcuR.js.map} +1 -1
- package/web-dist/assets/{logic-CHh1lc3G.js → logic-CxNUn_Si.js} +2 -2
- package/web-dist/assets/{logic-CHh1lc3G.js.map → logic-CxNUn_Si.js.map} +1 -1
- package/web-dist/assets/{more-BrHzsSfh.js → more-DPa20EIw.js} +2 -2
- package/web-dist/assets/{more-BrHzsSfh.js.map → more-DPa20EIw.js.map} +1 -1
- package/web-dist/assets/{pencil-BmHgPcCk.js → pencil-C7o6vJgq.js} +2 -2
- package/web-dist/assets/{pencil-BmHgPcCk.js.map → pencil-C7o6vJgq.js.map} +1 -1
- package/web-dist/assets/{play-Dul6ZDzY.js → play-CFs0JI3B.js} +2 -2
- package/web-dist/assets/{play-Dul6ZDzY.js.map → play-CFs0JI3B.js.map} +1 -1
- package/web-dist/assets/{plus-DzBRN9tc.js → plus-DEaNWSMA.js} +2 -2
- package/web-dist/assets/{plus-DzBRN9tc.js.map → plus-DEaNWSMA.js.map} +1 -1
- package/web-dist/assets/{policyLogic-DVorBdH6.js → policyLogic-1QWs7S1X.js} +2 -2
- package/web-dist/assets/{policyLogic-DVorBdH6.js.map → policyLogic-1QWs7S1X.js.map} +1 -1
- package/web-dist/assets/{prefs-CUMuH2EM.js → prefs-C0L6OJW2.js} +2 -2
- package/web-dist/assets/{prefs-CUMuH2EM.js.map → prefs-C0L6OJW2.js.map} +1 -1
- package/web-dist/assets/{preload-helper-vwPq19u5.js → preload-helper-B7-Z6Kuc.js} +2 -2
- package/web-dist/assets/{preload-helper-vwPq19u5.js.map → preload-helper-B7-Z6Kuc.js.map} +1 -1
- package/web-dist/assets/{queue-hRZWM_pM.js → queue-BGH7kGf3.js} +2 -2
- package/web-dist/assets/{queue-hRZWM_pM.js.map → queue-BGH7kGf3.js.map} +1 -1
- package/web-dist/assets/{rotate-ccw-ByDiAA6o.js → rotate-ccw-7XsjGljp.js} +2 -2
- package/web-dist/assets/{rotate-ccw-ByDiAA6o.js.map → rotate-ccw-7XsjGljp.js.map} +1 -1
- package/web-dist/assets/{search-DarT116I.js → search-cJqErX2K.js} +2 -2
- package/web-dist/assets/{search-DarT116I.js.map → search-cJqErX2K.js.map} +1 -1
- package/web-dist/assets/{settings-DHfdrqxv.js → settings-BWvrxYxe.js} +2 -2
- package/web-dist/assets/settings-BWvrxYxe.js.map +1 -0
- package/web-dist/assets/{states-hcvSpyb1.js → states-BtAXMBKP.js} +5 -5
- package/web-dist/assets/states-BtAXMBKP.js.map +1 -0
- package/web-dist/assets/{terminal-BmpsRI95.js → terminal-CMO1fwr6.js} +2 -2
- package/web-dist/assets/{terminal-BmpsRI95.js.map → terminal-CMO1fwr6.js.map} +1 -1
- package/web-dist/assets/{terminal-login-COaZPzQx.js → terminal-login-B4ilxY0w.js} +2 -2
- package/web-dist/assets/{terminal-login-COaZPzQx.js.map → terminal-login-B4ilxY0w.js.map} +1 -1
- package/web-dist/assets/{useBreakpoint-CXotoLeq.js → useBreakpoint-DQmHoUda.js} +2 -2
- package/web-dist/assets/{useBreakpoint-CXotoLeq.js.map → useBreakpoint-DQmHoUda.js.map} +1 -1
- package/web-dist/assets/{useNow-BweXkeWc.js → useNow-DAkRYkgZ.js} +2 -2
- package/web-dist/assets/{useNow-BweXkeWc.js.map → useNow-DAkRYkgZ.js.map} +1 -1
- package/web-dist/assets/{useResource-DAMkbbuf.js → useResource-BYljUzPs.js} +2 -2
- package/web-dist/assets/{useResource-DAMkbbuf.js.map → useResource-BYljUzPs.js.map} +1 -1
- package/web-dist/assets/{useSwipeTabs-3qLCxSS7.js → useSwipeTabs-DEx87Ogc.js} +2 -2
- package/web-dist/assets/{useSwipeTabs-3qLCxSS7.js.map → useSwipeTabs-DEx87Ogc.js.map} +1 -1
- package/web-dist/assets/{workboard-BEcRsjyQ.js → workboard-6c73HyIJ.js} +2 -2
- package/web-dist/assets/{workboard-BEcRsjyQ.js.map → workboard-6c73HyIJ.js.map} +1 -1
- package/web-dist/index.html +8 -8
- package/web-dist/sw.js +1 -1
- package/web-dist/assets/UINodeRenderer-CDPAUIOO.js.map +0 -1
- package/web-dist/assets/chevron-right-Q-RTE0ar.js +0 -2
- package/web-dist/assets/code-BuAtgr-5.js +0 -24
- package/web-dist/assets/code-BuAtgr-5.js.map +0 -1
- package/web-dist/assets/index-Bm6tklht.css +0 -2
- package/web-dist/assets/settings-DHfdrqxv.js.map +0 -1
- package/web-dist/assets/states-hcvSpyb1.js.map +0 -1
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ switchyard up
|
|
|
134
134
|
```sh
|
|
135
135
|
docker run -d --name switchyard -p 127.0.0.1:7400:7400 -v switchyard-data:/data \
|
|
136
136
|
-e SWITCHYARD_PUBLIC_URL=https://switchyard.example.com \
|
|
137
|
-
ghcr.io/justmytwospence/switchyard:0.
|
|
137
|
+
ghcr.io/justmytwospence/switchyard:0.26.0
|
|
138
138
|
# Single sign-on is required off localhost: see docs/auth.md
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -35,6 +35,7 @@ import { installPolicyHooks } from "./policy.js";
|
|
|
35
35
|
import { resourceSnapshot } from "./resource-snapshot.js";
|
|
36
36
|
import { shortSocketPath } from "./socket-paths.js";
|
|
37
37
|
const PATCHED = Symbol.for("switchyard.terminal");
|
|
38
|
+
const ENTRIES_PATCHED = Symbol.for("switchyard.terminal.entriesPatched");
|
|
38
39
|
const WRAPPED = Symbol.for("switchyard.terminal.wrapped");
|
|
39
40
|
const REMOTE_UI_CHANNEL = "switchyard.remote-ui.v1";
|
|
40
41
|
/** Set while one copy of this extension is active in the process (a global shim plus `-e`). */
|
|
@@ -1046,6 +1047,21 @@ export default function switchyardTerminal(pi) {
|
|
|
1046
1047
|
// RPC or an older Pi: no completions
|
|
1047
1048
|
}
|
|
1048
1049
|
entryCount = c.sessionManager.getEntries().length;
|
|
1050
|
+
try {
|
|
1051
|
+
const sm = c.sessionManager;
|
|
1052
|
+
if (sm && typeof sm.appendCustomEntry === "function" && !sm[ENTRIES_PATCHED]) {
|
|
1053
|
+
const origAppend = sm.appendCustomEntry;
|
|
1054
|
+
sm.appendCustomEntry = (...args) => {
|
|
1055
|
+
const r = origAppend.apply(sm, args);
|
|
1056
|
+
flushEntries();
|
|
1057
|
+
return r;
|
|
1058
|
+
};
|
|
1059
|
+
Object.defineProperty(sm, ENTRIES_PATCHED, { value: true });
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
catch {
|
|
1063
|
+
// ignore
|
|
1064
|
+
}
|
|
1049
1065
|
const sessionId = c.sessionManager.getSessionId();
|
|
1050
1066
|
const sessionFile = c.sessionManager.getSessionFile() ?? null;
|
|
1051
1067
|
hello();
|
package/dist/catalog/worker.js
CHANGED
|
@@ -158,10 +158,14 @@ var UINodeSchema = z2.lazy(() => z2.discriminatedUnion("t", [
|
|
|
158
158
|
}),
|
|
159
159
|
z2.object({
|
|
160
160
|
t: z2.literal("actions"),
|
|
161
|
+
label: z2.string().min(1).max(80).optional(),
|
|
162
|
+
layout: z2.enum(["row", "segmented"]).optional(),
|
|
161
163
|
actions: z2.array(z2.object({
|
|
162
164
|
id: z2.string(),
|
|
163
165
|
label: z2.string(),
|
|
164
|
-
tone: z2.enum(["default", "primary", "danger"]).optional()
|
|
166
|
+
tone: z2.enum(["default", "primary", "danger"]).optional(),
|
|
167
|
+
active: z2.boolean().optional(),
|
|
168
|
+
disabled: z2.boolean().optional()
|
|
165
169
|
}))
|
|
166
170
|
}),
|
|
167
171
|
z2.object({
|
|
@@ -239,6 +243,8 @@ var ContributionPlacement = z3.enum([
|
|
|
239
243
|
"composer.pill",
|
|
240
244
|
/** `adapter.trackers.v1`: a live summary above the input that opens its detail. */
|
|
241
245
|
"composer.tracker",
|
|
246
|
+
/** `composer.suggestions.v1`: an editable next-prompt or command suggestion in the composer. */
|
|
247
|
+
"composer.suggestion",
|
|
242
248
|
/** `adapter.trackers.v1`: a short word on the session's navigator row. */
|
|
243
249
|
"session.badge",
|
|
244
250
|
"palette.item",
|
|
@@ -254,11 +260,18 @@ var TrackerSummary = z3.object({
|
|
|
254
260
|
/** The step in progress, such as the current todo. */
|
|
255
261
|
step: z3.string().min(1).max(120).optional()
|
|
256
262
|
}).strict();
|
|
263
|
+
var ComposerSuggestion = z3.object({
|
|
264
|
+
/** Exact text inserted into the composer when accepted (never auto-sent). */
|
|
265
|
+
text: z3.string().min(1).max(4e3),
|
|
266
|
+
/** Presentation hint (default "prompt"). */
|
|
267
|
+
kind: z3.enum(["prompt", "command"]).optional()
|
|
268
|
+
}).strict();
|
|
257
269
|
var Common = {
|
|
258
270
|
placement: ContributionPlacement,
|
|
259
271
|
order: z3.number().int().min(-1e3).max(1e3).optional(),
|
|
260
272
|
actionId: ActionId.optional(),
|
|
261
|
-
tracker: TrackerSummary.optional()
|
|
273
|
+
tracker: TrackerSummary.optional(),
|
|
274
|
+
suggestion: ComposerSuggestion.optional()
|
|
262
275
|
};
|
|
263
276
|
var ContributionDescriptor = z3.object({
|
|
264
277
|
id: Id,
|
|
@@ -287,6 +300,12 @@ var ContributionDescriptor = z3.object({
|
|
|
287
300
|
if (v.placement !== "composer.tracker" && v.tracker !== void 0) {
|
|
288
301
|
ctx.addIssue({ code: "custom", message: "Only composer trackers have a tracker summary" });
|
|
289
302
|
}
|
|
303
|
+
if (v.placement === "composer.suggestion" && !v.suggestion) {
|
|
304
|
+
ctx.addIssue({ code: "custom", message: "Composer suggestions require a suggestion" });
|
|
305
|
+
}
|
|
306
|
+
if (v.placement !== "composer.suggestion" && v.suggestion !== void 0) {
|
|
307
|
+
ctx.addIssue({ code: "custom", message: "Only composer suggestions have a suggestion" });
|
|
308
|
+
}
|
|
290
309
|
});
|
|
291
310
|
var ContributionInput = z3.object({
|
|
292
311
|
...Common,
|
|
@@ -374,6 +393,9 @@ function validateContribution(id, input) {
|
|
|
374
393
|
if (descriptor.placement === "composer.pill" && node.t !== "text" && node.t !== "progress") {
|
|
375
394
|
throw new Error("Composer pill content must be text or progress");
|
|
376
395
|
}
|
|
396
|
+
if (descriptor.placement === "composer.suggestion" && node.t !== "text" && node.t !== "code") {
|
|
397
|
+
throw new Error("Composer suggestion content must be text or code");
|
|
398
|
+
}
|
|
377
399
|
if (descriptor.placement === "session.badge") {
|
|
378
400
|
if (node.t !== "text" && node.t !== "badge") {
|
|
379
401
|
throw new Error("Session badge content must be text or a badge");
|
|
@@ -2938,7 +2960,9 @@ var CLIENT_CAPABILITIES = [
|
|
|
2938
2960
|
/** The client draws checklist, facts, rows and badge nodes, `section.open` and URL refs. */
|
|
2939
2961
|
"ui.nodes.v2",
|
|
2940
2962
|
/** The client draws `composer.tracker` and `session.badge` contributions. */
|
|
2941
|
-
"adapter.trackers.v1"
|
|
2963
|
+
"adapter.trackers.v1",
|
|
2964
|
+
/** The client draws `composer.suggestion` contributions in the composer. */
|
|
2965
|
+
"composer.suggestions.v1"
|
|
2942
2966
|
];
|
|
2943
2967
|
var ClientToServer = z15.discriminatedUnion("type", [
|
|
2944
2968
|
z15.object({
|
package/dist/policies/worker.js
CHANGED
|
@@ -162,10 +162,14 @@ var UINodeSchema = z2.lazy(() => z2.discriminatedUnion("t", [
|
|
|
162
162
|
}),
|
|
163
163
|
z2.object({
|
|
164
164
|
t: z2.literal("actions"),
|
|
165
|
+
label: z2.string().min(1).max(80).optional(),
|
|
166
|
+
layout: z2.enum(["row", "segmented"]).optional(),
|
|
165
167
|
actions: z2.array(z2.object({
|
|
166
168
|
id: z2.string(),
|
|
167
169
|
label: z2.string(),
|
|
168
|
-
tone: z2.enum(["default", "primary", "danger"]).optional()
|
|
170
|
+
tone: z2.enum(["default", "primary", "danger"]).optional(),
|
|
171
|
+
active: z2.boolean().optional(),
|
|
172
|
+
disabled: z2.boolean().optional()
|
|
169
173
|
}))
|
|
170
174
|
}),
|
|
171
175
|
z2.object({
|
|
@@ -243,6 +247,8 @@ var ContributionPlacement = z3.enum([
|
|
|
243
247
|
"composer.pill",
|
|
244
248
|
/** `adapter.trackers.v1`: a live summary above the input that opens its detail. */
|
|
245
249
|
"composer.tracker",
|
|
250
|
+
/** `composer.suggestions.v1`: an editable next-prompt or command suggestion in the composer. */
|
|
251
|
+
"composer.suggestion",
|
|
246
252
|
/** `adapter.trackers.v1`: a short word on the session's navigator row. */
|
|
247
253
|
"session.badge",
|
|
248
254
|
"palette.item",
|
|
@@ -258,11 +264,18 @@ var TrackerSummary = z3.object({
|
|
|
258
264
|
/** The step in progress, such as the current todo. */
|
|
259
265
|
step: z3.string().min(1).max(120).optional()
|
|
260
266
|
}).strict();
|
|
267
|
+
var ComposerSuggestion = z3.object({
|
|
268
|
+
/** Exact text inserted into the composer when accepted (never auto-sent). */
|
|
269
|
+
text: z3.string().min(1).max(4e3),
|
|
270
|
+
/** Presentation hint (default "prompt"). */
|
|
271
|
+
kind: z3.enum(["prompt", "command"]).optional()
|
|
272
|
+
}).strict();
|
|
261
273
|
var Common = {
|
|
262
274
|
placement: ContributionPlacement,
|
|
263
275
|
order: z3.number().int().min(-1e3).max(1e3).optional(),
|
|
264
276
|
actionId: ActionId.optional(),
|
|
265
|
-
tracker: TrackerSummary.optional()
|
|
277
|
+
tracker: TrackerSummary.optional(),
|
|
278
|
+
suggestion: ComposerSuggestion.optional()
|
|
266
279
|
};
|
|
267
280
|
var ContributionDescriptor = z3.object({
|
|
268
281
|
id: Id,
|
|
@@ -291,6 +304,12 @@ var ContributionDescriptor = z3.object({
|
|
|
291
304
|
if (v.placement !== "composer.tracker" && v.tracker !== void 0) {
|
|
292
305
|
ctx.addIssue({ code: "custom", message: "Only composer trackers have a tracker summary" });
|
|
293
306
|
}
|
|
307
|
+
if (v.placement === "composer.suggestion" && !v.suggestion) {
|
|
308
|
+
ctx.addIssue({ code: "custom", message: "Composer suggestions require a suggestion" });
|
|
309
|
+
}
|
|
310
|
+
if (v.placement !== "composer.suggestion" && v.suggestion !== void 0) {
|
|
311
|
+
ctx.addIssue({ code: "custom", message: "Only composer suggestions have a suggestion" });
|
|
312
|
+
}
|
|
294
313
|
});
|
|
295
314
|
var ContributionInput = z3.object({
|
|
296
315
|
...Common,
|
|
@@ -378,6 +397,9 @@ function validateContribution(id, input) {
|
|
|
378
397
|
if (descriptor.placement === "composer.pill" && node.t !== "text" && node.t !== "progress") {
|
|
379
398
|
throw new Error("Composer pill content must be text or progress");
|
|
380
399
|
}
|
|
400
|
+
if (descriptor.placement === "composer.suggestion" && node.t !== "text" && node.t !== "code") {
|
|
401
|
+
throw new Error("Composer suggestion content must be text or code");
|
|
402
|
+
}
|
|
381
403
|
if (descriptor.placement === "session.badge") {
|
|
382
404
|
if (node.t !== "text" && node.t !== "badge") {
|
|
383
405
|
throw new Error("Session badge content must be text or a badge");
|
|
@@ -2930,7 +2952,9 @@ var CLIENT_CAPABILITIES = [
|
|
|
2930
2952
|
/** The client draws checklist, facts, rows and badge nodes, `section.open` and URL refs. */
|
|
2931
2953
|
"ui.nodes.v2",
|
|
2932
2954
|
/** The client draws `composer.tracker` and `session.badge` contributions. */
|
|
2933
|
-
"adapter.trackers.v1"
|
|
2955
|
+
"adapter.trackers.v1",
|
|
2956
|
+
/** The client draws `composer.suggestion` contributions in the composer. */
|
|
2957
|
+
"composer.suggestions.v1"
|
|
2934
2958
|
];
|
|
2935
2959
|
var ClientToServer = z15.discriminatedUnion("type", [
|
|
2936
2960
|
z15.object({
|
package/dist/switchyard.mjs
CHANGED
|
@@ -159,6 +159,15 @@ function downgradeUINode(node2) {
|
|
|
159
159
|
};
|
|
160
160
|
case "badge":
|
|
161
161
|
return text(node2.text, node2.tone);
|
|
162
|
+
case "actions": {
|
|
163
|
+
const hasNew = node2.label !== void 0 || node2.layout !== void 0 || node2.actions.some((a) => a.active !== void 0 || a.disabled !== void 0);
|
|
164
|
+
if (!hasNew)
|
|
165
|
+
return node2;
|
|
166
|
+
return {
|
|
167
|
+
t: "actions",
|
|
168
|
+
actions: node2.actions.map(({ id, label, tone }) => tone !== void 0 ? { id, label, tone } : { id, label })
|
|
169
|
+
};
|
|
170
|
+
}
|
|
162
171
|
case "ref":
|
|
163
172
|
return node2.ref.kind === "url" ? text(node2.label ? `${node2.label}: ${node2.ref.url}` : node2.ref.url) : node2;
|
|
164
173
|
case "list": {
|
|
@@ -289,10 +298,14 @@ var init_ui = __esm({
|
|
|
289
298
|
}),
|
|
290
299
|
z2.object({
|
|
291
300
|
t: z2.literal("actions"),
|
|
301
|
+
label: z2.string().min(1).max(80).optional(),
|
|
302
|
+
layout: z2.enum(["row", "segmented"]).optional(),
|
|
292
303
|
actions: z2.array(z2.object({
|
|
293
304
|
id: z2.string(),
|
|
294
305
|
label: z2.string(),
|
|
295
|
-
tone: z2.enum(["default", "primary", "danger"]).optional()
|
|
306
|
+
tone: z2.enum(["default", "primary", "danger"]).optional(),
|
|
307
|
+
active: z2.boolean().optional(),
|
|
308
|
+
disabled: z2.boolean().optional()
|
|
296
309
|
}))
|
|
297
310
|
}),
|
|
298
311
|
z2.object({
|
|
@@ -445,6 +458,9 @@ function validateContribution(id, input) {
|
|
|
445
458
|
if (descriptor.placement === "composer.pill" && node2.t !== "text" && node2.t !== "progress") {
|
|
446
459
|
throw new Error("Composer pill content must be text or progress");
|
|
447
460
|
}
|
|
461
|
+
if (descriptor.placement === "composer.suggestion" && node2.t !== "text" && node2.t !== "code") {
|
|
462
|
+
throw new Error("Composer suggestion content must be text or code");
|
|
463
|
+
}
|
|
448
464
|
if (descriptor.placement === "session.badge") {
|
|
449
465
|
if (node2.t !== "text" && node2.t !== "badge") {
|
|
450
466
|
throw new Error("Session badge content must be text or a badge");
|
|
@@ -477,7 +493,7 @@ function trackerText(title, tracker) {
|
|
|
477
493
|
const head = tracker?.count ? `${title} ${tracker.count}` : title;
|
|
478
494
|
return tracker?.step ? `${head} \xB7 ${tracker.step}` : head;
|
|
479
495
|
}
|
|
480
|
-
var ContributionPlacement, Id, ActionId, Keywords, TrackerSummary, Common, ContributionDescriptor, ContributionInput, SESSION_BADGE_MAX;
|
|
496
|
+
var ContributionPlacement, Id, ActionId, Keywords, TrackerSummary, ComposerSuggestion, Common, ContributionDescriptor, ContributionInput, SESSION_BADGE_MAX;
|
|
481
497
|
var init_contributions = __esm({
|
|
482
498
|
"packages/protocol/dist/contributions.js"() {
|
|
483
499
|
"use strict";
|
|
@@ -489,6 +505,8 @@ var init_contributions = __esm({
|
|
|
489
505
|
"composer.pill",
|
|
490
506
|
/** `adapter.trackers.v1`: a live summary above the input that opens its detail. */
|
|
491
507
|
"composer.tracker",
|
|
508
|
+
/** `composer.suggestions.v1`: an editable next-prompt or command suggestion in the composer. */
|
|
509
|
+
"composer.suggestion",
|
|
492
510
|
/** `adapter.trackers.v1`: a short word on the session's navigator row. */
|
|
493
511
|
"session.badge",
|
|
494
512
|
"palette.item",
|
|
@@ -504,11 +522,18 @@ var init_contributions = __esm({
|
|
|
504
522
|
/** The step in progress, such as the current todo. */
|
|
505
523
|
step: z3.string().min(1).max(120).optional()
|
|
506
524
|
}).strict();
|
|
525
|
+
ComposerSuggestion = z3.object({
|
|
526
|
+
/** Exact text inserted into the composer when accepted (never auto-sent). */
|
|
527
|
+
text: z3.string().min(1).max(4e3),
|
|
528
|
+
/** Presentation hint (default "prompt"). */
|
|
529
|
+
kind: z3.enum(["prompt", "command"]).optional()
|
|
530
|
+
}).strict();
|
|
507
531
|
Common = {
|
|
508
532
|
placement: ContributionPlacement,
|
|
509
533
|
order: z3.number().int().min(-1e3).max(1e3).optional(),
|
|
510
534
|
actionId: ActionId.optional(),
|
|
511
|
-
tracker: TrackerSummary.optional()
|
|
535
|
+
tracker: TrackerSummary.optional(),
|
|
536
|
+
suggestion: ComposerSuggestion.optional()
|
|
512
537
|
};
|
|
513
538
|
ContributionDescriptor = z3.object({
|
|
514
539
|
id: Id,
|
|
@@ -537,6 +562,12 @@ var init_contributions = __esm({
|
|
|
537
562
|
if (v.placement !== "composer.tracker" && v.tracker !== void 0) {
|
|
538
563
|
ctx.addIssue({ code: "custom", message: "Only composer trackers have a tracker summary" });
|
|
539
564
|
}
|
|
565
|
+
if (v.placement === "composer.suggestion" && !v.suggestion) {
|
|
566
|
+
ctx.addIssue({ code: "custom", message: "Composer suggestions require a suggestion" });
|
|
567
|
+
}
|
|
568
|
+
if (v.placement !== "composer.suggestion" && v.suggestion !== void 0) {
|
|
569
|
+
ctx.addIssue({ code: "custom", message: "Only composer suggestions have a suggestion" });
|
|
570
|
+
}
|
|
540
571
|
});
|
|
541
572
|
ContributionInput = z3.object({
|
|
542
573
|
...Common,
|
|
@@ -3804,7 +3835,9 @@ var init_client_wire = __esm({
|
|
|
3804
3835
|
/** The client draws checklist, facts, rows and badge nodes, `section.open` and URL refs. */
|
|
3805
3836
|
"ui.nodes.v2",
|
|
3806
3837
|
/** The client draws `composer.tracker` and `session.badge` contributions. */
|
|
3807
|
-
"adapter.trackers.v1"
|
|
3838
|
+
"adapter.trackers.v1",
|
|
3839
|
+
/** The client draws `composer.suggestion` contributions in the composer. */
|
|
3840
|
+
"composer.suggestions.v1"
|
|
3808
3841
|
];
|
|
3809
3842
|
ClientToServer = z15.discriminatedUnion("type", [
|
|
3810
3843
|
z15.object({
|
|
@@ -4286,6 +4319,10 @@ function projectPanel(panel, reader) {
|
|
|
4286
4319
|
const { contribution: _c, state: _s, ...rest } = out;
|
|
4287
4320
|
return { ...rest, node: null, webRenderer: false };
|
|
4288
4321
|
}
|
|
4322
|
+
if (out.contribution && !reader.suggestions && placement === "composer.suggestion") {
|
|
4323
|
+
const { contribution: _c, state: _s, ...rest } = out;
|
|
4324
|
+
return { ...rest, node: null, webRenderer: false };
|
|
4325
|
+
}
|
|
4289
4326
|
if (out.contribution && !reader.trackers && placement === "composer.tracker") {
|
|
4290
4327
|
const { tracker, actionId: _a, ...descriptor } = out.contribution;
|
|
4291
4328
|
out = {
|
|
@@ -4369,7 +4406,8 @@ var init_projection = __esm({
|
|
|
4369
4406
|
cards: true,
|
|
4370
4407
|
views: false,
|
|
4371
4408
|
nodes: false,
|
|
4372
|
-
trackers: false
|
|
4409
|
+
trackers: false,
|
|
4410
|
+
suggestions: false
|
|
4373
4411
|
};
|
|
4374
4412
|
node = (n, reader) => reader.nodes ? n : downgradeUINode(n);
|
|
4375
4413
|
}
|
|
@@ -8317,7 +8355,11 @@ var ADAPTER_FEATURES = [
|
|
|
8317
8355
|
/** The `composer.tracker` and `session.badge` placements validate. */
|
|
8318
8356
|
"adapter.trackers.v1",
|
|
8319
8357
|
/** `Claim.kind` is carried to clients. */
|
|
8320
|
-
"interaction.kinds.v1"
|
|
8358
|
+
"interaction.kinds.v1",
|
|
8359
|
+
/** The `composer.suggestion` placement validates. */
|
|
8360
|
+
"composer.suggestions.v1",
|
|
8361
|
+
/** `ctx.runCommand` dispatches Pi slash commands from `onAction`, and `actions` supports `label`, `layout`, `active` and `disabled`. */
|
|
8362
|
+
"adapter.commands.v1"
|
|
8321
8363
|
];
|
|
8322
8364
|
var TIER_ORDER = ["project", "owner", "plugin", "bundled"];
|
|
8323
8365
|
var InteractionResponseError = class extends Error {
|
|
@@ -8541,6 +8583,7 @@ var AdapterSession = class {
|
|
|
8541
8583
|
contributions = /* @__PURE__ */ new Map();
|
|
8542
8584
|
closed = false;
|
|
8543
8585
|
used = false;
|
|
8586
|
+
actionDepth = 0;
|
|
8544
8587
|
restorePromise;
|
|
8545
8588
|
restoringEntry = null;
|
|
8546
8589
|
restoreEffects = [];
|
|
@@ -8814,8 +8857,13 @@ var AdapterSession = class {
|
|
|
8814
8857
|
if (!entry.adapter.server.onAction) {
|
|
8815
8858
|
return { ok: false, reason: `adapter ${adapterId} has no actions` };
|
|
8816
8859
|
}
|
|
8817
|
-
|
|
8818
|
-
|
|
8860
|
+
this.actionDepth++;
|
|
8861
|
+
try {
|
|
8862
|
+
const r = await this.call(entry, "onAction", [actionId, payload]);
|
|
8863
|
+
return r.ok ? { ok: true } : { ok: false, reason: entry.disabled ?? "action failed" };
|
|
8864
|
+
} finally {
|
|
8865
|
+
this.actionDepth--;
|
|
8866
|
+
}
|
|
8819
8867
|
}
|
|
8820
8868
|
/** Per-adapter active/disabled state for this session (tests and diagnostics). */
|
|
8821
8869
|
statuses() {
|
|
@@ -9111,6 +9159,27 @@ var AdapterSession = class {
|
|
|
9111
9159
|
const match = toMatcher(matcher);
|
|
9112
9160
|
this.enqueue(opts?.toolCallId ?? this.latestToolCallId(), responses.map((source) => ({ adapterId, match, source })), adapterId);
|
|
9113
9161
|
},
|
|
9162
|
+
runCommand: (command) => {
|
|
9163
|
+
if (refuse("runCommand"))
|
|
9164
|
+
return;
|
|
9165
|
+
if (!live())
|
|
9166
|
+
return;
|
|
9167
|
+
if (this.actionDepth === 0) {
|
|
9168
|
+
this.diag("warning", entry.id, "runCommand is only allowed inside onAction.");
|
|
9169
|
+
return;
|
|
9170
|
+
}
|
|
9171
|
+
if (typeof command !== "string") {
|
|
9172
|
+
throw new Error("Command must be a string");
|
|
9173
|
+
}
|
|
9174
|
+
const trimmed2 = command.trim();
|
|
9175
|
+
if (!trimmed2.startsWith("/") || trimmed2.length < 2 || trimmed2.length > 500) {
|
|
9176
|
+
throw new Error("Adapter commands must be slash commands (/name ...)");
|
|
9177
|
+
}
|
|
9178
|
+
if (/[\r\n\0]/.test(trimmed2)) {
|
|
9179
|
+
throw new Error("Adapter commands must be a single line");
|
|
9180
|
+
}
|
|
9181
|
+
this.emit({ type: "command", adapterId, command: trimmed2 });
|
|
9182
|
+
},
|
|
9114
9183
|
log: (level, message) => {
|
|
9115
9184
|
if (live())
|
|
9116
9185
|
this.emit({ type: "log", adapterId, level, message });
|
|
@@ -13640,6 +13709,8 @@ var ManagedSession = class _ManagedSession extends EventEmitter3 {
|
|
|
13640
13709
|
_leafId = null;
|
|
13641
13710
|
/** The user item just created, waiting for its entry id from `entry_appended`. */
|
|
13642
13711
|
pendingUserItemId = null;
|
|
13712
|
+
/** Emitted text blocks from the last `message_end`, reconciled if `entry_appended` carries a post-hook replacement. */
|
|
13713
|
+
lastAssistantBlocks = null;
|
|
13643
13714
|
_queue = { steering: [], followUp: [] };
|
|
13644
13715
|
pending = /* @__PURE__ */ new Map();
|
|
13645
13716
|
policyWaiting = /* @__PURE__ */ new Set();
|
|
@@ -14603,8 +14674,10 @@ var ManagedSession = class _ManagedSession extends EventEmitter3 {
|
|
|
14603
14674
|
break;
|
|
14604
14675
|
}
|
|
14605
14676
|
case "message_start":
|
|
14606
|
-
if (ev.message?.role === "assistant")
|
|
14677
|
+
if (ev.message?.role === "assistant") {
|
|
14607
14678
|
this.current = { blocks: /* @__PURE__ */ new Map() };
|
|
14679
|
+
this.lastAssistantBlocks = null;
|
|
14680
|
+
}
|
|
14608
14681
|
break;
|
|
14609
14682
|
case "leaf":
|
|
14610
14683
|
this._leafId = typeof ev.leafId === "string" ? ev.leafId : null;
|
|
@@ -14618,6 +14691,29 @@ var ManagedSession = class _ManagedSession extends EventEmitter3 {
|
|
|
14618
14691
|
item.data.entryId = entry.id;
|
|
14619
14692
|
this.emit("item", structuredClone(item));
|
|
14620
14693
|
}
|
|
14694
|
+
} else if (entry?.type === "message" && entry.message?.role === "assistant" && this.lastAssistantBlocks) {
|
|
14695
|
+
const blocks = this.lastAssistantBlocks;
|
|
14696
|
+
this.lastAssistantBlocks = null;
|
|
14697
|
+
const content = Array.isArray(entry.message.content) ? entry.message.content : [];
|
|
14698
|
+
const texts = [];
|
|
14699
|
+
let changed2 = false;
|
|
14700
|
+
content.forEach((block, index) => {
|
|
14701
|
+
if (block?.type !== "text" || typeof block.text !== "string")
|
|
14702
|
+
return;
|
|
14703
|
+
texts.push(block.text);
|
|
14704
|
+
const prev = blocks.get(index);
|
|
14705
|
+
if (!prev || prev.text === block.text)
|
|
14706
|
+
return;
|
|
14707
|
+
changed2 = true;
|
|
14708
|
+
this.emitItem(makeItem("assistant", { text: block.text }, {
|
|
14709
|
+
id: prev.itemId,
|
|
14710
|
+
sessionId: this.sessionId,
|
|
14711
|
+
order: prev.order,
|
|
14712
|
+
at: this.now()
|
|
14713
|
+
}));
|
|
14714
|
+
});
|
|
14715
|
+
if (changed2 && texts.length > 0)
|
|
14716
|
+
this.runAssistantText = texts.join("\n");
|
|
14621
14717
|
}
|
|
14622
14718
|
break;
|
|
14623
14719
|
}
|
|
@@ -14851,6 +14947,7 @@ ${output}`.trimEnd() }));
|
|
|
14851
14947
|
onAssistantEnd(message) {
|
|
14852
14948
|
const content = Array.isArray(message.content) ? message.content : [];
|
|
14853
14949
|
const texts = [];
|
|
14950
|
+
const emittedBlocks = /* @__PURE__ */ new Map();
|
|
14854
14951
|
content.forEach((block, index) => {
|
|
14855
14952
|
if (block?.type === "thinking" && typeof block.thinking === "string" && block.thinking) {
|
|
14856
14953
|
const b = this.block(index, "thinking");
|
|
@@ -14863,6 +14960,7 @@ ${output}`.trimEnd() }));
|
|
|
14863
14960
|
} else if (block?.type === "text" && typeof block.text === "string" && block.text) {
|
|
14864
14961
|
const b = this.block(index, "assistant");
|
|
14865
14962
|
texts.push(block.text);
|
|
14963
|
+
emittedBlocks.set(index, { itemId: b.itemId, order: b.order, text: block.text });
|
|
14866
14964
|
this.emitItem(makeItem("assistant", { text: block.text }, {
|
|
14867
14965
|
id: b.itemId,
|
|
14868
14966
|
sessionId: this.sessionId,
|
|
@@ -14874,6 +14972,7 @@ ${output}`.trimEnd() }));
|
|
|
14874
14972
|
tool.data.args = block.arguments ?? tool.data.args;
|
|
14875
14973
|
}
|
|
14876
14974
|
});
|
|
14975
|
+
this.lastAssistantBlocks = emittedBlocks.size > 0 ? emittedBlocks : null;
|
|
14877
14976
|
if (texts.length > 0)
|
|
14878
14977
|
this.runAssistantText = texts.join("\n");
|
|
14879
14978
|
const usage = message.usage;
|
|
@@ -19907,6 +20006,19 @@ var SessionSupervisor = class {
|
|
|
19907
20006
|
case "log":
|
|
19908
20007
|
this.opts.log[effect.level === "warning" ? "warn" : effect.level]({ sessionId, adapterId: effect.adapterId }, effect.message);
|
|
19909
20008
|
return;
|
|
20009
|
+
case "command": {
|
|
20010
|
+
const live = this.live.get(sessionId);
|
|
20011
|
+
if (!live?.ms || live.rec.readOnly)
|
|
20012
|
+
return;
|
|
20013
|
+
const cmd = effect.command.trim();
|
|
20014
|
+
if (!cmd.startsWith("/") || /[\r\n\0]/.test(cmd))
|
|
20015
|
+
return;
|
|
20016
|
+
void live.ms.prompt(cmd, [], "prompt").catch((err) => {
|
|
20017
|
+
this.opts.log.warn({ sessionId, adapterId: effect.adapterId, command: cmd, err: errorMessage2(err) }, "adapter command failed");
|
|
20018
|
+
this.diagnostic(sessionId, effect.adapterId, "warning", `Command ${cmd.split(/\s+/)[0]} failed: ${errorMessage2(err)}`);
|
|
20019
|
+
});
|
|
20020
|
+
return;
|
|
20021
|
+
}
|
|
19910
20022
|
case "diagnostic":
|
|
19911
20023
|
if (effect.adapterId && l.adapters?.statuses().some((status) => status.adapterId === effect.adapterId && status.status === "disabled")) {
|
|
19912
20024
|
for (const panel of this.panels(sessionId)) {
|
|
@@ -31518,7 +31630,8 @@ function readerFor(capabilities) {
|
|
|
31518
31630
|
cards: capabilities.has("timeline.cards.v1"),
|
|
31519
31631
|
views: capabilities.has("tool.views.v1"),
|
|
31520
31632
|
nodes: capabilities.has("ui.nodes.v2"),
|
|
31521
|
-
trackers: capabilities.has("adapter.trackers.v1")
|
|
31633
|
+
trackers: capabilities.has("adapter.trackers.v1"),
|
|
31634
|
+
suggestions: capabilities.has("composer.suggestions.v1")
|
|
31522
31635
|
};
|
|
31523
31636
|
}
|
|
31524
31637
|
function legacyEvent(event) {
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,D as n,F as r,G as i,Qt as a,c as o,cn as s,d as c,en as l,ft as u,g as d,gn as f,i as p,in as m,lt as h,m as g,mn as ee,n as _,r as v,rn as y,s as te,t as b,tn as ne,u as x,v as re,vn as S,y as C,yn as ie,z as ae}from"./states-hcvSpyb1.js";import{t as oe,u as w,w as T}from"./Overlay-hRkfpjK4.js";import{t as E}from"./calendar-clock-CkYP2-Qf.js";import{a as D,i as se,t as O}from"./SegmentedControl-CefWecy1.js";import{n as ce,r as le,t as ue}from"./Priority-DL3f-tRD.js";import{t as de}from"./play-Dul6ZDzY.js";import{t as k}from"./plus-DzBRN9tc.js";import{n as fe,t as pe}from"./DangerZone-C6qU1pp7.js";import{s as me,t as he}from"./policyLogic-DVorBdH6.js";import{r as ge,t as _e}from"./useBreakpoint-CXotoLeq.js";import{$ as A,B as ve,G as j,K as M,L as ye,St as be,W as N,_t as xe,ct as Se,dt as P,nt as Ce,vt as we,yt as F,z as Te}from"./index-D3WBnjbc.js";import{t as I}from"./TextLink-DMi_ZI43.js";import{n as Ee,t as L}from"./Field-DGV7eljt.js";import{n as R,t as z}from"./RadioCards-9YvqB3va.js";import{t as B}from"./Select-CdANXO3X.js";import{t as V}from"./Switch-DrrWalaQ.js";import{E as H,O as De,S as Oe,T as U,a as W,b as ke,d as Ae,f as G,g as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,o as Le,p as K,r as Re,s as ze,t as Be,u as Ve,v as He,w as q,x as Ue,y as We}from"./describe-B1R7Rpb3.js";var J={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};J.node;var Ge=n(J),Y=e(ie(),1),X=g(),Ke=e=>`/tasks/${encodeURIComponent(e)}`;function Z(e){return m(e)&&(e.status===404||e.status===405||e.status===501)}function qe({summary:e,errorCount:t}){return(0,X.jsxs)(R,{stack:!0,title:`Summary`,testId:`automation-summary`,children:[(0,X.jsx)(`p`,{className:`text-sm break-words`,children:e}),t>0&&(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-danger`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0`}),t===1?`1 field needs attention`:`${t} fields need attention`]})]})}async function Je(e,n,r){return e&&!r?t(q(e,`/preview`)):ne(`/api/automations/preview`,n)}function Ye({automationId:e,dirty:t,getInput:n,currentKey:r}){let[i,a]=(0,Y.useState)({status:`idle`}),o=async()=>{let r=n();if(!r)M.error(`Fix the highlighted fields to preview the task`);else{a({status:`loading`});try{let n=await Je(e,r,t);a({status:`done`,preview:n,key:JSON.stringify(r)})}catch(e){a(Z(e)?{status:`unsupported`}:{status:`error`,error:e})}}};return(0,X.jsxs)(R,{stack:!0,title:`Preview`,description:`See the task an occurrence would create, and when it would run next.`,testId:`automation-preview`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{icon:(0,X.jsx)(P,{className:`size-4`}),busy:i.status===`loading`,onClick:()=>void o(),children:`Preview resulting task`})}),i.status===`unsupported`&&(0,X.jsx)(x,{capability:`Task preview`,reason:`This coordinator does not offer automation previews.`,fallback:`Read the summary above, or save and use Run now to see a real task.`}),i.status===`error`&&(0,X.jsx)(_,{compact:!0,title:`Could not preview`,error:i.error,onRetry:()=>void o()}),i.status===`done`&&(0,X.jsx)(Xe,{preview:i.preview,stale:i.key!==r})]})}function Xe({preview:e,stale:t}){let{task:n}=e;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[t&&(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-warning`,role:`status`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),`The form changed since this preview. Preview again to refresh it.`]}),(0,X.jsx)(`p`,{className:`text-sm break-words text-muted`,children:e.summary}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border bg-surface-2 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`min-w-0 font-medium break-words`,children:n.title}),(0,X.jsx)(ce,{priority:n.priority,muted:!0,className:`shrink-0 text-xs`})]}),n.objective?(0,X.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:n.objective}):(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective.`}),n.acceptanceCriteria.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h4`,{className:`flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`size-3.5`}),`Acceptance criteria`]}),(0,X.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm`,children:n.acceptanceCriteria.map((e,t)=>(0,X.jsx)(`li`,{className:`break-words`,children:e},t))})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`Next occurrences`}),e.next.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No scheduled times: this trigger fires on demand, on a webhook, or when a task is done.`}):(0,X.jsx)(`ol`,{className:`mt-1 flex flex-col gap-0.5 text-sm`,children:e.next.slice(0,5).map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,X.jsx)(`time`,{dateTime:e,children:K(e)}),(0,X.jsx)(`span`,{className:`text-muted`,children:d(e)})]},e))})]})]})}function Ze({label:e,value:t,mono:n=!0}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsx)(`code`,{className:`min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1.5 text-xs break-all select-all ${n?`font-mono`:``}`,children:t}),(0,X.jsx)(c,{size:`sm`,icon:(0,X.jsx)(D,{className:`size-3.5`}),onClick:()=>void se(t,`${e} copied`),"aria-label":`Copy ${e.toLowerCase()}`,children:`Copy`})]})]})}function Qe({automation:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(!1),u=e.webhookTokenSet||a!==null,d=async()=>{i(!1),n(!0);try{let t=await ne(q(e.id,`/webhook-token`)),n=h.safeParse(t);if(!n.success)throw Error(`The coordinator returned an unexpected token response`);let r=new URL(n.data.url,window.location.origin).toString();o({token:n.data.token,url:r}),M.success(u?`Webhook token rotated`:`Webhook token created`)}catch(e){Z(e)?l(!0):M.error(`Could not issue a webhook token: ${y(e)}`)}finally{n(!1)}};return(0,X.jsxs)(R,{stack:!0,title:`Webhook`,description:`POST JSON to the URL with the token as a Bearer header. Filters decide which payloads fire.`,testId:`webhook-token`,children:[(0,X.jsx)(`p`,{className:`flex items-center gap-1.5 text-sm`,children:u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{"aria-hidden":!0,className:`size-4 shrink-0 text-success`}),`A token is set`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(we,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),`No token yet: webhook calls are rejected until you create one`]})}),s?(0,X.jsx)(x,{capability:`Webhook tokens`,reason:`This coordinator does not issue webhook tokens.`}):(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{icon:(0,X.jsx)(Se,{className:`size-4`}),busy:t,onClick:()=>u?i(!0):void d(),children:u?`Rotate token`:`Create token`})}),a&&(0,X.jsxs)(`div`,{role:`alert`,className:`flex min-w-0 flex-col gap-3 rounded-md border border-warning bg-warning-soft p-3`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),`This token is shown once. Copy it now.`]}),(0,X.jsx)(Ze,{label:`Token`,value:a.token}),(0,X.jsx)(Ze,{label:`URL`,value:a.url}),(0,X.jsx)(Ze,{label:`Example`,value:Le(a.token,a.url)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{size:`sm`,onClick:()=>o(null),children:`I have copied it`})})]}),(0,X.jsx)(oe,{open:r,onClose:()=>i(!1),title:`Rotate webhook token?`,description:`The current token stops working immediately. Update every sender with the new token.`,confirmLabel:`Rotate token`,busy:t,onConfirm:()=>void d()})]})}var $e=[];function et({automationId:e,refreshKey:n,onRun:r}){let a=i(t=>t.occurrences[e]??$e),s=i(e=>e.tasks),[c,l]=(0,Y.useState)({status:`loading`}),u=(0,Y.useCallback)(async n=>{l(e=>e.status===`done`?e:{status:`loading`});try{let r=await t(q(e,`/history`),{},n);l({status:`done`,items:He(r)})}catch(e){if(n?.aborted)return;l(Z(e)?{status:`unsupported`}:{status:`error`,error:e})}},[e]);(0,Y.useEffect)(()=>{let e=new AbortController;return u(e.signal),()=>e.abort()},[u,n]);let f=je(c.status===`done`?c.items:[],a);return(0,X.jsxs)(R,{stack:!0,title:`History`,description:`Occurrences of this automation. Routine successes are hidden from the board and appear only here.`,testId:`automation-history`,children:[c.status===`unsupported`&&(0,X.jsx)(x,{capability:`Automation history`,reason:`This coordinator does not serve stored history; only occurrences seen live in this session are shown.`}),c.status===`error`&&(0,X.jsx)(_,{compact:!0,title:`Could not load history`,error:c.error,onRetry:()=>void u()}),c.status===`loading`&&f.length===0?(0,X.jsx)(o,{label:`Loading history…`,className:`py-4`}):f.length===0&&c.status!==`error`?(0,X.jsx)(b,{className:`py-4`,icon:(0,X.jsx)(Ge,{className:`size-6`}),title:`No occurrences yet`,description:`Occurrences appear here when the trigger fires or you run it.`,action:{label:`Run now`,onClick:r,icon:(0,X.jsx)(de,{className:`size-4`})}}):(0,X.jsx)(`ol`,{className:`flex flex-col divide-y divide-border`,children:f.map(e=>{let t=We(e),n=e.taskId?s[e.taskId]:void 0,r=[e.reason,e.outcome].filter(Boolean).join(` · `);return(0,X.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 first:pt-0 last:pb-0`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(A,{kind:`occurrence`,value:e.state,size:`sm`}),(0,X.jsx)(`time`,{dateTime:t,className:`text-sm`,children:K(t)}),(0,X.jsx)(`span`,{className:`text-xs text-muted`,children:d(t)})]}),r&&(0,X.jsx)(`p`,{className:`text-sm break-words text-muted`,children:r}),e.taskId&&(0,X.jsxs)(I,{to:Ke(e.taskId),variant:`action`,size:`sm`,className:`self-start`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n?`Task: ${n.title}`:`Open task`}),n?.hiddenFromBoard&&(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`(hidden from board)`})]})]},e.id)})})]})}var tt=`/automations`,nt=e=>`/automations/${encodeURIComponent(e)}`,rt=`sy:automation-draft`;function it(){let{automationId:e=`new`}=S();return(0,X.jsx)(at,{automationId:e},e)}function at({automationId:e}){let n=e===`new`,r=i(e=>e.hydrated),a=H(n?void 0:e),[s,c]=(0,Y.useState)({status:`idle`}),l=(0,Y.useCallback)(async()=>{c({status:`loading`});try{let n=await t(q(e)),r=u.safeParse(n);if(!r.success){c({status:`fatal`,error:Error(`The coordinator returned this automation in an unexpected format.`)});return}U.getState().put(r.data),c({status:`idle`})}catch(e){m(e)&&e.status===404?c({status:`notfound`}):c({status:`error`,error:e})}},[e]),d=!n&&!a;return(0,Y.useEffect)(()=>{d&&s.status===`idle`&&l()},[d,s.status,l]),n?(0,X.jsx)(ct,{automation:null}):a?(0,X.jsx)(ct,{automation:a}):s.status===`notfound`?(0,X.jsx)(b,{icon:(0,X.jsx)(Ce,{className:`size-8`}),title:`Automation not found`,description:`It may have been deleted, or the link is wrong.`,action:{label:`Back to automations`,to:tt}}):s.status===`error`?(0,X.jsx)(_,{title:`Could not load this automation`,error:s.error,onRetry:()=>void l()}):s.status===`fatal`?(0,X.jsx)(v,{error:s.error}):(0,X.jsx)(o,{label:r?`Loading automation…`:`Loading…`})}function ot(e){let t=Ae({projectId:e,timezone:Me()});try{let e=sessionStorage.getItem(rt);if(!e)return t;let n=JSON.parse(e);return!n||typeof n!=`object`?t:{...t,...n,filters:Array.isArray(n.filters)?n.filters:[]}}catch{return t}}function Q(e){try{e?sessionStorage.setItem(rt,JSON.stringify(e)):sessionStorage.removeItem(rt)}catch{}}var $=e=>JSON.stringify(Ve(e));function st(e){if(!m(e))return{};let t=e.details,n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.issues)?t.issues:[],r={};for(let e of n){if(!e||typeof e!=`object`)continue;let{path:t,message:n}=e;if(!Array.isArray(t)||typeof n!=`string`)continue;let i=G(t);i!==`form`&&!r[i]&&(r[i]=n)}return r}function ct({automation:e}){let t=f(),n=ee(),o=ve(tt),u=_e();ye(u===`mobile`?o:null);let d=u===`desktop`,m=ae(),h=r(),g=i(e=>e.hosts),_=i(e=>e.profiles),v=i(e=>e.tasks),b=i(e=>e.projects),x=e===null,S=(0,Y.useId)(),ie=(0,Y.useRef)(null),[w,T]=(0,Y.useState)(()=>e?Pe(e):ot(m[0]?.id)),[E,D]=(0,Y.useState)(()=>$(w)),[se,O]=(0,Y.useState)(!1),[ce,le]=(0,Y.useState)({}),[ue,k]=(0,Y.useState)(!1),[he,A]=(0,Y.useState)(!1),[j,N]=(0,Y.useState)(!1),[Se,P]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(0),F=(0,Y.useRef)(e?.updatedAt),I=$(w),L=I!==E;(0,Y.useEffect)(()=>{if(!e||e.updatedAt===F.current)return;F.current=e.updatedAt;let t=Pe(e),n=$(t);I===E?(T(t),P(!1)):n!==I&&P(!0),D(n)},[e,I,E]),(0,Y.useEffect)(()=>{x&&Q(w)},[x,w]),(0,Y.useEffect)(()=>{x&&!w.projectId&&m[0]&&T(e=>e.projectId?e:{...e,projectId:m[0].id})},[x,w.projectId,m]);let R=(0,Y.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),le(e=>Object.keys(e).length?{}:e)},[]),z=(0,Y.useMemo)(()=>Oe(w),[w]),B={...ce,...se?z.errors:{}},V=e=>B[e],H=b[w.projectId],W=w.hostId||H?.defaultHostId||null,G=W?g[W]:void 0,je=w.profileId||H?.defaultProfileId||null,Ne=(0,Y.useCallback)(e=>v[e]?.title,[v]),Fe=(0,Y.useMemo)(()=>ke(Ve(w),{projectName:H?.name,hostName:w.hostId?g[w.hostId]?.name??null:null,profileName:w.profileId?_[w.profileId]?.name??null:null,taskTitle:Ne}),[w,H?.name,g,_,Ne]),Ie=()=>{requestAnimationFrame(()=>{ie.current?.querySelector(`[aria-invalid="true"]`)?.focus()})},Le=()=>(O(!0),z.input||Ie(),z.input),K=async()=>{let r=Le();if(!r)M.error(`Fix the highlighted fields before saving`);else{k(!0);try{if(x){let e=await ne(`/api/automations`,r);if(!e||typeof e!=`object`||!e.id)throw Error(`The coordinator did not return the new automation`);U.getState().put(e),Q(null),M.success(`Created ${e.name}`),t(nt(e.id),{replace:!0,state:n.state});return}let i=await l(q(e.id),r);if(i&&typeof i==`object`&&i.id){U.getState().put(i),F.current=i.updatedAt;let e=Pe(i);T(e),D($(e))}else D(I);P(!1),O(!1),M.success(`Saved ${r.name}`)}catch(e){let t=st(e);le(t),Object.keys(t).length&&Ie(),M.error(`Could not save: ${y(e)}. Your changes are kept.`)}finally{k(!1)}}},Re=async()=>{if(e){A(!0);try{await a(q(e.id)),N(!1),M.success(`Deleted ${e.name}`),o(),U.getState().remove(e.id)}catch(e){M.error(`Could not delete: ${y(e)}`)}finally{A(!1)}}},{busy:ze,run:Be}=De(()=>we(e=>e+1)),He=e?!!ze[e.id]:!1,Ue=()=>e&&void Be(e),We=()=>{let e=Ae({projectId:m[0]?.id,timezone:Me()});T(e),O(!1),Q(null)},J=x?`New automation`:e.name,Ge=(0,X.jsxs)(X.Fragment,{children:[!x&&(0,X.jsx)(c,{icon:(0,X.jsx)(de,{className:`size-4`}),busy:He,onClick:Ue,title:L?`Runs the saved version`:void 0,children:`Run now`}),x&&L&&(0,X.jsx)(c,{variant:`ghost`,icon:(0,X.jsx)(ge,{className:`size-4`}),onClick:We,children:`Discard draft`})]}),Ke=e=>(0,X.jsx)(c,{type:`submit`,form:S,variant:`primary`,busy:ue,block:e,icon:(0,X.jsx)(fe,{className:`size-4`}),children:x?`Create automation`:`Save`}),Z=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{summary:Fe,errorCount:se?Object.keys(z.errors).length:0}),(0,X.jsx)(Ye,{automationId:e?.id??null,dirty:L,getInput:Le,currentKey:JSON.stringify(z.input)}),e&&e.trigger.kind===`webhook`&&(0,X.jsx)(Qe,{automation:e}),e&&(0,X.jsx)(et,{automationId:e.id,refreshKey:Ce,onRun:Ue})]});return(0,X.jsxs)(`div`,{"data-testid":`automation-editor`,className:`flex w-full min-w-0 flex-col gap-4 px-4 pt-4 md:px-6`,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsxs)(s,{to:tt,onClick:Te(o),className:`tap inline-flex items-center gap-1 self-start rounded text-sm text-muted hover:text-text`,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`size-4`}),`Automations`]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 text-lg font-semibold break-words`,children:J}),L&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,X.jsx)(xe,{"aria-hidden":!0,className:`size-3.5`}),`Unsaved changes`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ge,d&&Ke()]})]})]}),(0,X.jsx)(te,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),G&&G.connectivity!==`connected`&&(0,X.jsx)(p,{compact:!0,hostName:G.name,connectivity:G.connectivity,lastSeenAt:G.lastSeenAt,detail:`Occurrences are still recorded; their tasks wait until the host is reachable.`}),Se&&(0,X.jsxs)(`p`,{role:`status`,className:`flex items-start gap-1.5 rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-warning`}),`This automation changed elsewhere. Saving overwrites those changes with yours.`]}),(0,X.jsxs)(`div`,{className:re(`grid min-w-0 gap-4`,d?`grid-cols-[minmax(0,1fr)_minmax(320px,400px)] items-start`:`grid-cols-1`),children:[(0,X.jsxs)(`form`,{id:S,ref:ie,noValidate:!0,"aria-label":J,onSubmit:e=>{e.preventDefault(),K()},className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(lt,{draft:w,update:R,err:V,projects:m}),(0,X.jsx)(ft,{draft:w,update:R,err:V,tasks:v,projectsById:b,savedAutomation:e,segmented:u!==`mobile`}),(0,X.jsx)(pt,{draft:w,setDraft:T,err:V}),(0,X.jsx)(mt,{draft:w,update:R,err:V}),(0,X.jsx)(ht,{draft:w,update:R,err:V,hosts:h,profiles:Object.values(_).sort((e,t)=>e.name.localeCompare(t.name)),defaultHostName:H?.defaultHostId?g[H.defaultHostId]?.name:void 0,defaultProfileName:H?.defaultProfileId?_[H.defaultProfileId]?.name:void 0,selectedProfileMissing:!!je&&!_[je]}),(0,X.jsx)(gt,{draft:w,update:R}),(0,X.jsx)(_t,{draft:w,update:R,err:V}),(0,X.jsx)(vt,{draft:w,update:R,err:V,projectChecks:H?.checks}),B.form&&(0,X.jsx)(Ee,{children:B.form})]}),(0,X.jsx)(`aside`,{"aria-label":`Summary, preview and history`,className:`flex min-w-0 flex-col gap-4`,children:Z})]}),!x&&e&&(0,X.jsx)(pe,{description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,children:(0,X.jsx)(c,{variant:`danger`,icon:(0,X.jsx)(me,{className:`size-4`}),onClick:()=>N(!0),children:`Delete automation`})}),d?(0,X.jsx)(`div`,{className:`h-4`}):(0,X.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 flex items-center gap-3 border-t border-border bg-surface px-4 py-2 md:-mx-6 md:px-6`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:L?`Unsaved changes`:x?`Not saved yet`:`All changes saved`}),Ke()]}),(0,X.jsx)(oe,{open:j,onClose:()=>N(!1),title:`Delete ${e?.name??`automation`}?`,description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,confirmLabel:`Delete automation`,confirmIcon:(0,X.jsx)(me,{className:`size-4`}),busy:he,onConfirm:()=>void Re()})]})}function lt({draft:e,update:t,err:n,projects:r}){return(0,X.jsxs)(R,{stack:!0,title:`Basics`,children:[(0,X.jsx)(L,{label:`Name`,error:n(`name`),children:n=>(0,X.jsx)(j,{...n,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`Daily dependency check`,autoComplete:`off`})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Project`,error:n(`projectId`),hint:r.length===0?(0,X.jsxs)(X.Fragment,{children:[`No active projects.`,` `,(0,X.jsx)(I,{to:`/settings/projects`,children:`Connect a repository in Settings`}),`.`]}):void 0,children:n=>(0,X.jsxs)(B,{...n,value:e.projectId,onChange:e=>t(`projectId`,e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose a project`}),r.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,X.jsx)(L,{label:`Status`,hint:`Disabled automations keep their history and can still run manually.`,children:n=>(0,X.jsx)(V,{...n,checked:e.enabled,onChange:e=>t(`enabled`,e),label:`Enabled`,onText:`Enabled`,offText:`Disabled`,className:`self-start`})})]})]})}var ut=[`manual`,`once`,`cron`,`webhook`,`dependency`],dt={manual:`Runs only when you press Run now (or from the CLI).`,once:`Runs a single time at the chosen moment.`,cron:`Runs on a timezone-aware cron schedule.`,webhook:`Runs when an authenticated JSON POST arrives at this automation's webhook URL.`,dependency:`Runs when the chosen task is done.`};function ft({draft:e,update:t,err:n,tasks:r,projectsById:a,savedAutomation:o,segmented:s}){let c=i(e=>e.hydrated),l=e.triggerKind===`cron`?Ue(e.cronExpr):null,u=e.triggerKind===`cron`&&!l?ze(e.cronExpr,e.cronTimezone.trim()||void 0)??`Valid expression (no plain-language description available)`:null,d=(0,Y.useMemo)(()=>{try{return Intl.supportedValuesOf?.(`timeZone`)}catch{return}},[]),f=(0,Y.useId)(),p=Me(),m=(0,Y.useMemo)(()=>Object.values(r).filter(t=>t.state!==`canceled`||t.id===e.dependencyTaskId).sort((e,t)=>e.title.localeCompare(t.title)),[r,e.dependencyTaskId]),h=e.triggerKind===`once`?Fe(e.onceAt):``;return(0,X.jsxs)(R,{stack:!0,title:`Trigger`,description:dt[e.triggerKind],children:[s?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`text-sm font-medium`,children:`Trigger kind`}),(0,X.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain`,children:(0,X.jsx)(O,{label:`Trigger kind`,value:e.triggerKind,onChange:e=>t(`triggerKind`,e),options:ut.map(e=>({value:e,label:W[e]}))})})]}):(0,X.jsx)(L,{label:`Trigger kind`,children:n=>(0,X.jsx)(B,{...n,value:e.triggerKind,onChange:e=>t(`triggerKind`,e.target.value),children:ut.map(e=>(0,X.jsx)(`option`,{value:e,children:W[e]},e))})}),e.triggerKind===`once`&&(0,X.jsx)(L,{label:`Run at`,error:n(`onceAt`),hint:`Local time (${p})${h?`; saved as ${h}`:``}.`,children:n=>(0,X.jsx)(j,{...n,type:`datetime-local`,value:e.onceAt,onChange:e=>t(`onceAt`,e.target.value)})}),e.triggerKind===`cron`&&(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Cron expression`,error:n(`cronExpr`)??l??void 0,hint:`minute hour day-of-month month day-of-week, e.g. 0 9 * * 1-5`,children:n=>(0,X.jsx)(j,{...n,"aria-invalid":l?!0:n[`aria-invalid`],value:e.cronExpr,onChange:e=>t(`cronExpr`,e.target.value),className:`font-mono`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`})}),(0,X.jsx)(L,{label:`Timezone`,error:n(`cronTimezone`),hint:e.cronTimezone.trim()===p?`IANA timezone name; daylight saving is handled.`:(0,X.jsxs)(I,{onClick:()=>t(`cronTimezone`,p),children:[`Use this device's timezone (`,p,`)`]}),children:n=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{...n,list:d?f:void 0,value:e.cronTimezone,onChange:e=>t(`cronTimezone`,e.target.value),autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`}),d&&(0,X.jsx)(`datalist`,{id:f,children:d.map(e=>(0,X.jsx)(`option`,{value:e},e))})]})}),u&&(0,X.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm sm:col-span-2`,"aria-live":`polite`,"data-testid":`cron-description`,children:[(0,X.jsx)(E,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:u})]})]}),e.triggerKind===`webhook`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm text-muted`,children:[(0,X.jsxs)(`p`,{children:[`Senders POST a JSON body (up to 256 KB) with`,` `,(0,X.jsx)(`code`,{children:`Authorization: Bearer <token>`}),`. Use the filters below to fire only for matching payloads, and `,(0,X.jsx)(`code`,{children:`{{payload.<path>}}`}),` to copy payload values into the task.`]}),o?o.trigger.kind===`webhook`?(0,X.jsxs)(`p`,{children:[`Token:`,` `,o.webhookTokenSet?`set (see Webhook below to rotate)`:`not created yet`]}):(0,X.jsx)(`p`,{children:`Save to switch this automation to a webhook trigger, then create a token.`}):(0,X.jsx)(`p`,{children:`Save the automation to create its webhook token and URL.`})]}),e.triggerKind===`dependency`&&(0,X.jsx)(L,{label:`When this task is done`,error:n(`dependencyTaskId`),hint:`Fires once each time the task enters Done.`,children:n=>(0,X.jsxs)(B,{...n,value:e.dependencyTaskId,onChange:e=>t(`dependencyTaskId`,e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose a task`}),e.dependencyTaskId&&!r[e.dependencyTaskId]&&(0,X.jsx)(`option`,{value:e.dependencyTaskId,children:c?`Deleted task`:`Loading task…`}),m.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.title,a[e.projectId]?` (${a[e.projectId].name})`:``,e.state===`done`?` - done`:``]},e.id))]})})]})}function pt({draft:e,setDraft:t,err:n}){let r=(e,n)=>t(t=>({...t,filters:t.filters.map((t,r)=>r===e?{...t,...n}:t)})),i=e.triggerKind===`webhook`;return(0,X.jsxs)(R,{stack:!0,title:`Filters`,description:`Filters apply to webhook payloads. Each row compares a dot path (for example pull_request.base.ref) with an exact value; all rows must match. Payloads that do not match are recorded as Filtered out.`,children:[!i&&(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`Filters are ignored unless the trigger is Webhook.`}),e.filters.length===0&&(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No filters: every payload fires.`}),e.filters.map((e,i)=>(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(L,{label:`Path ${i+1}`,error:n(`filters.${i}.path`),children:t=>(0,X.jsx)(j,{...t,value:e.path,onChange:e=>r(i,{path:e.target.value}),placeholder:`action`,className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})}),(0,X.jsx)(L,{label:`Equals ${i+1}`,error:n(`filters.${i}.equals`),className:`col-start-1 row-start-2 sm:col-start-auto sm:row-start-auto`,children:t=>(0,X.jsx)(j,{...t,value:e.equals,onChange:e=>r(i,{equals:e.target.value}),placeholder:`opened`})}),(0,X.jsx)(w,{label:`Remove filter ${i+1}`,icon:(0,X.jsx)(ge,{className:`size-4`}),onClick:()=>t(e=>({...e,filters:e.filters.filter((e,t)=>t!==i)}))})]},i)),(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{size:`sm`,icon:(0,X.jsx)(k,{className:`size-3.5`}),onClick:()=>t(e=>({...e,filters:[...e.filters,{path:``,equals:``}]})),children:`Add filter`})})]})}function mt({draft:e,update:t,err:n}){return(0,X.jsxs)(R,{stack:!0,title:`Task template`,description:`Use ${Ne.join(`, `)} in the title, objective, criteria and grouping key.`,children:[(0,X.jsx)(L,{label:`Task title`,error:n(`title`),children:n=>(0,X.jsx)(j,{...n,value:e.title,onChange:e=>t(`title`,e.target.value),placeholder:`Triage new issues for {{date}}`})}),(0,X.jsx)(L,{label:`Objective`,error:n(`objective`),children:n=>(0,X.jsx)(N,{...n,minRows:4,value:e.objective,onChange:e=>t(`objective`,e.target.value)})}),(0,X.jsx)(L,{label:`Acceptance criteria`,error:n(`criteria`),hint:`One criterion per line.`,optional:!0,children:n=>(0,X.jsx)(N,{...n,minRows:3,value:e.criteria,onChange:e=>t(`criteria`,e.target.value)})}),(0,X.jsx)(L,{label:`Priority`,error:n(`priority`),children:n=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(ue,{priority:e.priority}),(0,X.jsx)(le,{...n,value:e.priority,onChange:e=>t(`priority`,e),className:`sm:max-w-48`})]})})]})}function ht({draft:e,update:t,err:n,hosts:r,profiles:i,defaultHostName:a,defaultProfileName:o,selectedProfileMissing:s}){return(0,X.jsxs)(R,{stack:!0,title:`Where and how it runs`,children:[(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Host`,error:n(`hostId`),children:n=>(0,X.jsxs)(B,{...n,value:e.hostId,onChange:e=>t(`hostId`,e.target.value),children:[(0,X.jsxs)(`option`,{value:``,children:[`Project default`,a?` (${a})`:``]}),e.hostId&&!r.some(t=>t.id===e.hostId)&&(0,X.jsx)(`option`,{value:e.hostId,children:`Unknown host`}),r.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id))]})}),(0,X.jsx)(L,{label:`Profile`,error:n(`profileId`),hint:s?`The selected profile is no longer available.`:void 0,children:n=>(0,X.jsxs)(B,{...n,value:e.profileId,onChange:e=>t(`profileId`,e.target.value),children:[(0,X.jsxs)(`option`,{value:``,children:[`Project default`,o?` (${o})`:``]}),e.profileId&&!i.some(t=>t.id===e.profileId)&&(0,X.jsx)(`option`,{value:e.profileId,children:`Unknown profile`}),i.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,X.jsx)(z,{legend:`Mode`,value:e.mode,options:Ie,onChange:e=>t(`mode`,e)}),(0,X.jsx)(L,{label:`Grouping key`,optional:e.mode!==`continue`,error:n(`groupingKey`),hint:`Occurrences with the same rendered key are the same work: Continue reuses that task and overlap checks compare it. Supports template variables, e.g. pr-{{payload.number}}.`,children:n=>(0,X.jsx)(j,{...n,value:e.groupingKey,onChange:e=>t(`groupingKey`,e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})})]})}function gt({draft:e,update:t}){let n=e.triggerKind===`cron`||e.triggerKind===`once`;return(0,X.jsxs)(R,{stack:!0,title:`Overlap and missed runs`,children:[(0,X.jsx)(z,{legend:`When previous work is still open`,value:e.overlap,options:Re,onChange:e=>t(`overlap`,e)}),(0,X.jsx)(z,{legend:`Missed runs`,value:e.missed,options:Be,onChange:e=>t(`missed`,e),hint:n?`A run is missed when the coordinator was down at its scheduled time.`:`Only applies to Schedule and Once triggers.`})]})}function _t({draft:e,update:t,err:n}){return(0,X.jsxs)(R,{stack:!0,title:`Limits`,description:`Continuation prompts the agent to keep going after a turn ends without finishing. It is off by default.`,children:[(0,X.jsx)(L,{label:`Automatic continuation`,children:n=>(0,X.jsx)(V,{...n,checked:e.continuationEnabled,onChange:e=>t(`continuationEnabled`,e),label:`Automatic continuation`,className:`self-start`})}),e.continuationEnabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{label:`Continuation objective`,error:n(`continuationObjective`),hint:`What the agent must achieve before it reports done.`,children:n=>(0,X.jsx)(N,{...n,minRows:2,value:e.continuationObjective,onChange:e=>t(`continuationObjective`,e.target.value)})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Max continuations`,error:n(`maxContinuations`),hint:`1–50`,children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,max:50,step:1,value:e.maxContinuations,onChange:e=>t(`maxContinuations`,e.target.value)})}),(0,X.jsx)(L,{label:`Max elapsed minutes`,error:n(`maxElapsedMinutes`),hint:`1–1440`,children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,max:1440,step:1,value:e.maxElapsedMinutes,onChange:e=>t(`maxElapsedMinutes`,e.target.value)})}),(0,X.jsx)(L,{label:`Continuation budget: tokens`,optional:!0,error:n(`maxTokens`),children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,step:1,value:e.maxTokens,onChange:e=>t(`maxTokens`,e.target.value)})}),(0,X.jsx)(L,{label:`Continuation budget: cost (USD)`,optional:!0,error:n(`maxCostUsd`),children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`decimal`,min:.01,step:.01,value:e.maxCostUsd,onChange:e=>t(`maxCostUsd`,e.target.value)})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted`,children:he})]})]})}function vt({draft:e,update:t,err:n,projectChecks:r}){let i=r&&r.length>0?`the project's checks (${r.join(`, `)})`:`the project's checks`;return(0,X.jsxs)(R,{stack:!0,title:`Review`,children:[(0,X.jsx)(L,{label:`Checks`,optional:!0,error:n(`checks`),hint:`One command per line. Leave empty to use ${i}.`,children:n=>(0,X.jsx)(N,{...n,minRows:2,value:e.checks,onChange:e=>t(`checks`,e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`})}),(0,X.jsx)(L,{label:`Human review`,hint:`When on, finished work waits in Review for you instead of completing on passing checks.`,children:n=>(0,X.jsx)(V,{...n,checked:e.requireHumanReview,onChange:e=>t(`requireHumanReview`,e),label:`Require human review`,onText:`Required`,offText:`Not required`,className:`self-start`})})]})}export{it as default};
|
|
2
|
-
//# sourceMappingURL=AutomationView-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,D as n,F as r,G as i,Qt as a,c as o,cn as s,d as c,en as l,ft as u,g as d,gn as f,i as p,in as m,lt as h,m as g,mn as ee,n as _,r as v,rn as y,s as te,t as b,tn as ne,u as x,v as re,vn as S,y as C,yn as ie,z as ae}from"./states-BtAXMBKP.js";import{t as oe,u as w,w as T}from"./Overlay-Cfm4AZk1.js";import{t as E}from"./calendar-clock-BPYJQFbH.js";import{a as D,i as se,t as O}from"./SegmentedControl-D6SGXg_K.js";import{n as ce,r as le,t as ue}from"./Priority-DBLBg1FP.js";import{t as de}from"./play-CFs0JI3B.js";import{t as k}from"./plus-DEaNWSMA.js";import{n as fe,t as pe}from"./DangerZone-CT2xbMEx.js";import{s as me,t as he}from"./policyLogic-1QWs7S1X.js";import{r as ge,t as _e}from"./useBreakpoint-DQmHoUda.js";import{$ as A,B as ve,G as j,K as M,L as ye,St as be,W as N,_t as xe,ct as Se,dt as P,nt as Ce,vt as we,yt as F,z as Te}from"./index-BHIBqflQ.js";import{t as I}from"./TextLink-DWXZwPZa.js";import{n as Ee,t as L}from"./Field-D4UpWJFx.js";import{n as R,t as z}from"./RadioCards-DoHz_a-g.js";import{t as B}from"./Select-D41sYIWt.js";import{t as V}from"./Switch-D6hfPoPE.js";import{E as H,O as De,S as Oe,T as U,a as W,b as ke,d as Ae,f as G,g as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,o as Le,p as K,r as Re,s as ze,t as Be,u as Ve,v as He,w as q,x as Ue,y as We}from"./describe-C6HLxXjb.js";var J={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};J.node;var Ge=n(J),Y=e(ie(),1),X=g(),Ke=e=>`/tasks/${encodeURIComponent(e)}`;function Z(e){return m(e)&&(e.status===404||e.status===405||e.status===501)}function qe({summary:e,errorCount:t}){return(0,X.jsxs)(R,{stack:!0,title:`Summary`,testId:`automation-summary`,children:[(0,X.jsx)(`p`,{className:`text-sm break-words`,children:e}),t>0&&(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-danger`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0`}),t===1?`1 field needs attention`:`${t} fields need attention`]})]})}async function Je(e,n,r){return e&&!r?t(q(e,`/preview`)):ne(`/api/automations/preview`,n)}function Ye({automationId:e,dirty:t,getInput:n,currentKey:r}){let[i,a]=(0,Y.useState)({status:`idle`}),o=async()=>{let r=n();if(!r)M.error(`Fix the highlighted fields to preview the task`);else{a({status:`loading`});try{let n=await Je(e,r,t);a({status:`done`,preview:n,key:JSON.stringify(r)})}catch(e){a(Z(e)?{status:`unsupported`}:{status:`error`,error:e})}}};return(0,X.jsxs)(R,{stack:!0,title:`Preview`,description:`See the task an occurrence would create, and when it would run next.`,testId:`automation-preview`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{icon:(0,X.jsx)(P,{className:`size-4`}),busy:i.status===`loading`,onClick:()=>void o(),children:`Preview resulting task`})}),i.status===`unsupported`&&(0,X.jsx)(x,{capability:`Task preview`,reason:`This coordinator does not offer automation previews.`,fallback:`Read the summary above, or save and use Run now to see a real task.`}),i.status===`error`&&(0,X.jsx)(_,{compact:!0,title:`Could not preview`,error:i.error,onRetry:()=>void o()}),i.status===`done`&&(0,X.jsx)(Xe,{preview:i.preview,stale:i.key!==r})]})}function Xe({preview:e,stale:t}){let{task:n}=e;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[t&&(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-warning`,role:`status`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),`The form changed since this preview. Preview again to refresh it.`]}),(0,X.jsx)(`p`,{className:`text-sm break-words text-muted`,children:e.summary}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-md border border-border bg-surface-2 p-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`min-w-0 font-medium break-words`,children:n.title}),(0,X.jsx)(ce,{priority:n.priority,muted:!0,className:`shrink-0 text-xs`})]}),n.objective?(0,X.jsx)(`p`,{className:`text-sm break-words whitespace-pre-wrap`,children:n.objective}):(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective.`}),n.acceptanceCriteria.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h4`,{className:`flex items-center gap-1 text-xs font-medium text-muted`,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`size-3.5`}),`Acceptance criteria`]}),(0,X.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm`,children:n.acceptanceCriteria.map((e,t)=>(0,X.jsx)(`li`,{className:`break-words`,children:e},t))})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`Next occurrences`}),e.next.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No scheduled times: this trigger fires on demand, on a webhook, or when a task is done.`}):(0,X.jsx)(`ol`,{className:`mt-1 flex flex-col gap-0.5 text-sm`,children:e.next.slice(0,5).map(e=>(0,X.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,X.jsx)(`time`,{dateTime:e,children:K(e)}),(0,X.jsx)(`span`,{className:`text-muted`,children:d(e)})]},e))})]})]})}function Ze({label:e,value:t,mono:n=!0}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsx)(`code`,{className:`min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1.5 text-xs break-all select-all ${n?`font-mono`:``}`,children:t}),(0,X.jsx)(c,{size:`sm`,icon:(0,X.jsx)(D,{className:`size-3.5`}),onClick:()=>void se(t,`${e} copied`),"aria-label":`Copy ${e.toLowerCase()}`,children:`Copy`})]})]})}function Qe({automation:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(!1),u=e.webhookTokenSet||a!==null,d=async()=>{i(!1),n(!0);try{let t=await ne(q(e.id,`/webhook-token`)),n=h.safeParse(t);if(!n.success)throw Error(`The coordinator returned an unexpected token response`);let r=new URL(n.data.url,window.location.origin).toString();o({token:n.data.token,url:r}),M.success(u?`Webhook token rotated`:`Webhook token created`)}catch(e){Z(e)?l(!0):M.error(`Could not issue a webhook token: ${y(e)}`)}finally{n(!1)}};return(0,X.jsxs)(R,{stack:!0,title:`Webhook`,description:`POST JSON to the URL with the token as a Bearer header. Filters decide which payloads fire.`,testId:`webhook-token`,children:[(0,X.jsx)(`p`,{className:`flex items-center gap-1.5 text-sm`,children:u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{"aria-hidden":!0,className:`size-4 shrink-0 text-success`}),`A token is set`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(we,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),`No token yet: webhook calls are rejected until you create one`]})}),s?(0,X.jsx)(x,{capability:`Webhook tokens`,reason:`This coordinator does not issue webhook tokens.`}):(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{icon:(0,X.jsx)(Se,{className:`size-4`}),busy:t,onClick:()=>u?i(!0):void d(),children:u?`Rotate token`:`Create token`})}),a&&(0,X.jsxs)(`div`,{role:`alert`,className:`flex min-w-0 flex-col gap-3 rounded-md border border-warning bg-warning-soft p-3`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),`This token is shown once. Copy it now.`]}),(0,X.jsx)(Ze,{label:`Token`,value:a.token}),(0,X.jsx)(Ze,{label:`URL`,value:a.url}),(0,X.jsx)(Ze,{label:`Example`,value:Le(a.token,a.url)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{size:`sm`,onClick:()=>o(null),children:`I have copied it`})})]}),(0,X.jsx)(oe,{open:r,onClose:()=>i(!1),title:`Rotate webhook token?`,description:`The current token stops working immediately. Update every sender with the new token.`,confirmLabel:`Rotate token`,busy:t,onConfirm:()=>void d()})]})}var $e=[];function et({automationId:e,refreshKey:n,onRun:r}){let a=i(t=>t.occurrences[e]??$e),s=i(e=>e.tasks),[c,l]=(0,Y.useState)({status:`loading`}),u=(0,Y.useCallback)(async n=>{l(e=>e.status===`done`?e:{status:`loading`});try{let r=await t(q(e,`/history`),{},n);l({status:`done`,items:He(r)})}catch(e){if(n?.aborted)return;l(Z(e)?{status:`unsupported`}:{status:`error`,error:e})}},[e]);(0,Y.useEffect)(()=>{let e=new AbortController;return u(e.signal),()=>e.abort()},[u,n]);let f=je(c.status===`done`?c.items:[],a);return(0,X.jsxs)(R,{stack:!0,title:`History`,description:`Occurrences of this automation. Routine successes are hidden from the board and appear only here.`,testId:`automation-history`,children:[c.status===`unsupported`&&(0,X.jsx)(x,{capability:`Automation history`,reason:`This coordinator does not serve stored history; only occurrences seen live in this session are shown.`}),c.status===`error`&&(0,X.jsx)(_,{compact:!0,title:`Could not load history`,error:c.error,onRetry:()=>void u()}),c.status===`loading`&&f.length===0?(0,X.jsx)(o,{label:`Loading history…`,className:`py-4`}):f.length===0&&c.status!==`error`?(0,X.jsx)(b,{className:`py-4`,icon:(0,X.jsx)(Ge,{className:`size-6`}),title:`No occurrences yet`,description:`Occurrences appear here when the trigger fires or you run it.`,action:{label:`Run now`,onClick:r,icon:(0,X.jsx)(de,{className:`size-4`})}}):(0,X.jsx)(`ol`,{className:`flex flex-col divide-y divide-border`,children:f.map(e=>{let t=We(e),n=e.taskId?s[e.taskId]:void 0,r=[e.reason,e.outcome].filter(Boolean).join(` · `);return(0,X.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 first:pt-0 last:pb-0`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(A,{kind:`occurrence`,value:e.state,size:`sm`}),(0,X.jsx)(`time`,{dateTime:t,className:`text-sm`,children:K(t)}),(0,X.jsx)(`span`,{className:`text-xs text-muted`,children:d(t)})]}),r&&(0,X.jsx)(`p`,{className:`text-sm break-words text-muted`,children:r}),e.taskId&&(0,X.jsxs)(I,{to:Ke(e.taskId),variant:`action`,size:`sm`,className:`self-start`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n?`Task: ${n.title}`:`Open task`}),n?.hiddenFromBoard&&(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:`(hidden from board)`})]})]},e.id)})})]})}var tt=`/automations`,nt=e=>`/automations/${encodeURIComponent(e)}`,rt=`sy:automation-draft`;function it(){let{automationId:e=`new`}=S();return(0,X.jsx)(at,{automationId:e},e)}function at({automationId:e}){let n=e===`new`,r=i(e=>e.hydrated),a=H(n?void 0:e),[s,c]=(0,Y.useState)({status:`idle`}),l=(0,Y.useCallback)(async()=>{c({status:`loading`});try{let n=await t(q(e)),r=u.safeParse(n);if(!r.success){c({status:`fatal`,error:Error(`The coordinator returned this automation in an unexpected format.`)});return}U.getState().put(r.data),c({status:`idle`})}catch(e){m(e)&&e.status===404?c({status:`notfound`}):c({status:`error`,error:e})}},[e]),d=!n&&!a;return(0,Y.useEffect)(()=>{d&&s.status===`idle`&&l()},[d,s.status,l]),n?(0,X.jsx)(ct,{automation:null}):a?(0,X.jsx)(ct,{automation:a}):s.status===`notfound`?(0,X.jsx)(b,{icon:(0,X.jsx)(Ce,{className:`size-8`}),title:`Automation not found`,description:`It may have been deleted, or the link is wrong.`,action:{label:`Back to automations`,to:tt}}):s.status===`error`?(0,X.jsx)(_,{title:`Could not load this automation`,error:s.error,onRetry:()=>void l()}):s.status===`fatal`?(0,X.jsx)(v,{error:s.error}):(0,X.jsx)(o,{label:r?`Loading automation…`:`Loading…`})}function ot(e){let t=Ae({projectId:e,timezone:Me()});try{let e=sessionStorage.getItem(rt);if(!e)return t;let n=JSON.parse(e);return!n||typeof n!=`object`?t:{...t,...n,filters:Array.isArray(n.filters)?n.filters:[]}}catch{return t}}function Q(e){try{e?sessionStorage.setItem(rt,JSON.stringify(e)):sessionStorage.removeItem(rt)}catch{}}var $=e=>JSON.stringify(Ve(e));function st(e){if(!m(e))return{};let t=e.details,n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.issues)?t.issues:[],r={};for(let e of n){if(!e||typeof e!=`object`)continue;let{path:t,message:n}=e;if(!Array.isArray(t)||typeof n!=`string`)continue;let i=G(t);i!==`form`&&!r[i]&&(r[i]=n)}return r}function ct({automation:e}){let t=f(),n=ee(),o=ve(tt),u=_e();ye(u===`mobile`?o:null);let d=u===`desktop`,m=ae(),h=r(),g=i(e=>e.hosts),_=i(e=>e.profiles),v=i(e=>e.tasks),b=i(e=>e.projects),x=e===null,S=(0,Y.useId)(),ie=(0,Y.useRef)(null),[w,T]=(0,Y.useState)(()=>e?Pe(e):ot(m[0]?.id)),[E,D]=(0,Y.useState)(()=>$(w)),[se,O]=(0,Y.useState)(!1),[ce,le]=(0,Y.useState)({}),[ue,k]=(0,Y.useState)(!1),[he,A]=(0,Y.useState)(!1),[j,N]=(0,Y.useState)(!1),[Se,P]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(0),F=(0,Y.useRef)(e?.updatedAt),I=$(w),L=I!==E;(0,Y.useEffect)(()=>{if(!e||e.updatedAt===F.current)return;F.current=e.updatedAt;let t=Pe(e),n=$(t);I===E?(T(t),P(!1)):n!==I&&P(!0),D(n)},[e,I,E]),(0,Y.useEffect)(()=>{x&&Q(w)},[x,w]),(0,Y.useEffect)(()=>{x&&!w.projectId&&m[0]&&T(e=>e.projectId?e:{...e,projectId:m[0].id})},[x,w.projectId,m]);let R=(0,Y.useCallback)((e,t)=>{T(n=>({...n,[e]:t})),le(e=>Object.keys(e).length?{}:e)},[]),z=(0,Y.useMemo)(()=>Oe(w),[w]),B={...ce,...se?z.errors:{}},V=e=>B[e],H=b[w.projectId],W=w.hostId||H?.defaultHostId||null,G=W?g[W]:void 0,je=w.profileId||H?.defaultProfileId||null,Ne=(0,Y.useCallback)(e=>v[e]?.title,[v]),Fe=(0,Y.useMemo)(()=>ke(Ve(w),{projectName:H?.name,hostName:w.hostId?g[w.hostId]?.name??null:null,profileName:w.profileId?_[w.profileId]?.name??null:null,taskTitle:Ne}),[w,H?.name,g,_,Ne]),Ie=()=>{requestAnimationFrame(()=>{ie.current?.querySelector(`[aria-invalid="true"]`)?.focus()})},Le=()=>(O(!0),z.input||Ie(),z.input),K=async()=>{let r=Le();if(!r)M.error(`Fix the highlighted fields before saving`);else{k(!0);try{if(x){let e=await ne(`/api/automations`,r);if(!e||typeof e!=`object`||!e.id)throw Error(`The coordinator did not return the new automation`);U.getState().put(e),Q(null),M.success(`Created ${e.name}`),t(nt(e.id),{replace:!0,state:n.state});return}let i=await l(q(e.id),r);if(i&&typeof i==`object`&&i.id){U.getState().put(i),F.current=i.updatedAt;let e=Pe(i);T(e),D($(e))}else D(I);P(!1),O(!1),M.success(`Saved ${r.name}`)}catch(e){let t=st(e);le(t),Object.keys(t).length&&Ie(),M.error(`Could not save: ${y(e)}. Your changes are kept.`)}finally{k(!1)}}},Re=async()=>{if(e){A(!0);try{await a(q(e.id)),N(!1),M.success(`Deleted ${e.name}`),o(),U.getState().remove(e.id)}catch(e){M.error(`Could not delete: ${y(e)}`)}finally{A(!1)}}},{busy:ze,run:Be}=De(()=>we(e=>e+1)),He=e?!!ze[e.id]:!1,Ue=()=>e&&void Be(e),We=()=>{let e=Ae({projectId:m[0]?.id,timezone:Me()});T(e),O(!1),Q(null)},J=x?`New automation`:e.name,Ge=(0,X.jsxs)(X.Fragment,{children:[!x&&(0,X.jsx)(c,{icon:(0,X.jsx)(de,{className:`size-4`}),busy:He,onClick:Ue,title:L?`Runs the saved version`:void 0,children:`Run now`}),x&&L&&(0,X.jsx)(c,{variant:`ghost`,icon:(0,X.jsx)(ge,{className:`size-4`}),onClick:We,children:`Discard draft`})]}),Ke=e=>(0,X.jsx)(c,{type:`submit`,form:S,variant:`primary`,busy:ue,block:e,icon:(0,X.jsx)(fe,{className:`size-4`}),children:x?`Create automation`:`Save`}),Z=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{summary:Fe,errorCount:se?Object.keys(z.errors).length:0}),(0,X.jsx)(Ye,{automationId:e?.id??null,dirty:L,getInput:Le,currentKey:JSON.stringify(z.input)}),e&&e.trigger.kind===`webhook`&&(0,X.jsx)(Qe,{automation:e}),e&&(0,X.jsx)(et,{automationId:e.id,refreshKey:Ce,onRun:Ue})]});return(0,X.jsxs)(`div`,{"data-testid":`automation-editor`,className:`flex w-full min-w-0 flex-col gap-4 px-4 pt-4 md:px-6`,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsxs)(s,{to:tt,onClick:Te(o),className:`tap inline-flex items-center gap-1 self-start rounded text-sm text-muted hover:text-text`,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`size-4`}),`Automations`]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 text-lg font-semibold break-words`,children:J}),L&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,X.jsx)(xe,{"aria-hidden":!0,className:`size-3.5`}),`Unsaved changes`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Ge,d&&Ke()]})]})]}),(0,X.jsx)(te,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),G&&G.connectivity!==`connected`&&(0,X.jsx)(p,{compact:!0,hostName:G.name,connectivity:G.connectivity,lastSeenAt:G.lastSeenAt,detail:`Occurrences are still recorded; their tasks wait until the host is reachable.`}),Se&&(0,X.jsxs)(`p`,{role:`status`,className:`flex items-start gap-1.5 rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:[(0,X.jsx)(C,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-warning`}),`This automation changed elsewhere. Saving overwrites those changes with yours.`]}),(0,X.jsxs)(`div`,{className:re(`grid min-w-0 gap-4`,d?`grid-cols-[minmax(0,1fr)_minmax(320px,400px)] items-start`:`grid-cols-1`),children:[(0,X.jsxs)(`form`,{id:S,ref:ie,noValidate:!0,"aria-label":J,onSubmit:e=>{e.preventDefault(),K()},className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(lt,{draft:w,update:R,err:V,projects:m}),(0,X.jsx)(ft,{draft:w,update:R,err:V,tasks:v,projectsById:b,savedAutomation:e,segmented:u!==`mobile`}),(0,X.jsx)(pt,{draft:w,setDraft:T,err:V}),(0,X.jsx)(mt,{draft:w,update:R,err:V}),(0,X.jsx)(ht,{draft:w,update:R,err:V,hosts:h,profiles:Object.values(_).sort((e,t)=>e.name.localeCompare(t.name)),defaultHostName:H?.defaultHostId?g[H.defaultHostId]?.name:void 0,defaultProfileName:H?.defaultProfileId?_[H.defaultProfileId]?.name:void 0,selectedProfileMissing:!!je&&!_[je]}),(0,X.jsx)(gt,{draft:w,update:R}),(0,X.jsx)(_t,{draft:w,update:R,err:V}),(0,X.jsx)(vt,{draft:w,update:R,err:V,projectChecks:H?.checks}),B.form&&(0,X.jsx)(Ee,{children:B.form})]}),(0,X.jsx)(`aside`,{"aria-label":`Summary, preview and history`,className:`flex min-w-0 flex-col gap-4`,children:Z})]}),!x&&e&&(0,X.jsx)(pe,{description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,children:(0,X.jsx)(c,{variant:`danger`,icon:(0,X.jsx)(me,{className:`size-4`}),onClick:()=>N(!0),children:`Delete automation`})}),d?(0,X.jsx)(`div`,{className:`h-4`}):(0,X.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 flex items-center gap-3 border-t border-border bg-surface px-4 py-2 md:-mx-6 md:px-6`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:L?`Unsaved changes`:x?`Not saved yet`:`All changes saved`}),Ke()]}),(0,X.jsx)(oe,{open:j,onClose:()=>N(!1),title:`Delete ${e?.name??`automation`}?`,description:`Future occurrences stop. Tasks it already created stay on the board; its history is removed.`,confirmLabel:`Delete automation`,confirmIcon:(0,X.jsx)(me,{className:`size-4`}),busy:he,onConfirm:()=>void Re()})]})}function lt({draft:e,update:t,err:n,projects:r}){return(0,X.jsxs)(R,{stack:!0,title:`Basics`,children:[(0,X.jsx)(L,{label:`Name`,error:n(`name`),children:n=>(0,X.jsx)(j,{...n,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`Daily dependency check`,autoComplete:`off`})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Project`,error:n(`projectId`),hint:r.length===0?(0,X.jsxs)(X.Fragment,{children:[`No active projects.`,` `,(0,X.jsx)(I,{to:`/settings/projects`,children:`Connect a repository in Settings`}),`.`]}):void 0,children:n=>(0,X.jsxs)(B,{...n,value:e.projectId,onChange:e=>t(`projectId`,e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose a project`}),r.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,X.jsx)(L,{label:`Status`,hint:`Disabled automations keep their history and can still run manually.`,children:n=>(0,X.jsx)(V,{...n,checked:e.enabled,onChange:e=>t(`enabled`,e),label:`Enabled`,onText:`Enabled`,offText:`Disabled`,className:`self-start`})})]})]})}var ut=[`manual`,`once`,`cron`,`webhook`,`dependency`],dt={manual:`Runs only when you press Run now (or from the CLI).`,once:`Runs a single time at the chosen moment.`,cron:`Runs on a timezone-aware cron schedule.`,webhook:`Runs when an authenticated JSON POST arrives at this automation's webhook URL.`,dependency:`Runs when the chosen task is done.`};function ft({draft:e,update:t,err:n,tasks:r,projectsById:a,savedAutomation:o,segmented:s}){let c=i(e=>e.hydrated),l=e.triggerKind===`cron`?Ue(e.cronExpr):null,u=e.triggerKind===`cron`&&!l?ze(e.cronExpr,e.cronTimezone.trim()||void 0)??`Valid expression (no plain-language description available)`:null,d=(0,Y.useMemo)(()=>{try{return Intl.supportedValuesOf?.(`timeZone`)}catch{return}},[]),f=(0,Y.useId)(),p=Me(),m=(0,Y.useMemo)(()=>Object.values(r).filter(t=>t.state!==`canceled`||t.id===e.dependencyTaskId).sort((e,t)=>e.title.localeCompare(t.title)),[r,e.dependencyTaskId]),h=e.triggerKind===`once`?Fe(e.onceAt):``;return(0,X.jsxs)(R,{stack:!0,title:`Trigger`,description:dt[e.triggerKind],children:[s?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`text-sm font-medium`,children:`Trigger kind`}),(0,X.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain`,children:(0,X.jsx)(O,{label:`Trigger kind`,value:e.triggerKind,onChange:e=>t(`triggerKind`,e),options:ut.map(e=>({value:e,label:W[e]}))})})]}):(0,X.jsx)(L,{label:`Trigger kind`,children:n=>(0,X.jsx)(B,{...n,value:e.triggerKind,onChange:e=>t(`triggerKind`,e.target.value),children:ut.map(e=>(0,X.jsx)(`option`,{value:e,children:W[e]},e))})}),e.triggerKind===`once`&&(0,X.jsx)(L,{label:`Run at`,error:n(`onceAt`),hint:`Local time (${p})${h?`; saved as ${h}`:``}.`,children:n=>(0,X.jsx)(j,{...n,type:`datetime-local`,value:e.onceAt,onChange:e=>t(`onceAt`,e.target.value)})}),e.triggerKind===`cron`&&(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Cron expression`,error:n(`cronExpr`)??l??void 0,hint:`minute hour day-of-month month day-of-week, e.g. 0 9 * * 1-5`,children:n=>(0,X.jsx)(j,{...n,"aria-invalid":l?!0:n[`aria-invalid`],value:e.cronExpr,onChange:e=>t(`cronExpr`,e.target.value),className:`font-mono`,autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`})}),(0,X.jsx)(L,{label:`Timezone`,error:n(`cronTimezone`),hint:e.cronTimezone.trim()===p?`IANA timezone name; daylight saving is handled.`:(0,X.jsxs)(I,{onClick:()=>t(`cronTimezone`,p),children:[`Use this device's timezone (`,p,`)`]}),children:n=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{...n,list:d?f:void 0,value:e.cronTimezone,onChange:e=>t(`cronTimezone`,e.target.value),autoComplete:`off`,spellCheck:!1,autoCapitalize:`off`}),d&&(0,X.jsx)(`datalist`,{id:f,children:d.map(e=>(0,X.jsx)(`option`,{value:e},e))})]})}),u&&(0,X.jsxs)(`p`,{className:`flex items-start gap-1.5 text-sm sm:col-span-2`,"aria-live":`polite`,"data-testid":`cron-description`,children:[(0,X.jsx)(E,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:u})]})]}),e.triggerKind===`webhook`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm text-muted`,children:[(0,X.jsxs)(`p`,{children:[`Senders POST a JSON body (up to 256 KB) with`,` `,(0,X.jsx)(`code`,{children:`Authorization: Bearer <token>`}),`. Use the filters below to fire only for matching payloads, and `,(0,X.jsx)(`code`,{children:`{{payload.<path>}}`}),` to copy payload values into the task.`]}),o?o.trigger.kind===`webhook`?(0,X.jsxs)(`p`,{children:[`Token:`,` `,o.webhookTokenSet?`set (see Webhook below to rotate)`:`not created yet`]}):(0,X.jsx)(`p`,{children:`Save to switch this automation to a webhook trigger, then create a token.`}):(0,X.jsx)(`p`,{children:`Save the automation to create its webhook token and URL.`})]}),e.triggerKind===`dependency`&&(0,X.jsx)(L,{label:`When this task is done`,error:n(`dependencyTaskId`),hint:`Fires once each time the task enters Done.`,children:n=>(0,X.jsxs)(B,{...n,value:e.dependencyTaskId,onChange:e=>t(`dependencyTaskId`,e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose a task`}),e.dependencyTaskId&&!r[e.dependencyTaskId]&&(0,X.jsx)(`option`,{value:e.dependencyTaskId,children:c?`Deleted task`:`Loading task…`}),m.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.title,a[e.projectId]?` (${a[e.projectId].name})`:``,e.state===`done`?` - done`:``]},e.id))]})})]})}function pt({draft:e,setDraft:t,err:n}){let r=(e,n)=>t(t=>({...t,filters:t.filters.map((t,r)=>r===e?{...t,...n}:t)})),i=e.triggerKind===`webhook`;return(0,X.jsxs)(R,{stack:!0,title:`Filters`,description:`Filters apply to webhook payloads. Each row compares a dot path (for example pull_request.base.ref) with an exact value; all rows must match. Payloads that do not match are recorded as Filtered out.`,children:[!i&&(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`Filters are ignored unless the trigger is Webhook.`}),e.filters.length===0&&(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:`No filters: every payload fires.`}),e.filters.map((e,i)=>(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-end gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,X.jsx)(L,{label:`Path ${i+1}`,error:n(`filters.${i}.path`),children:t=>(0,X.jsx)(j,{...t,value:e.path,onChange:e=>r(i,{path:e.target.value}),placeholder:`action`,className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})}),(0,X.jsx)(L,{label:`Equals ${i+1}`,error:n(`filters.${i}.equals`),className:`col-start-1 row-start-2 sm:col-start-auto sm:row-start-auto`,children:t=>(0,X.jsx)(j,{...t,value:e.equals,onChange:e=>r(i,{equals:e.target.value}),placeholder:`opened`})}),(0,X.jsx)(w,{label:`Remove filter ${i+1}`,icon:(0,X.jsx)(ge,{className:`size-4`}),onClick:()=>t(e=>({...e,filters:e.filters.filter((e,t)=>t!==i)}))})]},i)),(0,X.jsx)(`div`,{children:(0,X.jsx)(c,{size:`sm`,icon:(0,X.jsx)(k,{className:`size-3.5`}),onClick:()=>t(e=>({...e,filters:[...e.filters,{path:``,equals:``}]})),children:`Add filter`})})]})}function mt({draft:e,update:t,err:n}){return(0,X.jsxs)(R,{stack:!0,title:`Task template`,description:`Use ${Ne.join(`, `)} in the title, objective, criteria and grouping key.`,children:[(0,X.jsx)(L,{label:`Task title`,error:n(`title`),children:n=>(0,X.jsx)(j,{...n,value:e.title,onChange:e=>t(`title`,e.target.value),placeholder:`Triage new issues for {{date}}`})}),(0,X.jsx)(L,{label:`Objective`,error:n(`objective`),children:n=>(0,X.jsx)(N,{...n,minRows:4,value:e.objective,onChange:e=>t(`objective`,e.target.value)})}),(0,X.jsx)(L,{label:`Acceptance criteria`,error:n(`criteria`),hint:`One criterion per line.`,optional:!0,children:n=>(0,X.jsx)(N,{...n,minRows:3,value:e.criteria,onChange:e=>t(`criteria`,e.target.value)})}),(0,X.jsx)(L,{label:`Priority`,error:n(`priority`),children:n=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(ue,{priority:e.priority}),(0,X.jsx)(le,{...n,value:e.priority,onChange:e=>t(`priority`,e),className:`sm:max-w-48`})]})})]})}function ht({draft:e,update:t,err:n,hosts:r,profiles:i,defaultHostName:a,defaultProfileName:o,selectedProfileMissing:s}){return(0,X.jsxs)(R,{stack:!0,title:`Where and how it runs`,children:[(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Host`,error:n(`hostId`),children:n=>(0,X.jsxs)(B,{...n,value:e.hostId,onChange:e=>t(`hostId`,e.target.value),children:[(0,X.jsxs)(`option`,{value:``,children:[`Project default`,a?` (${a})`:``]}),e.hostId&&!r.some(t=>t.id===e.hostId)&&(0,X.jsx)(`option`,{value:e.hostId,children:`Unknown host`}),r.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id))]})}),(0,X.jsx)(L,{label:`Profile`,error:n(`profileId`),hint:s?`The selected profile is no longer available.`:void 0,children:n=>(0,X.jsxs)(B,{...n,value:e.profileId,onChange:e=>t(`profileId`,e.target.value),children:[(0,X.jsxs)(`option`,{value:``,children:[`Project default`,o?` (${o})`:``]}),e.profileId&&!i.some(t=>t.id===e.profileId)&&(0,X.jsx)(`option`,{value:e.profileId,children:`Unknown profile`}),i.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,X.jsx)(z,{legend:`Mode`,value:e.mode,options:Ie,onChange:e=>t(`mode`,e)}),(0,X.jsx)(L,{label:`Grouping key`,optional:e.mode!==`continue`,error:n(`groupingKey`),hint:`Occurrences with the same rendered key are the same work: Continue reuses that task and overlap checks compare it. Supports template variables, e.g. pr-{{payload.number}}.`,children:n=>(0,X.jsx)(j,{...n,value:e.groupingKey,onChange:e=>t(`groupingKey`,e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1})})]})}function gt({draft:e,update:t}){let n=e.triggerKind===`cron`||e.triggerKind===`once`;return(0,X.jsxs)(R,{stack:!0,title:`Overlap and missed runs`,children:[(0,X.jsx)(z,{legend:`When previous work is still open`,value:e.overlap,options:Re,onChange:e=>t(`overlap`,e)}),(0,X.jsx)(z,{legend:`Missed runs`,value:e.missed,options:Be,onChange:e=>t(`missed`,e),hint:n?`A run is missed when the coordinator was down at its scheduled time.`:`Only applies to Schedule and Once triggers.`})]})}function _t({draft:e,update:t,err:n}){return(0,X.jsxs)(R,{stack:!0,title:`Limits`,description:`Continuation prompts the agent to keep going after a turn ends without finishing. It is off by default.`,children:[(0,X.jsx)(L,{label:`Automatic continuation`,children:n=>(0,X.jsx)(V,{...n,checked:e.continuationEnabled,onChange:e=>t(`continuationEnabled`,e),label:`Automatic continuation`,className:`self-start`})}),e.continuationEnabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{label:`Continuation objective`,error:n(`continuationObjective`),hint:`What the agent must achieve before it reports done.`,children:n=>(0,X.jsx)(N,{...n,minRows:2,value:e.continuationObjective,onChange:e=>t(`continuationObjective`,e.target.value)})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(L,{label:`Max continuations`,error:n(`maxContinuations`),hint:`1–50`,children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,max:50,step:1,value:e.maxContinuations,onChange:e=>t(`maxContinuations`,e.target.value)})}),(0,X.jsx)(L,{label:`Max elapsed minutes`,error:n(`maxElapsedMinutes`),hint:`1–1440`,children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,max:1440,step:1,value:e.maxElapsedMinutes,onChange:e=>t(`maxElapsedMinutes`,e.target.value)})}),(0,X.jsx)(L,{label:`Continuation budget: tokens`,optional:!0,error:n(`maxTokens`),children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`numeric`,min:1,step:1,value:e.maxTokens,onChange:e=>t(`maxTokens`,e.target.value)})}),(0,X.jsx)(L,{label:`Continuation budget: cost (USD)`,optional:!0,error:n(`maxCostUsd`),children:n=>(0,X.jsx)(j,{...n,type:`number`,inputMode:`decimal`,min:.01,step:.01,value:e.maxCostUsd,onChange:e=>t(`maxCostUsd`,e.target.value)})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted`,children:he})]})]})}function vt({draft:e,update:t,err:n,projectChecks:r}){let i=r&&r.length>0?`the project's checks (${r.join(`, `)})`:`the project's checks`;return(0,X.jsxs)(R,{stack:!0,title:`Review`,children:[(0,X.jsx)(L,{label:`Checks`,optional:!0,error:n(`checks`),hint:`One command per line. Leave empty to use ${i}.`,children:n=>(0,X.jsx)(N,{...n,minRows:2,value:e.checks,onChange:e=>t(`checks`,e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`})}),(0,X.jsx)(L,{label:`Human review`,hint:`When on, finished work waits in Review for you instead of completing on passing checks.`,children:n=>(0,X.jsx)(V,{...n,checked:e.requireHumanReview,onChange:e=>t(`requireHumanReview`,e),label:`Require human review`,onText:`Required`,offText:`Not required`,className:`self-start`})})]})}export{it as default};
|
|
2
|
+
//# sourceMappingURL=AutomationView-BdmWs08y.js.map
|