@lukstei/dsh-schedule-script 0.0.0-stage → 0.2.2-rc.5.4

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/src/client.tsx ADDED
@@ -0,0 +1,717 @@
1
+ import type { Context as ClientContext } from "@deepseek-ai/cordis";
2
+ import type {} from "@deepseek-ai/dsh-api-remotes/client";
3
+ import type {} from "@deepseek-ai/dsh-client-ui-chat/client";
4
+ import type {} from "@deepseek-ai/dsh-client-ui-conversation/client";
5
+ import {
6
+ DisclosureRow,
7
+ IconApiOutlineRegular,
8
+ TextShimmer,
9
+ useDismissOnOutsidePointer,
10
+ } from "@deepseek-ai/dsh-client-ui-primitives";
11
+ import type {} from "@deepseek-ai/dsh-client-ui-renderer/client";
12
+ import type { ScheduleCatalogEntry } from "@deepseek-ai/dsh-schedule/client";
13
+ import type { SessionProjectionMap } from "@deepseek-ai/dsh-session-projection";
14
+ import {
15
+ type CSSProperties,
16
+ type RefObject,
17
+ useEffect,
18
+ useId,
19
+ useRef,
20
+ useState,
21
+ } from "react";
22
+ import { createPortal } from "react-dom";
23
+ import { parseScriptPrompt } from "./parser.ts";
24
+ import { SCHEDULE_SCRIPT_CSS } from "./styles.ts";
25
+ import {
26
+ SCHEDULE_SCRIPT_EVENT_NAME,
27
+ type ScheduleScriptEventPayload,
28
+ type ScheduleScriptPromptPayload,
29
+ type ScheduleScriptSummary,
30
+ type ScheduleSystemStatus,
31
+ type ScriptExecutionStatus,
32
+ } from "./types.ts";
33
+
34
+ export interface ScheduleCatalogStatusResult {
35
+ readonly status?: ScheduleSystemStatus;
36
+ readonly settled: boolean;
37
+ readonly matchingItem?: ScheduleCatalogEntry;
38
+ readonly parsedPrompt?: ScheduleScriptPromptPayload;
39
+ }
40
+
41
+ export interface ScheduleScriptPromptProps {
42
+ readonly summary?: ScheduleScriptSummary | null;
43
+ readonly initialOpen?: boolean;
44
+ readonly scheduleStatus?: ScheduleSystemStatus;
45
+ }
46
+
47
+ export function useScheduleCatalogStatus(
48
+ ctx: ClientContext,
49
+ sessionId: string,
50
+ scriptPath?: string,
51
+ ): ScheduleCatalogStatusResult {
52
+ const [catalogStatus, setCatalogStatus] =
53
+ useState<ScheduleCatalogStatusResult>({
54
+ settled: false,
55
+ });
56
+
57
+ useEffect(() => {
58
+ setCatalogStatus({ settled: false });
59
+
60
+ let active = true;
61
+
62
+ const refresh = async () => {
63
+ try {
64
+ const result = await ctx.remote.schedule.catalog();
65
+ if (!active || !result.ok) return;
66
+ const items = result.value;
67
+
68
+ let parsedMatch: ScheduleScriptPromptPayload | undefined;
69
+ const matching = items.find((item) => {
70
+ const targetSessionId =
71
+ item.lastDelivery === undefined
72
+ ? undefined
73
+ : item.lastDelivery.targetSessionId;
74
+ const isTarget =
75
+ (item.target.kind === "session" &&
76
+ item.target.sessionId === sessionId) ||
77
+ targetSessionId === sessionId;
78
+ const isInvolved = item.involvedSessionIds.some(
79
+ (id) => id === sessionId,
80
+ );
81
+ if (!isTarget && !isInvolved) return false;
82
+ if (typeof item.prompt !== "string") return false;
83
+ const parsed = parseScriptPrompt(item.prompt);
84
+ if (!parsed) return false;
85
+ if (scriptPath && parsed.scriptPath !== scriptPath) return false;
86
+ parsedMatch = parsed;
87
+ return true;
88
+ });
89
+
90
+ if (matching) {
91
+ setCatalogStatus({
92
+ status:
93
+ matching.status === "paused"
94
+ ? "paused"
95
+ : matching.status === "ended"
96
+ ? "ended"
97
+ : "active",
98
+ settled: true,
99
+ matchingItem: matching,
100
+ parsedPrompt: parsedMatch,
101
+ });
102
+ } else {
103
+ setCatalogStatus({
104
+ status: "deleted",
105
+ settled: true,
106
+ });
107
+ }
108
+ } catch {
109
+ // retain prior status on fetch failure
110
+ }
111
+ };
112
+
113
+ const changed = ctx.remote.$on("schedule/changed", refresh);
114
+ const reset = ctx.on("connection/reset", refresh);
115
+ void refresh();
116
+ return () => {
117
+ active = false;
118
+ changed();
119
+ reset();
120
+ };
121
+ }, [ctx, sessionId, scriptPath]);
122
+
123
+ return catalogStatus;
124
+ }
125
+
126
+ export interface EffectiveScriptState {
127
+ readonly scheduleStatus?: ScheduleSystemStatus;
128
+ readonly scriptStatus: ScriptExecutionStatus;
129
+ readonly displayStatus: "active" | "paused" | "warning" | "error" | "stopped";
130
+ readonly badgeText: string;
131
+ }
132
+
133
+ export function resolveEffectiveScriptState(
134
+ summary: ScheduleScriptSummary,
135
+ scheduleStatus?: ScheduleSystemStatus,
136
+ ): EffectiveScriptState {
137
+ const scriptStatus: ScriptExecutionStatus =
138
+ summary.scriptStatus ??
139
+ (scheduleStatus === "deleted" || scheduleStatus === "ended"
140
+ ? "stopped"
141
+ : "idle");
142
+
143
+ if (scriptStatus === "error" || summary.lastError?.fatal) {
144
+ return {
145
+ scheduleStatus,
146
+ scriptStatus,
147
+ displayStatus: "error",
148
+ badgeText: "Error",
149
+ };
150
+ }
151
+ if (scriptStatus === "stopped") {
152
+ return {
153
+ scheduleStatus,
154
+ scriptStatus,
155
+ displayStatus: "stopped",
156
+ badgeText: "Stopped",
157
+ };
158
+ }
159
+ if (scheduleStatus === "deleted" || scheduleStatus === "ended") {
160
+ return {
161
+ scheduleStatus,
162
+ scriptStatus,
163
+ displayStatus: "stopped",
164
+ badgeText: "Stopped",
165
+ };
166
+ }
167
+ if (scheduleStatus === "paused") {
168
+ return {
169
+ scheduleStatus,
170
+ scriptStatus,
171
+ displayStatus: "paused",
172
+ badgeText: "Paused",
173
+ };
174
+ }
175
+ if (
176
+ scriptStatus === "warning" ||
177
+ (Boolean(summary.lastError) && !summary.lastError?.fatal)
178
+ ) {
179
+ return {
180
+ scheduleStatus,
181
+ scriptStatus,
182
+ displayStatus: "warning",
183
+ badgeText: "Warning",
184
+ };
185
+ }
186
+ return {
187
+ scheduleStatus,
188
+ scriptStatus,
189
+ displayStatus: "active",
190
+ badgeText: "Active",
191
+ };
192
+ }
193
+
194
+ export function shouldRenderPill(
195
+ summary: ScheduleScriptSummary | null | undefined,
196
+ scheduleStatus?: ScheduleSystemStatus,
197
+ ): summary is ScheduleScriptSummary {
198
+ if (!summary) return false;
199
+ const hasError =
200
+ summary.scriptStatus === "error" || Boolean(summary.lastError);
201
+ if (
202
+ !hasError &&
203
+ summary.totalRuns === 0 &&
204
+ (scheduleStatus === "deleted" ||
205
+ scheduleStatus === "ended" ||
206
+ summary.scriptStatus === "stopped")
207
+ ) {
208
+ return false;
209
+ }
210
+ if (
211
+ hasError ||
212
+ summary.totalRuns > 0 ||
213
+ scheduleStatus === "active" ||
214
+ scheduleStatus === "paused" ||
215
+ summary.scriptPath
216
+ ) {
217
+ return true;
218
+ }
219
+ return false;
220
+ }
221
+
222
+ export function TimerIcon({ size = 14 }: { size?: number }) {
223
+ return (
224
+ <svg
225
+ width={size}
226
+ height={size}
227
+ viewBox="0 0 16 16"
228
+ fill="none"
229
+ stroke="currentColor"
230
+ strokeWidth="1.3"
231
+ strokeLinecap="round"
232
+ strokeLinejoin="round"
233
+ aria-hidden="true"
234
+ >
235
+ <circle cx="8" cy="8" r="6.5" />
236
+ <polyline points="8 4.5 8 8 10.5 9.5" />
237
+ </svg>
238
+ );
239
+ }
240
+
241
+ export function formatDuration(durationMs?: number): string {
242
+ if (durationMs === undefined) return "0.0s";
243
+ return `${(durationMs / 1000).toFixed(1)}s`;
244
+ }
245
+
246
+ export function formatRelativeTime(timestamp?: number): string {
247
+ if (!timestamp) return "Pending first run";
248
+ const elapsedSec = Math.max(0, Math.floor((Date.now() - timestamp) / 1000));
249
+ if (elapsedSec < 5) return "just now";
250
+ if (elapsedSec < 60) return `${elapsedSec}s ago`;
251
+ const elapsedMin = Math.floor(elapsedSec / 60);
252
+ if (elapsedMin < 60) return `${elapsedMin}m ago`;
253
+ const elapsedHours = Math.floor(elapsedMin / 60);
254
+ if (elapsedHours < 24) return `${elapsedHours}h ago`;
255
+ const elapsedDays = Math.floor(elapsedHours / 24);
256
+ return `${elapsedDays}d ago`;
257
+ }
258
+
259
+ export function formatClockTime(timestamp: number): string {
260
+ const d = new Date(timestamp);
261
+ return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
262
+ }
263
+
264
+ export interface ScheduleScriptPopoverCardProps {
265
+ readonly summary: ScheduleScriptSummary;
266
+ readonly scheduleStatus?: ScheduleSystemStatus;
267
+ readonly isStatic?: boolean;
268
+ readonly cardRef?: RefObject<HTMLDivElement | null>;
269
+ readonly style?: CSSProperties;
270
+ }
271
+
272
+ export function ScheduleScriptPopoverCard({
273
+ summary,
274
+ scheduleStatus,
275
+ isStatic = false,
276
+ cardRef,
277
+ style,
278
+ }: ScheduleScriptPopoverCardProps) {
279
+ const effective = resolveEffectiveScriptState(summary, scheduleStatus);
280
+ const statusKey = effective.displayStatus;
281
+ const statusText = effective.badgeText;
282
+ const isFatal = statusKey === "error";
283
+ const isPaused = statusKey === "paused";
284
+ const isStopped = statusKey === "stopped";
285
+ const isWarning = statusKey === "warning";
286
+ const isCompleted = statusKey === "active";
287
+
288
+ const scriptName = summary.scriptPath
289
+ ? (summary.scriptPath.split("/").pop() ?? "script.ts")
290
+ : "Background Script";
291
+
292
+ return (
293
+ <div
294
+ ref={cardRef}
295
+ style={style}
296
+ className={`dsh-schedule-popover ${isStatic ? "is-static" : ""}`}
297
+ role="dialog"
298
+ aria-label="Schedule script telemetry"
299
+ onClick={(e) => e.stopPropagation()}
300
+ >
301
+ <div className="dsh-schedule-popover-header">
302
+ <div className="dsh-schedule-popover-title">
303
+ <TimerIcon size={14} />
304
+ <span>{scriptName}</span>
305
+ </div>
306
+ <span className="dsh-schedule-status-badge" data-status={statusKey}>
307
+ <span className="dsh-schedule-dot" data-status={statusKey} />
308
+ {statusText}
309
+ </span>
310
+ </div>
311
+
312
+ <div className="dsh-schedule-details-grid">
313
+ <div className="dsh-schedule-detail-row">
314
+ <span>Script</span>
315
+ <span
316
+ className="dsh-schedule-mono-badge"
317
+ title={summary.scriptPath ?? "n/a"}
318
+ >
319
+ {summary.scriptPath ?? "n/a"}
320
+ </span>
321
+ </div>
322
+ <div className="dsh-schedule-detail-row">
323
+ <span>Total Runs</span>
324
+ <span className="dsh-schedule-detail-value">{summary.totalRuns}</span>
325
+ </div>
326
+ <div className="dsh-schedule-detail-row">
327
+ <span>Last Duration</span>
328
+ <span className="dsh-schedule-detail-value">
329
+ {formatDuration(summary.lastDurationMs)}
330
+ </span>
331
+ </div>
332
+ <div className="dsh-schedule-detail-row">
333
+ <span>Last Run</span>
334
+ <span
335
+ className="dsh-schedule-detail-value"
336
+ title={
337
+ summary.lastRunAt
338
+ ? new Date(summary.lastRunAt).toLocaleString()
339
+ : undefined
340
+ }
341
+ >
342
+ {formatRelativeTime(summary.lastRunAt)}
343
+ </span>
344
+ </div>
345
+ {isWarning && summary.lastError?.message && (
346
+ <div className="dsh-schedule-detail-row">
347
+ <span>Error</span>
348
+ <span
349
+ className="dsh-schedule-detail-value dsh-schedule-error-value"
350
+ title={summary.lastError.message}
351
+ >
352
+ {summary.lastError.message}
353
+ </span>
354
+ </div>
355
+ )}
356
+ </div>
357
+
358
+ {summary.cleanupError && (
359
+ <div className="dsh-schedule-command-error-line">
360
+ {summary.cleanupError}
361
+ </div>
362
+ )}
363
+ {isFatal ? (
364
+ <div className="dsh-schedule-callout dsh-schedule-callout-fatal">
365
+ <div className="dsh-schedule-callout-header">✖ Fatal Error</div>
366
+ <div>
367
+ {summary.lastError?.message ||
368
+ "Execution failed with an unhandled exception"}
369
+ </div>
370
+ </div>
371
+ ) : isPaused ? (
372
+ <div className="dsh-schedule-callout dsh-schedule-callout-paused">
373
+ <div className="dsh-schedule-callout-header">⏸ Paused</div>
374
+ <div>
375
+ Schedule is paused in Automation Tasks. Resume in UI to continue.
376
+ </div>
377
+ </div>
378
+ ) : isStopped ? (
379
+ <div className="dsh-schedule-callout dsh-schedule-callout-stopped">
380
+ <div className="dsh-schedule-callout-header">⏹ Stopped</div>
381
+ <div>
382
+ {summary.scriptStatus === "stopped"
383
+ ? `Execution stopped cleanly after #${summary.totalRuns} runs`
384
+ : effective.scheduleStatus === "deleted"
385
+ ? "Automation task was deleted in Automation Tasks"
386
+ : "Schedule was stopped in Automation Tasks"}
387
+ </div>
388
+ </div>
389
+ ) : isWarning ? (
390
+ <div className="dsh-schedule-callout dsh-schedule-callout-warning">
391
+ <div className="dsh-schedule-callout-header">⚠ Warning</div>
392
+ <div>{summary.lastError?.message}</div>
393
+ </div>
394
+ ) : isCompleted ? (
395
+ <div className="dsh-schedule-callout dsh-schedule-callout-completed">
396
+ <div className="dsh-schedule-callout-header">✔ Completed</div>
397
+ <div>Run #{summary.totalRuns} completed successfully</div>
398
+ </div>
399
+ ) : null}
400
+ </div>
401
+ );
402
+ }
403
+
404
+ export type UseProjectionHook = <K extends keyof SessionProjectionMap>(
405
+ key: K,
406
+ ) => SessionProjectionMap[K];
407
+
408
+ export interface ConnectedScheduleScriptPromptButtonProps {
409
+ readonly ctx: ClientContext;
410
+ readonly sessionId: string;
411
+ readonly useProjection: UseProjectionHook;
412
+ }
413
+
414
+ export function ConnectedScheduleScriptPromptButton({
415
+ ctx,
416
+ sessionId,
417
+ useProjection,
418
+ }: ConnectedScheduleScriptPromptButtonProps) {
419
+ const projection = useProjection("dshScheduleScript");
420
+ const catalog = useScheduleCatalogStatus(
421
+ ctx,
422
+ sessionId,
423
+ projection?.scriptPath,
424
+ );
425
+ const summary: ScheduleScriptSummary | undefined =
426
+ projection ??
427
+ (catalog.parsedPrompt !== undefined &&
428
+ (catalog.status === "active" || catalog.status === "paused")
429
+ ? {
430
+ scriptStatus: "idle",
431
+ totalRuns: 0,
432
+ scriptPath: catalog.parsedPrompt.scriptPath,
433
+ state: catalog.parsedPrompt.state,
434
+ }
435
+ : undefined);
436
+ return (
437
+ <ScheduleScriptPromptButton
438
+ summary={summary}
439
+ scheduleStatus={catalog.status}
440
+ />
441
+ );
442
+ }
443
+
444
+ export function ScheduleScriptPromptButton(props: ScheduleScriptPromptProps) {
445
+ const anchorName = `--dsh-schedule-${useId()}`;
446
+ const summary = props.summary;
447
+ const [open, setOpen] = useState(props.initialOpen ?? false);
448
+
449
+ const buttonRef = useRef<HTMLButtonElement>(null);
450
+ const panelRef = useRef<HTMLDivElement>(null);
451
+
452
+ useDismissOnOutsidePointer(buttonRef, open, setOpen, panelRef);
453
+
454
+ if (!shouldRenderPill(summary, props.scheduleStatus)) return null;
455
+
456
+ const effective = resolveEffectiveScriptState(summary, props.scheduleStatus);
457
+ const statusKey = effective.displayStatus;
458
+ const statusText = effective.badgeText;
459
+
460
+ const scriptName = summary.scriptPath
461
+ ? (summary.scriptPath.split("/").pop() ?? "script.ts")
462
+ : "Background Script";
463
+
464
+ const fullTooltip = `Schedule: ${scriptName} (${statusText} · ${summary.totalRuns} runs)`;
465
+
466
+ return (
467
+ <div className="dsh-schedule-root">
468
+ <style href="dsh-schedule-script" precedence="default">
469
+ {SCHEDULE_SCRIPT_CSS}
470
+ </style>
471
+
472
+ <button
473
+ ref={buttonRef}
474
+ style={{ anchorName }}
475
+ type="button"
476
+ className={`dsh-schedule-icon-btn ${open ? "is-pressed is-active" : ""}`}
477
+ title={fullTooltip}
478
+ aria-label={fullTooltip}
479
+ aria-expanded={open}
480
+ onClick={(e) => {
481
+ e.stopPropagation();
482
+ setOpen(!open);
483
+ }}
484
+ >
485
+ <TimerIcon size={14} />
486
+ <span className="dsh-schedule-dot-badge" data-status={statusKey} />
487
+ </button>
488
+
489
+ {open &&
490
+ typeof document !== "undefined" &&
491
+ createPortal(
492
+ <ScheduleScriptPopoverCard
493
+ summary={summary}
494
+ scheduleStatus={props.scheduleStatus}
495
+ cardRef={panelRef}
496
+ style={{ positionAnchor: anchorName }}
497
+ />,
498
+ document.body,
499
+ )}
500
+ </div>
501
+ );
502
+ }
503
+
504
+ // Backward-compatible alias
505
+ export const ScheduleScriptPill = ScheduleScriptPromptButton;
506
+
507
+ export interface ScheduleScriptCommandCardProps {
508
+ readonly node: {
509
+ readonly name?: string | null;
510
+ readonly args?: string | null;
511
+ readonly time?: number;
512
+ readonly outcome?: {
513
+ readonly kind: "success" | "error";
514
+ readonly text?: string;
515
+ } | null;
516
+ };
517
+ }
518
+
519
+ /**
520
+ * Renders the command line in the chat process/trajectory.
521
+ * Displays '>_ dsh-schedule-script · Completed at 10:24' with a separate line for recoverable/fatal errors when present.
522
+ */
523
+ export function ScheduleScriptCommandCard({
524
+ node,
525
+ }: ScheduleScriptCommandCardProps) {
526
+ const cardRef = useRef<HTMLDivElement>(null);
527
+
528
+ let payload: ScheduleScriptEventPayload | null = null;
529
+ if (node.args) {
530
+ try {
531
+ payload = JSON.parse(node.args) as ScheduleScriptEventPayload;
532
+ } catch {
533
+ // ignore malformed arguments
534
+ }
535
+ }
536
+
537
+ const isRunning = node.outcome === null;
538
+ const isOutcomeError = node.outcome?.kind === "error";
539
+
540
+ const completedTime =
541
+ payload && "durationMs" in payload && typeof payload.durationMs === "number"
542
+ ? payload.timestamp + payload.durationMs
543
+ : (payload?.timestamp ?? node.time);
544
+
545
+ const timeSuffix = completedTime
546
+ ? ` at ${formatClockTime(completedTime)}`
547
+ : "";
548
+
549
+ const summary = isRunning
550
+ ? "Running"
551
+ : isOutcomeError
552
+ ? `Failed${timeSuffix}`
553
+ : `Completed${timeSuffix}`;
554
+
555
+ const errorText =
556
+ payload && "error" in payload && typeof payload.error === "string"
557
+ ? payload.error
558
+ : undefined;
559
+
560
+ const isFatal = Boolean(
561
+ isOutcomeError || (payload && "fatal" in payload && payload.fatal),
562
+ );
563
+
564
+ useEffect(() => {
565
+ if (!errorText && !isFatal && !isOutcomeError) return;
566
+
567
+ const expandDisclosures = () => {
568
+ const el = cardRef.current;
569
+ if (!el) return;
570
+
571
+ const activeEl =
572
+ typeof document !== "undefined"
573
+ ? (document.activeElement as HTMLElement | null)
574
+ : null;
575
+
576
+ // 1. Expand the parent process group ("Analysis completed") if collapsed
577
+ const stepProcess = el.closest("[data-step-process]");
578
+ if (stepProcess) {
579
+ const groupBtn = stepProcess.querySelector<HTMLButtonElement>(
580
+ 'button[aria-expanded="false"]',
581
+ );
582
+ if (groupBtn) {
583
+ groupBtn.click();
584
+ }
585
+ }
586
+
587
+ // 2. Expand enclosing turn process ("Completed in Xs") if collapsed
588
+ const turnAttr = stepProcess?.getAttribute("data-chat-turn");
589
+ let turnBtn: HTMLButtonElement | null = null;
590
+ if (turnAttr) {
591
+ turnBtn = document.querySelector<HTMLButtonElement>(
592
+ `button[data-turn-process="${turnAttr}"][aria-expanded="false"]`,
593
+ );
594
+ }
595
+ if (!turnBtn) {
596
+ const flow = stepProcess?.parentElement;
597
+ if (flow) {
598
+ turnBtn = flow.querySelector<HTMLButtonElement>(
599
+ 'button[data-turn-process][aria-expanded="false"]',
600
+ );
601
+ }
602
+ }
603
+ if (turnBtn) {
604
+ turnBtn.click();
605
+ }
606
+
607
+ if (
608
+ activeEl &&
609
+ typeof activeEl.focus === "function" &&
610
+ document.activeElement !== activeEl
611
+ ) {
612
+ activeEl.focus();
613
+ }
614
+ };
615
+
616
+ expandDisclosures();
617
+ const t1 = setTimeout(expandDisclosures, 50);
618
+ const t2 = setTimeout(expandDisclosures, 200);
619
+ return () => {
620
+ clearTimeout(t1);
621
+ clearTimeout(t2);
622
+ };
623
+ }, [errorText, isFatal, isOutcomeError]);
624
+
625
+ const collapsedContent = (
626
+ <>
627
+ <span
628
+ className="dsh-schedule-command-separator"
629
+ data-shimmer-decoration
630
+ aria-hidden
631
+ />
632
+ <span
633
+ className="dsh-schedule-command-status"
634
+ data-error={isOutcomeError ? "true" : undefined}
635
+ title={
636
+ completedTime ? new Date(completedTime).toLocaleString() : undefined
637
+ }
638
+ >
639
+ <TextShimmer active={isRunning}>{summary}</TextShimmer>
640
+ </span>
641
+ </>
642
+ );
643
+
644
+ return (
645
+ <div
646
+ ref={cardRef}
647
+ className="dsh-schedule-command-card"
648
+ data-state={isOutcomeError ? "error" : isRunning ? "running" : "ok"}
649
+ >
650
+ <style href="dsh-schedule-script" precedence="default">
651
+ {SCHEDULE_SCRIPT_CSS}
652
+ </style>
653
+ <DisclosureRow
654
+ icon={<IconApiOutlineRegular size={14} />}
655
+ title={node.name ?? SCHEDULE_SCRIPT_EVENT_NAME}
656
+ running={isRunning}
657
+ open={false}
658
+ expandable={false}
659
+ onToggle={() => {}}
660
+ collapsedContent={collapsedContent}
661
+ />
662
+ {errorText && (
663
+ <div
664
+ className="dsh-schedule-command-error-line"
665
+ data-fatal={isFatal ? "true" : undefined}
666
+ >
667
+ <span className="dsh-schedule-command-error-bullet" aria-hidden>
668
+ {isFatal ? "✖" : "⚠"}
669
+ </span>
670
+ <span className="dsh-schedule-command-error-text" title={errorText}>
671
+ {errorText}
672
+ </span>
673
+ </div>
674
+ )}
675
+ </div>
676
+ );
677
+ }
678
+
679
+ export const name = "dsh-schedule-script";
680
+ export const inject = ["slots", "remote", "remote.schedule"] as const;
681
+
682
+ export function apply(ctx: ClientContext): void {
683
+ // Register in prompt toolbar (conversation.input.left) at order 85
684
+ ctx.effect(
685
+ () =>
686
+ ctx.slots.inject("conversation.input.left", () =>
687
+ ctx.slots.register(
688
+ {
689
+ name: "conversation.input.left",
690
+ id: "schedule-script.prompt-button",
691
+ order: 85,
692
+ inject: (sessionId: string) => ({
693
+ ctx,
694
+ sessionId,
695
+ }),
696
+ },
697
+ ConnectedScheduleScriptPromptButton,
698
+ ),
699
+ ),
700
+ "schedule-script: prompt-button",
701
+ );
702
+
703
+ // Register in chat trajectory (conversation.chat.commandview)
704
+ ctx.effect(
705
+ () =>
706
+ ctx.slots.inject("conversation.chat.commandview", () =>
707
+ ctx.slots.register(
708
+ {
709
+ name: "conversation.chat.commandview",
710
+ key: SCHEDULE_SCRIPT_EVENT_NAME,
711
+ },
712
+ ScheduleScriptCommandCard,
713
+ ),
714
+ ),
715
+ "schedule-script: commandview",
716
+ );
717
+ }