@superblocksteam/library-shared 1.99.99-next.3 → 2.0.0-SNAPSHOT.04704c19f32b3902

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 (175) hide show
  1. package/dist/computed.d.ts +4 -2
  2. package/dist/computed.d.ts.map +1 -1
  3. package/dist/computed.js +1 -1
  4. package/dist/computed.js.map +1 -1
  5. package/dist/default-structure.d.ts +12 -0
  6. package/dist/default-structure.d.ts.map +1 -0
  7. package/dist/default-structure.js +36 -0
  8. package/dist/default-structure.js.map +1 -0
  9. package/dist/event-trigger-constants.d.ts +2 -0
  10. package/dist/event-trigger-constants.d.ts.map +1 -0
  11. package/dist/event-trigger-constants.js +2 -0
  12. package/dist/event-trigger-constants.js.map +1 -0
  13. package/dist/index.d.ts +18 -9
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +17 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/layout.d.ts +12 -1
  18. package/dist/layout.d.ts.map +1 -1
  19. package/dist/layout.js +11 -4
  20. package/dist/layout.js.map +1 -1
  21. package/dist/mobx-sync/apply-patch.d.ts.map +1 -1
  22. package/dist/mobx-sync/apply-patch.js +23 -4
  23. package/dist/mobx-sync/apply-patch.js.map +1 -1
  24. package/dist/mobx-sync/to-patch.d.ts.map +1 -1
  25. package/dist/mobx-sync/to-patch.js.map +1 -1
  26. package/dist/pages.d.ts +76 -6
  27. package/dist/pages.d.ts.map +1 -1
  28. package/dist/pages.js +54 -2
  29. package/dist/pages.js.map +1 -1
  30. package/dist/pegs/find-string-interpolation.d.ts +12 -0
  31. package/dist/pegs/find-string-interpolation.d.ts.map +1 -0
  32. package/dist/pegs/find-string-interpolation.js +1265 -0
  33. package/dist/pegs/find-string-interpolation.js.map +1 -0
  34. package/dist/props/helpers.d.ts +1 -1
  35. package/dist/props/helpers.d.ts.map +1 -1
  36. package/dist/props/helpers.js +13 -5
  37. package/dist/props/helpers.js.map +1 -1
  38. package/dist/props/prop-types.d.ts +24 -13
  39. package/dist/props/prop-types.d.ts.map +1 -1
  40. package/dist/props/prop-types.js.map +1 -1
  41. package/dist/props/properties-panel.d.ts +61 -26
  42. package/dist/props/properties-panel.d.ts.map +1 -1
  43. package/dist/props/properties-panel.js +2 -5
  44. package/dist/props/properties-panel.js.map +1 -1
  45. package/dist/props/tailwind-property-keys.d.ts +5 -0
  46. package/dist/props/tailwind-property-keys.d.ts.map +1 -0
  47. package/dist/props/tailwind-property-keys.js +234 -0
  48. package/dist/props/tailwind-property-keys.js.map +1 -0
  49. package/dist/restart-contract.d.ts +35 -0
  50. package/dist/restart-contract.d.ts.map +1 -0
  51. package/dist/restart-contract.js +49 -0
  52. package/dist/restart-contract.js.map +1 -0
  53. package/dist/scope.d.ts +2 -0
  54. package/dist/scope.d.ts.map +1 -1
  55. package/dist/scope.js +3 -0
  56. package/dist/scope.js.map +1 -1
  57. package/dist/types/ai.d.ts +1721 -0
  58. package/dist/types/ai.d.ts.map +1 -0
  59. package/dist/types/ai.js +432 -0
  60. package/dist/types/ai.js.map +1 -0
  61. package/dist/types/apis.d.ts +44 -1
  62. package/dist/types/apis.d.ts.map +1 -1
  63. package/dist/types/base-entity-manager.d.ts +15 -0
  64. package/dist/types/base-entity-manager.d.ts.map +1 -0
  65. package/dist/types/base-entity-manager.js +2 -0
  66. package/dist/types/base-entity-manager.js.map +1 -0
  67. package/dist/types/common.d.ts +2 -1
  68. package/dist/types/common.d.ts.map +1 -1
  69. package/dist/types/edit-operations.d.ts +26 -23
  70. package/dist/types/edit-operations.d.ts.map +1 -1
  71. package/dist/types/edit-operations.js +2 -0
  72. package/dist/types/edit-operations.js.map +1 -1
  73. package/dist/types/entities.d.ts +10 -29
  74. package/dist/types/entities.d.ts.map +1 -1
  75. package/dist/types/entities.js +0 -5
  76. package/dist/types/entities.js.map +1 -1
  77. package/dist/types/errors.d.ts +82 -1
  78. package/dist/types/errors.d.ts.map +1 -1
  79. package/dist/types/errors.js +15 -1
  80. package/dist/types/errors.js.map +1 -1
  81. package/dist/types/events.d.ts +218 -26
  82. package/dist/types/events.d.ts.map +1 -1
  83. package/dist/types/events.js +33 -5
  84. package/dist/types/events.js.map +1 -1
  85. package/dist/types/index.d.ts +19 -7
  86. package/dist/types/index.d.ts.map +1 -1
  87. package/dist/types/index.js +19 -7
  88. package/dist/types/index.js.map +1 -1
  89. package/dist/types/migration.d.ts +240 -0
  90. package/dist/types/migration.d.ts.map +1 -0
  91. package/dist/types/migration.js +50 -0
  92. package/dist/types/migration.js.map +1 -0
  93. package/dist/types/mobx-shared-state.d.ts +27 -1
  94. package/dist/types/mobx-shared-state.d.ts.map +1 -1
  95. package/dist/types/parent-messages.d.ts +16 -7
  96. package/dist/types/parent-messages.d.ts.map +1 -1
  97. package/dist/types/persisted-chat-message.d.ts +55 -0
  98. package/dist/types/persisted-chat-message.d.ts.map +1 -0
  99. package/dist/types/persisted-chat-message.js +752 -0
  100. package/dist/types/persisted-chat-message.js.map +1 -0
  101. package/dist/types/protected-packages.d.ts +54 -0
  102. package/dist/types/protected-packages.d.ts.map +1 -0
  103. package/dist/types/protected-packages.js +91 -0
  104. package/dist/types/protected-packages.js.map +1 -0
  105. package/dist/types/register-component.d.ts +128 -0
  106. package/dist/types/register-component.d.ts.map +1 -0
  107. package/dist/types/register-component.js +45 -0
  108. package/dist/types/register-component.js.map +1 -0
  109. package/dist/types/routing.d.ts +68 -0
  110. package/dist/types/routing.d.ts.map +1 -0
  111. package/dist/types/routing.js +2 -0
  112. package/dist/types/routing.js.map +1 -0
  113. package/dist/types/runtime-sync.d.ts +32 -0
  114. package/dist/types/runtime-sync.d.ts.map +1 -0
  115. package/dist/types/runtime-sync.js +2 -0
  116. package/dist/types/runtime-sync.js.map +1 -0
  117. package/dist/types/scope.d.ts +8 -6
  118. package/dist/types/scope.d.ts.map +1 -1
  119. package/dist/types/snapshot.d.ts +53 -0
  120. package/dist/types/snapshot.d.ts.map +1 -0
  121. package/dist/types/snapshot.js +2 -0
  122. package/dist/types/snapshot.js.map +1 -0
  123. package/dist/types/socket.d.ts +668 -48
  124. package/dist/types/socket.d.ts.map +1 -1
  125. package/dist/types/theme.d.ts +8 -7
  126. package/dist/types/theme.d.ts.map +1 -1
  127. package/dist/types/theme.js +5 -6
  128. package/dist/types/theme.js.map +1 -1
  129. package/dist/types/tool-permission-response.d.ts +5 -0
  130. package/dist/types/tool-permission-response.d.ts.map +1 -0
  131. package/dist/types/tool-permission-response.js +26 -0
  132. package/dist/types/tool-permission-response.js.map +1 -0
  133. package/dist/types/vite.d.ts +29 -0
  134. package/dist/types/vite.d.ts.map +1 -0
  135. package/dist/types/vite.js +6 -0
  136. package/dist/types/vite.js.map +1 -0
  137. package/dist/urls.d.ts +7 -0
  138. package/dist/urls.d.ts.map +1 -0
  139. package/dist/urls.js +6 -0
  140. package/dist/urls.js.map +1 -0
  141. package/dist/utils/binding-identifier.d.ts +1 -0
  142. package/dist/utils/binding-identifier.d.ts.map +1 -1
  143. package/dist/utils/binding-identifier.js +3 -0
  144. package/dist/utils/binding-identifier.js.map +1 -1
  145. package/dist/utils/blocks.d.ts +3 -0
  146. package/dist/utils/blocks.d.ts.map +1 -0
  147. package/dist/utils/blocks.js +70 -0
  148. package/dist/utils/blocks.js.map +1 -0
  149. package/dist/utils/computed-args.d.ts +11 -0
  150. package/dist/utils/computed-args.d.ts.map +1 -0
  151. package/dist/utils/computed-args.js +13 -0
  152. package/dist/utils/computed-args.js.map +1 -0
  153. package/dist/utils/dev-server-authorization.d.ts +4 -0
  154. package/dist/utils/dev-server-authorization.d.ts.map +1 -0
  155. package/dist/utils/dev-server-authorization.js +56 -0
  156. package/dist/utils/dev-server-authorization.js.map +1 -0
  157. package/dist/utils/dotted-paths.js +1 -1
  158. package/dist/utils/dotted-paths.js.map +1 -1
  159. package/dist/utils/properties.d.ts +12 -9
  160. package/dist/utils/properties.d.ts.map +1 -1
  161. package/dist/utils/properties.js +14 -6
  162. package/dist/utils/properties.js.map +1 -1
  163. package/dist/utils/routing.d.ts +5 -0
  164. package/dist/utils/routing.d.ts.map +1 -0
  165. package/dist/utils/routing.js +16 -0
  166. package/dist/utils/routing.js.map +1 -0
  167. package/dist/utils/strings.d.ts +12 -0
  168. package/dist/utils/strings.d.ts.map +1 -1
  169. package/dist/utils/strings.js +40 -1
  170. package/dist/utils/strings.js.map +1 -1
  171. package/package.json +41 -25
  172. package/dist/apis.d.ts +0 -2
  173. package/dist/apis.d.ts.map +0 -1
  174. package/dist/apis.js +0 -4
  175. package/dist/apis.js.map +0 -1
@@ -0,0 +1,1721 @@
1
+ import type { AiQuotaPaywallReason, AppEnvironmentCompatibility, FactDto, PluginType, Profile } from "@superblocksteam/shared";
2
+ import type { InteractionMode, SbElement } from "./common.js";
3
+ export type PreviewDevice = "desktop" | "mobile";
4
+ export type EditorView = "code-viewer" | "git-setup" | "integration-setup" | "publish" | "preview";
5
+ export type DataTag = Profile;
6
+ export declare enum AiPermissionType {
7
+ READ = "read",
8
+ WRITE = "write",
9
+ DELETE = "delete"
10
+ }
11
+ export interface AiToolPermission {
12
+ entityType: AiEntityType;
13
+ entityId: string | undefined;
14
+ permissionType: AiPermissionType;
15
+ }
16
+ export declare enum AiEntityType {
17
+ COMPONENT = "component",
18
+ API = "api",
19
+ TIMER = "timer",
20
+ STATE_VARIABLE = "stateVariable",
21
+ INTEGRATION = "integration",
22
+ EVENT = "event",
23
+ THEME = "theme",
24
+ PAGE = "page",
25
+ PROFILE = "profile",
26
+ GROUP = "group",
27
+ USER = "user",
28
+ BLOCK = "block"
29
+ }
30
+ /**
31
+ * Serialized context entity for homepage prompt handoff (sessionStorage).
32
+ * Code-mode maps these to ContextEntity when building initialContextEntities.
33
+ */
34
+ export type HomepageContextEntity = {
35
+ id: string;
36
+ type: AiEntityType;
37
+ name: string;
38
+ pluginId?: string;
39
+ };
40
+ interface AiChatMessageBase {
41
+ role: "user" | "assistant" | "system";
42
+ content: string;
43
+ type?: "text" | "reasoning" | "changeInfo" | "appGenerationDone" | "appGenerationCanceled" | "draftAccepted" | "draftRejected" | "draftCommitted" | "commitRestored" | "commitRestoring" | "sessionTerminated" | "control" | "clark" | "context" | "tool" | "tool-result" | "tool-error" | "text-delta" | "plan" | "plan-delta" | "confirm" | "confirm_response" | "multi_choice" | "multi_choice_response" | "searchable_dropdown" | "searchable_dropdown_response" | "remember_knowledge_draft" | "remember_knowledge_draft_response" | "plan_response" | "tool_permission_request" | "test_run_start" | "test_step" | "test_run_end" | "test_case_update" | "git_setup_required" | "knowledge" | "app_knowledge_saved" | "retry_notification" | "system_notification" | "error" | "next_steps" | "aws_infra_demo";
44
+ id?: string;
45
+ timestamp?: number;
46
+ group?: string;
47
+ action?: "create" | "edit" | "delete" | "transient";
48
+ status?: "pending" | "ready" | "error" | "validated" | "cancelled";
49
+ agentHeader?: string;
50
+ name?: string;
51
+ attachments?: Array<Attachment>;
52
+ mode?: AiMode;
53
+ authorEmail?: string | null;
54
+ authorName?: string | null;
55
+ title?: string;
56
+ }
57
+ type BaseToolCallChatMessage = AiChatMessageBase & {
58
+ type: "tool";
59
+ streaming?: boolean;
60
+ toolCallId?: string;
61
+ error?: string;
62
+ errorCode?: AiToolExecutionErrorCode;
63
+ errorSummary?: string;
64
+ output?: any;
65
+ signature?: string;
66
+ requiresUserPermission?: boolean;
67
+ };
68
+ type BuildCaptureScreenshotToolCallChatMessage = {
69
+ tool: "build_captureScreenshot";
70
+ args: undefined;
71
+ output?: {
72
+ screenshotFileName?: string;
73
+ };
74
+ };
75
+ type BuildNavigatePreviewToolCallChatMessage = {
76
+ tool: "build_navigatePreview";
77
+ args: {
78
+ hash?: string;
79
+ path: string;
80
+ queryParams?: Record<string, string>;
81
+ routeParams?: Record<string, string>;
82
+ };
83
+ output?: {
84
+ message?: string;
85
+ path?: string;
86
+ success?: boolean;
87
+ };
88
+ };
89
+ type BuildCopyToolOutput = {
90
+ copied?: string[];
91
+ copiedCount: number;
92
+ rejected?: Array<{
93
+ path: string;
94
+ reason: string;
95
+ }>;
96
+ rejectedCount: number;
97
+ skipped?: Array<{
98
+ path: string;
99
+ reason: "destination_exists" | "default_excluded";
100
+ }>;
101
+ skippedCount: number;
102
+ };
103
+ type BuildCopyDirectoryToolCallChatMessage = {
104
+ tool: "build_copyDirectory";
105
+ args: {
106
+ conflictStrategy?: "fail" | "skip" | "replace";
107
+ destinationDir: string;
108
+ sourceDir: string;
109
+ verbose?: boolean;
110
+ };
111
+ output?: BuildCopyToolOutput;
112
+ };
113
+ type BuildCopyFileToolCallChatMessage = {
114
+ tool: "build_copyFile";
115
+ args: {
116
+ conflictStrategy?: "fail" | "skip" | "replace";
117
+ destinationPath: string;
118
+ sourcePath: string;
119
+ verbose?: boolean;
120
+ };
121
+ output?: BuildCopyToolOutput;
122
+ };
123
+ type BuildWriteFileToolCallChatMessage = {
124
+ tool: "build_writeFile";
125
+ args: {
126
+ filePath: string;
127
+ content: string;
128
+ };
129
+ };
130
+ type BuildEditFileToolCallChatMessage = {
131
+ tool: "build_editFile";
132
+ args: {
133
+ filePath: string;
134
+ oldString: string;
135
+ newString: string;
136
+ replaceAll?: boolean;
137
+ };
138
+ };
139
+ type BuildMultiEditFileToolCallChatMessage = {
140
+ tool: "build_multiEditFile";
141
+ args: {
142
+ filePath: string;
143
+ edits: Array<{
144
+ oldString: string;
145
+ newString: string;
146
+ replaceAll?: boolean;
147
+ }>;
148
+ };
149
+ };
150
+ type BuildDeleteFileToolCallChatMessage = {
151
+ tool: "build_deleteFile";
152
+ args: {
153
+ filePath: string;
154
+ reason?: string;
155
+ };
156
+ };
157
+ type BuildRenameFileToolCallChatMessage = {
158
+ tool: "build_renameFile";
159
+ args: {
160
+ oldPath: string;
161
+ newPath: string;
162
+ };
163
+ };
164
+ type BuildReadFilesToolCallChatMessage = {
165
+ tool: "build_readFiles";
166
+ args: {
167
+ filePaths: string[];
168
+ };
169
+ };
170
+ type BuildReadFileToolCallChatMessage = {
171
+ tool: "build_readFile";
172
+ args: {
173
+ filePath: string;
174
+ ranges?: Array<{
175
+ start: number;
176
+ end: number;
177
+ }>;
178
+ };
179
+ };
180
+ type BuildGenerateApiSourceToolCallChatMessage = {
181
+ tool: "build_generateApiSource";
182
+ args: {
183
+ apiName: string;
184
+ action: "create" | "edit";
185
+ };
186
+ };
187
+ type ReadIntegrationMetadataToolCallChatMessage = {
188
+ tool: "readIntegrationMetadata";
189
+ args: {
190
+ integrationName: string;
191
+ };
192
+ };
193
+ type FetchIntegrationToolCallChatMessage = {
194
+ tool: "fetchIntegration";
195
+ args: {
196
+ integrationName: string;
197
+ };
198
+ };
199
+ type WriteApiToolCallChatMessage = {
200
+ tool: "writeApi";
201
+ args: {
202
+ apiName: string;
203
+ apiSource: string;
204
+ };
205
+ };
206
+ type BuildApiToolCallChatMessage = {
207
+ tool: "buildApi";
208
+ args: {
209
+ apiName: string;
210
+ };
211
+ };
212
+ type TestApiToolCallChatMessage = {
213
+ tool: "testApi";
214
+ args: {
215
+ apiName: string;
216
+ inputs: Record<string, any>;
217
+ };
218
+ };
219
+ type SearchIntegrationsToolCallChatMessage = {
220
+ tool: "searchIntegrations";
221
+ args: {
222
+ type?: PluginType;
223
+ name?: string;
224
+ };
225
+ };
226
+ type ReadIntegrationMetadataForPromptToolCallChatMessage = {
227
+ tool: "readIntegrationMetadataForPrompt";
228
+ args: {
229
+ integrationNames: string[];
230
+ };
231
+ };
232
+ type GrepMetadataToolCallChatMessage = {
233
+ tool: "grepMetadata";
234
+ args: {
235
+ integrationId: string;
236
+ grepPattern: string;
237
+ limit?: number;
238
+ includeDetails?: boolean;
239
+ startIndex?: number;
240
+ };
241
+ };
242
+ type ExecuteRequestToIntegrationToolCallChatMessage = {
243
+ tool: "executeRequestToIntegration";
244
+ args: {
245
+ integrationId: string;
246
+ integrationName: string;
247
+ description?: {
248
+ request: string;
249
+ present: string;
250
+ past: string;
251
+ };
252
+ params?: {
253
+ type: "sql" | "graphql" | "rest" | "other" | "salesforce";
254
+ query?: string;
255
+ graphQLQuery?: {
256
+ query: string;
257
+ variables?: Record<string, unknown>;
258
+ headers?: Record<string, string>;
259
+ };
260
+ httpRequest?: {
261
+ path: string;
262
+ headers?: Record<string, string>;
263
+ queryParams?: Record<string, string>;
264
+ };
265
+ body?: string;
266
+ };
267
+ };
268
+ };
269
+ type RunCodeToolCallChatMessage = {
270
+ tool: "runCode";
271
+ args: {
272
+ integrationId: string;
273
+ integrationName: string;
274
+ script?: string;
275
+ };
276
+ };
277
+ type BuildInstallPackagesToolCallChatMessage = {
278
+ tool: "build_installPackages";
279
+ args?: {
280
+ packages?: Array<{
281
+ name: string;
282
+ version?: string;
283
+ dev?: boolean;
284
+ }>;
285
+ remove?: string[];
286
+ };
287
+ };
288
+ type BuildLookupNpmPackageToolCallChatMessage = {
289
+ tool: "build_lookupNpmPackage";
290
+ args?: {
291
+ name?: string;
292
+ };
293
+ output?: {
294
+ available?: boolean;
295
+ mode?: "private" | "public-npm" | "fail-closed";
296
+ reason?: "not_in_registry" | "registry_auth_failed" | "registry_unreachable";
297
+ registry_host?: string;
298
+ latest_version?: string;
299
+ recent_versions?: string[];
300
+ };
301
+ };
302
+ type SimpleToolCallChatMessage = {
303
+ tool: "build_manageChecklist" | "build_listFiles" | "build_debug" | "build_finalize" | "downloadAttachments" | "glob" | "grep" | "ls" | "getApiDocs" | "getIntegrationTypes" | "get_runtime_errors" | "get_console_logs" | "get_logs" | "clear_error_cache" | "listAttachments" | "exitPlanMode" | "closeIntegrationSetup" | "listAvailableIntegrationTypes" | "listTasks";
304
+ args: undefined;
305
+ };
306
+ type ProvisionDatabaseToolCallChatMessage = {
307
+ tool: "provisionDatabase";
308
+ args: {
309
+ requirement: {
310
+ logicalName: string;
311
+ migrationDirectory?: string;
312
+ };
313
+ };
314
+ output?: {
315
+ taskId: string;
316
+ label?: string;
317
+ state?: string;
318
+ };
319
+ };
320
+ type StartApplyDevDatabaseMigrationsToolCallChatMessage = {
321
+ tool: "startApplyDevDatabaseMigrations";
322
+ args: {
323
+ bindingKey?: string;
324
+ };
325
+ output?: {
326
+ taskId: string;
327
+ label?: string;
328
+ state?: string;
329
+ };
330
+ };
331
+ type CheckTaskToolCallChatMessage = {
332
+ tool: "checkTask";
333
+ args: {
334
+ taskId: string;
335
+ };
336
+ output?: {
337
+ taskId: string;
338
+ state?: string;
339
+ message?: string;
340
+ label?: string;
341
+ };
342
+ };
343
+ type WaitForTaskToolCallChatMessage = {
344
+ tool: "waitForTask";
345
+ args: {
346
+ taskId: string;
347
+ timeoutMs?: number;
348
+ };
349
+ output?: {
350
+ taskId: string;
351
+ state?: string;
352
+ message?: string;
353
+ label?: string;
354
+ timedOut?: boolean;
355
+ };
356
+ };
357
+ type CancelTaskToolCallChatMessage = {
358
+ tool: "cancelTask";
359
+ args: {
360
+ taskId: string;
361
+ };
362
+ output?: {
363
+ taskId: string;
364
+ state?: string;
365
+ label?: string;
366
+ };
367
+ };
368
+ type SpawnCodingSubagentsToolCallChatMessage = {
369
+ tool: "spawnCodingSubagents";
370
+ /**
371
+ * Compact wire shape forwarded by `getToolCallArguments` — `instructions`
372
+ * is intentionally stripped before persistence so we don't balloon chat
373
+ * messages with sub-agent prompts. Only fields the chat UI needs survive.
374
+ */
375
+ args: {
376
+ subagents: Array<{
377
+ id: string;
378
+ apiNames?: string[];
379
+ }>;
380
+ maxStepsPerSubagent?: number;
381
+ };
382
+ output?: {
383
+ success?: boolean;
384
+ completed?: number;
385
+ errored?: number;
386
+ maxSteps?: number;
387
+ };
388
+ };
389
+ type GetSdkApiDocsToolCallChatMessage = {
390
+ tool: "getSdkApiDocs";
391
+ args: {
392
+ integrationIds?: string[];
393
+ pluginIds?: string[];
394
+ };
395
+ output?: {
396
+ pluginIds: string[];
397
+ };
398
+ };
399
+ type BuildReloadFileToolCallChatMessage = {
400
+ tool: "build_reloadFile";
401
+ args: {
402
+ filePath: string;
403
+ };
404
+ };
405
+ export type BrowserPlaywrightToolCallChatMessage = {
406
+ tool: "browser_playwright_action";
407
+ args: {
408
+ action: "navigate" | "click" | "fill" | "screenshot" | "getText" | "getUrl" | "evaluate" | "waitForSelector" | "reload" | "getConsoleLogs" | "getEmbedEvents" | "triggerEmbedEvent" | "setEmbedProperties";
409
+ url?: string;
410
+ selector?: string;
411
+ value?: string;
412
+ fullPage?: boolean;
413
+ script?: string;
414
+ clear?: boolean;
415
+ eventName?: string;
416
+ payload?: Record<string, unknown>;
417
+ properties?: Record<string, unknown>;
418
+ };
419
+ };
420
+ type WebSearchToolCallChatMessage = {
421
+ tool: "web_search";
422
+ args: {
423
+ query: string;
424
+ allowed_domains?: string[];
425
+ blocked_domains?: string[];
426
+ };
427
+ };
428
+ type WebFetchToolCallChatMessage = {
429
+ tool: "web_fetch";
430
+ args: {
431
+ url: string;
432
+ prompt: string;
433
+ };
434
+ };
435
+ type GitToolCallChatMessage = {
436
+ tool: "git";
437
+ args: Record<string, any>;
438
+ };
439
+ type GitRawToolCallChatMessage = {
440
+ tool: "git_raw";
441
+ args: Record<string, any>;
442
+ };
443
+ type OpenIntegrationSetupToolCallChatMessage = {
444
+ tool: "openIntegrationSetup";
445
+ args: {
446
+ pluginId: string;
447
+ fields?: Record<string, unknown>;
448
+ label?: string;
449
+ };
450
+ output?: {
451
+ success: boolean;
452
+ tabId?: string;
453
+ formState?: unknown;
454
+ };
455
+ };
456
+ type OpenExistingIntegrationToolCallChatMessage = {
457
+ tool: "openExistingIntegration";
458
+ args: {
459
+ integrationId: string;
460
+ };
461
+ output?: {
462
+ success: boolean;
463
+ tabId?: string;
464
+ pluginId?: string;
465
+ integrationName?: string;
466
+ formState?: unknown;
467
+ };
468
+ };
469
+ type UpdateIntegrationFieldsToolCallChatMessage = {
470
+ tool: "updateIntegrationFields";
471
+ args: {
472
+ fields: Record<string, unknown>;
473
+ configId?: string;
474
+ };
475
+ output?: {
476
+ success: boolean;
477
+ formState?: unknown;
478
+ error?: string;
479
+ };
480
+ };
481
+ type UpdateAppEnvironmentToolCallChatMessage = {
482
+ tool: "updateAppEnvironment";
483
+ args: {
484
+ changes: Array<{
485
+ addProfileIds?: string[];
486
+ defaultProfileId?: string;
487
+ mode: "deployed" | "editor" | "preview";
488
+ removeProfileIds?: string[];
489
+ }>;
490
+ };
491
+ };
492
+ type TestIntegrationConnectionToolCallChatMessage = {
493
+ tool: "testIntegrationConnection";
494
+ args: {
495
+ configId?: string;
496
+ };
497
+ output?: {
498
+ success: boolean;
499
+ configId?: string;
500
+ error?: {
501
+ message: string;
502
+ details: string;
503
+ };
504
+ formState?: unknown;
505
+ };
506
+ };
507
+ type SaveIntegrationToolCallChatMessage = {
508
+ tool: "saveIntegration";
509
+ args: {
510
+ force?: boolean;
511
+ };
512
+ output?: {
513
+ success: boolean;
514
+ integrationId?: string;
515
+ testFailed?: boolean;
516
+ failedConfigIds?: string[];
517
+ validationErrors?: Record<string, string>;
518
+ error?: string;
519
+ };
520
+ };
521
+ type AskSearchableDropdownToolCallChatMessage = {
522
+ tool: "askSearchableDropdown";
523
+ args: {
524
+ question: string;
525
+ options: {
526
+ label: string;
527
+ value: string;
528
+ }[];
529
+ };
530
+ };
531
+ type DeleteIntegrationToolCallChatMessage = {
532
+ tool: "deleteIntegration";
533
+ args: {
534
+ integrationId: string;
535
+ };
536
+ output?: {
537
+ success: boolean;
538
+ integrationId?: string;
539
+ integrationName?: string;
540
+ alreadyDeleted?: boolean;
541
+ error?: string;
542
+ };
543
+ };
544
+ type GetIntegrationFormSchemaToolCallChatMessage = {
545
+ tool: "getIntegrationFormSchema";
546
+ args: {
547
+ pluginId: string;
548
+ };
549
+ };
550
+ export type ToolName = AiToolCallChatMessage["tool"];
551
+ type RunMigrationVerificationToolCallChatMessage = {
552
+ tool: "runMigrationVerification";
553
+ args: {
554
+ apiName: string;
555
+ attemptCount?: number;
556
+ };
557
+ };
558
+ type ToolWithArgs = SimpleToolCallChatMessage | RunMigrationVerificationToolCallChatMessage | BuildInstallPackagesToolCallChatMessage | BuildLookupNpmPackageToolCallChatMessage | BuildCopyDirectoryToolCallChatMessage | BuildCopyFileToolCallChatMessage | BuildWriteFileToolCallChatMessage | BuildEditFileToolCallChatMessage | BuildMultiEditFileToolCallChatMessage | BuildDeleteFileToolCallChatMessage | BuildRenameFileToolCallChatMessage | BuildReadFilesToolCallChatMessage | BuildGenerateApiSourceToolCallChatMessage | ReadIntegrationMetadataToolCallChatMessage | FetchIntegrationToolCallChatMessage | SearchIntegrationsToolCallChatMessage | ReadIntegrationMetadataForPromptToolCallChatMessage | GrepMetadataToolCallChatMessage | ExecuteRequestToIntegrationToolCallChatMessage | RunCodeToolCallChatMessage | WriteApiToolCallChatMessage | BuildApiToolCallChatMessage | TestApiToolCallChatMessage | BuildReloadFileToolCallChatMessage | BuildReadFileToolCallChatMessage | BrowserPlaywrightToolCallChatMessage | BuildCaptureScreenshotToolCallChatMessage | BuildNavigatePreviewToolCallChatMessage | WebSearchToolCallChatMessage | WebFetchToolCallChatMessage | RememberKnowledgeToolCallChatMessage | GitToolCallChatMessage | GitRawToolCallChatMessage | OpenIntegrationSetupToolCallChatMessage | OpenExistingIntegrationToolCallChatMessage | UpdateAppEnvironmentToolCallChatMessage | UpdateIntegrationFieldsToolCallChatMessage | TestIntegrationConnectionToolCallChatMessage | AskSearchableDropdownToolCallChatMessage | DeleteIntegrationToolCallChatMessage | GetIntegrationFormSchemaToolCallChatMessage | SaveIntegrationToolCallChatMessage | GetSdkApiDocsToolCallChatMessage | SpawnCodingSubagentsToolCallChatMessage | ProvisionDatabaseToolCallChatMessage | StartApplyDevDatabaseMigrationsToolCallChatMessage | CheckTaskToolCallChatMessage | WaitForTaskToolCallChatMessage | CancelTaskToolCallChatMessage;
559
+ export type AiToolCallChatMessage = BaseToolCallChatMessage & ToolWithArgs;
560
+ export interface AiChecklistChatMessage extends AiChatMessageBase {
561
+ type: "tool";
562
+ group: "checklist";
563
+ checklistData: {
564
+ type: "checklist_item_added" | "checklist_item_updated" | "checklist_cleared";
565
+ payload: {
566
+ item?: {
567
+ id: string;
568
+ content: string;
569
+ status: "pending" | "in_progress" | "completed" | "cancelled" | "failed";
570
+ createdAt: string;
571
+ updatedAt?: string;
572
+ failureReason?: string;
573
+ };
574
+ totalItems?: number;
575
+ completedItems?: number;
576
+ };
577
+ };
578
+ }
579
+ type Choice = string | {
580
+ text: string;
581
+ subText?: string;
582
+ action?: "approve" | "deny";
583
+ };
584
+ export interface AiMultiChoiceMessage extends AiChatMessageBase {
585
+ type: "multi_choice";
586
+ subtitle?: string;
587
+ details?: string;
588
+ choices: Array<Choice>;
589
+ selectionType?: "single" | "multiple";
590
+ questionType?: "api_integration_error";
591
+ userResponse?: AiMultiChoiceResponseMessage;
592
+ /**
593
+ * Knowledge candidates embedded in approval prompts so they can be
594
+ * recovered from chat history after a page reload (when clark.context is gone).
595
+ */
596
+ knowledgeCandidates?: RememberKnowledgeCandidate[];
597
+ }
598
+ export interface AiSearchableDropdownMessage extends AiChatMessageBase {
599
+ type: "searchable_dropdown";
600
+ options: AiSearchableDropdownOption[];
601
+ placeholder?: string;
602
+ userResponse?: AiSearchableDropdownResponseMessage;
603
+ }
604
+ export interface AiSearchableDropdownResponseMessage extends AiChatMessageBase {
605
+ type: "searchable_dropdown_response";
606
+ responseToMessageId: string;
607
+ selectedValue: string;
608
+ selectedLabel: string;
609
+ }
610
+ export interface AiRememberKnowledgeDraftMessage extends AiChatMessageBase {
611
+ type: "remember_knowledge_draft";
612
+ candidates: RememberKnowledgeCandidate[];
613
+ userResponse?: AiRememberKnowledgeDraftResponseMessage;
614
+ }
615
+ export interface AiConfirmMessage extends AiChatMessageBase {
616
+ type: "confirm";
617
+ knowledgeEntry?: AiAppFactInput;
618
+ userResponse?: AiConfirmResponseMessage;
619
+ }
620
+ export interface AiPlanMessage extends AiChatMessageBase {
621
+ type: "plan";
622
+ userResponse?: AiPlanResponseMessage;
623
+ streaming?: boolean;
624
+ integrations?: PromptContextIntegration[];
625
+ entities?: PromptContextEntity[];
626
+ title?: string;
627
+ includesFreshDatabase?: boolean;
628
+ }
629
+ export interface AiPlanDeltaMessage extends AiChatMessageBase {
630
+ type: "plan-delta";
631
+ streaming?: boolean;
632
+ }
633
+ export interface AiMultiChoiceResponseMessage extends AiChatMessageBase {
634
+ type: "multi_choice_response";
635
+ responseToMessageId: string;
636
+ selectedChoiceIndices: number[];
637
+ selectedScopes?: KnowledgePromotionSelection[];
638
+ savedFacts?: SavedKnowledgeFact[];
639
+ }
640
+ export interface AiConfirmResponseMessage extends AiChatMessageBase {
641
+ type: "confirm_response";
642
+ responseToMessageId: string;
643
+ approved: boolean;
644
+ selectedScopes?: KnowledgePromotionSelection[];
645
+ savedFacts?: SavedKnowledgeFact[];
646
+ }
647
+ export interface AiPlanResponseMessage extends AiChatMessageBase {
648
+ type: "plan_response";
649
+ responseToMessageId: string;
650
+ enableTesting?: boolean;
651
+ approved?: boolean;
652
+ }
653
+ export interface AiRememberKnowledgeDraftResponseMessage extends AiChatMessageBase {
654
+ type: "remember_knowledge_draft_response";
655
+ responseToMessageId: string;
656
+ selectedCandidateIndices: number[];
657
+ selectedScopes?: KnowledgePromotionSelection[];
658
+ savedFacts?: SavedKnowledgeFact[];
659
+ }
660
+ export type KnowledgePromotionScope = "app" | "org" | "user" | "integration";
661
+ export type KnowledgePromotionSelection = {
662
+ candidateIndex: number;
663
+ entityScope: KnowledgePromotionScope;
664
+ entityId?: string;
665
+ };
666
+ export type SavedKnowledgeFact = {
667
+ candidateIndex: number;
668
+ scope: KnowledgePromotionScope;
669
+ factName: string;
670
+ factId?: string;
671
+ };
672
+ export interface AiCommitRestoringMessage extends AiChatMessageBase {
673
+ type: "commitRestoring";
674
+ commitId: string;
675
+ }
676
+ export interface AiCommitRestoredMessage extends AiChatMessageBase {
677
+ type: "commitRestored";
678
+ commitId?: string;
679
+ }
680
+ export interface AiDraftCommittedMessage extends AiChatMessageBase {
681
+ type: "draftCommitted";
682
+ commitId?: string;
683
+ }
684
+ export type TestCasePlan = {
685
+ id: string;
686
+ name: string;
687
+ description?: string;
688
+ status: "not_started" | "running" | "passed" | "failed" | "skipped";
689
+ };
690
+ export interface AiTestRunStartMessage extends AiChatMessageBase {
691
+ type: "test_run_start";
692
+ testRunId: string;
693
+ header: string;
694
+ testCases?: TestCasePlan[];
695
+ }
696
+ export interface AiTestRunEndMessage extends AiChatMessageBase {
697
+ type: "test_run_end";
698
+ testRunId: string;
699
+ testStatus: "completed" | "failed";
700
+ summary?: string;
701
+ }
702
+ export interface AiTestCaseUpdateMessage extends AiChatMessageBase {
703
+ type: "test_case_update";
704
+ testRunId: string;
705
+ testCaseId: string;
706
+ testCaseStatus: "running" | "passed" | "failed" | "skipped";
707
+ }
708
+ export interface AiToolPermissionDetails {
709
+ targets: string[];
710
+ details?: string;
711
+ summary?: string;
712
+ /** Type of entity being deleted (for build_deleteFile) */
713
+ entityType?: "api" | "page" | "file";
714
+ /** Name of the entity being deleted (for build_deleteFile) */
715
+ entityName?: string;
716
+ }
717
+ export interface AiToolPermissionRequestMessage extends AiChatMessageBase {
718
+ type: "tool_permission_request";
719
+ toolName: string;
720
+ actionName?: {
721
+ future: string;
722
+ present: string;
723
+ past: string;
724
+ };
725
+ formattedInput?: AiToolPermissionDetails;
726
+ rawInput?: any;
727
+ permissions?: AiToolPermission[];
728
+ decision?: "approved" | "denied";
729
+ decisionTimestamp?: number;
730
+ signature?: string;
731
+ alwaysAllowPermissions?: AiToolPermission[];
732
+ output?: any;
733
+ error?: string;
734
+ errorCode?: AiToolExecutionErrorCode;
735
+ errorSummary?: string;
736
+ }
737
+ export interface AiToolResultMessage extends AiChatMessageBase {
738
+ type: "tool-result";
739
+ toolCallId: string;
740
+ toolName: string;
741
+ output: any;
742
+ }
743
+ export interface AiToolErrorMessage extends AiChatMessageBase {
744
+ type: "tool-error";
745
+ toolCallId: string;
746
+ toolName: string;
747
+ error: string;
748
+ errorCode?: AiToolExecutionErrorCode;
749
+ errorSummary?: string;
750
+ }
751
+ export interface AiGitSetupRequiredMessage extends AiChatMessageBase {
752
+ type: "git_setup_required";
753
+ applicationId?: string;
754
+ reason?: "git_not_connected";
755
+ }
756
+ export interface AiKnowledgeMessage extends AiChatMessageBase {
757
+ type: "knowledge";
758
+ facts: {
759
+ org: FactDto[];
760
+ user: FactDto[];
761
+ integrations: {
762
+ [integrationId: string]: FactDto[];
763
+ };
764
+ };
765
+ }
766
+ export interface AiAppKnowledgeSavedMessage extends AiChatMessageBase {
767
+ type: "app_knowledge_saved";
768
+ knowledgeCount: number;
769
+ responseToMessageId?: string;
770
+ savedFacts?: SavedKnowledgeFact[];
771
+ saveOutcomes?: KnowledgeSaveOutcome[];
772
+ }
773
+ export interface AiNextStepsChatMessage extends AiChatMessageBase {
774
+ type: "next_steps";
775
+ nextSteps: AiNextStep[];
776
+ }
777
+ export interface AiRetryNotificationChatMessage extends AiChatMessageBase {
778
+ type: "retry_notification";
779
+ retryType: "same_provider" | "fallback_provider";
780
+ attempt?: number;
781
+ delaySeconds?: number;
782
+ fromProvider?: string;
783
+ toProvider?: string;
784
+ reason?: string;
785
+ /** Number of consecutive retries (used by UI to consolidate messages) */
786
+ retryCount?: number;
787
+ success?: boolean;
788
+ }
789
+ export interface AiCompactionControlMessage extends AiChatMessageBase {
790
+ type: "control";
791
+ group: `context-compaction-${"phase1" | "phase2"}`;
792
+ status: "pending" | "validated" | "cancelled";
793
+ summary?: string;
794
+ }
795
+ export type AwsInfraDemoTaskKey = "db" | "s3";
796
+ export type AwsInfraDemoTaskStatus = "pending" | "done";
797
+ /**
798
+ * Demo-only: state snapshot for the "Preparing development environment" mock
799
+ * card in the Clark sidebar. The AI service emits this message multiple
800
+ * times during a single demo run — always with the SAME `id` — to drive
801
+ * the card's UI through its state transitions (e.g. pending/pending →
802
+ * done/pending → done/done). The UI's awsInfraDemoHandler folds repeated
803
+ * sends with the same id into a single message that always reflects the
804
+ * latest server snapshot, so no client-side timers are involved.
805
+ *
806
+ * Emitted only when the `superblocks.byo-db.demo` feature flag returns
807
+ * `{ enabled: true }` and the user submits the first prompt of an empty
808
+ * app. The UI also re-checks the flag before rendering.
809
+ */
810
+ export interface AiAwsInfraDemoMessage extends AiChatMessageBase {
811
+ type: "aws_infra_demo";
812
+ statuses: Record<AwsInfraDemoTaskKey, AwsInfraDemoTaskStatus>;
813
+ }
814
+ export type AiChatMessage = AiChatMessageBase | AiToolCallChatMessage | AiChecklistChatMessage | AiCompactionControlMessage | AiConfirmMessage | AiConfirmResponseMessage | AiMultiChoiceMessage | AiMultiChoiceResponseMessage | AiSearchableDropdownMessage | AiSearchableDropdownResponseMessage | AiRememberKnowledgeDraftMessage | AiRememberKnowledgeDraftResponseMessage | AiPlanMessage | AiPlanDeltaMessage | AiPlanResponseMessage | AiToolPermissionRequestMessage | AiToolResultMessage | AiToolErrorMessage | AiGitSetupRequiredMessage | AiCommitRestoringMessage | AiCommitRestoredMessage | AiDraftCommittedMessage | AiTestRunStartMessage | AiTestRunEndMessage | AiTestCaseUpdateMessage | AiKnowledgeMessage | AiAppKnowledgeSavedMessage | AiRetryNotificationChatMessage | AiNextStepsChatMessage | AiAwsInfraDemoMessage;
815
+ export interface AiChatSummary {
816
+ summary: string;
817
+ relevantFilePaths: string[];
818
+ goals: string[];
819
+ decisions: string[];
820
+ adviceToAgents: string;
821
+ timestamp: number;
822
+ }
823
+ /**
824
+ * Context V2 options for the two-phase compaction system.
825
+ * Phase 1: Tool output redaction (removes verbose outputs)
826
+ * Phase 2: Session summarization (LLM-generated summary)
827
+ *
828
+ * Use Partial<ContextOptionsV2> for overrides; merge with defaults via spread.
829
+ */
830
+ export interface ContextOptionsV2 {
831
+ /** Maximum tokens allowed in the context window. Default: 170,000 */
832
+ contextLimit: number;
833
+ /** Tokens reserved for context buffer/jitter. Default: 4,000 */
834
+ contextBufferTokens: number;
835
+ /** Tokens reserved for model output. Default: 64,000 */
836
+ maxOutputTokens: number;
837
+ /** Whether Phase 1 (tool output redaction) is enabled. Default: true */
838
+ phase1Enabled: boolean;
839
+ /** Minimum pruneable tokens required to run Phase 1. Default: 10,000 */
840
+ phase1MinPruneable: number;
841
+ /** Recent tool call tokens protected from Phase 1 redaction. Default: 5,000 */
842
+ phase1ProtectedTokens: number;
843
+ /** Recent tool use/result pairs protected from Phase 1 redaction. Default: 3 */
844
+ phase1ProtectedToolUseCount: number;
845
+ /**
846
+ * Whether Phase 2 (LLM session summarization) is enabled. Default: true.
847
+ * Set false for bounded one-shot nested generations (e.g. exitPlanMode)
848
+ * that should inherit the conversation rather than re-summarize it.
849
+ */
850
+ phase2Enabled: boolean;
851
+ /** Target context ratio (0-1). After Phase 1, Phase 2 runs if usage exceeds this. Default: 0.4 */
852
+ phase2TargetRatio: number;
853
+ /**
854
+ * Within one turn, after a compaction whose measured post-compaction floor
855
+ * F is still over the compaction threshold, a second compaction is blocked
856
+ * until input exceeds F + reArmDeltaTokens. Guards same-instance per-step
857
+ * re-fire; the first compaction of a turn is unguarded, and a floor at or
858
+ * below threshold never arms the guard. Default: 40,000. Tunable via the
859
+ * ai.context-v2.options flag.
860
+ */
861
+ reArmDeltaTokens: number;
862
+ /**
863
+ * Whether to size the request before sending it and compact when it is
864
+ * already over the model's input limit. Default: true.
865
+ *
866
+ * The kill switch for ENG-5282. This is the one compaction trigger that runs
867
+ * on a size estimate rather than on provider-reported usage, so a bad
868
+ * estimate spends money and discards history on a conversation that would
869
+ * have been fine. Setting this false through the `ai.context-v2.options`
870
+ * flag restores the previous behavior: the provider rejects the oversized
871
+ * request and the session stays wedged, which is visible and recoverable,
872
+ * where a wrong estimate is neither.
873
+ */
874
+ preflightCompactionEnabled: boolean;
875
+ }
876
+ /**
877
+ * Server-side context management thresholds sent to the Anthropic API.
878
+ *
879
+ * These control when Claude's server-side edits fire:
880
+ * - `clear_tool_uses_20250919`: removes old tool use/result pairs
881
+ * - `compact_20260112`: summarizes conversation to reduce context size
882
+ *
883
+ * All fields are optional; omitted fields use the hardcoded defaults
884
+ * in `context-management.ts`.
885
+ */
886
+ export interface ServerContextManagementOptions {
887
+ /**
888
+ * Master switch for server-side context management. Defaults to
889
+ * client-side compaction (phase 1 tool summarization + phase 2 LLM
890
+ * session summarization); set `true` to opt into Anthropic's
891
+ * `compact_20260112` / `clear_tool_uses_20250919` edits. `false`,
892
+ * `undefined`, and missing flag payloads all resolve to client-side.
893
+ * The polarity is "opt-in for server-side" rather than "opt-out for
894
+ * client-side" so a regression in the server-side path can't
895
+ * silently catch users whose flag wasn't migrated.
896
+ */
897
+ enabled?: boolean;
898
+ /** Input token threshold for clearing old tool uses. Default: 100,000 */
899
+ clearToolUsesTriggerTokens?: number;
900
+ /** Input token threshold for server-side compaction. Default: 150,000 */
901
+ compactTriggerTokens?: number;
902
+ /** Number of recent tool use/result pairs to keep. Default: 6 */
903
+ keepRecentToolUses?: number;
904
+ /** Minimum tokens to reclaim per clear operation. Default: 10,000 */
905
+ clearAtLeastTokens?: number;
906
+ }
907
+ /**
908
+ * Model capabilities for Claude models.
909
+ * maxOutputTokens is the absolute maximum including thinking budget.
910
+ */
911
+ export declare const MODEL_CAPABILITIES: {
912
+ readonly "claude-haiku-4-5": {
913
+ readonly maxOutputTokens: 64000;
914
+ };
915
+ readonly "claude-opus-4-5": {
916
+ readonly maxOutputTokens: 64000;
917
+ };
918
+ readonly "claude-opus-4-6": {
919
+ readonly maxOutputTokens: 128000;
920
+ };
921
+ readonly "claude-opus-4-7": {
922
+ readonly maxOutputTokens: 128000;
923
+ };
924
+ readonly "claude-opus-4-8": {
925
+ readonly maxOutputTokens: 128000;
926
+ };
927
+ readonly "claude-opus-5": {
928
+ readonly maxOutputTokens: 128000;
929
+ };
930
+ readonly "claude-sonnet-4-5": {
931
+ readonly maxOutputTokens: 64000;
932
+ };
933
+ readonly "claude-sonnet-4-6": {
934
+ readonly maxOutputTokens: 128000;
935
+ };
936
+ };
937
+ /**
938
+ * Maximum tokens reserved for model output (non-thinking).
939
+ * Set to 48K to leave headroom for thinking budget (default 5K-16K).
940
+ * The total (maxOutputTokens + thinkingBudget) must not exceed
941
+ * MODEL_CAPABILITIES[model].maxOutputTokens (64K).
942
+ */
943
+ export declare const MAX_OUTPUT_TOKENS = 48000;
944
+ /**
945
+ * Default values for ContextOptionsV2.
946
+ */
947
+ export declare const DEFAULT_CONTEXT_OPTIONS_V2: ContextOptionsV2;
948
+ export interface ChaosOptions {
949
+ errorRate?: number;
950
+ }
951
+ export type ApiLLMProviderType = "bedrock" | "anthropic" | "vertex" | "snowflake";
952
+ /**
953
+ * Known core models, as a runtime list so callers can validate untrusted input
954
+ * against it — a bare type union erases at compile time and leaves request
955
+ * bodies unchecked.
956
+ */
957
+ export declare const CORE_MODEL_NAMES: readonly ["claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6"];
958
+ export type CoreModelName = (typeof CORE_MODEL_NAMES)[number];
959
+ export declare function isCoreModelName(value: unknown): value is CoreModelName;
960
+ /** Metric-label value for anything outside {@link CORE_MODEL_NAMES}. */
961
+ export declare const UNKNOWN_CORE_MODEL_LABEL = "unknown";
962
+ /**
963
+ * Bound a core model to the known set before it becomes a metric label.
964
+ *
965
+ * `coreModel` reaches telemetry from caller-controlled input on both the server
966
+ * (request body) and the dev server (the UI's `llmConfig`), and is only typed,
967
+ * never validated on arrival. Unrecognized values collapse onto a single label
968
+ * so a caller cannot mint an unbounded series by varying the field.
969
+ */
970
+ export declare function coreModelLabel(value: unknown): string;
971
+ /**
972
+ * Clark LLM usage surfaces for golden cost/reliability metrics. Values align
973
+ * with billing metadata `surface` on proxy requests.
974
+ */
975
+ export declare const CLARK_USAGE_SURFACES: readonly ["app", "dashboard", "policy_gate"];
976
+ export type ClarkUsageSurface = (typeof CLARK_USAGE_SURFACES)[number];
977
+ export declare function isClarkUsageSurface(value: unknown): value is ClarkUsageSurface;
978
+ /** Metric-label value for anything outside {@link CLARK_USAGE_SURFACES}. */
979
+ export declare const UNKNOWN_USAGE_SURFACE_LABEL = "unknown";
980
+ export declare function usageSurfaceLabel(value: unknown): string;
981
+ /**
982
+ * Compaction implementations, as a runtime list so the proxy can check the
983
+ * client-supplied billing attribute before it egresses to Snowflake.
984
+ */
985
+ export declare const CONTEXT_MANAGEMENT_MODES: readonly ["client", "server"];
986
+ export type ContextManagementMode = (typeof CONTEXT_MANAGEMENT_MODES)[number];
987
+ export declare function isContextManagementMode(value: unknown): value is ContextManagementMode;
988
+ /** Thinking configurations a request can send, as a runtime list. */
989
+ export declare const THINKING_MODES: readonly ["adaptive", "budgeted", "off"];
990
+ export type ThinkingMode = (typeof THINKING_MODES)[number];
991
+ export declare function isThinkingMode(value: unknown): value is ThinkingMode;
992
+ /**
993
+ * Bucket boundaries for the `superblocks.clark.prompt.credits` histogram.
994
+ * Shared because the dev-server and the server both emit that one metric name:
995
+ * two local bucket definitions would silently produce incomparable percentiles.
996
+ */
997
+ export declare const CLARK_PROMPT_CREDITS_BUCKETS: readonly [0.5, 1, 2, 5, 7.5, 10, 15, 25, 50, 100, 250];
998
+ /** AI SDK usage shape, as reported per step and in aggregate. */
999
+ export interface LlmUsageTokens {
1000
+ cachedInputTokens?: number;
1001
+ inputTokenDetails?: {
1002
+ cacheReadTokens?: number;
1003
+ cacheWriteTokens?: number;
1004
+ noCacheTokens?: number;
1005
+ };
1006
+ inputTokens?: number;
1007
+ outputTokens?: number;
1008
+ }
1009
+ export interface PromptCostTokens {
1010
+ cachedReadTokens: number;
1011
+ cachedWriteTokens: number;
1012
+ inputTokens: number;
1013
+ outputTokens: number;
1014
+ }
1015
+ /**
1016
+ * Normalizes AI SDK token usage into the four counts credit pricing bills on.
1017
+ *
1018
+ * `inputTokens` from the SDK is the total including cache traffic, so the
1019
+ * uncached remainder is derived rather than read directly, and clamped because
1020
+ * providers occasionally report cache counts that exceed the total.
1021
+ */
1022
+ export declare function promptCostTokensFrom(usage: LlmUsageTokens): PromptCostTokens;
1023
+ export declare const FALLBACK_STRATEGIES: readonly ["model-then-provider", "provider-then-model", "model-then-provider-no-retry", "provider-then-model-no-retry", "only-model", "only-provider", "disabled"];
1024
+ /**
1025
+ * Fallback strategy for model failover.
1026
+ *
1027
+ * The initial provider comes from ui.clark-ai.llm-provider feature flag.
1028
+ * The initial model comes from superblocks.ai.core-model.name feature flag.
1029
+ * This strategy controls what happens when the initial provider/model fails.
1030
+ *
1031
+ * With retry (4 entries):
1032
+ * - "model-then-provider": initial → initial+model2 → provider2+initial → provider2+model2
1033
+ * - "provider-then-model": initial → provider2+initial → initial+model2 → provider2+model2
1034
+ *
1035
+ * Without retry (3 entries):
1036
+ * - "model-then-provider-no-retry": initial → initial+model2 → provider2+model2
1037
+ * - "provider-then-model-no-retry": initial → provider2+initial → provider2+model2
1038
+ *
1039
+ * Limited (2 entries):
1040
+ * - "only-model": initial → initial+model2
1041
+ * - "only-provider": initial → provider2+initial
1042
+ *
1043
+ * No fallback:
1044
+ * - "disabled": initial only, fail immediately on error
1045
+ */
1046
+ export type FallbackStrategy = (typeof FALLBACK_STRATEGIES)[number];
1047
+ export interface LLMProviderConfig {
1048
+ provider: ApiLLMProviderType;
1049
+ thinkingEnabled: boolean;
1050
+ thinkingBudgetTokens: string;
1051
+ interleavedThinking: boolean;
1052
+ disabledTools?: string[];
1053
+ contextOptionsV2?: Partial<ContextOptionsV2>;
1054
+ serverContextManagement?: Partial<ServerContextManagementOptions>;
1055
+ chaosOptions?: ChaosOptions;
1056
+ flags?: {
1057
+ isChecklistEnabled?: boolean;
1058
+ isNavigationToolEnabled?: boolean;
1059
+ isScreenshotToolEnabled?: boolean;
1060
+ isTestingEnabled?: boolean;
1061
+ isFactsEnabled?: boolean;
1062
+ isAppKnowledgeEnabled?: boolean;
1063
+ isTypecheckEnabled?: boolean;
1064
+ textUploadContextByReferenceMimeTypes?: unknown;
1065
+ };
1066
+ coreModel: CoreModelName;
1067
+ unifiedProviderEnabled: boolean;
1068
+ fallbackStrategy?: FallbackStrategy;
1069
+ /** @deprecated Hardcoded to true for one release cycle so old dev servers don't block data access. Remove after next release. */
1070
+ customerDataAccessEnabled?: boolean;
1071
+ }
1072
+ export type PlanContext = {
1073
+ plan?: string;
1074
+ approved?: boolean;
1075
+ integrations?: PromptContextIntegration[];
1076
+ entities?: PromptContextEntity[];
1077
+ title?: string;
1078
+ attachments?: Array<Attachment>;
1079
+ enableTesting?: boolean;
1080
+ };
1081
+ /**
1082
+ * Init data from sb-init message - required for socket connection setup.
1083
+ */
1084
+ export interface InitData {
1085
+ peerId: string;
1086
+ userId?: string;
1087
+ appId: string;
1088
+ sessionRecordingKey?: string;
1089
+ interactionMode?: InteractionMode;
1090
+ /** The value of the authorization header on requests to the dev server. */
1091
+ devServerAuthorization: string | undefined;
1092
+ /** Timestamp when the parent connection started (for end-to-end metrics) */
1093
+ connectionStartTime?: number;
1094
+ /** W3C Trace Context headers for linking app websocket span to parent trace */
1095
+ traceContext?: Record<string, string>;
1096
+ /** Connection type: initial or reconnect */
1097
+ connectionType?: "initial" | "reconnect";
1098
+ /** Connection target: local, sabs, or default */
1099
+ connectionTarget?: string;
1100
+ /** Window origin URL for initializing tracer provider */
1101
+ windowOriginUrl?: string;
1102
+ aiState?: {
1103
+ generationState: AiGenerationState;
1104
+ editingComponents: SbElement[];
1105
+ };
1106
+ }
1107
+ /**
1108
+ * Bootstrap data required for the vite dev server app to initialize.
1109
+ * This simulates the data normally sent from the parent window via postMessage.
1110
+ */
1111
+ export interface BootstrapData {
1112
+ appId: string;
1113
+ userId: string;
1114
+ token: string;
1115
+ accessToken: string;
1116
+ /** Explicit authorization for the code-mode dev server. */
1117
+ devServerAuthorization: string | null;
1118
+ agentUrls?: string[];
1119
+ /**
1120
+ * On-prem agent metadata. Cloud / Gateway capture must send `[]` rather
1121
+ * than omitting the key: the library assigns `payload.agents` onto
1122
+ * `_agents` and then reads `_agents.length`.
1123
+ */
1124
+ agents?: unknown[];
1125
+ orgId?: string;
1126
+ orgName?: string;
1127
+ userEmail?: string;
1128
+ windowOriginUrl?: string;
1129
+ /** Profile data for API execution - includes selected profile with id/key */
1130
+ profiles?: {
1131
+ available: Profile[];
1132
+ selected?: Profile;
1133
+ default: Profile;
1134
+ };
1135
+ /**
1136
+ * Editor parent sends LaunchDarkly flags here. `clark.sdk-api.enabled`
1137
+ * must be true or the canvas runs YAML `runApiByPath` instead of v3/execute.
1138
+ */
1139
+ featureFlags?: Record<string, unknown>;
1140
+ }
1141
+ /**
1142
+ * Data needed for Playwright browser automation to interact with the app.
1143
+ * Contains the iframe URL and initialization data that the app expects.
1144
+ */
1145
+ export type BrowserContext = {
1146
+ /** The base URL of the iframe (e.g., sandbox URL from socket connection) */
1147
+ iframeBaseUrl: string;
1148
+ /** Data from sb-init message - required for socket connection setup */
1149
+ initData: InitData;
1150
+ /** Data from sb-bootstrap-response - required for API manager initialization */
1151
+ bootstrapData: BootstrapData;
1152
+ };
1153
+ export type AiResponseMetadata = {
1154
+ responseToMessageId: string;
1155
+ } & ({
1156
+ type: "multi_choice_response";
1157
+ selectedChoiceIndices: number[];
1158
+ selectedScopes?: KnowledgePromotionSelection[];
1159
+ } | {
1160
+ type: "remember_knowledge_draft_response";
1161
+ selectedCandidateIndices: number[];
1162
+ selectedScopes?: KnowledgePromotionSelection[];
1163
+ } | {
1164
+ type: "confirm_response";
1165
+ approved: boolean;
1166
+ selectedScopes?: KnowledgePromotionSelection[];
1167
+ } | {
1168
+ type: "plan_response";
1169
+ approved?: boolean;
1170
+ enableTesting?: boolean;
1171
+ } | {
1172
+ type: "searchable_dropdown_response";
1173
+ selectedValue: string;
1174
+ selectedLabel: string;
1175
+ } | {
1176
+ type: "tool_permission_response";
1177
+ responseToMessageId: string;
1178
+ approved?: boolean;
1179
+ /** Distinguishes an editor-delivery failure from an actual user decision. */
1180
+ outcome?: "delivery_expired" | "user_response";
1181
+ alwaysAllowPermissions?: AiToolPermission[];
1182
+ /** When true, the user's typed message is clarification rather than a denial. Only meaningful when `approved` is false. */
1183
+ clarification?: boolean;
1184
+ });
1185
+ export type AiGenerateRequest = {
1186
+ prompt: string;
1187
+ promptContext?: PromptContext;
1188
+ planContext?: PlanContext;
1189
+ mockGeneration?: boolean;
1190
+ jwt: string;
1191
+ /** Required - contains provider and coreModel from feature flags */
1192
+ llmConfig: LLMProviderConfig;
1193
+ mode?: AiMode;
1194
+ responseMetadata?: AiResponseMetadata;
1195
+ browserContext?: BrowserContext;
1196
+ userPreferences?: ClarkUserPreferences;
1197
+ requestId?: string;
1198
+ /** Third-party import source id (e.g. "lovable") for billing attribution of the turn. */
1199
+ importSource?: string;
1200
+ };
1201
+ export type ClarkUserPreferences = {
1202
+ suggestNextSteps: boolean;
1203
+ };
1204
+ export declare const CLARK_USER_PREFERENCES_DEFAULTS: ClarkUserPreferences;
1205
+ export type AiLabelAttachmentRequest = {
1206
+ attachment: Attachment;
1207
+ jwt: string;
1208
+ llmConfig?: LLMProviderConfig;
1209
+ };
1210
+ export type AiLabelAttachmentResponse = {
1211
+ label: string;
1212
+ insight: string;
1213
+ };
1214
+ export declare enum AiMode {
1215
+ BUILD = "BUILD",
1216
+ PLAN = "PLAN"
1217
+ }
1218
+ /**
1219
+ * A saved app-level fact that Clark can reference when building/editing this application.
1220
+ * Stored as a markdown file with YAML frontmatter in skills/app/*.md.
1221
+ */
1222
+ export type AiAppFact = {
1223
+ /** Virtual path used as a stable identifier, e.g. ".superblocks/skills/app/no-emojis.md" */
1224
+ path: string;
1225
+ name: string;
1226
+ description: string;
1227
+ content: string;
1228
+ /** Currently only "always" — on_demand is reserved for a future phase */
1229
+ accessType: "always" | "on_demand";
1230
+ isEnabled: boolean;
1231
+ createdAt?: string;
1232
+ };
1233
+ export type AiMoveAppKnowledgeTargetScope = Exclude<KnowledgePromotionScope, "app">;
1234
+ export type AiMoveAppKnowledgeRequest = {
1235
+ path: string;
1236
+ targetScope: AiMoveAppKnowledgeTargetScope;
1237
+ entityId?: string;
1238
+ };
1239
+ export type AiMoveAppKnowledgeResult = {
1240
+ sourcePath: string;
1241
+ createdFact: {
1242
+ id?: string;
1243
+ name: string;
1244
+ scope: AiMoveAppKnowledgeTargetScope;
1245
+ entityId?: string;
1246
+ };
1247
+ };
1248
+ export type KnowledgeSaveOutcome = {
1249
+ candidateIndex: number;
1250
+ scope: KnowledgePromotionScope;
1251
+ factName: string;
1252
+ status: "created" | "updated" | "deleted" | "created_remote" | "skipped_existing" | "skipped_not_found" | "failed";
1253
+ factId?: string;
1254
+ reason?: string;
1255
+ };
1256
+ export type AiAppFactInput = {
1257
+ name: string;
1258
+ description: string;
1259
+ content: string;
1260
+ currentContent?: string;
1261
+ proposedContent?: string;
1262
+ evidence?: string;
1263
+ confidence?: number;
1264
+ reasonCode?: "explicit_user_instruction" | "drift_detected" | "invalidation";
1265
+ factKind?: "durable_guardrail" | "mutable_state";
1266
+ status?: "active" | "stale";
1267
+ reason?: string;
1268
+ accessType?: "always" | "on_demand";
1269
+ isEnabled?: boolean;
1270
+ createdAt?: string;
1271
+ action?: "create" | "update" | "delete";
1272
+ targetFactName?: string;
1273
+ };
1274
+ /**
1275
+ * A candidate knowledge entry to create, update, or delete.
1276
+ * Passed in by the rememberKnowledge tool when the user asks Clark to remember something.
1277
+ */
1278
+ export type RememberKnowledgeCandidate = {
1279
+ name: string;
1280
+ description: string;
1281
+ content: string;
1282
+ currentContent?: string;
1283
+ proposedContent?: string;
1284
+ evidence?: string;
1285
+ confidence?: number;
1286
+ reasonCode?: "explicit_user_instruction" | "drift_detected" | "invalidation";
1287
+ action?: "create" | "update" | "delete";
1288
+ targetFactName?: string;
1289
+ reason?: string;
1290
+ };
1291
+ export type RememberKnowledgeToolCallChatMessage = {
1292
+ tool: "rememberKnowledge";
1293
+ args: {
1294
+ candidates?: RememberKnowledgeCandidate[];
1295
+ };
1296
+ };
1297
+ export type AiChangeInfoPush = {
1298
+ type: "component" | "api" | "page" | "dependency" | "theme";
1299
+ name: string;
1300
+ action: AiChatMessage["action"];
1301
+ status: AiChatMessage["status"];
1302
+ };
1303
+ /**
1304
+ * Message types that are excluded from being stored by the server.
1305
+ * These messages are ephemeral and should not be persisted to the database.
1306
+ */
1307
+ export declare const EXCLUDED_MESSAGE_TYPES: readonly AiChatMessage["type"][];
1308
+ /** Maps legacy persisted roles ("server", "ai") onto "assistant". */
1309
+ export declare function normalizeLegacyChatRole(role: string): string;
1310
+ /**
1311
+ * Types the live-edit pod never evicts. Shared so editor pod-reconcile can
1312
+ * exclude them when inferring the eviction frontier from a payload.
1313
+ *
1314
+ * Distinct from EXCLUDED_MESSAGE_TYPES (what the server never persists).
1315
+ */
1316
+ export declare const EVICTION_PROTECTED_MESSAGE_TYPES: readonly AiChatMessage["type"][];
1317
+ export type AiSearchableDropdownOption = {
1318
+ label: string;
1319
+ value: string;
1320
+ description?: string;
1321
+ };
1322
+ /**
1323
+ * Curated list of Lucide icon names (kebab-case) available for next steps.
1324
+ * This is the single source of truth — both the backend prompt and the frontend icon map
1325
+ * must stay in sync with this list.
1326
+ */
1327
+ export declare const NEXT_STEPS_ICON_NAMES: readonly ["alert-triangle", "arrow-right-left", "arrow-up-down", "bar-chart-3", "bell", "bookmark", "calendar", "check", "check-circle", "circle-user", "clipboard", "clock", "cloud", "code", "copy", "database", "download", "external-link", "eye", "file-down", "file-plus", "file-text", "filter", "folder", "git-branch", "globe", "grip-vertical", "hard-drive", "heart", "home", "image", "info", "key", "layers", "layout-grid", "line-chart", "link", "list", "lock", "log-out", "mail", "map", "message-square", "monitor", "moon", "package", "palette", "pencil", "pie-chart", "plus", "printer", "puzzle", "refresh-cw", "repeat", "rocket", "save", "search", "server", "settings", "share-2", "shield", "sliders", "smartphone", "sparkles", "star", "table", "tag", "thumbs-up", "toggle-left", "trash-2", "upload", "user-plus", "users", "wand-2", "zap"];
1328
+ export type NextStepsIconName = (typeof NEXT_STEPS_ICON_NAMES)[number];
1329
+ export type AiNextStep = {
1330
+ label: string;
1331
+ prompt: string;
1332
+ /** Lucide icon name (kebab-case) chosen by the LLM to represent this next step */
1333
+ icon?: NextStepsIconName;
1334
+ };
1335
+ export type PromptContextEntity = {
1336
+ id: string;
1337
+ type: AiEntityType;
1338
+ metadata?: Record<string, any>;
1339
+ };
1340
+ export type ElementDomMetadata = {
1341
+ openingTagHtml?: string;
1342
+ boundingRect?: {
1343
+ x: number;
1344
+ y: number;
1345
+ width: number;
1346
+ height: number;
1347
+ top: number;
1348
+ right: number;
1349
+ bottom: number;
1350
+ left: number;
1351
+ };
1352
+ };
1353
+ export type TaggedElementDomMetadata = {
1354
+ sourceId: string;
1355
+ totalCount: number;
1356
+ elements: ElementDomMetadata[];
1357
+ };
1358
+ export type AiPromptInterpretationPush = {
1359
+ prompt: string;
1360
+ classification: PromptClassification;
1361
+ entities: PromptContextEntity[];
1362
+ };
1363
+ export type AiGenerationStateSnapshot = {
1364
+ state: AiGenerationState;
1365
+ /**
1366
+ * The generation this state is about, as the dev server named it when the
1367
+ * prompt started (`aiGenerateWithQueue` returns the same id).
1368
+ *
1369
+ * Without it a terminal state is unattributable: the ai-service starts
1370
+ * generations of its own — a migration turn, an interrupt-and-continue —
1371
+ * and their COMPLETED is indistinguishable on the wire from the one a
1372
+ * caller is waiting for. A consumer must ignore terminal states naming a
1373
+ * generation other than the one it started.
1374
+ *
1375
+ * Absent from dev servers that predate this field; treat that as today's
1376
+ * behavior rather than as a mismatch. (APPS-5161)
1377
+ */
1378
+ generationId?: string;
1379
+ hasError?: boolean;
1380
+ hasSuggestions?: boolean;
1381
+ paywallReason?: AiQuotaPaywallReason;
1382
+ };
1383
+ export type AiChatGetMessagesResponse = {
1384
+ messages: AiChatMessage[];
1385
+ };
1386
+ export type PromptContextIntegration = {
1387
+ id: string;
1388
+ name: string;
1389
+ displayName?: string;
1390
+ type: string;
1391
+ metadata: Record<string, any>;
1392
+ openApiSpecRef?: string;
1393
+ /** True when this integration can fall back to a default configuration for any app data tag. */
1394
+ hasDefaultConfiguration?: boolean;
1395
+ /** App data tags that do not have an integration configuration and require user confirmation. */
1396
+ mismatchedAppProfileKeys?: string[];
1397
+ /** Data tags that have an explicit configuration or can use the default configuration. */
1398
+ supportedProfileKeys?: string[];
1399
+ /** Set to `database_lifecycle` for app-scoped managed Native DB integrations. */
1400
+ managedBy?: string | null;
1401
+ };
1402
+ /** Base fields for all attachment types */
1403
+ export type BaseAttachment = {
1404
+ /** Original filename; may be missing or blank when attachments come from partial/legacy payloads */
1405
+ fileName?: string;
1406
+ /** Brief 2-3 word description of the attachment (populated async by LLM) */
1407
+ label?: string;
1408
+ /** Key observation about what the attachment shows (populated async by LLM) */
1409
+ insight?: string;
1410
+ };
1411
+ /** Display and model-input-safe filename when `fileName` is missing or whitespace-only */
1412
+ export declare const DEFAULT_ATTACHMENT_FILE_NAME = "Attachment";
1413
+ /**
1414
+ * Returns a non-empty filename for UI, LLM file parts, and lease metadata.
1415
+ * Prefer `fileName` when present; otherwise infer from `mediaType` / `type` when possible.
1416
+ */
1417
+ export declare function resolveAttachmentFileName(attachment: {
1418
+ fileName?: string;
1419
+ /** Uploaded attachments use `mediaType`; text file attachments use `mimeType` */
1420
+ mediaType?: string;
1421
+ mimeType?: string;
1422
+ type?: string;
1423
+ }): string;
1424
+ export type ImageAttachment = BaseAttachment & {
1425
+ type: "image";
1426
+ image: string;
1427
+ };
1428
+ export type PdfAttachment = BaseAttachment & {
1429
+ type: "pdf";
1430
+ data: string;
1431
+ size?: number;
1432
+ };
1433
+ export type ArchiveAttachment = BaseAttachment & {
1434
+ type: "archive";
1435
+ data: string;
1436
+ size?: number;
1437
+ };
1438
+ /**
1439
+ * Uploaded attachment reference.
1440
+ *
1441
+ * Uses a stable URL and carries upload metadata so downstream services can
1442
+ * refresh leases or authorize access as needed.
1443
+ */
1444
+ export type UploadedAttachment = BaseAttachment & {
1445
+ type: "uploaded";
1446
+ url: string;
1447
+ signedUrl?: string;
1448
+ mediaType: string;
1449
+ storageKey?: string;
1450
+ signedUrlExpiresAt?: string;
1451
+ scopeType?: "org" | "app";
1452
+ applicationId?: string;
1453
+ };
1454
+ /** Text-based attachment types that share the same structure */
1455
+ export declare const TEXT_ATTACHMENT_TYPES: readonly ["csv", "json", "yaml", "css", "txt"];
1456
+ export type TextAttachmentType = (typeof TEXT_ATTACHMENT_TYPES)[number];
1457
+ /** Unified type for text-based file attachments (CSV, JSON, YAML, CSS, TXT) */
1458
+ export type TextAttachment = BaseAttachment & {
1459
+ type: TextAttachmentType;
1460
+ content: string;
1461
+ mimeType: string;
1462
+ size?: number;
1463
+ };
1464
+ /** Default MIME types for text attachments */
1465
+ export declare const TEXT_ATTACHMENT_MIME_TYPES: Record<TextAttachmentType, string>;
1466
+ /** Accepted file types configuration for file inputs and dropzones */
1467
+ export declare const ACCEPTED_ATTACHMENT_TYPES: Record<string, string[]>;
1468
+ /** Image-only file types configuration */
1469
+ export declare const ACCEPTED_IMAGE_TYPES: Record<string, string[]>;
1470
+ /** Returns accepted attachment types based on whether file attachments are enabled */
1471
+ export declare const getAcceptedAttachmentTypes: (fileAttachmentsEnabled: boolean) => Record<string, string[]>;
1472
+ /** Accepted file types as a string for HTML input accept attribute */
1473
+ export declare const ACCEPTED_ATTACHMENT_TYPES_STRING: string;
1474
+ /** Image-only file types as a string for HTML input accept attribute */
1475
+ export declare const ACCEPTED_IMAGE_TYPES_STRING: string;
1476
+ /** Helper to check if an attachment is a text-based attachment */
1477
+ export declare const isTextAttachment: (attachment: Attachment) => attachment is TextAttachment;
1478
+ export type FileAttachment = ArchiveAttachment | PdfAttachment | TextAttachment;
1479
+ export type Attachment = ImageAttachment | FileAttachment | UploadedAttachment;
1480
+ /**
1481
+ * Simplified user type for PromptContext
1482
+ */
1483
+ export type PromptContextUser = {
1484
+ id: string;
1485
+ name: string;
1486
+ email: string;
1487
+ username: string;
1488
+ };
1489
+ export type KnowledgePromotionIntegrationCapability = {
1490
+ entityId: string;
1491
+ name: string;
1492
+ canCreate: boolean;
1493
+ reason?: string;
1494
+ };
1495
+ export type KnowledgePromotionCapabilities = {
1496
+ app: {
1497
+ canCreate: true;
1498
+ };
1499
+ org: {
1500
+ canCreate: boolean;
1501
+ entityId?: string;
1502
+ };
1503
+ user: {
1504
+ canCreate: boolean;
1505
+ entityId?: string;
1506
+ };
1507
+ integrations: KnowledgePromotionIntegrationCapability[];
1508
+ };
1509
+ export type PromptContext = {
1510
+ entities: PromptContextEntity[];
1511
+ integrations: PromptContextIntegration[];
1512
+ knowledgePromotionCapabilities?: KnowledgePromotionCapabilities;
1513
+ unresolvedIntegrations?: string[];
1514
+ fromEmptyState?: boolean;
1515
+ currentPageName?: string;
1516
+ currentApiName?: string;
1517
+ currentRoutePattern?: string;
1518
+ currentPathname?: string;
1519
+ currentRouteParams?: Record<string, string | undefined>;
1520
+ previewDevice?: PreviewDevice;
1521
+ currentView?: EditorView;
1522
+ attachments?: Array<Attachment>;
1523
+ dataTags?: {
1524
+ available: Array<DataTag>;
1525
+ selected?: DataTag;
1526
+ default: DataTag;
1527
+ };
1528
+ environmentCompatibility?: AppEnvironmentCompatibility;
1529
+ user?: PromptContextUser;
1530
+ groups?: Array<{
1531
+ id: string;
1532
+ name: string;
1533
+ size: number;
1534
+ }>;
1535
+ conflictedFiles?: string[];
1536
+ gitSetup?: {
1537
+ isConnected: boolean;
1538
+ provider?: string;
1539
+ remoteUrl?: string;
1540
+ };
1541
+ integrationSetup?: {
1542
+ pluginId: string;
1543
+ mode: "create" | "edit";
1544
+ integrationName?: string;
1545
+ };
1546
+ /**
1547
+ * Org-level `app_ai` setting. Mirrors the server-side jsonb and is intentionally
1548
+ * extensible (per-purpose defaults, model preference, etc. land here as new fields).
1549
+ * When `preferredAppInferenceIntegrationId` is set, Clark treats it as the preferred
1550
+ * provider for AI inference in customer-built apps.
1551
+ */
1552
+ aiConfiguration?: {
1553
+ preferredAppInferenceIntegrationId?: string;
1554
+ };
1555
+ };
1556
+ export type AiInterpretPromptRequest = {
1557
+ prompt: string;
1558
+ promptContext?: PromptContext;
1559
+ jwt: string;
1560
+ };
1561
+ export declare const PromptClassificationAndComplexity: {
1562
+ readonly full_app_gen: 1;
1563
+ readonly broad_edit: 2;
1564
+ readonly specific_edit: 3;
1565
+ readonly question: 4;
1566
+ readonly unknown: 5;
1567
+ };
1568
+ export type PromptClassification = keyof typeof PromptClassificationAndComplexity;
1569
+ export declare enum AiContextMode {
1570
+ HIGHLIGHT = "highlight",
1571
+ AUTO_SELECT = "auto-select",
1572
+ SILENT = "silent"
1573
+ }
1574
+ export declare enum AiGenerationState {
1575
+ IDLE = "idle",
1576
+ GENERATING = "generating",
1577
+ DEBUGGING = "debugging",
1578
+ SUMMARIZING = "summarizing",
1579
+ COMPLETED = "completed",
1580
+ CANCELLED = "cancelled",
1581
+ AWAITING_USER_INPUT = "awaiting_user_input"
1582
+ }
1583
+ /**
1584
+ * Internal marker used to signal the end of plan streaming.
1585
+ * This value is intentionally unique to avoid conflicts with plan content.
1586
+ */
1587
+ export declare const AI_PLAN_STREAMING_END_MARKER = "[__SUPERBLOCKS_PLAN_DONE__]";
1588
+ export interface TokenRequestData {
1589
+ requestId: string;
1590
+ inputTokens: number;
1591
+ outputTokens: number;
1592
+ totalTokens: number;
1593
+ cachedInputTokens?: number;
1594
+ model: string;
1595
+ startTime: string;
1596
+ endTime: string;
1597
+ }
1598
+ export type TokenUsage = Omit<TokenRequestData, "requestId">;
1599
+ export interface TokenSessionSummary {
1600
+ startTime: string;
1601
+ totalInputTokens: number;
1602
+ totalOutputTokens: number;
1603
+ totalTokens: number;
1604
+ totalCachedTokens: number;
1605
+ requestCount: number;
1606
+ primaryModel: string;
1607
+ endTime: string;
1608
+ }
1609
+ export declare enum AiToolExecutionErrorCode {
1610
+ NOT_FOUND = "tool_not_found",
1611
+ NOT_ALLOWED = "tool_not_allowed",
1612
+ REQUIRES_USER_CONFIRMATION = "tool_requires_user_confirmation",
1613
+ INVALID_INPUT = "tool_invalid_input",
1614
+ INTERNAL_ERROR = "tool_internal_error"
1615
+ }
1616
+ /**
1617
+ * AI Attributes
1618
+ *
1619
+ * Attributes passed from ai-service (dev-server) to control plane (server) for AI usage tracking.
1620
+ * This data is included in the LLM request body and extracted by the control plane to log
1621
+ * usage events to Snowflake.
1622
+ *
1623
+ * This interface is designed to be extensible - additional fields can be added in future PRs
1624
+ * for plan mode, timestamps, LOC tracking, etc.
1625
+ */
1626
+ export interface AiAttributes {
1627
+ /** Unique ID for this user interaction (UUID) */
1628
+ prompt_id?: string;
1629
+ /** Chat message ID for linking to chat history (UUID) */
1630
+ chatmessage_id?: string;
1631
+ /** Application ID associated with this request */
1632
+ application_id?: string;
1633
+ /** Attribution details for internal reporting, such as migration or import identifiers. */
1634
+ metadata?: Record<string, unknown>;
1635
+ /** LLMObs session ID for correlation with Datadog LLM Observability */
1636
+ session_id?: string;
1637
+ /** AI agent run ID supplied by the caller; the server validates org ownership before attribution. */
1638
+ ai_agent_run_id?: string;
1639
+ /** Underlying model ID (e.g. claude-3-5-sonnet-20241022) */
1640
+ model?: string;
1641
+ /** Clark model abstraction (e.g. clark-fast) */
1642
+ clark_model?: string;
1643
+ /** Provider (bedrock, vertex, etc.) */
1644
+ provider?: string;
1645
+ /** Authenticated Superblocks platform user email for AI billing attribution. */
1646
+ user_email?: string | null;
1647
+ /** Organization display name, denormalized so analytics can resolve an org id to a name without a DB join. */
1648
+ organization_name?: string | null;
1649
+ /** True when organization_name was derived from an email-shaped name (the self-serve default) rather than chosen. */
1650
+ organization_name_is_derived?: boolean | null;
1651
+ /** AI credits consumed for this request (computed from token costs × multiplier) */
1652
+ credits_used?: number;
1653
+ /** Input tokens from LLM response */
1654
+ input_tokens?: number;
1655
+ /** Output tokens from LLM response */
1656
+ output_tokens?: number;
1657
+ /** Total tokens (input + output) */
1658
+ total_tokens?: number;
1659
+ /** Cache read tokens (90% discount) */
1660
+ cached_read_tokens?: number;
1661
+ /** Cache write tokens (25% of regular price) */
1662
+ cached_write_tokens?: number;
1663
+ /** Reasoning tokens (o1/o3 models) */
1664
+ reasoning_tokens?: number;
1665
+ /** ISO 8601 UTC timestamp when LLM call begins */
1666
+ started_at?: string;
1667
+ /** ISO 8601 UTC timestamp when LLM call finishes */
1668
+ completed_at?: string;
1669
+ /** Lines added from Write tool calls */
1670
+ lines_added?: number;
1671
+ /** Lines edited from Edit tool calls (min of added/removed) */
1672
+ lines_edited?: number;
1673
+ /** Lines removed from Edit tool calls */
1674
+ lines_removed?: number;
1675
+ /** Number of reasoning steps */
1676
+ step_count?: number;
1677
+ /** Total tool invocations */
1678
+ tool_call_count?: number;
1679
+ /** Number of retry attempts for this request */
1680
+ retry_count?: number;
1681
+ /** Whether workflow failed after all retries */
1682
+ workflow_failed?: boolean;
1683
+ /** Mode: "plan" (when exitPlanMode called) or "build" (default) */
1684
+ mode?: "plan" | "build";
1685
+ /** Plan complexity: "small" | "medium" | "large" | "extra large" (only when mode="plan") */
1686
+ plan_size?: "small" | "medium" | "large" | "extra large";
1687
+ /** Type of system operation that triggered this AI call (e.g. commit_message, attachment_label) */
1688
+ trigger_type?: string;
1689
+ /** Context window (tokens) available to the request. */
1690
+ context_limit?: number;
1691
+ /** Tokens reserved for model output. */
1692
+ max_output_tokens?: number;
1693
+ /** Safety margin (tokens) held back on top of the output reservation. */
1694
+ context_buffer_tokens?: number;
1695
+ /**
1696
+ * Which compaction implementation ran. "client" is our two-phase local
1697
+ * compaction, whose phase 2 bills a separate summarization call; "server"
1698
+ * delegates to Anthropic's managed context edits, which fold into the
1699
+ * request. The two have different cost shapes, so comparing GAU per prompt
1700
+ * across a rollout is only meaningful when split by this.
1701
+ *
1702
+ * Client-side compaction fires once input exceeds
1703
+ * `context_limit - max_output_tokens - context_buffer_tokens`.
1704
+ */
1705
+ context_management?: ContextManagementMode;
1706
+ /**
1707
+ * Thinking configuration sent upstream. Adaptive models (opus 4.7 and later)
1708
+ * take an effort level and ignore the token budget entirely, so they report
1709
+ * "adaptive" and carry no `thinking_budget_tokens`.
1710
+ */
1711
+ thinking_mode?: ThinkingMode;
1712
+ /**
1713
+ * Requested thinking budget (tokens), set only when `thinking_mode` is
1714
+ * "budgeted". This is what the config asked for: the request path can still
1715
+ * shrink it at call time if output reservation plus budget would exceed the
1716
+ * model's ceiling.
1717
+ */
1718
+ thinking_budget_tokens?: number;
1719
+ }
1720
+ export type { AiAttachmentLeaseReference, AiResolveAttachmentLeasesRequest, AiResolveAttachmentLeasesResponse, AiResolvedAttachment, } from "@superblocksteam/shared";
1721
+ //# sourceMappingURL=ai.d.ts.map