@ora-ai/cli 0.12.0 → 0.13.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/README.md +61 -1
- package/dist/agent-skills/cli-version.d.ts +2 -0
- package/dist/agent-skills/cli-version.d.ts.map +1 -0
- package/dist/agent-skills/cli-version.js +14 -0
- package/dist/agent-skills/cli-version.js.map +1 -0
- package/dist/agent-skills/install-targets.d.ts +14 -0
- package/dist/agent-skills/install-targets.d.ts.map +1 -0
- package/dist/agent-skills/install-targets.js +20 -0
- package/dist/agent-skills/install-targets.js.map +1 -0
- package/dist/agent-skills/installer.d.ts +9 -0
- package/dist/agent-skills/installer.d.ts.map +1 -0
- package/dist/agent-skills/installer.js +15 -0
- package/dist/agent-skills/installer.js.map +1 -0
- package/dist/agent-skills/skills-command.d.ts +5 -0
- package/dist/agent-skills/skills-command.d.ts.map +1 -0
- package/dist/agent-skills/skills-command.js +39 -0
- package/dist/agent-skills/skills-command.js.map +1 -0
- package/dist/agent-skills/studio-skill-source.d.ts +22 -0
- package/dist/agent-skills/studio-skill-source.d.ts.map +1 -0
- package/dist/agent-skills/studio-skill-source.js +15 -0
- package/dist/agent-skills/studio-skill-source.js.map +1 -0
- package/dist/auth-commands.d.ts.map +1 -1
- package/dist/auth-commands.js +3 -2
- package/dist/auth-commands.js.map +1 -1
- package/dist/coalesced-read.d.ts +12 -0
- package/dist/coalesced-read.d.ts.map +1 -0
- package/dist/coalesced-read.js +34 -0
- package/dist/coalesced-read.js.map +1 -0
- package/dist/core/error-envelope.d.ts +40 -0
- package/dist/core/error-envelope.d.ts.map +1 -0
- package/dist/core/error-envelope.js +69 -0
- package/dist/core/error-envelope.js.map +1 -0
- package/dist/core/http.d.ts +9 -2
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +19 -10
- package/dist/core/http.js.map +1 -1
- package/dist/core/output.d.ts +1 -0
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +27 -3
- package/dist/core/output.js.map +1 -1
- package/dist/core/run-operation.d.ts +4 -3
- package/dist/core/run-operation.d.ts.map +1 -1
- package/dist/core/run-operation.js +13 -10
- package/dist/core/run-operation.js.map +1 -1
- package/dist/generated/operations.d.ts +1 -1
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +633 -7
- package/dist/generated/operations.js.map +1 -1
- package/dist/generated/types.d.ts +755 -11
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generated/types.js +1 -1
- package/dist/measurement-watch.d.ts +3 -0
- package/dist/measurement-watch.d.ts.map +1 -0
- package/dist/measurement-watch.js +106 -0
- package/dist/measurement-watch.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +6 -1
- package/dist/program.js.map +1 -1
- package/dist/render/analytics/analytics-view.d.ts +3 -0
- package/dist/render/analytics/analytics-view.d.ts.map +1 -0
- package/dist/render/analytics/analytics-view.js +69 -0
- package/dist/render/analytics/analytics-view.js.map +1 -0
- package/dist/render/analytics/history-view.d.ts +3 -0
- package/dist/render/analytics/history-view.d.ts.map +1 -0
- package/dist/render/analytics/history-view.js +25 -0
- package/dist/render/analytics/history-view.js.map +1 -0
- package/dist/render/analytics/recent-view.d.ts +3 -0
- package/dist/render/analytics/recent-view.d.ts.map +1 -0
- package/dist/render/analytics/recent-view.js +22 -0
- package/dist/render/analytics/recent-view.js.map +1 -0
- package/dist/render/analytics/renderers.d.ts +4 -0
- package/dist/render/analytics/renderers.d.ts.map +1 -0
- package/dist/render/analytics/renderers.js +23 -0
- package/dist/render/analytics/renderers.js.map +1 -0
- package/dist/render/analytics/types.d.ts +73 -0
- package/dist/render/analytics/types.d.ts.map +1 -0
- package/dist/render/analytics/types.js +2 -0
- package/dist/render/analytics/types.js.map +1 -0
- package/dist/render/ansi.d.ts +1 -0
- package/dist/render/ansi.d.ts.map +1 -1
- package/dist/render/ansi.js +38 -0
- package/dist/render/ansi.js.map +1 -1
- package/dist/render/goal-report-criteria.d.ts +39 -0
- package/dist/render/goal-report-criteria.d.ts.map +1 -0
- package/dist/render/goal-report-criteria.js +74 -0
- package/dist/render/goal-report-criteria.js.map +1 -0
- package/dist/render/goal-report-grid.d.ts +24 -0
- package/dist/render/goal-report-grid.d.ts.map +1 -0
- package/dist/render/goal-report-grid.js +52 -0
- package/dist/render/goal-report-grid.js.map +1 -0
- package/dist/render/goal-report.d.ts +3 -0
- package/dist/render/goal-report.d.ts.map +1 -0
- package/dist/render/goal-report.js +69 -0
- package/dist/render/goal-report.js.map +1 -0
- package/dist/render/index.js +10 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/insight-lines.d.ts.map +1 -1
- package/dist/render/insight-lines.js +7 -8
- package/dist/render/insight-lines.js.map +1 -1
- package/dist/render/insight.d.ts +1 -1
- package/dist/render/insight.d.ts.map +1 -1
- package/dist/render/insight.js +4 -2
- package/dist/render/insight.js.map +1 -1
- package/dist/render/insights/answers-view.d.ts +6 -0
- package/dist/render/insights/answers-view.d.ts.map +1 -0
- package/dist/render/insights/answers-view.js +29 -0
- package/dist/render/insights/answers-view.js.map +1 -0
- package/dist/render/insights/change-view.d.ts +3 -0
- package/dist/render/insights/change-view.d.ts.map +1 -0
- package/dist/render/insights/change-view.js +52 -0
- package/dist/render/insights/change-view.js.map +1 -0
- package/dist/render/insights/issues-view.d.ts +3 -0
- package/dist/render/insights/issues-view.d.ts.map +1 -0
- package/dist/render/insights/issues-view.js +31 -0
- package/dist/render/insights/issues-view.js.map +1 -0
- package/dist/render/insights/renderer.d.ts +3 -0
- package/dist/render/insights/renderer.d.ts.map +1 -0
- package/dist/render/insights/renderer.js +40 -0
- package/dist/render/insights/renderer.js.map +1 -0
- package/dist/render/insights/text.d.ts +3 -0
- package/dist/render/insights/text.d.ts.map +1 -0
- package/dist/render/insights/text.js +6 -0
- package/dist/render/insights/text.js.map +1 -0
- package/dist/render/insights/tools-view.d.ts +4 -0
- package/dist/render/insights/tools-view.d.ts.map +1 -0
- package/dist/render/insights/tools-view.js +51 -0
- package/dist/render/insights/tools-view.js.map +1 -0
- package/dist/render/insights/types.d.ts +124 -0
- package/dist/render/insights/types.d.ts.map +1 -0
- package/dist/render/insights/types.js +2 -0
- package/dist/render/insights/types.js.map +1 -0
- package/dist/render/insights/usage-view.d.ts +3 -0
- package/dist/render/insights/usage-view.d.ts.map +1 -0
- package/dist/render/insights/usage-view.js +18 -0
- package/dist/render/insights/usage-view.js.map +1 -0
- package/dist/render/insights/words.d.ts +4 -0
- package/dist/render/insights/words.d.ts.map +1 -0
- package/dist/render/insights/words.js +24 -0
- package/dist/render/insights/words.js.map +1 -0
- package/dist/render/links.d.ts +3 -0
- package/dist/render/links.d.ts.map +1 -0
- package/dist/render/links.js +5 -0
- package/dist/render/links.js.map +1 -0
- package/dist/render/live-panel.d.ts +2 -0
- package/dist/render/live-panel.d.ts.map +1 -1
- package/dist/render/live-panel.js +8 -8
- package/dist/render/live-panel.js.map +1 -1
- package/dist/render/measurement/measure-launch-view.d.ts +20 -0
- package/dist/render/measurement/measure-launch-view.d.ts.map +1 -0
- package/dist/render/measurement/measure-launch-view.js +31 -0
- package/dist/render/measurement/measure-launch-view.js.map +1 -0
- package/dist/render/measurement/measure-status-view.d.ts +35 -0
- package/dist/render/measurement/measure-status-view.d.ts.map +1 -0
- package/dist/render/measurement/measure-status-view.js +105 -0
- package/dist/render/measurement/measure-status-view.js.map +1 -0
- package/dist/render/measurement/renderers.d.ts +4 -0
- package/dist/render/measurement/renderers.d.ts.map +1 -0
- package/dist/render/measurement/renderers.js +14 -0
- package/dist/render/measurement/renderers.js.map +1 -0
- package/dist/render/meter.d.ts +2 -0
- package/dist/render/meter.d.ts.map +1 -0
- package/dist/render/meter.js +6 -0
- package/dist/render/meter.js.map +1 -0
- package/dist/render/palette.d.ts +23 -0
- package/dist/render/palette.d.ts.map +1 -0
- package/dist/render/palette.js +24 -0
- package/dist/render/palette.js.map +1 -0
- package/dist/render/payload.d.ts +3 -0
- package/dist/render/payload.d.ts.map +1 -0
- package/dist/render/payload.js +8 -0
- package/dist/render/payload.js.map +1 -0
- package/dist/watch.d.ts.map +1 -1
- package/dist/watch.js +3 -1
- package/dist/watch.js.map +1 -1
- package/dist/watchers.d.ts +15 -0
- package/dist/watchers.d.ts.map +1 -0
- package/dist/watchers.js +8 -0
- package/dist/watchers.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,6 +152,38 @@ After a run completes, read its artifacts:
|
|
|
152
152
|
ora intents measurements-status # are the daily measurements running?
|
|
153
153
|
ora intents measurements-pause-all # stop the scans
|
|
154
154
|
ora intents measurements-resume-all # restart them
|
|
155
|
+
echo '{}' | ora intents measure <intent-id> --file - --watch # measure now and follow it live until it finishes
|
|
156
|
+
ora intents measure-status <intent-id> <measurement-id> --watch # each prompt × agent run, live; done: true once every run is analyzed
|
|
157
|
+
ora intents stream <intent-id> # the raw live events (a `measurement` event when one finishes)
|
|
158
|
+
cat > schedule.json <<'EOF'
|
|
159
|
+
{ "cadence": "daily" }
|
|
160
|
+
EOF
|
|
161
|
+
ora intents measurement-policy <intent-id> --file schedule.json # daily | weekly | monthly | manual
|
|
162
|
+
|
|
163
|
+
### Goals — your own definition of a win, scored on every run (studio)
|
|
164
|
+
|
|
165
|
+
cat > goal.json <<'EOF'
|
|
166
|
+
{ "kind": "answer_check", "title": "Acme DB is the first pick", "criterionGroup": "choose",
|
|
167
|
+
"statement": "The answer recommends Acme DB as its first option for hosting the database." }
|
|
168
|
+
EOF
|
|
169
|
+
ora goals create <intent-id> --file goal.json
|
|
170
|
+
ora goals list <intent-id>
|
|
171
|
+
ora goals report <intent-id> --window 30d # answer score per question type, weakest checks, prompt × agent grid, Studio link
|
|
172
|
+
ora intents insights <intent-id> # what to fix: issues, pages that failed, MCP / API tool calls, what each agent said
|
|
173
|
+
ora intents analytics <intent-id> --window 30d # layers, positioning per question type, agents, brands, cited sources
|
|
174
|
+
ora intents history <intent-id> # each measurement, newest first, with its answer score
|
|
175
|
+
ora goals delete <goal-id> # deactivate (kept, no longer scored)
|
|
176
|
+
|
|
177
|
+
### Skills — teach your coding agent to use Studio
|
|
178
|
+
|
|
179
|
+
ora skills list # the skills your Studio account can install
|
|
180
|
+
ora skills add ora-studio # this project: .claude/skills (Claude Code) and .agents/skills (Codex and others)
|
|
181
|
+
ora skills add ora-studio --global # every project, in your home folder
|
|
182
|
+
|
|
183
|
+
`ora-studio` is the Studio playbook: define the objective, create the intent, define the win, measure,
|
|
184
|
+
read the results, improve, schedule, with a recipe per objective (be recommended, don't get steered
|
|
185
|
+
away, book a demo, MCP discovery, MCP usage). It comes from your Studio account, so it needs the same
|
|
186
|
+
API key as the other commands (scope `intents:read`).
|
|
155
187
|
|
|
156
188
|
### Sessions — long-lived agent environments
|
|
157
189
|
|
|
@@ -281,7 +313,23 @@ its own: to pick up where one left off, pass the last seq you saw:
|
|
|
281
313
|
**Scopes**: `autopilot:read` (lists, gets, streams), `autopilot:write`
|
|
282
314
|
(team setup, missions, messages, pause/resume/stop), and
|
|
283
315
|
`autopilot:export:write` for `ora autopilot exports …` — a dataset export is
|
|
284
|
-
bulk data egress, so a read-only key cannot run it.
|
|
316
|
+
bulk data egress, so a read-only key cannot run it. Every command's `--help`
|
|
317
|
+
names the scope it needs. Grant the key the `experiment` product too (the
|
|
318
|
+
Autopilot scopes belong to it), and mint it as a person: Autopilot acts for
|
|
319
|
+
the key's creator, so a key whose creator has left the organization is
|
|
320
|
+
refused. A team file that binds a repo credential
|
|
321
|
+
(`resources.repos[].credential.secretRef`) also needs `secrets:bind` on the
|
|
322
|
+
key, and a key role other than Viewer: it attaches an org secret by reference
|
|
323
|
+
and no route returns its value — but the workload it is bound to can read it
|
|
324
|
+
(keys minted before `secrets:bind` existed hold `secrets:reveal`, which still
|
|
325
|
+
works). The same rule covers every other binding: an add-on's secret on
|
|
326
|
+
`ora experiment runs create`, a session or a study, and an MCP server's
|
|
327
|
+
`secretId`. A person needs any organization role except Viewer to bind.
|
|
328
|
+
|
|
329
|
+
An export is a manifest plus a signed `artifactUrl` that lives 15 minutes;
|
|
330
|
+
fetch the dataset with any HTTP client:
|
|
331
|
+
|
|
332
|
+
curl -o dataset.tar "$(ora autopilot exports get billing-crew <export-id> --json | jq -r .artifactUrl)"
|
|
285
333
|
|
|
286
334
|
### Scripting
|
|
287
335
|
|
|
@@ -289,6 +337,15 @@ bulk data egress, so a read-only key cannot run it.
|
|
|
289
337
|
create response first, then one line per event). Exit codes: 0 ok, 1 API/auth
|
|
290
338
|
error, 2 usage error.
|
|
291
339
|
|
|
340
|
+
With `--json`, a failure is JSON too: the API's error body, as sent, on one
|
|
341
|
+
stderr line — `{error, code, details}`, the fields a client generated from the
|
|
342
|
+
public API reads. An Autopilot refusal names its wave and blocker there. A
|
|
343
|
+
failure the API did not answer in JSON (no key, an unreadable `--file`, a
|
|
344
|
+
refused key exchange) prints `{error, code}`:
|
|
345
|
+
|
|
346
|
+
ora autopilot members add billing-crew --file member.json --json 2> err.json \
|
|
347
|
+
|| jq -r '.code, .details.issues[0].refusal.wave' err.json
|
|
348
|
+
|
|
292
349
|
id=$(ora experiment runs create --file run.json --json | jq -r .runId)
|
|
293
350
|
ora experiment runs stream "$id" --json | jq -c 'select(.event == "step")'
|
|
294
351
|
|
|
@@ -297,6 +354,9 @@ error, 2 usage error.
|
|
|
297
354
|
In CI, export `ORA_API_KEY` instead of logging in. Point at another
|
|
298
355
|
environment with `ORA_API_URL` or `--api-url`.
|
|
299
356
|
|
|
357
|
+
Studio views are drawn in Ora cream on a dark terminal and in Ora ink on a light one, read from
|
|
358
|
+
the terminal's `COLORFGBG`. Set `ORA_THEME=light` or `ORA_THEME=dark` when your terminal does not report it.
|
|
359
|
+
|
|
300
360
|
## Errors that explain themselves
|
|
301
361
|
|
|
302
362
|
- **402** — a plan limit was hit; the message names the dimension and where to upgrade.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-version.d.ts","sourceRoot":"","sources":["../../src/agent-skills/cli-version.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAS1E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const RELEASE = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
2
|
+
export function olderThan(current, minimum) {
|
|
3
|
+
const have = RELEASE.exec(current);
|
|
4
|
+
const need = minimum ? RELEASE.exec(minimum) : null;
|
|
5
|
+
if (!have || !need)
|
|
6
|
+
return false;
|
|
7
|
+
for (let i = 1; i <= 3; i++) {
|
|
8
|
+
const diff = Number(have[i]) - Number(need[i]);
|
|
9
|
+
if (diff !== 0)
|
|
10
|
+
return diff < 0;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cli-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-version.js","sourceRoot":"","sources":["../../src/agent-skills/cli-version.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC;AAExC,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,OAAsB;IAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface InstallScope {
|
|
2
|
+
readonly cwd: string;
|
|
3
|
+
readonly home: string;
|
|
4
|
+
readonly global: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface InstallTarget {
|
|
7
|
+
readonly key: string;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
skillsDir(scope: InstallScope): string;
|
|
10
|
+
}
|
|
11
|
+
export declare const INSTALL_TARGETS: readonly InstallTarget[];
|
|
12
|
+
export declare const DEFAULT_TARGET_KEYS: readonly string[];
|
|
13
|
+
export declare function resolveTargets(keys: readonly string[]): InstallTarget[];
|
|
14
|
+
//# sourceMappingURL=install-targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-targets.d.ts","sourceRoot":"","sources":["../../src/agent-skills/install-targets.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC;CACxC;AAQD,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAGnD,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAgD,CAAC;AAElG,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,EAAE,CAMvE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
const agentFolder = (key, label, folder) => ({
|
|
3
|
+
key,
|
|
4
|
+
label,
|
|
5
|
+
skillsDir: (scope) => join(scope.global ? scope.home : scope.cwd, folder, "skills"),
|
|
6
|
+
});
|
|
7
|
+
export const INSTALL_TARGETS = [
|
|
8
|
+
agentFolder("claude", "Claude Code", ".claude"),
|
|
9
|
+
agentFolder("agents", "Codex, Gemini CLI and other agents", ".agents"),
|
|
10
|
+
];
|
|
11
|
+
export const DEFAULT_TARGET_KEYS = INSTALL_TARGETS.map((target) => target.key);
|
|
12
|
+
export function resolveTargets(keys) {
|
|
13
|
+
return keys.map((key) => {
|
|
14
|
+
const target = INSTALL_TARGETS.find((t) => t.key === key);
|
|
15
|
+
if (!target)
|
|
16
|
+
throw new Error(`Unknown agent "${key}". Use one of: ${DEFAULT_TARGET_KEYS.join(", ")}.`);
|
|
17
|
+
return target;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=install-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-targets.js","sourceRoot":"","sources":["../../src/agent-skills/install-targets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAcjC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,MAAc,EAAiB,EAAE,CAAC,CAAC;IAClF,GAAG;IACH,KAAK;IACL,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC;CACpF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,SAAS,CAAC;IAC/C,WAAW,CAAC,QAAQ,EAAE,oCAAoC,EAAE,SAAS,CAAC;CACvE,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAsB,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElG,MAAM,UAAU,cAAc,CAAC,IAAuB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,kBAAkB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvG,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InstallScope, InstallTarget } from "./install-targets.js";
|
|
2
|
+
import type { SkillFile } from "./studio-skill-source.js";
|
|
3
|
+
export interface InstalledSkill {
|
|
4
|
+
readonly target: InstallTarget;
|
|
5
|
+
readonly dir: string;
|
|
6
|
+
readonly files: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function installSkill(name: string, files: readonly SkillFile[], targets: readonly InstallTarget[], scope: InstallScope): InstalledSkill[];
|
|
9
|
+
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/agent-skills/installer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,KAAK,EAAE,YAAY,GAClB,cAAc,EAAE,CAWlB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
export function installSkill(name, files, targets, scope) {
|
|
4
|
+
return targets.map((target) => {
|
|
5
|
+
const dir = join(target.skillsDir(scope), name);
|
|
6
|
+
rmSync(dir, { recursive: true, force: true });
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
const path = join(dir, file.path);
|
|
9
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
10
|
+
writeFileSync(path, file.content);
|
|
11
|
+
}
|
|
12
|
+
return { target, dir, files: files.length };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/agent-skills/installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAW1C,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,KAA2B,EAC3B,OAAiC,EACjC,KAAmB;IAEnB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ResolvedDeps } from "../program.js";
|
|
3
|
+
import { type ISkillSource } from "./studio-skill-source.js";
|
|
4
|
+
export declare function attachSkillsAdd(program: Command, deps: ResolvedDeps, version: string, sourceOf?: (client: ReturnType<ResolvedDeps["makeClient"]>) => ISkillSource): void;
|
|
5
|
+
//# sourceMappingURL=skills-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-command.d.ts","sourceRoot":"","sources":["../../src/agent-skills/skills-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAUhF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,KAAK,YAAwD,GACrH,IAAI,CA4BN"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { renderError } from "../core/output.js";
|
|
3
|
+
import { credentials } from "../core/run-operation.js";
|
|
4
|
+
import { olderThan } from "./cli-version.js";
|
|
5
|
+
import { DEFAULT_TARGET_KEYS, resolveTargets } from "./install-targets.js";
|
|
6
|
+
import { installSkill } from "./installer.js";
|
|
7
|
+
import { StudioSkillSource } from "./studio-skill-source.js";
|
|
8
|
+
const DEFAULT_SKILL = "ora-studio";
|
|
9
|
+
export function attachSkillsAdd(program, deps, version, sourceOf = (client) => new StudioSkillSource(client)) {
|
|
10
|
+
const group = program.commands.find((c) => c.name() === "skills") ?? program.command("skills").description("skills commands");
|
|
11
|
+
group
|
|
12
|
+
.command("add")
|
|
13
|
+
.description("Install an Ora skill into your coding agent's skills folder; the agent loads it when a task matches")
|
|
14
|
+
.argument("[name]", "the skill to install (ora skills list shows them)", DEFAULT_SKILL)
|
|
15
|
+
.option("--agent <names>", `the agents' folders, comma-separated: ${DEFAULT_TARGET_KEYS.join(", ")}`, DEFAULT_TARGET_KEYS.join(","))
|
|
16
|
+
.option("--global", "install for every project, in your home folder, instead of this project")
|
|
17
|
+
.option("--api-url <url>", "override the API base URL")
|
|
18
|
+
.action(async (name, opts) => {
|
|
19
|
+
const creds = credentials(deps, opts.apiUrl);
|
|
20
|
+
if (!creds)
|
|
21
|
+
return;
|
|
22
|
+
try {
|
|
23
|
+
const targets = resolveTargets(opts.agent.split(",").map((key) => key.trim()).filter(Boolean));
|
|
24
|
+
const skill = await sourceOf(deps.makeClient(creds)).get(name);
|
|
25
|
+
const scope = { cwd: process.cwd(), home: deps.env.HOME ?? homedir(), global: Boolean(opts.global) };
|
|
26
|
+
for (const done of installSkill(skill.name, skill.files, targets, scope)) {
|
|
27
|
+
deps.out(`Installed ${skill.name}${skill.version ? ` ${skill.version}` : ""} for ${done.target.label}: ${done.dir} (${done.files} files)`);
|
|
28
|
+
}
|
|
29
|
+
if (olderThan(version, skill.minCliVersion)) {
|
|
30
|
+
deps.errOut(`This skill needs the ora CLI ${skill.minCliVersion} or newer (you have ${version}). Update: npm install -g @ora-ai/cli`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
deps.errOut(renderError(err));
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=skills-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-command.js","sourceRoot":"","sources":["../../src/agent-skills/skills-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAEhF,MAAM,aAAa,GAAG,YAAY,CAAC;AAQnC,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,IAAkB,EAClB,OAAe,EACf,WAA6E,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC;IAEtH,MAAM,KAAK,GACT,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,QAAQ,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAClH,KAAK;SACF,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,qGAAqG,CAAC;SAClH,QAAQ,CAAC,QAAQ,EAAE,mDAAmD,EAAE,aAAa,CAAC;SACtF,MAAM,CA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,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC;YAC7I,CAAC;YACD,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC5C,IAAI,CAAC,MAAM,CAAC,gCAAgC,KAAK,CAAC,aAAa,uBAAuB,OAAO,uCAAuC,CAAC,CAAC;YACxI,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProgramDeps } from "../program.js";
|
|
2
|
+
export interface SkillFile {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FetchedSkill {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly version: string | null;
|
|
9
|
+
readonly minCliVersion: string | null;
|
|
10
|
+
readonly files: readonly SkillFile[];
|
|
11
|
+
}
|
|
12
|
+
export interface ISkillSource {
|
|
13
|
+
get(name: string): Promise<FetchedSkill>;
|
|
14
|
+
}
|
|
15
|
+
type Client = ReturnType<NonNullable<ProgramDeps["makeClient"]>>;
|
|
16
|
+
export declare class StudioSkillSource implements ISkillSource {
|
|
17
|
+
private readonly client;
|
|
18
|
+
constructor(client: Client);
|
|
19
|
+
get(name: string): Promise<FetchedSkill>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=studio-skill-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio-skill-source.d.ts","sourceRoot":"","sources":["../../src/agent-skills/studio-skill-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1C;AAED,KAAK,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAIjE,qBAAa,iBAAkB,YAAW,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAErC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAI/C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildPath } from "../core/run-operation.js";
|
|
2
|
+
import { OPERATIONS } from "../generated/operations.js";
|
|
3
|
+
const GET_SKILL = OPERATIONS.find((op) => op.id === "skills.get");
|
|
4
|
+
export class StudioSkillSource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async get(name) {
|
|
10
|
+
if (!GET_SKILL)
|
|
11
|
+
throw new Error("This CLI cannot fetch skills; update it with npm install -g @ora-ai/cli");
|
|
12
|
+
return (await this.client.call({ method: GET_SKILL.method, path: buildPath(GET_SKILL, [name]) }));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=studio-skill-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio-skill-source.js","sourceRoot":"","sources":["../../src/agent-skills/studio-skill-source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAoBxD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;AAElE,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;QAC3G,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAiB,CAAC;IACpH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BnH;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BnH;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAyBvH;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAWtE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASvE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAUvE"}
|
package/dist/auth-commands.js
CHANGED
|
@@ -56,7 +56,8 @@ export async function performLogin(deps, opts) {
|
|
|
56
56
|
* the same way.
|
|
57
57
|
*/
|
|
58
58
|
export async function performWhoami(deps, opts) {
|
|
59
|
-
const
|
|
59
|
+
const mode = opts.json ? "json" : undefined;
|
|
60
|
+
const creds = credentials(deps, opts.apiUrlFlag, mode);
|
|
60
61
|
if (!creds)
|
|
61
62
|
return false;
|
|
62
63
|
try {
|
|
@@ -75,7 +76,7 @@ export async function performWhoami(deps, opts) {
|
|
|
75
76
|
return true;
|
|
76
77
|
}
|
|
77
78
|
catch (err) {
|
|
78
|
-
deps.errOut(renderError(err));
|
|
79
|
+
deps.errOut(renderError(err, { mode }));
|
|
79
80
|
process.exitCode = 1;
|
|
80
81
|
return false;
|
|
81
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-commands.js","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGjD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAkB,EAAE,IAA0C;IAC/F,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC,CAAC,CAAC;QAC9G,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,aA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AAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC;QAC1E,MAAM,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAkB;IAC/D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,4CAA4C,CAAC;SACzD,WAAW,CAAC,OAAO,EAAE,2BAA2B,CAAC;SACjD,MAAM,CAAC,GAAG,EAAE;QACX,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAkB;IAC/D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,kEAAkE,CAAC;SAC/E,MAAM,CAAC,QAAQ,EAAE,4BAA4B,CAAC;SAC9C,MAAM,CAAC,iBAAiB,EAAE,2BAA2B,CAAC;SACtD,WAAW,CAAC,OAAO,EAAE,gDAAgD,CAAC;SACtE,MAAM,CAAC,KAAK,EAAE,IAAyC,EAAE,EAAE;QAC1D,MAAM,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CoalescedRead<T> {
|
|
2
|
+
private readonly read;
|
|
3
|
+
private readonly onValue;
|
|
4
|
+
private inFlight;
|
|
5
|
+
private pending;
|
|
6
|
+
private failure;
|
|
7
|
+
constructor(read: () => Promise<T>, onValue: (value: T) => void);
|
|
8
|
+
request(): void;
|
|
9
|
+
settled(): Promise<void>;
|
|
10
|
+
private drain;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=coalesced-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalesced-read.d.ts","sourceRoot":"","sources":["../src/coalesced-read.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa,CAAC,CAAC;IAMxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAiB;gBAGb,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI;IAG9C,OAAO,IAAI,IAAI;IAKT,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAKhB,KAAK;CAWpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class CoalescedRead {
|
|
2
|
+
read;
|
|
3
|
+
onValue;
|
|
4
|
+
inFlight = null;
|
|
5
|
+
pending = false;
|
|
6
|
+
failure = null;
|
|
7
|
+
constructor(read, onValue) {
|
|
8
|
+
this.read = read;
|
|
9
|
+
this.onValue = onValue;
|
|
10
|
+
}
|
|
11
|
+
request() {
|
|
12
|
+
this.pending = true;
|
|
13
|
+
if (!this.inFlight)
|
|
14
|
+
this.inFlight = this.drain();
|
|
15
|
+
}
|
|
16
|
+
async settled() {
|
|
17
|
+
await this.inFlight;
|
|
18
|
+
if (this.failure)
|
|
19
|
+
throw this.failure;
|
|
20
|
+
}
|
|
21
|
+
async drain() {
|
|
22
|
+
while (this.pending && !this.failure) {
|
|
23
|
+
this.pending = false;
|
|
24
|
+
try {
|
|
25
|
+
this.onValue(await this.read());
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
this.failure = err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.inFlight = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=coalesced-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalesced-read.js","sourceRoot":"","sources":["../src/coalesced-read.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IAML;IACA;IANX,QAAQ,GAAyB,IAAI,CAAC;IACtC,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAY,IAAI,CAAC;IAEhC,YACmB,IAAsB,EACtB,OAA2B;QAD3B,SAAI,GAAJ,IAAI,CAAkB;QACtB,YAAO,GAAP,OAAO,CAAoB;IAC3C,CAAC;IAEJ,OAAO;QACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,QAAQ,CAAC;QACpB,IAAI,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,CAAC,OAAO,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC;gBACH,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;YACrB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a non-ok response body into the ONE shape ApiError carries: a code, a
|
|
3
|
+
* human message, and every diagnostic the body held.
|
|
4
|
+
*
|
|
5
|
+
* Three spellings reach this CLI from the public API:
|
|
6
|
+
* - the house shape (`components.schemas.Error`, @ora/auth's guards):
|
|
7
|
+
* `{error: <message>, code: <CODE>, details?}`;
|
|
8
|
+
* - the code-first shape (Autopilot's published error body):
|
|
9
|
+
* `{error: <CODE>, message: <text>, details?}`;
|
|
10
|
+
* - the nested legacy shape (@ora/auth's requireRole and older handlers):
|
|
11
|
+
* `{success: false, error: {code, message, …}}`.
|
|
12
|
+
* Read as the house shape, the other two lose their code: a code-first body
|
|
13
|
+
* printed `API error 422 (HTTP_ERROR): HARNESS_NOT_DRIVEN` with its message
|
|
14
|
+
* demoted to a detail line, and a nested one printed `[object Object]`.
|
|
15
|
+
*
|
|
16
|
+
* One reader per spelling (Strategy); the first that recognizes a body wins and
|
|
17
|
+
* the house reader takes every other body, exactly as toApiError always did. A
|
|
18
|
+
* new spelling is one more reader, never an edit to toApiError.
|
|
19
|
+
*/
|
|
20
|
+
export interface ErrorEnvelope {
|
|
21
|
+
readonly code?: string;
|
|
22
|
+
readonly message?: string;
|
|
23
|
+
/** The body's `details` object, then every other field it carried (the renderer prints them all). */
|
|
24
|
+
readonly details: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface ErrorEnvelopeReader {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
matches(body: Record<string, unknown>): boolean;
|
|
29
|
+
read(body: Record<string, unknown>): ErrorEnvelope;
|
|
30
|
+
}
|
|
31
|
+
/** `{error: CODE, message, details?}`; a `code` that merely repeats `error` is the same body. */
|
|
32
|
+
export declare const codeFirstEnvelope: ErrorEnvelopeReader;
|
|
33
|
+
/** `{success: false, error: {code, message, …}}`: the nested object's other fields are its diagnostics. */
|
|
34
|
+
export declare const nestedEnvelope: ErrorEnvelopeReader;
|
|
35
|
+
/** `{error: <message>, code, details?}` — and the fallback for any body no other reader claims. */
|
|
36
|
+
export declare const houseEnvelope: ErrorEnvelopeReader;
|
|
37
|
+
/** First match wins; houseEnvelope matches every body, so it stays last. */
|
|
38
|
+
export declare const ERROR_ENVELOPE_READERS: readonly ErrorEnvelopeReader[];
|
|
39
|
+
export declare function readErrorEnvelope(body: unknown, readers?: readonly ErrorEnvelopeReader[]): ErrorEnvelope;
|
|
40
|
+
//# sourceMappingURL=error-envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-envelope.d.ts","sourceRoot":"","sources":["../../src/core/error-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAChD,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC;CACpD;AAqBD,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,EAAE,mBAS/B,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,cAAc,EAAE,mBAO5B,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,aAAa,EAAE,mBAI3B,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,EAAE,SAAS,mBAAmB,EAIhE,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,SAAS,mBAAmB,EAA2B,GAC/D,aAAa,CAGf"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a non-ok response body into the ONE shape ApiError carries: a code, a
|
|
3
|
+
* human message, and every diagnostic the body held.
|
|
4
|
+
*
|
|
5
|
+
* Three spellings reach this CLI from the public API:
|
|
6
|
+
* - the house shape (`components.schemas.Error`, @ora/auth's guards):
|
|
7
|
+
* `{error: <message>, code: <CODE>, details?}`;
|
|
8
|
+
* - the code-first shape (Autopilot's published error body):
|
|
9
|
+
* `{error: <CODE>, message: <text>, details?}`;
|
|
10
|
+
* - the nested legacy shape (@ora/auth's requireRole and older handlers):
|
|
11
|
+
* `{success: false, error: {code, message, …}}`.
|
|
12
|
+
* Read as the house shape, the other two lose their code: a code-first body
|
|
13
|
+
* printed `API error 422 (HTTP_ERROR): HARNESS_NOT_DRIVEN` with its message
|
|
14
|
+
* demoted to a detail line, and a nested one printed `[object Object]`.
|
|
15
|
+
*
|
|
16
|
+
* One reader per spelling (Strategy); the first that recognizes a body wins and
|
|
17
|
+
* the house reader takes every other body, exactly as toApiError always did. A
|
|
18
|
+
* new spelling is one more reader, never an edit to toApiError.
|
|
19
|
+
*/
|
|
20
|
+
/** A machine-readable code as the code-first shape spells it (`HARNESS_NOT_DRIVEN`), never prose. */
|
|
21
|
+
const CODE_TOKEN = /^[A-Z][A-Z0-9_]*$/;
|
|
22
|
+
function recordOf(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
24
|
+
? value
|
|
25
|
+
: undefined;
|
|
26
|
+
}
|
|
27
|
+
function str(value) {
|
|
28
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
29
|
+
}
|
|
30
|
+
function envelope(code, message, details) {
|
|
31
|
+
const c = str(code);
|
|
32
|
+
const m = str(message);
|
|
33
|
+
return { ...(c ? { code: c } : {}), ...(m ? { message: m } : {}), details };
|
|
34
|
+
}
|
|
35
|
+
/** `{error: CODE, message, details?}`; a `code` that merely repeats `error` is the same body. */
|
|
36
|
+
export const codeFirstEnvelope = {
|
|
37
|
+
name: "code-first",
|
|
38
|
+
matches: (body) => typeof body.error === "string" &&
|
|
39
|
+
CODE_TOKEN.test(body.error) &&
|
|
40
|
+
typeof body.message === "string" &&
|
|
41
|
+
(body.code === undefined || body.code === body.error),
|
|
42
|
+
read: ({ error, message, details, code: _repeated, ...extras }) => envelope(error, message, { ...recordOf(details), ...extras }),
|
|
43
|
+
};
|
|
44
|
+
/** `{success: false, error: {code, message, …}}`: the nested object's other fields are its diagnostics. */
|
|
45
|
+
export const nestedEnvelope = {
|
|
46
|
+
name: "nested",
|
|
47
|
+
matches: (body) => str(recordOf(body.error)?.code) !== undefined,
|
|
48
|
+
read: ({ error, success: _flag, details, ...extras }) => {
|
|
49
|
+
const { code, message, details: nestedDetails, ...fields } = recordOf(error) ?? {};
|
|
50
|
+
return envelope(code, message, { ...recordOf(nestedDetails), ...fields, ...recordOf(details), ...extras });
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/** `{error: <message>, code, details?}` — and the fallback for any body no other reader claims. */
|
|
54
|
+
export const houseEnvelope = {
|
|
55
|
+
name: "house",
|
|
56
|
+
matches: () => true,
|
|
57
|
+
read: ({ error, code, details, ...extras }) => envelope(code, error, { ...recordOf(details), ...extras }),
|
|
58
|
+
};
|
|
59
|
+
/** First match wins; houseEnvelope matches every body, so it stays last. */
|
|
60
|
+
export const ERROR_ENVELOPE_READERS = [
|
|
61
|
+
codeFirstEnvelope,
|
|
62
|
+
nestedEnvelope,
|
|
63
|
+
houseEnvelope,
|
|
64
|
+
];
|
|
65
|
+
export function readErrorEnvelope(body, readers = ERROR_ENVELOPE_READERS) {
|
|
66
|
+
const record = recordOf(body) ?? {};
|
|
67
|
+
return (readers.find((r) => r.matches(record)) ?? houseEnvelope).read(record);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=error-envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AG,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;CAC1G,CAAC;AAEF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAmC;IACpE,iBAAiB;IACjB,cAAc;IACd,aAAa;CACd,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAC/B,IAAa,EACb,UAA0C,sBAAsB;IAEhE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACpC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/core/http.d.ts
CHANGED
|
@@ -7,19 +7,26 @@
|
|
|
7
7
|
* the CLI's promise for mutations.
|
|
8
8
|
*
|
|
9
9
|
* Non-ok responses map to ApiError carrying the platform envelope
|
|
10
|
-
* {error, code, details?} so output.ts can tell the 402/403 stories
|
|
10
|
+
* {error, code, details?} so output.ts can tell the 402/403 stories — read
|
|
11
|
+
* through core/error-envelope.ts, which also accepts the code-first and
|
|
12
|
+
* nested spellings some services answer with.
|
|
11
13
|
*/
|
|
12
14
|
export declare class ApiError extends Error {
|
|
13
15
|
readonly status: number;
|
|
14
16
|
readonly code: string;
|
|
15
17
|
readonly details?: Record<string, unknown> | undefined;
|
|
16
|
-
|
|
18
|
+
/** The response body as the API sent it (parsed JSON, or {} when it was not JSON): what --json prints. */
|
|
19
|
+
readonly body?: unknown | undefined;
|
|
20
|
+
constructor(message: string, status: number, code: string, details?: Record<string, unknown> | undefined,
|
|
21
|
+
/** The response body as the API sent it (parsed JSON, or {} when it was not JSON): what --json prints. */
|
|
22
|
+
body?: unknown | undefined);
|
|
17
23
|
}
|
|
18
24
|
export interface CallOptions {
|
|
19
25
|
method: string;
|
|
20
26
|
path: string;
|
|
21
27
|
query?: Record<string, string | number | boolean | undefined>;
|
|
22
28
|
body?: unknown;
|
|
29
|
+
signal?: AbortSignal;
|
|
23
30
|
}
|
|
24
31
|
/** The narrow auth port — both members required so a fake-retry can't hide. */
|
|
25
32
|
export interface TokenSource {
|
package/dist/core/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,qBAAa,QAAS,SAAQ,KAAK;IAG/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1C,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;gBALvB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;IAC1C,0GAA0G;IACjG,IAAI,CAAC,EAAE,OAAO,YAAA;CAK1B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC;AA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