@superblocksteam/vite-plugin-file-sync 2.0.154 → 2.0.155-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +23 -1
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  3. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +84 -29
  4. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  5. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +2 -0
  6. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -1
  7. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +11 -2
  8. package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -1
  9. package/dist/ai-service/agent/tool-permission-delivery.d.ts.map +1 -1
  10. package/dist/ai-service/agent/tool-permission-delivery.js +4 -0
  11. package/dist/ai-service/agent/tool-permission-delivery.js.map +1 -1
  12. package/dist/ai-service/agent/tools/app-environment/update-app-environment.d.ts +29 -0
  13. package/dist/ai-service/agent/tools/app-environment/update-app-environment.d.ts.map +1 -0
  14. package/dist/ai-service/agent/tools/app-environment/update-app-environment.js +387 -0
  15. package/dist/ai-service/agent/tools/app-environment/update-app-environment.js.map +1 -0
  16. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts +58 -0
  17. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts.map +1 -0
  18. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js +258 -0
  19. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js.map +1 -0
  20. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +18 -6
  21. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
  22. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +203 -51
  23. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
  24. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts +12 -10
  25. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts.map +1 -1
  26. package/dist/ai-service/agent/tools/databases/dev-database-tools.js +29 -8
  27. package/dist/ai-service/agent/tools/databases/dev-database-tools.js.map +1 -1
  28. package/dist/ai-service/agent/tools/integrations/metadata.d.ts +3 -0
  29. package/dist/ai-service/agent/tools/integrations/metadata.d.ts.map +1 -1
  30. package/dist/ai-service/agent/tools/integrations/metadata.js +10 -2
  31. package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -1
  32. package/dist/ai-service/agent/tools.d.ts +9 -1
  33. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  34. package/dist/ai-service/agent/tools.js +25 -1
  35. package/dist/ai-service/agent/tools.js.map +1 -1
  36. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +8 -0
  37. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  38. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +104 -14
  39. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  40. package/dist/ai-service/app-interface/npm-registry.d.ts +9 -0
  41. package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -1
  42. package/dist/ai-service/app-interface/npm-registry.js +50 -1
  43. package/dist/ai-service/app-interface/npm-registry.js.map +1 -1
  44. package/dist/ai-service/app-skills/helpers.d.ts.map +1 -1
  45. package/dist/ai-service/app-skills/helpers.js +1 -0
  46. package/dist/ai-service/app-skills/helpers.js.map +1 -1
  47. package/dist/ai-service/dev-database-client.d.ts +3 -1
  48. package/dist/ai-service/dev-database-client.d.ts.map +1 -1
  49. package/dist/ai-service/dev-database-client.js.map +1 -1
  50. package/dist/ai-service/features.d.ts +24 -0
  51. package/dist/ai-service/features.d.ts.map +1 -1
  52. package/dist/ai-service/features.js +24 -0
  53. package/dist/ai-service/features.js.map +1 -1
  54. package/dist/ai-service/helper-system-ai-attributes.d.ts +19 -0
  55. package/dist/ai-service/helper-system-ai-attributes.d.ts.map +1 -0
  56. package/dist/ai-service/helper-system-ai-attributes.js +17 -0
  57. package/dist/ai-service/helper-system-ai-attributes.js.map +1 -0
  58. package/dist/ai-service/index.d.ts +58 -2
  59. package/dist/ai-service/index.d.ts.map +1 -1
  60. package/dist/ai-service/index.js +182 -33
  61. package/dist/ai-service/index.js.map +1 -1
  62. package/dist/ai-service/integrations/store.d.ts +3 -0
  63. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  64. package/dist/ai-service/integrations/store.js +3 -0
  65. package/dist/ai-service/integrations/store.js.map +1 -1
  66. package/dist/ai-service/live-edit-events/bridge.d.ts +21 -0
  67. package/dist/ai-service/live-edit-events/bridge.d.ts.map +1 -0
  68. package/dist/ai-service/live-edit-events/bridge.js +52 -0
  69. package/dist/ai-service/live-edit-events/bridge.js.map +1 -0
  70. package/dist/ai-service/live-edit-events/forwarder.d.ts +158 -0
  71. package/dist/ai-service/live-edit-events/forwarder.d.ts.map +1 -0
  72. package/dist/ai-service/live-edit-events/forwarder.js +403 -0
  73. package/dist/ai-service/live-edit-events/forwarder.js.map +1 -0
  74. package/dist/ai-service/state-machine/clark-fsm.d.ts +14 -0
  75. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  76. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  77. package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
  78. package/dist/ai-service/state-machine/handlers/awaiting-user.js +4 -0
  79. package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
  80. package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
  81. package/dist/ai-service/state-machine/handlers/idle.js +3 -0
  82. package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
  83. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts +2 -0
  84. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  85. package/dist/ai-service/state-machine/handlers/llm-generating.js +93 -3
  86. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  87. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.d.ts +27 -0
  88. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.d.ts.map +1 -0
  89. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.js +34 -0
  90. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.js.map +1 -0
  91. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  92. package/dist/ai-service/state-machine/helpers/peer.js +24 -0
  93. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  94. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
  95. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +4 -0
  96. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
  97. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts +103 -1
  98. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts.map +1 -1
  99. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js +263 -3
  100. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js.map +1 -1
  101. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +143 -0
  102. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
  103. package/dist/ai-service/state-machine/helpers/stable-peer.js +220 -2
  104. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
  105. package/dist/ai-service/tasks/peer-push.d.ts.map +1 -1
  106. package/dist/ai-service/tasks/peer-push.js +7 -0
  107. package/dist/ai-service/tasks/peer-push.js.map +1 -1
  108. package/dist/dev-server-ws-smoke-client.d.ts.map +1 -1
  109. package/dist/dev-server-ws-smoke-client.js +1 -0
  110. package/dist/dev-server-ws-smoke-client.js.map +1 -1
  111. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  112. package/dist/file-sync-vite-plugin.js +9 -2
  113. package/dist/file-sync-vite-plugin.js.map +1 -1
  114. package/dist/lock-service/activity-tracker.d.ts.map +1 -1
  115. package/dist/lock-service/activity-tracker.js +5 -6
  116. package/dist/lock-service/activity-tracker.js.map +1 -1
  117. package/dist/lock-service/index.d.ts +56 -1
  118. package/dist/lock-service/index.d.ts.map +1 -1
  119. package/dist/lock-service/index.js +158 -13
  120. package/dist/lock-service/index.js.map +1 -1
  121. package/dist/rename-manager.d.ts.map +1 -1
  122. package/dist/rename-manager.js +2 -6
  123. package/dist/rename-manager.js.map +1 -1
  124. package/dist/socket-manager.d.ts +64 -0
  125. package/dist/socket-manager.d.ts.map +1 -1
  126. package/dist/socket-manager.js +236 -51
  127. package/dist/socket-manager.js.map +1 -1
  128. package/dist/util/logger.d.ts +2 -0
  129. package/dist/util/logger.d.ts.map +1 -1
  130. package/dist/util/logger.js +5 -0
  131. package/dist/util/logger.js.map +1 -1
  132. package/package.json +9 -9
  133. package/dist/parsing/entity/to-code-entity.d.ts +0 -3
  134. package/dist/parsing/entity/to-code-entity.d.ts.map +0 -1
  135. package/dist/parsing/entity/to-code-entity.js +0 -77
  136. package/dist/parsing/entity/to-code-entity.js.map +0 -1
  137. package/dist/parsing/entity/to-value-entity.d.ts +0 -8
  138. package/dist/parsing/entity/to-value-entity.d.ts.map +0 -1
  139. package/dist/parsing/entity/to-value-entity.js +0 -129
  140. package/dist/parsing/entity/to-value-entity.js.map +0 -1
@@ -0,0 +1,387 @@
1
+ import z from "zod";
2
+ import { AiEntityType, AiPermissionType, } from "@superblocksteam/library-shared/types";
3
+ import { withRpcTimeout } from "../../../util/rpc-timeout.js";
4
+ import { createToolFactory, ToolCategory, ToolExecutionError, PermissionLevel, } from "../../tools2/types.js";
5
+ const MODES = ["editor", "preview", "deployed"];
6
+ export const FORMAT_INPUT_TIMEOUT_MS = 15_000;
7
+ const EXECUTE_REQUEST_TIMEOUT_MS = 30_000;
8
+ const MODE_LABELS = {
9
+ editor: "Edit",
10
+ preview: "Preview",
11
+ deployed: "Deployed",
12
+ };
13
+ function noDuplicates(arr) {
14
+ return new Set(arr).size === arr.length;
15
+ }
16
+ const modeChangeSchema = z
17
+ .object({
18
+ mode: z.enum(MODES),
19
+ addProfileIds: z.array(z.string()).optional(),
20
+ removeProfileIds: z.array(z.string()).optional(),
21
+ defaultProfileId: z.string().optional(),
22
+ })
23
+ .strict()
24
+ .refine((val) => (val.addProfileIds && val.addProfileIds.length > 0) ||
25
+ (val.removeProfileIds && val.removeProfileIds.length > 0) ||
26
+ val.defaultProfileId !== undefined, {
27
+ message: "Each change must include at least one operation (add, remove, or set default)",
28
+ })
29
+ .refine((val) => !val.addProfileIds || noDuplicates(val.addProfileIds), {
30
+ message: "addProfileIds must not contain duplicates",
31
+ })
32
+ .refine((val) => !val.removeProfileIds || noDuplicates(val.removeProfileIds), { message: "removeProfileIds must not contain duplicates" })
33
+ .refine((val) => {
34
+ if (!val.addProfileIds || !val.removeProfileIds)
35
+ return true;
36
+ const addSet = new Set(val.addProfileIds);
37
+ return !val.removeProfileIds.some((id) => addSet.has(id));
38
+ }, {
39
+ message: "A profile ID cannot appear in both addProfileIds and removeProfileIds",
40
+ });
41
+ const inputSchema = z
42
+ .object({
43
+ changes: z
44
+ .array(modeChangeSchema)
45
+ .min(1)
46
+ .refine((changes) => {
47
+ const modes = changes.map((c) => c.mode);
48
+ return new Set(modes).size === modes.length;
49
+ }, { message: "Each mode may appear at most once in changes" }),
50
+ })
51
+ .strict();
52
+ function buildUrl(baseUrl, applicationId, subpath) {
53
+ const normalizedBase = baseUrl.replace(/\/+$/, "");
54
+ const encodedAppId = encodeURIComponent(applicationId);
55
+ return new URL(`/api/v2/applications/${encodedAppId}/${subpath}`, normalizedBase).toString();
56
+ }
57
+ function applyChanges(currentProfiles, changes) {
58
+ const result = {};
59
+ for (const mode of MODES) {
60
+ const current = currentProfiles[mode];
61
+ if (!current)
62
+ continue;
63
+ result[mode] = { ...current };
64
+ }
65
+ for (const change of changes) {
66
+ const mode = change.mode;
67
+ const existing = result[mode];
68
+ if (!existing && !change.defaultProfileId) {
69
+ throw new ToolExecutionError(`Mode "${mode}" is not configured in the current environment and no defaultProfileId was provided. ` +
70
+ `Cannot add profiles to an unconfigured mode without also setting a default.`);
71
+ }
72
+ const base = existing ?? {
73
+ availableProfileIds: [],
74
+ defaultProfileId: change.defaultProfileId,
75
+ };
76
+ let profileIds = [...base.availableProfileIds];
77
+ if (change.addProfileIds) {
78
+ for (const id of change.addProfileIds) {
79
+ if (!profileIds.includes(id)) {
80
+ profileIds.push(id);
81
+ }
82
+ }
83
+ }
84
+ if (change.removeProfileIds) {
85
+ const removeSet = new Set(change.removeProfileIds);
86
+ profileIds = profileIds.filter((id) => !removeSet.has(id));
87
+ }
88
+ result[mode] = {
89
+ availableProfileIds: profileIds,
90
+ defaultProfileId: change.defaultProfileId ?? base.defaultProfileId,
91
+ };
92
+ }
93
+ return result;
94
+ }
95
+ function formatHttpError(status) {
96
+ if (status === 403) {
97
+ return "Permission denied. You do not have access to modify this environment.";
98
+ }
99
+ if (status === 409) {
100
+ return "Conflict: the environment was modified concurrently. Please retry the operation.";
101
+ }
102
+ if (status === 400) {
103
+ return "Validation failed. The requested changes are invalid or incompatible.";
104
+ }
105
+ if (status >= 500 && status < 600) {
106
+ return `Service temporarily unavailable (${status}). Please try again later.`;
107
+ }
108
+ return `Unexpected server error (${status}).`;
109
+ }
110
+ function isResponseDtoEnvelope(value) {
111
+ if (typeof value !== "object" || value === null)
112
+ return false;
113
+ if (!("responseMeta" in value) || !("data" in value))
114
+ return false;
115
+ return typeof value.responseMeta === "object" && value.responseMeta !== null;
116
+ }
117
+ function unwrapEnvelope(raw, context, validate) {
118
+ if (!isResponseDtoEnvelope(raw)) {
119
+ throw new ToolExecutionError(`Invalid response format from ${context}: missing ResponseDto envelope.`);
120
+ }
121
+ if (raw.responseMeta.success === false ||
122
+ (raw.responseMeta.status && raw.responseMeta.status >= 400)) {
123
+ throw new ToolExecutionError(formatHttpError(raw.responseMeta.status));
124
+ }
125
+ if (!validate(raw.data)) {
126
+ throw new ToolExecutionError(`Invalid response format from ${context}: unexpected data shape.`);
127
+ }
128
+ return raw.data;
129
+ }
130
+ function isEnvironmentSettings(data) {
131
+ if (typeof data !== "object" || data === null)
132
+ return false;
133
+ if (!("profiles" in data) || !("updated" in data))
134
+ return false;
135
+ return (typeof data.profiles === "object" &&
136
+ data.profiles !== null &&
137
+ typeof data.updated === "number");
138
+ }
139
+ function isCompatibilityResult(data) {
140
+ if (typeof data !== "object" || data === null)
141
+ return false;
142
+ if (!("isBlocking" in data) ||
143
+ !("overallState" in data) ||
144
+ !("remediationActions" in data) ||
145
+ !("integrations" in data) ||
146
+ !("appDatabase" in data))
147
+ return false;
148
+ return (typeof data.isBlocking === "boolean" &&
149
+ typeof data.overallState === "string" &&
150
+ Array.isArray(data.remediationActions));
151
+ }
152
+ async function serverRequest(baseUrl, applicationId, jwt, method, subpath, validate, body, signal) {
153
+ const url = buildUrl(baseUrl, applicationId, subpath);
154
+ const headers = {
155
+ Authorization: `Bearer ${jwt}`,
156
+ "Content-Type": "application/json",
157
+ };
158
+ const response = await fetch(url, {
159
+ method,
160
+ headers,
161
+ signal,
162
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
163
+ });
164
+ if (!response.ok) {
165
+ throw new ToolExecutionError(formatHttpError(response.status));
166
+ }
167
+ const json = await response.json();
168
+ return unwrapEnvelope(json, `${method} ${subpath}`, validate);
169
+ }
170
+ function extractProfiles(settings) {
171
+ const result = {};
172
+ for (const mode of MODES) {
173
+ const modeSettings = settings.profiles[mode];
174
+ if (modeSettings) {
175
+ result[mode] = modeSettings;
176
+ }
177
+ }
178
+ return result;
179
+ }
180
+ export const updateAppEnvironmentToolFactory = createToolFactory("updateAppEnvironment", (deps) => ({
181
+ category: ToolCategory.INTERACTIVE,
182
+ defaultPermission: PermissionLevel.PROMPT,
183
+ description: "Updates the application environment profile membership and defaults. " +
184
+ "Operations include adding or removing profiles from specific modes (editor, preview, deployed) " +
185
+ "and setting a default profile for a mode. Use profileIds from organizationDataTags to enable an existing organization tag on this app. " +
186
+ "The user will be asked to confirm before changes are applied. " +
187
+ "A compatibility preview is shown before confirmation.",
188
+ inputSchema,
189
+ execute: async (input, options) => {
190
+ const jwt = deps.getJwt();
191
+ if (!jwt) {
192
+ throw new ToolExecutionError("No authentication token available.");
193
+ }
194
+ const timeoutController = new AbortController();
195
+ const timeout = setTimeout(() => timeoutController.abort(), EXECUTE_REQUEST_TIMEOUT_MS);
196
+ const externalSignal = options.abortSignal;
197
+ const combinedSignal = externalSignal
198
+ ? AbortSignal.any([externalSignal, timeoutController.signal])
199
+ : timeoutController.signal;
200
+ try {
201
+ const freshEnvironment = await serverRequest(deps.superblocksBaseUrl, deps.applicationId, jwt, "GET", "environments", isEnvironmentSettings, undefined, combinedSignal);
202
+ const proposedProfiles = applyChanges(extractProfiles(freshEnvironment), input.changes);
203
+ const previewResult = await serverRequest(deps.superblocksBaseUrl, deps.applicationId, jwt, "POST", "environment-compatibility/preview", isCompatibilityResult, { profiles: proposedProfiles }, combinedSignal);
204
+ if (previewResult.isBlocking) {
205
+ throw new ToolExecutionError("Preview indicates a blocking incompatibility. The environment cannot be updated until the blocking issue is resolved.");
206
+ }
207
+ const patchResult = await serverRequest(deps.superblocksBaseUrl, deps.applicationId, jwt, "PATCH", "environments", isEnvironmentSettings, {
208
+ profiles: proposedProfiles,
209
+ lastSuccessfulWrite: freshEnvironment.updated,
210
+ }, combinedSignal);
211
+ await deps.onEnvironmentUpdated?.(patchResult);
212
+ return {
213
+ success: true,
214
+ environment: {
215
+ profiles: extractProfiles(patchResult),
216
+ updated: patchResult.updated,
217
+ },
218
+ compatibility: {
219
+ isBlocking: previewResult.isBlocking,
220
+ needsAttention: previewResult.needsAttention,
221
+ overallState: previewResult.overallState,
222
+ remediationActions: previewResult.remediationActions,
223
+ },
224
+ };
225
+ }
226
+ catch (err) {
227
+ if (err instanceof ToolExecutionError) {
228
+ throw err;
229
+ }
230
+ if (err instanceof DOMException && err.name === "AbortError") {
231
+ throw new ToolExecutionError("Operation was aborted or timed out.");
232
+ }
233
+ throw new ToolExecutionError(`Network error: ${err instanceof Error ? err.message : "unknown"}`);
234
+ }
235
+ finally {
236
+ clearTimeout(timeout);
237
+ }
238
+ },
239
+ getActionName: () => ({
240
+ future: "update app environment",
241
+ present: "updating app environment",
242
+ past: "updated app environment",
243
+ }),
244
+ formatInput: async (input) => {
245
+ const jwt = deps.getJwt();
246
+ if (!jwt) {
247
+ return {
248
+ targets: ["app environment"],
249
+ summary: "Unable to preview: no authentication token available.",
250
+ };
251
+ }
252
+ try {
253
+ const getResult = await withRpcTimeout(serverRequest(deps.superblocksBaseUrl, deps.applicationId, jwt, "GET", "environments", isEnvironmentSettings), FORMAT_INPUT_TIMEOUT_MS, "GET environments");
254
+ const proposedProfiles = applyChanges(extractProfiles(getResult), input.changes);
255
+ const previewResult = await withRpcTimeout(serverRequest(deps.superblocksBaseUrl, deps.applicationId, jwt, "POST", "environment-compatibility/preview", isCompatibilityResult, { profiles: proposedProfiles }), FORMAT_INPUT_TIMEOUT_MS, "POST environment-compatibility/preview");
256
+ const profileLabels = new Map(previewResult.organizationDataTags.map((tag) => [
257
+ tag.profileId,
258
+ tag.displayName.trim() || tag.profileKey,
259
+ ]));
260
+ const details = [
261
+ `Changes:\n${formatEnvironmentChanges(input.changes, profileLabels)}`,
262
+ formatCompatibilityMessage(previewResult),
263
+ buildPreviewDetails(previewResult, profileLabels),
264
+ ]
265
+ .filter((detail) => Boolean(detail))
266
+ .join("\n\n");
267
+ return {
268
+ targets: ["app environment"],
269
+ summary: "Update this app's environment settings?",
270
+ details,
271
+ };
272
+ }
273
+ catch {
274
+ const changeSummary = input.changes
275
+ .map((c) => {
276
+ const parts = [`${MODE_LABELS[c.mode]} mode`];
277
+ if (c.addProfileIds?.length)
278
+ parts.push(`add ${formatTagCount(c.addProfileIds.length)}`);
279
+ if (c.removeProfileIds?.length)
280
+ parts.push(`remove ${formatTagCount(c.removeProfileIds.length)}`);
281
+ if (c.defaultProfileId)
282
+ parts.push("change the default data tag");
283
+ return parts.join(": ");
284
+ })
285
+ .join("; ");
286
+ return {
287
+ targets: ["app environment"],
288
+ summary: "Update this app's environment settings?",
289
+ details: "I couldn't check whether this change is compatible. It will be checked again before anything is saved.\n\n" +
290
+ changeSummary,
291
+ };
292
+ }
293
+ },
294
+ getRequiredPermissions: (input) => {
295
+ const profileIds = new Set();
296
+ for (const change of input.changes) {
297
+ if (change.addProfileIds) {
298
+ for (const id of change.addProfileIds)
299
+ profileIds.add(id);
300
+ }
301
+ if (change.removeProfileIds) {
302
+ for (const id of change.removeProfileIds)
303
+ profileIds.add(id);
304
+ }
305
+ if (change.defaultProfileId) {
306
+ profileIds.add(change.defaultProfileId);
307
+ }
308
+ }
309
+ return [...profileIds].sort().map((id) => ({
310
+ entityType: AiEntityType.PROFILE,
311
+ entityId: id,
312
+ permissionType: AiPermissionType.WRITE,
313
+ }));
314
+ },
315
+ getSummary: () => {
316
+ return { output: "environment updated successfully" };
317
+ },
318
+ }));
319
+ function formatTagCount(count) {
320
+ return `${count} data ${count === 1 ? "tag" : "tags"}`;
321
+ }
322
+ function formatEnvironmentChanges(changes, profileLabels) {
323
+ return changes
324
+ .map((change) => {
325
+ const operations = [];
326
+ if (change.addProfileIds?.length) {
327
+ operations.push(`- Add ${change.addProfileIds.map((id) => profileLabels.get(id) ?? id).join(", ")}`);
328
+ }
329
+ if (change.removeProfileIds?.length) {
330
+ operations.push(`- Remove ${change.removeProfileIds.map((id) => profileLabels.get(id) ?? id).join(", ")}`);
331
+ }
332
+ if (change.defaultProfileId) {
333
+ operations.push(`- Set ${profileLabels.get(change.defaultProfileId) ?? change.defaultProfileId} as the default`);
334
+ }
335
+ return `${MODE_LABELS[change.mode]} mode:\n${operations.join("\n")}`;
336
+ })
337
+ .join("\n");
338
+ }
339
+ function formatCompatibilityMessage(preview) {
340
+ if (preview.isBlocking) {
341
+ return "This change cannot be saved until the compatibility issue below is resolved.";
342
+ }
343
+ if (preview.needsAttention) {
344
+ return "You can save this change, but some integrations may need attention.";
345
+ }
346
+ return "This change is safe. Your app will continue to work with its current integrations and App Database.";
347
+ }
348
+ function buildPreviewDetails(preview, profileLabels) {
349
+ const lines = [];
350
+ if (preview.remediationActions.length > 0) {
351
+ const nextSteps = preview.remediationActions.map((action) => {
352
+ switch (action) {
353
+ case "change_app_environment":
354
+ return "change this app's environment settings";
355
+ case "configure_integration":
356
+ return "configure the affected integration";
357
+ case "connect_lifecycle_agent":
358
+ return "connect an App Database lifecycle agent";
359
+ case "request_environment_access":
360
+ return "ask an administrator for permission to change environments";
361
+ case "retry_later":
362
+ return "try again later";
363
+ }
364
+ });
365
+ lines.push(`Suggested next steps: ${nextSteps.join(", ")}`);
366
+ }
367
+ if (preview.integrations.length > 0) {
368
+ for (const integration of preview.integrations) {
369
+ const affectedTags = integration.tags.filter((t) => t.state !== "exact" && t.state !== "default_fallback");
370
+ if (affectedTags.length > 0) {
371
+ lines.push(`${integration.integrationName}: ` +
372
+ affectedTags
373
+ .map((t) => t.state === "temporarily_unavailable"
374
+ ? `${profileLabels.get(t.profileId) ?? t.profileKey} could not be checked right now`
375
+ : `${profileLabels.get(t.profileId) ?? t.profileKey} has no matching configuration`)
376
+ .join(", "));
377
+ }
378
+ }
379
+ }
380
+ if (preview.appDatabase.needsAttention) {
381
+ lines.push(preview.appDatabase.overallState === "temporarily_unavailable"
382
+ ? "The App Database could not be checked right now."
383
+ : "The App Database is not compatible with these settings.");
384
+ }
385
+ return lines.length > 0 ? lines.join("\n") : undefined;
386
+ }
387
+ //# sourceMappingURL=update-app-environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-app-environment.js","sourceRoot":"","sources":["../../../../../src/ai-service/agent/tools/app-environment/update-app-environment.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,gBAAgB,GACjB,MAAM,uCA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C,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,CAAC,KAAK,KAAK,kBAAkB,CACxD,CAAC;YACF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,KAAK,CAAC,IAAI,CACR,GAAG,WAAW,CAAC,eAAe,IAAI;oBAChC,YAAY;yBACT,GAAG,CAAC,CAAC,CAA8B,EAAE,EAAE,CACtC,CAAC,CAAC,KAAK,KAAK,yBAAyB;wBACnC,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,iCAAiC;wBACpF,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,gCAAgC,CACtF;yBACA,IAAI,CAAC,IAAI,CAAC,CAChB,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CACR,OAAO,CAAC,WAAW,CAAC,YAAY,KAAK,yBAAyB;YAC5D,CAAC,CAAC,kDAAkD;YACpD,CAAC,CAAC,yDAAyD,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copy for the authoring-mode permission card the user answers before Clark
3
+ * applies a migration that deletes something.
4
+ *
5
+ * Clark declares the deletion on the apply call by filling the fields below.
6
+ * That declaration is what makes the tool report a WRITE permission, which the
7
+ * registry turns into this card, and the same call is re-run once the user
8
+ * approves - so nothing is applied while the question is open, and Clark never
9
+ * has to fail, ask in chat, or call the tool a second time.
10
+ *
11
+ * The card used to say "These migrations include destructive schema changes
12
+ * listed in the previous apply error", which points at an error the person
13
+ * approving never saw and assumes they know what a schema change is. Builders
14
+ * are not all SQL readers, so the card answers the three questions a person
15
+ * needs before clicking Yes: what is being deleted, why, and what it costs.
16
+ *
17
+ * Clark writes the "what" and the "why", because Clark is the only party that
18
+ * has both the migration SQL and the conversation it came from. Deriving that
19
+ * prose here from the server's findings meant parsing SQL to guess at English,
20
+ * which was wrong on any statement the regexes did not anticipate and could
21
+ * not explain intent at all. The risk sentence stays fixed copy: it is the
22
+ * same every time and is not Clark's to soften.
23
+ */
24
+ /** The user-facing copy Clark writes for one destructive apply. */
25
+ export type DestructiveApplyCopy = {
26
+ /** What the migrations about to run will delete. */
27
+ details?: string;
28
+ /** Why the deletion is needed. */
29
+ reason?: string;
30
+ /** Short phrase completing "Ok if I ...", for the card's header. */
31
+ summary?: string;
32
+ };
33
+ /**
34
+ * Whether Clark is telling us this apply deletes something.
35
+ *
36
+ * This is what gates the apply behind a confirmation card, so it is
37
+ * deliberately generous: any of the three copy fields counts. Over-declaring
38
+ * costs an unnecessary card on an additive apply; under-declaring is caught by
39
+ * the server, which refuses an unacknowledged destructive apply outright.
40
+ *
41
+ * Cheap and side-effect free by contract - the tool registry calls this
42
+ * several times per execute while it works out whether to prompt.
43
+ */
44
+ export declare function declaresDestructiveChange(copy: DestructiveApplyCopy): boolean;
45
+ /**
46
+ * The question shown as the card's header, the body underneath it, and the
47
+ * fields the card ended up without.
48
+ *
49
+ * `missing` exists so the caller can log a card that fell back to generic
50
+ * wording. Without it, a prompt regression that stops Clark writing this copy
51
+ * would silently weaken every consent card, and nobody would find out.
52
+ */
53
+ export declare function buildDestructiveApplyPrompt(copy: DestructiveApplyCopy): {
54
+ details: string;
55
+ missing: string[];
56
+ summary: string;
57
+ };
58
+ //# sourceMappingURL=destructive-migration-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destructive-migration-prompt.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/agent/tools/databases/destructive-migration-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,mEAAmE;AACnE,MAAM,MAAM,oBAAoB,GAAG;IACjC,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAI7E;AAsND;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,oBAAoB,GAAG;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAyCA"}