@elmohq/sdk 0.0.0-stage → 0.1.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 (129) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +325 -2
  3. package/dist/calls/index.d.mts +288 -0
  4. package/dist/calls/index.d.mts.map +1 -0
  5. package/dist/calls/index.mjs +390 -0
  6. package/dist/calls/index.mjs.map +1 -0
  7. package/dist/index.d.mts +2 -0
  8. package/dist/index.mjs +1029 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/request-options-DWYI_Ldj.d.mts +1550 -0
  11. package/dist/request-options-DWYI_Ldj.d.mts.map +1 -0
  12. package/dist/tools-7Hs5J2xb.d.mts +1945 -0
  13. package/dist/tools-7Hs5J2xb.d.mts.map +1 -0
  14. package/dist/tools-SwP0sK8H.mjs +2458 -0
  15. package/dist/tools-SwP0sK8H.mjs.map +1 -0
  16. package/dist/types/index.d.mts +2 -0
  17. package/dist/types/index.mjs +1 -0
  18. package/package.json +67 -4
  19. package/src/calls/brands-analytics-get.ts +33 -0
  20. package/src/calls/brands-citations-domains-list.ts +36 -0
  21. package/src/calls/brands-citations-urls-list.ts +32 -0
  22. package/src/calls/brands-create.ts +19 -0
  23. package/src/calls/brands-get.ts +19 -0
  24. package/src/calls/brands-list.ts +18 -0
  25. package/src/calls/brands-opportunities-get.ts +42 -0
  26. package/src/calls/brands-prompt-performance-list.ts +39 -0
  27. package/src/calls/brands-query-fanout-get.ts +30 -0
  28. package/src/calls/brands-tags-list.ts +28 -0
  29. package/src/calls/brands-update.ts +20 -0
  30. package/src/calls/competitors-create.ts +23 -0
  31. package/src/calls/competitors-delete.ts +19 -0
  32. package/src/calls/competitors-get.ts +19 -0
  33. package/src/calls/competitors-list.ts +23 -0
  34. package/src/calls/competitors-update.ts +24 -0
  35. package/src/calls/index.ts +33 -0
  36. package/src/calls/me-get.ts +18 -0
  37. package/src/calls/models-list.ts +20 -0
  38. package/src/calls/organizations-billing-get.ts +37 -0
  39. package/src/calls/organizations-get.ts +24 -0
  40. package/src/calls/organizations-list.ts +27 -0
  41. package/src/calls/prompts-create.ts +27 -0
  42. package/src/calls/prompts-delete.ts +28 -0
  43. package/src/calls/prompts-get.ts +23 -0
  44. package/src/calls/prompts-list.ts +28 -0
  45. package/src/calls/prompts-runs-get.ts +27 -0
  46. package/src/calls/prompts-runs-list.ts +30 -0
  47. package/src/calls/prompts-snapshot-get.ts +28 -0
  48. package/src/calls/prompts-update.ts +29 -0
  49. package/src/calls/reports-create.ts +31 -0
  50. package/src/calls/reports-get.ts +27 -0
  51. package/src/calls/reports-list.ts +28 -0
  52. package/src/calls/tools-analyze.ts +26 -0
  53. package/src/client.ts +662 -0
  54. package/src/index.ts +21 -0
  55. package/src/internal/binding/rest/binding.ts +127 -0
  56. package/src/internal/binding/rest/errors.ts +107 -0
  57. package/src/internal/binding/rest/path.ts +9 -0
  58. package/src/internal/binding/rest/url.ts +97 -0
  59. package/src/internal/codec/json.ts +66 -0
  60. package/src/internal/codec/registry.ts +55 -0
  61. package/src/internal/core/backoff.ts +170 -0
  62. package/src/internal/core/body.ts +54 -0
  63. package/src/internal/core/browser.ts +11 -0
  64. package/src/internal/core/call-promise.ts +145 -0
  65. package/src/internal/core/callable.ts +11 -0
  66. package/src/internal/core/client.ts +89 -0
  67. package/src/internal/core/config.ts +84 -0
  68. package/src/internal/core/credentials.ts +40 -0
  69. package/src/internal/core/dispatch.ts +227 -0
  70. package/src/internal/core/env.ts +68 -0
  71. package/src/internal/core/errors.ts +431 -0
  72. package/src/internal/core/features.ts +60 -0
  73. package/src/internal/core/lazy-promise.ts +39 -0
  74. package/src/internal/core/metadata.ts +79 -0
  75. package/src/internal/core/params.ts +98 -0
  76. package/src/internal/core/protocol.ts +17 -0
  77. package/src/internal/core/read-reply.ts +7 -0
  78. package/src/internal/core/text.ts +7 -0
  79. package/src/internal/core/types.ts +556 -0
  80. package/src/internal/feature/auth.ts +201 -0
  81. package/src/internal/feature/interceptors.ts +36 -0
  82. package/src/internal/feature/logger.ts +222 -0
  83. package/src/internal/feature/retry.ts +165 -0
  84. package/src/internal/feature/rules.ts +54 -0
  85. package/src/internal/feature/timeout.ts +146 -0
  86. package/src/internal/feature/validate.ts +74 -0
  87. package/src/internal/page/page.ts +402 -0
  88. package/src/internal/transport/fetch.ts +82 -0
  89. package/src/resources/analytics.ts +363 -0
  90. package/src/resources/brands.ts +285 -0
  91. package/src/resources/competitors.ts +212 -0
  92. package/src/resources/identity.ts +48 -0
  93. package/src/resources/models.ts +32 -0
  94. package/src/resources/opportunities.ts +79 -0
  95. package/src/resources/organizations.ts +181 -0
  96. package/src/resources/prompts.ts +292 -0
  97. package/src/resources/reports.ts +211 -0
  98. package/src/resources/runs.ts +123 -0
  99. package/src/resources/shared/auth.ts +13 -0
  100. package/src/resources/shared/request-options.ts +26 -0
  101. package/src/resources/shared/resource.ts +23 -0
  102. package/src/resources/shared/rule.ts +25 -0
  103. package/src/resources/snapshots.ts +54 -0
  104. package/src/resources/tags.ts +46 -0
  105. package/src/resources/tools.ts +68 -0
  106. package/src/types/analytics.ts +497 -0
  107. package/src/types/brands.ts +228 -0
  108. package/src/types/competitors.ts +196 -0
  109. package/src/types/identity.ts +55 -0
  110. package/src/types/index.ts +163 -0
  111. package/src/types/models.ts +40 -0
  112. package/src/types/opportunities.ts +84 -0
  113. package/src/types/organizations.ts +157 -0
  114. package/src/types/prompts.ts +231 -0
  115. package/src/types/reports.ts +266 -0
  116. package/src/types/runs.ts +131 -0
  117. package/src/types/shared/brand-id-path.ts +2 -0
  118. package/src/types/shared/conflict-error.ts +7 -0
  119. package/src/types/shared/error.ts +29 -0
  120. package/src/types/shared/limit.ts +8 -0
  121. package/src/types/shared/mention-entry.ts +21 -0
  122. package/src/types/shared/model-filter.ts +15 -0
  123. package/src/types/shared/not-found-error.ts +4 -0
  124. package/src/types/shared/page.ts +7 -0
  125. package/src/types/shared/pagination.ts +7 -0
  126. package/src/types/shared/validation-error.ts +4 -0
  127. package/src/types/snapshots.ts +88 -0
  128. package/src/types/tags.ts +47 -0
  129. package/src/types/tools.ts +78 -0
@@ -0,0 +1,84 @@
1
+ import type {
2
+ ForbiddenError,
3
+ InternalServerError,
4
+ RateLimitError,
5
+ UnauthorizedError,
6
+ } from './shared/error';
7
+ import type { NotFoundError } from './shared/not-found-error';
8
+
9
+ export type OpportunityPrompt = {
10
+ /** The tracked prompt it resolved to, or null when it didn't match one. */
11
+ promptId: string | null;
12
+ /** The prompt as the report names it. */
13
+ text: string;
14
+ };
15
+
16
+ export type CitedPage = {
17
+ domain: string;
18
+ title: string | null;
19
+ url: string;
20
+ };
21
+
22
+ export type Opportunity = {
23
+ /**
24
+ * Which workstream this belongs to: `creation` is net-new content, `existing-content` is a page
25
+ * that could win the mention with a refresh, `outreach` is earning a placement on a third-party
26
+ * site assistants cite, `social` is the community conversations they pull from.
27
+ */
28
+ category: 'creation' | 'existing-content' | 'outreach' | 'social';
29
+ /** Pages on competitor domains cited for those prompts. */
30
+ competitorCitations: Array<CitedPage>;
31
+ /** Tracked prompts this would help. May be empty. */
32
+ relatedPrompts: Array<OpportunityPrompt>;
33
+ /** Short and action-oriented — the concrete surface or angle. */
34
+ title: string;
35
+ /** Why it is worth doing, in plain language. */
36
+ why: string;
37
+ /** Pages on the brand's own domains already cited for those prompts. */
38
+ yourCitations: Array<CitedPage>;
39
+ };
40
+
41
+ /**
42
+ * The brand's latest Opportunities report — the same LLM-generated analysis the dashboard shows,
43
+ * read from the append-only history rather than regenerated. Elmo decides when to produce a new
44
+ * one; there is no way to trigger generation over the API, because it spends provider budget with
45
+ * no per-call metering behind it.
46
+ */
47
+ export type BrandOpportunities = {
48
+ brandId: string;
49
+ generatedAt: Date | null;
50
+ /** The model that produced the report, when recorded. */
51
+ model: string | null;
52
+ /** Prioritized, highest impact first. */
53
+ opportunities: Array<Opportunity>;
54
+ /** Caveats: hard-to-win areas, or tactics to avoid. */
55
+ risks: Array<string>;
56
+ /**
57
+ * `ready` when a report is present. `insufficient-data` when the brand hasn't accumulated enough
58
+ * tracked answers to say anything useful yet, in which case the lists are empty.
59
+ */
60
+ status: 'ready' | 'insufficient-data';
61
+ /** A few bullets on where the brand stands and the through-line of the plan. */
62
+ summary: Array<string>;
63
+ };
64
+
65
+ export type GetBrandOpportunitiesErrors = {
66
+ /** Authentication required */
67
+ 401: UnauthorizedError;
68
+ /**
69
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
70
+ * read-only (demo) mode.
71
+ */
72
+ 403: ForbiddenError;
73
+ /** Resource not found */
74
+ 404: NotFoundError;
75
+ /** Per-key rate limit exceeded. */
76
+ 429: RateLimitError;
77
+ /** Internal server error */
78
+ 500: InternalServerError;
79
+ };
80
+
81
+ export type GetBrandOpportunitiesResponses = {
82
+ /** Get the latest opportunities report */
83
+ 200: BrandOpportunities;
84
+ };
@@ -0,0 +1,157 @@
1
+ import type {
2
+ ForbiddenError,
3
+ InternalServerError,
4
+ RateLimitError,
5
+ UnauthorizedError,
6
+ } from './shared/error';
7
+ import type { Limit } from './shared/limit';
8
+ import type { NotFoundError } from './shared/not-found-error';
9
+ import type { Page } from './shared/page';
10
+ import type { Pagination } from './shared/pagination';
11
+
12
+ export type Organization = {
13
+ brandCount: number;
14
+ createdAt: Date;
15
+ id: string;
16
+ name: string;
17
+ slug: string;
18
+ };
19
+
20
+ /** The organization's plan limits. Every field is null on deployments without billing. */
21
+ export type PlanLimits = {
22
+ /** Null means no limit. */
23
+ maxBrands: number | null;
24
+ /** Enabled prompts across the whole organization. Null means no limit. */
25
+ maxPrompts: number | null;
26
+ /** Models the plan may pick from. Null means any. */
27
+ modelMenu: Array<string> | null;
28
+ /** Models trackable per brand. */
29
+ modelPicks: number | null;
30
+ /** Prompt/model pairings trackable grounded. */
31
+ premiumPool: number;
32
+ premiumRunsPerDay: number;
33
+ standardRunsPerDay: number | null;
34
+ };
35
+
36
+ /**
37
+ * Read-only view of an organization's subscription, limits, and usage. The API has no way to change
38
+ * any of it: there is no billing write endpoint and no billing write scope. Stripe identifiers,
39
+ * payment methods, and invoices are deliberately not exposed — those live in the Stripe customer
40
+ * portal.
41
+ */
42
+ export type OrganizationBilling = {
43
+ /** False on self-hosted deployments, where nothing is metered. */
44
+ billingEnabled: boolean;
45
+ limits: PlanLimits | null;
46
+ organizationId: string;
47
+ /** Null when the organization has no subscription, or when billing is disabled. */
48
+ plan: BillingPlan | null;
49
+ usage: {
50
+ brands: number;
51
+ enabledPrompts: number;
52
+ premiumPairingsAssigned: number;
53
+ };
54
+ };
55
+
56
+ export type BillingPlan = {
57
+ cancelAtPeriodEnd: boolean;
58
+ /** Null on a negotiated plan, which carries no billing interval. */
59
+ interval?: 'monthly' | 'annual' | null;
60
+ /** Plan identifier, or `custom` for a negotiated plan. */
61
+ key: string | null;
62
+ /** Display name. */
63
+ name: string;
64
+ periodEnd?: Date | null;
65
+ /**
66
+ * What the subscription means for service, and the only field a caller needs to act on: `active`
67
+ * and `grace` keep tracking running, `paused` stops it, `none` is unsubscribed. The payment
68
+ * provider's own status string is deliberately not passed through.
69
+ */
70
+ standing: 'active' | 'grace' | 'paused' | 'none';
71
+ /** Whether prompts are currently being sampled. */
72
+ trackingActive: boolean;
73
+ };
74
+
75
+ export type OrganizationList = {
76
+ data: Array<Organization>;
77
+ pagination: Pagination;
78
+ };
79
+
80
+ export type ListOrganizationsErrors = {
81
+ /** Authentication required */
82
+ 401: UnauthorizedError;
83
+ /**
84
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
85
+ * read-only (demo) mode.
86
+ */
87
+ 403: ForbiddenError;
88
+ /** Per-key rate limit exceeded. */
89
+ 429: RateLimitError;
90
+ /** Internal server error */
91
+ 500: InternalServerError;
92
+ };
93
+
94
+ export type ListOrganizationsResponses = {
95
+ /** List organizations */
96
+ 200: OrganizationList;
97
+ };
98
+
99
+ export type GetOrganizationErrors = {
100
+ /** Authentication required */
101
+ 401: UnauthorizedError;
102
+ /**
103
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
104
+ * read-only (demo) mode.
105
+ */
106
+ 403: ForbiddenError;
107
+ /** Resource not found */
108
+ 404: NotFoundError;
109
+ /** Per-key rate limit exceeded. */
110
+ 429: RateLimitError;
111
+ /** Internal server error */
112
+ 500: InternalServerError;
113
+ };
114
+
115
+ export type GetOrganizationResponses = {
116
+ /** Get an organization */
117
+ 200: Organization;
118
+ };
119
+
120
+ export type GetOrganizationBillingErrors = {
121
+ /** Authentication required */
122
+ 401: UnauthorizedError;
123
+ /**
124
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
125
+ * read-only (demo) mode.
126
+ */
127
+ 403: ForbiddenError;
128
+ /** Resource not found */
129
+ 404: NotFoundError;
130
+ /** Per-key rate limit exceeded. */
131
+ 429: RateLimitError;
132
+ /** Internal server error */
133
+ 500: InternalServerError;
134
+ };
135
+
136
+ export type GetOrganizationBillingResponses = {
137
+ /** Get billing state */
138
+ 200: OrganizationBilling;
139
+ };
140
+
141
+ export type ListOrganizationsParams = {
142
+ /**
143
+ * Page number, 1-based.
144
+ *
145
+ * @default 1
146
+ * @minimum 1
147
+ */
148
+ page?: Page;
149
+ /**
150
+ * Items per page. Values above the maximum are clamped, not rejected.
151
+ *
152
+ * @default 20
153
+ * @minimum 1
154
+ * @maximum 100
155
+ */
156
+ limit?: Limit;
157
+ };
@@ -0,0 +1,231 @@
1
+ import type { ConflictError, PaymentRequiredError } from './shared/conflict-error';
2
+ import type {
3
+ ForbiddenError,
4
+ InternalServerError,
5
+ RateLimitError,
6
+ UnauthorizedError,
7
+ } from './shared/error';
8
+ import type { NotFoundError } from './shared/not-found-error';
9
+ import type { Page } from './shared/page';
10
+ import type { ValidationError } from './shared/validation-error';
11
+
12
+ export type Prompt = {
13
+ /** Brand identifier this prompt belongs to */
14
+ brandId: string;
15
+ /** Timestamp when the prompt was created */
16
+ createdAt: Date;
17
+ /** Whether the prompt is currently enabled */
18
+ enabled: boolean;
19
+ /** Unique identifier for the prompt */
20
+ id: string;
21
+ /** Models this prompt is tracked on grounded. Each entry spends one premium pairing. */
22
+ premiumModels: Array<string>;
23
+ /** Auto-computed system tags (e.g., 'branded', 'unbranded'). Read-only. */
24
+ systemTags: Array<string>;
25
+ /** User-defined tags for categorizing this prompt */
26
+ tags: Array<string>;
27
+ /** Timestamp when the prompt was last updated */
28
+ updatedAt: Date;
29
+ /** The actual prompt text */
30
+ value: string;
31
+ };
32
+
33
+ export type ListPromptsErrors = {
34
+ /** Authentication required */
35
+ 401: UnauthorizedError;
36
+ /**
37
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
38
+ * read-only (demo) mode.
39
+ */
40
+ 403: ForbiddenError;
41
+ /** Per-key rate limit exceeded. */
42
+ 429: RateLimitError;
43
+ /** Internal server error */
44
+ 500: InternalServerError;
45
+ };
46
+
47
+ export type ListPromptsResponses = {
48
+ /** List of prompts */
49
+ 200: {
50
+ /** The items on this page. Read this rather than the named key below. */
51
+ data: Array<Prompt>;
52
+ pagination: {
53
+ limit: number;
54
+ page: number;
55
+ total: number;
56
+ totalPages: number;
57
+ };
58
+ /**
59
+ * Deprecated: read `data` instead. Kept while the one known consumer migrates, and removed in a
60
+ * future release.
61
+ *
62
+ * @deprecated
63
+ */
64
+ prompts: Array<Prompt>;
65
+ };
66
+ };
67
+
68
+ export type ListPromptsResponse = ListPromptsResponses[keyof ListPromptsResponses];
69
+
70
+ export type CreatePromptErrors = {
71
+ /** Invalid request data */
72
+ 400: ValidationError;
73
+ /** Authentication required */
74
+ 401: UnauthorizedError;
75
+ /** The organization has no active subscription. Cloud deployments only. */
76
+ 402: PaymentRequiredError;
77
+ /**
78
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
79
+ * read-only (demo) mode.
80
+ */
81
+ 403: ForbiddenError;
82
+ /** Resource already exists */
83
+ 409: ConflictError;
84
+ /** Per-key rate limit exceeded. */
85
+ 429: RateLimitError;
86
+ /** Internal server error */
87
+ 500: InternalServerError;
88
+ };
89
+
90
+ export type CreatePromptResponses = {
91
+ /** Prompt created successfully */
92
+ 201: Prompt;
93
+ };
94
+
95
+ export type DeletePromptErrors = {
96
+ /** Invalid request data */
97
+ 400: ValidationError;
98
+ /** Authentication required */
99
+ 401: UnauthorizedError;
100
+ /** The organization has no active subscription. Cloud deployments only. */
101
+ 402: PaymentRequiredError;
102
+ /**
103
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
104
+ * read-only (demo) mode.
105
+ */
106
+ 403: ForbiddenError;
107
+ /** Resource not found */
108
+ 404: NotFoundError;
109
+ /** Resource already exists */
110
+ 409: ConflictError;
111
+ /** Per-key rate limit exceeded. */
112
+ 429: RateLimitError;
113
+ /** Internal server error */
114
+ 500: InternalServerError;
115
+ };
116
+
117
+ export type DeletePromptResponses = {
118
+ /** Prompt deleted (returns the deleted prompt) */
119
+ 200: Prompt & {
120
+ /** Number of related prompt_runs rows deleted by the cascade. */
121
+ deletedRunsCount: number;
122
+ };
123
+ };
124
+
125
+ export type DeletePromptResponse = DeletePromptResponses[keyof DeletePromptResponses];
126
+
127
+ export type GetPromptErrors = {
128
+ /** Invalid request data */
129
+ 400: ValidationError;
130
+ /** Authentication required */
131
+ 401: UnauthorizedError;
132
+ /**
133
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
134
+ * read-only (demo) mode.
135
+ */
136
+ 403: ForbiddenError;
137
+ /** Resource not found */
138
+ 404: NotFoundError;
139
+ /** Per-key rate limit exceeded. */
140
+ 429: RateLimitError;
141
+ /** Internal server error */
142
+ 500: InternalServerError;
143
+ };
144
+
145
+ export type GetPromptResponses = {
146
+ /** Prompt details */
147
+ 200: Prompt;
148
+ };
149
+
150
+ export type UpdatePromptErrors = {
151
+ /** Invalid request data */
152
+ 400: ValidationError;
153
+ /** Authentication required */
154
+ 401: UnauthorizedError;
155
+ /** The organization has no active subscription. Cloud deployments only. */
156
+ 402: PaymentRequiredError;
157
+ /**
158
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
159
+ * read-only (demo) mode.
160
+ */
161
+ 403: ForbiddenError;
162
+ /** Resource not found */
163
+ 404: NotFoundError;
164
+ /** Resource already exists */
165
+ 409: ConflictError;
166
+ /** Per-key rate limit exceeded. */
167
+ 429: RateLimitError;
168
+ /** Internal server error */
169
+ 500: InternalServerError;
170
+ };
171
+
172
+ export type UpdatePromptResponses = {
173
+ /** Prompt updated successfully */
174
+ 200: Prompt;
175
+ };
176
+
177
+ export type ListPromptsParams = {
178
+ /** Filter prompts by brand ID */
179
+ brandId?: string;
180
+ /**
181
+ * Page number, 1-based.
182
+ *
183
+ * @default 1
184
+ * @minimum 1
185
+ */
186
+ page?: Page;
187
+ /**
188
+ * Items per page. Values above the maximum are clamped, not rejected. This list had no ceiling
189
+ * before, so the maximum is set to bound a runaway query rather than to change what an existing
190
+ * caller gets back.
191
+ *
192
+ * @default 20
193
+ * @minimum 1
194
+ * @maximum 1000
195
+ */
196
+ limit?: number;
197
+ /** Only prompts with this tracking state. */
198
+ enabled?: boolean;
199
+ /** Comma-separated tags. A prompt matches if it carries any of them. */
200
+ tags?: string;
201
+ /** Case-insensitive substring match on prompt text. */
202
+ q?: string;
203
+ };
204
+
205
+ export type CreatePromptParams = {
206
+ /** Brand identifier this prompt belongs to */
207
+ brandId: string;
208
+ /**
209
+ * The prompt text
210
+ *
211
+ * @minLength 1
212
+ */
213
+ value: string;
214
+ /** User-defined tags for categorizing this prompt */
215
+ tags?: Array<string>;
216
+ };
217
+
218
+ export type UpdatePromptParams = {
219
+ /**
220
+ * The prompt text
221
+ *
222
+ * @minLength 1
223
+ */
224
+ value?: string;
225
+ /** Whether the prompt is enabled */
226
+ enabled?: boolean;
227
+ /** User-defined tags for categorizing this prompt */
228
+ tags?: Array<string>;
229
+ /** Replaces the prompt's grounded models. Checked against the organization's premium pool. */
230
+ premiumModels?: Array<string>;
231
+ };