@opvs-ai/cli 0.16.1 → 0.20.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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * A PAT request that is still waiting for a human to approve it (PC-252).
3
+ *
4
+ * The server keeps a request approvable for an hour, because the person who
5
+ * approves is usually someone else, reading email on a phone. The CLI must not
6
+ * sit polling for that hour — an agent's shell call is killed long before, and
7
+ * an hour of silent polling is a hang, not a feature. So `auth request` waits a
8
+ * bounded time (`--wait`, default 5 min) and then hands off: this file keeps
9
+ * what is needed to collect the token later with `opvs auth resume`.
10
+ *
11
+ * It is written BEFORE the first poll, so a process killed mid-wait (a tool-call
12
+ * timeout) still leaves a request that can be resumed. It holds the poll token —
13
+ * a bearer secret that fetches the PAT once approved — so it is written 0600,
14
+ * like a key file, and removed the moment the request settles either way.
15
+ *
16
+ * One pending request at a time: a new `auth request` replaces the old one,
17
+ * which matches what the approver is told — "approve the newest email".
18
+ */
19
+ import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
20
+ import { dirname, join } from "node:path";
21
+ import { getConfigPath } from "@opvs-ai/core";
22
+ export function pendingAuthPath() {
23
+ return join(dirname(getConfigPath()), "pending-auth.json");
24
+ }
25
+ export function savePendingAuth(pending, path = pendingAuthPath()) {
26
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
27
+ writeFileSync(path, JSON.stringify(pending, null, 2) + "\n", { mode: 0o600 });
28
+ // `mode` above applies only when the file is created; a file left by an older
29
+ // run keeps whatever bits it had.
30
+ chmodSync(path, 0o600);
31
+ }
32
+ /** The saved request, or `null` when there is none — or it is unreadable, which is the same thing to a caller. */
33
+ export function loadPendingAuth(path = pendingAuthPath()) {
34
+ let raw;
35
+ try {
36
+ raw = readFileSync(path, "utf8");
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ let p;
42
+ try {
43
+ p = JSON.parse(raw);
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ if (!p ||
49
+ typeof p.request_id !== "string" ||
50
+ typeof p.poll_token !== "string" ||
51
+ typeof p.api_url !== "string" ||
52
+ typeof p.expires_at !== "string") {
53
+ return null;
54
+ }
55
+ return {
56
+ request_id: p.request_id,
57
+ poll_token: p.poll_token,
58
+ api_url: p.api_url,
59
+ expires_at: p.expires_at,
60
+ owner_email: typeof p.owner_email === "string" ? p.owner_email : "",
61
+ workspace_slug: typeof p.workspace_slug === "string" ? p.workspace_slug : null,
62
+ brands: Array.isArray(p.brands) ? p.brands : [],
63
+ created_at: typeof p.created_at === "string" ? p.created_at : "",
64
+ };
65
+ }
66
+ export function clearPendingAuth(path = pendingAuthPath()) {
67
+ rmSync(path, { force: true });
68
+ }
69
+ //# sourceMappingURL=pending-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-auth.js","sourceRoot":"","sources":["../../src/lib/pending-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAiB9C,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAoB,EAAE,OAAe,eAAe,EAAE;IACpF,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE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AC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC/C,UAAU,EAAE,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;KACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe,eAAe,EAAE;IAC/D,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAChC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opvs-ai/cli",
3
- "version": "0.16.1",
4
- "description": "OPVS CLI \u2014 Terminal access to AgentBoard + AgentDocs for AI coding agents",
3
+ "version": "0.20.1",
4
+ "description": "OPVS CLI — Terminal access to AgentBoard + AgentDocs for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opvs": "dist/index.js"