@ora-ai/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 +21 -0
- package/README.md +102 -0
- package/dist/auth-commands.d.ts +39 -0
- package/dist/auth-commands.d.ts.map +1 -0
- package/dist/auth-commands.js +116 -0
- package/dist/auth-commands.js.map +1 -0
- package/dist/core/auth.d.ts +41 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +110 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/config.d.ts +26 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +51 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/http.d.ts +46 -0
- package/dist/core/http.d.ts.map +1 -0
- package/dist/core/http.js +82 -0
- package/dist/core/http.js.map +1 -0
- package/dist/core/login.d.ts +14 -0
- package/dist/core/login.d.ts.map +1 -0
- package/dist/core/login.js +70 -0
- package/dist/core/login.js.map +1 -0
- package/dist/core/output.d.ts +18 -0
- package/dist/core/output.d.ts.map +1 -0
- package/dist/core/output.js +94 -0
- package/dist/core/output.js.map +1 -0
- package/dist/core/run-operation.d.ts +57 -0
- package/dist/core/run-operation.d.ts.map +1 -0
- package/dist/core/run-operation.js +119 -0
- package/dist/core/run-operation.js.map +1 -0
- package/dist/core/sse.d.ts +13 -0
- package/dist/core/sse.d.ts.map +1 -0
- package/dist/core/sse.js +63 -0
- package/dist/core/sse.js.map +1 -0
- package/dist/generated/operations.d.ts +47 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +2050 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/generated/types.d.ts +1039 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive/derive-prompts.d.ts +44 -0
- package/dist/interactive/derive-prompts.d.ts.map +1 -0
- package/dist/interactive/derive-prompts.js +58 -0
- package/dist/interactive/derive-prompts.js.map +1 -0
- package/dist/interactive/inquirer-prompter.d.ts +11 -0
- package/dist/interactive/inquirer-prompter.d.ts.map +1 -0
- package/dist/interactive/inquirer-prompter.js +64 -0
- package/dist/interactive/inquirer-prompter.js.map +1 -0
- package/dist/interactive/menu.d.ts +25 -0
- package/dist/interactive/menu.d.ts.map +1 -0
- package/dist/interactive/menu.js +57 -0
- package/dist/interactive/menu.js.map +1 -0
- package/dist/interactive/prompter.d.ts +25 -0
- package/dist/interactive/prompter.d.ts.map +1 -0
- package/dist/interactive/prompter.js +14 -0
- package/dist/interactive/prompter.js.map +1 -0
- package/dist/interactive/session.d.ts +19 -0
- package/dist/interactive/session.d.ts.map +1 -0
- package/dist/interactive/session.js +204 -0
- package/dist/interactive/session.js.map +1 -0
- package/dist/program.d.ts +81 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +178 -0
- package/dist/program.js.map +1 -0
- package/dist/render/ansi.d.ts +13 -0
- package/dist/render/ansi.d.ts.map +1 -0
- package/dist/render/ansi.js +34 -0
- package/dist/render/ansi.js.map +1 -0
- package/dist/render/banner.d.ts +7 -0
- package/dist/render/banner.d.ts.map +1 -0
- package/dist/render/banner.js +18 -0
- package/dist/render/banner.js.map +1 -0
- package/dist/render/glyphs.d.ts +39 -0
- package/dist/render/glyphs.d.ts.map +1 -0
- package/dist/render/glyphs.js +83 -0
- package/dist/render/glyphs.js.map +1 -0
- package/dist/render/index.d.ts +13 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +24 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/insight-lines.d.ts +8 -0
- package/dist/render/insight-lines.d.ts.map +1 -0
- package/dist/render/insight-lines.js +62 -0
- package/dist/render/insight-lines.js.map +1 -0
- package/dist/render/insight.d.ts +9 -0
- package/dist/render/insight.d.ts.map +1 -0
- package/dist/render/insight.js +68 -0
- package/dist/render/insight.js.map +1 -0
- package/dist/render/journey-graph.d.ts +73 -0
- package/dist/render/journey-graph.d.ts.map +1 -0
- package/dist/render/journey-graph.js +250 -0
- package/dist/render/journey-graph.js.map +1 -0
- package/dist/render/journey.d.ts +14 -0
- package/dist/render/journey.d.ts.map +1 -0
- package/dist/render/journey.js +67 -0
- package/dist/render/journey.js.map +1 -0
- package/dist/render/live-panel.d.ts +34 -0
- package/dist/render/live-panel.d.ts.map +1 -0
- package/dist/render/live-panel.js +84 -0
- package/dist/render/live-panel.js.map +1 -0
- package/dist/render/mode.d.ts +19 -0
- package/dist/render/mode.d.ts.map +1 -0
- package/dist/render/mode.js +23 -0
- package/dist/render/mode.js.map +1 -0
- package/dist/render/registry.d.ts +17 -0
- package/dist/render/registry.d.ts.map +1 -0
- package/dist/render/registry.js +34 -0
- package/dist/render/registry.js.map +1 -0
- package/dist/render/run-list.d.ts +11 -0
- package/dist/render/run-list.d.ts.map +1 -0
- package/dist/render/run-list.js +53 -0
- package/dist/render/run-list.js.map +1 -0
- package/dist/render/spinner.d.ts +14 -0
- package/dist/render/spinner.d.ts.map +1 -0
- package/dist/render/spinner.js +37 -0
- package/dist/render/spinner.js.map +1 -0
- package/dist/render/table.d.ts +20 -0
- package/dist/render/table.d.ts.map +1 -0
- package/dist/render/table.js +29 -0
- package/dist/render/table.js.map +1 -0
- package/dist/render/trajectory.d.ts +19 -0
- package/dist/render/trajectory.d.ts.map +1 -0
- package/dist/render/trajectory.js +75 -0
- package/dist/render/trajectory.js.map +1 -0
- package/dist/render/tunnel.d.ts +10 -0
- package/dist/render/tunnel.d.ts.map +1 -0
- package/dist/render/tunnel.js +108 -0
- package/dist/render/tunnel.js.map +1 -0
- package/dist/render/usage.d.ts +29 -0
- package/dist/render/usage.d.ts.map +1 -0
- package/dist/render/usage.js +83 -0
- package/dist/render/usage.js.map +1 -0
- package/dist/tunnel-command.d.ts +15 -0
- package/dist/tunnel-command.d.ts.map +1 -0
- package/dist/tunnel-command.js +267 -0
- package/dist/tunnel-command.js.map +1 -0
- package/dist/watch.d.ts +53 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +305 -0
- package/dist/watch.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The interactive session: a derived-menu REPL over the manifest, depending only on the Prompter port + injectable
|
|
3
|
+
* SessionDeps.runOp/login — never on commander or a real terminal, so a scripted fake Prompter drives it in tests.
|
|
4
|
+
*/
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { clearCredentials, readConfig, resolveApiKey, resolveApiUrl } from "../core/config.js";
|
|
7
|
+
import { renderError } from "../core/output.js";
|
|
8
|
+
import { MISSING_BODY_MESSAGE, runOperation } from "../core/run-operation.js";
|
|
9
|
+
import { performLogin, performWhoami } from "../auth-commands.js";
|
|
10
|
+
import { SPEC } from "../generated/operations.js";
|
|
11
|
+
import { cliVersion } from "../program.js";
|
|
12
|
+
import { derivePromptPlan, valueFromAnswer } from "./derive-prompts.js";
|
|
13
|
+
import { BACK_VALUE, LOGIN_VALUE, LOGOUT_VALUE, QUIT_VALUE, WHOAMI_VALUE, groupMenu, operationFor, topLevelMenu } from "./menu.js";
|
|
14
|
+
import { PromptAborted } from "./prompter.js";
|
|
15
|
+
import { bannerLines } from "../render/banner.js";
|
|
16
|
+
// MenuEntry's {label, value} -> the Prompter port's {name, value} — the one shape adapter between menu.ts and Prompter.
|
|
17
|
+
const toChoices = (entries) => entries.map((e) => ({ name: e.label, value: e.value }));
|
|
18
|
+
// A bare word a shell would pass through unchanged — safe to print unquoted in a teach line.
|
|
19
|
+
const SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
20
|
+
/** Shell-quotes a value for a printed, copy-pasteable teach line: a bare safe word is left as-is; anything with whitespace or a shell metacharacter (including the empty string — a real, dispatchable empty argument) is single-quoted, with embedded single quotes escaped as the standard `'\''` (close, escaped quote, reopen). */
|
|
21
|
+
export function shellQuote(value) {
|
|
22
|
+
if (value !== "" && SHELL_SAFE.test(value))
|
|
23
|
+
return value;
|
|
24
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
25
|
+
}
|
|
26
|
+
/** The equivalent scriptable command for a collected RunValues — printed before the run confirm. */
|
|
27
|
+
export function teachLine(meta, values) {
|
|
28
|
+
const parts = ["ora", ...meta.commandPath, ...values.positionals.map(shellQuote)];
|
|
29
|
+
for (const [name, value] of Object.entries(values.query)) {
|
|
30
|
+
if (value === undefined || value === false)
|
|
31
|
+
continue;
|
|
32
|
+
const flag = meta.queryParams.find((q) => q.name === name)?.flag ?? name;
|
|
33
|
+
if (value === true)
|
|
34
|
+
parts.push(`--${flag}`);
|
|
35
|
+
else
|
|
36
|
+
parts.push(`--${flag}`, shellQuote(String(value)));
|
|
37
|
+
}
|
|
38
|
+
if (values.body !== undefined)
|
|
39
|
+
parts.push("--file run.json");
|
|
40
|
+
if (values.watch)
|
|
41
|
+
parts.push("--watch");
|
|
42
|
+
return parts.join(" ");
|
|
43
|
+
}
|
|
44
|
+
// Reserved sentinel for "leave this optional picker unset" — mirrors menu.ts's BACK_VALUE
|
|
45
|
+
// pattern (a value real API enums/booleans will never emit), offered ONLY on an optional
|
|
46
|
+
// field's select() so a required field can never be silently skipped.
|
|
47
|
+
export const SKIP_VALUE = "__skip__";
|
|
48
|
+
const SKIP_CHOICE = { name: "— skip —", value: SKIP_VALUE };
|
|
49
|
+
/** An OPTIONAL boolean has no confirm()-shaped way to say "leave unset" (blank Enter there always answers false-ish), so it prompts as a 3-way select instead. A REQUIRED boolean keeps the plain confirm(). */
|
|
50
|
+
async function askOptionalBoolean(message, prompter) {
|
|
51
|
+
const choice = await prompter.select(message, [
|
|
52
|
+
SKIP_CHOICE,
|
|
53
|
+
{ name: "true", value: "true" },
|
|
54
|
+
{ name: "false", value: "false" },
|
|
55
|
+
]);
|
|
56
|
+
return choice === SKIP_VALUE ? SKIP_VALUE : choice === "true";
|
|
57
|
+
}
|
|
58
|
+
function askField(field, name, prompter, optional) {
|
|
59
|
+
const message = field.description ?? name;
|
|
60
|
+
if (field.kind === "boolean")
|
|
61
|
+
return optional ? askOptionalBoolean(message, prompter) : prompter.confirm(message);
|
|
62
|
+
if (field.enum) {
|
|
63
|
+
const choices = field.enum.map((v) => ({ name: v, value: v }));
|
|
64
|
+
return prompter.select(message, optional ? [SKIP_CHOICE, ...choices] : choices);
|
|
65
|
+
}
|
|
66
|
+
// The "(Enter to skip)" hint lives entirely in the InquirerPrompter adapter now (it derives
|
|
67
|
+
// it from opts.required === false) — composing it here too would double-hint the message.
|
|
68
|
+
return prompter.input(message, { placeholder: field.placeholder, required: field.required });
|
|
69
|
+
}
|
|
70
|
+
function askStep(step, prompter, optional) {
|
|
71
|
+
if (step.kind === "positional")
|
|
72
|
+
return prompter.input(step.name, { required: true });
|
|
73
|
+
return step.kind === "query" ? askField(step.param, step.param.name, prompter, optional) : askField(step.field, step.field.name, prompter, optional);
|
|
74
|
+
}
|
|
75
|
+
// Re-prompts on ANY parseError (derive-prompts.ts's contract) — EXCEPT an OPTIONAL step whose blank raw answer skips
|
|
76
|
+
// parsing entirely and returns `undefined` ("leave unset"), so a blank Enter never dead-loops JSON.parse("")/Number("").
|
|
77
|
+
async function collectAnswer(step, prompter, errOut, optional) {
|
|
78
|
+
for (;;) {
|
|
79
|
+
const raw = await askStep(step, prompter, optional);
|
|
80
|
+
if (optional && raw === SKIP_VALUE)
|
|
81
|
+
return undefined; // enum/boolean picker's skip choice
|
|
82
|
+
if (optional && typeof raw === "string" && raw.trim() === "")
|
|
83
|
+
return undefined;
|
|
84
|
+
const result = valueFromAnswer(step, raw);
|
|
85
|
+
if (!result.parseError)
|
|
86
|
+
return result;
|
|
87
|
+
errOut(result.parseError);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function collectValues(meta, prompter, errOut) {
|
|
91
|
+
const positionals = [];
|
|
92
|
+
const query = {};
|
|
93
|
+
const body = {};
|
|
94
|
+
let skipOptional = false;
|
|
95
|
+
for (const step of derivePromptPlan(meta)) {
|
|
96
|
+
if (step.kind === "optionalGate") {
|
|
97
|
+
skipOptional = !(await prompter.confirm(`Fill in ${step.count} optional field${step.count === 1 ? "" : "s"}?`, false));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (skipOptional)
|
|
101
|
+
continue;
|
|
102
|
+
const optional = step.kind !== "positional" && (step.kind === "query" ? !step.param.required : !step.field.required);
|
|
103
|
+
const answer = await collectAnswer(step, prompter, errOut, optional);
|
|
104
|
+
if (!answer)
|
|
105
|
+
continue; // blank answer to an OPTIONAL field — leave it unset
|
|
106
|
+
const { key, value } = answer;
|
|
107
|
+
if (step.kind === "positional") {
|
|
108
|
+
positionals.push(String(value));
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (step.kind === "query")
|
|
112
|
+
query[key] = value;
|
|
113
|
+
else
|
|
114
|
+
body[key] = value;
|
|
115
|
+
}
|
|
116
|
+
const hasBody = meta.hasBody && Object.keys(body).length > 0;
|
|
117
|
+
return { positionals, query, ...(hasBody ? { body } : {}), json: false, plain: false, watch: false };
|
|
118
|
+
}
|
|
119
|
+
async function runChosenOperation(meta, prompter, deps, runOp) {
|
|
120
|
+
const values = await collectValues(meta, prompter, deps.errOut);
|
|
121
|
+
// A bodyRequired op whose fields are ALL optional (e.g. intents.update) can reach here with
|
|
122
|
+
// an empty collected body — declining/skipping every optional field is a legitimate path
|
|
123
|
+
// through collectValues, but dispatching it would silently PATCH with no body. Mirror
|
|
124
|
+
// readBody's own missing-body story instead of sending it, and leave process.exitCode alone
|
|
125
|
+
// (this is a declined-at-the-gate story, not a failed call).
|
|
126
|
+
if (meta.bodyRequired && values.body === undefined) {
|
|
127
|
+
deps.errOut(renderError(new Error(MISSING_BODY_MESSAGE)));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (meta.watchable)
|
|
131
|
+
values.watch = await prompter.confirm("Stream live events after create?", true);
|
|
132
|
+
deps.out(teachLine(meta, values));
|
|
133
|
+
// Surface the run's engine configs at approval time — the harness/model/
|
|
134
|
+
// provider the request will carry, or the platform default when unset.
|
|
135
|
+
// ONLY for run-creating (watchable) ops — a tunnels/intents create has no
|
|
136
|
+
// engine and the line reads as noise there (a real user complaint).
|
|
137
|
+
if (meta.watchable && typeof values.body === "object" && values.body !== null) {
|
|
138
|
+
const b = values.body;
|
|
139
|
+
const cfg = ["harness", "model", "provider", "engine"]
|
|
140
|
+
.map((k) => (typeof b[k] === "string" ? `${k} ${String(b[k])}` : undefined))
|
|
141
|
+
.filter((v) => Boolean(v));
|
|
142
|
+
deps.out(chalk.dim(` ▶ ${cfg.length ? cfg.join(" · ") : "harness/model: platform default"}`));
|
|
143
|
+
}
|
|
144
|
+
if (!(await prompter.confirm("Run this?", true)))
|
|
145
|
+
return;
|
|
146
|
+
await runOp(meta, values, deps);
|
|
147
|
+
if (process.exitCode)
|
|
148
|
+
process.exitCode = 0; // the session survives a failed call — exit code is the session's, not one command's
|
|
149
|
+
}
|
|
150
|
+
async function handleLogin(prompter, deps, login) {
|
|
151
|
+
await login(deps, { apiKey: await prompter.password("Paste your ora_sk_… api key") });
|
|
152
|
+
if (process.exitCode)
|
|
153
|
+
process.exitCode = 0;
|
|
154
|
+
}
|
|
155
|
+
async function handleWhoami(deps) {
|
|
156
|
+
if (!resolveApiKey(readConfig(deps.dir), deps.env))
|
|
157
|
+
return deps.errOut("No api key configured — choose login first.");
|
|
158
|
+
await performWhoami(deps, {});
|
|
159
|
+
if (process.exitCode)
|
|
160
|
+
process.exitCode = 0; // the session survives a failed call — exit code is the session's, not one command's
|
|
161
|
+
}
|
|
162
|
+
/** Resolves on quit or Ctrl+C (PromptAborted). Never throws. */
|
|
163
|
+
export async function runSession(s) {
|
|
164
|
+
const { prompter, deps } = s;
|
|
165
|
+
const runOp = s.runOp ?? runOperation;
|
|
166
|
+
const login = s.login ?? performLogin;
|
|
167
|
+
try {
|
|
168
|
+
for (const line of bannerLines(cliVersion(), resolveApiUrl(readConfig(deps.dir), undefined, SPEC.server, deps.env))) {
|
|
169
|
+
deps.out(line);
|
|
170
|
+
}
|
|
171
|
+
if (!resolveApiKey(readConfig(deps.dir), deps.env))
|
|
172
|
+
await handleLogin(prompter, deps, login);
|
|
173
|
+
for (;;) {
|
|
174
|
+
const top = await prompter.select("ora", toChoices(topLevelMenu()));
|
|
175
|
+
if (top === QUIT_VALUE)
|
|
176
|
+
return;
|
|
177
|
+
if (top === LOGIN_VALUE) {
|
|
178
|
+
await handleLogin(prompter, deps, login);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (top === LOGOUT_VALUE) {
|
|
182
|
+
clearCredentials(deps.dir);
|
|
183
|
+
deps.out("Logged out.");
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (top === WHOAMI_VALUE) {
|
|
187
|
+
await handleWhoami(deps);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const choice = await prompter.select(top, toChoices(groupMenu(top)));
|
|
191
|
+
if (choice === BACK_VALUE)
|
|
192
|
+
continue;
|
|
193
|
+
const meta = operationFor(choice);
|
|
194
|
+
if (meta)
|
|
195
|
+
await runChosenOperation(meta, prompter, deps, runOp);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (err instanceof PromptAborted)
|
|
200
|
+
return;
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/interactive/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,m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ACX,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACrE,IAAI,MAAM,KAAK,UAAU;gBAAE,SAAS;YACpC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,IAAI;gBAAE,MAAM,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,aAAa;YAAE,OAAO;QACzC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commander program. ONE registrar walks the generated OPERATIONS
|
|
3
|
+
* manifest and builds every command (a data Registry — adding a public op to
|
|
4
|
+
* the platform changes the generated manifest, never this file), plus the
|
|
5
|
+
* three handwritten auth commands: login / logout / whoami (auth-commands.ts).
|
|
6
|
+
* The manifest-op execution core (credentials, path/query/body derivation,
|
|
7
|
+
* runOperation) lives in core/run-operation.ts — this file only wires
|
|
8
|
+
* commander around it.
|
|
9
|
+
*
|
|
10
|
+
* Every seam (client, auth, io, env, config dir) is injectable via
|
|
11
|
+
* ProgramDeps so tests drive the program through parseAsync — the same door a
|
|
12
|
+
* user uses.
|
|
13
|
+
*/
|
|
14
|
+
import { Command } from "commander";
|
|
15
|
+
import { ApiKeyAuth } from "./core/auth.js";
|
|
16
|
+
import type { HttpClient } from "./core/http.js";
|
|
17
|
+
export interface ProgramDeps {
|
|
18
|
+
makeClient?: (opts: {
|
|
19
|
+
apiUrl: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
}) => Pick<HttpClient, "call" | "open">;
|
|
22
|
+
makeAuth?: (opts: {
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
apiKey: string;
|
|
25
|
+
}) => Pick<ApiKeyAuth, "forceRefresh" | "clearCache" | "getToken">;
|
|
26
|
+
out?: (text: string) => void;
|
|
27
|
+
errOut?: (text: string) => void;
|
|
28
|
+
env?: NodeJS.ProcessEnv;
|
|
29
|
+
configDirPath?: string;
|
|
30
|
+
/** Defaults to the real terminal check — override in tests to exercise rich mode off a real TTY. */
|
|
31
|
+
stdoutIsTty?: boolean;
|
|
32
|
+
/** Raw (no trailing-newline-appending) writer for rich mode's \r-rewrite spinner frames — bypasses `out`'s line-per-call convention. Defaults to `process.stdout.write`. */
|
|
33
|
+
rawOut?: (text: string) => void;
|
|
34
|
+
/** Injectable clock for rich mode's per-event elapsed `(+N.Ns)` suffix. Defaults to `Date.now`. */
|
|
35
|
+
now?: () => number;
|
|
36
|
+
/** Defaults to the real terminal check — override in tests to exercise the interactive session off a real TTY. */
|
|
37
|
+
stdinIsTty?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Runs the interactive session for a bare `ora` invocation on a real
|
|
40
|
+
* terminal. Defaults to the real session (`interactive/session.js`'s
|
|
41
|
+
* `runSession`) wired with an `InquirerPrompter` — imported DYNAMICALLY
|
|
42
|
+
* inside the default (see resolveDeps) so program.ts carries no static
|
|
43
|
+
* import of `interactive/*`. session.ts statically imports
|
|
44
|
+
* core/run-operation.js and auth-commands.js (for runOperation/
|
|
45
|
+
* performLogin); a static edge back from here would be a cycle. Override in
|
|
46
|
+
* tests with a fake to drive the root action without a real terminal.
|
|
47
|
+
*/
|
|
48
|
+
session?: (deps: ResolvedDeps) => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface ResolvedDeps {
|
|
51
|
+
makeClient: NonNullable<ProgramDeps["makeClient"]>;
|
|
52
|
+
makeAuth: NonNullable<ProgramDeps["makeAuth"]>;
|
|
53
|
+
out: (text: string) => void;
|
|
54
|
+
errOut: (text: string) => void;
|
|
55
|
+
env: NodeJS.ProcessEnv;
|
|
56
|
+
dir: string;
|
|
57
|
+
stdoutIsTty: boolean;
|
|
58
|
+
rawOut: (text: string) => void;
|
|
59
|
+
now: () => number;
|
|
60
|
+
stdinIsTty: boolean;
|
|
61
|
+
session: (deps: ResolvedDeps) => Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export declare function cliVersion(): string;
|
|
64
|
+
/**
|
|
65
|
+
* The real entrypoint's (index.ts) last line of defense around parseAsync.
|
|
66
|
+
* Every commander-driven exit already passes through buildProgram's own
|
|
67
|
+
* exitOverride below, which sets process.exitCode correctly (0 for
|
|
68
|
+
* help/version, 2 for a usage error) before rethrowing — for the WHOLE
|
|
69
|
+
* command tree, since commander propagates exitOverride into every
|
|
70
|
+
* subcommand. So `current` is normally already set by the time this runs.
|
|
71
|
+
* `?? 2`, not `|| 2`, is load-bearing: an already-set 0 (help/version) must
|
|
72
|
+
* survive; `0 || 2` would wrongly clobber it to 2. Only a throw that never
|
|
73
|
+
* reached exitOverride (current genuinely undefined) falls back to 2.
|
|
74
|
+
*
|
|
75
|
+
* Typed against `NodeJS.Process["exitCode"]` (not a hand-narrowed
|
|
76
|
+
* `number | undefined`) so it accepts `process.exitCode` as-is — Node
|
|
77
|
+
* types that setter as `number | string | null | undefined`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function entryExitCode(current: NodeJS.Process["exitCode"]): NodeJS.Process["exitCode"];
|
|
80
|
+
export declare function buildProgram(depsIn?: ProgramDeps): Command;
|
|
81
|
+
//# sourceMappingURL=program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AASjD,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,CAAC,IAAI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AAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAiCD,wBAAgB,UAAU,IAAI,MAAM,CAOnC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAE7F;AAED,wBAAgB,YAAY,CAAC,MAAM,GAAE,WAAgB,GAAG,OAAO,CAwD9D"}
|
package/dist/program.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commander program. ONE registrar walks the generated OPERATIONS
|
|
3
|
+
* manifest and builds every command (a data Registry — adding a public op to
|
|
4
|
+
* the platform changes the generated manifest, never this file), plus the
|
|
5
|
+
* three handwritten auth commands: login / logout / whoami (auth-commands.ts).
|
|
6
|
+
* The manifest-op execution core (credentials, path/query/body derivation,
|
|
7
|
+
* runOperation) lives in core/run-operation.ts — this file only wires
|
|
8
|
+
* commander around it.
|
|
9
|
+
*
|
|
10
|
+
* Every seam (client, auth, io, env, config dir) is injectable via
|
|
11
|
+
* ProgramDeps so tests drive the program through parseAsync — the same door a
|
|
12
|
+
* user uses.
|
|
13
|
+
*/
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import { Command } from "commander";
|
|
16
|
+
import { ApiKeyAuth } from "./core/auth.js";
|
|
17
|
+
import { configDir } from "./core/config.js";
|
|
18
|
+
import { HttpClient as RealHttpClient } from "./core/http.js";
|
|
19
|
+
import { attachTunnelCommand } from "./tunnel-command.js";
|
|
20
|
+
import { buildQuery, readBody, runOperation } from "./core/run-operation.js";
|
|
21
|
+
import { renderError } from "./core/output.js";
|
|
22
|
+
import { attachLogin, attachLogout, attachWhoami } from "./auth-commands.js";
|
|
23
|
+
import { OPERATIONS, SPEC } from "./generated/operations.js";
|
|
24
|
+
import { helpEpilog } from "./watch.js";
|
|
25
|
+
function resolveDeps(deps) {
|
|
26
|
+
const dir = deps.configDirPath ?? configDir(deps.env ?? process.env);
|
|
27
|
+
return {
|
|
28
|
+
makeClient: deps.makeClient ??
|
|
29
|
+
(({ apiUrl, apiKey }) => new RealHttpClient({ apiUrl, auth: new ApiKeyAuth({ apiUrl, apiKey, dir }) })),
|
|
30
|
+
makeAuth: deps.makeAuth ?? (({ apiUrl, apiKey }) => new ApiKeyAuth({ apiUrl, apiKey, dir })),
|
|
31
|
+
out: deps.out ?? ((text) => process.stdout.write(`${text}\n`)),
|
|
32
|
+
errOut: deps.errOut ?? ((text) => process.stderr.write(`${text}\n`)),
|
|
33
|
+
env: deps.env ?? process.env,
|
|
34
|
+
dir,
|
|
35
|
+
stdoutIsTty: deps.stdoutIsTty ?? process.stdout.isTTY === true,
|
|
36
|
+
rawOut: deps.rawOut ?? ((text) => process.stdout.write(text)),
|
|
37
|
+
now: deps.now ?? Date.now,
|
|
38
|
+
stdinIsTty: deps.stdinIsTty ?? process.stdin.isTTY === true,
|
|
39
|
+
session: deps.session ??
|
|
40
|
+
(async (resolved) => {
|
|
41
|
+
// Dynamic — NOT a static top-of-file import: session.ts statically
|
|
42
|
+
// imports core/run-operation.js (runOperation) and auth-commands.js
|
|
43
|
+
// (performLogin), so a static import the other way would be a
|
|
44
|
+
// require cycle. See ProgramDeps.session's doc comment.
|
|
45
|
+
const [{ runSession }, { InquirerPrompter }] = await Promise.all([
|
|
46
|
+
import("./interactive/session.js"),
|
|
47
|
+
import("./interactive/inquirer-prompter.js"),
|
|
48
|
+
]);
|
|
49
|
+
await runSession({ prompter: new InquirerPrompter(), deps: resolved });
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function cliVersion() {
|
|
54
|
+
try {
|
|
55
|
+
const pkg = createRequire(import.meta.url)("../package.json");
|
|
56
|
+
return pkg.version ?? "0.0.0-unknown";
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return "0.0.0-unknown";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The real entrypoint's (index.ts) last line of defense around parseAsync.
|
|
64
|
+
* Every commander-driven exit already passes through buildProgram's own
|
|
65
|
+
* exitOverride below, which sets process.exitCode correctly (0 for
|
|
66
|
+
* help/version, 2 for a usage error) before rethrowing — for the WHOLE
|
|
67
|
+
* command tree, since commander propagates exitOverride into every
|
|
68
|
+
* subcommand. So `current` is normally already set by the time this runs.
|
|
69
|
+
* `?? 2`, not `|| 2`, is load-bearing: an already-set 0 (help/version) must
|
|
70
|
+
* survive; `0 || 2` would wrongly clobber it to 2. Only a throw that never
|
|
71
|
+
* reached exitOverride (current genuinely undefined) falls back to 2.
|
|
72
|
+
*
|
|
73
|
+
* Typed against `NodeJS.Process["exitCode"]` (not a hand-narrowed
|
|
74
|
+
* `number | undefined`) so it accepts `process.exitCode` as-is — Node
|
|
75
|
+
* types that setter as `number | string | null | undefined`.
|
|
76
|
+
*/
|
|
77
|
+
export function entryExitCode(current) {
|
|
78
|
+
return current ?? 2;
|
|
79
|
+
}
|
|
80
|
+
export function buildProgram(depsIn = {}) {
|
|
81
|
+
const deps = resolveDeps(depsIn);
|
|
82
|
+
const program = new Command();
|
|
83
|
+
program
|
|
84
|
+
.name(SPEC.bin)
|
|
85
|
+
.description("ora CLI — the ora public API from your terminal")
|
|
86
|
+
.version(`${cliVersion()} (spec ${SPEC.version}, ${SPEC.contentHash.slice(0, 8)})`)
|
|
87
|
+
.configureOutput({
|
|
88
|
+
writeOut: (str) => deps.out(str.replace(/\n$/, "")),
|
|
89
|
+
writeErr: (str) => deps.errOut(str.replace(/\n$/, "")),
|
|
90
|
+
});
|
|
91
|
+
program.exitOverride((err) => {
|
|
92
|
+
process.exitCode = err.exitCode === 0 ? 0 : 2;
|
|
93
|
+
throw err;
|
|
94
|
+
});
|
|
95
|
+
// Bare `ora`, no subcommand: on a real terminal (both stdin and stdout are
|
|
96
|
+
// a tty) open the interactive session; piped/scripted, fall back to
|
|
97
|
+
// today's help-on-no-command output.
|
|
98
|
+
program.action(async () => {
|
|
99
|
+
if (!(deps.stdinIsTty && deps.stdoutIsTty)) {
|
|
100
|
+
program.outputHelp();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
await deps.session(deps);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
// Every other path in this file renders a caught error the same way
|
|
108
|
+
// (renderError + errOut + exitCode 1) instead of letting it propagate
|
|
109
|
+
// to index.ts's blanket catch, which prints nothing. runSession
|
|
110
|
+
// re-throws anything that isn't a PromptAborted (Ctrl+C) — e.g. the
|
|
111
|
+
// default session wiring's dynamic import() rejecting — so this path
|
|
112
|
+
// needs the same treatment.
|
|
113
|
+
deps.errOut(renderError(err));
|
|
114
|
+
process.exitCode = 1;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// Registering a root action flips commander's own heuristic for the
|
|
118
|
+
// implicit `help [command]` subcommand off (it only auto-adds one when the
|
|
119
|
+
// root has no action handler — see commander's `_getHelpCommand`), which
|
|
120
|
+
// would silently drop the `help [command]` line from this exact help text.
|
|
121
|
+
// Force it back on so piped bare `ora`'s help output stays byte-identical
|
|
122
|
+
// to before this action existed.
|
|
123
|
+
program.helpCommand(true);
|
|
124
|
+
attachLogin(program, deps);
|
|
125
|
+
attachLogout(program, deps);
|
|
126
|
+
attachWhoami(program, deps);
|
|
127
|
+
for (const meta of OPERATIONS)
|
|
128
|
+
attachOperation(program, meta, deps);
|
|
129
|
+
// The hand-written live data plane (`ora tunnel <port>`) — the ngrok-style
|
|
130
|
+
// companion to the generated `ora tunnels …` ledger CRUD.
|
|
131
|
+
attachTunnelCommand(program, deps);
|
|
132
|
+
return program;
|
|
133
|
+
}
|
|
134
|
+
function attachOperation(program, meta, deps) {
|
|
135
|
+
let node = program;
|
|
136
|
+
for (const seg of meta.commandPath.slice(0, -1)) {
|
|
137
|
+
node = node.commands.find((c) => c.name() === seg) ?? node.command(seg).description(`${seg} commands`);
|
|
138
|
+
}
|
|
139
|
+
const leaf = node.command(meta.commandPath.at(-1) ?? meta.id).description(meta.summary);
|
|
140
|
+
for (const p of meta.pathParams)
|
|
141
|
+
leaf.argument(`<${p.name}>`, `${p.name} path parameter`);
|
|
142
|
+
for (const q of meta.queryParams) {
|
|
143
|
+
const spec = q.kind === "boolean" ? `--${q.flag}` : `--${q.flag} <value>`;
|
|
144
|
+
leaf.option(spec, q.description ?? `${q.name} query parameter`);
|
|
145
|
+
}
|
|
146
|
+
if (meta.hasBody) {
|
|
147
|
+
leaf.option("--file <path>", `JSON request body file, or "-" for stdin${meta.bodyRequired ? " (required)" : ""}`);
|
|
148
|
+
}
|
|
149
|
+
leaf.option("--json", "print the raw JSON response");
|
|
150
|
+
leaf.option("--plain", "force plain non-visual output");
|
|
151
|
+
leaf.option("--api-url <url>", "override the API base URL");
|
|
152
|
+
if (meta.watchable) {
|
|
153
|
+
leaf.option("-w, --watch", "after the call, stream the created resource's live events (server-provided streamUrl) until the stream closes");
|
|
154
|
+
}
|
|
155
|
+
leaf.addHelpText("after", helpEpilog(meta));
|
|
156
|
+
leaf.action(async (...actionArgs) => {
|
|
157
|
+
const positionals = actionArgs.slice(0, meta.pathParams.length);
|
|
158
|
+
const opts = leaf.opts();
|
|
159
|
+
let body;
|
|
160
|
+
if (meta.hasBody) {
|
|
161
|
+
const r = readBody(opts.file, meta, deps);
|
|
162
|
+
if (r.kind === "error")
|
|
163
|
+
return; // readBody already reported + set exitCode
|
|
164
|
+
body = r.body;
|
|
165
|
+
}
|
|
166
|
+
const values = {
|
|
167
|
+
positionals,
|
|
168
|
+
query: buildQuery(meta, opts),
|
|
169
|
+
body,
|
|
170
|
+
json: Boolean(opts.json),
|
|
171
|
+
plain: Boolean(opts.plain),
|
|
172
|
+
watch: Boolean(opts.watch),
|
|
173
|
+
apiUrlFlag: opts.apiUrl,
|
|
174
|
+
};
|
|
175
|
+
await runOperation(meta, values, deps);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAkB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,IAAI,EAAsB,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA4CxC,SAAS,WAAW,CAAC,IAAiB;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE,OAAO;QACL,UAAU,EACR,IAAI,CAAC,UAAU;YACf,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CA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I;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACxB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAC1B,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAC1B,UAAU,EAAE,IAAI,CAAC,MAA4B;SAC9C,CAAC;QACF,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal-text helpers for the journey graph (ported from the standalone
|
|
3
|
+
* eralabs-ai/ora-cli renderer). All width math operates on PLAIN strings;
|
|
4
|
+
* color is applied to whole lines only, after wrapping, so ANSI escapes never
|
|
5
|
+
* skew column calculations.
|
|
6
|
+
*/
|
|
7
|
+
/** Current stdout width clamped into [lo, hi]; 100 when not a terminal. */
|
|
8
|
+
export declare function stdoutWidth(lo: number, hi: number): number;
|
|
9
|
+
/** Collapse runs of whitespace and cap at `max` chars with a trailing ellipsis. */
|
|
10
|
+
export declare function squeeze(value: string, max: number): string;
|
|
11
|
+
/** Greedy word wrap (no hard-breaking); collapses whitespace first. */
|
|
12
|
+
export declare function flow(value: string, max: number): string[];
|
|
13
|
+
//# sourceMappingURL=ansi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../../src/render/ansi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,uEAAuE;AACvE,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAazD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal-text helpers for the journey graph (ported from the standalone
|
|
3
|
+
* eralabs-ai/ora-cli renderer). All width math operates on PLAIN strings;
|
|
4
|
+
* color is applied to whole lines only, after wrapping, so ANSI escapes never
|
|
5
|
+
* skew column calculations.
|
|
6
|
+
*/
|
|
7
|
+
/** Current stdout width clamped into [lo, hi]; 100 when not a terminal. */
|
|
8
|
+
export function stdoutWidth(lo, hi) {
|
|
9
|
+
const cols = process.stdout.columns ?? 100;
|
|
10
|
+
return Math.min(hi, Math.max(lo, cols));
|
|
11
|
+
}
|
|
12
|
+
/** Collapse runs of whitespace and cap at `max` chars with a trailing ellipsis. */
|
|
13
|
+
export function squeeze(value, max) {
|
|
14
|
+
const flat = value.replace(/\s+/g, " ").trim();
|
|
15
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
16
|
+
}
|
|
17
|
+
/** Greedy word wrap (no hard-breaking); collapses whitespace first. */
|
|
18
|
+
export function flow(value, max) {
|
|
19
|
+
const out = [];
|
|
20
|
+
let current = "";
|
|
21
|
+
for (const word of value.replace(/\s+/g, " ").trim().split(" ")) {
|
|
22
|
+
if (current && current.length + 1 + word.length > max) {
|
|
23
|
+
out.push(current);
|
|
24
|
+
current = word;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
current = current ? `${current} ${word}` : word;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (current)
|
|
31
|
+
out.push(current);
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ansi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../../src/render/ansi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE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CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ORA session head — a compact logotype + version line, printed once when
|
|
3
|
+
* the interactive session opens. Block glyphs only (no external art assets),
|
|
4
|
+
* accent-tinted so it reads in light and dark terminals alike.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bannerLines(version: string, apiUrl?: string): string[];
|
|
7
|
+
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/render/banner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ORA session head — a compact logotype + version line, printed once when
|
|
3
|
+
* the interactive session opens. Block glyphs only (no external art assets),
|
|
4
|
+
* accent-tinted so it reads in light and dark terminals alike.
|
|
5
|
+
*/
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { SPEC } from "../generated/operations.js";
|
|
8
|
+
const MARK = ["█▀█ █▀█ ▄▀█", "█▄█ █▀▄ █▀█"];
|
|
9
|
+
export function bannerLines(version, apiUrl) {
|
|
10
|
+
const meta = [`v${version}`, `spec ${SPEC.version}`, ...(apiUrl ? [apiUrl] : [])];
|
|
11
|
+
return [
|
|
12
|
+
"",
|
|
13
|
+
` ${chalk.cyan(MARK[0])}`,
|
|
14
|
+
` ${chalk.cyan(MARK[1])} ${chalk.dim(meta.join(" · "))}`,
|
|
15
|
+
"",
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/render/banner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAE5C,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,MAAe;IAC1D,MAAM,IAAI,GAAG,CAAC,IAAI,OAAO,EAAE,EAAE,QAAQ,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClF,OAAO;QACL,EAAE;QACF,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1B,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;QAC7D,EAAE;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of the CLI's rich-mode visual language: the brand accent
|
|
3
|
+
* color and the glyph set Task 6's renderers draw event streams with.
|
|
4
|
+
*
|
|
5
|
+
* The accent purple (#7C3AED) matches the internal dev CLI's brand color
|
|
6
|
+
* (utils/ora-dev-cli/src/lib/ui) — same company, same look — but this module
|
|
7
|
+
* takes NONE of that CLI's dependencies (figlet, inquirer, npm's `ora`
|
|
8
|
+
* spinner package): chalk is enough for a hex color and a \r-rewrite.
|
|
9
|
+
*/
|
|
10
|
+
export declare const accent: import("chalk").ChalkInstance;
|
|
11
|
+
export declare const GLYPHS: {
|
|
12
|
+
thought: string;
|
|
13
|
+
tool: string;
|
|
14
|
+
ok: string;
|
|
15
|
+
error: string;
|
|
16
|
+
stageDone: string;
|
|
17
|
+
stageRunning: string;
|
|
18
|
+
stagePending: string;
|
|
19
|
+
};
|
|
20
|
+
/** Maps a stream/event kind (step/trajectory/result/insight/run) to its glyph. */
|
|
21
|
+
export declare function eventGlyph(event: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Maps a run/agent lifecycle STATUS to its glyph, distinguishing success from
|
|
24
|
+
* failure — run-list.ts's status column. Shared here (not duplicated in
|
|
25
|
+
* run-list.ts) because journey.ts needs the SAME "is this terminal/running/
|
|
26
|
+
* pending" reading, just without the success/failure split (see
|
|
27
|
+
* `progressGlyph` below). An unrecognized status degrades to `stagePending`
|
|
28
|
+
* rather than throwing — a CLI must never crash on a value it doesn't know
|
|
29
|
+
* about yet.
|
|
30
|
+
*/
|
|
31
|
+
export declare function outcomeGlyph(status: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Maps a journey stage's (agent run's) status to its PROGRESS marker only —
|
|
34
|
+
* done vs running vs not-started, never success vs failure: a journey stage
|
|
35
|
+
* marker answers "did this agent finish", and the outcome (succeeded/failed)
|
|
36
|
+
* is printed alongside the marker, not folded into it. See journey.ts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function progressGlyph(status: string): string;
|
|
39
|
+
//# sourceMappingURL=glyphs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphs.d.ts","sourceRoot":"","sources":["../../src/render/glyphs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,MAAM,+BAAuB,CAAC;AAE3C,eAAO,MAAM,MAAM,EAAE;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CAStB,CAAC;AAEF,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAehD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAenD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAapD"}
|