@gajae-code/coding-agent 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/types/async/job-manager.d.ts +7 -0
- package/dist/types/cli/args.d.ts +1 -1
- package/dist/types/commands/deep-interview.d.ts +3 -0
- package/dist/types/config/keybindings.d.ts +5 -0
- package/dist/types/config/settings-schema.d.ts +4 -4
- package/dist/types/debug/crash-diagnostics.d.ts +45 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/deep-interview/render-middleware.d.ts +1 -0
- package/dist/types/eval/py/executor.d.ts +2 -0
- package/dist/types/eval/py/kernel.d.ts +2 -0
- package/dist/types/exec/bash-executor.d.ts +10 -0
- package/dist/types/gjc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -0
- package/dist/types/gjc-runtime/state-migrations.d.ts +9 -0
- package/dist/types/gjc-runtime/state-schema.d.ts +317 -0
- package/dist/types/gjc-runtime/state-writer.d.ts +10 -0
- package/dist/types/gjc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +3 -2
- package/dist/types/hooks/skill-state.d.ts +21 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +2 -2
- package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
- package/dist/types/internal-urls/registry-helpers.d.ts +8 -7
- package/dist/types/internal-urls/types.d.ts +4 -0
- package/dist/types/lsp/index.d.ts +10 -10
- package/dist/types/modes/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +44 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/custom-editor.d.ts +6 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
- package/dist/types/modes/components/status-line/types.d.ts +2 -0
- package/dist/types/modes/components/status-line.d.ts +2 -0
- package/dist/types/modes/controllers/input-controller.d.ts +1 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -0
- package/dist/types/modes/index.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -0
- package/dist/types/modes/jobs-observer.d.ts +57 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -16
- package/dist/types/modes/rpc/host-uris.d.ts +1 -38
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +20 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +24 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +46 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +44 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/types.d.ts +1 -0
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +11 -1
- package/dist/types/skill-state/workflow-state-contract.d.ts +1 -2
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +5 -0
- package/dist/types/task/receipt.d.ts +85 -0
- package/dist/types/task/spawn-gate.d.ts +38 -0
- package/dist/types/task/types.d.ts +143 -11
- package/dist/types/tools/cron.d.ts +6 -0
- package/dist/types/tools/index.d.ts +2 -0
- package/dist/types/tools/path-utils.d.ts +1 -0
- package/dist/types/tools/subagent.d.ts +15 -0
- package/package.json +7 -7
- package/scripts/build-binary.ts +7 -0
- package/src/async/job-manager.ts +36 -0
- package/src/cli/args.ts +9 -2
- package/src/commands/deep-interview.ts +1 -0
- package/src/commands/harness.ts +289 -19
- package/src/commands/launch.ts +2 -2
- package/src/commands/state.ts +2 -1
- package/src/commands/team.ts +22 -4
- package/src/config/keybindings.ts +6 -0
- package/src/config/settings-schema.ts +6 -3
- package/src/dap/client.ts +17 -3
- package/src/debug/crash-diagnostics.ts +223 -0
- package/src/debug/runtime-gauges.ts +20 -0
- package/src/deep-interview/render-middleware.ts +6 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
- package/src/defaults/gjc/skills/ralplan/SKILL.md +31 -2
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +28 -2
- package/src/eval/py/executor.ts +21 -1
- package/src/eval/py/kernel.ts +15 -0
- package/src/exec/bash-executor.ts +41 -0
- package/src/gjc-runtime/cli-write-receipt.ts +31 -0
- package/src/gjc-runtime/deep-interview-runtime.ts +69 -32
- package/src/gjc-runtime/ralplan-runtime.ts +213 -36
- package/src/gjc-runtime/state-migrations.ts +54 -7
- package/src/gjc-runtime/state-runtime.ts +461 -64
- package/src/gjc-runtime/state-schema.ts +192 -0
- package/src/gjc-runtime/state-writer.ts +32 -1
- package/src/gjc-runtime/team-runtime.ts +177 -105
- package/src/gjc-runtime/ultragoal-runtime.ts +114 -26
- package/src/gjc-runtime/workflow-command-ref.ts +239 -0
- package/src/gjc-runtime/workflow-manifest.generated.json +108 -4
- package/src/gjc-runtime/workflow-manifest.ts +3 -1
- package/src/harness-control-plane/control-endpoint.ts +19 -8
- package/src/harness-control-plane/owner.ts +57 -10
- package/src/harness-control-plane/state-machine.ts +2 -1
- package/src/hooks/skill-state.ts +176 -26
- package/src/internal-urls/agent-protocol.ts +68 -21
- package/src/internal-urls/artifact-protocol.ts +12 -17
- package/src/internal-urls/docs-index.generated.ts +3 -2
- package/src/internal-urls/registry-helpers.ts +19 -16
- package/src/internal-urls/types.ts +4 -0
- package/src/lsp/client.ts +18 -2
- package/src/main.ts +21 -5
- package/src/modes/bridge/auth.ts +41 -0
- package/src/modes/bridge/bridge-client-bridge.ts +47 -0
- package/src/modes/bridge/bridge-mode.ts +520 -0
- package/src/modes/bridge/bridge-ui-context.ts +200 -0
- package/src/modes/bridge/event-stream.ts +70 -0
- package/src/modes/components/custom-editor.ts +101 -0
- package/src/modes/components/hook-selector.ts +61 -18
- package/src/modes/components/jobs-overlay-model.ts +109 -0
- package/src/modes/components/jobs-overlay.ts +172 -0
- package/src/modes/components/status-line/presets.ts +7 -5
- package/src/modes/components/status-line/segments.ts +25 -0
- package/src/modes/components/status-line/types.ts +2 -0
- package/src/modes/components/status-line.ts +9 -1
- package/src/modes/controllers/extension-ui-controller.ts +39 -3
- package/src/modes/controllers/input-controller.ts +97 -9
- package/src/modes/controllers/selector-controller.ts +29 -0
- package/src/modes/index.ts +1 -0
- package/src/modes/interactive-mode.ts +27 -0
- package/src/modes/jobs-observer.ts +204 -0
- package/src/modes/rpc/host-tools.ts +1 -186
- package/src/modes/rpc/host-uris.ts +1 -235
- package/src/modes/rpc/rpc-client.ts +25 -10
- package/src/modes/rpc/rpc-mode.ts +12 -381
- package/src/modes/shared/agent-wire/command-dispatch.ts +341 -0
- package/src/modes/shared/agent-wire/command-validation.ts +131 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +108 -0
- package/src/modes/shared/agent-wire/handshake.ts +117 -0
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
- package/src/modes/shared/agent-wire/protocol.ts +96 -0
- package/src/modes/shared/agent-wire/responses.ts +17 -0
- package/src/modes/shared/agent-wire/scopes.ts +89 -0
- package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
- package/src/modes/shared/agent-wire/ui-result.ts +48 -0
- package/src/modes/types.ts +1 -0
- package/src/prompts/tools/subagent.md +12 -7
- package/src/prompts/tools/task-summary.md +3 -9
- package/src/prompts/tools/task.md +5 -1
- package/src/sdk.ts +4 -0
- package/src/session/agent-session.ts +214 -38
- package/src/skill-state/deep-interview-mutation-guard.ts +23 -4
- package/src/skill-state/workflow-state-contract.ts +7 -4
- package/src/skill-state/workflow-state-version.ts +3 -0
- package/src/slash-commands/builtin-registry.ts +8 -0
- package/src/task/executor.ts +29 -5
- package/src/task/id.ts +33 -0
- package/src/task/index.ts +257 -67
- package/src/task/output-manager.ts +5 -4
- package/src/task/receipt.ts +297 -0
- package/src/task/render.ts +48 -131
- package/src/task/spawn-gate.ts +132 -0
- package/src/task/types.ts +48 -7
- package/src/tools/ask.ts +73 -33
- package/src/tools/ast-edit.ts +1 -0
- package/src/tools/ast-grep.ts +1 -0
- package/src/tools/bash.ts +1 -1
- package/src/tools/cron.ts +48 -0
- package/src/tools/find.ts +4 -1
- package/src/tools/index.ts +2 -0
- package/src/tools/path-utils.ts +3 -2
- package/src/tools/read.ts +1 -0
- package/src/tools/search.ts +1 -0
- package/src/tools/skill.ts +6 -1
- package/src/tools/subagent.ts +237 -84
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtensionUIContext,
|
|
3
|
+
ExtensionUIDialogOptions,
|
|
4
|
+
ExtensionWidgetContent,
|
|
5
|
+
ExtensionWidgetOptions,
|
|
6
|
+
TerminalInputHandler,
|
|
7
|
+
} from "../../extensibility/extensions";
|
|
8
|
+
import type { UiRequestBroker, UiRequestCancelled, UiRequestResolution } from "../shared/agent-wire/ui-request-broker";
|
|
9
|
+
import type { BridgeUiResult } from "../shared/agent-wire/ui-result";
|
|
10
|
+
import { isUiUnsupported, isUiValue } from "../shared/agent-wire/ui-result";
|
|
11
|
+
import { type Theme, theme } from "../theme/theme";
|
|
12
|
+
|
|
13
|
+
export type BridgeUiRequestPayload =
|
|
14
|
+
| { kind: "select"; title: string; options: string[]; timeout?: number }
|
|
15
|
+
| { kind: "confirm"; title: string; message: string; timeout?: number }
|
|
16
|
+
| { kind: "input"; title: string; placeholder?: string; timeout?: number }
|
|
17
|
+
| { kind: "editor"; title: string; prefill?: string; promptStyle?: boolean }
|
|
18
|
+
| { kind: "notify"; message: string; type?: "info" | "warning" | "error" }
|
|
19
|
+
| { kind: "status"; key: string; text: string | undefined }
|
|
20
|
+
| { kind: "widget"; key: string; lines: string[] | undefined; placement?: "aboveEditor" | "belowEditor" }
|
|
21
|
+
| { kind: "title"; title: string }
|
|
22
|
+
| { kind: "set_editor_text"; text: string }
|
|
23
|
+
| { kind: "unsupported"; capability: string; reason: string };
|
|
24
|
+
|
|
25
|
+
export type BridgeUiBroker = UiRequestBroker<BridgeUiRequestPayload, BridgeUiResult<unknown>>;
|
|
26
|
+
export type BridgeUiEmitter = (payload: BridgeUiRequestPayload) => void;
|
|
27
|
+
|
|
28
|
+
function isBrokerCancelled(resolution: UiRequestResolution<BridgeUiResult<unknown>>): resolution is UiRequestCancelled {
|
|
29
|
+
return resolution.status === "cancelled";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function timeoutFor(dialogOptions: ExtensionUIDialogOptions | undefined): number | undefined {
|
|
33
|
+
return dialogOptions?.timeout;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class BridgeExtensionUIContext implements ExtensionUIContext {
|
|
37
|
+
readonly #broker: BridgeUiBroker;
|
|
38
|
+
readonly #emit: BridgeUiEmitter;
|
|
39
|
+
|
|
40
|
+
constructor(options: { broker: BridgeUiBroker; emit: BridgeUiEmitter }) {
|
|
41
|
+
this.#broker = options.broker;
|
|
42
|
+
this.#emit = options.emit;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#emitUnsupported(capability: string, reason: string): void {
|
|
46
|
+
this.#emit({ kind: "unsupported", capability, reason });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async select(
|
|
50
|
+
title: string,
|
|
51
|
+
options: string[],
|
|
52
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
53
|
+
): Promise<string | undefined> {
|
|
54
|
+
const result = await this.#broker.request(
|
|
55
|
+
{ kind: "select", title, options, timeout: timeoutFor(dialogOptions) },
|
|
56
|
+
{ timeoutMs: timeoutFor(dialogOptions), signal: dialogOptions?.signal },
|
|
57
|
+
);
|
|
58
|
+
if (isBrokerCancelled(result)) {
|
|
59
|
+
if (result.reason === "timeout") dialogOptions?.onTimeout?.();
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
if (isUiValue(result) && typeof result.value === "string") return result.value;
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async confirm(title: string, message: string, dialogOptions?: ExtensionUIDialogOptions): Promise<boolean> {
|
|
67
|
+
const result = await this.#broker.request(
|
|
68
|
+
{ kind: "confirm", title, message, timeout: timeoutFor(dialogOptions) },
|
|
69
|
+
{ timeoutMs: timeoutFor(dialogOptions), signal: dialogOptions?.signal },
|
|
70
|
+
);
|
|
71
|
+
if (isBrokerCancelled(result)) {
|
|
72
|
+
if (result.reason === "timeout") dialogOptions?.onTimeout?.();
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (isUiValue(result) && typeof result.value === "boolean") return result.value;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async input(
|
|
80
|
+
title: string,
|
|
81
|
+
placeholder?: string,
|
|
82
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
83
|
+
): Promise<string | undefined> {
|
|
84
|
+
const result = await this.#broker.request(
|
|
85
|
+
{ kind: "input", title, placeholder, timeout: timeoutFor(dialogOptions) },
|
|
86
|
+
{ timeoutMs: timeoutFor(dialogOptions), signal: dialogOptions?.signal },
|
|
87
|
+
);
|
|
88
|
+
if (isBrokerCancelled(result)) {
|
|
89
|
+
if (result.reason === "timeout") dialogOptions?.onTimeout?.();
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (isUiValue(result) && typeof result.value === "string") return result.value;
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
notify(message: string, type?: "info" | "warning" | "error"): void {
|
|
97
|
+
this.#emit({ kind: "notify", message, type });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
onTerminalInput(_handler: TerminalInputHandler): () => void {
|
|
101
|
+
this.#emitUnsupported("ui.terminal_input", "Raw terminal input is not supported by the bridge protocol yet");
|
|
102
|
+
return () => {};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setStatus(key: string, text: string | undefined): void {
|
|
106
|
+
this.#emit({ kind: "status", key, text });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setWorkingMessage(message?: string): void {
|
|
110
|
+
this.#emit({ kind: "status", key: "working", text: message });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setWidget(key: string, content: ExtensionWidgetContent, options?: ExtensionWidgetOptions): void {
|
|
114
|
+
if (content === undefined || Array.isArray(content)) {
|
|
115
|
+
this.#emit({ kind: "widget", key, lines: content, placement: options?.placement });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.#emitUnsupported("ui.widget.component", "Component factory widgets are local-only and not serializable");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
setFooter(_factory?: unknown): void {
|
|
122
|
+
this.#emitUnsupported("ui.footer.component", "Footer component factories are local-only and not serializable");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
setHeader(_factory?: unknown): void {
|
|
126
|
+
this.#emitUnsupported("ui.header.component", "Header component factories are local-only and not serializable");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
setTitle(title: string): void {
|
|
130
|
+
this.#emit({ kind: "title", title });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async custom<T>(): Promise<T> {
|
|
134
|
+
this.#emitUnsupported("ui.custom.component", "Custom focused components are local-only and not serializable");
|
|
135
|
+
throw new Error("Custom focused components are local-only and not serializable through bridge UI context");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setEditorText(text: string): void {
|
|
139
|
+
this.#emit({ kind: "set_editor_text", text });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pasteToEditor(text: string): void {
|
|
143
|
+
this.setEditorText(text);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
getEditorText(): string {
|
|
147
|
+
this.#emitUnsupported(
|
|
148
|
+
"ui.editor.get_text",
|
|
149
|
+
"Synchronous editor reads are local-only and not supported by bridge UI context",
|
|
150
|
+
);
|
|
151
|
+
throw new Error("Synchronous editor reads are local-only and not supported by bridge UI context");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async editor(
|
|
155
|
+
title: string,
|
|
156
|
+
prefill?: string,
|
|
157
|
+
dialogOptions?: ExtensionUIDialogOptions,
|
|
158
|
+
editorOptions?: { promptStyle?: boolean },
|
|
159
|
+
): Promise<string | undefined> {
|
|
160
|
+
const result = await this.#broker.request(
|
|
161
|
+
{ kind: "editor", title, prefill, promptStyle: editorOptions?.promptStyle },
|
|
162
|
+
{ timeoutMs: timeoutFor(dialogOptions), signal: dialogOptions?.signal },
|
|
163
|
+
);
|
|
164
|
+
if (isBrokerCancelled(result)) {
|
|
165
|
+
if (result.reason === "timeout") dialogOptions?.onTimeout?.();
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
if (isUiUnsupported(result)) return undefined;
|
|
169
|
+
if (isUiValue(result) && typeof result.value === "string") return result.value;
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
setEditorComponent(_factory?: unknown): void {
|
|
174
|
+
this.#emitUnsupported("ui.editor.component", "Custom editor components are local-only and not serializable");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get theme(): Theme {
|
|
178
|
+
return theme;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
getAllThemes(): Promise<{ name: string; path: string | undefined }[]> {
|
|
182
|
+
return Promise.resolve([]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
getTheme(_name: string): Promise<Theme | undefined> {
|
|
186
|
+
return Promise.resolve(undefined);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
setTheme(_theme: string | Theme): Promise<{ success: boolean; error?: string }> {
|
|
190
|
+
return Promise.resolve({ success: false, error: "Theme switching is not supported by bridge UI context yet" });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
getToolsExpanded(): boolean {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
setToolsExpanded(_expanded: boolean): void {
|
|
198
|
+
this.#emitUnsupported("ui.tools_expanded", "Tool expansion state is not supported by bridge UI context yet");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { BridgeFrameEnvelope } from "../shared/agent-wire/protocol";
|
|
2
|
+
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
const DEFAULT_REPLAY_LIMIT = 1_000;
|
|
5
|
+
|
|
6
|
+
function encodeSseFrame(frame: BridgeFrameEnvelope): Uint8Array {
|
|
7
|
+
return encoder.encode(`data: ${JSON.stringify(frame)}\n\n`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class BridgeEventStream {
|
|
11
|
+
#frames: BridgeFrameEnvelope[] = [];
|
|
12
|
+
#subscribers = new Set<ReadableStreamDefaultController<Uint8Array>>();
|
|
13
|
+
#replayLimit: number;
|
|
14
|
+
|
|
15
|
+
constructor(replayLimit = DEFAULT_REPLAY_LIMIT) {
|
|
16
|
+
this.#replayLimit = replayLimit;
|
|
17
|
+
}
|
|
18
|
+
get frameCount(): number {
|
|
19
|
+
return this.#frames.length;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
publish(frame: BridgeFrameEnvelope): void {
|
|
23
|
+
this.#frames.push(frame);
|
|
24
|
+
if (this.#frames.length > this.#replayLimit) this.#frames.splice(0, this.#frames.length - this.#replayLimit);
|
|
25
|
+
const encoded = encodeSseFrame(frame);
|
|
26
|
+
for (const controller of this.#subscribers) {
|
|
27
|
+
try {
|
|
28
|
+
controller.enqueue(encoded);
|
|
29
|
+
} catch {
|
|
30
|
+
this.#subscribers.delete(controller);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
response(lastSeq = 0): Response {
|
|
36
|
+
let streamController: ReadableStreamDefaultController<Uint8Array> | undefined;
|
|
37
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
38
|
+
start: controller => {
|
|
39
|
+
streamController = controller;
|
|
40
|
+
const first = this.#frames[0];
|
|
41
|
+
if (first && lastSeq > 0 && first.seq > lastSeq + 1) {
|
|
42
|
+
controller.enqueue(
|
|
43
|
+
encodeSseFrame({
|
|
44
|
+
protocol_version: first.protocol_version,
|
|
45
|
+
session_id: first.session_id,
|
|
46
|
+
seq: first.seq - 1,
|
|
47
|
+
frame_id: `reset-${first.seq}`,
|
|
48
|
+
type: "reset",
|
|
49
|
+
payload: { reason: "replay_window_exceeded", first_seq: first.seq },
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
for (const frame of this.#frames) {
|
|
54
|
+
if (frame.seq > lastSeq) controller.enqueue(encodeSseFrame(frame));
|
|
55
|
+
}
|
|
56
|
+
this.#subscribers.add(controller);
|
|
57
|
+
},
|
|
58
|
+
cancel: () => {
|
|
59
|
+
if (streamController) this.#subscribers.delete(streamController);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return new Response(stream, {
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "text/event-stream",
|
|
65
|
+
"Cache-Control": "no-cache",
|
|
66
|
+
Connection: "keep-alive",
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Editor, type KeyId, matchesKey, parseKittySequence } from "@gajae-code/tui";
|
|
2
|
+
import { BracketedPasteHandler } from "@gajae-code/tui/bracketed-paste";
|
|
2
3
|
import type { AppKeybinding } from "../../config/keybindings";
|
|
3
4
|
|
|
4
5
|
type ConfigurableEditorAction = Extract<
|
|
@@ -40,6 +41,11 @@ const DEFAULT_ACTION_KEYS: Record<ConfigurableEditorAction, KeyId[]> = {
|
|
|
40
41
|
"app.clipboard.copyPrompt": ["alt+shift+c"],
|
|
41
42
|
};
|
|
42
43
|
|
|
44
|
+
const PASTE_DECISION_TIMEOUT_MS = 5_000;
|
|
45
|
+
const PENDING_PASTE_INPUT_MAX = 64;
|
|
46
|
+
|
|
47
|
+
type PastePendingClearReason = "timeout" | "queue-limit";
|
|
48
|
+
|
|
43
49
|
/**
|
|
44
50
|
* Custom editor that handles configurable app-level shortcuts for coding-agent.
|
|
45
51
|
*/
|
|
@@ -63,6 +69,10 @@ export class CustomEditor extends Editor {
|
|
|
63
69
|
onCopyPrompt?: () => void;
|
|
64
70
|
/** Called when the configured image-paste shortcut is pressed. */
|
|
65
71
|
onPasteImage?: () => Promise<boolean>;
|
|
72
|
+
/** Called before bracketed paste content is inserted. Return true to consume it. */
|
|
73
|
+
onPasteText?: (text: string) => boolean | Promise<boolean>;
|
|
74
|
+
/** Called when async paste handling drops queued input instead of replaying it. */
|
|
75
|
+
onPastePendingInputCleared?: (reason: PastePendingClearReason, droppedInputCount: number) => void;
|
|
66
76
|
/** Called when the configured dequeue shortcut is pressed. */
|
|
67
77
|
onDequeue?: () => void;
|
|
68
78
|
/** Called when Caps Lock is pressed. */
|
|
@@ -73,6 +83,11 @@ export class CustomEditor extends Editor {
|
|
|
73
83
|
#actionKeys = new Map<ConfigurableEditorAction, KeyId[]>(
|
|
74
84
|
Object.entries(DEFAULT_ACTION_KEYS).map(([action, keys]) => [action as ConfigurableEditorAction, [...keys]]),
|
|
75
85
|
);
|
|
86
|
+
#pasteHandler = new BracketedPasteHandler();
|
|
87
|
+
#pasteDecisionPending = false;
|
|
88
|
+
#pasteDecisionToken = 0;
|
|
89
|
+
#pasteDecisionTimeout: NodeJS.Timeout | undefined;
|
|
90
|
+
#pendingPasteInput: string[] = [];
|
|
76
91
|
|
|
77
92
|
setActionKeys(action: ConfigurableEditorAction, keys: KeyId[]): void {
|
|
78
93
|
this.#actionKeys.set(action, [...keys]);
|
|
@@ -108,7 +123,84 @@ export class CustomEditor extends Editor {
|
|
|
108
123
|
this.#customKeyHandlers.clear();
|
|
109
124
|
}
|
|
110
125
|
|
|
126
|
+
#clearPasteDecisionTimeout(): void {
|
|
127
|
+
if (this.#pasteDecisionTimeout) {
|
|
128
|
+
clearTimeout(this.#pasteDecisionTimeout);
|
|
129
|
+
this.#pasteDecisionTimeout = undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#clearPendingPasteState(): number {
|
|
134
|
+
this.#clearPasteDecisionTimeout();
|
|
135
|
+
this.#pasteDecisionPending = false;
|
|
136
|
+
this.#pasteDecisionToken += 1;
|
|
137
|
+
const droppedInputCount = this.#pendingPasteInput.length;
|
|
138
|
+
this.#pendingPasteInput = [];
|
|
139
|
+
return droppedInputCount;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#startPasteDecisionTimeout(token: number): void {
|
|
143
|
+
this.#clearPasteDecisionTimeout();
|
|
144
|
+
this.#pasteDecisionTimeout = setTimeout(() => {
|
|
145
|
+
if (token !== this.#pasteDecisionToken) return;
|
|
146
|
+
const droppedInputCount = this.#clearPendingPasteState();
|
|
147
|
+
this.onPastePendingInputCleared?.("timeout", droppedInputCount);
|
|
148
|
+
}, PASTE_DECISION_TIMEOUT_MS);
|
|
149
|
+
this.#pasteDecisionTimeout.unref?.();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
dispose(): void {
|
|
153
|
+
this.#clearPendingPasteState();
|
|
154
|
+
this.#pasteHandler = new BracketedPasteHandler();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#drainPendingPasteInput(initialInput?: string): void {
|
|
158
|
+
if (initialInput && initialInput.length > 0) {
|
|
159
|
+
this.handleInput(initialInput);
|
|
160
|
+
}
|
|
161
|
+
while (!this.#pasteDecisionPending) {
|
|
162
|
+
const nextInput = this.#pendingPasteInput.shift();
|
|
163
|
+
if (nextInput === undefined) break;
|
|
164
|
+
this.handleInput(nextInput);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#handleBracketedPaste(pasteContent: string, remaining: string): void {
|
|
169
|
+
const applyPasteResult = (token: number, handled: boolean | undefined) => {
|
|
170
|
+
if (token !== this.#pasteDecisionToken) return;
|
|
171
|
+
this.#clearPasteDecisionTimeout();
|
|
172
|
+
if (!handled) {
|
|
173
|
+
super.handleInput(`\x1b[200~${pasteContent}\x1b[201~`);
|
|
174
|
+
}
|
|
175
|
+
this.#pasteDecisionPending = false;
|
|
176
|
+
this.#drainPendingPasteInput(remaining);
|
|
177
|
+
};
|
|
178
|
+
const pasteResult = this.onPasteText?.(pasteContent);
|
|
179
|
+
|
|
180
|
+
if (pasteResult instanceof Promise) {
|
|
181
|
+
const token = this.#pasteDecisionToken + 1;
|
|
182
|
+
this.#pasteDecisionToken = token;
|
|
183
|
+
this.#pasteDecisionPending = true;
|
|
184
|
+
this.#startPasteDecisionTimeout(token);
|
|
185
|
+
void pasteResult.then(
|
|
186
|
+
handled => applyPasteResult(token, handled),
|
|
187
|
+
() => applyPasteResult(token, false),
|
|
188
|
+
);
|
|
189
|
+
} else {
|
|
190
|
+
applyPasteResult(this.#pasteDecisionToken, pasteResult);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
111
194
|
handleInput(data: string): void {
|
|
195
|
+
if (this.#pasteDecisionPending) {
|
|
196
|
+
this.#pendingPasteInput.push(data);
|
|
197
|
+
if (this.#pendingPasteInput.length > PENDING_PASTE_INPUT_MAX) {
|
|
198
|
+
const droppedInputCount = this.#clearPendingPasteState();
|
|
199
|
+
this.onPastePendingInputCleared?.("queue-limit", droppedInputCount);
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
112
204
|
const parsed = parseKittySequence(data);
|
|
113
205
|
if (parsed && (parsed.modifier & 64) !== 0 && this.onCapsLock) {
|
|
114
206
|
// Caps Lock is modifier bit 64
|
|
@@ -116,6 +208,15 @@ export class CustomEditor extends Editor {
|
|
|
116
208
|
return;
|
|
117
209
|
}
|
|
118
210
|
|
|
211
|
+
if (this.onPasteText) {
|
|
212
|
+
const paste = this.#pasteHandler.process(data);
|
|
213
|
+
if (paste.handled) {
|
|
214
|
+
if (paste.pasteContent !== undefined) {
|
|
215
|
+
this.#handleBracketedPaste(paste.pasteContent, paste.remaining);
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
119
220
|
// Intercept configured image paste (async - fires and handles result)
|
|
120
221
|
if (this.#matchesAction(data, "app.clipboard.pasteImage") && this.onPasteImage) {
|
|
121
222
|
void this.onPasteImage();
|
|
@@ -21,6 +21,22 @@ import { matchesAppExternalEditor, matchesSelectCancel } from "../../modes/utils
|
|
|
21
21
|
import { CountdownTimer } from "./countdown-timer";
|
|
22
22
|
import { DynamicBorder } from "./dynamic-border";
|
|
23
23
|
|
|
24
|
+
const SGR_MOUSE_PRESS_PATTERN = /^\x1b\[<(\d+);\d+;\d+M$/;
|
|
25
|
+
const MOUSE_WHEEL_TITLE_SCROLL_ROWS = 3;
|
|
26
|
+
|
|
27
|
+
function getMouseWheelTitleScrollRows(keyData: string): number {
|
|
28
|
+
const match = SGR_MOUSE_PRESS_PATTERN.exec(keyData);
|
|
29
|
+
if (!match) return 0;
|
|
30
|
+
|
|
31
|
+
const button = Number.parseInt(match[1] ?? "", 10);
|
|
32
|
+
if (!Number.isFinite(button) || (button & 64) === 0) return 0;
|
|
33
|
+
|
|
34
|
+
const wheelDirection = button & 3;
|
|
35
|
+
if (wheelDirection === 0) return -MOUSE_WHEEL_TITLE_SCROLL_ROWS;
|
|
36
|
+
if (wheelDirection === 1) return MOUSE_WHEEL_TITLE_SCROLL_ROWS;
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
export interface HookSelectorOptions {
|
|
25
41
|
tui?: TUI;
|
|
26
42
|
timeout?: number;
|
|
@@ -125,11 +141,10 @@ class ScrollableTitle extends Container {
|
|
|
125
141
|
* `maxVisibleRows`; everything that depends on terminal width is recomputed
|
|
126
142
|
* on each render so resize Just Works.
|
|
127
143
|
*
|
|
128
|
-
* `maxVisibleRows` is a
|
|
129
|
-
* options shrink first
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* fully with zero siblings.
|
|
144
|
+
* `maxVisibleRows` is a hard viewport budget for every rendered option-list
|
|
145
|
+
* row. Surrounding options shrink first; if the focused option alone would
|
|
146
|
+
* exceed the remaining budget, it is compacted to contextual rows plus an
|
|
147
|
+
* omitted-rows marker so controls stay reachable for untrusted long labels.
|
|
133
148
|
*/
|
|
134
149
|
class FocusAwareList extends Container {
|
|
135
150
|
#options: string[] = [];
|
|
@@ -168,19 +183,20 @@ class FocusAwareList extends Container {
|
|
|
168
183
|
theme.fg("accent", t),
|
|
169
184
|
);
|
|
170
185
|
const focusedWrappedSegments = wrapTextWithAnsi(focusedLabel, availableLabelWidth);
|
|
171
|
-
const focusedRows = Math.max(1, focusedWrappedSegments.length);
|
|
172
186
|
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
187
|
+
// Reserve one row for the option position marker only when the focused
|
|
188
|
+
// block itself must be compacted. Moderate focused labels keep the legacy
|
|
189
|
+
// wrap-focused behavior and spend the full viewport on label context.
|
|
176
190
|
const totalOptions = this.#options.length;
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const
|
|
191
|
+
const mustCompactFocused = focusedWrappedSegments.length > this.#maxVisibleRows;
|
|
192
|
+
const positionMarkerSlot = mustCompactFocused && totalOptions > 1 ? 1 : 0;
|
|
193
|
+
const focusedBudget = Math.max(1, this.#maxVisibleRows - positionMarkerSlot);
|
|
194
|
+
const focusedSegments = this.#capFocusedSegments(focusedWrappedSegments, focusedBudget, availableLabelWidth);
|
|
195
|
+
const focusedRows = Math.max(1, focusedSegments.length);
|
|
180
196
|
|
|
181
|
-
// Sibling budget. If the focused block
|
|
182
|
-
//
|
|
183
|
-
const siblingBudget = Math.max(0, this.#maxVisibleRows - focusedRows -
|
|
197
|
+
// Sibling budget. If the focused block consumes the available viewport,
|
|
198
|
+
// render it with zero siblings and the reserved position marker.
|
|
199
|
+
const siblingBudget = Math.max(0, this.#maxVisibleRows - focusedRows - positionMarkerSlot);
|
|
184
200
|
|
|
185
201
|
// Distribute sibling slots around focus, preferring closest options.
|
|
186
202
|
const availableAbove = this.#selectedIndex;
|
|
@@ -203,8 +219,8 @@ class FocusAwareList extends Container {
|
|
|
203
219
|
if (i === this.#selectedIndex) {
|
|
204
220
|
// Emit focused wrapped rows. Cursor only on row 0; continuation
|
|
205
221
|
// rows are whitespace-aligned under the label start.
|
|
206
|
-
for (let r = 0; r <
|
|
207
|
-
const segment =
|
|
222
|
+
for (let r = 0; r < focusedSegments.length; r++) {
|
|
223
|
+
const segment = focusedSegments[r] ?? "";
|
|
208
224
|
rows.push(r === 0 ? styledSelectedPrefix + segment : continuationPrefix + segment);
|
|
209
225
|
}
|
|
210
226
|
} else {
|
|
@@ -217,13 +233,33 @@ class FocusAwareList extends Container {
|
|
|
217
233
|
}
|
|
218
234
|
}
|
|
219
235
|
|
|
220
|
-
if (showMarker) {
|
|
236
|
+
if (showMarker && rows.length < this.#maxVisibleRows) {
|
|
221
237
|
rows.push(theme.fg("dim", ` (${this.#selectedIndex + 1}/${totalOptions})`));
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
return this.#outline ? this.#wrapOutline(rows, width) : rows;
|
|
225
241
|
}
|
|
226
242
|
|
|
243
|
+
#capFocusedSegments(segments: string[], maxRows: number, availableLabelWidth: number): string[] {
|
|
244
|
+
const rows = segments.length > 0 ? segments : [""];
|
|
245
|
+
const budget = Math.max(1, Math.floor(maxRows));
|
|
246
|
+
if (rows.length <= budget) return rows;
|
|
247
|
+
|
|
248
|
+
if (budget === 1) {
|
|
249
|
+
return [truncateToWidth(`… ${rows.length - 1} wrapped rows omitted …`, availableLabelWidth)];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (budget === 2) {
|
|
253
|
+
return [rows[0] ?? "", truncateToWidth(`… ${rows.length - 1} wrapped rows omitted …`, availableLabelWidth)];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const tailRows = Math.max(1, Math.floor((budget - 2) / 2));
|
|
257
|
+
const headRows = Math.max(1, budget - 1 - tailRows);
|
|
258
|
+
const omittedRows = Math.max(1, rows.length - headRows - tailRows);
|
|
259
|
+
const marker = truncateToWidth(`… ${omittedRows} wrapped rows omitted …`, availableLabelWidth);
|
|
260
|
+
return [...rows.slice(0, headRows), marker, ...rows.slice(rows.length - tailRows)];
|
|
261
|
+
}
|
|
262
|
+
|
|
227
263
|
#wrapOutline(rows: string[], width: number): string[] {
|
|
228
264
|
// Mirror the outline border drawn by `OutlinedList.render(width)`. The
|
|
229
265
|
// rows passed in are already constrained to `innerWidth` by
|
|
@@ -381,6 +417,13 @@ export class HookSelectorComponent extends Container {
|
|
|
381
417
|
// Reset countdown on any interaction
|
|
382
418
|
this.#countdown?.reset();
|
|
383
419
|
|
|
420
|
+
if (this.#scrollTitleRows !== undefined) {
|
|
421
|
+
const wheelRows = getMouseWheelTitleScrollRows(keyData);
|
|
422
|
+
if (wheelRows !== 0) {
|
|
423
|
+
this.#scrollableTitle?.scrollBy(wheelRows);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
384
427
|
if (this.#scrollTitleRows !== undefined && matchesKey(keyData, "pageUp")) {
|
|
385
428
|
this.#scrollableTitle?.scrollBy(-this.#scrollTitleRows);
|
|
386
429
|
return;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure model helpers for the jobs overlay.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of UI/Component dependencies so the grouping/ordering and
|
|
5
|
+
* detail-formatting logic is unit-testable. The selector controller wires these
|
|
6
|
+
* SelectItem lists into nested SelectLists (list -> detail -> confirm).
|
|
7
|
+
*/
|
|
8
|
+
import type { SelectItem } from "@gajae-code/tui";
|
|
9
|
+
import type { JobsSnapshot } from "../jobs-observer";
|
|
10
|
+
|
|
11
|
+
export type JobRefKind = "monitor" | "cron";
|
|
12
|
+
|
|
13
|
+
export interface JobRef {
|
|
14
|
+
kind: JobRefKind;
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PROMPT_PREVIEW_MAX = 60;
|
|
19
|
+
|
|
20
|
+
function preview(text: string, max = PROMPT_PREVIEW_MAX): string {
|
|
21
|
+
const oneLine = text.replace(/\s+/g, " ").trim();
|
|
22
|
+
return oneLine.length > max ? `${oneLine.slice(0, max - 1)}…` : oneLine;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Compact relative time, e.g. "in 5m", "2m ago", "now". */
|
|
26
|
+
export function formatRelative(targetMs: number | undefined, nowMs = Date.now()): string {
|
|
27
|
+
if (targetMs === undefined) return "—";
|
|
28
|
+
const deltaMs = targetMs - nowMs;
|
|
29
|
+
const abs = Math.abs(deltaMs);
|
|
30
|
+
const mins = Math.round(abs / 60_000);
|
|
31
|
+
if (mins < 1) return "now";
|
|
32
|
+
const unit = mins >= 60 ? `${Math.round(mins / 60)}h` : `${mins}m`;
|
|
33
|
+
return deltaMs >= 0 ? `in ${unit}` : `${unit} ago`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Parse a list item value back into a job reference. */
|
|
37
|
+
export function parseJobRef(value: string): JobRef | null {
|
|
38
|
+
const sep = value.indexOf(":");
|
|
39
|
+
if (sep === -1) return null;
|
|
40
|
+
const kind = value.slice(0, sep);
|
|
41
|
+
const id = value.slice(sep + 1);
|
|
42
|
+
if ((kind === "monitor" || kind === "cron") && id.length > 0) {
|
|
43
|
+
return { kind, id };
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Build the grouped jobs list: monitors first (newest-first), then crons
|
|
50
|
+
* (newest-first). The snapshot arrays are already sorted newest-first.
|
|
51
|
+
*/
|
|
52
|
+
export function buildJobsListItems(snapshot: JobsSnapshot): SelectItem[] {
|
|
53
|
+
const items: SelectItem[] = [];
|
|
54
|
+
for (const monitor of snapshot.monitors) {
|
|
55
|
+
items.push({
|
|
56
|
+
value: `monitor:${monitor.id}`,
|
|
57
|
+
label: `monitor · ${preview(monitor.label, 40)}`,
|
|
58
|
+
description: monitor.status,
|
|
59
|
+
hint: monitor.status === "failed" ? "failed" : undefined,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
for (const cron of snapshot.crons) {
|
|
63
|
+
items.push({
|
|
64
|
+
value: `cron:${cron.id}`,
|
|
65
|
+
label: `cron · ${cron.humanSchedule}`,
|
|
66
|
+
description: preview(cron.prompt),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return items;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Build the detail-level items for a job: read-only info rows (value "noop"),
|
|
74
|
+
* then the destructive action, then a back row. `output` is the bounded monitor
|
|
75
|
+
* output tail (ignored for cron jobs).
|
|
76
|
+
*/
|
|
77
|
+
export function buildJobDetailItems(snapshot: JobsSnapshot, ref: JobRef, output = ""): SelectItem[] {
|
|
78
|
+
if (ref.kind === "monitor") {
|
|
79
|
+
const monitor = snapshot.monitors.find(m => m.id === ref.id);
|
|
80
|
+
if (!monitor) return [{ value: "back", label: "Back (job no longer present)" }];
|
|
81
|
+
const lastOutput = output.trim().split("\n").filter(Boolean).slice(-1)[0] ?? "(no output captured)";
|
|
82
|
+
return [
|
|
83
|
+
{ value: "noop", label: "Status", description: monitor.status },
|
|
84
|
+
{ value: "noop", label: "Label", description: preview(monitor.label) },
|
|
85
|
+
{ value: "noop", label: "Started", description: formatRelative(monitor.startTime) },
|
|
86
|
+
{ value: "noop", label: "Output", description: preview(lastOutput, 80) },
|
|
87
|
+
{ value: "action:cancel", label: "Cancel this monitor", hint: "stops the running job" },
|
|
88
|
+
{ value: "back", label: "Back" },
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
const cron = snapshot.crons.find(c => c.id === ref.id);
|
|
92
|
+
if (!cron) return [{ value: "back", label: "Back (job no longer present)" }];
|
|
93
|
+
return [
|
|
94
|
+
{ value: "noop", label: "Schedule", description: `${cron.humanSchedule} (${cron.cronExpression})` },
|
|
95
|
+
{ value: "noop", label: "Recurring", description: cron.recurring ? "yes" : "no" },
|
|
96
|
+
{ value: "noop", label: "Next fire", description: formatRelative(cron.nextFireAt) },
|
|
97
|
+
{ value: "noop", label: "Prompt", description: preview(cron.prompt, 80) },
|
|
98
|
+
{ value: "action:delete", label: "Delete this cron", hint: "removes the schedule" },
|
|
99
|
+
{ value: "back", label: "Back" },
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Yes/No confirm items for a destructive action. */
|
|
104
|
+
export function buildConfirmItems(actionLabel: string): SelectItem[] {
|
|
105
|
+
return [
|
|
106
|
+
{ value: "no", label: `No, keep it` },
|
|
107
|
+
{ value: "yes", label: `Yes, ${actionLabel}` },
|
|
108
|
+
];
|
|
109
|
+
}
|