@superblocksteam/library-shared 1.99.99-next.3 → 2.0.0-SNAPSHOT.295fc0b43e332060

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 (193) 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 -9
  35. package/dist/props/helpers.d.ts.map +1 -1
  36. package/dist/props/helpers.js +5 -54
  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/testing/default-structure-scope/index.d.ts +8 -0
  58. package/dist/testing/default-structure-scope/index.d.ts.map +1 -0
  59. package/dist/testing/default-structure-scope/index.js +62 -0
  60. package/dist/testing/default-structure-scope/index.js.map +1 -0
  61. package/dist/testing/fake-editor-channel/fake-artifact.d.ts +41 -0
  62. package/dist/testing/fake-editor-channel/fake-artifact.d.ts.map +1 -0
  63. package/dist/testing/fake-editor-channel/fake-artifact.js +74 -0
  64. package/dist/testing/fake-editor-channel/fake-artifact.js.map +1 -0
  65. package/dist/testing/fake-editor-channel/index.d.ts +115 -0
  66. package/dist/testing/fake-editor-channel/index.d.ts.map +1 -0
  67. package/dist/testing/fake-editor-channel/index.js +292 -0
  68. package/dist/testing/fake-editor-channel/index.js.map +1 -0
  69. package/dist/testing/fake-editor-channel/type-pins.d.ts +13 -0
  70. package/dist/testing/fake-editor-channel/type-pins.d.ts.map +1 -0
  71. package/dist/testing/fake-editor-channel/type-pins.js +13 -0
  72. package/dist/testing/fake-editor-channel/type-pins.js.map +1 -0
  73. package/dist/types/ai.d.ts +1745 -0
  74. package/dist/types/ai.d.ts.map +1 -0
  75. package/dist/types/ai.js +445 -0
  76. package/dist/types/ai.js.map +1 -0
  77. package/dist/types/apis.d.ts +44 -1
  78. package/dist/types/apis.d.ts.map +1 -1
  79. package/dist/types/base-entity-manager.d.ts +15 -0
  80. package/dist/types/base-entity-manager.d.ts.map +1 -0
  81. package/dist/types/base-entity-manager.js +2 -0
  82. package/dist/types/base-entity-manager.js.map +1 -0
  83. package/dist/types/common.d.ts +4 -1
  84. package/dist/types/common.d.ts.map +1 -1
  85. package/dist/types/common.js +4 -1
  86. package/dist/types/common.js.map +1 -1
  87. package/dist/types/edit-operations.d.ts +26 -35
  88. package/dist/types/edit-operations.d.ts.map +1 -1
  89. package/dist/types/edit-operations.js +2 -0
  90. package/dist/types/edit-operations.js.map +1 -1
  91. package/dist/types/entities.d.ts +10 -29
  92. package/dist/types/entities.d.ts.map +1 -1
  93. package/dist/types/entities.js +0 -5
  94. package/dist/types/entities.js.map +1 -1
  95. package/dist/types/errors.d.ts +82 -1
  96. package/dist/types/errors.d.ts.map +1 -1
  97. package/dist/types/errors.js +18 -1
  98. package/dist/types/errors.js.map +1 -1
  99. package/dist/types/events.d.ts +218 -26
  100. package/dist/types/events.d.ts.map +1 -1
  101. package/dist/types/events.js +33 -5
  102. package/dist/types/events.js.map +1 -1
  103. package/dist/types/index.d.ts +19 -7
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/index.js +19 -7
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/migration.d.ts +240 -0
  108. package/dist/types/migration.d.ts.map +1 -0
  109. package/dist/types/migration.js +50 -0
  110. package/dist/types/migration.js.map +1 -0
  111. package/dist/types/mobx-shared-state.d.ts +25 -1
  112. package/dist/types/mobx-shared-state.d.ts.map +1 -1
  113. package/dist/types/parent-messages.d.ts +44 -14
  114. package/dist/types/parent-messages.d.ts.map +1 -1
  115. package/dist/types/persisted-chat-message.d.ts +55 -0
  116. package/dist/types/persisted-chat-message.d.ts.map +1 -0
  117. package/dist/types/persisted-chat-message.js +757 -0
  118. package/dist/types/persisted-chat-message.js.map +1 -0
  119. package/dist/types/protected-packages.d.ts +54 -0
  120. package/dist/types/protected-packages.d.ts.map +1 -0
  121. package/dist/types/protected-packages.js +91 -0
  122. package/dist/types/protected-packages.js.map +1 -0
  123. package/dist/types/register-component.d.ts +128 -0
  124. package/dist/types/register-component.d.ts.map +1 -0
  125. package/dist/types/register-component.js +45 -0
  126. package/dist/types/register-component.js.map +1 -0
  127. package/dist/types/routing.d.ts +68 -0
  128. package/dist/types/routing.d.ts.map +1 -0
  129. package/dist/types/routing.js +2 -0
  130. package/dist/types/routing.js.map +1 -0
  131. package/dist/types/scope.d.ts +8 -6
  132. package/dist/types/scope.d.ts.map +1 -1
  133. package/dist/types/snapshot.d.ts +53 -0
  134. package/dist/types/snapshot.d.ts.map +1 -0
  135. package/dist/types/snapshot.js +2 -0
  136. package/dist/types/snapshot.js.map +1 -0
  137. package/dist/types/socket-method-names.d.ts +216 -0
  138. package/dist/types/socket-method-names.d.ts.map +1 -0
  139. package/dist/types/socket-method-names.js +165 -0
  140. package/dist/types/socket-method-names.js.map +1 -0
  141. package/dist/types/socket.d.ts +722 -48
  142. package/dist/types/socket.d.ts.map +1 -1
  143. package/dist/types/theme.d.ts +8 -7
  144. package/dist/types/theme.d.ts.map +1 -1
  145. package/dist/types/theme.js +5 -6
  146. package/dist/types/theme.js.map +1 -1
  147. package/dist/types/tool-permission-response.d.ts +5 -0
  148. package/dist/types/tool-permission-response.d.ts.map +1 -0
  149. package/dist/types/tool-permission-response.js +26 -0
  150. package/dist/types/tool-permission-response.js.map +1 -0
  151. package/dist/types/vite.d.ts +29 -0
  152. package/dist/types/vite.d.ts.map +1 -0
  153. package/dist/types/vite.js +6 -0
  154. package/dist/types/vite.js.map +1 -0
  155. package/dist/urls.d.ts +7 -0
  156. package/dist/urls.d.ts.map +1 -0
  157. package/dist/urls.js +6 -0
  158. package/dist/urls.js.map +1 -0
  159. package/dist/utils/binding-identifier.d.ts +1 -0
  160. package/dist/utils/binding-identifier.d.ts.map +1 -1
  161. package/dist/utils/binding-identifier.js +3 -0
  162. package/dist/utils/binding-identifier.js.map +1 -1
  163. package/dist/utils/blocks.d.ts +3 -0
  164. package/dist/utils/blocks.d.ts.map +1 -0
  165. package/dist/utils/blocks.js +70 -0
  166. package/dist/utils/blocks.js.map +1 -0
  167. package/dist/utils/computed-args.d.ts +11 -0
  168. package/dist/utils/computed-args.d.ts.map +1 -0
  169. package/dist/utils/computed-args.js +13 -0
  170. package/dist/utils/computed-args.js.map +1 -0
  171. package/dist/utils/dev-server-authorization.d.ts +4 -0
  172. package/dist/utils/dev-server-authorization.d.ts.map +1 -0
  173. package/dist/utils/dev-server-authorization.js +56 -0
  174. package/dist/utils/dev-server-authorization.js.map +1 -0
  175. package/dist/utils/dotted-paths.js +1 -1
  176. package/dist/utils/dotted-paths.js.map +1 -1
  177. package/dist/utils/properties.d.ts +12 -9
  178. package/dist/utils/properties.d.ts.map +1 -1
  179. package/dist/utils/properties.js +14 -6
  180. package/dist/utils/properties.js.map +1 -1
  181. package/dist/utils/routing.d.ts +5 -0
  182. package/dist/utils/routing.d.ts.map +1 -0
  183. package/dist/utils/routing.js +16 -0
  184. package/dist/utils/routing.js.map +1 -0
  185. package/dist/utils/strings.d.ts +12 -0
  186. package/dist/utils/strings.d.ts.map +1 -1
  187. package/dist/utils/strings.js +40 -1
  188. package/dist/utils/strings.js.map +1 -1
  189. package/package.json +53 -25
  190. package/dist/apis.d.ts +0 -2
  191. package/dist/apis.d.ts.map +0 -1
  192. package/dist/apis.js +0 -4
  193. package/dist/apis.js.map +0 -1
@@ -1,38 +1,478 @@
1
+ import type { DefaultStructureState } from "../default-structure.js";
2
+ import type { AiAppFact, AiChangeInfoPush, AiChatGetMessagesResponse, AiChatMessage, AiGenerateRequest, AiGenerationStateSnapshot, AiInterpretPromptRequest, AiLabelAttachmentRequest, AiLabelAttachmentResponse, AiMoveAppKnowledgeRequest, AiMoveAppKnowledgeResult, AiPromptInterpretationPush, AiToolPermission, AiToolPermissionDetails, LLMProviderConfig, PromptContextIntegration, TokenRequestData } from "./ai.js";
3
+ import type { ApiRunRecord, IApiV3Dto } from "./apis.js";
1
4
  import type { SbElement } from "./common.js";
2
- import type { AddEntityRequest, ApiUpdateRequest, BatchUpdateRequest, CreateRequest, DeleteEntityRequest, ReparentRequest, SetPropertiesRequest, SetPropertyRequest, UpdateEntityRequest, UpdateThemeRequest, DeleteRequest, ApiUpdateResponse, ApiDeleteRequest, ApiDeleteResponse, DeletePropertiesRequest, RenameElementRequest, RenameApiRequest, SyncronizationStatus, AiGenerateRequest } from "./edit-operations.js";
3
- import type { ServerError } from "./errors.js";
5
+ /**
6
+ * A single live execution step emitted by a policy gate agent while it runs.
7
+ * Mirrors what Clark surfaces (a tool invocation or a reasoning/thinking
8
+ * block) so the editor can render the agent's latest activity inline under the
9
+ * running policy row. Only the latest step per policy is retained; these are
10
+ * best-effort, ephemeral, and not persisted.
11
+ *
12
+ * A step always represents the agent's *current* activity (an in-flight tool
13
+ * call or an ongoing thought), so the editor renders it in the present tense
14
+ * ("Reading `file`", "Thinking..."). Completed tool results are not surfaced.
15
+ */
16
+ export type AiPolicyAgentStep = {
17
+ kind: "tool";
18
+ toolCallId: string;
19
+ tool: string;
20
+ args?: Record<string, unknown>;
21
+ } | {
22
+ kind: "reasoning";
23
+ content: string;
24
+ };
25
+ export interface AiPolicyAgentStepPush {
26
+ applicationId: string;
27
+ policyId: string;
28
+ step: AiPolicyAgentStep;
29
+ }
30
+ /**
31
+ * Response type for SDK API execution via aiExecuteSdkApi.
32
+ * Used by both the library iframe (sender) and socket handler (receiver)
33
+ * to ensure type consistency.
34
+ */
35
+ /**
36
+ * Per-integration-call diagnostic record captured during SDK API execution.
37
+ */
38
+ export interface IntegrationCallDiagnostic {
39
+ integrationId: string;
40
+ pluginId: string;
41
+ inputTruncated?: string;
42
+ outputTruncated?: string;
43
+ startMs: number;
44
+ endMs: number;
45
+ durationMs: number;
46
+ error?: string;
47
+ /** Error code from the orchestrator (e.g. INTEGRATION_QUERY_TIMEOUT, INTEGRATION_NETWORK). */
48
+ errorCode?: string;
49
+ sequence: number;
50
+ metadata?: {
51
+ label?: string;
52
+ description?: string;
53
+ };
54
+ /** True when the input field was truncated to fit within the byte limit. */
55
+ inputWasTruncated?: boolean;
56
+ /** True when the output field was truncated to fit within the byte limit. */
57
+ outputWasTruncated?: boolean;
58
+ }
59
+ /**
60
+ * Breakdown of time spent in each phase of an SDK API execution.
61
+ * All values are milliseconds. Phases are sequential:
62
+ * bootstrap → discovery → fileSync → authCheck → network (fetch round-trip).
63
+ */
64
+ export interface ExecutionTimingBreakdown {
65
+ /** Time spent waiting for the bootstrap response (app context, tokens). */
66
+ bootstrapMs?: number;
67
+ /** Time spent waiting for SDK API discovery to register the entry point. */
68
+ discoveryMs?: number;
69
+ /** Time spent flushing pending file writes to the server (ensureFilesSynced). */
70
+ fileSyncMs?: number;
71
+ /** Time spent on frontend auth checks before the orchestrator call. */
72
+ authCheckMs?: number;
73
+ /** Network round-trip time for the fetch to the orchestrator (fetch end − fetch start). */
74
+ networkMs?: number;
75
+ }
76
+ export interface SdkApiExecutionResult {
77
+ /** Whether execution succeeded */
78
+ success: boolean;
79
+ /** Output data if successful */
80
+ output?: unknown;
81
+ /** Error details if failed */
82
+ error?: {
83
+ code: string;
84
+ message: string;
85
+ details?: unknown;
86
+ };
87
+ /** Per-integration-call diagnostics when includeDiagnostics was requested */
88
+ diagnostics?: IntegrationCallDiagnostic[];
89
+ /** Unix epoch ms when the orchestrator started execution (from response performance.start). */
90
+ executionStartMs?: number;
91
+ /** Total execution duration in ms as measured by the orchestrator (from response performance.total). */
92
+ executionDurationMs?: number;
93
+ /** Unix epoch ms captured right before the HTTP request to the orchestrator. Used as fallback start time when orchestrator timing is unavailable. */
94
+ fetchStartMs?: number;
95
+ /** Per-phase timing breakdown for the execution. */
96
+ timingBreakdown?: ExecutionTimingBreakdown;
97
+ }
98
+ export interface AiSummarizeApiUsageRequest {
99
+ apiName: string;
100
+ jwt: string;
101
+ llmConfig?: LLMProviderConfig;
102
+ pages?: Array<{
103
+ name: string;
104
+ scopeId: string;
105
+ }>;
106
+ }
107
+ export interface AiPushApiUsageSummary {
108
+ apiName: string;
109
+ delta?: string;
110
+ isComplete?: boolean;
111
+ error?: string;
112
+ }
113
+ export interface AiSummarizeErrorRequest {
114
+ errorMessage: string;
115
+ pluginId: string;
116
+ integrationName: string;
117
+ input?: string;
118
+ summaryKey: string;
119
+ jwt: string;
120
+ llmConfig?: LLMProviderConfig;
121
+ apiName?: string;
122
+ stepLabel?: string;
123
+ errorCode?: string;
124
+ }
125
+ export interface AiPushErrorSummary {
126
+ summaryKey: string;
127
+ delta?: string;
128
+ isComplete?: boolean;
129
+ error?: string;
130
+ }
131
+ export interface DestructiveMigrationSummaryFinding {
132
+ excerpt: string;
133
+ fileName: string;
134
+ kind: string;
135
+ }
136
+ export interface AiSummarizeDestructiveMigrationRequest {
137
+ findings: DestructiveMigrationSummaryFinding[];
138
+ jwt: string;
139
+ scanUnavailable: boolean;
140
+ summaryKey: string;
141
+ llmConfig?: LLMProviderConfig;
142
+ }
143
+ export interface AiPushDestructiveMigrationSummary {
144
+ summaryKey: string;
145
+ delta?: string;
146
+ error?: string;
147
+ isComplete?: boolean;
148
+ }
149
+ /**
150
+ * Lifecycle state of a background task — mirrors the discriminated union
151
+ * the agent's TaskStore tracks (`TaskStatus`'s `state` field). Defined
152
+ * here (not in the agent's `tasks/types.ts`) so the UI can consume it
153
+ * without crossing the package boundary into agent-only code.
154
+ */
155
+ export type BackgroundTaskState = "running" | "completed" | "failed" | "cancelled";
156
+ /**
157
+ * Snapshot the agent pushes to the UI on every state/message change of a
158
+ * background task.
159
+ *
160
+ * Wire shape of `EditorClientMethods.aiPushTaskStatus`. Intentionally
161
+ * never includes the task's `result` — terminal results are only
162
+ * conveyed to the LLM via the generic checkTask/waitForTask flow, which
163
+ * already runs through the secret-scanning middleware. The UI surfaces
164
+ * `state` + `message` for live progress and `error` for failures only.
165
+ */
166
+ export interface BackgroundTaskSummary {
167
+ taskId: string;
168
+ taskType: string;
169
+ label?: string;
170
+ state: BackgroundTaskState;
171
+ message?: string;
172
+ /** ms since `startedAt`. */
173
+ ageMs: number;
174
+ /** ISO timestamp for terminal states, otherwise undefined. */
175
+ completedAt?: string;
176
+ /**
177
+ * Short, plain-language failure reason when `state === "failed"`.
178
+ * Rendered directly in the chat checklist row (clamped) — keep it
179
+ * action-first and free of internal tool/infra jargon.
180
+ */
181
+ error?: string;
182
+ /**
183
+ * Optional fuller failure detail (classified code/message, request id,
184
+ * agent guidance). Surfaced to Clark via checkTask/waitForTask and as
185
+ * the checklist row tooltip — never as the clamped visible row text.
186
+ */
187
+ detail?: string;
188
+ }
189
+ import type { ApplicationEnvironmentSettings, ApplicationHashChangeSource, DegradedMode, MethodSchema, OpenApiSpec } from "@superblocksteam/shared";
190
+ import type { ApiUpdateRequest, ApiUpdateResponse, ApiDeleteRequest, ApiDeleteResponse, RenameElementRequest, RenameApiRequest, SyncronizationStatus } from "./edit-operations.js";
191
+ import type { RouterParseError, RuntimeErrorData, ServerError, ConsoleLogEntry } from "./errors.js";
4
192
  import type { DeleteMeLibraryApi } from "./parent-messages.js";
5
193
  import type { AppScope, SbScope } from "./scope.js";
6
- import type { MethodSchema } from "@superblocksteam/shared";
194
+ export type EditorHasDefaultStructure = DefaultStructureState;
195
+ export type EditorStructureReport = {
196
+ hasDefaultStructure: EditorHasDefaultStructure;
197
+ };
7
198
  /**
8
199
  * Clients -> Server
200
+ *
201
+ * Adding a method to `editor` also requires adding its name to the registry
202
+ * in `./socket-method-names.ts`; the `satisfies` guard there makes the
203
+ * compiler enforce it.
9
204
  */
10
205
  export interface ServerMethods {
11
206
  editor: {
12
- setProperties: MethodSchema<SetPropertiesRequest, any>;
13
- deleteProperties: MethodSchema<DeletePropertiesRequest, void>;
14
- moveComponent: MethodSchema<ReparentRequest, void>;
15
- createComponent: MethodSchema<CreateRequest, SbElement | undefined>;
16
- deleteComponents: MethodSchema<DeleteRequest, void>;
17
- setProperty: MethodSchema<SetPropertyRequest, void>;
18
- batchUpdate: MethodSchema<BatchUpdateRequest, unknown[]>;
19
207
  renameElement: MethodSchema<RenameElementRequest, void>;
20
208
  renameApi: MethodSchema<RenameApiRequest, void>;
21
209
  apiUpdate: MethodSchema<ApiUpdateRequest, ApiUpdateResponse>;
22
210
  apiDelete: MethodSchema<ApiDeleteRequest, ApiDeleteResponse | undefined>;
23
- addEntity: MethodSchema<AddEntityRequest, void>;
24
- updateEntity: MethodSchema<UpdateEntityRequest, void>;
25
- deleteEntity: MethodSchema<DeleteEntityRequest, void>;
26
- updateTheme: MethodSchema<UpdateThemeRequest, void>;
27
211
  ensureFilesSynced: MethodSchema<void, string | undefined>;
28
- aiRejectDraft: MethodSchema<void, void>;
29
- aiAcceptDraft: MethodSchema<void, void>;
212
+ aiRejectDraft: MethodSchema<{
213
+ silently?: boolean;
214
+ }, void>;
215
+ aiAcceptDraft: MethodSchema<{
216
+ silently?: boolean;
217
+ }, {
218
+ commitId: string;
219
+ warning?: {
220
+ code: "draft_state_cleanup_failed";
221
+ message: string;
222
+ };
223
+ }>;
224
+ aiUploadCheckpointScreenshot: MethodSchema<{
225
+ commitId: string;
226
+ screenshotDataUrl: string;
227
+ }, void>;
228
+ aiClearDraftState: MethodSchema<void, void>;
30
229
  aiGenerate: MethodSchema<AiGenerateRequest, void>;
230
+ aiGenerateWithQueue: MethodSchema<AiGenerateRequest & {
231
+ queueMode: "queue" | "interrupt";
232
+ }, {
233
+ /**
234
+ * The generation this prompt started, named the same way every
235
+ * `aiSetGenerationState` push for it is. A caller keeps it so it can
236
+ * tell its own turn ending from a generation the ai-service started
237
+ * on its own. Absent from dev servers that predate the field.
238
+ * (APPS-5161)
239
+ */
240
+ generationId?: string;
241
+ status: "started" | "interrupted";
242
+ }>;
243
+ releaseTurnLock: MethodSchema<{
244
+ headlessTurnId?: string;
245
+ }, void>;
246
+ /**
247
+ * Fires the invisible post-flip v2→v3 API migration turn on the
248
+ * ai-service. The server-side handler is idempotent (one-shot per
249
+ * ai-service process) and bails if no `seed_api` checklist items are
250
+ * pending, so the UI can call this unconditionally as soon as it
251
+ * observes the `translating` phase.
252
+ */
253
+ aiTriggerMigrationTurn: MethodSchema<{
254
+ jwt: string;
255
+ llmConfig: LLMProviderConfig;
256
+ /**
257
+ * When set, the turn is dispatched in debug-retry mode: the
258
+ * server bypasses its one-shot guard and the translation
259
+ * prompt is reframed around prior failures. Used after the
260
+ * UI's "Fix with Clark" button hits
261
+ * `/sb-migration-retry-unresolved`.
262
+ */
263
+ retryMode?: "focused-debug";
264
+ }, {
265
+ dispatched: boolean;
266
+ reason?: string;
267
+ }>;
31
268
  aiCancel: MethodSchema<void, void>;
269
+ aiNotifyIntegrationSetupClosed: MethodSchema<void | {
270
+ outcome: "abandoned" | "saved";
271
+ }, void>;
272
+ aiChatGetMessages: MethodSchema<{
273
+ force?: boolean;
274
+ }, AiChatGetMessagesResponse>;
275
+ aiNewChat: MethodSchema<void, void>;
276
+ aiRestoreToCommit: MethodSchema<{
277
+ sinceTimestamp: number;
278
+ commitId: string;
279
+ applicationId: string;
280
+ branchName: string;
281
+ }, void>;
282
+ aiInterpretPrompt: MethodSchema<AiInterpretPromptRequest, void>;
283
+ aiSummarizeApiUsage: MethodSchema<AiSummarizeApiUsageRequest, void>;
284
+ aiSummarizeDestructiveMigration: MethodSchema<AiSummarizeDestructiveMigrationRequest, void>;
285
+ aiSummarizeError: MethodSchema<AiSummarizeErrorRequest, void>;
286
+ aiSkipTestCase: MethodSchema<{
287
+ testRunId: string;
288
+ testCaseId: string;
289
+ }, void>;
290
+ aiRespondToToolPermission: MethodSchema<{
291
+ messageId: string;
292
+ approved: boolean;
293
+ alwaysAllowPermissions?: AiToolPermission[];
294
+ denyMessage?: string;
295
+ requestId?: string;
296
+ }, void>;
297
+ /**
298
+ * UI-initiated cancellation of a background task. The agent aborts
299
+ * the local poll loop and best-effort invokes the task type's
300
+ * `cancel` hook on the external system. Returns `{ cancelled: true }`
301
+ * when the task transitioned from `running` to `cancelled`, or
302
+ * `{ cancelled: false }` when the task was already terminal (or
303
+ * unknown — both surface as a no-op so the UI can dispatch this
304
+ * thunk optimistically).
305
+ */
306
+ aiCancelBackgroundTask: MethodSchema<{
307
+ taskId: string;
308
+ }, {
309
+ cancelled: boolean;
310
+ }>;
311
+ aiLabelAttachment: MethodSchema<AiLabelAttachmentRequest, AiLabelAttachmentResponse>;
312
+ handleRuntimeError: MethodSchema<RuntimeErrorData, void>;
313
+ handleClearRuntimeError: MethodSchema<{
314
+ id: string;
315
+ }, void>;
316
+ handleClearRuntimeErrors: MethodSchema<{
317
+ before?: number;
318
+ }, void>;
319
+ handleConsoleLog: MethodSchema<ConsoleLogEntry, void>;
320
+ handleApiRunRecord: MethodSchema<{
321
+ apiId: string;
322
+ run: ApiRunRecord;
323
+ }, void>;
324
+ handleJudgeEvaluation: MethodSchema<{
325
+ promptId: string;
326
+ prompt: string;
327
+ appId: string;
328
+ appUrl: string;
329
+ jwt: string;
330
+ llmConfig?: LLMProviderConfig;
331
+ options?: {
332
+ complexity?: "low" | "medium" | "high";
333
+ storageStatePath?: string;
334
+ playwrightServerUrl?: string;
335
+ connectWsEndpoint?: string;
336
+ storageStateData?: any;
337
+ sessionStorageData?: {
338
+ origin: string;
339
+ items: Array<{
340
+ name: string;
341
+ value: string;
342
+ }>;
343
+ };
344
+ extraOrigins?: Array<{
345
+ origin: string;
346
+ localStorage: Array<{
347
+ name: string;
348
+ value: string;
349
+ }>;
350
+ sessionStorage?: Array<{
351
+ name: string;
352
+ value: string;
353
+ }>;
354
+ }>;
355
+ };
356
+ }, {
357
+ promptId: string;
358
+ appId: string;
359
+ overallScore: number;
360
+ passed: boolean;
361
+ criteriaEvaluations: Array<{
362
+ criterion: string;
363
+ passed: boolean;
364
+ score: number;
365
+ reasoning: string;
366
+ evidence?: string;
367
+ suggestions?: string[];
368
+ }>;
369
+ summary: string;
370
+ suggestions: string[];
371
+ strengths?: string[];
372
+ weaknesses?: string[];
373
+ tokensUsed: {
374
+ input: number;
375
+ output: number;
376
+ cached?: number;
377
+ total: number;
378
+ };
379
+ evaluationDurationMs?: number;
380
+ confidence?: number;
381
+ error?: string;
382
+ }>;
383
+ ping: MethodSchema<void | {
384
+ isUserActive: boolean;
385
+ }, void>;
386
+ /** Enable/disable forwarding Clark (Vite plugin) logs to browser console. Use `?clark_logs=true` query param. */
387
+ setClarkLogsEnabled: MethodSchema<{
388
+ enabled: boolean;
389
+ }, void>;
390
+ /** Prime Clark with the user's inference JWT when auth hot-reload is unavailable (EE). */
391
+ primeClarkInferenceJwt: MethodSchema<{
392
+ jwt: string;
393
+ }, void>;
394
+ /** Get all saved app skill facts for the current application */
395
+ aiGetAppFacts: MethodSchema<void, {
396
+ facts: AiAppFact[];
397
+ }>;
398
+ /** Delete an app skill fact by its virtual path */
399
+ aiDeleteAppFact: MethodSchema<{
400
+ path: string;
401
+ }, void>;
402
+ /** Toggle the isEnabled field of an app skill fact */
403
+ aiToggleAppFact: MethodSchema<{
404
+ path: string;
405
+ isEnabled: boolean;
406
+ }, {
407
+ fact: AiAppFact;
408
+ }>;
409
+ /** Move app skill knowledge to org/user/integration scope */
410
+ aiMoveAppKnowledge: MethodSchema<AiMoveAppKnowledgeRequest, AiMoveAppKnowledgeResult>;
411
+ gitCommitLocal: MethodSchema<{
412
+ message: string;
413
+ }, {
414
+ sha: string;
415
+ }>;
416
+ gitPushLiveBranch: MethodSchema<void, void>;
417
+ gitRollbackLastCommit: MethodSchema<{
418
+ expectedSha: string;
419
+ }, {
420
+ rolledBack: boolean;
421
+ }>;
422
+ gitPull: MethodSchema<{
423
+ jwt?: string;
424
+ } | void, {
425
+ merged: boolean;
426
+ conflictedFiles?: string[];
427
+ }>;
428
+ gitSyncStatus: MethodSchema<void, {
429
+ ahead: number;
430
+ behind: number;
431
+ hasUncommittedChanges: boolean;
432
+ aheadOfDefaultBranch: boolean;
433
+ isLiveBranchMissing: boolean;
434
+ remoteAuthFailed?: boolean;
435
+ } | {
436
+ authFailed?: boolean;
437
+ bootstrapFailed: true;
438
+ } | null>;
439
+ gitChangedFiles: MethodSchema<void, Array<{
440
+ path: string;
441
+ status: "added" | "modified" | "deleted";
442
+ }>>;
443
+ gitDisconnect: MethodSchema<void, void>;
444
+ gitDefaultBranch: MethodSchema<void, string | null>;
445
+ gitBranchLog: MethodSchema<{
446
+ branch?: string;
447
+ limit?: number;
448
+ remote?: boolean;
449
+ } | void, Array<{
450
+ sha: string;
451
+ parents?: string[];
452
+ message: string;
453
+ author: string;
454
+ date: string;
455
+ }>>;
456
+ gitPrepareMainCommit: MethodSchema<{
457
+ sha: string;
458
+ }, {
459
+ directoryHash: string;
460
+ sha: string;
461
+ }>;
462
+ gitActivate: MethodSchema<void, {
463
+ activated: boolean;
464
+ }>;
465
+ gitRefreshCredentials: MethodSchema<void, {
466
+ refreshed: boolean;
467
+ }>;
32
468
  };
33
469
  }
34
470
  /**
35
471
  * Server -> Editor
472
+ *
473
+ * Adding a method here also requires adding its name to the registry in
474
+ * `./socket-method-names.ts`; the `satisfies` guard there makes the compiler
475
+ * enforce it.
36
476
  */
37
477
  export interface EditorClientMethods {
38
478
  updateScope: MethodSchema<{
@@ -46,58 +486,284 @@ export interface EditorClientMethods {
46
486
  id: string;
47
487
  }, void>;
48
488
  manualUpdateApi: MethodSchema<{
49
- api: DeleteMeLibraryApi;
489
+ api: DeleteMeLibraryApi & {
490
+ scopeId: string;
491
+ };
492
+ }, void>;
493
+ updateApiInputs: MethodSchema<{
494
+ apiId: string;
495
+ inputs: string[];
50
496
  }, void>;
51
497
  error: MethodSchema<ServerError, void>;
498
+ routerParseError: MethodSchema<RouterParseError | null, void>;
52
499
  releasingLock: MethodSchema<void, void>;
500
+ closedByServer: MethodSchema<{
501
+ initiatedByEmail?: string;
502
+ switchingTo?: "local" | "cloud" | "none";
503
+ }, void>;
53
504
  syncStatus: MethodSchema<{
54
505
  status: SyncronizationStatus;
55
506
  generationNumber: number | undefined;
507
+ /** What caused the change, when it was an upload the dev server ran. */
508
+ source?: ApplicationHashChangeSource;
56
509
  }, void>;
57
- aiSetLoading: MethodSchema<{
58
- isLoading: boolean;
59
- }, void>;
60
- aiPushMessage: MethodSchema<{
61
- text: string;
62
- type?: "reasoning" | "text";
63
- }, void>;
64
- aiSetCompleted: MethodSchema<{
65
- hasError?: boolean;
66
- hasSuggestions?: boolean;
510
+ setDegradedMode: MethodSchema<{
511
+ degradedMode: DegradedMode | undefined;
67
512
  }, void>;
513
+ aiApplyApplicationEnvironmentSettings: MethodSchema<ApplicationEnvironmentSettings, void>;
514
+ aiSwitchSelectedEnvironment: MethodSchema<{
515
+ profileKey: string;
516
+ }, {
517
+ success: boolean;
518
+ profile?: {
519
+ displayName: string;
520
+ id: string;
521
+ key: string;
522
+ };
523
+ error?: string;
524
+ }>;
525
+ aiPushChangeInfo: MethodSchema<AiChangeInfoPush, void>;
526
+ aiPushMessage: MethodSchema<AiChatMessage, void>;
527
+ aiPushPromptInterpretation: MethodSchema<AiPromptInterpretationPush, void>;
68
528
  aiSetDraftState: MethodSchema<{
69
529
  hasDraft: boolean;
70
530
  }, void>;
531
+ aiGetOpenApiSpec: MethodSchema<{
532
+ ref: string;
533
+ integrationId: string;
534
+ }, OpenApiSpec | undefined>;
535
+ aiGetIntegration: MethodSchema<{
536
+ integrationId: string;
537
+ }, PromptContextIntegration>;
538
+ aiGetIntegrations: MethodSchema<void, Omit<PromptContextIntegration, "metadata">[]>;
539
+ aiSetGenerationState: MethodSchema<AiGenerationStateSnapshot, void>;
540
+ aiExecuteRequestToIntegration: MethodSchema<{
541
+ request: Record<string, unknown>;
542
+ integrationId: string;
543
+ integrationHint?: {
544
+ name: string;
545
+ type: string;
546
+ displayName?: string;
547
+ };
548
+ }, {
549
+ response?: string;
550
+ error?: string;
551
+ }>;
552
+ aiRequestToolPermission: MethodSchema<{
553
+ messageId: string;
554
+ toolName: string;
555
+ actionName: {
556
+ future: string;
557
+ present: string;
558
+ past: string;
559
+ } | undefined;
560
+ formattedInput: AiToolPermissionDetails | undefined;
561
+ rawInput: any;
562
+ permissions: AiToolPermission[];
563
+ signature?: string;
564
+ }, void>;
565
+ aiClearToolPermission: MethodSchema<void, void>;
566
+ aiPushTokenUsage: MethodSchema<TokenRequestData, void>;
567
+ aiPushContextUsed: MethodSchema<{
568
+ contextUsed: number;
569
+ }, void>;
570
+ aiPushApiUsageSummary: MethodSchema<AiPushApiUsageSummary, void>;
571
+ aiPushDestructiveMigrationSummary: MethodSchema<AiPushDestructiveMigrationSummary, void>;
572
+ aiPushErrorSummary: MethodSchema<AiPushErrorSummary, void>;
573
+ aiPushPolicyAgentStep: MethodSchema<AiPolicyAgentStepPush, void>;
574
+ /**
575
+ * Agent -> UI push fired on every background-task status transition
576
+ * (including the initial in-store snapshot after `start`) and
577
+ * re-emitted for every non-terminal task on socket reconnect so a
578
+ * fresh tab can rebuild its indicator state. Terminal summaries
579
+ * (`completed | failed | cancelled`) are pushed once; the UI is
580
+ * responsible for evicting entries on chat-clear or app-switch.
581
+ */
582
+ aiPushTaskStatus: MethodSchema<BackgroundTaskSummary, void>;
583
+ /**
584
+ * Agent -> UI push of the authoritative set of tasks the agent is
585
+ * actually running, sent once per socket reconnect alongside the
586
+ * per-task resync above (ENG-6785).
587
+ *
588
+ * `aiPushTaskStatus` is additive and cannot retire a row: when the
589
+ * process that owned a task is replaced, its successor has no record of
590
+ * the task and pushes nothing for it, which is indistinguishable from a
591
+ * task running quietly. The UI marks any local `running` row missing
592
+ * from `runningTaskIds` as no longer running. Scoped to what the
593
+ * reconnecting peer may see, so it never names another user's task.
594
+ */
595
+ aiSyncActiveTasks: MethodSchema<{
596
+ runningTaskIds: string[];
597
+ }, void>;
71
598
  setApiDependencies: MethodSchema<{
72
599
  apiDependencies: Record<string, string[]>;
73
600
  }, void>;
601
+ aiExecuteV2Api: MethodSchema<{
602
+ api: {
603
+ type: "inline";
604
+ definition: IApiV3Dto["apiPb"];
605
+ } | {
606
+ type: "fetch";
607
+ apiName: string;
608
+ };
609
+ inputs: Record<string, any>;
610
+ includeStepOutputs?: boolean;
611
+ timeout?: number;
612
+ }, {
613
+ outputs?: Record<string, any>;
614
+ stepOutputs?: Record<string, {
615
+ error?: any;
616
+ output?: any;
617
+ }>;
618
+ errors?: Array<{
619
+ message: string;
620
+ handled?: boolean;
621
+ }>;
622
+ systemError?: string;
623
+ }>;
624
+ aiExecuteSdkApi: MethodSchema<{
625
+ /** Name of the registered SDK API to execute */
626
+ apiName: string;
627
+ /** Input data for the API */
628
+ input: Record<string, unknown>;
629
+ /** Entry point resolved by the caller (used when browser discovery hasn't run yet) */
630
+ entryPoint?: string;
631
+ /** Export name for named-export APIs sharing a file */
632
+ exportName?: string;
633
+ /** Integration IDs extracted from the API source by the caller.
634
+ * Used for auth preflight when the browser-side SDK discovery
635
+ * hasn't registered the API in the Redux store yet. */
636
+ integrationIds?: string[];
637
+ }, SdkApiExecutionResult>;
638
+ aiCaptureScreenshot: MethodSchema<{
639
+ selector?: string;
640
+ } | void, {
641
+ dataUrl?: string;
642
+ error?: string;
643
+ /**
644
+ * True when no screenshot was taken because the app preview had not
645
+ * rendered yet (e.g. still building/migrating). The agent must treat this
646
+ * as "not ready / wait and retry", NOT as a visual verification result.
647
+ */
648
+ notReady?: boolean;
649
+ }>;
650
+ aiNavigatePreviewRoute: MethodSchema<{
651
+ hash?: string;
652
+ path: string;
653
+ queryParams?: Record<string, string>;
654
+ routeParams?: Record<string, string>;
655
+ }, {
656
+ error?: string;
657
+ path?: string;
658
+ success: boolean;
659
+ }>;
660
+ reloadIframe: MethodSchema<void, void>;
661
+ clarkLog: MethodSchema<{
662
+ level: "info" | "warn" | "error";
663
+ state: string;
664
+ messages: unknown[];
665
+ timestamp: number;
666
+ meta?: {
667
+ error: {
668
+ kind: string;
669
+ message: string;
670
+ stack?: string;
671
+ };
672
+ };
673
+ }, void>;
674
+ appFactsChanged: MethodSchema<void, void>;
675
+ requestGitRefresh: MethodSchema<void, void>;
676
+ notifyDeploySuccess: MethodSchema<{
677
+ commitId: string;
678
+ gitSha?: string;
679
+ }, void>;
680
+ aiGetIntegrationFormSchema: MethodSchema<{
681
+ pluginId: string;
682
+ }, {
683
+ success: boolean;
684
+ pluginId?: string;
685
+ pluginName?: string;
686
+ isTestable?: boolean;
687
+ fields?: Record<string, unknown>;
688
+ error?: string;
689
+ }>;
690
+ aiOpenIntegrationSetup: MethodSchema<{
691
+ pluginId: string;
692
+ label?: string;
693
+ fields?: Record<string, unknown>;
694
+ }, {
695
+ success: boolean;
696
+ formState?: unknown;
697
+ error?: string;
698
+ }>;
699
+ aiOpenExistingIntegration: MethodSchema<{
700
+ integrationId: string;
701
+ fields?: Record<string, unknown>;
702
+ }, {
703
+ success: boolean;
704
+ pluginId?: string;
705
+ integrationName?: string;
706
+ formState?: unknown;
707
+ error?: string;
708
+ }>;
709
+ aiUpdateIntegrationFields: MethodSchema<{
710
+ fields: Record<string, unknown>;
711
+ configId?: string;
712
+ }, {
713
+ success: boolean;
714
+ formState?: unknown;
715
+ error?: string;
716
+ }>;
717
+ aiTestIntegrationConnection: MethodSchema<{
718
+ configId?: string;
719
+ }, {
720
+ success: boolean;
721
+ configId?: string;
722
+ error?: {
723
+ message: string;
724
+ details: string;
725
+ };
726
+ formState?: unknown;
727
+ }>;
728
+ aiSaveIntegration: MethodSchema<{
729
+ force?: boolean;
730
+ }, {
731
+ success: boolean;
732
+ integrationId?: string;
733
+ integrationName?: string;
734
+ pluginId?: string;
735
+ testFailed?: boolean;
736
+ failedConfigIds?: string[];
737
+ error?: string;
738
+ }>;
739
+ aiCloseIntegrationSetup: MethodSchema<void, {
740
+ success: boolean;
741
+ }>;
742
+ aiDeleteIntegration: MethodSchema<{
743
+ integrationId: string;
744
+ }, {
745
+ success: boolean;
746
+ integrationId?: string;
747
+ integrationName?: string;
748
+ error?: string;
749
+ }>;
750
+ aiGetIntegrationDependents: MethodSchema<{
751
+ integrationId: string;
752
+ }, {
753
+ success: boolean;
754
+ appCount?: number;
755
+ appNames?: string[];
756
+ error?: string;
757
+ }>;
758
+ }
759
+ export interface GatewayClientMethods extends EditorClientMethods {
760
+ aiSetEditorHasDefaultStructure: MethodSchema<EditorStructureReport, void>;
74
761
  }
75
762
  /**
76
763
  * Server -> Library
77
764
  */
78
765
  export interface LibraryClientMethods {
79
766
  nonVisualEdit: MethodSchema<void, void>;
80
- updateApiParams: MethodSchema<{
81
- apiName: string;
82
- params: string[];
83
- apiDependencies: string[];
84
- }, void>;
85
- setApiDefinitions: MethodSchema<Record<string, {
86
- api: DeleteMeLibraryApi;
87
- scopeId: string;
88
- }>, void>;
89
- updateApi: MethodSchema<{
90
- api: DeleteMeLibraryApi;
91
- oldName?: string;
92
- scopeId: string;
93
- }, void>;
94
- deleteApis: MethodSchema<{
95
- apiName: string;
96
- scopeId?: string;
97
- }[], void>;
98
- updateLocalBindingEntities: MethodSchema<{
99
- entities: string[];
100
- }, void>;
101
767
  renameRegisteredComponent: MethodSchema<{
102
768
  name: string;
103
769
  oldName?: string;
@@ -111,5 +777,13 @@ export interface LibraryClientMethods {
111
777
  entityId?: string;
112
778
  entityName?: string;
113
779
  }[], void>;
780
+ clientImport: MethodSchema<{
781
+ importPath: string;
782
+ }, Error | undefined>;
783
+ /** Notify library that an SDK API's source code has changed */
784
+ sdkApiSourceUpdated: MethodSchema<{
785
+ apiName: string;
786
+ sourceCode: string;
787
+ }, void>;
114
788
  }
115
789
  //# sourceMappingURL=socket.d.ts.map