zcode-acp-server 0.40.1 → 0.41.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 (51) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +1 -1
  3. package/dist/bin/quota.d.ts +1 -1
  4. package/dist/bin/quota.d.ts.map +1 -1
  5. package/dist/bin/quota.js +28 -17
  6. package/dist/bin/quota.js.map +1 -1
  7. package/dist/code-fingerprint.json +2 -2
  8. package/dist/config/user-config.d.ts +10 -0
  9. package/dist/config/user-config.d.ts.map +1 -1
  10. package/dist/config/user-config.js +31 -4
  11. package/dist/config/user-config.js.map +1 -1
  12. package/dist/handlers/account.d.ts +21 -6
  13. package/dist/handlers/account.d.ts.map +1 -1
  14. package/dist/handlers/account.js +25 -8
  15. package/dist/handlers/account.js.map +1 -1
  16. package/dist/quota/combined.d.ts +13 -9
  17. package/dist/quota/combined.d.ts.map +1 -1
  18. package/dist/quota/combined.js +54 -29
  19. package/dist/quota/combined.js.map +1 -1
  20. package/dist/quota/ollama-cloud/cache.d.ts +16 -0
  21. package/dist/quota/ollama-cloud/cache.d.ts.map +1 -0
  22. package/dist/quota/ollama-cloud/cache.js +30 -0
  23. package/dist/quota/ollama-cloud/cache.js.map +1 -0
  24. package/dist/quota/ollama-cloud/client.d.ts +23 -0
  25. package/dist/quota/ollama-cloud/client.d.ts.map +1 -0
  26. package/dist/quota/ollama-cloud/client.js +33 -0
  27. package/dist/quota/ollama-cloud/client.js.map +1 -0
  28. package/dist/quota/ollama-cloud/config.d.ts +25 -0
  29. package/dist/quota/ollama-cloud/config.d.ts.map +1 -0
  30. package/dist/quota/ollama-cloud/config.js +31 -0
  31. package/dist/quota/ollama-cloud/config.js.map +1 -0
  32. package/dist/quota/ollama-cloud/format.d.ts +28 -0
  33. package/dist/quota/ollama-cloud/format.d.ts.map +1 -0
  34. package/dist/quota/ollama-cloud/format.js +53 -0
  35. package/dist/quota/ollama-cloud/format.js.map +1 -0
  36. package/dist/quota/ollama-cloud/index.d.ts +27 -0
  37. package/dist/quota/ollama-cloud/index.d.ts.map +1 -0
  38. package/dist/quota/ollama-cloud/index.js +91 -0
  39. package/dist/quota/ollama-cloud/index.js.map +1 -0
  40. package/dist/quota/ollama-cloud/types.d.ts +44 -0
  41. package/dist/quota/ollama-cloud/types.d.ts.map +1 -0
  42. package/dist/quota/ollama-cloud/types.js +15 -0
  43. package/dist/quota/ollama-cloud/types.js.map +1 -0
  44. package/dist/quota/opencode-go/config.d.ts +11 -11
  45. package/dist/quota/opencode-go/config.js +11 -11
  46. package/dist/quota/opencode-go/index.d.ts.map +1 -1
  47. package/dist/quota/opencode-go/index.js +16 -7
  48. package/dist/quota/opencode-go/index.js.map +1 -1
  49. package/docs/CLI.md +45 -13
  50. package/docs/REMOTE-CLIENTS.md +16 -2
  51. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"combined.js","sourceRoot":"","sources":["../../src/quota/combined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAavE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAkB;IACjD,0EAA0E;IAC1E,qEAAqE;IACrE,yEAAyE;IACzE,sDAAsD;IACtD,KAAK,QAAQ,CAAC;IACd,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAkB;IACpD,2EAA2E;IAC3E,0EAA0E;IAC1E,6EAA6E;IAC7E,MAAM,KAAK,GACT,QAAQ,KAAK,KAAK;QAChB,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC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ud results.
3
+ *
4
+ * Mirrors {@link ../../cache.ts} but typed for {@link OcQueryResult}. Same
5
+ * 10s TTL — matches the quota cache and the CLI's minimum watch interval.
6
+ */
7
+ import type { OcQueryResult } from "./types.js";
8
+ /** Return the cached result if still fresh, else `null`. */
9
+ export declare function getCached(): OcQueryResult | null;
10
+ /** Store a fresh result, stamping it with the current time. */
11
+ export declare function setCached(result: OcQueryResult): void;
12
+ /** Clear the cache (test helper, and used by CLI watch mode per tick). */
13
+ export declare function clearCache(): void;
14
+ /** Override the clock (test-only). Pass `undefined` to restore real time. */
15
+ export declare function setClock(fn?: () => number): void;
16
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAUhD,4DAA4D;AAC5D,wBAAgB,SAAS,IAAI,aAAa,GAAG,IAAI,CAGhD;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAErD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAEhD"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * In-memory TTL cache for Ollama Cloud results.
3
+ *
4
+ * Mirrors {@link ../../cache.ts} but typed for {@link OcQueryResult}. Same
5
+ * 10s TTL — matches the quota cache and the CLI's minimum watch interval.
6
+ */
7
+ /** How long a cached result is served before re-querying. */
8
+ const TTL_MS = 10_000;
9
+ let slot = null;
10
+ /** Inject a fake clock — only tests should need this. */
11
+ let now = () => Date.now();
12
+ /** Return the cached result if still fresh, else `null`. */
13
+ export function getCached() {
14
+ if (slot && now() - slot.at < TTL_MS)
15
+ return slot.result;
16
+ return null;
17
+ }
18
+ /** Store a fresh result, stamping it with the current time. */
19
+ export function setCached(result) {
20
+ slot = { result, at: now() };
21
+ }
22
+ /** Clear the cache (test helper, and used by CLI watch mode per tick). */
23
+ export function clearCache() {
24
+ slot = null;
25
+ }
26
+ /** Override the clock (test-only). Pass `undefined` to restore real time. */
27
+ export function setClock(fn) {
28
+ now = fn ?? (() => Date.now());
29
+ }
30
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6DAA6D;AAC7D,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,IAAI,IAAI,GAAiD,IAAI,CAAC;AAE9D,yDAAyD;AACzD,IAAI,GAAG,GAAiB,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAEzC,4DAA4D;AAC5D,MAAM,UAAU,SAAS;IACvB,IAAI,IAAI,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,SAAS,CAAC,MAAqB;IAC7C,IAAI,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;AAC/B,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,UAAU;IACxB,IAAI,GAAG,IAAI,CAAC;AACd,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,QAAQ,CAAC,EAAiB;IACxC,GAAG,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Ollama Cloud usage HTTP client.
3
+ *
4
+ * Talks to `https://ollama.com/api/usage` — an undocumented but live endpoint
5
+ * that returns `{limits:{session:{usage},weekly:{usage}}}` with usage as a
6
+ * 0..1 fraction. Auth is a plain Bearer API key (docs.ollama.com). No
7
+ * rate-limit headers exist on any Ollama endpoint, so the body is the only
8
+ * data source.
9
+ */
10
+ /** The undocumented usage endpoint (verified live 2026-09). */
11
+ export declare const USAGE_URL = "https://ollama.com/api/usage";
12
+ /**
13
+ * Fetch the usage JSON body.
14
+ *
15
+ * @throws on network errors or timeout. The caller maps these to
16
+ * `unavailable`. Auth failures are NOT thrown — the status is
17
+ * returned so the orchestrator can classify 401/403 as `auth_error`.
18
+ */
19
+ export declare function fetchOcUsage(apiKey: string, fetchImpl?: typeof globalThis.fetch): Promise<{
20
+ status: number;
21
+ text: string;
22
+ }>;
23
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,+DAA+D;AAC/D,eAAO,MAAM,SAAS,iCAAiC,CAAC;AAExD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,UAAU,CAAC,KAAwB,GACpD,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAW3C"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Ollama Cloud usage HTTP client.
3
+ *
4
+ * Talks to `https://ollama.com/api/usage` — an undocumented but live endpoint
5
+ * that returns `{limits:{session:{usage},weekly:{usage}}}` with usage as a
6
+ * 0..1 fraction. Auth is a plain Bearer API key (docs.ollama.com). No
7
+ * rate-limit headers exist on any Ollama endpoint, so the body is the only
8
+ * data source.
9
+ */
10
+ /** Request timeout (ms). Small JSON response; 10s is plenty. */
11
+ const TIMEOUT_MS = 10_000;
12
+ /** The undocumented usage endpoint (verified live 2026-09). */
13
+ export const USAGE_URL = "https://ollama.com/api/usage";
14
+ /**
15
+ * Fetch the usage JSON body.
16
+ *
17
+ * @throws on network errors or timeout. The caller maps these to
18
+ * `unavailable`. Auth failures are NOT thrown — the status is
19
+ * returned so the orchestrator can classify 401/403 as `auth_error`.
20
+ */
21
+ export async function fetchOcUsage(apiKey, fetchImpl = globalThis.fetch) {
22
+ const resp = await fetchImpl(USAGE_URL, {
23
+ method: "GET",
24
+ headers: {
25
+ Authorization: `Bearer ${apiKey}`,
26
+ Accept: "application/json",
27
+ },
28
+ signal: AbortSignal.timeout(TIMEOUT_MS),
29
+ });
30
+ const text = await resp.text();
31
+ return { status: resp.status, text };
32
+ }
33
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,YAAqC,UAAU,CAAC,KAAK;IAErD,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE;QACtC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,MAAM,EAAE;YACjC,MAAM,EAAE,kBAAkB;SAC3B;QACD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC;KACxC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Ollama Cloud credential discovery.
3
+ *
4
+ * The API key comes from two sources, with the **config file taking
5
+ * precedence** over the environment variable (the user-config convention —
6
+ * the file is the authoritative home for stable preferences):
7
+ * 1. `quota.ollamaApiKey` in `~/.config/zcode-acp/config.json`.
8
+ * 2. `OLLAMA_API_KEY` env var — the name Ollama's own docs use for cloud
9
+ * authentication (`Authorization: Bearer $OLLAMA_API_KEY`), kept as a
10
+ * full fallback for setups without a config file and one-off overrides.
11
+ *
12
+ * Unlike Opencode Go (which reuses `~/.pi/agent/` for historical reasons),
13
+ * the Ollama key is a plain static API key and belongs in our own config.
14
+ *
15
+ * A missing/blank key yields `not_configured` (the section is silently
16
+ * skipped in `all` mode).
17
+ */
18
+ /** Env var name — documented in the CLI help and README. */
19
+ export declare const ENV_API_KEY = "OLLAMA_API_KEY";
20
+ /**
21
+ * Resolve the API key: config file first, env var as fallback. Blank strings
22
+ * count as absent.
23
+ */
24
+ export declare function loadApiKey(): string | null;
25
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,4DAA4D;AAC5D,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAI1C"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Ollama Cloud credential discovery.
3
+ *
4
+ * The API key comes from two sources, with the **config file taking
5
+ * precedence** over the environment variable (the user-config convention —
6
+ * the file is the authoritative home for stable preferences):
7
+ * 1. `quota.ollamaApiKey` in `~/.config/zcode-acp/config.json`.
8
+ * 2. `OLLAMA_API_KEY` env var — the name Ollama's own docs use for cloud
9
+ * authentication (`Authorization: Bearer $OLLAMA_API_KEY`), kept as a
10
+ * full fallback for setups without a config file and one-off overrides.
11
+ *
12
+ * Unlike Opencode Go (which reuses `~/.pi/agent/` for historical reasons),
13
+ * the Ollama key is a plain static API key and belongs in our own config.
14
+ *
15
+ * A missing/blank key yields `not_configured` (the section is silently
16
+ * skipped in `all` mode).
17
+ */
18
+ import process from "node:process";
19
+ import { loadUserConfig } from "../../config/user-config.js";
20
+ /** Env var name — documented in the CLI help and README. */
21
+ export const ENV_API_KEY = "OLLAMA_API_KEY";
22
+ /**
23
+ * Resolve the API key: config file first, env var as fallback. Blank strings
24
+ * count as absent.
25
+ */
26
+ export function loadApiKey() {
27
+ const file = loadUserConfig().quota?.ollamaApiKey;
28
+ const key = (file ?? process.env[ENV_API_KEY] ?? "").trim();
29
+ return key.length > 0 ? key : null;
30
+ }
31
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;IAClD,MAAM,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Ollama Cloud usage formatting.
3
+ *
4
+ * Renders the plan's usage windows as progress bars in the same style as the
5
+ * GLM and Opencode Go sections, so all sections read as one card in the
6
+ * combined view. Which windows exist depends on the account's plan: legacy
7
+ * plans expose session (5h) + weekly; current credit plans expose monthly.
8
+ * The API exposes no reset timestamps, so — unlike the other providers — the
9
+ * lines carry no reset stamp, just the percent.
10
+ */
11
+ import type { OcQueryResult } from "./types.js";
12
+ /** A rendered section: a header line and zero or more body lines. */
13
+ export interface RenderedSection {
14
+ header: string;
15
+ body: string[];
16
+ }
17
+ /**
18
+ * Render the Ollama Cloud section.
19
+ *
20
+ * Used by the combined formatter. The header is always `Ollama Cloud`; body
21
+ * has one bar line per window. Non-success kinds return a header + a single
22
+ * explanatory line.
23
+ *
24
+ * When `color` is true the bar is a heat-colored 24-bit ANSI bar with the
25
+ * percent overlaid inside, mirroring the other providers' color layout.
26
+ */
27
+ export declare function formatOcSection(result: OcQueryResult, color?: boolean): RenderedSection;
28
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAWhD,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,UAAQ,GAAG,eAAe,CAwBrF"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Ollama Cloud usage formatting.
3
+ *
4
+ * Renders the plan's usage windows as progress bars in the same style as the
5
+ * GLM and Opencode Go sections, so all sections read as one card in the
6
+ * combined view. Which windows exist depends on the account's plan: legacy
7
+ * plans expose session (5h) + weekly; current credit plans expose monthly.
8
+ * The API exposes no reset timestamps, so — unlike the other providers — the
9
+ * lines carry no reset stamp, just the percent.
10
+ */
11
+ import { pickOverlay, renderColorBar } from "../color.js";
12
+ import { renderBar } from "../format.js";
13
+ import { roundTenth } from "../rounding.js";
14
+ /** Label + window metadata, in display order. Which rows appear depends on
15
+ * the account's plan: legacy plans carry session (5h) + weekly; current
16
+ * credit plans carry monthly only. */
17
+ const WINDOW_META = [
18
+ { key: "session", label: "5h" },
19
+ { key: "weekly", label: "Week" },
20
+ { key: "monthly", label: "Month" },
21
+ ];
22
+ /**
23
+ * Render the Ollama Cloud section.
24
+ *
25
+ * Used by the combined formatter. The header is always `Ollama Cloud`; body
26
+ * has one bar line per window. Non-success kinds return a header + a single
27
+ * explanatory line.
28
+ *
29
+ * When `color` is true the bar is a heat-colored 24-bit ANSI bar with the
30
+ * percent overlaid inside, mirroring the other providers' color layout.
31
+ */
32
+ export function formatOcSection(result, color = false) {
33
+ const header = "Ollama Cloud";
34
+ if (result.kind !== "success") {
35
+ const msg = result.kind === "not_configured"
36
+ ? "not configured (set OLLAMA_API_KEY)"
37
+ : result.kind === "auth_error"
38
+ ? "auth failed — check your Ollama API key"
39
+ : "unavailable";
40
+ return { header, body: [msg] };
41
+ }
42
+ const body = WINDOW_META.filter((m) => result[m.key] !== undefined).map((m) => {
43
+ const fraction = result[m.key];
44
+ const pct = roundTenth(fraction * 100);
45
+ if (color) {
46
+ const bar = renderColorBar(pct, { overlay: pickOverlay({ usedPercent: pct }) });
47
+ return `${m.label.padEnd(5)} ${bar}`;
48
+ }
49
+ return `${m.label.padEnd(5)} ${renderBar(pct)} ${String(pct).padStart(2)}%`;
50
+ });
51
+ return { header, body };
52
+ }
53
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C;;uCAEuC;AACvC,MAAM,WAAW,GAAoE;IACnF,EAAE,GAAG,EAAE,SAAS,EAAE,K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,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/E,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Ollama Cloud usage orchestration — the entry point used by the
3
+ * `zcode-acp quota` CLI.
4
+ *
5
+ * Flow: credential (env + config file) → cache check → fetch → status/auth
6
+ * check → parse → cache write. Any thrown error degrades to `unavailable`
7
+ * rather than propagating, so the CLI always produces output.
8
+ *
9
+ * A missing API key yields `not_configured`, which the combined view silently
10
+ * skips — so users who only care about GLM see no noise.
11
+ */
12
+ import type { OcQueryResult } from "./types.js";
13
+ /**
14
+ * Query Ollama Cloud usage and return a normalised {@link OcQueryResult}.
15
+ *
16
+ * - No key → `not_configured`.
17
+ * - Serves a cached result when fresh (< 10s).
18
+ * - HTTP 401/403 → `auth_error` (bad or revoked key).
19
+ * - Network/timeout/parse failure → `unavailable`.
20
+ */
21
+ export declare function queryOcUsage(): Promise<OcQueryResult>;
22
+ export { clearCache, clearCache as clearOcCache } from "./cache.js";
23
+ export { fetchOcUsage, USAGE_URL } from "./client.js";
24
+ export { formatOcSection } from "./format.js";
25
+ export { loadApiKey, ENV_API_KEY } from "./config.js";
26
+ export type { OcQueryResult, OcUsageResponse } from "./types.js";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAchD;;;;;;;GAOG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CAoD3D;AAGD,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Ollama Cloud usage orchestration — the entry point used by the
3
+ * `zcode-acp quota` CLI.
4
+ *
5
+ * Flow: credential (env + config file) → cache check → fetch → status/auth
6
+ * check → parse → cache write. Any thrown error degrades to `unavailable`
7
+ * rather than propagating, so the CLI always produces output.
8
+ *
9
+ * A missing API key yields `not_configured`, which the combined view silently
10
+ * skips — so users who only care about GLM see no noise.
11
+ */
12
+ import { log } from "../../utils.js";
13
+ import { getCached, setCached } from "./cache.js";
14
+ import { loadApiKey } from "./config.js";
15
+ import { fetchOcUsage } from "./client.js";
16
+ /**
17
+ * Validate a usage value from the response body: a finite number in [0, 1].
18
+ *
19
+ * Values > 1 are rejected on purpose: the endpoint is undocumented, and if
20
+ * Ollama ever switches to percent-valued numbers, silently treating 42 as a
21
+ * 4200% fraction would render a nonsensical full bar. The same guard is used
22
+ * by the pi-multi-account reference client.
23
+ */
24
+ function validFraction(v) {
25
+ return typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1;
26
+ }
27
+ /**
28
+ * Query Ollama Cloud usage and return a normalised {@link OcQueryResult}.
29
+ *
30
+ * - No key → `not_configured`.
31
+ * - Serves a cached result when fresh (< 10s).
32
+ * - HTTP 401/403 → `auth_error` (bad or revoked key).
33
+ * - Network/timeout/parse failure → `unavailable`.
34
+ */
35
+ export async function queryOcUsage() {
36
+ const cached = getCached();
37
+ if (cached) {
38
+ log("ollama-cloud: serving cached result");
39
+ return cached;
40
+ }
41
+ const apiKey = loadApiKey();
42
+ if (!apiKey)
43
+ return { kind: "not_configured" };
44
+ let result;
45
+ try {
46
+ const resp = await fetchOcUsage(apiKey);
47
+ if (resp.status === 401 || resp.status === 403) {
48
+ result = { kind: "auth_error" };
49
+ }
50
+ else if (resp.status !== 200) {
51
+ // 429 = quota exhausted, 5xx = server-side; neither is a usage snapshot.
52
+ log(`ollama-cloud: unexpected status ${resp.status}`);
53
+ result = { kind: "unavailable" };
54
+ }
55
+ else {
56
+ const parsed = JSON.parse(resp.text);
57
+ const limits = parsed.limits ?? {};
58
+ const window = (key) => validFraction(limits[key]?.usage) ? limits[key].usage : undefined;
59
+ const session = window("session");
60
+ const weekly = window("weekly");
61
+ const monthly = window("monthly");
62
+ if (session !== undefined || weekly !== undefined || monthly !== undefined) {
63
+ // At least one recognised window — legacy plans carry session+weekly,
64
+ // current credit plans carry monthly only.
65
+ result = {
66
+ kind: "success",
67
+ ...(session !== undefined && { session }),
68
+ ...(weekly !== undefined && { weekly }),
69
+ ...(monthly !== undefined && { monthly }),
70
+ fetchedAt: Date.now(),
71
+ };
72
+ }
73
+ else {
74
+ log("ollama-cloud: response shape not recognised (endpoint may have changed)");
75
+ result = { kind: "unavailable" };
76
+ }
77
+ }
78
+ }
79
+ catch (e) {
80
+ log(`ollama-cloud: fetch failed (${e instanceof Error ? e.message : String(e)})`);
81
+ result = { kind: "unavailable" };
82
+ }
83
+ setCached(result);
84
+ return result;
85
+ }
86
+ // Re-exports for consumers (CLI + tests).
87
+ export { clearCache, clearCache as clearOcCache } from "./cache.js";
88
+ export { fetchOcUsage, USAGE_URL } from "./client.js";
89
+ export { formatOcSection } from "./format.js";
90
+ export { loadApiKey, ENV_API_KEY } from "./config.js";
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE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OAAO,MAAM,CAAC;AAChB,CAAC;AAED,0CAA0C;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Type definitions for the Ollama Cloud subscription usage feature.
3
+ *
4
+ * `zcode-acp quota` queries the undocumented-but-live
5
+ * `GET https://ollama.com/api/usage` endpoint with the user's API key. The
6
+ * response carries two usage fractions (session = 5h rolling window, weekly =
7
+ * 7d window) in [0, 1] and NO reset timestamps — the server does not expose
8
+ * them, so the card shows bars + percents only (no countdown stamps).
9
+ *
10
+ * Shape verified against live probes + the pi-multi-account reference client
11
+ * (2026-09); see `.zcode/scratch/research-ollama-cloud-usage.md`. Undocumented
12
+ * — treat parse failures as `unavailable`, never as a crash.
13
+ */
14
+ /**
15
+ * Result of querying Ollama Cloud usage — a 4-state sum type mirroring
16
+ * {@link ../opencode-go/types.js GoQueryResult}.
17
+ *
18
+ * `not_configured` is distinct from `unavailable`: the CLI uses it to silently
19
+ * skip the Ollama section in default (all-provider) mode when the user has not
20
+ * supplied an API key, rather than printing an error.
21
+ */
22
+ export type OcQueryResult = {
23
+ kind: "success";
24
+ /** Present windows only — the account's plan decides which exist.
25
+ * Fractions in [0, 1]. Legacy plans expose session+weekly; current
26
+ * credit plans expose monthly (with per-model request counts). */
27
+ session?: number;
28
+ weekly?: number;
29
+ monthly?: number;
30
+ /** Epoch ms of the fetch (kept for symmetry with the other providers). */
31
+ fetchedAt: number;
32
+ } | {
33
+ kind: "not_configured";
34
+ } | {
35
+ kind: "auth_error";
36
+ } | {
37
+ kind: "unavailable";
38
+ };
39
+ /** Raw /api/usage fetch result — status + body text. */
40
+ export interface OcUsageResponse {
41
+ status: number;
42
+ text: string;
43
+ }
44
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB;;uEAEmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAE5B,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Type definitions for the Ollama Cloud subscription usage feature.
3
+ *
4
+ * `zcode-acp quota` queries the undocumented-but-live
5
+ * `GET https://ollama.com/api/usage` endpoint with the user's API key. The
6
+ * response carries two usage fractions (session = 5h rolling window, weekly =
7
+ * 7d window) in [0, 1] and NO reset timestamps — the server does not expose
8
+ * them, so the card shows bars + percents only (no countdown stamps).
9
+ *
10
+ * Shape verified against live probes + the pi-multi-account reference client
11
+ * (2026-09); see `.zcode/scratch/research-ollama-cloud-usage.md`. Undocumented
12
+ * — treat parse failures as `unavailable`, never as a crash.
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/quota/ollama-cloud/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -1,18 +1,18 @@
1
1
  /**
2
- * Opencode Go credential discovery.
2
+ * Opencode Go credential discovery — the LEGACY `~/.pi/agent/opencode-go.json`
3
+ * fallback source.
3
4
  *
4
- * Credentials may come from two sources, merged field-by-field with
5
- * **environment variables taking precedence** over the config file:
6
- * 1. `OPENCODE_GO_WORKSPACE_ID` / `OPENCODE_GO_AUTH_COOKIE` env vars
5
+ * Full precedence (highest first), resolved in ../index.ts:
6
+ * 1. `quota.opencodeGoWorkspaceId` / `quota.opencodeGoAuthCookie` in
7
+ * `~/.config/zcode-acp/config.json` (our own config).
8
+ * 2. `OPENCODE_GO_WORKSPACE_ID` / `OPENCODE_GO_AUTH_COOKIE` env vars
7
9
  * (best for CI / scripts / temporary overrides).
8
- * 2. `~/.pi/agent/opencode-go.json` — `{ workspaceId, authCookie }`
9
- * (the convention used by the @beyona/pi-zai-usage Pi extension, so users
10
- * who already configured it there get reuse for free).
10
+ * 3. `~/.pi/agent/opencode-go.json` — `{ workspaceId, authCookie }`
11
+ * (the convention used by the @beyona/pi-zai-usage Pi extension, kept so
12
+ * users who already configured it there get reuse for free).
11
13
  *
12
- * A field present in env overrides the same field from the file; a field only
13
- * in the file is still used. This lets a user keep their stable workspaceId in
14
- * the file while rotating the cookie via env, etc. Both fields must resolve to
15
- * a valid pair — a missing/invalid one yields `not_configured`.
14
+ * Both fields must resolve to a valid pair — a missing/invalid one yields
15
+ * `not_configured`.
16
16
  */
17
17
  /** Env var names — documented in the CLI help and README. */
18
18
  export declare const ENV_WORKSPACE_ID = "OPENCODE_GO_WORKSPACE_ID";
@@ -1,18 +1,18 @@
1
1
  /**
2
- * Opencode Go credential discovery.
2
+ * Opencode Go credential discovery — the LEGACY `~/.pi/agent/opencode-go.json`
3
+ * fallback source.
3
4
  *
4
- * Credentials may come from two sources, merged field-by-field with
5
- * **environment variables taking precedence** over the config file:
6
- * 1. `OPENCODE_GO_WORKSPACE_ID` / `OPENCODE_GO_AUTH_COOKIE` env vars
5
+ * Full precedence (highest first), resolved in ../index.ts:
6
+ * 1. `quota.opencodeGoWorkspaceId` / `quota.opencodeGoAuthCookie` in
7
+ * `~/.config/zcode-acp/config.json` (our own config).
8
+ * 2. `OPENCODE_GO_WORKSPACE_ID` / `OPENCODE_GO_AUTH_COOKIE` env vars
7
9
  * (best for CI / scripts / temporary overrides).
8
- * 2. `~/.pi/agent/opencode-go.json` — `{ workspaceId, authCookie }`
9
- * (the convention used by the @beyona/pi-zai-usage Pi extension, so users
10
- * who already configured it there get reuse for free).
10
+ * 3. `~/.pi/agent/opencode-go.json` — `{ workspaceId, authCookie }`
11
+ * (the convention used by the @beyona/pi-zai-usage Pi extension, kept so
12
+ * users who already configured it there get reuse for free).
11
13
  *
12
- * A field present in env overrides the same field from the file; a field only
13
- * in the file is still used. This lets a user keep their stable workspaceId in
14
- * the file while rotating the cookie via env, etc. Both fields must resolve to
15
- * a valid pair — a missing/invalid one yields `not_configured`.
14
+ * Both fields must resolve to a valid pair — a missing/invalid one yields
15
+ * `not_configured`.
16
16
  */
17
17
  import { readFileSync } from "node:fs";
18
18
  import path from "node:path";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/quota/opencode-go/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAgChD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CA6C3D;AAGD,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7F,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/quota/opencode-go/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwChD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CA6C3D;AAGD,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7F,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
@@ -10,6 +10,7 @@
10
10
  * combined view silently skips (vs. `unavailable`, which renders an error
11
11
  * line) — so users who only care about GLM see no noise.
12
12
  */
13
+ import { loadUserConfig } from "../../config/user-config.js";
13
14
  import { log } from "../../utils.js";
14
15
  import { getCached, setCached } from "./cache.js";
15
16
  import { ENV_AUTH_COOKIE, ENV_WORKSPACE_ID, readConfigFile } from "./config.js";
@@ -21,16 +22,24 @@ const COOKIE_PREFIX = "Fe26.2**";
21
22
  /**
22
23
  * Resolve & validate credentials.
23
24
  *
24
- * Environment variables take precedence over `~/.pi/agent/opencode-go.json`,
25
- * merged field-by-field: env overrides the same field from the file, but a
26
- * field present only in the file still counts. Returns `null` when the
27
- * resolved pair is incomplete or malformed — `queryGoUsage` maps that to
28
- * `not_configured`.
25
+ * Three sources, merged field-by-field with the standard user-config
26
+ * precedence (highest first):
27
+ * 1. `quota.opencodeGoWorkspaceId` / `quota.opencodeGoAuthCookie` in
28
+ * `~/.config/zcode-acp/config.json` (our own config — preferred home).
29
+ * 2. `OPENCODE_GO_WORKSPACE_ID` / `OPENCODE_GO_AUTH_COOKIE` env vars.
30
+ * 3. `~/.pi/agent/opencode-go.json` (legacy — the @beyona/pi-zai-usage Pi
31
+ * extension convention, kept so existing setups keep working).
32
+ *
33
+ * A field present in a higher-precedence source overrides the same field
34
+ * below it; a field present only lower down still counts. Returns `null`
35
+ * when the resolved pair is incomplete or malformed — `queryGoUsage` maps
36
+ * that to `not_configured`.
29
37
  */
30
38
  function loadCredentials() {
39
+ const own = loadUserConfig().quota;
31
40
  const file = readConfigFile();
32
- const workspaceId = process.env[ENV_WORKSPACE_ID] ?? file.workspaceId;
33
- const authCookie = process.env[ENV_AUTH_COOKIE] ?? file.authCookie;
41
+ const workspaceId = own?.opencodeGoWorkspaceId ?? process.env[ENV_WORKSPACE_ID] ?? file.workspaceId;
42
+ const authCookie = own?.opencodeGoAuthCookie ?? process.env[ENV_AUTH_COOKIE] ?? file.authCookie;
34
43
  if (!workspaceId || !authCookie)
35
44
  return null;
36
45
  if (!RE_WORKSPACE.test(workspaceId)) {