@ora-ai/cli 0.23.0 → 0.25.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.
Files changed (194) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +44 -13
  3. package/dist/agent-skills/skills-command.d.ts.map +1 -1
  4. package/dist/agent-skills/skills-command.js +2 -2
  5. package/dist/agent-skills/skills-command.js.map +1 -1
  6. package/dist/auth-commands.d.ts +25 -9
  7. package/dist/auth-commands.d.ts.map +1 -1
  8. package/dist/auth-commands.js +59 -49
  9. package/dist/auth-commands.js.map +1 -1
  10. package/dist/core/auth.d.ts +2 -2
  11. package/dist/core/auth.d.ts.map +1 -1
  12. package/dist/core/auth.js +5 -4
  13. package/dist/core/auth.js.map +1 -1
  14. package/dist/core/cli-arguments.d.ts +21 -0
  15. package/dist/core/cli-arguments.d.ts.map +1 -0
  16. package/dist/core/cli-arguments.js +53 -0
  17. package/dist/core/cli-arguments.js.map +1 -0
  18. package/dist/core/config.d.ts +10 -5
  19. package/dist/core/config.d.ts.map +1 -1
  20. package/dist/core/config.js +10 -7
  21. package/dist/core/config.js.map +1 -1
  22. package/dist/core/credentials/api-key-credential.d.ts +29 -0
  23. package/dist/core/credentials/api-key-credential.d.ts.map +1 -0
  24. package/dist/core/credentials/api-key-credential.js +58 -0
  25. package/dist/core/credentials/api-key-credential.js.map +1 -0
  26. package/dist/core/credentials/ci-oidc-credential.d.ts +44 -0
  27. package/dist/core/credentials/ci-oidc-credential.d.ts.map +1 -0
  28. package/dist/core/credentials/ci-oidc-credential.js +82 -0
  29. package/dist/core/credentials/ci-oidc-credential.js.map +1 -0
  30. package/dist/core/credentials/credential-chain.d.ts +25 -0
  31. package/dist/core/credentials/credential-chain.d.ts.map +1 -0
  32. package/dist/core/credentials/credential-chain.js +39 -0
  33. package/dist/core/credentials/credential-chain.js.map +1 -0
  34. package/dist/core/credentials/credential.d.ts +73 -0
  35. package/dist/core/credentials/credential.d.ts.map +1 -0
  36. package/dist/core/credentials/credential.js +9 -0
  37. package/dist/core/credentials/credential.js.map +1 -0
  38. package/dist/core/credentials/device-session-credential.d.ts +27 -0
  39. package/dist/core/credentials/device-session-credential.d.ts.map +1 -0
  40. package/dist/core/credentials/device-session-credential.js +78 -0
  41. package/dist/core/credentials/device-session-credential.js.map +1 -0
  42. package/dist/core/credentials/identity-lines.d.ts +14 -0
  43. package/dist/core/credentials/identity-lines.d.ts.map +1 -0
  44. package/dist/core/credentials/identity-lines.js +45 -0
  45. package/dist/core/credentials/identity-lines.js.map +1 -0
  46. package/dist/core/credentials/refusal-words.d.ts +15 -0
  47. package/dist/core/credentials/refusal-words.d.ts.map +1 -0
  48. package/dist/core/credentials/refusal-words.js +56 -0
  49. package/dist/core/credentials/refusal-words.js.map +1 -0
  50. package/dist/core/credentials/sign-in-areas.d.ts +18 -0
  51. package/dist/core/credentials/sign-in-areas.d.ts.map +1 -0
  52. package/dist/core/credentials/sign-in-areas.js +22 -0
  53. package/dist/core/credentials/sign-in-areas.js.map +1 -0
  54. package/dist/core/http.d.ts +10 -4
  55. package/dist/core/http.d.ts.map +1 -1
  56. package/dist/core/http.js +7 -5
  57. package/dist/core/http.js.map +1 -1
  58. package/dist/core/identity.d.ts +11 -0
  59. package/dist/core/identity.d.ts.map +1 -0
  60. package/dist/core/identity.js +21 -0
  61. package/dist/core/identity.js.map +1 -0
  62. package/dist/core/limit-story.d.ts +11 -0
  63. package/dist/core/limit-story.d.ts.map +1 -0
  64. package/dist/core/limit-story.js +16 -0
  65. package/dist/core/limit-story.js.map +1 -0
  66. package/dist/core/login.d.ts +5 -3
  67. package/dist/core/login.d.ts.map +1 -1
  68. package/dist/core/login.js +5 -3
  69. package/dist/core/login.js.map +1 -1
  70. package/dist/core/oauth/metadata.d.ts +24 -0
  71. package/dist/core/oauth/metadata.d.ts.map +1 -0
  72. package/dist/core/oauth/metadata.js +99 -0
  73. package/dist/core/oauth/metadata.js.map +1 -0
  74. package/dist/core/oauth/oauth-client.d.ts +70 -0
  75. package/dist/core/oauth/oauth-client.d.ts.map +1 -0
  76. package/dist/core/oauth/oauth-client.js +136 -0
  77. package/dist/core/oauth/oauth-client.js.map +1 -0
  78. package/dist/core/oauth/oauth-error.d.ts +18 -0
  79. package/dist/core/oauth/oauth-error.d.ts.map +1 -0
  80. package/dist/core/oauth/oauth-error.js +31 -0
  81. package/dist/core/oauth/oauth-error.js.map +1 -0
  82. package/dist/core/oauth/sign-in-error.d.ts +15 -0
  83. package/dist/core/oauth/sign-in-error.d.ts.map +1 -0
  84. package/dist/core/oauth/sign-in-error.js +21 -0
  85. package/dist/core/oauth/sign-in-error.js.map +1 -0
  86. package/dist/core/oauth/sign-in-target.d.ts +31 -0
  87. package/dist/core/oauth/sign-in-target.d.ts.map +1 -0
  88. package/dist/core/oauth/sign-in-target.js +44 -0
  89. package/dist/core/oauth/sign-in-target.js.map +1 -0
  90. package/dist/core/output.d.ts +14 -3
  91. package/dist/core/output.d.ts.map +1 -1
  92. package/dist/core/output.js +38 -38
  93. package/dist/core/output.js.map +1 -1
  94. package/dist/core/retry-after.d.ts +8 -0
  95. package/dist/core/retry-after.d.ts.map +1 -0
  96. package/dist/core/retry-after.js +18 -0
  97. package/dist/core/retry-after.js.map +1 -0
  98. package/dist/core/run-operation.d.ts +26 -10
  99. package/dist/core/run-operation.d.ts.map +1 -1
  100. package/dist/core/run-operation.js +40 -21
  101. package/dist/core/run-operation.js.map +1 -1
  102. package/dist/core/session/device-session-auth.d.ts +29 -0
  103. package/dist/core/session/device-session-auth.d.ts.map +1 -0
  104. package/dist/core/session/device-session-auth.js +92 -0
  105. package/dist/core/session/device-session-auth.js.map +1 -0
  106. package/dist/core/session/file-lock.d.ts +33 -0
  107. package/dist/core/session/file-lock.d.ts.map +1 -0
  108. package/dist/core/session/file-lock.js +145 -0
  109. package/dist/core/session/file-lock.js.map +1 -0
  110. package/dist/core/session/session-refusals.d.ts +22 -0
  111. package/dist/core/session/session-refusals.d.ts.map +1 -0
  112. package/dist/core/session/session-refusals.js +23 -0
  113. package/dist/core/session/session-refusals.js.map +1 -0
  114. package/dist/core/session/session-store.d.ts +53 -0
  115. package/dist/core/session/session-store.d.ts.map +1 -0
  116. package/dist/core/session/session-store.js +71 -0
  117. package/dist/core/session/session-store.js.map +1 -0
  118. package/dist/core/sign-in.d.ts +2 -2
  119. package/dist/core/sign-in.js +2 -2
  120. package/dist/core/token-expiry.d.ts +9 -0
  121. package/dist/core/token-expiry.d.ts.map +1 -0
  122. package/dist/core/token-expiry.js +11 -0
  123. package/dist/core/token-expiry.js.map +1 -0
  124. package/dist/core/url.d.ts +5 -0
  125. package/dist/core/url.d.ts.map +1 -0
  126. package/dist/core/url.js +17 -0
  127. package/dist/core/url.js.map +1 -0
  128. package/dist/generated/operations.d.ts +2 -1
  129. package/dist/generated/operations.d.ts.map +1 -1
  130. package/dist/generated/operations.js +32 -5
  131. package/dist/generated/operations.js.map +1 -1
  132. package/dist/generated/types.d.ts +584 -0
  133. package/dist/generated/types.d.ts.map +1 -1
  134. package/dist/generated/types.js +1 -1
  135. package/dist/interactive/menu.d.ts.map +1 -1
  136. package/dist/interactive/menu.js +4 -2
  137. package/dist/interactive/menu.js.map +1 -1
  138. package/dist/interactive/session.d.ts.map +1 -1
  139. package/dist/interactive/session.js +17 -8
  140. package/dist/interactive/session.js.map +1 -1
  141. package/dist/login/browser-opener.d.ts +20 -0
  142. package/dist/login/browser-opener.d.ts.map +1 -0
  143. package/dist/login/browser-opener.js +43 -0
  144. package/dist/login/browser-opener.js.map +1 -0
  145. package/dist/login/device-flow.d.ts +60 -0
  146. package/dist/login/device-flow.d.ts.map +1 -0
  147. package/dist/login/device-flow.js +98 -0
  148. package/dist/login/device-flow.js.map +1 -0
  149. package/dist/login/device-login.d.ts +27 -0
  150. package/dist/login/device-login.d.ts.map +1 -0
  151. package/dist/login/device-login.js +148 -0
  152. package/dist/login/device-login.js.map +1 -0
  153. package/dist/login/device-presenter.d.ts +24 -0
  154. package/dist/login/device-presenter.d.ts.map +1 -0
  155. package/dist/login/device-presenter.js +69 -0
  156. package/dist/login/device-presenter.js.map +1 -0
  157. package/dist/login/login-command.d.ts +14 -0
  158. package/dist/login/login-command.d.ts.map +1 -0
  159. package/dist/login/login-command.js +73 -0
  160. package/dist/login/login-command.js.map +1 -0
  161. package/dist/login/login-deps.d.ts +17 -0
  162. package/dist/login/login-deps.d.ts.map +1 -0
  163. package/dist/login/login-deps.js +18 -0
  164. package/dist/login/login-deps.js.map +1 -0
  165. package/dist/login/piped-input.d.ts +23 -0
  166. package/dist/login/piped-input.d.ts.map +1 -0
  167. package/dist/login/piped-input.js +36 -0
  168. package/dist/login/piped-input.js.map +1 -0
  169. package/dist/login/requested-scopes.d.ts +22 -0
  170. package/dist/login/requested-scopes.d.ts.map +1 -0
  171. package/dist/login/requested-scopes.js +43 -0
  172. package/dist/login/requested-scopes.js.map +1 -0
  173. package/dist/program.d.ts +16 -5
  174. package/dist/program.d.ts.map +1 -1
  175. package/dist/program.js +35 -10
  176. package/dist/program.js.map +1 -1
  177. package/dist/study-ci/ci-command.d.ts.map +1 -1
  178. package/dist/study-ci/ci-command.js +2 -2
  179. package/dist/study-ci/ci-command.js.map +1 -1
  180. package/dist/study-ci/ci-rehearse-command.d.ts.map +1 -1
  181. package/dist/study-ci/ci-rehearse-command.js +2 -2
  182. package/dist/study-ci/ci-rehearse-command.js.map +1 -1
  183. package/dist/tunnel/connection-end.d.ts +30 -0
  184. package/dist/tunnel/connection-end.d.ts.map +1 -0
  185. package/dist/tunnel/connection-end.js +29 -0
  186. package/dist/tunnel/connection-end.js.map +1 -0
  187. package/dist/tunnel-command.d.ts.map +1 -1
  188. package/dist/tunnel-command.js +24 -8
  189. package/dist/tunnel-command.js.map +1 -1
  190. package/package.json +3 -2
  191. package/dist/core/credential-sources.d.ts +0 -45
  192. package/dist/core/credential-sources.d.ts.map +0 -1
  193. package/dist/core/credential-sources.js +0 -65
  194. package/dist/core/credential-sources.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * A cross-process advisory lock: a lock FILE created with O_EXCL (`wx`), removed when the work ends. Two `ora`
3
+ * processes refreshing one sign-in at the same moment would each send the same refresh token, and the authorization
4
+ * server rotates refresh tokens — the second use is a replay, which revokes the whole grant. Serializing the refresh
5
+ * is what keeps a second terminal from signing the person out.
6
+ *
7
+ * A lock older than `staleMs` belongs to a process that died (or was suspended, a laptop closed) mid-work, and is
8
+ * broken. Each holder therefore writes a token of its own into the file and removes the file only while it still
9
+ * holds that token: a suspended holder that wakes after its lock was broken finds its successor's token there, and
10
+ * leaves it — removing it would let a third process in beside the second.
11
+ *
12
+ * Every removal of the lock is serialized by a second O_EXCL file (`<lock>.break`): a waiter breaking a stale lock,
13
+ * and a holder letting go of its own. Two waiters that both judged a dead lock stale would otherwise race — one
14
+ * removes it and takes a fresh lock, the other then removes THAT fresh lock — and a holder checking its token could
15
+ * have the lock broken and retaken between the check and the removal. Holding the breaker, a waiter re-checks
16
+ * staleness and a holder re-checks its token before removing anything. A waiter gives up after `waitMs` with an
17
+ * error rather than hanging.
18
+ */
19
+ import { randomUUID } from "node:crypto";
20
+ import { closeSync, openSync, readFileSync, rmSync, statSync, writeSync } from "node:fs";
21
+ /** A lock older than this belongs to a holder that died (or was suspended) mid-work, and is broken. */
22
+ export const DEFAULT_STALE_MS = 30_000;
23
+ /** How long a waiter waits for the lock before it gives up with an error. */
24
+ export const DEFAULT_WAIT_MS = 20_000;
25
+ /** How often a waiter, or a holder letting go, tries again. */
26
+ export const DEFAULT_RETRY_MS = 100;
27
+ /** A breaker this old belongs to a process that died inside the (instant) step it guards: removed so others can go on. */
28
+ const BREAKER_STALE_MS = 10_000;
29
+ const sleepFor = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
30
+ const errnoCode = (err) => err instanceof Error && "code" in err && typeof err.code === "string" ? err.code : undefined;
31
+ /** Creates `path` exclusively, holding a token of this holder's own: the token, or null when someone else holds it. */
32
+ function tryAcquire(path) {
33
+ const token = `${process.pid}:${randomUUID()}`;
34
+ try {
35
+ const fd = openSync(path, "wx", 0o600);
36
+ try {
37
+ writeSync(fd, token);
38
+ }
39
+ finally {
40
+ closeSync(fd);
41
+ }
42
+ return token;
43
+ }
44
+ catch (err) {
45
+ if (errnoCode(err) === "EEXIST")
46
+ return null;
47
+ throw err;
48
+ }
49
+ }
50
+ /** What `path` holds now; null once it is gone. */
51
+ function heldBy(path) {
52
+ try {
53
+ return readFileSync(path, "utf8");
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ /** Removes `path` only while it still holds `token`: never a file someone else has taken since. */
60
+ function removeIfHeld(path, token) {
61
+ if (heldBy(path) === token)
62
+ rmSync(path, { force: true });
63
+ }
64
+ function isStale(path, staleMs, now) {
65
+ try {
66
+ return now - statSync(path).mtimeMs > staleMs;
67
+ }
68
+ catch {
69
+ return true; // vanished between the failed create and the stat: free now
70
+ }
71
+ }
72
+ /**
73
+ * Runs `step` while holding `<path>.break`, and gives the breaker back. Null when another process holds it; a breaker
74
+ * that has gone stale is removed then (only while it still holds what was seen in it), so the next try can take it.
75
+ */
76
+ function underBreaker(path, now, step) {
77
+ const breaker = `${path}.break`;
78
+ const token = tryAcquire(breaker);
79
+ if (token === null) {
80
+ const seen = heldBy(breaker);
81
+ if (seen !== null && isStale(breaker, BREAKER_STALE_MS, now))
82
+ removeIfHeld(breaker, seen);
83
+ return null;
84
+ }
85
+ try {
86
+ return { done: step() };
87
+ }
88
+ finally {
89
+ removeIfHeld(breaker, token);
90
+ }
91
+ }
92
+ /**
93
+ * Removes `path` if it is STILL stale while this waiter holds the breaker. True when it broke the lock; false when
94
+ * another process holds the breaker or the lock turned out fresh — the caller then waits.
95
+ */
96
+ function breakIfStale(path, staleMs, now) {
97
+ const broke = underBreaker(path, now, () => {
98
+ if (!isStale(path, staleMs, now))
99
+ return false;
100
+ rmSync(path, { force: true });
101
+ return true;
102
+ });
103
+ return broke?.done ?? false;
104
+ }
105
+ /**
106
+ * Lets go of the lock: removes it while it still holds `token`, under the breaker. A lock this holder could not let go
107
+ * of within `waitMs` (a breaker held throughout) is left to go stale, and is then broken like a dead holder's.
108
+ */
109
+ async function release(path, token, t) {
110
+ const startedAt = t.now();
111
+ while (underBreaker(path, t.now(), () => removeIfHeld(path, token)) === null) {
112
+ if (t.now() - startedAt > t.waitMs)
113
+ return;
114
+ await t.sleep(t.retryMs);
115
+ }
116
+ }
117
+ export async function withFileLock(path, work, opts = {}) {
118
+ const t = {
119
+ staleMs: opts.staleMs ?? DEFAULT_STALE_MS,
120
+ waitMs: opts.waitMs ?? DEFAULT_WAIT_MS,
121
+ retryMs: opts.retryMs ?? DEFAULT_RETRY_MS,
122
+ now: opts.now ?? Date.now,
123
+ sleep: opts.sleep ?? sleepFor,
124
+ };
125
+ const startedAt = t.now();
126
+ let token = tryAcquire(path);
127
+ while (token === null) {
128
+ if (isStale(path, t.staleMs, t.now()) && breakIfStale(path, t.staleMs, t.now())) {
129
+ token = tryAcquire(path);
130
+ continue;
131
+ }
132
+ if (t.now() - startedAt > t.waitMs) {
133
+ throw new Error("Another ora command is refreshing your sign-in. Try again in a moment.");
134
+ }
135
+ await t.sleep(t.retryMs);
136
+ token = tryAcquire(path);
137
+ }
138
+ try {
139
+ return await work();
140
+ }
141
+ finally {
142
+ await release(path, token, t);
143
+ }
144
+ }
145
+ //# sourceMappingURL=file-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-lock.js","sourceRoot":"","sources":["../../../src/core/session/file-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzF,uGAAuG;AACvG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,6EAA6E;AAC7E,MAAM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AAO,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;YAChF,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YACzB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The refusals a browser sign-in makes on its own (device-session-auth.ts), before or instead of the API answering,
3
+ * by code. Each is thrown with a message that already says what to do: sign in again, sign in to this API, or retry.
4
+ * credentials/refusal-words.ts prints these as written, and words every other refusal itself.
5
+ */
6
+ export declare const SESSION_REFUSAL: {
7
+ /** Nobody is signed in on this machine. */
8
+ readonly notSignedIn: "NOT_SIGNED_IN";
9
+ /** The sign-in on this machine was made for another API. */
10
+ readonly signedInElsewhere: "SIGNED_IN_ELSEWHERE";
11
+ /** Another `ora login` or `ora logout` replaced the sign-in while this request waited: the command is retried. */
12
+ readonly changed: "SESSION_CHANGED";
13
+ /** No refresh token is left to renew the sign-in with. */
14
+ readonly expired: "SESSION_EXPIRED";
15
+ /** The sign-in server ended the grant (revoked, or expired). */
16
+ readonly ended: "SESSION_ENDED";
17
+ };
18
+ /** Is this one of the sign-in's own refusals, worded where it was thrown? */
19
+ export declare const isSessionRefusal: (code: string) => boolean;
20
+ /** What a person whose sign-in no longer works does next. */
21
+ export declare const SIGN_IN_AGAIN = "Run `ora login` to sign in again.";
22
+ //# sourceMappingURL=session-refusals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-refusals.d.ts","sourceRoot":"","sources":["../../../src/core/session/session-refusals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,eAAe;IAC1B,2CAA2C;;IAE3C,4DAA4D;;IAE5D,kHAAkH;;IAElH,0DAA0D;;IAE1D,gEAAgE;;CAExD,CAAC;AAIX,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAA8B,CAAC;AAE/E,6DAA6D;AAC7D,eAAO,MAAM,aAAa,sCAAsC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The refusals a browser sign-in makes on its own (device-session-auth.ts), before or instead of the API answering,
3
+ * by code. Each is thrown with a message that already says what to do: sign in again, sign in to this API, or retry.
4
+ * credentials/refusal-words.ts prints these as written, and words every other refusal itself.
5
+ */
6
+ export const SESSION_REFUSAL = {
7
+ /** Nobody is signed in on this machine. */
8
+ notSignedIn: "NOT_SIGNED_IN",
9
+ /** The sign-in on this machine was made for another API. */
10
+ signedInElsewhere: "SIGNED_IN_ELSEWHERE",
11
+ /** Another `ora login` or `ora logout` replaced the sign-in while this request waited: the command is retried. */
12
+ changed: "SESSION_CHANGED",
13
+ /** No refresh token is left to renew the sign-in with. */
14
+ expired: "SESSION_EXPIRED",
15
+ /** The sign-in server ended the grant (revoked, or expired). */
16
+ ended: "SESSION_ENDED",
17
+ };
18
+ const OWN_CODES = new Set(Object.values(SESSION_REFUSAL));
19
+ /** Is this one of the sign-in's own refusals, worded where it was thrown? */
20
+ export const isSessionRefusal = (code) => OWN_CODES.has(code);
21
+ /** What a person whose sign-in no longer works does next. */
22
+ export const SIGN_IN_AGAIN = "Run `ora login` to sign in again.";
23
+ //# sourceMappingURL=session-refusals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-refusals.js","sourceRoot":"","sources":["../../../src/core/session/session-refusals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,2CAA2C;IAC3C,WAAW,EAAE,eAAe;IAC5B,4DAA4D;IAC5D,iBAAiB,EAAE,qBAAqB;IACxC,kHAAkH;IAClH,OAAO,EAAE,iBAAiB;IAC1B,0DAA0D;IAC1D,OAAO,EAAE,iBAAiB;IAC1B,gEAAgE;IAChE,KAAK,EAAE,eAAe;CACd,CAAC;AAEX,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAE/E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,mCAAmC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The device sign-in session on disk: `~/.config/ora/session.json`, 0600 in a 0700 dir (it holds a refresh token,
3
+ * a standing credential). Written atomically (a temp file renamed over the old one) so a crash mid-write never
4
+ * leaves half a session — a lost rotated refresh token would sign the person out. A corrupt or foreign file reads
5
+ * as "not signed in", never as a crash.
6
+ */
7
+ import { type FileLockOptions } from "./file-lock.js";
8
+ export interface DeviceSession {
9
+ version: 1;
10
+ /** Random per sign-in; identifies the session across refreshes. */
11
+ id: string;
12
+ /** The API the session was made for; a command against another API refuses it. */
13
+ apiUrl: string;
14
+ issuer: string;
15
+ clientId: string;
16
+ resource: string;
17
+ tokenEndpoint: string;
18
+ revocationEndpoint?: string;
19
+ /** What the person approved (space-separated), as the server granted it. */
20
+ scope: string;
21
+ accessToken: string;
22
+ /** Epoch ms. */
23
+ accessTokenExpiresAt: number;
24
+ refreshToken?: string;
25
+ /** Epoch ms. */
26
+ createdAt: number;
27
+ }
28
+ export declare function newSessionId(): string;
29
+ /**
30
+ * The device sign-in on disk, as its users need it: read it, replace it, remove it, and take turns — a refresh, a
31
+ * login and a logout run one at a time across `ora` processes (withLock).
32
+ */
33
+ export interface SessionStorage {
34
+ read(): DeviceSession | null;
35
+ write(session: DeviceSession): void;
36
+ clear(): void;
37
+ withLock<T>(work: () => Promise<T>): Promise<T>;
38
+ }
39
+ export declare class SessionStore implements SessionStorage {
40
+ private readonly dir;
41
+ private readonly lockOptions;
42
+ constructor(dir: string, lockOptions?: FileLockOptions);
43
+ read(): DeviceSession | null;
44
+ write(session: DeviceSession): void;
45
+ clear(): void;
46
+ /**
47
+ * Runs `work` while holding the config dir's credential lock (file-lock.ts): a refresh rotating the refresh token,
48
+ * a login replacing what is stored, and a logout removing it take turns.
49
+ */
50
+ withLock<T>(work: () => Promise<T>): Promise<T>;
51
+ private path;
52
+ }
53
+ //# sourceMappingURL=session-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../../src/core/session/session-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAoBD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,aAAa,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjD;AAED,qBAAa,YAAa,YAAW,cAAc;IAE/C,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,GAAG,EAAE,MAAM,EACX,WAAW,GAAE,eAAoB;IAGpD,IAAI,IAAI,aAAa,GAAG,IAAI;IAS5B,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IASnC,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/C,OAAO,CAAC,IAAI;CAGb"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The device sign-in session on disk: `~/.config/ora/session.json`, 0600 in a 0700 dir (it holds a refresh token,
3
+ * a standing credential). Written atomically (a temp file renamed over the old one) so a crash mid-write never
4
+ * leaves half a session — a lost rotated refresh token would sign the person out. A corrupt or foreign file reads
5
+ * as "not signed in", never as a crash.
6
+ */
7
+ import { randomUUID } from "node:crypto";
8
+ import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ import { withFileLock } from "./file-lock.js";
11
+ const SESSION_FILE = "session.json";
12
+ const LOCK_FILE = "session.lock";
13
+ export function newSessionId() {
14
+ return randomUUID();
15
+ }
16
+ function isSession(value) {
17
+ if (typeof value !== "object" || value === null)
18
+ return false;
19
+ const s = value;
20
+ return (s.version === 1 &&
21
+ typeof s.id === "string" &&
22
+ typeof s.apiUrl === "string" &&
23
+ typeof s.issuer === "string" &&
24
+ typeof s.clientId === "string" &&
25
+ typeof s.resource === "string" &&
26
+ typeof s.tokenEndpoint === "string" &&
27
+ typeof s.scope === "string" &&
28
+ typeof s.accessToken === "string" &&
29
+ typeof s.accessTokenExpiresAt === "number" &&
30
+ (s.refreshToken === undefined || typeof s.refreshToken === "string"));
31
+ }
32
+ export class SessionStore {
33
+ dir;
34
+ lockOptions;
35
+ constructor(dir, lockOptions = {}) {
36
+ this.dir = dir;
37
+ this.lockOptions = lockOptions;
38
+ }
39
+ read() {
40
+ try {
41
+ const parsed = JSON.parse(readFileSync(this.path(), "utf8"));
42
+ return isSession(parsed) ? parsed : null;
43
+ }
44
+ catch {
45
+ return null;
46
+ }
47
+ }
48
+ write(session) {
49
+ mkdirSync(this.dir, { recursive: true, mode: 0o700 });
50
+ chmodSync(this.dir, 0o700);
51
+ const tmp = join(this.dir, `${SESSION_FILE}.${process.pid}.${randomUUID()}.tmp`);
52
+ writeFileSync(tmp, `${JSON.stringify(session, null, 2)}\n`, { mode: 0o600 });
53
+ chmodSync(tmp, 0o600);
54
+ renameSync(tmp, this.path());
55
+ }
56
+ clear() {
57
+ rmSync(this.path(), { force: true });
58
+ }
59
+ /**
60
+ * Runs `work` while holding the config dir's credential lock (file-lock.ts): a refresh rotating the refresh token,
61
+ * a login replacing what is stored, and a logout removing it take turns.
62
+ */
63
+ withLock(work) {
64
+ mkdirSync(this.dir, { recursive: true, mode: 0o700 });
65
+ return withFileLock(join(this.dir, LOCK_FILE), work, this.lockOptions);
66
+ }
67
+ path() {
68
+ return join(this.dir, SESSION_FILE);
69
+ }
70
+ }
71
+ //# sourceMappingURL=session-store.js.map
@@ -0,0 +1 @@
1
+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AE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACzE,CAAC;IAEO,IAAI;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -7,8 +7,8 @@
7
7
  * exchange itself (auth.ts) knows neither: it sends what a sign-in presents
8
8
  * and caches the token under the sign-in's own cache key.
9
9
  *
10
- * Adding a way to sign in is one {@link SignIn} and one entry in
11
- * credential-sources.ts. Nothing that makes a call changes.
10
+ * Adding a way to sign in is one {@link SignIn} and one provider in
11
+ * credentials/credential-chain.ts. Nothing that makes a call changes.
12
12
  */
13
13
  /** What one exchange sends: the bearer, and the JSON body beside it. */
14
14
  export interface TokenExchangeRequest {
@@ -7,8 +7,8 @@
7
7
  * exchange itself (auth.ts) knows neither: it sends what a sign-in presents
8
8
  * and caches the token under the sign-in's own cache key.
9
9
  *
10
- * Adding a way to sign in is one {@link SignIn} and one entry in
11
- * credential-sources.ts. Nothing that makes a call changes.
10
+ * Adding a way to sign in is one {@link SignIn} and one provider in
11
+ * credentials/credential-chain.ts. Nothing that makes a call changes.
12
12
  */
13
13
  import { createHash } from "node:crypto";
14
14
  const digest = (text) => createHash("sha256").update(text).digest("hex").slice(0, 16);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * When a short-lived token is renewed: a little before it expires, never at it, so it cannot die between "checked" and
3
+ * "used". One rule for every token the CLI sends — an api key's traded token (auth.ts) and a browser sign-in's access
4
+ * token (session/device-session-auth.ts).
5
+ */
6
+ export declare const EXPIRY_SKEW_MS = 30000;
7
+ /** Is a token that expires at `expiresAt` (epoch ms) still good to send at `now`? */
8
+ export declare function stillFresh(expiresAt: number, now: number): boolean;
9
+ //# sourceMappingURL=token-expiry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-expiry.d.ts","sourceRoot":"","sources":["../../src/core/token-expiry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAElE"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * When a short-lived token is renewed: a little before it expires, never at it, so it cannot die between "checked" and
3
+ * "used". One rule for every token the CLI sends — an api key's traded token (auth.ts) and a browser sign-in's access
4
+ * token (session/device-session-auth.ts).
5
+ */
6
+ export const EXPIRY_SKEW_MS = 30_000;
7
+ /** Is a token that expires at `expiresAt` (epoch ms) still good to send at `now`? */
8
+ export function stillFresh(expiresAt, now) {
9
+ return expiresAt - EXPIRY_SKEW_MS > now;
10
+ }
11
+ //# sourceMappingURL=token-expiry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-expiry.js","sourceRoot":"","sources":["../../src/core/token-expiry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,GAAW;IACvD,OAAO,SAAS,GAAG,cAAc,GAAG,GAAG,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** `new URL(value)` without the throw — null for anything unparseable. (`URL.parse` needs Node 22; the CLI runs on 20.) */
2
+ export declare function parseUrl(value: string, base?: string): URL | null;
3
+ /** An absolute http(s) URL — the only kind the CLI follows or opens. */
4
+ export declare function isHttpUrl(value: unknown): value is string;
5
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/core/url.ts"],"names":[],"mappings":"AAAA,2HAA2H;AAC3H,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAMjE;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAIzD"}
@@ -0,0 +1,17 @@
1
+ /** `new URL(value)` without the throw — null for anything unparseable. (`URL.parse` needs Node 22; the CLI runs on 20.) */
2
+ export function parseUrl(value, base) {
3
+ try {
4
+ return new URL(value, base);
5
+ }
6
+ catch {
7
+ return null;
8
+ }
9
+ }
10
+ /** An absolute http(s) URL — the only kind the CLI follows or opens. */
11
+ export function isHttpUrl(value) {
12
+ if (typeof value !== "string")
13
+ return false;
14
+ const url = parseUrl(value);
15
+ return url !== null && (url.protocol === "https:" || url.protocol === "http:");
16
+ }
17
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/core/url.ts"],"names":[],"mappings":"AAAA,2HAA2H;AAC3H,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,IAAa;IACnD,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AACjF,CAAC"}
@@ -38,10 +38,11 @@ export interface OperationMeta {
38
38
  body?: string;
39
39
  };
40
40
  bodyFields?: BodyFieldMeta[];
41
+ cliArguments?: string[];
41
42
  }
42
43
  export declare const SPEC: {
43
44
  readonly version: "1.0.0";
44
- readonly contentHash: "fe3e7f533202e4ed7f17422627f7d89bb2fe15cf3b2e20c064df03ed0cc6113d";
45
+ readonly contentHash: "c97b354920b98a5146e7ccd3ad2233b3fa2cf4de3bdba1a82392a5e819d24ebe";
45
46
  readonly server: "https://api.ora.ai";
46
47
  readonly bin: "ora";
47
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3D,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAA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,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACrB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,IAAI;;;;;CAKP,CAAC;AAEX,eAAO,MAAM,UAAU,EAAE,aAAa,EA07VrC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAEjD,CAAC"}
@@ -1,9 +1,9 @@
1
1
  // GENERATED by scripts/generate.mjs — DO NOT EDIT.
2
- // Source: openapi/ora-public.openapi.json (sha256 fe3e7f533202e4ed7f17422627f7d89bb2fe15cf3b2e20c064df03ed0cc6113d)
2
+ // Source: openapi/ora-public.openapi.json (sha256 c97b354920b98a5146e7ccd3ad2233b3fa2cf4de3bdba1a82392a5e819d24ebe)
3
3
  // Regenerate: yarn nx run ora-cli:generate
4
4
  export const SPEC = {
5
5
  "version": "1.0.0",
6
- "contentHash": "fe3e7f533202e4ed7f17422627f7d89bb2fe15cf3b2e20c064df03ed0cc6113d",
6
+ "contentHash": "c97b354920b98a5146e7ccd3ad2233b3fa2cf4de3bdba1a82392a5e819d24ebe",
7
7
  "server": "https://api.ora.ai",
8
8
  "bin": "ora"
9
9
  };
@@ -864,10 +864,12 @@ export const OPERATIONS = [
864
864
  "placeholder": "true"
865
865
  }
866
866
  ],
867
+ "cliArguments": [
868
+ "domain"
869
+ ],
867
870
  "watchable": true,
868
871
  "help": {
869
- "command": "ora audit run --file run.json --watch",
870
- "body": "{\n \"domain\": \"example.com\"\n}"
872
+ "command": "ora audit run example.com --watch"
871
873
  }
872
874
  },
873
875
  {
@@ -10659,6 +10661,31 @@ export const OPERATIONS = [
10659
10661
  "body": "{\n \"name\": \"<name>\",\n \"visibility\": \"user\",\n \"body\": \"<body>\"\n}"
10660
10662
  }
10661
10663
  },
10664
+ {
10665
+ "id": "study.stop",
10666
+ "commandPath": [
10667
+ "study",
10668
+ "stop"
10669
+ ],
10670
+ "method": "post",
10671
+ "pathTemplate": "/study/v1/studies/{id}/stop",
10672
+ "summary": "Stop a running study: it starts no more runs (the ones a paced launch was holding back never start), and its unfinished runs are cancelled. Finished runs keep their results, and the study completes with them. It cannot be undone: a stopped study refuses a launch, a re-run and new agents. Calling it again is safe, and cancels any run that started in between.",
10673
+ "scope": "study.studies:write",
10674
+ "product": "study",
10675
+ "pathParams": [
10676
+ {
10677
+ "name": "id"
10678
+ }
10679
+ ],
10680
+ "queryParams": [],
10681
+ "hasBody": false,
10682
+ "bodyRequired": false,
10683
+ "isStream": false,
10684
+ "watchable": false,
10685
+ "help": {
10686
+ "command": "ora study stop 1f7e4d1c-4b2a-4f3e-9d8c-5a6b7c8d9e0f"
10687
+ }
10688
+ },
10662
10689
  {
10663
10690
  "id": "study.stream",
10664
10691
  "commandPath": [
@@ -11007,7 +11034,7 @@ export const OPERATIONS = [
11007
11034
  "method": "get",
11008
11035
  "pathTemplate": "/studio/v1/usage",
11009
11036
  "summary": "This month's agent runs and Ora Score scans for your organization: for each, how many were used, the plan's limit (null when uncapped) and how many remain, plus when the counts reset",
11010
- "scope": "intents:read",
11037
+ "scope": "usage:read",
11011
11038
  "product": "studio",
11012
11039
  "pathParams": [],
11013
11040
  "queryParams": [],