lh-api-client 0.0.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.
Files changed (49) hide show
  1. package/dist/api-keys/index.d.ts +37 -0
  2. package/dist/api-keys/index.js +23 -0
  3. package/dist/api-keys/index.js.map +1 -0
  4. package/dist/audit/index.d.ts +47 -0
  5. package/dist/audit/index.js +27 -0
  6. package/dist/audit/index.js.map +1 -0
  7. package/dist/cache-coverage/index.d.ts +24 -0
  8. package/dist/cache-coverage/index.js +9 -0
  9. package/dist/cache-coverage/index.js.map +1 -0
  10. package/dist/client.d.ts +25 -0
  11. package/dist/client.js +68 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/index.d.ts +29 -0
  14. package/dist/index.js +53 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/member/index.d.ts +49 -0
  17. package/dist/member/index.js +38 -0
  18. package/dist/member/index.js.map +1 -0
  19. package/dist/models/index.d.ts +7 -0
  20. package/dist/models/index.js +15 -0
  21. package/dist/models/index.js.map +1 -0
  22. package/dist/org-usage/index.d.ts +47 -0
  23. package/dist/org-usage/index.js +7 -0
  24. package/dist/org-usage/index.js.map +1 -0
  25. package/dist/orgs/index.d.ts +113 -0
  26. package/dist/orgs/index.js +65 -0
  27. package/dist/orgs/index.js.map +1 -0
  28. package/dist/phase2/index.d.ts +46 -0
  29. package/dist/phase2/index.js +120 -0
  30. package/dist/phase2/index.js.map +1 -0
  31. package/dist/plan/index.d.ts +52 -0
  32. package/dist/plan/index.js +41 -0
  33. package/dist/plan/index.js.map +1 -0
  34. package/dist/platform-token/index.d.ts +37 -0
  35. package/dist/platform-token/index.js +22 -0
  36. package/dist/platform-token/index.js.map +1 -0
  37. package/dist/price-book/index.d.ts +17 -0
  38. package/dist/price-book/index.js +10 -0
  39. package/dist/price-book/index.js.map +1 -0
  40. package/dist/statement/index.d.ts +38 -0
  41. package/dist/statement/index.js +10 -0
  42. package/dist/statement/index.js.map +1 -0
  43. package/dist/subscription/index.d.ts +45 -0
  44. package/dist/subscription/index.js +30 -0
  45. package/dist/subscription/index.js.map +1 -0
  46. package/dist/topup/index.d.ts +37 -0
  47. package/dist/topup/index.js +19 -0
  48. package/dist/topup/index.js.map +1 -0
  49. package/package.json +27 -0
@@ -0,0 +1,37 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * One row from `GET /platform/orgs/:orgId/keys` — the export-shape api-key
4
+ * row. Backend source: `ApiKeyService.findAllForExport` (T5 of v0.1.7 #283).
5
+ *
6
+ * Returned for v0.1.7 compliance export AND v0.2.0 agent-native admin
7
+ * surface (read tool — operator/admin asks "which keys does this org have"
8
+ * or "哪些 key 闲置了").
9
+ */
10
+ export interface ApiKeyExportRow {
11
+ id: string;
12
+ keyPrefix: string;
13
+ label: string | null;
14
+ status: 'ACTIVE' | 'INACTIVE' | 'REVOKED';
15
+ memberId: string;
16
+ subscriptionId: string;
17
+ createdAt: string;
18
+ claimedAt: string | null;
19
+ acknowledgedBy: string | null;
20
+ lastUsageAt: string | null;
21
+ }
22
+ export interface ListApiKeysArgs {
23
+ orgId: string;
24
+ includeRevoked?: boolean;
25
+ }
26
+ /**
27
+ * v0.2.0 agent read tool. Mirrors the v0.1.7 T5 export endpoint —
28
+ * `GET /platform/orgs/:orgId/keys?include-revoked=...`. Returns the
29
+ * denormalized export shape including `lastUsageAt` so the LLM can
30
+ * answer "which keys haven't been used in 30+ days" without a second
31
+ * tool call.
32
+ *
33
+ * `includeRevoked: false` (default) returns ACTIVE + INACTIVE only —
34
+ * the natural answer to "active keys" questions. Set true for full
35
+ * audit / compliance export.
36
+ */
37
+ export declare function listApiKeys(client: Client, args: ListApiKeysArgs): Promise<ApiKeyExportRow[]>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listApiKeys = listApiKeys;
4
+ /**
5
+ * v0.2.0 agent read tool. Mirrors the v0.1.7 T5 export endpoint —
6
+ * `GET /platform/orgs/:orgId/keys?include-revoked=...`. Returns the
7
+ * denormalized export shape including `lastUsageAt` so the LLM can
8
+ * answer "which keys haven't been used in 30+ days" without a second
9
+ * tool call.
10
+ *
11
+ * `includeRevoked: false` (default) returns ACTIVE + INACTIVE only —
12
+ * the natural answer to "active keys" questions. Set true for full
13
+ * audit / compliance export.
14
+ */
15
+ async function listApiKeys(client, args) {
16
+ return client.request(`/platform/orgs/${encodeURIComponent(args.orgId)}/keys`, {
17
+ method: 'GET',
18
+ query: {
19
+ 'include-revoked': args.includeRevoked ? '1' : undefined,
20
+ },
21
+ });
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api-keys/index.ts"],"names":[],"mappings":";;AAuCA,kCAaC;AAxBD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,IAAqB;IAErB,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EACvD;QACE,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,iBAAiB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;SACzD;KACF,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * One audit entry from `GET /platform/audit`. Mirrors the `AuditLog`
4
+ * Prisma model (backend/prisma/schema.prisma) verbatim — verified by
5
+ * canary smoke 2026-05-20 against live data.
6
+ *
7
+ * `occurredAt` is the timestamp; `before` + `after` are diffable JSON
8
+ * snapshots (used for state-change audits); `payload` is free-form
9
+ * context (request params, response codes, etc.). All three Json fields
10
+ * are nullable — many actions only set one or two.
11
+ */
12
+ export interface AuditEntry {
13
+ id: string;
14
+ occurredAt: string;
15
+ actor: string;
16
+ action: string;
17
+ orgId: string | null;
18
+ before: unknown;
19
+ after: unknown;
20
+ payload: unknown;
21
+ }
22
+ export interface QueryAuditArgs {
23
+ /** ISO-8601 inclusive start, e.g. 2026-04-19T00:00:00Z */
24
+ from: string;
25
+ /** ISO-8601 inclusive end */
26
+ to: string;
27
+ /** Filter by org UUID */
28
+ orgId?: string;
29
+ /** Filter by actor user UUID */
30
+ actor?: string;
31
+ /** Filter by action key, e.g. `api_key.create` */
32
+ action?: string;
33
+ /** Page size, 1-200 (backend default 50) */
34
+ limit?: number;
35
+ /** Offset for paginating past the limit */
36
+ offset?: number;
37
+ }
38
+ /**
39
+ * v0.2.0 agent read tool. Mirrors `GET /platform/audit` (lh-ops CLI has
40
+ * the same endpoint via `audit query`). All filters are AND-composed
41
+ * server-side; from/to are required.
42
+ *
43
+ * For common asks like "this week's events" the agent should compute the
44
+ * from/to in the user's timezone before calling — the backend doesn't
45
+ * accept relative ranges.
46
+ */
47
+ export declare function queryAudit(client: Client, args: QueryAuditArgs): Promise<AuditEntry[]>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryAudit = queryAudit;
4
+ /**
5
+ * v0.2.0 agent read tool. Mirrors `GET /platform/audit` (lh-ops CLI has
6
+ * the same endpoint via `audit query`). All filters are AND-composed
7
+ * server-side; from/to are required.
8
+ *
9
+ * For common asks like "this week's events" the agent should compute the
10
+ * from/to in the user's timezone before calling — the backend doesn't
11
+ * accept relative ranges.
12
+ */
13
+ async function queryAudit(client, args) {
14
+ return client.request('/platform/audit', {
15
+ method: 'GET',
16
+ query: {
17
+ from: args.from,
18
+ to: args.to,
19
+ orgId: args.orgId,
20
+ actor: args.actor,
21
+ action: args.action,
22
+ limit: args.limit,
23
+ offset: args.offset,
24
+ },
25
+ });
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":";;AAiDA,gCAgBC;AAzBD;;;;;;;;GAQG;AACI,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,IAAoB;IAEpB,OAAO,MAAM,CAAC,OAAO,CAAe,iBAAiB,EAAE;QACrD,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Response payload from `GET /platform/cache-coverage` (#595) — platform-wide
4
+ * cache-hit audit: per model, how many rows returned prompt-cache tokens and
5
+ * the hit rate. Cross-org (cache behaviour is upstream-driven). Backs
6
+ * `lh-ops cache-coverage`.
7
+ */
8
+ export interface CacheCoverageModelRow {
9
+ model: string;
10
+ rows: number;
11
+ cacheTokens: number;
12
+ rowsWithCache: number;
13
+ pctCache: number;
14
+ }
15
+ export interface CacheCoveragePayload {
16
+ models: CacheCoverageModelRow[];
17
+ totals: {
18
+ rows: number;
19
+ cacheTokens: number;
20
+ rowsWithCache: number;
21
+ pctCache: number;
22
+ };
23
+ }
24
+ export declare function getCacheCoverage(client: Client): Promise<CacheCoveragePayload>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCacheCoverage = getCacheCoverage;
4
+ async function getCacheCoverage(client) {
5
+ return client.request('/platform/cache-coverage', {
6
+ method: 'GET',
7
+ });
8
+ }
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache-coverage/index.ts"],"names":[],"mappings":";;AA0BA,4CAMC;AANM,KAAK,UAAU,gBAAgB,CACpC,MAAc;IAEd,OAAO,MAAM,CAAC,OAAO,CAAuB,0BAA0B,EAAE;QACtE,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface ClientOptions {
2
+ apiBase: string;
3
+ token?: string;
4
+ }
5
+ export interface RequestOptions {
6
+ method?: string;
7
+ body?: unknown;
8
+ query?: Record<string, string | number | boolean | undefined>;
9
+ /**
10
+ * Extra request headers, merged on top of the defaults (content-type +
11
+ * Authorization). Used for optimistic-lock preconditions like
12
+ * `If-Match: <updatedAt>` on plan mutations (US-1).
13
+ */
14
+ headers?: Record<string, string>;
15
+ }
16
+ export declare class ApiError extends Error {
17
+ readonly status: number;
18
+ readonly body: unknown;
19
+ constructor(status: number, body: unknown, message: string);
20
+ }
21
+ export declare class Client {
22
+ private readonly opts;
23
+ constructor(opts: ClientOptions);
24
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
25
+ }
package/dist/client.js ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ // Canonical HTTP client for LH Enterprise backend. The single source of truth
3
+ // shared by lh-ops (CLI) and lh-ops-skill (MCP server) — historically each
4
+ // kept its own copy and they drifted by the time we had 3 tools in the skill.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Client = exports.ApiError = void 0;
7
+ class ApiError extends Error {
8
+ status;
9
+ body;
10
+ constructor(status, body, message) {
11
+ super(message);
12
+ this.status = status;
13
+ this.body = body;
14
+ this.name = 'ApiError';
15
+ }
16
+ }
17
+ exports.ApiError = ApiError;
18
+ class Client {
19
+ opts;
20
+ constructor(opts) {
21
+ this.opts = opts;
22
+ }
23
+ async request(path, options = {}) {
24
+ const url = new URL(this.opts.apiBase.replace(/\/$/, '') + path);
25
+ if (options.query) {
26
+ for (const [k, v] of Object.entries(options.query)) {
27
+ if (v !== undefined)
28
+ url.searchParams.set(k, String(v));
29
+ }
30
+ }
31
+ const headers = {
32
+ 'content-type': 'application/json',
33
+ };
34
+ if (this.opts.token)
35
+ headers.authorization = `Bearer ${this.opts.token}`;
36
+ if (options.headers)
37
+ Object.assign(headers, options.headers);
38
+ const res = await fetch(url, {
39
+ method: options.method ?? 'GET',
40
+ headers,
41
+ body: options.body !== undefined ? JSON.stringify(options.body) : undefined,
42
+ });
43
+ const text = await res.text();
44
+ let parsed = text;
45
+ if (text.length > 0) {
46
+ try {
47
+ parsed = JSON.parse(text);
48
+ }
49
+ catch {
50
+ // leave as text
51
+ }
52
+ }
53
+ if (!res.ok) {
54
+ throw new ApiError(res.status, parsed, `HTTP ${res.status} ${res.statusText} from ${options.method ?? 'GET'} ${url.pathname}`);
55
+ }
56
+ // LH backend wraps successful responses in a TransformInterceptor envelope:
57
+ // `{ data: <actual payload>, timestamp, ... }`. Unwrap for caller convenience.
58
+ if (parsed &&
59
+ typeof parsed === 'object' &&
60
+ !Array.isArray(parsed) &&
61
+ 'data' in parsed) {
62
+ return parsed.data;
63
+ }
64
+ return parsed;
65
+ }
66
+ }
67
+ exports.Client = Client;
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;;;AAmB9E,MAAa,QAAS,SAAQ,KAAK;IAEf;IACA;IAFlB,YACkB,MAAc,EACd,IAAa,EAC7B,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAS;QAI7B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AATD,4BASC;AAED,MAAa,MAAM;IACY;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,OAAO,CAAI,IAAY,EAAE,UAA0B,EAAE;QACzD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACjE,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnD,IAAI,CAAC,KAAK,SAAS;oBAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QACF,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,aAAa,GAAG,UAAU,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACzE,IAAI,OAAO,CAAC,OAAO;YAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE7D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;YAC/B,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC5E,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,MAAM,GAAY,IAAI,CAAC;QAC3B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,QAAQ,CAChB,GAAG,CAAC,MAAM,EACV,MAAM,EACN,QAAQ,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,SAAS,OAAO,CAAC,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC,QAAQ,EAAE,CACvF,CAAC;QACJ,CAAC;QAED,4EAA4E;QAC5E,+EAA+E;QAC/E,IACE,MAAM;YACN,OAAO,MAAM,KAAK,QAAQ;YAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACtB,MAAM,IAAK,MAAkC,EAC7C,CAAC;YACD,OAAQ,MAAsB,CAAC,IAAI,CAAC;QACtC,CAAC;QACD,OAAO,MAAW,CAAC;IACrB,CAAC;CACF;AArDD,wBAqDC"}
@@ -0,0 +1,29 @@
1
+ export { Client, ApiError } from './client';
2
+ export type { ClientOptions, RequestOptions } from './client';
3
+ export { listOrgs, getOrgTokens, renameOrg, provisionOrg, setOrgCurrency, } from './orgs';
4
+ export type { OrgListRow, ListOrgsArgs, OrgTokenInfo, RenamedOrg, ProvisionOrgArgs, ProvisionedOrg, SetOrgCurrencyArgs, OrgCurrency, } from './orgs';
5
+ export { getStatement } from './statement';
6
+ export type { StatementPayload, GetStatementArgs } from './statement';
7
+ export { getOrgUsage } from './org-usage';
8
+ export type { OrgUsageSummaryPayload, GetOrgUsageArgs } from './org-usage';
9
+ export { getCacheCoverage } from './cache-coverage';
10
+ export type { CacheCoveragePayload, CacheCoverageModelRow } from './cache-coverage';
11
+ export { evaluatePhase2State, loadPhase2Flags, savePhase2Flags, phase2Status, DEFAULT_STATE_PATH, PHASE2_BANNER, } from './phase2';
12
+ export type { Phase2Flags, Phase2Trigger, Phase2State, Phase2StatusResult, } from './phase2';
13
+ export { listApiKeys } from './api-keys';
14
+ export type { ApiKeyExportRow, ListApiKeysArgs } from './api-keys';
15
+ export { listMembers, unfreezeMember, setMemberBudgetCap, } from './member';
16
+ export type { MemberRow, ListMembersArgs } from './member';
17
+ export { queryAudit } from './audit';
18
+ export type { AuditEntry, QueryAuditArgs } from './audit';
19
+ export { listPlans, getPlan, updatePlan, archivePlan } from './plan';
20
+ export type { Plan, PlanQuota, PlanStatus, ListPlansArgs, UpdatePlanInput, } from './plan';
21
+ export { listPriceBooks } from './price-book';
22
+ export type { PriceBookSummary } from './price-book';
23
+ export { extendContract, addSubscription } from './subscription';
24
+ export type { Subscription, ExtendContractArgs, AddSubscriptionArgs, } from './subscription';
25
+ export { executeTopup } from './topup';
26
+ export type { ExecuteTopupArgs, TopupResult } from './topup';
27
+ export { listUpstreamModels } from './models';
28
+ export { issuePlatformToken, listPlatformTokens, revokePlatformToken, } from './platform-token';
29
+ export type { IssueTokenArgs, IssuedToken, TokenSummary, } from './platform-token';
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.revokePlatformToken = exports.listPlatformTokens = exports.issuePlatformToken = exports.listUpstreamModels = exports.executeTopup = exports.addSubscription = exports.extendContract = exports.listPriceBooks = exports.archivePlan = exports.updatePlan = exports.getPlan = exports.listPlans = exports.queryAudit = exports.setMemberBudgetCap = exports.unfreezeMember = exports.listMembers = exports.listApiKeys = exports.PHASE2_BANNER = exports.DEFAULT_STATE_PATH = exports.phase2Status = exports.savePhase2Flags = exports.loadPhase2Flags = exports.evaluatePhase2State = exports.getCacheCoverage = exports.getOrgUsage = exports.getStatement = exports.setOrgCurrency = exports.provisionOrg = exports.renameOrg = exports.getOrgTokens = exports.listOrgs = exports.ApiError = exports.Client = void 0;
4
+ // Public surface — both lh-ops and lh-ops-skill import from here.
5
+ var client_1 = require("./client");
6
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
7
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return client_1.ApiError; } });
8
+ var orgs_1 = require("./orgs");
9
+ Object.defineProperty(exports, "listOrgs", { enumerable: true, get: function () { return orgs_1.listOrgs; } });
10
+ Object.defineProperty(exports, "getOrgTokens", { enumerable: true, get: function () { return orgs_1.getOrgTokens; } });
11
+ Object.defineProperty(exports, "renameOrg", { enumerable: true, get: function () { return orgs_1.renameOrg; } });
12
+ Object.defineProperty(exports, "provisionOrg", { enumerable: true, get: function () { return orgs_1.provisionOrg; } });
13
+ Object.defineProperty(exports, "setOrgCurrency", { enumerable: true, get: function () { return orgs_1.setOrgCurrency; } });
14
+ var statement_1 = require("./statement");
15
+ Object.defineProperty(exports, "getStatement", { enumerable: true, get: function () { return statement_1.getStatement; } });
16
+ var org_usage_1 = require("./org-usage");
17
+ Object.defineProperty(exports, "getOrgUsage", { enumerable: true, get: function () { return org_usage_1.getOrgUsage; } });
18
+ var cache_coverage_1 = require("./cache-coverage");
19
+ Object.defineProperty(exports, "getCacheCoverage", { enumerable: true, get: function () { return cache_coverage_1.getCacheCoverage; } });
20
+ var phase2_1 = require("./phase2");
21
+ Object.defineProperty(exports, "evaluatePhase2State", { enumerable: true, get: function () { return phase2_1.evaluatePhase2State; } });
22
+ Object.defineProperty(exports, "loadPhase2Flags", { enumerable: true, get: function () { return phase2_1.loadPhase2Flags; } });
23
+ Object.defineProperty(exports, "savePhase2Flags", { enumerable: true, get: function () { return phase2_1.savePhase2Flags; } });
24
+ Object.defineProperty(exports, "phase2Status", { enumerable: true, get: function () { return phase2_1.phase2Status; } });
25
+ Object.defineProperty(exports, "DEFAULT_STATE_PATH", { enumerable: true, get: function () { return phase2_1.DEFAULT_STATE_PATH; } });
26
+ Object.defineProperty(exports, "PHASE2_BANNER", { enumerable: true, get: function () { return phase2_1.PHASE2_BANNER; } });
27
+ var api_keys_1 = require("./api-keys");
28
+ Object.defineProperty(exports, "listApiKeys", { enumerable: true, get: function () { return api_keys_1.listApiKeys; } });
29
+ var member_1 = require("./member");
30
+ Object.defineProperty(exports, "listMembers", { enumerable: true, get: function () { return member_1.listMembers; } });
31
+ Object.defineProperty(exports, "unfreezeMember", { enumerable: true, get: function () { return member_1.unfreezeMember; } });
32
+ Object.defineProperty(exports, "setMemberBudgetCap", { enumerable: true, get: function () { return member_1.setMemberBudgetCap; } });
33
+ var audit_1 = require("./audit");
34
+ Object.defineProperty(exports, "queryAudit", { enumerable: true, get: function () { return audit_1.queryAudit; } });
35
+ var plan_1 = require("./plan");
36
+ Object.defineProperty(exports, "listPlans", { enumerable: true, get: function () { return plan_1.listPlans; } });
37
+ Object.defineProperty(exports, "getPlan", { enumerable: true, get: function () { return plan_1.getPlan; } });
38
+ Object.defineProperty(exports, "updatePlan", { enumerable: true, get: function () { return plan_1.updatePlan; } });
39
+ Object.defineProperty(exports, "archivePlan", { enumerable: true, get: function () { return plan_1.archivePlan; } });
40
+ var price_book_1 = require("./price-book");
41
+ Object.defineProperty(exports, "listPriceBooks", { enumerable: true, get: function () { return price_book_1.listPriceBooks; } });
42
+ var subscription_1 = require("./subscription");
43
+ Object.defineProperty(exports, "extendContract", { enumerable: true, get: function () { return subscription_1.extendContract; } });
44
+ Object.defineProperty(exports, "addSubscription", { enumerable: true, get: function () { return subscription_1.addSubscription; } });
45
+ var topup_1 = require("./topup");
46
+ Object.defineProperty(exports, "executeTopup", { enumerable: true, get: function () { return topup_1.executeTopup; } });
47
+ var models_1 = require("./models");
48
+ Object.defineProperty(exports, "listUpstreamModels", { enumerable: true, get: function () { return models_1.listUpstreamModels; } });
49
+ var platform_token_1 = require("./platform-token");
50
+ Object.defineProperty(exports, "issuePlatformToken", { enumerable: true, get: function () { return platform_token_1.issuePlatformToken; } });
51
+ Object.defineProperty(exports, "listPlatformTokens", { enumerable: true, get: function () { return platform_token_1.listPlatformTokens; } });
52
+ Object.defineProperty(exports, "revokePlatformToken", { enumerable: true, get: function () { return platform_token_1.revokePlatformToken; } });
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAClE,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAGzB,+BAMgB;AALd,gGAAA,QAAQ,OAAA;AACR,oGAAA,YAAY,OAAA;AACZ,iGAAA,SAAS,OAAA;AACT,oGAAA,YAAY,OAAA;AACZ,sGAAA,cAAc,OAAA;AAahB,yCAA2C;AAAlC,yGAAA,YAAY,OAAA;AAGrB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AAEpB,mDAAoD;AAA3C,kHAAA,gBAAgB,OAAA;AAGzB,mCAOkB;AANhB,6GAAA,mBAAmB,OAAA;AACnB,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,sGAAA,YAAY,OAAA;AACZ,4GAAA,kBAAkB,OAAA;AAClB,uGAAA,aAAa,OAAA;AASf,uCAAyC;AAAhC,uGAAA,WAAW,OAAA;AAGpB,mCAIkB;AAHhB,qGAAA,WAAW,OAAA;AACX,wGAAA,cAAc,OAAA;AACd,4GAAA,kBAAkB,OAAA;AAIpB,iCAAqC;AAA5B,mGAAA,UAAU,OAAA;AAGnB,+BAAqE;AAA5D,iGAAA,SAAS,OAAA;AAAE,+FAAA,OAAO,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA;AASpD,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAGvB,+CAAiE;AAAxD,8GAAA,cAAc,OAAA;AAAE,+GAAA,eAAe,OAAA;AAOxC,iCAAuC;AAA9B,qGAAA,YAAY,OAAA;AAGrB,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAE3B,mDAI0B;AAHxB,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAClB,qHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,49 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * One row from `GET /platform/orgs/:orgId/members` (#307). Mirrors the
4
+ * Prisma `Member` model returned by `MemberService.findAll` — the same shape
5
+ * the EA `GET /organizations/:orgId/members` endpoint returns, but reachable
6
+ * by a scoped `read:members` platform token (the MCP credential is a
7
+ * PlatformOperator that can only hit `/platform/*` routes).
8
+ *
9
+ * Backed by the actual model (schema.prisma `model Member`): no `seat` /
10
+ * `role` field — members are people in an org, not seat assignments.
11
+ */
12
+ export interface MemberRow {
13
+ id: string;
14
+ orgId: string;
15
+ name: string;
16
+ email: string;
17
+ department: string | null;
18
+ status: 'ACTIVE' | 'INACTIVE' | 'FROZEN';
19
+ dailyBudgetCap?: number | string | null;
20
+ frozenAt?: string | null;
21
+ frozenReason?: string | null;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }
25
+ export interface ListMembersArgs {
26
+ orgId: string;
27
+ department?: string;
28
+ }
29
+ /**
30
+ * v0.2.0 agent read tool (`list_members`). Answers "who are my admins?",
31
+ * "我们组里有谁", "市场部有几个人". Optional `department` filters server-side
32
+ * (mirrors the EA endpoint's `?department=` filter).
33
+ */
34
+ export declare function listMembers(client: Client, args: ListMembersArgs): Promise<MemberRow[]>;
35
+ /**
36
+ * #574 (ADR-028) — lift a budget-guardian freeze for a member (FROZEN →
37
+ * ACTIVE). Mirrors `POST /platform/orgs/:orgId/members/:memberId/unfreeze`.
38
+ * Token must carry `write:orgs`. Backend returns 409 if the member is not
39
+ * frozen (nothing to unfreeze).
40
+ */
41
+ export declare function unfreezeMember(client: Client, orgId: string, memberId: string): Promise<MemberRow>;
42
+ /**
43
+ * #574 (ADR-028 #558 / ADR-026) — set or clear a member's daily budget cap.
44
+ * The amount is in the org's SETTLEMENT currency (backend converts to
45
+ * USD-canonical for storage). `null` clears the cap (member unbounded).
46
+ * Mirrors `PATCH /platform/orgs/:orgId/members/:memberId/budget-cap`. Token
47
+ * must carry `write:orgs`.
48
+ */
49
+ export declare function setMemberBudgetCap(client: Client, orgId: string, memberId: string, dailyBudgetCap: number | null): Promise<MemberRow>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listMembers = listMembers;
4
+ exports.unfreezeMember = unfreezeMember;
5
+ exports.setMemberBudgetCap = setMemberBudgetCap;
6
+ /**
7
+ * v0.2.0 agent read tool (`list_members`). Answers "who are my admins?",
8
+ * "我们组里有谁", "市场部有几个人". Optional `department` filters server-side
9
+ * (mirrors the EA endpoint's `?department=` filter).
10
+ */
11
+ async function listMembers(client, args) {
12
+ return client.request(`/platform/orgs/${encodeURIComponent(args.orgId)}/members`, {
13
+ method: 'GET',
14
+ query: {
15
+ department: args.department,
16
+ },
17
+ });
18
+ }
19
+ /**
20
+ * #574 (ADR-028) — lift a budget-guardian freeze for a member (FROZEN →
21
+ * ACTIVE). Mirrors `POST /platform/orgs/:orgId/members/:memberId/unfreeze`.
22
+ * Token must carry `write:orgs`. Backend returns 409 if the member is not
23
+ * frozen (nothing to unfreeze).
24
+ */
25
+ async function unfreezeMember(client, orgId, memberId) {
26
+ return client.request(`/platform/orgs/${encodeURIComponent(orgId)}/members/${encodeURIComponent(memberId)}/unfreeze`, { method: 'POST' });
27
+ }
28
+ /**
29
+ * #574 (ADR-028 #558 / ADR-026) — set or clear a member's daily budget cap.
30
+ * The amount is in the org's SETTLEMENT currency (backend converts to
31
+ * USD-canonical for storage). `null` clears the cap (member unbounded).
32
+ * Mirrors `PATCH /platform/orgs/:orgId/members/:memberId/budget-cap`. Token
33
+ * must carry `write:orgs`.
34
+ */
35
+ async function setMemberBudgetCap(client, orgId, memberId, dailyBudgetCap) {
36
+ return client.request(`/platform/orgs/${encodeURIComponent(orgId)}/members/${encodeURIComponent(memberId)}/budget-cap`, { method: 'PATCH', body: { dailyBudgetCap } });
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/member/index.ts"],"names":[],"mappings":";;AA0CA,kCAaC;AAQD,wCAWC;AASD,gDAYC;AA1DD;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,IAAqB;IAErB,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAC1D;QACE,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B;KACF,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,KAAa,EACb,QAAgB;IAEhB,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,KAAK,CAAC,YAAY,kBAAkB,CACvE,QAAQ,CACT,WAAW,EACZ,EAAE,MAAM,EAAE,MAAM,EAAE,CACnB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,KAAa,EACb,QAAgB,EAChB,cAA6B;IAE7B,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,KAAK,CAAC,YAAY,kBAAkB,CACvE,QAAQ,CACT,aAAa,EACd,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,EAAE,CAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Operator view of the upstream new-api model catalog (canary prep, #445).
4
+ * These are the canonical model names usable in plan / price-book authoring.
5
+ * Read-only; proxies `GET /platform/models` → new-api `/v1/models`.
6
+ */
7
+ export declare function listUpstreamModels(client: Client): Promise<string[]>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listUpstreamModels = listUpstreamModels;
4
+ /**
5
+ * Operator view of the upstream new-api model catalog (canary prep, #445).
6
+ * These are the canonical model names usable in plan / price-book authoring.
7
+ * Read-only; proxies `GET /platform/models` → new-api `/v1/models`.
8
+ */
9
+ async function listUpstreamModels(client) {
10
+ const body = await client.request('/platform/models', {
11
+ method: 'GET',
12
+ });
13
+ return body.models;
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;AAOA,gDAKC;AAVD;;;;GAIG;AACI,KAAK,UAAU,kBAAkB,CAAC,MAAc;IACrD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAuB,kBAAkB,EAAE;QAC1E,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { Client } from '../client';
2
+ /**
3
+ * Response payload from `GET /platform/orgs/:orgId/usage` (#589) — all-time
4
+ * reconciliation view: current balance + lifetime deposits/charges + usage
5
+ * by billing-decision + by model. Counterpart to StatementPayload (monthly).
6
+ *
7
+ * All amounts are USD-canonical; `currency` + `contractRate` let the caller
8
+ * render the display currency (balance × contractRate).
9
+ */
10
+ export interface OrgUsageSummaryPayload {
11
+ orgId: string;
12
+ name: string;
13
+ balance: string;
14
+ currency: string;
15
+ contractRate: string | null;
16
+ deposits: {
17
+ count: number;
18
+ amount: string;
19
+ };
20
+ charges: {
21
+ count: number;
22
+ amount: string;
23
+ };
24
+ totals: {
25
+ requests: number;
26
+ cost: string;
27
+ firstSeen: string | null;
28
+ lastSeen: string | null;
29
+ };
30
+ byBillingDecision: Array<{
31
+ billingDecision: string;
32
+ requests: number;
33
+ cost: string;
34
+ }>;
35
+ byModel: Array<{
36
+ model: string;
37
+ requests: number;
38
+ promptTokens: number;
39
+ completionTokens: number;
40
+ cacheTokens: number;
41
+ cost: string;
42
+ }>;
43
+ }
44
+ export interface GetOrgUsageArgs {
45
+ orgId: string;
46
+ }
47
+ export declare function getOrgUsage(client: Client, args: GetOrgUsageArgs): Promise<OrgUsageSummaryPayload>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOrgUsage = getOrgUsage;
4
+ async function getOrgUsage(client, args) {
5
+ return client.request(`/platform/orgs/${encodeURIComponent(args.orgId)}/usage`, { method: 'GET' });
6
+ }
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/org-usage/index.ts"],"names":[],"mappings":";;AA2CA,kCAQC;AARM,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,IAAqB;IAErB,OAAO,MAAM,CAAC,OAAO,CACnB,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EACxD,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;AACJ,CAAC"}