@possibl/rcrt-sdk 0.1.2 → 0.5.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 (108) hide show
  1. package/CHANGELOG.md +99 -62
  2. package/LICENSE +21 -0
  3. package/README.md +35 -21
  4. package/dist/auth.d.ts +45 -0
  5. package/dist/auth.d.ts.map +1 -0
  6. package/{src/auth.ts → dist/auth.js} +9 -24
  7. package/dist/auth.js.map +1 -0
  8. package/dist/authn.d.ts +114 -0
  9. package/dist/authn.d.ts.map +1 -0
  10. package/dist/authn.js +107 -0
  11. package/dist/authn.js.map +1 -0
  12. package/dist/breadcrumbs.d.ts +43 -0
  13. package/dist/breadcrumbs.d.ts.map +1 -0
  14. package/dist/breadcrumbs.js +122 -0
  15. package/dist/breadcrumbs.js.map +1 -0
  16. package/dist/cards.d.ts +28 -0
  17. package/dist/cards.d.ts.map +1 -0
  18. package/dist/cards.js +105 -0
  19. package/dist/cards.js.map +1 -0
  20. package/dist/chat.d.ts +103 -0
  21. package/dist/chat.d.ts.map +1 -0
  22. package/dist/chat.js +105 -0
  23. package/dist/chat.js.map +1 -0
  24. package/dist/client.d.ts +85 -0
  25. package/dist/client.d.ts.map +1 -0
  26. package/dist/client.js +133 -0
  27. package/dist/client.js.map +1 -0
  28. package/dist/errors.d.ts +32 -0
  29. package/dist/errors.d.ts.map +1 -0
  30. package/dist/errors.js +76 -0
  31. package/dist/errors.js.map +1 -0
  32. package/dist/files.d.ts +41 -0
  33. package/dist/files.d.ts.map +1 -0
  34. package/dist/files.js +64 -0
  35. package/dist/files.js.map +1 -0
  36. package/dist/generated/conformance.d.ts +48 -0
  37. package/dist/generated/conformance.d.ts.map +1 -0
  38. package/dist/generated/conformance.js +24 -0
  39. package/dist/generated/conformance.js.map +1 -0
  40. package/dist/generated/index.d.ts +34 -0
  41. package/dist/generated/index.d.ts.map +1 -0
  42. package/dist/generated/index.js +34 -0
  43. package/dist/generated/index.js.map +1 -0
  44. package/dist/generated/openapi.d.ts +3900 -0
  45. package/dist/generated/openapi.d.ts.map +1 -0
  46. package/dist/generated/openapi.js +6 -0
  47. package/dist/generated/openapi.js.map +1 -0
  48. package/dist/grants.d.ts +41 -0
  49. package/dist/grants.d.ts.map +1 -0
  50. package/dist/grants.js +50 -0
  51. package/dist/grants.js.map +1 -0
  52. package/dist/index.d.ts +34 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +24 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/internal/fetch.d.ts +47 -0
  57. package/dist/internal/fetch.d.ts.map +1 -0
  58. package/dist/internal/fetch.js +108 -0
  59. package/dist/internal/fetch.js.map +1 -0
  60. package/dist/internal/sse.d.ts +82 -0
  61. package/dist/internal/sse.d.ts.map +1 -0
  62. package/dist/internal/sse.js +161 -0
  63. package/dist/internal/sse.js.map +1 -0
  64. package/dist/marketplace.d.ts +98 -0
  65. package/dist/marketplace.d.ts.map +1 -0
  66. package/dist/marketplace.js +74 -0
  67. package/dist/marketplace.js.map +1 -0
  68. package/dist/members.d.ts +60 -0
  69. package/dist/members.d.ts.map +1 -0
  70. package/dist/members.js +74 -0
  71. package/dist/members.js.map +1 -0
  72. package/dist/org.d.ts +85 -0
  73. package/dist/org.d.ts.map +1 -0
  74. package/dist/org.js +70 -0
  75. package/dist/org.js.map +1 -0
  76. package/dist/types/breadcrumb.d.ts +70 -0
  77. package/dist/types/breadcrumb.d.ts.map +1 -0
  78. package/dist/types/breadcrumb.js +8 -0
  79. package/dist/types/breadcrumb.js.map +1 -0
  80. package/dist/types/card.d.ts +251 -0
  81. package/dist/types/card.d.ts.map +1 -0
  82. package/dist/types/card.js +10 -0
  83. package/dist/types/card.js.map +1 -0
  84. package/dist/types/engine.d.ts +69 -0
  85. package/dist/types/engine.d.ts.map +1 -0
  86. package/dist/types/engine.js +53 -0
  87. package/dist/types/engine.js.map +1 -0
  88. package/dist/types/index.d.ts +4 -0
  89. package/dist/types/index.d.ts.map +1 -0
  90. package/dist/types/index.js +4 -0
  91. package/dist/types/index.js.map +1 -0
  92. package/package.json +35 -6
  93. package/src/authn.ts +0 -159
  94. package/src/breadcrumbs.ts +0 -111
  95. package/src/capabilities.ts +0 -93
  96. package/src/cards.ts +0 -109
  97. package/src/chat.ts +0 -83
  98. package/src/client.ts +0 -97
  99. package/src/errors.ts +0 -101
  100. package/src/files.ts +0 -135
  101. package/src/grants.ts +0 -99
  102. package/src/index.ts +0 -103
  103. package/src/internal/fetch.ts +0 -133
  104. package/src/internal/sse.ts +0 -236
  105. package/src/sessions.ts +0 -110
  106. package/src/types/breadcrumb.ts +0 -77
  107. package/src/types/card.ts +0 -298
  108. package/src/types/index.ts +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/internal/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,yEAAyE;IACzE,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CA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,IAAI,IAAI,CAAC;IACd,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IACnF,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,KAAK,IAAI,IAAI,CAAC;IACd,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;CAClD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,GAAG,aAAa,CA6ItF"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * SSE client with automatic reconnection + typed event dispatch.
3
+ *
4
+ * Works in three environments:
5
+ * - Browsers: uses the built-in `EventSource`. Auth goes via query
6
+ * params because `EventSource` can't set custom headers.
7
+ * - Node 18+: uses the built-in `EventSource` (Node 22+) or a
8
+ * pluggable polyfill (see `config.eventSource`).
9
+ * - React Native: install `react-native-sse` and pass its
10
+ * constructor as `config.eventSource`. Custom headers work there.
11
+ *
12
+ * Subscribers get typed events. Streams auto-reconnect with
13
+ * exponential backoff unless `close()` was called explicitly.
14
+ */
15
+ export function connect(config, handlers) {
16
+ const maxBackoff = config.maxBackoffMs ?? 30_000;
17
+ let backoff = 1_000;
18
+ let closed = false;
19
+ let es = null;
20
+ let state = 'connecting';
21
+ let reconnectTimer = null;
22
+ async function open() {
23
+ if (closed)
24
+ return;
25
+ const token = await config.getToken();
26
+ const u = new URL(config.apiUrl.replace(/\/$/, '') + config.path);
27
+ if (config.query) {
28
+ for (const [k, v] of Object.entries(config.query)) {
29
+ u.searchParams.set(k, v);
30
+ }
31
+ }
32
+ const EventSourceCtor = (config.eventSource
33
+ ?? globalThis.EventSource);
34
+ if (!EventSourceCtor) {
35
+ handlers.onError?.({ message: 'No EventSource implementation available. Pass config.eventSource for React Native.', fatal: true }, true);
36
+ closed = true;
37
+ state = 'closed';
38
+ return;
39
+ }
40
+ // Prefer header auth when the EventSource impl supports it (React
41
+ // Native with `react-native-sse`, Node 22+, any custom
42
+ // `config.eventSource` that accepts a `headers` init). The browser's
43
+ // built-in EventSource constructor has NO support for custom
44
+ // headers — there's no proposal in the WHATWG spec to change that —
45
+ // so when we're stuck with it we fall back to passing the bearer
46
+ // token and tenant ID as query params.
47
+ //
48
+ // Security note (Sonar hotspot review): tokens in URLs are a
49
+ // documented smell — they can leak via proxy logs, HTTP Referer
50
+ // headers, and browser history. We mitigate:
51
+ // * TLS is assumed (RCRT's api-gateway rejects plaintext HTTP).
52
+ // * Firebase ID tokens are short-lived (60 min) and auto-rotated.
53
+ // A leaked token in a server log expires fast; it can't be used
54
+ // to escalate outside the scope Firebase already granted.
55
+ // * `tk_*` workspace API keys are long-lived and should NEVER be
56
+ // passed through this path. Callers holding a tk_ key are
57
+ // server-side and must set `useHeaderAuth: true`. The SDK docs
58
+ // and the TokenProvider interface make this explicit.
59
+ // * This fallback only triggers for SSE subscriptions. The regular
60
+ // fetch-based surface (`src/internal/fetch.ts`) always uses the
61
+ // Authorization header.
62
+ // Without this fallback the SDK cannot open SSE connections from a
63
+ // browser at all, which would break every chat UI built on RCRT.
64
+ const init = {};
65
+ if (config.useHeaderAuth) {
66
+ init.headers = {
67
+ Authorization: `Bearer ${token}`,
68
+ ...(config.tenantId ? { 'X-Tenant-ID': config.tenantId } : {}),
69
+ };
70
+ }
71
+ else {
72
+ u.searchParams.set('token', token); // NOSONAR - required for browser EventSource; see block comment above
73
+ if (config.tenantId)
74
+ u.searchParams.set('tenant_id', config.tenantId);
75
+ }
76
+ try {
77
+ es = new EventSourceCtor(u.toString(), init);
78
+ }
79
+ catch (err) {
80
+ handlers.onError?.({ message: err.message, fatal: true }, true);
81
+ scheduleReconnect();
82
+ return;
83
+ }
84
+ es.onopen = () => {
85
+ backoff = 1_000;
86
+ state = 'open';
87
+ handlers.onOpen?.();
88
+ };
89
+ es.addEventListener('connected', (e) => {
90
+ const data = tryJson(e.data);
91
+ handlers.onConnected?.(data);
92
+ });
93
+ es.addEventListener('delta', (e) => {
94
+ const data = tryJson(e.data);
95
+ if (data)
96
+ handlers.onDelta?.(data);
97
+ });
98
+ es.addEventListener('message', (e) => {
99
+ const data = tryJson(e.data);
100
+ if (data)
101
+ handlers.onMessage?.(data);
102
+ });
103
+ es.addEventListener('thought', (e) => {
104
+ const data = tryJson(e.data);
105
+ if (data)
106
+ handlers.onThought?.(data);
107
+ });
108
+ es.addEventListener('action', (e) => {
109
+ const data = tryJson(e.data);
110
+ if (data)
111
+ handlers.onAction?.(data);
112
+ });
113
+ es.addEventListener('error', (e) => {
114
+ const data = tryJson(e?.data ?? '');
115
+ handlers.onError?.(data ?? { message: 'stream error' }, false);
116
+ });
117
+ es.onerror = () => {
118
+ state = 'closed';
119
+ handlers.onClose?.();
120
+ es?.close();
121
+ es = null;
122
+ scheduleReconnect();
123
+ };
124
+ }
125
+ function scheduleReconnect() {
126
+ if (closed)
127
+ return;
128
+ state = 'connecting';
129
+ const delay = backoff + Math.floor(Math.random() * 500);
130
+ backoff = Math.min(maxBackoff, backoff * 2);
131
+ reconnectTimer = setTimeout(() => {
132
+ reconnectTimer = null;
133
+ void open();
134
+ }, delay);
135
+ }
136
+ void open();
137
+ return {
138
+ close() {
139
+ closed = true;
140
+ state = 'closed';
141
+ if (reconnectTimer)
142
+ clearTimeout(reconnectTimer);
143
+ es?.close();
144
+ es = null;
145
+ },
146
+ get state() {
147
+ return state;
148
+ },
149
+ };
150
+ }
151
+ function tryJson(raw) {
152
+ if (typeof raw !== 'string' || !raw)
153
+ return undefined;
154
+ try {
155
+ return JSON.parse(raw);
156
+ }
157
+ catch {
158
+ return undefined;
159
+ }
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AK,EAAE,CAAC;YACZ,EAAE,GAAG,IAAI,CAAC;QACZ,CAAC;QACD,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAc,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IACtD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Marketplace module — bundle catalogue, install state and lifecycle.
3
+ *
4
+ * Mirrors the gateway's `/v1/marketplace/*` surface:
5
+ *
6
+ * GET /v1/marketplace/bundles list catalogue bundles
7
+ * GET /v1/marketplace/bundles/{scope}/{bundle} one bundle definition
8
+ * GET /v1/marketplace/bundles/{scope}/{bundle}/status install status in this workspace
9
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/install install into this workspace
10
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/update upgrade install to latest published
11
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/repair re-install drifted items
12
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/prune remove items dropped from the bundle
13
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/uninstall remove the install
14
+ * GET /v1/marketplace/installed/bundles all bundle installs in this workspace
15
+ *
16
+ * All calls run against the client's current tenant — use
17
+ * `client.forTenant(id)` for fleet fan-out across workspaces.
18
+ */
19
+ import type { FetchContext } from './internal/fetch.js';
20
+ /** Where a marketplace bundle is published. */
21
+ export type BundleScope = 'platform' | 'org' | 'tenant';
22
+ /** Per-item state inside a bundle install. */
23
+ export interface BundleItemStatus {
24
+ name: string;
25
+ /** e.g. current | drifted | missing */
26
+ status: string;
27
+ }
28
+ /**
29
+ * One bundle's install state in the active workspace, as returned by
30
+ * `GET /v1/marketplace/installed/bundles` and `.../status`.
31
+ */
32
+ export interface BundleStatus {
33
+ bundle_name: string;
34
+ /** current | update_available | drifted | prune_available | not_installed | … */
35
+ status: string;
36
+ installed?: boolean;
37
+ effective_source?: {
38
+ display_name?: string;
39
+ version?: string;
40
+ scope?: string;
41
+ };
42
+ install_record?: {
43
+ installed_version?: string;
44
+ source_scope?: string;
45
+ };
46
+ item_statuses?: BundleItemStatus[];
47
+ missing_item_names?: string[];
48
+ removed_item_names?: string[];
49
+ }
50
+ /** Per-item outcome of an install / update / repair call. */
51
+ export interface BundleItemResult {
52
+ name: string;
53
+ /** created | updated | platform (skipped — platform-scope copy exists) | error */
54
+ status: string;
55
+ error?: string;
56
+ }
57
+ /** A catalogue bundle (`GET /v1/marketplace/bundles`). */
58
+ export interface BundleSummary {
59
+ name: string;
60
+ scope: string;
61
+ display_name?: string;
62
+ description?: string;
63
+ version?: string;
64
+ item_count?: number;
65
+ items?: Array<{
66
+ name: string;
67
+ kind?: string;
68
+ }>;
69
+ [key: string]: unknown;
70
+ }
71
+ export declare class MarketplaceModule {
72
+ private readonly ctx;
73
+ constructor(ctx: FetchContext);
74
+ /** All bundle installs in the active workspace, with version/drift status. */
75
+ listInstalledBundles(): Promise<BundleStatus[]>;
76
+ /** Catalogue of bundles visible from the active workspace. */
77
+ listBundles(): Promise<BundleSummary[]>;
78
+ /** One bundle's definition. */
79
+ getBundle(scope: BundleScope, bundle: string): Promise<BundleSummary>;
80
+ /** Install status of one bundle in the active workspace. */
81
+ bundleStatus(scope: BundleScope, bundle: string): Promise<BundleStatus>;
82
+ /** Install a bundle into the active workspace. */
83
+ installBundle(scope: BundleScope, bundle: string): Promise<BundleItemResult[]>;
84
+ /**
85
+ * Upgrade an installed bundle to the latest published version.
86
+ * Items that also exist at platform scope are skipped (status
87
+ * `"platform"`), so callers can detect no-op updates.
88
+ */
89
+ updateBundle(scope: BundleScope, bundle: string): Promise<BundleItemResult[]>;
90
+ /** Re-install drifted items from the published source. */
91
+ repairBundle(scope: BundleScope, bundle: string): Promise<BundleItemResult[]>;
92
+ /** Remove installed items that were dropped from the bundle definition. */
93
+ pruneBundle(scope: BundleScope, bundle: string): Promise<BundleItemResult[]>;
94
+ /** Uninstall a bundle from the active workspace. */
95
+ uninstallBundle(scope: BundleScope, bundle: string): Promise<BundleItemResult[]>;
96
+ private lifecycle;
97
+ }
98
+ //# sourceMappingURL=marketplace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../src/marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAExD,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,cAAc,CAAC,EAAE;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,WAAW,g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K,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAInF,2EAA2E;IACrE,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIlF,oDAAoD;IAC9C,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAIxE,SAAS;CAaxB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Marketplace module — bundle catalogue, install state and lifecycle.
3
+ *
4
+ * Mirrors the gateway's `/v1/marketplace/*` surface:
5
+ *
6
+ * GET /v1/marketplace/bundles list catalogue bundles
7
+ * GET /v1/marketplace/bundles/{scope}/{bundle} one bundle definition
8
+ * GET /v1/marketplace/bundles/{scope}/{bundle}/status install status in this workspace
9
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/install install into this workspace
10
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/update upgrade install to latest published
11
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/repair re-install drifted items
12
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/prune remove items dropped from the bundle
13
+ * POST /v1/marketplace/bundles/{scope}/{bundle}/uninstall remove the install
14
+ * GET /v1/marketplace/installed/bundles all bundle installs in this workspace
15
+ *
16
+ * All calls run against the client's current tenant — use
17
+ * `client.forTenant(id)` for fleet fan-out across workspaces.
18
+ */
19
+ import { request } from './internal/fetch.js';
20
+ export class MarketplaceModule {
21
+ ctx;
22
+ constructor(ctx) {
23
+ this.ctx = ctx;
24
+ }
25
+ /** All bundle installs in the active workspace, with version/drift status. */
26
+ async listInstalledBundles() {
27
+ const res = await request(this.ctx, '/v1/marketplace/installed/bundles');
28
+ return Array.isArray(res) ? res : (res?.bundles ?? []);
29
+ }
30
+ /** Catalogue of bundles visible from the active workspace. */
31
+ async listBundles() {
32
+ const res = await request(this.ctx, '/v1/marketplace/bundles');
33
+ return Array.isArray(res) ? res : (res?.bundles ?? []);
34
+ }
35
+ /** One bundle's definition. */
36
+ async getBundle(scope, bundle) {
37
+ return request(this.ctx, `/v1/marketplace/bundles/${scope}/${encodeURIComponent(bundle)}`);
38
+ }
39
+ /** Install status of one bundle in the active workspace. */
40
+ async bundleStatus(scope, bundle) {
41
+ return request(this.ctx, `/v1/marketplace/bundles/${scope}/${encodeURIComponent(bundle)}/status`);
42
+ }
43
+ /** Install a bundle into the active workspace. */
44
+ async installBundle(scope, bundle) {
45
+ return this.lifecycle(scope, bundle, 'install');
46
+ }
47
+ /**
48
+ * Upgrade an installed bundle to the latest published version.
49
+ * Items that also exist at platform scope are skipped (status
50
+ * `"platform"`), so callers can detect no-op updates.
51
+ */
52
+ async updateBundle(scope, bundle) {
53
+ return this.lifecycle(scope, bundle, 'update');
54
+ }
55
+ /** Re-install drifted items from the published source. */
56
+ async repairBundle(scope, bundle) {
57
+ return this.lifecycle(scope, bundle, 'repair');
58
+ }
59
+ /** Remove installed items that were dropped from the bundle definition. */
60
+ async pruneBundle(scope, bundle) {
61
+ return this.lifecycle(scope, bundle, 'prune');
62
+ }
63
+ /** Uninstall a bundle from the active workspace. */
64
+ async uninstallBundle(scope, bundle) {
65
+ return this.lifecycle(scope, bundle, 'uninstall');
66
+ }
67
+ async lifecycle(scope, bundle, action) {
68
+ const res = await request(this.ctx, `/v1/marketplace/bundles/${scope}/${encodeURIComponent(bundle)}/${action}`, { method: 'POST', body: {} });
69
+ if (Array.isArray(res))
70
+ return res;
71
+ return res?.items ?? [];
72
+ }
73
+ }
74
+ //# sourceMappingURL=marketplace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketplace.js","sourceRoot":"","sources":["../src/marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAuD9C,MAAM,OAAO,iBAAiB;IACC;I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SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,YAAY,CAAC,KAAkB,EAAE,MAAc;QACnD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,WAAW,CAAC,KAAkB,EAAE,MAAc;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,eAAe,CAAC,KAAkB,EAAE,MAAc;QACtD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;IAEO,KAAK,CAAC,SAAS,CACrB,KAAkB,EAClB,MAAc,EACd,MAA+D;QAE/D,MAAM,GAAG,GAAG,MAAM,OAAO,CACvB,IAAI,CAAC,GAAG,EACR,2BAA2B,KAAK,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,EAC1E,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAC7B,CAAC;QACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QACnC,OAAO,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Members module — workspace membership + invitations.
3
+ *
4
+ * GET/POST /v1/tenants/{tenant_id}/members
5
+ * PUT/DELETE /v1/tenants/{tenant_id}/members/{user_id}
6
+ * GET/POST /v1/tenants/{tenant_id}/invitations
7
+ * DELETE /v1/tenants/{tenant_id}/invitations/{invitation_id}
8
+ *
9
+ * Accept/decline/pending live on the IdentityModule (`auth.*`) because
10
+ * they are keyed by the *caller's* email, not a workspace.
11
+ *
12
+ * Note: creating an invitation also sends the invite email server-side;
13
+ * there is no separate "resend" endpoint — re-create to resend.
14
+ */
15
+ import type { FetchContext } from './internal/fetch.js';
16
+ export interface TenantMember {
17
+ id: string;
18
+ email: string;
19
+ name: string;
20
+ avatar_url?: string | null;
21
+ role: string;
22
+ joined_at: string;
23
+ }
24
+ export interface TenantInvitation {
25
+ id: string;
26
+ email: string;
27
+ role: string;
28
+ status: 'pending' | 'accepted' | 'declined' | 'expired' | 'cancelled' | string;
29
+ created_at?: string;
30
+ expires_at?: string | null;
31
+ invited_by_name?: string | null;
32
+ invited_by_email?: string | null;
33
+ }
34
+ export declare class MembersModule {
35
+ private readonly ctx;
36
+ constructor(ctx: FetchContext);
37
+ private tenant;
38
+ /** `GET /v1/tenants/{id}/members` */
39
+ list(tenantId?: string): Promise<TenantMember[]>;
40
+ /** `POST /v1/tenants/{id}/members` — direct add (caller must know the user id). */
41
+ add(userId: string, role: string, tenantId?: string): Promise<void>;
42
+ /** `PUT /v1/tenants/{id}/members/{userId}` — change a member's role. */
43
+ updateRole(userId: string, role: string, tenantId?: string): Promise<void>;
44
+ /** `DELETE /v1/tenants/{id}/members/{userId}` */
45
+ remove(userId: string, tenantId?: string): Promise<void>;
46
+ /** `GET /v1/tenants/{id}/invitations` — all invitations incl. resolved ones. */
47
+ listInvitations(tenantId?: string): Promise<TenantInvitation[]>;
48
+ /**
49
+ * `POST /v1/tenants/{id}/invitations` — creates the invite AND sends
50
+ * the email. Role defaults server-side to 'member'.
51
+ */
52
+ invite(email: string, options?: {
53
+ role?: string;
54
+ message?: string;
55
+ tenantId?: string;
56
+ }): Promise<TenantInvitation>;
57
+ /** `DELETE /v1/tenants/{id}/invitations/{invId}` — soft-cancel (status → cancelled). */
58
+ cancelInvitation(invitationId: string, tenantId?: string): Promise<void>;
59
+ }
60
+ //# sourceMappingURL=members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../src/members.ts"],"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M,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9D,gFAAgF;IAC1E,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQrE;;;OAGG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GACnE,OAAO,CAAC,gBAAgB,CAAC;IAO5B,wFAAwF;IAClF,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/E"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Members module — workspace membership + invitations.
3
+ *
4
+ * GET/POST /v1/tenants/{tenant_id}/members
5
+ * PUT/DELETE /v1/tenants/{tenant_id}/members/{user_id}
6
+ * GET/POST /v1/tenants/{tenant_id}/invitations
7
+ * DELETE /v1/tenants/{tenant_id}/invitations/{invitation_id}
8
+ *
9
+ * Accept/decline/pending live on the IdentityModule (`auth.*`) because
10
+ * they are keyed by the *caller's* email, not a workspace.
11
+ *
12
+ * Note: creating an invitation also sends the invite email server-side;
13
+ * there is no separate "resend" endpoint — re-create to resend.
14
+ */
15
+ import { request } from './internal/fetch.js';
16
+ export class MembersModule {
17
+ ctx;
18
+ constructor(ctx) {
19
+ this.ctx = ctx;
20
+ }
21
+ tenant(tenantId) {
22
+ const id = tenantId ?? this.ctx.tenantId;
23
+ if (!id)
24
+ throw new Error('MembersModule requires a tenant id (set via setTenantId or pass explicitly)');
25
+ return id;
26
+ }
27
+ /** `GET /v1/tenants/{id}/members` */
28
+ async list(tenantId) {
29
+ const res = await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/members`);
30
+ return res.members ?? [];
31
+ }
32
+ /** `POST /v1/tenants/{id}/members` — direct add (caller must know the user id). */
33
+ async add(userId, role, tenantId) {
34
+ await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/members`, {
35
+ method: 'POST',
36
+ body: { user_id: userId, role },
37
+ });
38
+ }
39
+ /** `PUT /v1/tenants/{id}/members/{userId}` — change a member's role. */
40
+ async updateRole(userId, role, tenantId) {
41
+ await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/members/${userId}`, {
42
+ method: 'PUT',
43
+ body: { role },
44
+ });
45
+ }
46
+ /** `DELETE /v1/tenants/{id}/members/{userId}` */
47
+ async remove(userId, tenantId) {
48
+ await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/members/${userId}`, {
49
+ method: 'DELETE',
50
+ });
51
+ }
52
+ /** `GET /v1/tenants/{id}/invitations` — all invitations incl. resolved ones. */
53
+ async listInvitations(tenantId) {
54
+ const res = await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/invitations`);
55
+ return res.invitations ?? [];
56
+ }
57
+ /**
58
+ * `POST /v1/tenants/{id}/invitations` — creates the invite AND sends
59
+ * the email. Role defaults server-side to 'member'.
60
+ */
61
+ async invite(email, options = {}) {
62
+ return request(this.ctx, `/v1/tenants/${this.tenant(options.tenantId)}/invitations`, {
63
+ method: 'POST',
64
+ body: { email, role: options.role, message: options.message },
65
+ });
66
+ }
67
+ /** `DELETE /v1/tenants/{id}/invitations/{invId}` — soft-cancel (status → cancelled). */
68
+ async cancelInvitation(invitationId, tenantId) {
69
+ await request(this.ctx, `/v1/tenants/${this.tenant(tenantId)}/invitations/${invitationId}`, {
70
+ method: 'DELETE',
71
+ });
72
+ }
73
+ }
74
+ //# sourceMappingURL=members.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"members.js","sourceRoot":"","sources":["../src/members.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAsB9C,MAAM,O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MAAM,CAAC,QAAQ,CAAC,YAAY,MAAM,EAAE,EAAE;YACtF,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;IAED,gFAAgF;IAChF,KAAK,CAAC,eAAe,CAAC,QAAiB;QACrC,MAAM,GAAG,GAAG,MAAM,OAAO,CACvB,IAAI,CAAC,GAAG,EACR,eAAe,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CACnD,CAAC;QACF,OAAO,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CACV,KAAa,EACb,UAAkE,EAAE;QAEpE,OAAO,OAAO,CAAmB,IAAI,CAAC,GAAG,EAAE,eAAe,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,EAAE;YACrG,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,wFAAwF;IACxF,KAAK,CAAC,gBAAgB,CAAC,YAAoB,EAAE,QAAiB;QAC5D,MAAM,OAAO,CAAO,IAAI,CAAC,GAAG,EAAE,eAAe,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,YAAY,EAAE,EAAE;YAChG,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
package/dist/org.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Org admin module — `/v1/orgs/*` management surface.
3
+ *
4
+ * Everything here requires org-admin (or platform-admin) rights on the
5
+ * target org. Tenant scoping does not apply — calls are addressed by
6
+ * org id, not by the client's X-Tenant-ID.
7
+ */
8
+ import type { FetchContext } from './internal/fetch.js';
9
+ export interface OrgSummary {
10
+ id: string;
11
+ name: string;
12
+ slug?: string;
13
+ allowed_domains?: string[];
14
+ [key: string]: unknown;
15
+ }
16
+ export interface OrgMember {
17
+ user_id: string;
18
+ email?: string;
19
+ name?: string;
20
+ role: string;
21
+ [key: string]: unknown;
22
+ }
23
+ export interface OrgTenant {
24
+ id: string;
25
+ name: string;
26
+ slug?: string;
27
+ org_id?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ /** Response of `POST /v1/orgs/{org_id}/customers` — a child customer org + its default workspace. */
31
+ export interface CustomerOrgResponse {
32
+ org?: {
33
+ id: string;
34
+ name?: string;
35
+ };
36
+ workspace?: {
37
+ id: string;
38
+ name?: string;
39
+ };
40
+ [key: string]: unknown;
41
+ }
42
+ /**
43
+ * A stored org LLM provider credential.
44
+ *
45
+ * `org_llm_providers` is now purely a credential store keyed by route (see
46
+ * docs/design/LLM_PROVIDER_MODEL_RESOLUTION.md). `is_default` is retained only
47
+ * as a convenience flag for credential listing and does NOT influence
48
+ * resolution. The removed `fallback_for_id` column and the tier-override
49
+ * surface are gone — model selection is the agent breadcrumb's concrete
50
+ * `route/provider/model` address.
51
+ */
52
+ export interface OrgLLMProvider {
53
+ id: string;
54
+ provider_type: string;
55
+ name: string;
56
+ is_default: boolean;
57
+ }
58
+ export declare class OrgModule {
59
+ private readonly ctx;
60
+ constructor(ctx: FetchContext);
61
+ /** `GET /v1/orgs/{org_id}` */
62
+ get(orgId: string): Promise<OrgSummary>;
63
+ /** `GET /v1/orgs/{org_id}/members` */
64
+ listMembers(orgId: string): Promise<OrgMember[]>;
65
+ /**
66
+ * `GET /v1/orgs/{org_id}/tenants` — all workspaces in the org.
67
+ *
68
+ * Privacy note for fleet apps: never enumerate a *customer-run*
69
+ * platform org's tenants; use org-level rollups instead.
70
+ */
71
+ listTenants(orgId: string): Promise<OrgTenant[]>;
72
+ /** `POST /v1/orgs/{org_id}/tenants` — create a workspace inside the org. Returns the new tenant id. */
73
+ createTenant(orgId: string, name: string, slug?: string): Promise<OrgTenant>;
74
+ /**
75
+ * `POST /v1/orgs/{org_id}/customers` — create a child customer org
76
+ * (optionally adopting an existing workspace as its default).
77
+ */
78
+ createCustomerOrg(orgId: string, opts: {
79
+ name: string;
80
+ adoptTenantId?: string;
81
+ }): Promise<CustomerOrgResponse>;
82
+ /** `GET /v1/orgs/{org_id}/llm-providers` — list stored BYO credentials (no fallback role). */
83
+ listLLMProviders(orgId: string): Promise<OrgLLMProvider[]>;
84
+ }
85
+ //# sourceMappingURL=org.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org.d.ts","sourceRoot":"","sources":["../src/org.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,SAAS,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC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