@qoren/cli 0.1.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/LICENSE +202 -0
- package/README.md +162 -0
- package/dist/args.d.ts +5 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +23 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/account.d.ts +4 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +154 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/agent.d.ts +27 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +968 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/api.d.ts +4 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +66 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/approvals.d.ts +11 -0
- package/dist/commands/approvals.d.ts.map +1 -0
- package/dist/commands/approvals.js +140 -0
- package/dist/commands/approvals.js.map +1 -0
- package/dist/commands/auth.d.ts +4 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +215 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/clients.d.ts +62 -0
- package/dist/commands/clients.d.ts.map +1 -0
- package/dist/commands/clients.js +311 -0
- package/dist/commands/clients.js.map +1 -0
- package/dist/commands/console.d.ts +4 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +26 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/customAgent.d.ts +42 -0
- package/dist/commands/customAgent.d.ts.map +1 -0
- package/dist/commands/customAgent.js +449 -0
- package/dist/commands/customAgent.js.map +1 -0
- package/dist/commands/designer.d.ts +32 -0
- package/dist/commands/designer.d.ts.map +1 -0
- package/dist/commands/designer.js +682 -0
- package/dist/commands/designer.js.map +1 -0
- package/dist/commands/env.d.ts +15 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +245 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/interactive.d.ts +4 -0
- package/dist/commands/interactive.d.ts.map +1 -0
- package/dist/commands/interactive.js +30 -0
- package/dist/commands/interactive.js.map +1 -0
- package/dist/commands/jobs.d.ts +4 -0
- package/dist/commands/jobs.d.ts.map +1 -0
- package/dist/commands/jobs.js +59 -0
- package/dist/commands/jobs.js.map +1 -0
- package/dist/commands/secrets.d.ts +15 -0
- package/dist/commands/secrets.d.ts.map +1 -0
- package/dist/commands/secrets.js +164 -0
- package/dist/commands/secrets.js.map +1 -0
- package/dist/commands/webhook.d.ts +4 -0
- package/dist/commands/webhook.d.ts.map +1 -0
- package/dist/commands/webhook.js +275 -0
- package/dist/commands/webhook.js.map +1 -0
- package/dist/config.d.ts +38 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +117 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +52 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +163 -0
- package/dist/context.js.map +1 -0
- package/dist/duration.d.ts +9 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +30 -0
- package/dist/duration.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/issues.d.ts +10 -0
- package/dist/issues.d.ts.map +1 -0
- package/dist/issues.js +45 -0
- package/dist/issues.js.map +1 -0
- package/dist/jobProgress.d.ts +12 -0
- package/dist/jobProgress.d.ts.map +1 -0
- package/dist/jobProgress.js +56 -0
- package/dist/jobProgress.js.map +1 -0
- package/dist/loopback.d.ts +28 -0
- package/dist/loopback.d.ts.map +1 -0
- package/dist/loopback.js +110 -0
- package/dist/loopback.js.map +1 -0
- package/dist/migrate/apply.d.ts +29 -0
- package/dist/migrate/apply.d.ts.map +1 -0
- package/dist/migrate/apply.js +135 -0
- package/dist/migrate/apply.js.map +1 -0
- package/dist/migrate/bundle.d.ts +89 -0
- package/dist/migrate/bundle.d.ts.map +1 -0
- package/dist/migrate/bundle.js +681 -0
- package/dist/migrate/bundle.js.map +1 -0
- package/dist/migrate/tar.d.ts +9 -0
- package/dist/migrate/tar.d.ts.map +1 -0
- package/dist/migrate/tar.js +89 -0
- package/dist/migrate/tar.js.map +1 -0
- package/dist/output.d.ts +46 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +152 -0
- package/dist/output.js.map +1 -0
- package/dist/program.d.ts +17 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +89 -0
- package/dist/program.js.map +1 -0
- package/dist/runtimes.d.ts +11 -0
- package/dist/runtimes.d.ts.map +1 -0
- package/dist/runtimes.js +20 -0
- package/dist/runtimes.js.map +1 -0
- package/dist/slug.d.ts +3 -0
- package/dist/slug.d.ts.map +1 -0
- package/dist/slug.js +15 -0
- package/dist/slug.js.map +1 -0
- package/dist/taskChain.d.ts +20 -0
- package/dist/taskChain.d.ts.map +1 -0
- package/dist/taskChain.js +40 -0
- package/dist/taskChain.js.map +1 -0
- package/dist/taskDelivery.d.ts +33 -0
- package/dist/taskDelivery.d.ts.map +1 -0
- package/dist/taskDelivery.js +67 -0
- package/dist/taskDelivery.js.map +1 -0
- package/dist/tui/app.d.ts +5 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +130 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/index.d.ts +12 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +34 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/model.d.ts +110 -0
- package/dist/tui/model.d.ts.map +1 -0
- package/dist/tui/model.js +257 -0
- package/dist/tui/model.js.map +1 -0
- package/dist/tui/overlay.d.ts +66 -0
- package/dist/tui/overlay.d.ts.map +1 -0
- package/dist/tui/overlay.js +216 -0
- package/dist/tui/overlay.js.map +1 -0
- package/dist/tui/panes/account.d.ts +5 -0
- package/dist/tui/panes/account.d.ts.map +1 -0
- package/dist/tui/panes/account.js +108 -0
- package/dist/tui/panes/account.js.map +1 -0
- package/dist/tui/panes/agents.d.ts +9 -0
- package/dist/tui/panes/agents.d.ts.map +1 -0
- package/dist/tui/panes/agents.js +340 -0
- package/dist/tui/panes/agents.js.map +1 -0
- package/dist/tui/panes/chat.d.ts +14 -0
- package/dist/tui/panes/chat.d.ts.map +1 -0
- package/dist/tui/panes/chat.js +169 -0
- package/dist/tui/panes/chat.js.map +1 -0
- package/dist/tui/panes/environments.d.ts +6 -0
- package/dist/tui/panes/environments.d.ts.map +1 -0
- package/dist/tui/panes/environments.js +364 -0
- package/dist/tui/panes/environments.js.map +1 -0
- package/dist/tui/panes/jobs.d.ts +5 -0
- package/dist/tui/panes/jobs.d.ts.map +1 -0
- package/dist/tui/panes/jobs.js +104 -0
- package/dist/tui/panes/jobs.js.map +1 -0
- package/dist/tui/store.d.ts +40 -0
- package/dist/tui/store.d.ts.map +1 -0
- package/dist/tui/store.js +124 -0
- package/dist/tui/store.js.map +1 -0
- package/dist/tui/ui.d.ts +95 -0
- package/dist/tui/ui.d.ts.map +1 -0
- package/dist/tui/ui.js +144 -0
- package/dist/tui/ui.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Box, useInput } from "ink";
|
|
4
|
+
import { age } from "../../output.js";
|
|
5
|
+
import { currentStep, jobProgressText, statusColorName, truncate } from "../model.js";
|
|
6
|
+
import { useUi } from "../overlay.js";
|
|
7
|
+
import { describeError, statusPaced, useResource, useSession } from "../store.js";
|
|
8
|
+
import { Hints, StatusLine, Table, navigate } from "../ui.js";
|
|
9
|
+
// Jobs: the durable record of everything expensive the platform is doing.
|
|
10
|
+
//
|
|
11
|
+
// This is where you come when a deploy was started and then walked away from,
|
|
12
|
+
// or when something is taking longer than it should. Watching one from here is
|
|
13
|
+
// the same wait the other panes do inline, so a job started anywhere can be
|
|
14
|
+
// picked back up here.
|
|
15
|
+
export function JobsPane({ height, focused, }) {
|
|
16
|
+
const { qoren } = useSession();
|
|
17
|
+
const ui = useUi();
|
|
18
|
+
const [selected, setSelected] = useState(0);
|
|
19
|
+
const jobs = useResource("jobs", () => qoren.jobs.list(50), {
|
|
20
|
+
active: !ui.busy,
|
|
21
|
+
interval: statusPaced((rows) => rows.map((j) => j.status)),
|
|
22
|
+
});
|
|
23
|
+
const rows = jobs.data ?? [];
|
|
24
|
+
const current = rows[Math.min(selected, rows.length - 1)];
|
|
25
|
+
const inspect = async (job) => {
|
|
26
|
+
// Re-read it: the list is a summary, and the steps of a job that has moved
|
|
27
|
+
// on since the last poll are the whole point of opening it.
|
|
28
|
+
let full = job;
|
|
29
|
+
try {
|
|
30
|
+
full = await qoren.jobs.get(job.id);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// The list row is still worth showing, so fall through with what we have.
|
|
34
|
+
}
|
|
35
|
+
const steps = full.steps
|
|
36
|
+
.map((s) => `${s.status.padEnd(10)} ${s.label || s.key}${s.detail ? ` ${s.detail}` : ""}`)
|
|
37
|
+
.join("\n");
|
|
38
|
+
await ui.show(`${full.title || full.type} ${full.status}`, [
|
|
39
|
+
`Id ${full.id}`,
|
|
40
|
+
`Target ${full.target ?? "-"}`,
|
|
41
|
+
`Started ${full.startedAt ?? "-"}`,
|
|
42
|
+
`Ended ${full.finishedAt ?? "-"}`,
|
|
43
|
+
"",
|
|
44
|
+
steps || "(no steps recorded)",
|
|
45
|
+
full.error ? `\nFailed at ${full.error.stepKey ?? "?"}\n${full.error.message}` : "",
|
|
46
|
+
].join("\n"));
|
|
47
|
+
};
|
|
48
|
+
const watch = async (job) => {
|
|
49
|
+
const outcome = await ui.job(job.id, job.title || job.type);
|
|
50
|
+
if (outcome.status === "failed")
|
|
51
|
+
ui.toast(outcome.message, "bad");
|
|
52
|
+
else if (outcome.status === "done")
|
|
53
|
+
ui.toast("Finished.");
|
|
54
|
+
jobs.reload();
|
|
55
|
+
};
|
|
56
|
+
const cancel = async (job) => {
|
|
57
|
+
const ok = await ui.confirm({
|
|
58
|
+
title: `Cancel ${job.title || job.type}?`,
|
|
59
|
+
body: "Best effort: a step already running finishes before it stops.",
|
|
60
|
+
});
|
|
61
|
+
if (!ok)
|
|
62
|
+
return;
|
|
63
|
+
try {
|
|
64
|
+
await qoren.jobs.cancel(job.id);
|
|
65
|
+
ui.toast("Cancellation requested.");
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
ui.toast(describeError(err), "bad");
|
|
69
|
+
}
|
|
70
|
+
jobs.reload();
|
|
71
|
+
};
|
|
72
|
+
useInput((input, key) => {
|
|
73
|
+
const next = navigate(rows.length, selected, input, key);
|
|
74
|
+
if (next !== null) {
|
|
75
|
+
setSelected(next);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!current)
|
|
79
|
+
return;
|
|
80
|
+
if (key.return)
|
|
81
|
+
void inspect(current);
|
|
82
|
+
else if (input === "w")
|
|
83
|
+
void watch(current);
|
|
84
|
+
else if (input === "c")
|
|
85
|
+
void cancel(current);
|
|
86
|
+
}, { isActive: focused && !ui.busy });
|
|
87
|
+
return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Box, { flexDirection: "column", flexGrow: 1, children: _jsx(Table, { rows: rows, selected: selected, height: height, focused: focused, empty: jobs.loading ? "Loading..." : "Nothing has run yet.", columns: [
|
|
88
|
+
{ header: "job", width: 30, value: (j) => j.title || j.type },
|
|
89
|
+
{
|
|
90
|
+
header: "status",
|
|
91
|
+
width: 10,
|
|
92
|
+
value: (j) => j.status,
|
|
93
|
+
color: (j) => statusColorName(j.status),
|
|
94
|
+
},
|
|
95
|
+
{ header: "steps", width: 7, value: jobProgressText },
|
|
96
|
+
{ header: "now", width: 26, value: (j) => truncate(currentStep(j), 26) },
|
|
97
|
+
{ header: "age", value: (j) => age(j.createdAt) },
|
|
98
|
+
] }) }), _jsx(Box, { children: _jsx(StatusLine, { error: jobs.error, refreshing: jobs.refreshing, children: _jsx(Hints, { keys: [
|
|
99
|
+
["enter", "steps"],
|
|
100
|
+
["w", "watch"],
|
|
101
|
+
["c", "cancel"],
|
|
102
|
+
] }) }) })] }));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../../src/tui/panes/jobs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE9D,0EAA0E;AAC1E,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,uBAAuB;AAEvB,MAAM,UAAU,QAAQ,CAAC,EACvB,MAAM,EACN,OAAO,GAIR;IACC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,CAAC;IAC/B,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5C,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAC1D,MAAM,E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AC,CAAC,IAAI,EAAE;wBAC7D;4BACE,MAAM,EAAE,QAAQ;4BAChB,KAAK,EAAE,EAAE;4BACT,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM;4BACtB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC;yBACxC;wBACD,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE;wBACrD,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE;wBACxE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;qBAClD,GACD,GACE,EACN,KAAC,GAAG,cACF,KAAC,UAAU,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,YACxD,KAAC,KAAK,IACJ,IAAI,EAAE;4BACJ,CAAC,OAAO,EAAE,OAAO,CAAC;4BAClB,CAAC,GAAG,EAAE,OAAO,CAAC;4BACd,CAAC,GAAG,EAAE,QAAQ,CAAC;yBAChB,GACD,GACS,GACT,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type Context } from "../context.js";
|
|
3
|
+
export declare function SessionProvider({ value, children, }: {
|
|
4
|
+
value: Context;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
/** The authenticated client, the profile behind it, and who it belongs to. */
|
|
8
|
+
export declare function useSession(): Context;
|
|
9
|
+
/** Whatever a failed request actually means, as one sentence. */
|
|
10
|
+
export declare function describeError(err: unknown): string;
|
|
11
|
+
export type Resource<T> = {
|
|
12
|
+
data: T | null;
|
|
13
|
+
error: string | null;
|
|
14
|
+
/** True only for the very first load; a background refresh never blanks the
|
|
15
|
+
* pane, because a list that flickers to "loading" every few seconds is worse
|
|
16
|
+
* than a list that is a few seconds stale. */
|
|
17
|
+
loading: boolean;
|
|
18
|
+
refreshing: boolean;
|
|
19
|
+
reload: () => void;
|
|
20
|
+
};
|
|
21
|
+
export type ResourceOptions<T> = {
|
|
22
|
+
/** Stop fetching entirely — the pane is off screen, or a form has the floor. */
|
|
23
|
+
active?: boolean;
|
|
24
|
+
/** How long to wait before refetching. Given the last value so a pane can
|
|
25
|
+
* poll hard while something is mid-flight and slowly otherwise. Return 0 to
|
|
26
|
+
* fetch once and never again. */
|
|
27
|
+
interval?: (data: T | null) => number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Load something, keep it fresh, and hand back what is known right now.
|
|
31
|
+
*
|
|
32
|
+
* `load` is re-run whenever `key` changes, which is how a pane switches to a
|
|
33
|
+
* different environment's agents without a stale list showing through. An
|
|
34
|
+
* AbortSignal is passed so an in-flight request is dropped rather than raced.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useResource<T>(key: string, load: (signal: AbortSignal) => Promise<T>, options?: ResourceOptions<T>): Resource<T>;
|
|
37
|
+
/** The usual cadence: poll hard while anything in the list is mid-flight, and
|
|
38
|
+
* slowly when the fleet is at rest. */
|
|
39
|
+
export declare const statusPaced: <T>(statuses: (data: T) => string[]) => (data: T | null) => number;
|
|
40
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/tui/store.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAsC,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAajF,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAIA;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,IAAI,OAAO,CAIpC;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAclD;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACxB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;kDAE8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;qCAEiC;IACjC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,OAAO,GAAE,eAAe,CAAC,CAAC,CAAM,GAC/B,QAAQ,CAAC,CAAC,CAAC,CAqEb;AAED;uCACuC;AACvC,eAAO,MAAM,WAAW,GACrB,CAAC,EAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAAE,MACnC,MAAM,CAAC,GAAG,IAAI,KAAG,MACwB,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
|
|
3
|
+
import { QorenError } from "@qoren/sdk";
|
|
4
|
+
import { isApiAccessRequired, isOrgDeleting } from "../context.js";
|
|
5
|
+
import { refreshDelay } from "./model.js";
|
|
6
|
+
// Talking to the control plane from a long-lived process.
|
|
7
|
+
//
|
|
8
|
+
// A command runs once and exits, so it can afford to be naive about fetching. A
|
|
9
|
+
// console stays open for an hour, so it cannot: it has to refresh without being
|
|
10
|
+
// asked, stop refreshing what nobody is looking at, and never let a request
|
|
11
|
+
// that was in flight when the reader moved on write into the pane they moved
|
|
12
|
+
// to. All of that lives here, so the panes stay declarative.
|
|
13
|
+
const SessionContext = createContext(null);
|
|
14
|
+
export function SessionProvider({ value, children, }) {
|
|
15
|
+
return (_jsx(SessionContext.Provider, { value: value, children: children }));
|
|
16
|
+
}
|
|
17
|
+
/** The authenticated client, the profile behind it, and who it belongs to. */
|
|
18
|
+
export function useSession() {
|
|
19
|
+
const ctx = useContext(SessionContext);
|
|
20
|
+
if (!ctx)
|
|
21
|
+
throw new Error("useSession outside a SessionProvider");
|
|
22
|
+
return ctx;
|
|
23
|
+
}
|
|
24
|
+
/** Whatever a failed request actually means, as one sentence. */
|
|
25
|
+
export function describeError(err) {
|
|
26
|
+
if (err instanceof QorenError) {
|
|
27
|
+
// Before isAuthError: a 403, but the plan is the problem, not the token.
|
|
28
|
+
if (isApiAccessRequired(err))
|
|
29
|
+
return err.message;
|
|
30
|
+
if (isOrgDeleting(err))
|
|
31
|
+
return err.message;
|
|
32
|
+
if (err.isAuthError) {
|
|
33
|
+
return "Your credentials were rejected. Quit and run `qoren login` again.";
|
|
34
|
+
}
|
|
35
|
+
if (err.isPaymentRequired) {
|
|
36
|
+
return "This action needs an active plan.";
|
|
37
|
+
}
|
|
38
|
+
return err.message;
|
|
39
|
+
}
|
|
40
|
+
return err instanceof Error ? err.message : String(err);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load something, keep it fresh, and hand back what is known right now.
|
|
44
|
+
*
|
|
45
|
+
* `load` is re-run whenever `key` changes, which is how a pane switches to a
|
|
46
|
+
* different environment's agents without a stale list showing through. An
|
|
47
|
+
* AbortSignal is passed so an in-flight request is dropped rather than raced.
|
|
48
|
+
*/
|
|
49
|
+
export function useResource(key, load, options = {}) {
|
|
50
|
+
const { active = true, interval } = options;
|
|
51
|
+
const [data, setData] = useState(null);
|
|
52
|
+
const [error, setError] = useState(null);
|
|
53
|
+
const [loading, setLoading] = useState(true);
|
|
54
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
55
|
+
const [nonce, setNonce] = useState(0);
|
|
56
|
+
// Held in refs so changing them does not restart the fetch effect: `load` is
|
|
57
|
+
// an inline closure at every call site and would otherwise re-fire forever.
|
|
58
|
+
const loadRef = useRef(load);
|
|
59
|
+
loadRef.current = load;
|
|
60
|
+
const intervalRef = useRef(interval);
|
|
61
|
+
intervalRef.current = interval;
|
|
62
|
+
// The interval callback needs the value the last fetch produced, and reading
|
|
63
|
+
// `data` from the effect's closure would pin it to whatever it was at setup.
|
|
64
|
+
const dataRef = useRef(null);
|
|
65
|
+
dataRef.current = data;
|
|
66
|
+
// A key change means the pane is now showing something else, so the old
|
|
67
|
+
// value must not linger under the new heading.
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setData(null);
|
|
70
|
+
setError(null);
|
|
71
|
+
setLoading(true);
|
|
72
|
+
}, [key]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!active)
|
|
75
|
+
return;
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
let timer;
|
|
78
|
+
let cancelled = false;
|
|
79
|
+
const tick = async (first) => {
|
|
80
|
+
if (!first)
|
|
81
|
+
setRefreshing(true);
|
|
82
|
+
try {
|
|
83
|
+
const value = await loadRef.current(controller.signal);
|
|
84
|
+
if (cancelled)
|
|
85
|
+
return;
|
|
86
|
+
setData(value);
|
|
87
|
+
setError(null);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (cancelled || controller.signal.aborted)
|
|
91
|
+
return;
|
|
92
|
+
// Keep whatever was on screen: a transient failure should read as a
|
|
93
|
+
// warning next to stale data, not as an empty pane.
|
|
94
|
+
setError(describeError(err));
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
if (!cancelled) {
|
|
98
|
+
setLoading(false);
|
|
99
|
+
setRefreshing(false);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (cancelled)
|
|
103
|
+
return;
|
|
104
|
+
const wait = intervalRef.current?.(dataRef.current) ?? 0;
|
|
105
|
+
if (wait > 0)
|
|
106
|
+
timer = setTimeout(() => void tick(false), wait);
|
|
107
|
+
};
|
|
108
|
+
void tick(true);
|
|
109
|
+
return () => {
|
|
110
|
+
cancelled = true;
|
|
111
|
+
controller.abort();
|
|
112
|
+
if (timer)
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
};
|
|
115
|
+
}, [key, active, nonce]);
|
|
116
|
+
const reload = useCallback(() => {
|
|
117
|
+
setNonce((n) => n + 1);
|
|
118
|
+
}, []);
|
|
119
|
+
return { data, error, loading, refreshing, reload };
|
|
120
|
+
}
|
|
121
|
+
/** The usual cadence: poll hard while anything in the list is mid-flight, and
|
|
122
|
+
* slowly when the fleet is at rest. */
|
|
123
|
+
export const statusPaced = (statuses) => (data) => refreshDelay(data ? statuses(data) : []);
|
|
124
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/tui/store.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAgB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,0DAA0D;AAC1D,EAAE;AACF,gFAAgF;AA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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC;AAED;uCACuC;AACvC,MAAM,CAAC,MAAM,WAAW,GACtB,CAAK,QAA+B,EAAE,EAAE,CACxC,CAAC,IAAc,EAAU,EAAE,CACzB,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
package/dist/tui/ui.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type Key } from "ink";
|
|
3
|
+
import { type LineState } from "./model.js";
|
|
4
|
+
export declare const ACCENT = "cyan";
|
|
5
|
+
/** A frame around a pane, titled, with the accent border when it has focus. */
|
|
6
|
+
export declare function Panel({ title, focused, footer, children, }: {
|
|
7
|
+
title: string;
|
|
8
|
+
focused?: boolean;
|
|
9
|
+
footer?: ReactNode;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export type Column<T> = {
|
|
13
|
+
header: string;
|
|
14
|
+
/** Fixed width in characters. The last column may omit it to take the rest. */
|
|
15
|
+
width?: number;
|
|
16
|
+
value: (row: T) => string;
|
|
17
|
+
color?: (row: T) => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A scrolling, selectable table.
|
|
21
|
+
*
|
|
22
|
+
* Selection and the scroll window are the caller's state, not this component's:
|
|
23
|
+
* a pane needs to know which row is selected to act on it, and lifting that up
|
|
24
|
+
* is simpler than reaching into a child for it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Table<T>({ rows, columns, selected, height, focused, empty, }: {
|
|
27
|
+
rows: T[];
|
|
28
|
+
columns: Column<T>[];
|
|
29
|
+
selected: number;
|
|
30
|
+
height: number;
|
|
31
|
+
focused?: boolean;
|
|
32
|
+
empty?: string;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
/** A key/value block for one record. */
|
|
35
|
+
export declare function Details({ pairs }: {
|
|
36
|
+
pairs: [string, ReactNode][];
|
|
37
|
+
}): import("react").JSX.Element;
|
|
38
|
+
/** Something is happening and we do not know for how long. */
|
|
39
|
+
export declare function Spinner({ label }: {
|
|
40
|
+
label?: string;
|
|
41
|
+
}): import("react").JSX.Element;
|
|
42
|
+
/**
|
|
43
|
+
* A single-line text field.
|
|
44
|
+
*
|
|
45
|
+
* Ink has no cursor of its own to lend a component, so the caret is drawn: the
|
|
46
|
+
* character under it is rendered inverse, and a caret past the end of the line
|
|
47
|
+
* becomes an inverse space. Editing rules live in model.editLine, which is
|
|
48
|
+
* where they can be tested.
|
|
49
|
+
*/
|
|
50
|
+
export declare function Field({ value, onChange, onSubmit, onCancel, placeholder, mask, focused, }: {
|
|
51
|
+
value: LineState;
|
|
52
|
+
onChange: (next: LineState) => void;
|
|
53
|
+
onSubmit?: (value: string) => void;
|
|
54
|
+
onCancel?: () => void;
|
|
55
|
+
placeholder?: string;
|
|
56
|
+
mask?: boolean;
|
|
57
|
+
focused?: boolean;
|
|
58
|
+
}): import("react").JSX.Element;
|
|
59
|
+
/** A field that owns its own buffer, for the common one-shot prompt. */
|
|
60
|
+
export declare function useField(initial?: string): {
|
|
61
|
+
line: LineState;
|
|
62
|
+
setLine: import("react").Dispatch<import("react").SetStateAction<LineState>>;
|
|
63
|
+
value: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A vertical list of choices.
|
|
67
|
+
*
|
|
68
|
+
* Used for every "which one?" the console asks — size, region, template, model,
|
|
69
|
+
* environment — because they are all the same question, and a person who has
|
|
70
|
+
* learned to pick a size has learned to pick a template.
|
|
71
|
+
*/
|
|
72
|
+
export declare function Choices<T>({ items, selected, render, height, hint, }: {
|
|
73
|
+
items: T[];
|
|
74
|
+
selected: number;
|
|
75
|
+
render: (item: T) => {
|
|
76
|
+
label: string;
|
|
77
|
+
detail?: string;
|
|
78
|
+
};
|
|
79
|
+
height?: number;
|
|
80
|
+
hint?: (item: T) => string | undefined;
|
|
81
|
+
}): import("react").JSX.Element;
|
|
82
|
+
/** Move a selection with the arrow keys, j/k, or page keys. Returns the new
|
|
83
|
+
* index, or null when the keystroke was not navigation. */
|
|
84
|
+
export declare function navigate(count: number, current: number, input: string, key: Key, page?: number): number | null;
|
|
85
|
+
/** The key hints along the bottom of a pane. */
|
|
86
|
+
export declare function Hints({ keys }: {
|
|
87
|
+
keys: [string, string][];
|
|
88
|
+
}): import("react").JSX.Element;
|
|
89
|
+
/** Whatever the pane wants to say about its own state, in one line. */
|
|
90
|
+
export declare function StatusLine({ error, refreshing, children, }: {
|
|
91
|
+
error?: string | null;
|
|
92
|
+
refreshing?: boolean;
|
|
93
|
+
children?: ReactNode;
|
|
94
|
+
}): import("react").JSX.Element;
|
|
95
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/tui/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAuB,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACpD,OAAO,EAML,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AASpB,eAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,OAAc,EACd,MAAM,EACN,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAoBA;AAED,MAAM,MAAM,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_jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Box, Text, useInput } from "ink";
|
|
4
|
+
import { editLine, emptyLine, moveSelection, scrollWindow, truncate, } from "./model.js";
|
|
5
|
+
// The console's furniture: lists, fields, key hints.
|
|
6
|
+
//
|
|
7
|
+
// Deliberately plain. A terminal is a low-resolution medium and a fleet console
|
|
8
|
+
// is something people keep open, so the job here is legibility over decoration:
|
|
9
|
+
// one accent colour for what is selected, dim for what is context, and nothing
|
|
10
|
+
// that moves unless something is actually happening.
|
|
11
|
+
export const ACCENT = "cyan";
|
|
12
|
+
/** A frame around a pane, titled, with the accent border when it has focus. */
|
|
13
|
+
export function Panel({ title, focused = true, footer, children, }) {
|
|
14
|
+
return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, borderStyle: "round", borderColor: focused ? ACCENT : "gray", paddingX: 1, children: [_jsx(Box, { children: _jsx(Text, { bold: true, color: focused ? ACCENT : undefined, children: title }) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, children: children }), footer ? _jsx(Box, { children: footer }) : null] }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A scrolling, selectable table.
|
|
18
|
+
*
|
|
19
|
+
* Selection and the scroll window are the caller's state, not this component's:
|
|
20
|
+
* a pane needs to know which row is selected to act on it, and lifting that up
|
|
21
|
+
* is simpler than reaching into a child for it.
|
|
22
|
+
*/
|
|
23
|
+
export function Table({ rows, columns, selected, height, focused = true, empty = "Nothing here yet.", }) {
|
|
24
|
+
const startRef = useRef(0);
|
|
25
|
+
const window = scrollWindow(rows.length, selected, height, startRef.current);
|
|
26
|
+
startRef.current = window.start;
|
|
27
|
+
if (rows.length === 0) {
|
|
28
|
+
return (_jsx(Box, { paddingTop: 1, children: _jsx(Text, { dimColor: true, children: empty }) }));
|
|
29
|
+
}
|
|
30
|
+
const cell = (text, width) => width === undefined ? text : truncate(text, width).padEnd(width);
|
|
31
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: [" ", columns
|
|
32
|
+
.map((c) => cell(c.header.toUpperCase(), c.width))
|
|
33
|
+
.join(" ")] }), rows.slice(window.start, window.end).map((row, i) => {
|
|
34
|
+
const index = window.start + i;
|
|
35
|
+
const isSelected = index === selected;
|
|
36
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: isSelected ? ACCENT : undefined, children: isSelected && focused ? "> " : " " }), columns.map((column, c) => (_jsxs(Text, { color: isSelected && focused ? ACCENT : column.color?.(row), bold: isSelected && focused, dimColor: !isSelected && c > 0 && !column.color, children: [cell(column.value(row) || "-", column.width), c < columns.length - 1 ? " " : ""] }, c)))] }, index));
|
|
37
|
+
}), rows.length > height ? (_jsx(Text, { dimColor: true, children: ` ${window.start + 1}-${window.end} of ${rows.length}` })) : null] }));
|
|
38
|
+
}
|
|
39
|
+
/** A key/value block for one record. */
|
|
40
|
+
export function Details({ pairs }) {
|
|
41
|
+
const width = Math.max(...pairs.map(([key]) => key.length));
|
|
42
|
+
return (_jsx(Box, { flexDirection: "column", children: pairs.map(([key, value]) => (_jsxs(Box, { children: [_jsxs(Text, { dimColor: true, children: [key.padEnd(width), " "] }), typeof value === "string" ? (_jsx(Text, { children: value || "-" })) : ((value ?? _jsx(Text, { dimColor: true, children: "-" })))] }, key))) }));
|
|
43
|
+
}
|
|
44
|
+
const FRAMES = ["|", "/", "-", "\\"];
|
|
45
|
+
/** Something is happening and we do not know for how long. */
|
|
46
|
+
export function Spinner({ label }) {
|
|
47
|
+
const [frame, setFrame] = useState(0);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const timer = setInterval(() => {
|
|
50
|
+
setFrame((f) => (f + 1) % FRAMES.length);
|
|
51
|
+
}, 120);
|
|
52
|
+
return () => {
|
|
53
|
+
clearInterval(timer);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
return (_jsxs(Text, { color: ACCENT, children: [FRAMES[frame], label ? ` ${label}` : ""] }));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A single-line text field.
|
|
60
|
+
*
|
|
61
|
+
* Ink has no cursor of its own to lend a component, so the caret is drawn: the
|
|
62
|
+
* character under it is rendered inverse, and a caret past the end of the line
|
|
63
|
+
* becomes an inverse space. Editing rules live in model.editLine, which is
|
|
64
|
+
* where they can be tested.
|
|
65
|
+
*/
|
|
66
|
+
export function Field({ value, onChange, onSubmit, onCancel, placeholder = "", mask = false, focused = true, }) {
|
|
67
|
+
useInput((input, key) => {
|
|
68
|
+
if (key.return) {
|
|
69
|
+
onSubmit?.(value.value);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (key.escape) {
|
|
73
|
+
onCancel?.();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const next = editLine(value, input, key);
|
|
77
|
+
if (next !== value)
|
|
78
|
+
onChange(next);
|
|
79
|
+
}, { isActive: focused });
|
|
80
|
+
const text = mask ? "*".repeat(value.value.length) : value.value;
|
|
81
|
+
if (!text) {
|
|
82
|
+
return (_jsxs(Text, { children: [focused ? _jsx(Text, { inverse: true, children: " " }) : null, _jsx(Text, { dimColor: true, children: placeholder })] }));
|
|
83
|
+
}
|
|
84
|
+
const before = text.slice(0, value.cursor);
|
|
85
|
+
const at = text.slice(value.cursor, value.cursor + 1);
|
|
86
|
+
const after = text.slice(value.cursor + 1);
|
|
87
|
+
return (_jsxs(Text, { children: [before, focused ? _jsx(Text, { inverse: true, children: at || " " }) : at, after] }));
|
|
88
|
+
}
|
|
89
|
+
/** A field that owns its own buffer, for the common one-shot prompt. */
|
|
90
|
+
export function useField(initial = "") {
|
|
91
|
+
const [line, setLine] = useState(() => emptyLine(initial));
|
|
92
|
+
return { line, setLine, value: line.value };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A vertical list of choices.
|
|
96
|
+
*
|
|
97
|
+
* Used for every "which one?" the console asks — size, region, template, model,
|
|
98
|
+
* environment — because they are all the same question, and a person who has
|
|
99
|
+
* learned to pick a size has learned to pick a template.
|
|
100
|
+
*/
|
|
101
|
+
export function Choices({ items, selected, render, height = 10, hint, }) {
|
|
102
|
+
const startRef = useRef(0);
|
|
103
|
+
const window = scrollWindow(items.length, selected, height, startRef.current);
|
|
104
|
+
startRef.current = window.start;
|
|
105
|
+
if (items.length === 0)
|
|
106
|
+
return _jsx(Text, { dimColor: true, children: "Nothing to choose from." });
|
|
107
|
+
return (_jsxs(Box, { flexDirection: "column", children: [items.slice(window.start, window.end).map((item, i) => {
|
|
108
|
+
const index = window.start + i;
|
|
109
|
+
const isSelected = index === selected;
|
|
110
|
+
const { label, detail } = render(item);
|
|
111
|
+
return (_jsxs(Box, { children: [_jsxs(Text, { color: isSelected ? ACCENT : undefined, bold: isSelected, children: [isSelected ? "> " : " ", label] }), detail ? _jsx(Text, { dimColor: true, children: ` ${detail}` }) : null, hint?.(item) ? _jsx(Text, { color: "green", children: ` ${hint(item)}` }) : null] }, index));
|
|
112
|
+
}), items.length > height ? (_jsx(Text, { dimColor: true, children: ` ${window.start + 1}-${window.end} of ${items.length}` })) : null] }));
|
|
113
|
+
}
|
|
114
|
+
/** Move a selection with the arrow keys, j/k, or page keys. Returns the new
|
|
115
|
+
* index, or null when the keystroke was not navigation. */
|
|
116
|
+
export function navigate(count, current, input, key, page = 10) {
|
|
117
|
+
if (key.downArrow || input === "j")
|
|
118
|
+
return moveSelection(count, current, 1);
|
|
119
|
+
if (key.upArrow || input === "k")
|
|
120
|
+
return moveSelection(count, current, -1);
|
|
121
|
+
if (key.pageDown)
|
|
122
|
+
return moveSelection(count, current, page);
|
|
123
|
+
if (key.pageUp)
|
|
124
|
+
return moveSelection(count, current, -page);
|
|
125
|
+
if (key.home || input === "g")
|
|
126
|
+
return 0;
|
|
127
|
+
if (key.end || input === "G")
|
|
128
|
+
return Math.max(0, count - 1);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
/** The key hints along the bottom of a pane. */
|
|
132
|
+
export function Hints({ keys }) {
|
|
133
|
+
return (_jsx(Text, { dimColor: true, children: keys.map(([key, label], i) => (_jsxs(Text, { children: [i > 0 ? " " : "", _jsx(Text, { color: ACCENT, children: key }), " ", label] }, key))) }));
|
|
134
|
+
}
|
|
135
|
+
/** Whatever the pane wants to say about its own state, in one line. */
|
|
136
|
+
export function StatusLine({ error, refreshing, children, }) {
|
|
137
|
+
if (error) {
|
|
138
|
+
return (_jsx(Text, { color: "red", wrap: "truncate-end", children: error }));
|
|
139
|
+
}
|
|
140
|
+
if (refreshing)
|
|
141
|
+
return _jsx(Spinner, { label: "refreshing" });
|
|
142
|
+
return _jsx(_Fragment, { children: children ?? null });
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/tui/ui.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAY,MAAM,KAAK,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,GAET,MAAM,YAAY,CAAC;AAEpB,qDAAqD;AACrD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,qDAAqD;AAErD,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAE7B,+EAA+E;AAC/E,MAAM,UAAU,KAAK,CAAC,EACpB,KAAK,EACL,OAAO,GAAG,IAAI,EACd,MAAM,EACN,QAAQ,GAMT;IACC,OAAO,CACL,MAAC,GAAG,IACF,aAAa,EAAC,QAAQ,EACtB,QAAQ,EAAE,CAAC,EACX,WAAW,EAAC,OAAO,EACnB,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACt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AI,CAAC,CAAC,CAAC,EAAE,EAClB,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,YAAG,GAAG,GAAQ,OAAE,KAAK,KAF/B,GAAG,CAGP,CACR,CAAC,GACG,CACR,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,UAAU,EACV,QAAQ,GAKT;IACC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CACL,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,cAAc,YAClC,KAAK,GACD,CACR,CAAC;IACJ,CAAC;IACD,IAAI,UAAU;QAAE,OAAO,KAAC,OAAO,IAAC,KAAK,EAAC,YAAY,GAAG,CAAC;IACtD,OAAO,4BAAG,QAAQ,IAAI,IAAI,GAAI,CAAC;AACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qoren/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Drive your Qoren account, environments and agents from the terminal.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://qoren.sh/docs/cli",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://qoren.sh/docs/report-a-bug",
|
|
9
|
+
"email": "hello@qoren.sh"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"qoren": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"check": "eslint . && tsc --noEmit",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@qoren/sdk": "^0.1.0",
|
|
36
|
+
"commander": "^13.1.0",
|
|
37
|
+
"ink": "^7.1.1",
|
|
38
|
+
"picocolors": "^1.1.1",
|
|
39
|
+
"react": "^19.2.8"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/js": "^9.39.0",
|
|
43
|
+
"@types/node": "^22.10.2",
|
|
44
|
+
"@types/react": "^19.2.18",
|
|
45
|
+
"eslint": "^9.39.0",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"typescript-eslint": "^8.46.2",
|
|
48
|
+
"vitest": "^4.1.10"
|
|
49
|
+
},
|
|
50
|
+
"packageManager": "npm@11.7.0"
|
|
51
|
+
}
|