@databricks/sdk-core 0.34.0 → 0.36.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 (135) hide show
  1. package/dist/apierror/apierror.d.ts +52 -49
  2. package/dist/apierror/apierror.d.ts.map +1 -1
  3. package/dist/apierror/apierror.js +124 -172
  4. package/dist/apierror/apierror.js.map +1 -1
  5. package/dist/apierror/codes/codes.d.ts +113 -113
  6. package/dist/apierror/codes/codes.d.ts.map +1 -1
  7. package/dist/apierror/codes/codes.js +24 -115
  8. package/dist/apierror/codes/codes.js.map +1 -1
  9. package/dist/apierror/codes/index.d.ts +2 -7
  10. package/dist/apierror/codes/index.js +3 -7
  11. package/dist/apierror/details.d.ts +104 -101
  12. package/dist/apierror/details.d.ts.map +1 -1
  13. package/dist/apierror/details.js +151 -226
  14. package/dist/apierror/details.js.map +1 -1
  15. package/dist/apierror/index.d.ts +3 -8
  16. package/dist/apierror/index.js +3 -7
  17. package/dist/clientinfo/agent.d.ts +6 -3
  18. package/dist/clientinfo/agent.d.ts.map +1 -1
  19. package/dist/clientinfo/agent.js +134 -112
  20. package/dist/clientinfo/agent.js.map +1 -1
  21. package/dist/clientinfo/base.d.ts +13 -15
  22. package/dist/clientinfo/base.d.ts.map +1 -1
  23. package/dist/clientinfo/base.js +50 -50
  24. package/dist/clientinfo/base.js.map +1 -1
  25. package/dist/clientinfo/clientinfo.d.ts +40 -38
  26. package/dist/clientinfo/clientinfo.d.ts.map +1 -1
  27. package/dist/clientinfo/clientinfo.js +78 -88
  28. package/dist/clientinfo/clientinfo.js.map +1 -1
  29. package/dist/clientinfo/default.browser.d.ts +6 -10
  30. package/dist/clientinfo/default.browser.d.ts.map +1 -1
  31. package/dist/clientinfo/default.browser.js +24 -16
  32. package/dist/clientinfo/default.browser.js.map +1 -1
  33. package/dist/clientinfo/default.d.ts +8 -4
  34. package/dist/clientinfo/default.d.ts.map +1 -1
  35. package/dist/clientinfo/default.js +157 -102
  36. package/dist/clientinfo/default.js.map +1 -1
  37. package/dist/clientinfo/index.browser.d.ts +4 -5
  38. package/dist/clientinfo/index.browser.js +5 -4
  39. package/dist/clientinfo/index.d.ts +4 -5
  40. package/dist/clientinfo/index.js +5 -4
  41. package/dist/clientinfo/meta-harness.d.ts +6 -3
  42. package/dist/clientinfo/meta-harness.d.ts.map +1 -1
  43. package/dist/clientinfo/meta-harness.js +30 -46
  44. package/dist/clientinfo/meta-harness.js.map +1 -1
  45. package/dist/http/http.d.ts +25 -22
  46. package/dist/http/http.d.ts.map +1 -1
  47. package/dist/http/http.js +24 -34
  48. package/dist/http/http.js.map +1 -1
  49. package/dist/http/index.d.ts +2 -8
  50. package/dist/http/index.js +3 -7
  51. package/dist/index.d.ts +1 -6
  52. package/dist/index.js +7 -5
  53. package/dist/index.js.map +1 -1
  54. package/dist/logger/index.d.ts +2 -8
  55. package/dist/logger/index.js +3 -7
  56. package/dist/logger/logger.d.ts +26 -23
  57. package/dist/logger/logger.d.ts.map +1 -1
  58. package/dist/logger/logger.js +46 -60
  59. package/dist/logger/logger.js.map +1 -1
  60. package/dist/ops/execute.d.ts +7 -3
  61. package/dist/ops/execute.d.ts.map +1 -1
  62. package/dist/ops/execute.js +55 -67
  63. package/dist/ops/execute.js.map +1 -1
  64. package/dist/ops/index.d.ts +5 -12
  65. package/dist/ops/index.js +4 -9
  66. package/dist/ops/limiter.d.ts +5 -2
  67. package/dist/ops/limiter.d.ts.map +1 -1
  68. package/dist/ops/limiter.js +0 -2
  69. package/dist/ops/options.d.ts +23 -19
  70. package/dist/ops/options.d.ts.map +1 -1
  71. package/dist/ops/options.js +0 -2
  72. package/dist/ops/retrier.d.ts +34 -31
  73. package/dist/ops/retrier.d.ts.map +1 -1
  74. package/dist/ops/retrier.js +55 -66
  75. package/dist/ops/retrier.js.map +1 -1
  76. package/dist/package.js +6 -0
  77. package/dist/package.js.map +1 -0
  78. package/dist/profiles/errors.d.ts +7 -4
  79. package/dist/profiles/errors.d.ts.map +1 -1
  80. package/dist/profiles/errors.js +16 -17
  81. package/dist/profiles/errors.js.map +1 -1
  82. package/dist/profiles/index.browser.d.ts +4 -10
  83. package/dist/profiles/index.browser.js +4 -8
  84. package/dist/profiles/index.d.ts +5 -15
  85. package/dist/profiles/index.js +5 -13
  86. package/dist/profiles/ini.d.ts +6 -3
  87. package/dist/profiles/ini.d.ts.map +1 -1
  88. package/dist/profiles/ini.js +60 -108
  89. package/dist/profiles/ini.js.map +1 -1
  90. package/dist/profiles/profile.d.ts +66 -67
  91. package/dist/profiles/profile.d.ts.map +1 -1
  92. package/dist/profiles/profile.js +89 -84
  93. package/dist/profiles/profile.js.map +1 -1
  94. package/dist/profiles/resolve.d.ts +8 -9
  95. package/dist/profiles/resolve.d.ts.map +1 -1
  96. package/dist/profiles/resolve.js +140 -185
  97. package/dist/profiles/resolve.js.map +1 -1
  98. package/dist/profiles/secret.d.ts +15 -12
  99. package/dist/profiles/secret.d.ts.map +1 -1
  100. package/dist/profiles/secret.js +38 -35
  101. package/dist/profiles/secret.js.map +1 -1
  102. package/dist/wkt/fieldmask.d.ts +23 -20
  103. package/dist/wkt/fieldmask.d.ts.map +1 -1
  104. package/dist/wkt/fieldmask.js +53 -62
  105. package/dist/wkt/fieldmask.js.map +1 -1
  106. package/dist/wkt/index.d.ts +3 -4
  107. package/dist/wkt/index.js +3 -2
  108. package/dist/wkt/value.d.ts +6 -3
  109. package/dist/wkt/value.d.ts.map +1 -1
  110. package/dist/wkt/value.js +0 -2
  111. package/package.json +2 -2
  112. package/dist/apierror/codes/index.d.ts.map +0 -1
  113. package/dist/apierror/codes/index.js.map +0 -1
  114. package/dist/apierror/index.d.ts.map +0 -1
  115. package/dist/apierror/index.js.map +0 -1
  116. package/dist/clientinfo/index.browser.d.ts.map +0 -1
  117. package/dist/clientinfo/index.browser.js.map +0 -1
  118. package/dist/clientinfo/index.d.ts.map +0 -1
  119. package/dist/clientinfo/index.js.map +0 -1
  120. package/dist/http/index.d.ts.map +0 -1
  121. package/dist/http/index.js.map +0 -1
  122. package/dist/index.d.ts.map +0 -1
  123. package/dist/logger/index.d.ts.map +0 -1
  124. package/dist/logger/index.js.map +0 -1
  125. package/dist/ops/index.d.ts.map +0 -1
  126. package/dist/ops/index.js.map +0 -1
  127. package/dist/ops/limiter.js.map +0 -1
  128. package/dist/ops/options.js.map +0 -1
  129. package/dist/profiles/index.browser.d.ts.map +0 -1
  130. package/dist/profiles/index.browser.js.map +0 -1
  131. package/dist/profiles/index.d.ts.map +0 -1
  132. package/dist/profiles/index.js.map +0 -1
  133. package/dist/wkt/index.d.ts.map +0 -1
  134. package/dist/wkt/index.js.map +0 -1
  135. package/dist/wkt/value.js.map +0 -1
@@ -1,127 +1,149 @@
1
+ import { sanitize } from "./clientinfo.js";
2
+
3
+ //#region src/clientinfo/agent.ts
1
4
  /**
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
- import { sanitize } from './clientinfo';
13
- // Name of the agents.md standard env var.
14
- const AGENT_ENV_VAR = 'AGENT';
15
- // Name of the Vercel @vercel/detect-agent convention env var. It serves
16
- // the same purpose as AGENT_ENV_VAR; agentEnvFallback consults it only when
17
- // AGENT_ENV_VAR is unset or empty.
18
- const AI_AGENT_ENV_VAR = 'AI_AGENT';
19
- // Caps fallback values to keep the user-agent bounded. Explicit-matcher
20
- // products are short by construction; only the fallback path can carry
21
- // arbitrary lengths.
5
+ * Detects the AI coding agent (e.g. Claude Code, Cursor, Gemini CLI) that
6
+ * is running the current Node.js process. The detected product name is
7
+ * appended to the user-agent header so that Databricks can understand
8
+ * which agents are invoking the SDK.
9
+ *
10
+ * The agent list and precedence rules are kept in sync across the Go,
11
+ * Java, Python, and TypeScript SDKs.
12
+ *
13
+ * @module
14
+ */
15
+ const AGENT_ENV_VAR = "AGENT";
16
+ const AI_AGENT_ENV_VAR = "AI_AGENT";
22
17
  const MAX_AGENT_FALLBACK_LEN = 64;
23
- // Canonical list of AI coding agents. Keep this list, and the AGENT /
24
- // AI_AGENT fallback handling in agentEnvFallback, in sync with the Go,
25
- // Java, and Python SDKs. Agents are listed alphabetically by product name.
26
18
  const KNOWN_AGENTS = [
27
- // The amp agent also sets AGENT=amp, handled by the central fallback.
28
- { envVar: 'AMP_CURRENT_THREAD_ID', product: 'amp' },
29
- { envVar: 'ANTIGRAVITY_AGENT', product: 'antigravity' },
30
- { envVar: 'AUGMENT_AGENT', product: 'augment' },
31
- { envVar: 'CLAUDECODE', product: 'claude-code' },
32
- { envVar: 'CLINE_ACTIVE', product: 'cline' },
33
- { envVar: 'CODEX_CI', product: 'codex' },
34
- { envVar: 'COPILOT_CLI', product: 'copilot-cli' },
35
- { envVar: 'CURSOR_AGENT', product: 'cursor' },
36
- { envVar: 'GEMINI_CLI', product: 'gemini-cli' },
37
- // The goose agent also sets AGENT=goose, handled by the central
38
- // fallback.
39
- { envVar: 'GOOSE_TERMINAL', product: 'goose' },
40
- { envVar: 'KIRO', product: 'kiro' },
41
- { envVar: 'OPENCLAW_SHELL', product: 'openclaw' },
42
- { envVar: 'OPENCODE', product: 'opencode' },
43
- // Set by VS Code 1.121+ for agent-initiated terminal commands
44
- // (https://code.visualstudio.com/updates/v1_121).
45
- { envVar: 'VSCODE_AGENT', product: 'vscode-agent' },
46
- { envVar: 'WINDSURF_AGENT', product: 'windsurf' },
19
+ {
20
+ envVar: "AMP_CURRENT_THREAD_ID",
21
+ product: "amp"
22
+ },
23
+ {
24
+ envVar: "ANTIGRAVITY_AGENT",
25
+ product: "antigravity"
26
+ },
27
+ {
28
+ envVar: "AUGMENT_AGENT",
29
+ product: "augment"
30
+ },
31
+ {
32
+ envVar: "CLAUDECODE",
33
+ product: "claude-code"
34
+ },
35
+ {
36
+ envVar: "CLINE_ACTIVE",
37
+ product: "cline"
38
+ },
39
+ {
40
+ envVar: "CODEX_CI",
41
+ product: "codex"
42
+ },
43
+ {
44
+ envVar: "COPILOT_CLI",
45
+ product: "copilot-cli"
46
+ },
47
+ {
48
+ envVar: "CURSOR_AGENT",
49
+ product: "cursor"
50
+ },
51
+ {
52
+ envVar: "GEMINI_CLI",
53
+ product: "gemini-cli"
54
+ },
55
+ {
56
+ envVar: "GOOSE_TERMINAL",
57
+ product: "goose"
58
+ },
59
+ {
60
+ envVar: "KIRO",
61
+ product: "kiro"
62
+ },
63
+ {
64
+ envVar: "OPENCLAW_SHELL",
65
+ product: "openclaw"
66
+ },
67
+ {
68
+ envVar: "OPENCODE",
69
+ product: "opencode"
70
+ },
71
+ {
72
+ envVar: "VSCODE_AGENT",
73
+ product: "vscode-agent"
74
+ },
75
+ {
76
+ envVar: "WINDSURF_AGENT",
77
+ product: "windsurf"
78
+ }
47
79
  ];
48
80
  /**
49
- * Returns a sanitized, length-capped name from `AGENT` or `AI_AGENT`,
50
- * preferring `AGENT` when both are non-empty. Empty is treated as unset for
51
- * both. The value is passed through rather than categorized so that new
52
- * names are propagated without the need to update the list of known agents.
53
- */
81
+ * Returns a sanitized, length-capped name from `AGENT` or `AI_AGENT`,
82
+ * preferring `AGENT` when both are non-empty. Empty is treated as unset for
83
+ * both. The value is passed through rather than categorized so that new
84
+ * names are propagated without the need to update the list of known agents.
85
+ */
54
86
  function agentEnvFallback() {
55
- let v = process.env[AGENT_ENV_VAR];
56
- if (v === undefined || v === '') {
57
- v = process.env[AI_AGENT_ENV_VAR];
58
- }
59
- if (v === undefined || v === '') {
60
- return '';
61
- }
62
- // slice is a no-op when the value is already within the cap.
63
- return sanitize(v).slice(0, MAX_AGENT_FALLBACK_LEN);
87
+ let v = process.env[AGENT_ENV_VAR];
88
+ if (v === void 0 || v === "") v = process.env[AI_AGENT_ENV_VAR];
89
+ if (v === void 0 || v === "") return "";
90
+ return sanitize(v).slice(0, MAX_AGENT_FALLBACK_LEN);
64
91
  }
65
92
  /**
66
- * Checks environment variables for known AI agents and returns the
67
- * detected product name.
68
- *
69
- * Explicit product-specific env vars always take precedence over the
70
- * generic `AGENT` and `AI_AGENT` env vars, so that an explicit signal
71
- * (e.g. `CLAUDECODE=1`) always wins over a conflicting `AGENT=<name>`
72
- * value.
73
- *
74
- * Returns:
75
- *
76
- * - The product name when exactly one known env var is set.
77
- * - `"multiple"` when multiple known env vars are set. Agent env vars
78
- * can be stacked when one agent invokes another as a subagent (e.g.
79
- * Claude Code spawning a Cursor CLI subprocess), so the child process
80
- * inherits env vars from multiple layers.
81
- * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no
82
- * known env var is set (see {@link agentEnvFallback}).
83
- * - `""` when nothing is set.
84
- */
85
- export function lookupAgentProvider() {
86
- const matches = [];
87
- for (const a of KNOWN_AGENTS) {
88
- if (a.envVar in process.env) {
89
- matches.push(a.product);
90
- }
91
- }
92
- if (matches.length === 1) {
93
- return matches[0];
94
- }
95
- if (matches.length > 1) {
96
- return 'multiple';
97
- }
98
- return agentEnvFallback();
93
+ * Checks environment variables for known AI agents and returns the
94
+ * detected product name.
95
+ *
96
+ * Explicit product-specific env vars always take precedence over the
97
+ * generic `AGENT` and `AI_AGENT` env vars, so that an explicit signal
98
+ * (e.g. `CLAUDECODE=1`) always wins over a conflicting `AGENT=<name>`
99
+ * value.
100
+ *
101
+ * Returns:
102
+ *
103
+ * - The product name when exactly one known env var is set.
104
+ * - `"multiple"` when multiple known env vars are set. Agent env vars
105
+ * can be stacked when one agent invokes another as a subagent (e.g.
106
+ * Claude Code spawning a Cursor CLI subprocess), so the child process
107
+ * inherits env vars from multiple layers.
108
+ * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no
109
+ * known env var is set (see {@link agentEnvFallback}).
110
+ * - `""` when nothing is set.
111
+ */
112
+ function lookupAgentProvider() {
113
+ const matches = [];
114
+ for (const a of KNOWN_AGENTS) if (a.envVar in process.env) matches.push(a.product);
115
+ if (matches.length === 1) return matches[0];
116
+ if (matches.length > 1) return "multiple";
117
+ return agentEnvFallback();
99
118
  }
100
119
  let cached;
101
120
  /**
102
- * Returns the detected AI agent name, cached for the process lifetime.
103
- *
104
- * Returns one of:
105
- *
106
- * - The known product name when exactly one agent is detected via
107
- * explicit env matchers.
108
- * - `"multiple"` when multiple explicit matchers fire for different
109
- * agents (typically nested agents, e.g. Cursor CLI running as a
110
- * Claude Code subagent).
111
- * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no
112
- * explicit matcher fired (see {@link agentEnvFallback}).
113
- * - `""` when no agent is detected.
114
- */
115
- export function agentProvider() {
116
- cached ??= lookupAgentProvider();
117
- return cached;
121
+ * Returns the detected AI agent name, cached for the process lifetime.
122
+ *
123
+ * Returns one of:
124
+ *
125
+ * - The known product name when exactly one agent is detected via
126
+ * explicit env matchers.
127
+ * - `"multiple"` when multiple explicit matchers fire for different
128
+ * agents (typically nested agents, e.g. Cursor CLI running as a
129
+ * Claude Code subagent).
130
+ * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no
131
+ * explicit matcher fired (see {@link agentEnvFallback}).
132
+ * - `""` when no agent is detected.
133
+ */
134
+ function agentProvider() {
135
+ cached ??= lookupAgentProvider();
136
+ return cached;
118
137
  }
119
138
  /**
120
- * Clears the cached agent detection result so that the next call to
121
- * {@link agentProvider} re-evaluates the environment. Exported for
122
- * testing only.
123
- */
124
- export function clearAgentCache() {
125
- cached = undefined;
139
+ * Clears the cached agent detection result so that the next call to
140
+ * {@link agentProvider} re-evaluates the environment. Exported for
141
+ * testing only.
142
+ */
143
+ function clearAgentCache() {
144
+ cached = void 0;
126
145
  }
146
+
147
+ //#endregion
148
+ export { agentProvider, clearAgentCache, lookupAgentProvider };
127
149
  //# sourceMappingURL=agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/clientinfo/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EA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AAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,SAAS,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"agent.js","names":[],"sources":["../../src/clientinfo/agent.ts"],"sourcesContent":["/**\n * Detects the AI coding agent (e.g. Claude Code, Cursor, Gemini CLI) that\n * is running the current Node.js process. The detected product name is\n * appended to the user-agent header so that Databricks can understand\n * which agents are invoking the SDK.\n *\n * The agent list and precedence rules are kept in sync across the Go,\n * Java, Python, and TypeScript SDKs.\n *\n * @module\n */\n\nimport {sanitize} from './clientinfo';\n\ninterface KnownAgent {\n readonly envVar: string;\n readonly product: string;\n}\n\n// Name of the agents.md standard env var.\nconst AGENT_ENV_VAR = 'AGENT';\n\n// Name of the Vercel @vercel/detect-agent convention env var. It serves\n// the same purpose as AGENT_ENV_VAR; agentEnvFallback consults it only when\n// AGENT_ENV_VAR is unset or empty.\nconst AI_AGENT_ENV_VAR = 'AI_AGENT';\n\n// Caps fallback values to keep the user-agent bounded. Explicit-matcher\n// products are short by construction; only the fallback path can carry\n// arbitrary lengths.\nconst MAX_AGENT_FALLBACK_LEN = 64;\n\n// Canonical list of AI coding agents. Keep this list, and the AGENT /\n// AI_AGENT fallback handling in agentEnvFallback, in sync with the Go,\n// Java, and Python SDKs. Agents are listed alphabetically by product name.\nconst KNOWN_AGENTS: readonly KnownAgent[] = [\n // The amp agent also sets AGENT=amp, handled by the central fallback.\n {envVar: 'AMP_CURRENT_THREAD_ID', product: 'amp'},\n {envVar: 'ANTIGRAVITY_AGENT', product: 'antigravity'},\n {envVar: 'AUGMENT_AGENT', product: 'augment'},\n {envVar: 'CLAUDECODE', product: 'claude-code'},\n {envVar: 'CLINE_ACTIVE', product: 'cline'},\n {envVar: 'CODEX_CI', product: 'codex'},\n {envVar: 'COPILOT_CLI', product: 'copilot-cli'},\n {envVar: 'CURSOR_AGENT', product: 'cursor'},\n {envVar: 'GEMINI_CLI', product: 'gemini-cli'},\n // The goose agent also sets AGENT=goose, handled by the central\n // fallback.\n {envVar: 'GOOSE_TERMINAL', product: 'goose'},\n {envVar: 'KIRO', product: 'kiro'},\n {envVar: 'OPENCLAW_SHELL', product: 'openclaw'},\n {envVar: 'OPENCODE', product: 'opencode'},\n // Set by VS Code 1.121+ for agent-initiated terminal commands\n // (https://code.visualstudio.com/updates/v1_121).\n {envVar: 'VSCODE_AGENT', product: 'vscode-agent'},\n {envVar: 'WINDSURF_AGENT', product: 'windsurf'},\n];\n\n/**\n * Returns a sanitized, length-capped name from `AGENT` or `AI_AGENT`,\n * preferring `AGENT` when both are non-empty. Empty is treated as unset for\n * both. The value is passed through rather than categorized so that new\n * names are propagated without the need to update the list of known agents.\n */\nfunction agentEnvFallback(): string {\n let v = process.env[AGENT_ENV_VAR];\n if (v === undefined || v === '') {\n v = process.env[AI_AGENT_ENV_VAR];\n }\n if (v === undefined || v === '') {\n return '';\n }\n // slice is a no-op when the value is already within the cap.\n return sanitize(v).slice(0, MAX_AGENT_FALLBACK_LEN);\n}\n\n/**\n * Checks environment variables for known AI agents and returns the\n * detected product name.\n *\n * Explicit product-specific env vars always take precedence over the\n * generic `AGENT` and `AI_AGENT` env vars, so that an explicit signal\n * (e.g. `CLAUDECODE=1`) always wins over a conflicting `AGENT=<name>`\n * value.\n *\n * Returns:\n *\n * - The product name when exactly one known env var is set.\n * - `\"multiple\"` when multiple known env vars are set. Agent env vars\n * can be stacked when one agent invokes another as a subagent (e.g.\n * Claude Code spawning a Cursor CLI subprocess), so the child process\n * inherits env vars from multiple layers.\n * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no\n * known env var is set (see {@link agentEnvFallback}).\n * - `\"\"` when nothing is set.\n */\nexport function lookupAgentProvider(): string {\n const matches: string[] = [];\n for (const a of KNOWN_AGENTS) {\n if (a.envVar in process.env) {\n matches.push(a.product);\n }\n }\n if (matches.length === 1) {\n return matches[0];\n }\n if (matches.length > 1) {\n return 'multiple';\n }\n return agentEnvFallback();\n}\n\nlet cached: string | undefined;\n\n/**\n * Returns the detected AI agent name, cached for the process lifetime.\n *\n * Returns one of:\n *\n * - The known product name when exactly one agent is detected via\n * explicit env matchers.\n * - `\"multiple\"` when multiple explicit matchers fire for different\n * agents (typically nested agents, e.g. Cursor CLI running as a\n * Claude Code subagent).\n * - A sanitized, length-capped value from `AGENT` or `AI_AGENT` when no\n * explicit matcher fired (see {@link agentEnvFallback}).\n * - `\"\"` when no agent is detected.\n */\nexport function agentProvider(): string {\n cached ??= lookupAgentProvider();\n return cached;\n}\n\n/**\n * Clears the cached agent detection result so that the next call to\n * {@link agentProvider} re-evaluates the environment. Exported for\n * testing only.\n */\nexport function clearAgentCache(): void {\n cached = undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,gBAAgB;AAKtB,MAAM,mBAAmB;AAKzB,MAAM,yBAAyB;AAK/B,MAAM,eAAsC;CAE1C;EAAC,QAAQ;EAAyB,SAAS;EAAM;CACjD;EAAC,QAAQ;EAAqB,SAAS;EAAc;CACrD;EAAC,QAAQ;EAAiB,SAAS;EAAU;CAC7C;EAAC,QAAQ;EAAc,SAAS;EAAc;CAC9C;EAAC,QAAQ;EAAgB,SAAS;EAAQ;CAC1C;EAAC,QAAQ;EAAY,SAAS;EAAQ;CACtC;EAAC,QAAQ;EAAe,SAAS;EAAc;CAC/C;EAAC,QAAQ;EAAgB,SAAS;EAAS;CAC3C;EAAC,QAAQ;EAAc,SAAS;EAAa;CAG7C;EAAC,QAAQ;EAAkB,SAAS;EAAQ;CAC5C;EAAC,QAAQ;EAAQ,SAAS;EAAO;CACjC;EAAC,QAAQ;EAAkB,SAAS;EAAW;CAC/C;EAAC,QAAQ;EAAY,SAAS;EAAW;CAGzC;EAAC,QAAQ;EAAgB,SAAS;EAAe;CACjD;EAAC,QAAQ;EAAkB,SAAS;EAAW;CAChD;;;;;;;AAQD,SAAS,mBAA2B;CAClC,IAAI,IAAI,QAAQ,IAAI;AACpB,KAAI,MAAM,UAAa,MAAM,GAC3B,KAAI,QAAQ,IAAI;AAElB,KAAI,MAAM,UAAa,MAAM,GAC3B,QAAO;AAGT,QAAO,SAAS,EAAE,CAAC,MAAM,GAAG,uBAAuB;;;;;;;;;;;;;;;;;;;;;;AAuBrD,SAAgB,sBAA8B;CAC5C,MAAM,UAAoB,EAAE;AAC5B,MAAK,MAAM,KAAK,aACd,KAAI,EAAE,UAAU,QAAQ,IACtB,SAAQ,KAAK,EAAE,QAAQ;AAG3B,KAAI,QAAQ,WAAW,EACrB,QAAO,QAAQ;AAEjB,KAAI,QAAQ,SAAS,EACnB,QAAO;AAET,QAAO,kBAAkB;;AAG3B,IAAI;;;;;;;;;;;;;;;AAgBJ,SAAgB,gBAAwB;AACtC,YAAW,qBAAqB;AAChC,QAAO;;;;;;;AAQT,SAAgB,kBAAwB;AACtC,UAAS"}
@@ -1,12 +1,8 @@
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: string;
1
+ import { ClientInfo } from "./clientinfo.js";
2
+
3
+ //#region src/clientinfo/base.d.ts
4
+ declare const MODULE_NAME = "sdk-js-core";
5
+ declare const VERSION: string;
10
6
  /**
11
7
  * Sets the product name and version globally. The version must be a
12
8
  * valid semver string.
@@ -14,7 +10,7 @@ export declare const VERSION: string;
14
10
  * Must be called before any client is created. Not safe for concurrent
15
11
  * use.
16
12
  */
17
- export declare function setProduct(name: string, version: string): void;
13
+ declare function setProduct(name: string, version: string): void;
18
14
  /**
19
15
  * Adds a partner identifier globally. Partner attribution is a
20
16
  * first-class concept used for support ticket routing.
@@ -22,7 +18,7 @@ export declare function setProduct(name: string, version: string): void;
22
18
  * Must be called before any client is created. Not safe for concurrent
23
19
  * use.
24
20
  */
25
- export declare function setPartner(partner: string): void;
21
+ declare function setPartner(partner: string): void;
26
22
  /**
27
23
  * Adds a global key/value segment that will be included in every
28
24
  * {@link createDefault} call. Same key with different values is allowed
@@ -32,8 +28,10 @@ export declare function setPartner(partner: string): void;
32
28
  * Must be called before any client is created. Not safe for concurrent
33
29
  * use.
34
30
  */
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;
31
+ declare function addToDefault(key: string, value: string): void;
32
+ declare function getBase(): ClientInfo;
33
+ declare function resetBase(): void;
34
+ declare function baseToString(): string;
35
+ //#endregion
36
+ export { MODULE_NAME, VERSION, addToDefault, baseToString, getBase, resetBase, setPartner, setProduct };
39
37
  //# sourceMappingURL=base.d.ts.map
@@ -1 +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;AAGnE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,OAAO,EAAE,MAAwB,CAAC;AAM/C;;;;;;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"}
1
+ {"version":3,"file":"base.d.ts","names":[],"sources":["../../src/clientinfo/base.ts"],"mappings":";;;cAUa,WAAA;AAAA,cACA,OAAA;;;;;AAab;;;iBAAgB,UAAA,CAAW,IAAA,UAAc,OAAA;;AAiBzC;;;;;AAaA;iBAbgB,UAAA,CAAW,OAAA;;;;AAkB3B;;;;;AAKA;iBAVgB,YAAA,CAAa,GAAA,UAAa,KAAA;AAAA,iBAK1B,OAAA,CAAA,GAAW,UAAA;AAAA,iBAKX,SAAA,CAAA;AAAA,iBAMA,YAAA,CAAA"}
@@ -1,62 +1,62 @@
1
+ import { ClientInfo, ClientInfoError, isSemVer } from "./clientinfo.js";
2
+ import { version } from "../package.js";
3
+
4
+ //#region src/clientinfo/base.ts
1
5
  /**
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
- import pkgJson from '../../package.json' with { type: 'json' };
9
- export const MODULE_NAME = 'sdk-js-core';
10
- export const VERSION = pkgJson.version;
11
- // Holds segments added via addToDefault, setProduct, and setPartner.
12
- // createDefault returns a copy of this with env detection appended.
6
+ * Shared state management for {@link ClientInfo} defaults. This module
7
+ * is browser-safe and contains no Node.js-specific APIs.
8
+ *
9
+ * @module
10
+ */
11
+ const MODULE_NAME = "sdk-js-core";
12
+ const VERSION = version;
13
13
  let base = ClientInfo.EMPTY;
14
14
  /**
15
- * Sets the product name and version globally. The version must be a
16
- * valid semver string.
17
- *
18
- * Must be called before any client is created. Not safe for concurrent
19
- * use.
20
- */
21
- export function setProduct(name, version) {
22
- if (!isSemVer(version)) {
23
- throw new ClientInfoError('INVALID_VERSION', `Invalid version: ${version}.`);
24
- }
25
- addToDefault(name, version);
15
+ * Sets the product name and version globally. The version must be a
16
+ * valid semver string.
17
+ *
18
+ * Must be called before any client is created. Not safe for concurrent
19
+ * use.
20
+ */
21
+ function setProduct(name, version) {
22
+ if (!isSemVer(version)) throw new ClientInfoError("INVALID_VERSION", `Invalid version: ${version}.`);
23
+ addToDefault(name, version);
26
24
  }
27
25
  /**
28
- * Adds a partner identifier globally. Partner attribution is a
29
- * first-class concept used for support ticket routing.
30
- *
31
- * Must be called before any client is created. Not safe for concurrent
32
- * use.
33
- */
34
- export function setPartner(partner) {
35
- addToDefault('partner', partner);
26
+ * Adds a partner identifier globally. Partner attribution is a
27
+ * first-class concept used for support ticket routing.
28
+ *
29
+ * Must be called before any client is created. Not safe for concurrent
30
+ * use.
31
+ */
32
+ function setPartner(partner) {
33
+ addToDefault("partner", partner);
36
34
  }
37
35
  /**
38
- * Adds a global key/value segment that will be included in every
39
- * {@link createDefault} call. Same key with different values is allowed
40
- * (e.g., multiple partners). Exact key+value duplicates are silently
41
- * ignored.
42
- *
43
- * Must be called before any client is created. Not safe for concurrent
44
- * use.
45
- */
46
- export function addToDefault(key, value) {
47
- base = base.with({ key, value });
36
+ * Adds a global key/value segment that will be included in every
37
+ * {@link createDefault} call. Same key with different values is allowed
38
+ * (e.g., multiple partners). Exact key+value duplicates are silently
39
+ * ignored.
40
+ *
41
+ * Must be called before any client is created. Not safe for concurrent
42
+ * use.
43
+ */
44
+ function addToDefault(key, value) {
45
+ base = base.with({
46
+ key,
47
+ value
48
+ });
48
49
  }
49
- // Returns the base ClientInfo for use in createDefault.
50
- export function getBase() {
51
- return base;
50
+ function getBase() {
51
+ return base;
52
52
  }
53
- // Resets the base segments. Exported for testing only.
54
- export function resetBase() {
55
- base = ClientInfo.EMPTY;
53
+ function resetBase() {
54
+ base = ClientInfo.EMPTY;
56
55
  }
57
- // Returns the base segments as a formatted string. Exported for
58
- // testing only.
59
- export function baseToString() {
60
- return base.toString();
56
+ function baseToString() {
57
+ return base.toString();
61
58
  }
59
+
60
+ //#endregion
61
+ export { MODULE_NAME, VERSION, addToDefault, baseToString, getBase, resetBase, setPartner, setProduct };
62
62
  //# sourceMappingURL=base.js.map
@@ -1 +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;AACnE,OAAO,OAAO,MAAM,oBAAoB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAW,OAAO,CAAC,OAAO,CAAC;AAE/C,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"}
1
+ {"version":3,"file":"base.js","names":["pkgJson.version"],"sources":["../../src/clientinfo/base.ts"],"sourcesContent":["/**\n * Shared state management for {@link ClientInfo} defaults. This module\n * is browser-safe and contains no Node.js-specific APIs.\n *\n * @module\n */\n\nimport {ClientInfo, ClientInfoError, isSemVer} from './clientinfo';\nimport pkgJson from '../../package.json' with {type: 'json'};\n\nexport const MODULE_NAME = 'sdk-js-core';\nexport const VERSION: string = pkgJson.version;\n\n// Holds segments added via addToDefault, setProduct, and setPartner.\n// createDefault returns a copy of this with env detection appended.\nlet base = ClientInfo.EMPTY;\n\n/**\n * Sets the product name and version globally. The version must be a\n * valid semver string.\n *\n * Must be called before any client is created. Not safe for concurrent\n * use.\n */\nexport function setProduct(name: string, version: string): void {\n if (!isSemVer(version)) {\n throw new ClientInfoError(\n 'INVALID_VERSION',\n `Invalid version: ${version}.`\n );\n }\n addToDefault(name, version);\n}\n\n/**\n * Adds a partner identifier globally. Partner attribution is a\n * first-class concept used for support ticket routing.\n *\n * Must be called before any client is created. Not safe for concurrent\n * use.\n */\nexport function setPartner(partner: string): void {\n addToDefault('partner', partner);\n}\n\n/**\n * Adds a global key/value segment that will be included in every\n * {@link createDefault} call. Same key with different values is allowed\n * (e.g., multiple partners). Exact key+value duplicates are silently\n * ignored.\n *\n * Must be called before any client is created. Not safe for concurrent\n * use.\n */\nexport function addToDefault(key: string, value: string): void {\n base = base.with({key, value});\n}\n\n// Returns the base ClientInfo for use in createDefault.\nexport function getBase(): ClientInfo {\n return base;\n}\n\n// Resets the base segments. Exported for testing only.\nexport function resetBase(): void {\n base = ClientInfo.EMPTY;\n}\n\n// Returns the base segments as a formatted string. Exported for\n// testing only.\nexport function baseToString(): string {\n return base.toString();\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAa,cAAc;AAC3B,MAAa,UAAkBA;AAI/B,IAAI,OAAO,WAAW;;;;;;;;AAStB,SAAgB,WAAW,MAAc,SAAuB;AAC9D,KAAI,CAAC,SAAS,QAAQ,CACpB,OAAM,IAAI,gBACR,mBACA,oBAAoB,QAAQ,GAC7B;AAEH,cAAa,MAAM,QAAQ;;;;;;;;;AAU7B,SAAgB,WAAW,SAAuB;AAChD,cAAa,WAAW,QAAQ;;;;;;;;;;;AAYlC,SAAgB,aAAa,KAAa,OAAqB;AAC7D,QAAO,KAAK,KAAK;EAAC;EAAK;EAAM,CAAC;;AAIhC,SAAgB,UAAsB;AACpC,QAAO;;AAIT,SAAgB,YAAkB;AAChC,QAAO,WAAW;;AAKpB,SAAgB,eAAuB;AACrC,QAAO,KAAK,UAAU"}
@@ -1,3 +1,4 @@
1
+ //#region src/clientinfo/clientinfo.d.ts
1
2
  /**
2
3
  * Collects information about the client and its environment into an
3
4
  * immutable {@link ClientInfo} value.
@@ -7,55 +8,56 @@
7
8
  *
8
9
  * @module
9
10
  */
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);
11
+ type ClientInfoErrorCode = 'INVALID_KEY' | 'INVALID_VALUE' | 'INVALID_VERSION';
12
+ declare class ClientInfoError extends Error {
13
+ readonly code: ClientInfoErrorCode;
14
+ constructor(code: ClientInfoErrorCode, message: string);
14
15
  }
15
16
  interface Segment {
16
- readonly key: string;
17
- readonly value: string;
17
+ readonly key: string;
18
+ readonly value: string;
18
19
  }
19
- export declare function isSemVer(s: string): boolean;
20
- export declare function isValidSegment(s: string): boolean;
20
+ declare function isSemVer(s: string): boolean;
21
+ declare function isValidSegment(s: string): boolean;
21
22
  /**
22
23
  * Replaces characters that are not valid in segment values with
23
24
  * hyphens. Used for environment-sourced values (runtime version,
24
25
  * upstream) that we do not control and cannot reject.
25
26
  */
26
- export declare function sanitize(s: string): string;
27
+ declare function sanitize(s: string): string;
27
28
  /**
28
29
  * ClientInfo is an immutable, ordered list of key/value segments. Use
29
30
  * {@link ClientInfo.with} to derive new values with additional segments.
30
31
  */
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;
32
+ declare class ClientInfo {
33
+ static readonly EMPTY: ClientInfo;
34
+ readonly segments: readonly Segment[];
35
+ private constructor();
36
+ /**
37
+ * Returns a new {@link ClientInfo} with the given items appended. Accepts
38
+ * either individual key/value pairs or another {@link ClientInfo} whose
39
+ * segments are merged in order. The original is not modified; mixing the
40
+ * two forms in a single call is supported.
41
+ *
42
+ * Keys and values on pair arguments must contain only alphanumeric
43
+ * characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
44
+ * silently ignored. On error, an exception is thrown (all-or-nothing).
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * base.with({key: 'partner', value: 'acme'});
49
+ * base.with(pkgClientInfo);
50
+ * base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
51
+ * ```
52
+ */
53
+ with(...items: (ClientInfo | Segment)[]): ClientInfo;
54
+ /**
55
+ * Returns a string representation of the client info suitable for
56
+ * inclusion in HTTP headers. Key/value pairs are formatted as
57
+ * "key/value" and joined by spaces in the order they were inserted.
58
+ */
59
+ toString(): string;
59
60
  }
60
- export {};
61
+ //#endregion
62
+ export { ClientInfo, ClientInfoError, ClientInfoErrorCode, isSemVer, isValidSegment, sanitize };
61
63
  //# sourceMappingURL=clientinfo.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"clientinfo.d.ts","names":[],"sources":["../../src/clientinfo/clientinfo.ts"],"mappings":";;AAUA;;;;;AAKA;;;KALY,mBAAA;AAAA,cAKC,eAAA,SAAwB,KAAA;EAAA,SAC1B,IAAA,EAAM,mBAAA;cAEH,IAAA,EAAM,mBAAA,EAAqB,OAAA;AAAA;AAAA,UAO/B,OAAA;EAAA,SACC,GAAA;EAAA,SACA,KAAA;A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