@databricks/sdk-core 0.0.0-dev → 0.1.0-dev.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 (163) hide show
  1. package/README.md +11 -1
  2. package/dist/api/execute.d.ts +12 -0
  3. package/dist/api/execute.d.ts.map +1 -0
  4. package/dist/api/execute.js +77 -0
  5. package/dist/api/execute.js.map +1 -0
  6. package/dist/api/index.d.ts +12 -0
  7. package/dist/api/index.d.ts.map +1 -0
  8. package/dist/api/index.js +8 -0
  9. package/dist/api/index.js.map +1 -0
  10. package/dist/api/limiter.d.ts +9 -0
  11. package/dist/api/limiter.d.ts.map +1 -0
  12. package/dist/api/limiter.js +2 -0
  13. package/dist/api/limiter.js.map +1 -0
  14. package/dist/api/options.d.ts +22 -0
  15. package/dist/api/options.d.ts.map +1 -0
  16. package/dist/api/options.js +2 -0
  17. package/dist/api/options.js.map +1 -0
  18. package/dist/api/retrier.d.ts +58 -0
  19. package/dist/api/retrier.d.ts.map +1 -0
  20. package/dist/api/retrier.js +70 -0
  21. package/dist/api/retrier.js.map +1 -0
  22. package/dist/apierror/apierror.d.ts +53 -0
  23. package/dist/apierror/apierror.d.ts.map +1 -0
  24. package/dist/apierror/apierror.js +217 -0
  25. package/dist/apierror/apierror.js.map +1 -0
  26. package/dist/apierror/codes/codes.d.ts +140 -0
  27. package/dist/apierror/codes/codes.d.ts.map +1 -0
  28. package/dist/apierror/codes/codes.js +167 -0
  29. package/dist/apierror/codes/codes.js.map +1 -0
  30. package/dist/apierror/codes/index.d.ts +7 -0
  31. package/dist/apierror/codes/index.d.ts.map +1 -0
  32. package/dist/apierror/codes/index.js +7 -0
  33. package/dist/apierror/codes/index.js.map +1 -0
  34. package/dist/apierror/details.d.ts +177 -0
  35. package/dist/apierror/details.d.ts.map +1 -0
  36. package/dist/apierror/details.js +250 -0
  37. package/dist/apierror/details.js.map +1 -0
  38. package/dist/apierror/index.d.ts +8 -0
  39. package/dist/apierror/index.d.ts.map +1 -0
  40. package/dist/apierror/index.js +7 -0
  41. package/dist/apierror/index.js.map +1 -0
  42. package/dist/clientinfo/agent.d.ts +56 -0
  43. package/dist/clientinfo/agent.d.ts.map +1 -0
  44. package/dist/clientinfo/agent.js +120 -0
  45. package/dist/clientinfo/agent.js.map +1 -0
  46. package/dist/clientinfo/base.d.ts +39 -0
  47. package/dist/clientinfo/base.d.ts.map +1 -0
  48. package/dist/clientinfo/base.js +61 -0
  49. package/dist/clientinfo/base.js.map +1 -0
  50. package/dist/clientinfo/clientinfo.d.ts +61 -0
  51. package/dist/clientinfo/clientinfo.d.ts.map +1 -0
  52. package/dist/clientinfo/clientinfo.js +96 -0
  53. package/dist/clientinfo/clientinfo.js.map +1 -0
  54. package/dist/clientinfo/default.browser.d.ts +17 -0
  55. package/dist/clientinfo/default.browser.d.ts.map +1 -0
  56. package/dist/clientinfo/default.browser.js +20 -0
  57. package/dist/clientinfo/default.browser.js.map +1 -0
  58. package/dist/clientinfo/default.d.ts +14 -0
  59. package/dist/clientinfo/default.d.ts.map +1 -0
  60. package/dist/clientinfo/default.js +104 -0
  61. package/dist/clientinfo/default.js.map +1 -0
  62. package/dist/clientinfo/index.browser.d.ts +5 -0
  63. package/dist/clientinfo/index.browser.d.ts.map +1 -0
  64. package/dist/clientinfo/index.browser.js +4 -0
  65. package/dist/clientinfo/index.browser.js.map +1 -0
  66. package/dist/clientinfo/index.d.ts +5 -0
  67. package/dist/clientinfo/index.d.ts.map +1 -0
  68. package/dist/clientinfo/index.js +4 -0
  69. package/dist/clientinfo/index.js.map +1 -0
  70. package/dist/http/http.d.ts +40 -0
  71. package/dist/http/http.d.ts.map +1 -0
  72. package/dist/http/http.js +37 -0
  73. package/dist/http/http.js.map +1 -0
  74. package/dist/http/index.d.ts +8 -0
  75. package/dist/http/index.d.ts.map +1 -0
  76. package/dist/http/index.js +7 -0
  77. package/dist/http/index.js.map +1 -0
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +7 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/logger/index.d.ts +8 -0
  83. package/dist/logger/index.d.ts.map +1 -0
  84. package/dist/logger/index.js +7 -0
  85. package/dist/logger/index.js.map +1 -0
  86. package/dist/logger/logger.d.ts +49 -0
  87. package/dist/logger/logger.d.ts.map +1 -0
  88. package/dist/logger/logger.js +65 -0
  89. package/dist/logger/logger.js.map +1 -0
  90. package/dist/profiles/errors.d.ts +17 -0
  91. package/dist/profiles/errors.d.ts.map +1 -0
  92. package/dist/profiles/errors.js +19 -0
  93. package/dist/profiles/errors.js.map +1 -0
  94. package/dist/profiles/index.browser.d.ts +10 -0
  95. package/dist/profiles/index.browser.d.ts.map +1 -0
  96. package/dist/profiles/index.browser.js +8 -0
  97. package/dist/profiles/index.browser.js.map +1 -0
  98. package/dist/profiles/index.d.ts +15 -0
  99. package/dist/profiles/index.d.ts.map +1 -0
  100. package/dist/profiles/index.js +13 -0
  101. package/dist/profiles/index.js.map +1 -0
  102. package/dist/profiles/ini.d.ts +36 -0
  103. package/dist/profiles/ini.d.ts.map +1 -0
  104. package/dist/profiles/ini.js +113 -0
  105. package/dist/profiles/ini.js.map +1 -0
  106. package/dist/profiles/profile.d.ts +131 -0
  107. package/dist/profiles/profile.d.ts.map +1 -0
  108. package/dist/profiles/profile.js +307 -0
  109. package/dist/profiles/profile.js.map +1 -0
  110. package/dist/profiles/resolve.d.ts +29 -0
  111. package/dist/profiles/resolve.d.ts.map +1 -0
  112. package/dist/profiles/resolve.js +206 -0
  113. package/dist/profiles/resolve.js.map +1 -0
  114. package/dist/profiles/secret.d.ts +25 -0
  115. package/dist/profiles/secret.d.ts.map +1 -0
  116. package/dist/profiles/secret.js +38 -0
  117. package/dist/profiles/secret.js.map +1 -0
  118. package/dist/wkt/fieldmask.d.ts +32 -0
  119. package/dist/wkt/fieldmask.d.ts.map +1 -0
  120. package/dist/wkt/fieldmask.js +68 -0
  121. package/dist/wkt/fieldmask.js.map +1 -0
  122. package/dist/wkt/index.d.ts +4 -0
  123. package/dist/wkt/index.d.ts.map +1 -0
  124. package/dist/wkt/index.js +2 -0
  125. package/dist/wkt/index.js.map +1 -0
  126. package/dist/wkt/value.d.ts +13 -0
  127. package/dist/wkt/value.d.ts.map +1 -0
  128. package/dist/wkt/value.js +2 -0
  129. package/dist/wkt/value.js.map +1 -0
  130. package/package.json +80 -4
  131. package/src/api/execute.ts +102 -0
  132. package/src/api/index.ts +12 -0
  133. package/src/api/limiter.ts +8 -0
  134. package/src/api/options.ts +22 -0
  135. package/src/api/retrier.ts +108 -0
  136. package/src/apierror/apierror.ts +253 -0
  137. package/src/apierror/codes/codes.ts +189 -0
  138. package/src/apierror/codes/index.ts +7 -0
  139. package/src/apierror/details.ts +459 -0
  140. package/src/apierror/index.ts +24 -0
  141. package/src/clientinfo/agent.ts +131 -0
  142. package/src/clientinfo/base.ts +72 -0
  143. package/src/clientinfo/clientinfo.ts +129 -0
  144. package/src/clientinfo/default.browser.ts +24 -0
  145. package/src/clientinfo/default.ts +128 -0
  146. package/src/clientinfo/index.browser.ts +4 -0
  147. package/src/clientinfo/index.ts +4 -0
  148. package/src/http/http.ts +75 -0
  149. package/src/http/index.ts +8 -0
  150. package/src/index.ts +5 -0
  151. package/src/logger/index.ts +8 -0
  152. package/src/logger/logger.ts +99 -0
  153. package/src/profiles/errors.ts +28 -0
  154. package/src/profiles/index.browser.ts +10 -0
  155. package/src/profiles/index.ts +15 -0
  156. package/src/profiles/ini.ts +126 -0
  157. package/src/profiles/profile.ts +467 -0
  158. package/src/profiles/resolve.ts +251 -0
  159. package/src/profiles/secret.ts +40 -0
  160. package/src/wkt/fieldmask.ts +89 -0
  161. package/src/wkt/index.ts +3 -0
  162. package/src/wkt/value.ts +19 -0
  163. package/index.js +0 -1
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Defines structured error detail types for API errors.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { z } from 'zod';
7
+ // ---------------------------------------------------------------------------
8
+ // Zod schemas for the wire format (snake_case JSON from the API).
9
+ //
10
+ // Each schema validates the snake_case wire format from the API and transforms
11
+ // it into the camelCase TypeScript interface. Nullish fields default to their
12
+ // zero values (empty string, empty array, empty record) when absent or null.
13
+ // ---------------------------------------------------------------------------
14
+ // Reusable schema fragments. Nullish fields default to their zero values
15
+ // (empty string, empty array, empty record) when absent or null.
16
+ const nullishString = z
17
+ .string()
18
+ .nullish()
19
+ .transform(v => v ?? '');
20
+ const errorInfoSchema = z.object({
21
+ reason: nullishString,
22
+ domain: nullishString,
23
+ metadata: z
24
+ .record(z.string(), z.string())
25
+ .nullish()
26
+ .transform(v => v ?? {}),
27
+ });
28
+ const requestInfoSchema = z
29
+ .object({
30
+ request_id: nullishString,
31
+ serving_data: nullishString,
32
+ })
33
+ .transform(d => ({
34
+ requestId: d.request_id,
35
+ servingData: d.serving_data,
36
+ }));
37
+ // Parses a protobuf Duration string (e.g. "42.000000001s") into milliseconds.
38
+ // Null/undefined defaults to 0. Invalid format causes a Zod validation failure.
39
+ const nullishProtoDuration = z
40
+ .string()
41
+ .nullish()
42
+ .transform((v, ctx) => {
43
+ if (v === null || v === undefined) {
44
+ return 0;
45
+ }
46
+ const ms = parseProtoDuration(v);
47
+ if (ms === undefined) {
48
+ ctx.addIssue({ code: 'custom', message: 'Invalid protobuf duration.' });
49
+ return z.NEVER;
50
+ }
51
+ return ms;
52
+ });
53
+ const retryInfoSchema = z
54
+ .object({
55
+ retry_delay: nullishProtoDuration,
56
+ })
57
+ .transform(d => ({
58
+ retryDelayMs: d.retry_delay,
59
+ }));
60
+ const debugInfoSchema = z
61
+ .object({
62
+ stack_entries: z
63
+ .array(z.string())
64
+ .nullish()
65
+ .transform(v => v ?? []),
66
+ detail: nullishString,
67
+ })
68
+ .transform(d => ({
69
+ stackEntries: d.stack_entries,
70
+ detail: d.detail,
71
+ }));
72
+ const quotaViolationSchema = z.object({
73
+ subject: nullishString,
74
+ description: nullishString,
75
+ });
76
+ const quotaFailureSchema = z.object({
77
+ violations: z
78
+ .array(quotaViolationSchema)
79
+ .nullish()
80
+ .transform(v => v ?? []),
81
+ });
82
+ const preconditionViolationSchema = z.object({
83
+ type: nullishString,
84
+ subject: nullishString,
85
+ description: nullishString,
86
+ });
87
+ const preconditionFailureSchema = z.object({
88
+ violations: z
89
+ .array(preconditionViolationSchema)
90
+ .nullish()
91
+ .transform(v => v ?? []),
92
+ });
93
+ const fieldViolationSchema = z.object({
94
+ field: nullishString,
95
+ description: nullishString,
96
+ });
97
+ const badRequestSchema = z
98
+ .object({
99
+ field_violations: z
100
+ .array(fieldViolationSchema)
101
+ .nullish()
102
+ .transform(v => v ?? []),
103
+ })
104
+ .transform(d => ({
105
+ fieldViolations: d.field_violations,
106
+ }));
107
+ const resourceInfoSchema = z
108
+ .object({
109
+ resource_type: nullishString,
110
+ resource_name: nullishString,
111
+ owner: nullishString,
112
+ description: nullishString,
113
+ })
114
+ .transform(d => ({
115
+ resourceType: d.resource_type,
116
+ resourceName: d.resource_name,
117
+ owner: d.owner,
118
+ description: d.description,
119
+ }));
120
+ const helpLinkSchema = z.object({
121
+ description: nullishString,
122
+ url: nullishString,
123
+ });
124
+ const helpSchema = z.object({
125
+ links: z
126
+ .array(helpLinkSchema)
127
+ .nullish()
128
+ .transform(v => v ?? []),
129
+ });
130
+ // Google RPC type URLs used to identify error detail types in the wire format.
131
+ const ERROR_INFO_TYPE = 'type.googleapis.com/google.rpc.ErrorInfo';
132
+ const REQUEST_INFO_TYPE = 'type.googleapis.com/google.rpc.RequestInfo';
133
+ const RETRY_INFO_TYPE = 'type.googleapis.com/google.rpc.RetryInfo';
134
+ const DEBUG_INFO_TYPE = 'type.googleapis.com/google.rpc.DebugInfo';
135
+ const QUOTA_FAILURE_TYPE = 'type.googleapis.com/google.rpc.QuotaFailure';
136
+ const PRECONDITION_FAILURE_TYPE = 'type.googleapis.com/google.rpc.PreconditionFailure';
137
+ const BAD_REQUEST_TYPE = 'type.googleapis.com/google.rpc.BadRequest';
138
+ const RESOURCE_INFO_TYPE = 'type.googleapis.com/google.rpc.ResourceInfo';
139
+ const HELP_TYPE = 'type.googleapis.com/google.rpc.Help';
140
+ // Checks whether a value is a plain object (not null, not an array).
141
+ function isRecord(value) {
142
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
143
+ }
144
+ // Parses a protobuf Duration string (e.g. "42.000000001s") into milliseconds.
145
+ // Returns undefined if the format is invalid.
146
+ function parseProtoDuration(s) {
147
+ if (!s.endsWith('s')) {
148
+ return undefined;
149
+ }
150
+ const seconds = Number(s.slice(0, -1));
151
+ if (Number.isNaN(seconds)) {
152
+ return undefined;
153
+ }
154
+ return seconds * 1000;
155
+ }
156
+ // Attempts to parse a single detail and assign it to the right ErrorDetails
157
+ // field. Returns true if the detail was recognized and valid, false otherwise.
158
+ function tryAssignDetail(ed, type, raw) {
159
+ switch (type) {
160
+ case ERROR_INFO_TYPE: {
161
+ const r = errorInfoSchema.safeParse(raw);
162
+ if (!r.success)
163
+ return false;
164
+ ed.errorInfo = r.data;
165
+ return true;
166
+ }
167
+ case REQUEST_INFO_TYPE: {
168
+ const r = requestInfoSchema.safeParse(raw);
169
+ if (!r.success)
170
+ return false;
171
+ ed.requestInfo = r.data;
172
+ return true;
173
+ }
174
+ case RETRY_INFO_TYPE: {
175
+ const r = retryInfoSchema.safeParse(raw);
176
+ if (!r.success)
177
+ return false;
178
+ ed.retryInfo = r.data;
179
+ return true;
180
+ }
181
+ case DEBUG_INFO_TYPE: {
182
+ const r = debugInfoSchema.safeParse(raw);
183
+ if (!r.success)
184
+ return false;
185
+ ed.debugInfo = r.data;
186
+ return true;
187
+ }
188
+ case QUOTA_FAILURE_TYPE: {
189
+ const r = quotaFailureSchema.safeParse(raw);
190
+ if (!r.success)
191
+ return false;
192
+ ed.quotaFailure = r.data;
193
+ return true;
194
+ }
195
+ case PRECONDITION_FAILURE_TYPE: {
196
+ const r = preconditionFailureSchema.safeParse(raw);
197
+ if (!r.success)
198
+ return false;
199
+ ed.preconditionFailure = r.data;
200
+ return true;
201
+ }
202
+ case BAD_REQUEST_TYPE: {
203
+ const r = badRequestSchema.safeParse(raw);
204
+ if (!r.success)
205
+ return false;
206
+ ed.badRequest = r.data;
207
+ return true;
208
+ }
209
+ case RESOURCE_INFO_TYPE: {
210
+ const r = resourceInfoSchema.safeParse(raw);
211
+ if (!r.success)
212
+ return false;
213
+ ed.resourceInfo = r.data;
214
+ return true;
215
+ }
216
+ case HELP_TYPE: {
217
+ const r = helpSchema.safeParse(raw);
218
+ if (!r.success)
219
+ return false;
220
+ ed.help = r.data;
221
+ return true;
222
+ }
223
+ default:
224
+ return false;
225
+ }
226
+ }
227
+ /**
228
+ * Parses an array of raw error detail values into a structured ErrorDetails
229
+ * object. If multiple details of the same known type are present, the last
230
+ * one wins.
231
+ */
232
+ export function parseErrorDetails(rawDetails) {
233
+ const ed = { unknownDetails: [] };
234
+ for (const rd of rawDetails) {
235
+ if (!isRecord(rd)) {
236
+ ed.unknownDetails.push(rd);
237
+ continue;
238
+ }
239
+ const type = rd['@type'];
240
+ if (typeof type !== 'string') {
241
+ ed.unknownDetails.push(rd);
242
+ continue;
243
+ }
244
+ if (!tryAssignDetail(ed, type, rd)) {
245
+ ed.unknownDetails.push(rd);
246
+ }
247
+ }
248
+ return ed;
249
+ }
250
+ //# sourceMappingURL=details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"details.js","sourceRoot":"","sources":["../../src/apierror/details.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAkMtB,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAE9E,yEAAyE;AACzE,iEAAiE;AACjE,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,OAAO,EAAE;KACT,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,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CAAC,EAAE,CAAC,CAAC;YAC3B,SAAS;QACX,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;YACnC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Databricks API error types.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { APIError } from './apierror';
7
+ export type { ErrorDetails, ErrorInfo, RequestInfo, RetryInfo, DebugInfo, QuotaFailure, QuotaFailureViolation, PreconditionFailure, PreconditionFailureViolation, BadRequest, BadRequestFieldViolation, ResourceInfo, Help, HelpLink, } from './details';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apierror/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,YAAY,EACV,YAAY,EACZ,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,UAAU,EACV,wBAAwB,EACxB,YAAY,EACZ,IAAI,EACJ,QAAQ,GACT,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Databricks API error types.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { APIError } from './apierror';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apierror/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Detects the AI coding agent (e.g. Claude Code, Cursor, Gemini CLI) that
3
+ * is running the current Node.js process. The detected product name is
4
+ * appended to the user-agent header so that Databricks can understand
5
+ * which agents are invoking the SDK.
6
+ *
7
+ * The agent list and precedence rules are kept in sync across the Go,
8
+ * Java, Python, and TypeScript SDKs.
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * Checks environment variables for known AI agents and returns the
14
+ * detected product name.
15
+ *
16
+ * Explicit product-specific env vars always take precedence over the
17
+ * generic agents.md `AGENT` env var. `AGENT` is consulted only as a
18
+ * fallback when no explicit matcher fires, so that an explicit signal
19
+ * (e.g. `CLAUDECODE=1`) always wins over a conflicting `AGENT=<name>`
20
+ * value.
21
+ *
22
+ * Returns:
23
+ *
24
+ * - The product name when exactly one known env var is set.
25
+ * - `"multiple"` when multiple known env vars are set. Agent env vars
26
+ * can be stacked when one agent invokes another as a subagent (e.g.
27
+ * Claude Code spawning a Cursor CLI subprocess), so the child process
28
+ * inherits env vars from multiple layers.
29
+ * - When no known env var is set and `AGENT` is a non-empty value: the
30
+ * value itself if it names a known product, otherwise `"unknown"`.
31
+ * - `""` when nothing is set.
32
+ */
33
+ export declare function lookupAgentProvider(): string;
34
+ /**
35
+ * Returns the detected AI agent name, cached for the process lifetime.
36
+ *
37
+ * Returns one of:
38
+ *
39
+ * - The known product name when exactly one agent is detected via
40
+ * explicit env matchers, or when `AGENT` is set to a known product
41
+ * name and no explicit matcher fired.
42
+ * - `"multiple"` when multiple explicit matchers fire for different
43
+ * agents (typically nested agents, e.g. Cursor CLI running as a
44
+ * Claude Code subagent).
45
+ * - `"unknown"` when no explicit matcher fired and `AGENT` is set to a
46
+ * value that is not a known product name.
47
+ * - `""` when no agent is detected.
48
+ */
49
+ export declare function agentProvider(): string;
50
+ /**
51
+ * Clears the cached agent detection result so that the next call to
52
+ * {@link agentProvider} re-evaluates the environment. Exported for
53
+ * testing only.
54
+ */
55
+ export declare function clearAgentCache(): void;
56
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/clientinfo/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgDH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAoB5C;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAGtC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Detects the AI coding agent (e.g. Claude Code, Cursor, Gemini CLI) that
3
+ * is running the current Node.js process. The detected product name is
4
+ * appended to the user-agent header so that Databricks can understand
5
+ * which agents are invoking the SDK.
6
+ *
7
+ * The agent list and precedence rules are kept in sync across the Go,
8
+ * Java, Python, and TypeScript SDKs.
9
+ *
10
+ * @module
11
+ */
12
+ // Name of the agents.md standard env var. When set to a value that no
13
+ // known agent recognizes, detection falls back to "unknown".
14
+ const AGENT_ENV_VAR = 'AGENT';
15
+ // Canonical list of AI coding agents. Keep this list in sync with the
16
+ // Go, Java, and Python SDKs. Agents are listed alphabetically by product
17
+ // name.
18
+ const KNOWN_AGENTS = [
19
+ // The amp agent also sets AGENT=amp, handled by the central fallback.
20
+ { envVar: 'AMP_CURRENT_THREAD_ID', product: 'amp' },
21
+ { envVar: 'ANTIGRAVITY_AGENT', product: 'antigravity' },
22
+ { envVar: 'AUGMENT_AGENT', product: 'augment' },
23
+ { envVar: 'CLAUDECODE', product: 'claude-code' },
24
+ { envVar: 'CLINE_ACTIVE', product: 'cline' },
25
+ { envVar: 'CODEX_CI', product: 'codex' },
26
+ { envVar: 'COPILOT_CLI', product: 'copilot-cli' },
27
+ // VS Code Copilot terminal, best-effort heuristic, not officially
28
+ // identified.
29
+ { envVar: 'COPILOT_MODEL', product: 'copilot-vscode' },
30
+ { envVar: 'CURSOR_AGENT', product: 'cursor' },
31
+ { envVar: 'GEMINI_CLI', product: 'gemini-cli' },
32
+ // The goose agent also sets AGENT=goose, handled by the central
33
+ // fallback.
34
+ { envVar: 'GOOSE_TERMINAL', product: 'goose' },
35
+ { envVar: 'KIRO', product: 'kiro' },
36
+ { envVar: 'OPENCLAW_SHELL', product: 'openclaw' },
37
+ { envVar: 'OPENCODE', product: 'opencode' },
38
+ { envVar: 'WINDSURF_AGENT', product: 'windsurf' },
39
+ ];
40
+ function agentEnvFallback() {
41
+ const v = process.env[AGENT_ENV_VAR];
42
+ if (v === undefined || v === '') {
43
+ return '';
44
+ }
45
+ if (KNOWN_AGENTS.some(a => a.product === v)) {
46
+ return v;
47
+ }
48
+ return 'unknown';
49
+ }
50
+ /**
51
+ * Checks environment variables for known AI agents and returns the
52
+ * detected product name.
53
+ *
54
+ * Explicit product-specific env vars always take precedence over the
55
+ * generic agents.md `AGENT` env var. `AGENT` is consulted only as a
56
+ * fallback when no explicit matcher fires, so that an explicit signal
57
+ * (e.g. `CLAUDECODE=1`) always wins over a conflicting `AGENT=<name>`
58
+ * value.
59
+ *
60
+ * Returns:
61
+ *
62
+ * - The product name when exactly one known env var is set.
63
+ * - `"multiple"` when multiple known env vars are set. Agent env vars
64
+ * can be stacked when one agent invokes another as a subagent (e.g.
65
+ * Claude Code spawning a Cursor CLI subprocess), so the child process
66
+ * inherits env vars from multiple layers.
67
+ * - When no known env var is set and `AGENT` is a non-empty value: the
68
+ * value itself if it names a known product, otherwise `"unknown"`.
69
+ * - `""` when nothing is set.
70
+ */
71
+ export function lookupAgentProvider() {
72
+ let matches = [];
73
+ for (const a of KNOWN_AGENTS) {
74
+ if (a.envVar in process.env) {
75
+ matches.push(a.product);
76
+ }
77
+ }
78
+ // Known BYOK false positive: Copilot CLI users often set COPILOT_MODEL
79
+ // alongside COPILOT_CLI. Treat the pair as a single copilot-cli signal
80
+ // rather than a stacked multi-agent setup.
81
+ if (matches.includes('copilot-cli') && matches.includes('copilot-vscode')) {
82
+ matches = matches.filter(m => m !== 'copilot-vscode');
83
+ }
84
+ if (matches.length === 1) {
85
+ return matches[0];
86
+ }
87
+ if (matches.length > 1) {
88
+ return 'multiple';
89
+ }
90
+ return agentEnvFallback();
91
+ }
92
+ let cached;
93
+ /**
94
+ * Returns the detected AI agent name, cached for the process lifetime.
95
+ *
96
+ * Returns one of:
97
+ *
98
+ * - The known product name when exactly one agent is detected via
99
+ * explicit env matchers, or when `AGENT` is set to a known product
100
+ * name and no explicit matcher fired.
101
+ * - `"multiple"` when multiple explicit matchers fire for different
102
+ * agents (typically nested agents, e.g. Cursor CLI running as a
103
+ * Claude Code subagent).
104
+ * - `"unknown"` when no explicit matcher fired and `AGENT` is set to a
105
+ * value that is not a known product name.
106
+ * - `""` when no agent is detected.
107
+ */
108
+ export function agentProvider() {
109
+ cached ??= lookupAgentProvider();
110
+ return cached;
111
+ }
112
+ /**
113
+ * Clears the cached agent detection result so that the next call to
114
+ * {@link agentProvider} re-evaluates the environment. Exported for
115
+ * testing only.
116
+ */
117
+ export function clearAgentCache() {
118
+ cached = undefined;
119
+ }
120
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/clientinfo/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,sEAAsE;AACtE,6DAA6D;AAC7D,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,sEAAsE;AACtE,yEAAyE;AACzE,QAAQ;AACR,MAAM,YAAY,GAA0B;IAC1C,sEAAsE;IACtE,EAAC,MAAM,EAAE,uBAAuB,EAAE,OAAO,EAAE,KAAK,EAAC;IACjD,EAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,EAAC;IACrD,EAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAC;IAC7C,EAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAC;IAC9C,EAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAC;IAC1C,EAAC,MAAM,EAAE,UAA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C;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,uEAAuE;IACvE,uEAAuE;IACvE,2CAA2C;IAC3C,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1E,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC;AAED,IAAI,MAA0B,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,KAAK,mBAAmB,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shared state management for {@link ClientInfo} defaults. This module
3
+ * is browser-safe and contains no Node.js-specific APIs.
4
+ *
5
+ * @module
6
+ */
7
+ import { ClientInfo } from './clientinfo';
8
+ export declare const MODULE_NAME = "sdk-js-core";
9
+ export declare const VERSION = "0.1.0";
10
+ /**
11
+ * Sets the product name and version globally. The version must be a
12
+ * valid semver string.
13
+ *
14
+ * Must be called before any client is created. Not safe for concurrent
15
+ * use.
16
+ */
17
+ export declare function setProduct(name: string, version: string): void;
18
+ /**
19
+ * Adds a partner identifier globally. Partner attribution is a
20
+ * first-class concept used for support ticket routing.
21
+ *
22
+ * Must be called before any client is created. Not safe for concurrent
23
+ * use.
24
+ */
25
+ export declare function setPartner(partner: string): void;
26
+ /**
27
+ * Adds a global key/value segment that will be included in every
28
+ * {@link createDefault} call. Same key with different values is allowed
29
+ * (e.g., multiple partners). Exact key+value duplicates are silently
30
+ * ignored.
31
+ *
32
+ * Must be called before any client is created. Not safe for concurrent
33
+ * use.
34
+ */
35
+ export declare function addToDefault(key: string, value: string): void;
36
+ export declare function getBase(): ClientInfo;
37
+ export declare function resetBase(): void;
38
+ export declare function baseToString(): string;
39
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/clientinfo/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAA4B,MAAM,cAAc,CAAC;AAEnE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,OAAO,UAAU,CAAC;AAM/B;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQ9D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7D;AAGD,wBAAgB,OAAO,IAAI,UAAU,CAEpC;AAGD,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAID,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Shared state management for {@link ClientInfo} defaults. This module
3
+ * is browser-safe and contains no Node.js-specific APIs.
4
+ *
5
+ * @module
6
+ */
7
+ import { ClientInfo, ClientInfoError, isSemVer } from './clientinfo';
8
+ export const MODULE_NAME = 'sdk-js-core';
9
+ export const VERSION = '0.1.0';
10
+ // Holds segments added via addToDefault, setProduct, and setPartner.
11
+ // createDefault returns a copy of this with env detection appended.
12
+ let base = ClientInfo.EMPTY;
13
+ /**
14
+ * Sets the product name and version globally. The version must be a
15
+ * valid semver string.
16
+ *
17
+ * Must be called before any client is created. Not safe for concurrent
18
+ * use.
19
+ */
20
+ export function setProduct(name, version) {
21
+ if (!isSemVer(version)) {
22
+ throw new ClientInfoError('INVALID_VERSION', `Invalid version: ${version}.`);
23
+ }
24
+ addToDefault(name, version);
25
+ }
26
+ /**
27
+ * Adds a partner identifier globally. Partner attribution is a
28
+ * first-class concept used for support ticket routing.
29
+ *
30
+ * Must be called before any client is created. Not safe for concurrent
31
+ * use.
32
+ */
33
+ export function setPartner(partner) {
34
+ addToDefault('partner', partner);
35
+ }
36
+ /**
37
+ * Adds a global key/value segment that will be included in every
38
+ * {@link createDefault} call. Same key with different values is allowed
39
+ * (e.g., multiple partners). Exact key+value duplicates are silently
40
+ * ignored.
41
+ *
42
+ * Must be called before any client is created. Not safe for concurrent
43
+ * use.
44
+ */
45
+ export function addToDefault(key, value) {
46
+ base = base.with({ key, value });
47
+ }
48
+ // Returns the base ClientInfo for use in createDefault.
49
+ export function getBase() {
50
+ return base;
51
+ }
52
+ // Resets the base segments. Exported for testing only.
53
+ export function resetBase() {
54
+ base = ClientInfo.EMPTY;
55
+ }
56
+ // Returns the base segments as a formatted string. Exported for
57
+ // testing only.
58
+ export function baseToString() {
59
+ return base.toString();
60
+ }
61
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/clientinfo/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEnE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,qEAAqE;AACrE,oEAAoE;AACpE,IAAI,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAe;IACtD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,eAAe,CACvB,iBAAiB,EACjB,oBAAoB,OAAO,GAAG,CAC/B,CAAC;IACJ,CAAC;IACD,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,KAAa;IACrD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;AACjC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,OAAO;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,SAAS;IACvB,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,gEAAgE;AAChE,gBAAgB;AAChB,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Collects information about the client and its environment into an
3
+ * immutable {@link ClientInfo} value.
4
+ *
5
+ * {@link ClientInfo.with} derives a new value with additional key/value
6
+ * segments; it never mutates the original.
7
+ *
8
+ * @module
9
+ */
10
+ export type ClientInfoErrorCode = 'INVALID_KEY' | 'INVALID_VALUE' | 'INVALID_VERSION';
11
+ export declare class ClientInfoError extends Error {
12
+ readonly code: ClientInfoErrorCode;
13
+ constructor(code: ClientInfoErrorCode, message: string);
14
+ }
15
+ interface Segment {
16
+ readonly key: string;
17
+ readonly value: string;
18
+ }
19
+ export declare function isSemVer(s: string): boolean;
20
+ export declare function isValidSegment(s: string): boolean;
21
+ /**
22
+ * Replaces characters that are not valid in segment values with
23
+ * hyphens. Used for environment-sourced values (runtime version,
24
+ * upstream) that we do not control and cannot reject.
25
+ */
26
+ export declare function sanitize(s: string): string;
27
+ /**
28
+ * ClientInfo is an immutable, ordered list of key/value segments. Use
29
+ * {@link ClientInfo.with} to derive new values with additional segments.
30
+ */
31
+ export declare class ClientInfo {
32
+ static readonly EMPTY: ClientInfo;
33
+ readonly segments: readonly Segment[];
34
+ private constructor();
35
+ /**
36
+ * Returns a new {@link ClientInfo} with the given items appended. Accepts
37
+ * either individual key/value pairs or another {@link ClientInfo} whose
38
+ * segments are merged in order. The original is not modified; mixing the
39
+ * two forms in a single call is supported.
40
+ *
41
+ * Keys and values on pair arguments must contain only alphanumeric
42
+ * characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
43
+ * silently ignored. On error, an exception is thrown (all-or-nothing).
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * base.with({key: 'partner', value: 'acme'});
48
+ * base.with(pkgClientInfo);
49
+ * base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
50
+ * ```
51
+ */
52
+ with(...items: (ClientInfo | Segment)[]): ClientInfo;
53
+ /**
54
+ * Returns a string representation of the client info suitable for
55
+ * inclusion in HTTP headers. Key/value pairs are formatted as
56
+ * "key/value" and joined by spaces in the order they were inserted.
57
+ */
58
+ toString(): string;
59
+ }
60
+ export {};
61
+ //# sourceMappingURL=clientinfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientinfo.d.ts","sourceRoot":"","sources":["../../src/clientinfo/clientinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,eAAe,GACf,iBAAiB,CAAC;AAEtB,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;gBAEvB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM;CAKvD;AAED,UAAU,OAAO;IACf,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAcD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAoB;IAEzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAEtC,OAAO;IAMP;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,UAAU,GAAG,OAAO,CAAC,EAAE,GAAG,UAAU;IA6BpD;;;;OAIG;IACH,QAAQ,IAAI,MAAM;CAGnB"}