@superblocksteam/vite-plugin-file-sync 2.0.140 → 2.0.141-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 (156) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +1 -0
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  3. package/dist/ai-service/agent/tools/apis/api-testing-state.d.ts +1 -0
  4. package/dist/ai-service/agent/tools/apis/api-testing-state.d.ts.map +1 -1
  5. package/dist/ai-service/agent/tools/apis/api-testing-state.js +16 -0
  6. package/dist/ai-service/agent/tools/apis/api-testing-state.js.map +1 -1
  7. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +1 -1
  8. package/dist/ai-service/agent/tools/apis/test-api.d.ts +1 -1
  9. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
  10. package/dist/ai-service/agent/tools/apis/test-api.js +13 -7
  11. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
  12. package/dist/ai-service/agent/tools/build-copy-directory.d.ts +1 -1
  13. package/dist/ai-service/agent/tools/build-copy-file.d.ts +1 -1
  14. package/dist/ai-service/agent/tools/build-copy-utils.d.ts +8 -8
  15. package/dist/ai-service/agent/tools/build-delete-file.d.ts +1 -1
  16. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
  17. package/dist/ai-service/agent/tools/build-finalize.js +1 -2
  18. package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
  19. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +4 -4
  20. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +4 -4
  21. package/dist/ai-service/agent/tools/get-logs.d.ts +3 -3
  22. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +9 -9
  23. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +2 -2
  24. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  25. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +93 -6
  26. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  27. package/dist/ai-service/agent/tools2/tools/git.d.ts +1 -1
  28. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +1 -1
  29. package/dist/ai-service/agent/tools2/tools/grep.d.ts +1 -1
  30. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts +1 -1
  31. package/dist/ai-service/app-interface/npm-package-lookup.d.ts +3 -2
  32. package/dist/ai-service/app-interface/npm-package-lookup.d.ts.map +1 -1
  33. package/dist/ai-service/app-interface/npm-package-lookup.js +21 -13
  34. package/dist/ai-service/app-interface/npm-package-lookup.js.map +1 -1
  35. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  36. package/dist/ai-service/app-interface/shell.js +119 -0
  37. package/dist/ai-service/app-interface/shell.js.map +1 -1
  38. package/dist/ai-service/checklist/api-migration-checklist-gate.js +1 -1
  39. package/dist/ai-service/checklist/api-migration-checklist-gate.js.map +1 -1
  40. package/dist/ai-service/features.d.ts +11 -0
  41. package/dist/ai-service/features.d.ts.map +1 -1
  42. package/dist/ai-service/features.js +24 -0
  43. package/dist/ai-service/features.js.map +1 -1
  44. package/dist/ai-service/index.d.ts +38 -4
  45. package/dist/ai-service/index.d.ts.map +1 -1
  46. package/dist/ai-service/index.js +210 -13
  47. package/dist/ai-service/index.js.map +1 -1
  48. package/dist/ai-service/llm/client.d.ts.map +1 -1
  49. package/dist/ai-service/llm/client.js +23 -0
  50. package/dist/ai-service/llm/client.js.map +1 -1
  51. package/dist/ai-service/llm/context-v2/context.d.ts +31 -2
  52. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
  53. package/dist/ai-service/llm/context-v2/context.js +81 -8
  54. package/dist/ai-service/llm/context-v2/context.js.map +1 -1
  55. package/dist/ai-service/llm/context-v2/turns.d.ts.map +1 -1
  56. package/dist/ai-service/llm/context-v2/turns.js +25 -1
  57. package/dist/ai-service/llm/context-v2/turns.js.map +1 -1
  58. package/dist/ai-service/llm/context-v2/types.d.ts +9 -0
  59. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
  60. package/dist/ai-service/llm/context-v2/types.js.map +1 -1
  61. package/dist/ai-service/llm/stream/config.d.ts +15 -0
  62. package/dist/ai-service/llm/stream/config.d.ts.map +1 -1
  63. package/dist/ai-service/llm/stream/config.js +9 -0
  64. package/dist/ai-service/llm/stream/config.js.map +1 -1
  65. package/dist/ai-service/llm/stream/errors.d.ts +1 -1
  66. package/dist/ai-service/llm/stream/errors.d.ts.map +1 -1
  67. package/dist/ai-service/llm/stream/errors.js.map +1 -1
  68. package/dist/ai-service/llm/stream/idle-monitor.d.ts +8 -0
  69. package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -1
  70. package/dist/ai-service/llm/stream/idle-monitor.js +51 -0
  71. package/dist/ai-service/llm/stream/idle-monitor.js.map +1 -1
  72. package/dist/ai-service/llm/stream/index.d.ts +1 -1
  73. package/dist/ai-service/llm/stream/index.d.ts.map +1 -1
  74. package/dist/ai-service/llm/stream/index.js.map +1 -1
  75. package/dist/ai-service/llm/stream/managed-stream.d.ts.map +1 -1
  76. package/dist/ai-service/llm/stream/managed-stream.js +2 -5
  77. package/dist/ai-service/llm/stream/managed-stream.js.map +1 -1
  78. package/dist/ai-service/llm/stream/orchestrator.d.ts +2 -0
  79. package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
  80. package/dist/ai-service/llm/stream/orchestrator.js +67 -3
  81. package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
  82. package/dist/ai-service/llm/stream/structured-output-chunk.d.ts +16 -0
  83. package/dist/ai-service/llm/stream/structured-output-chunk.d.ts.map +1 -0
  84. package/dist/ai-service/llm/stream/structured-output-chunk.js +26 -0
  85. package/dist/ai-service/llm/stream/structured-output-chunk.js.map +1 -0
  86. package/dist/ai-service/migration-auto-dispatch-readiness.d.ts +18 -0
  87. package/dist/ai-service/migration-auto-dispatch-readiness.d.ts.map +1 -0
  88. package/dist/ai-service/migration-auto-dispatch-readiness.js +17 -0
  89. package/dist/ai-service/migration-auto-dispatch-readiness.js.map +1 -0
  90. package/dist/ai-service/migration-autodispatch-metrics.d.ts +3 -0
  91. package/dist/ai-service/migration-autodispatch-metrics.d.ts.map +1 -0
  92. package/dist/ai-service/migration-autodispatch-metrics.js +51 -0
  93. package/dist/ai-service/migration-autodispatch-metrics.js.map +1 -0
  94. package/dist/ai-service/migration-llm-config.d.ts +12 -0
  95. package/dist/ai-service/migration-llm-config.d.ts.map +1 -0
  96. package/dist/ai-service/migration-llm-config.js +130 -0
  97. package/dist/ai-service/migration-llm-config.js.map +1 -0
  98. package/dist/ai-service/migration-session-active.d.ts +14 -0
  99. package/dist/ai-service/migration-session-active.d.ts.map +1 -0
  100. package/dist/ai-service/migration-session-active.js +29 -0
  101. package/dist/ai-service/migration-session-active.js.map +1 -0
  102. package/dist/ai-service/resolve-generation-state-for-ui.d.ts +8 -0
  103. package/dist/ai-service/resolve-generation-state-for-ui.d.ts.map +1 -0
  104. package/dist/ai-service/resolve-generation-state-for-ui.js +25 -0
  105. package/dist/ai-service/resolve-generation-state-for-ui.js.map +1 -0
  106. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts +1 -1
  107. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts.map +1 -1
  108. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js +5 -1
  109. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js.map +1 -1
  110. package/dist/ai-service/state-machine/helpers/peer.d.ts +19 -1
  111. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  112. package/dist/ai-service/state-machine/helpers/peer.js +81 -7
  113. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  114. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  115. package/dist/ai-service/state-machine/mocks.js +1 -0
  116. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  117. package/dist/ai-service/types.d.ts +6 -0
  118. package/dist/ai-service/types.d.ts.map +1 -1
  119. package/dist/ai-service/types.js.map +1 -1
  120. package/dist/ai-service/util/inference-jwt.d.ts +15 -0
  121. package/dist/ai-service/util/inference-jwt.d.ts.map +1 -0
  122. package/dist/ai-service/util/inference-jwt.js +56 -0
  123. package/dist/ai-service/util/inference-jwt.js.map +1 -0
  124. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  125. package/dist/file-sync-vite-plugin.js +3 -6
  126. package/dist/file-sync-vite-plugin.js.map +1 -1
  127. package/dist/file-system-helpers.d.ts +14 -0
  128. package/dist/file-system-helpers.d.ts.map +1 -1
  129. package/dist/file-system-helpers.js +30 -0
  130. package/dist/file-system-helpers.js.map +1 -1
  131. package/dist/migration/integration-write-policy.d.ts +12 -0
  132. package/dist/migration/integration-write-policy.d.ts.map +1 -0
  133. package/dist/migration/integration-write-policy.js +31 -0
  134. package/dist/migration/integration-write-policy.js.map +1 -0
  135. package/dist/migration/migration-metrics.d.ts +69 -0
  136. package/dist/migration/migration-metrics.d.ts.map +1 -0
  137. package/dist/migration/migration-metrics.js +98 -0
  138. package/dist/migration/migration-metrics.js.map +1 -0
  139. package/dist/migration/migration-routes.d.ts.map +1 -1
  140. package/dist/migration/migration-routes.js +53 -121
  141. package/dist/migration/migration-routes.js.map +1 -1
  142. package/dist/migration/migration-verification.d.ts +49 -7
  143. package/dist/migration/migration-verification.d.ts.map +1 -1
  144. package/dist/migration/migration-verification.js +92 -28
  145. package/dist/migration/migration-verification.js.map +1 -1
  146. package/dist/migration/restructure.d.ts +10 -4
  147. package/dist/migration/restructure.d.ts.map +1 -1
  148. package/dist/migration/restructure.js +3 -2
  149. package/dist/migration/restructure.js.map +1 -1
  150. package/dist/server-rpc/client.d.ts.map +1 -1
  151. package/dist/server-rpc/client.js +11 -2
  152. package/dist/server-rpc/client.js.map +1 -1
  153. package/dist/socket-manager.d.ts.map +1 -1
  154. package/dist/socket-manager.js +5 -0
  155. package/dist/socket-manager.js.map +1 -1
  156. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"file-system-helpers.js","sourceRoot":"","sources":["../src/file-system-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,CAAC,MAAM,iCAAiC,GAC5C,gCAAgC,CAAC;AACnC,MAAM,8BAA8B,GAAG,iBAAiB,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iDAAiD,GAC5D,wCAAwC,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,QAAgB;IAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,QAAgB;IACrE,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,QAAgB;IAChE,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;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K;IACL,MAAM;IACN,KAAK;CACG,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAY;IACpD,MAAM,cAAc,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,MAAM,IAAI,CACtB,CAAC,SAAS,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EACnD,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,CACtC,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,sCAAsC;IAIpD,MAAM,eAAe,GAAG,IAAI,uBAAuB,EAAE,CAAC;IACtD,OAAO;QACL,sEAAsE;QACtE,IAAI,EAAE;YACJ,GAAG,mCAAmC;YACtC,GAAG,qBAAqB;SACzB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,OAAO,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,GAAG,qBAAqB,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACvE,OAAO;YACP,MAAM,OAAO,EAAE;SAChB,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type IntegrationWritePolicy = "allow" | "deny";
2
+ export type ParseIntegrationWritePolicyResult = {
3
+ ok: true;
4
+ policy: Record<string, IntegrationWritePolicy> | undefined;
5
+ } | {
6
+ ok: false;
7
+ error: string;
8
+ };
9
+ export declare function parseIntegrationWritePolicy(input: unknown, options?: {
10
+ required?: boolean;
11
+ }): ParseIntegrationWritePolicyResult;
12
+ //# sourceMappingURL=integration-write-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-write-policy.d.ts","sourceRoot":"","sources":["../../src/migration/integration-write-policy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,MAAM,MAAM,iCAAiC,GACzC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,SAAS,CAAA;CAAE,GACxE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,iCAAiC,CAsCnC"}
@@ -0,0 +1,31 @@
1
+ const VALID_POLICIES = new Set(["allow", "deny"]);
2
+ export function parseIntegrationWritePolicy(input, options = {}) {
3
+ if (input === undefined || input === null) {
4
+ if (options.required) {
5
+ return { ok: false, error: "policy object required" };
6
+ }
7
+ return { ok: true, policy: undefined };
8
+ }
9
+ if (typeof input !== "object" || Array.isArray(input)) {
10
+ return { ok: false, error: "policy object required" };
11
+ }
12
+ const entries = Object.entries(input);
13
+ if (entries.length === 0) {
14
+ if (options.required) {
15
+ return { ok: false, error: "policy object required" };
16
+ }
17
+ return { ok: true, policy: undefined };
18
+ }
19
+ const invalidEntries = entries.filter(([, value]) => typeof value !== "string" || !VALID_POLICIES.has(value));
20
+ if (invalidEntries.length > 0) {
21
+ return {
22
+ ok: false,
23
+ error: `Invalid policy values for: ${invalidEntries.map(([key]) => key).join(", ")}. Allowed: allow, deny`,
24
+ };
25
+ }
26
+ return {
27
+ ok: true,
28
+ policy: Object.fromEntries(entries.map(([key, value]) => [key, value])),
29
+ };
30
+ }
31
+ //# sourceMappingURL=integration-write-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-write-policy.js","sourceRoot":"","sources":["../../src/migration/integration-write-policy.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAA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AAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB;SAC3G,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,OAAO,CAAC,GAAG,CACT,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAA+B,CAAU,CAClE,CACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Dev-server-side telemetry for the v2 -> v3 (Clark) migration.
3
+ *
4
+ * The server owns the lifecycle counters (attempted / completed / aborted). The
5
+ * dev server owns the *mechanical* migration that actually rewrites the app, so
6
+ * here we record:
7
+ *
8
+ * - per-stage outcomes of `/sb-migrate-to-fullstack` (backup, restructure,
9
+ * flip) and `/sb-migration-complete` finalization, and
10
+ * - per-API verification outcomes (passed / diverged / ...), which today only
11
+ * exist as a log line.
12
+ *
13
+ * Metrics use the OTel API directly (there is no dev-server `metricsClient`
14
+ * wrapper). A run span ties the mechanical stages together on one trace so
15
+ * per-stage latency and failures are attributable. Instruments are created
16
+ * lazily so telemetry init order never matters.
17
+ */
18
+ import { type Span } from "@opentelemetry/api";
19
+ import type { VerificationOutcome } from "./migration-verification.js";
20
+ /** Mechanical migration stages driven by the dev server. */
21
+ export type MigrationStage = "backup" | "complete" | "flip" | "restructure";
22
+ export type MigrationStageOutcome = "failure" | "success";
23
+ /**
24
+ * Verification outcome kinds emitted by `runMigrationVerification`. Derived
25
+ * from `VerificationOutcome["kind"]` (type-only import — erased at runtime,
26
+ * so no import cycle) rather than hand-mirrored, so adding an outcome kind
27
+ * can never silently desync the metric from the log.
28
+ */
29
+ export type MigrationVerificationKind = VerificationOutcome["kind"];
30
+ /**
31
+ * Pipeline side carried by the transient outcomes (`timeout` /
32
+ * `disconnected`). Derived from the outcome union for the same
33
+ * no-silent-desync reason as {@link MigrationVerificationKind}.
34
+ */
35
+ export type MigrationVerificationSide = Extract<VerificationOutcome, {
36
+ side: unknown;
37
+ }>["side"];
38
+ /** Records the outcome of one mechanical migration stage. */
39
+ export declare function recordMigrationStage(stage: MigrationStage, outcome: MigrationStageOutcome): void;
40
+ /**
41
+ * Records one per-API verification outcome. Takes the outcome itself (not
42
+ * just its kind) so sided outcomes can never lose `side` at the call site:
43
+ * a v2 timeout (stalled editor-client chain — user keeps the tab focused)
44
+ * and a v3 timeout (SDK/orchestrator stall — infra look) have different
45
+ * remediations, so oncall needs the split on the dashboard. Only `kind` and
46
+ * `side` become labels — everything else on an outcome (e.g. free-form
47
+ * `reason` strings) is unbounded and potentially sensitive, so it stays out.
48
+ */
49
+ export declare function recordMigrationVerification(outcome: {
50
+ kind: MigrationVerificationKind;
51
+ side?: MigrationVerificationSide;
52
+ }): void;
53
+ /**
54
+ * Starts the parent span for a `/sb-migrate-to-fullstack` run. The caller owns
55
+ * ending it (via {@link endMigrationRunSpan}) because the run may end by the
56
+ * process self-restarting after the flip.
57
+ */
58
+ export declare function startMigrationRunSpan(attributes: {
59
+ generation: number;
60
+ willSelfRestart: boolean;
61
+ }): Span;
62
+ /** Marks a stage boundary on the run span with its elapsed time. */
63
+ export declare function markMigrationRunStage(span: Span, stage: MigrationStage, outcome: MigrationStageOutcome): void;
64
+ /** Ends the run span, recording success or the failing stage. */
65
+ export declare function endMigrationRunSpan(span: Span, result: {
66
+ failedStage?: MigrationStage;
67
+ error?: unknown;
68
+ }): void;
69
+ //# sourceMappingURL=migration-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-metrics.d.ts","sourceRoot":"","sources":["../../src/migration/migration-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAGL,KAAK,IAAI,EAIV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAKvE,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,aAAa,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,mBAAmB,EACnB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAClB,CAAC,MAAM,CAAC,CAAC;AAyBV,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,IAAI,EAAE,yBAAyB,CAAC;IAChC,IAAI,CAAC,EAAE,yBAAyB,CAAC;CAClC,GAAG,IAAI,CAKP;AAMD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;CAC1B,GAAG,IAAI,CAOP;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,IAAI,CAiBN"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Dev-server-side telemetry for the v2 -> v3 (Clark) migration.
3
+ *
4
+ * The server owns the lifecycle counters (attempted / completed / aborted). The
5
+ * dev server owns the *mechanical* migration that actually rewrites the app, so
6
+ * here we record:
7
+ *
8
+ * - per-stage outcomes of `/sb-migrate-to-fullstack` (backup, restructure,
9
+ * flip) and `/sb-migration-complete` finalization, and
10
+ * - per-API verification outcomes (passed / diverged / ...), which today only
11
+ * exist as a log line.
12
+ *
13
+ * Metrics use the OTel API directly (there is no dev-server `metricsClient`
14
+ * wrapper). A run span ties the mechanical stages together on one trace so
15
+ * per-stage latency and failures are attributable. Instruments are created
16
+ * lazily so telemetry init order never matters.
17
+ */
18
+ import { metrics, SpanStatusCode, trace, } from "@opentelemetry/api";
19
+ const METER_NAME = "superblocks.dev-server.migration";
20
+ const TRACER_NAME = "superblocks.dev-server.migration";
21
+ let stageCounter;
22
+ let verificationCounter;
23
+ function getStageCounter() {
24
+ stageCounter ??= metrics
25
+ .getMeter(METER_NAME)
26
+ .createCounter("superblocks_dev_server.migration.stage", {
27
+ description: "Outcome of each mechanical migration stage (backup, restructure, flip, complete).",
28
+ });
29
+ return stageCounter;
30
+ }
31
+ function getVerificationCounter() {
32
+ verificationCounter ??= metrics
33
+ .getMeter(METER_NAME)
34
+ .createCounter("superblocks_dev_server.migration.verification", {
35
+ description: "Per-API migration verification outcomes by kind; transient kinds (timeout, disconnected) also carry the pipeline side (v2/v3).",
36
+ });
37
+ return verificationCounter;
38
+ }
39
+ /** Records the outcome of one mechanical migration stage. */
40
+ export function recordMigrationStage(stage, outcome) {
41
+ getStageCounter().add(1, { stage, outcome });
42
+ }
43
+ /**
44
+ * Records one per-API verification outcome. Takes the outcome itself (not
45
+ * just its kind) so sided outcomes can never lose `side` at the call site:
46
+ * a v2 timeout (stalled editor-client chain — user keeps the tab focused)
47
+ * and a v3 timeout (SDK/orchestrator stall — infra look) have different
48
+ * remediations, so oncall needs the split on the dashboard. Only `kind` and
49
+ * `side` become labels — everything else on an outcome (e.g. free-form
50
+ * `reason` strings) is unbounded and potentially sensitive, so it stays out.
51
+ */
52
+ export function recordMigrationVerification(outcome) {
53
+ getVerificationCounter().add(1, {
54
+ kind: outcome.kind,
55
+ ...(outcome.side !== undefined && { side: outcome.side }),
56
+ });
57
+ }
58
+ function getTracer() {
59
+ return trace.getTracer(TRACER_NAME);
60
+ }
61
+ /**
62
+ * Starts the parent span for a `/sb-migrate-to-fullstack` run. The caller owns
63
+ * ending it (via {@link endMigrationRunSpan}) because the run may end by the
64
+ * process self-restarting after the flip.
65
+ */
66
+ export function startMigrationRunSpan(attributes) {
67
+ return getTracer().startSpan("migration.dev_server.run", {
68
+ attributes: {
69
+ "migration.generation": attributes.generation,
70
+ "migration.will_self_restart": attributes.willSelfRestart,
71
+ },
72
+ });
73
+ }
74
+ /** Marks a stage boundary on the run span with its elapsed time. */
75
+ export function markMigrationRunStage(span, stage, outcome) {
76
+ span.addEvent(`migration.stage.${stage}`, { outcome });
77
+ }
78
+ /** Ends the run span, recording success or the failing stage. */
79
+ export function endMigrationRunSpan(span, result) {
80
+ if (result.failedStage) {
81
+ span.setAttribute("migration.failed_stage", result.failedStage);
82
+ // Record only the error *type*, never its message or stack: migration
83
+ // errors can carry payload fragments (tokens, signed URLs), and the full
84
+ // sanitized detail already goes to the logger. Datadog gets the class name.
85
+ if (result.error instanceof Error) {
86
+ span.setAttribute("migration.error_type", result.error.name);
87
+ }
88
+ span.setStatus({
89
+ code: SpanStatusCode.ERROR,
90
+ message: `migration failed at ${result.failedStage}`,
91
+ });
92
+ }
93
+ else {
94
+ span.setStatus({ code: SpanStatusCode.OK });
95
+ }
96
+ span.end();
97
+ }
98
+ //# sourceMappingURL=migration-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-metrics.js","sourceRoot":"","sources":["../../src/migration/migration-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,OAAO,EAEP,cAAc,EACd,KAAK,GAEN,MAAM,oBAAoB,CAAC;AAI5B,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AAyBvD,IAAI,YAAiC,CAAC;AACtC,IAAI,mBAAwC,CAAC;A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CAAC;IAC3C,qBAAqB,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAoBD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA8d7B,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAu9BN"}
@@ -5,13 +5,14 @@ import { parse as parseYaml } from "yaml";
5
5
  import { RESTART_EXIT_CODE, RESTART_SUPERVISED_ENV, } from "@superblocksteam/library-shared/restart-contract";
6
6
  import { LanguagePluginID } from "@superblocksteam/shared";
7
7
  import { getTelemetryInstance, isTelemetryInitialized, } from "@superblocksteam/telemetry";
8
- import { extractIntegrationIdsFromSource } from "../ai-service/agent/tools/apis/analysis.js";
9
8
  import { API_MIGRATION_ORIGINS, clearChecklist, clearChecklistItemsByOrigin, markChecklistCompleted, readPersistedChecklist, retryFailedSeedApiItemsFromChecklist, updateChecklistItem, } from "../ai-service/checklist/persisted-checklist-store.js";
10
9
  import { getErrorMeta } from "../util/logger.js";
11
10
  import { getFullstackTemplateDir } from "./get-fullstack-template-dir.js";
11
+ import { parseIntegrationWritePolicy } from "./integration-write-policy.js";
12
12
  import { classifyIntegrationMutations } from "./migration-classifier.js";
13
+ import { endMigrationRunSpan, markMigrationRunStage, recordMigrationStage, startMigrationRunSpan, } from "./migration-metrics.js";
13
14
  import { reconcileMigrationSessionOnBoot, rehydrateMigrationScratchOnBoot, } from "./migration-session-reconcile.js";
14
- import { analyzeV2BackupMutations, clearVerificationHistory, } from "./migration-verification.js";
15
+ import { clearVerificationHistory } from "./migration-verification.js";
15
16
  import { migrateToFullstack, restoreFromV2Backup } from "./restructure.js";
16
17
  import { detectUnsupportedIntegrations } from "./unsupported-integrations.js";
17
18
  import { forEachYamlStep } from "./yaml-walk.js";
@@ -180,7 +181,7 @@ async function extractIntegrationsFromYamls(yamlPaths) {
180
181
  .map(([id, steps]) => ({
181
182
  id,
182
183
  displayName: id,
183
- defaultPolicy: "ask",
184
+ defaultPolicy: "deny",
184
185
  mutationKind: classifyIntegrationMutations(steps),
185
186
  }));
186
187
  }
@@ -603,6 +604,14 @@ export function registerMigrationRoutes(server, options) {
603
604
  }));
604
605
  return;
605
606
  }
607
+ const parsedWritePolicy = parseIntegrationWritePolicy(body?.integrationWritePolicy);
608
+ if (!parsedWritePolicy.ok) {
609
+ res.statusCode = 400;
610
+ res.setHeader("Content-Type", "application/json");
611
+ res.end(JSON.stringify({ error: parsedWritePolicy.error }));
612
+ return;
613
+ }
614
+ const integrationWritePolicy = parsedWritePolicy.policy;
606
615
  if (!syncService) {
607
616
  res.statusCode = 503;
608
617
  res.end(JSON.stringify({
@@ -663,6 +672,12 @@ export function registerMigrationRoutes(server, options) {
663
672
  // Gates the actual `process.exit` below. Set only after a *successful*
664
673
  // flip so a thrown flip never triggers an in-place restart.
665
674
  let shouldSelfRestart = false;
675
+ const runSpan = startMigrationRunSpan({
676
+ generation: migrationGeneration,
677
+ willSelfRestart,
678
+ });
679
+ let runFailedStage;
680
+ let runError;
666
681
  inMemoryStatus = {
667
682
  state: "backup",
668
683
  startedAt: new Date().toISOString(),
@@ -678,12 +693,17 @@ export function registerMigrationRoutes(server, options) {
678
693
  if (!backupCommitId) {
679
694
  const msg = "Pre-migration backup did not produce a commitId; aborting.";
680
695
  logger.error("[migrate-route] " + msg);
696
+ recordMigrationStage("backup", "failure");
697
+ markMigrationRunStage(runSpan, "backup", "failure");
698
+ runFailedStage = "backup";
681
699
  inMemoryStatus = { state: "failed", error: msg };
682
700
  return;
683
701
  }
684
702
  logger.info("[migrate-route] Backup commit created", {
685
703
  backupCommitId,
686
704
  });
705
+ recordMigrationStage("backup", "success");
706
+ markMigrationRunStage(runSpan, "backup", "success");
687
707
  await persistMigrationStateMetadata(stateFilePath, {
688
708
  backupCommitId,
689
709
  startedAt: inMemoryStatus.startedAt,
@@ -703,12 +723,17 @@ export function registerMigrationRoutes(server, options) {
703
723
  appRootDirPath: appRootDir,
704
724
  templateSourceDirPath: getFullstackTemplateDir(),
705
725
  logger,
726
+ ...(integrationWritePolicy !== undefined && {
727
+ integrationWritePolicy,
728
+ }),
706
729
  });
707
730
  restructured = true;
708
731
  await persistMigrationStateMetadata(stateFilePath, {
709
732
  backupCommitId,
710
733
  });
711
734
  logger.info("[migrate-route] Local restructure complete");
735
+ recordMigrationStage("restructure", "success");
736
+ markMigrationRunStage(runSpan, "restructure", "success");
712
737
  inMemoryStatus = {
713
738
  state: "flip",
714
739
  backupCommitId,
@@ -738,6 +763,8 @@ export function registerMigrationRoutes(server, options) {
738
763
  logger.info("[migrate-route] Template flip complete", {
739
764
  migrationCommitId: flip.commitId,
740
765
  });
766
+ recordMigrationStage("flip", "success");
767
+ markMigrationRunStage(runSpan, "flip", "success");
741
768
  // After the flip, the SABS pod restarts and this process is
742
769
  // replaced. If by chance we survive, leave in-memory status at
743
770
  // `done` — the GET endpoint will derive `translating` /
@@ -751,24 +778,33 @@ export function registerMigrationRoutes(server, options) {
751
778
  }
752
779
  catch (error) {
753
780
  const errorMsg = error instanceof Error ? error.message : String(error);
781
+ const failedStage = restructured
782
+ ? "flip"
783
+ : backupCommitId
784
+ ? "restructure"
785
+ : "backup";
754
786
  logger.error("[migrate-route] Migration failed", getErrorMeta(error));
755
787
  logger.info("[migrate-route] Migration context", {
756
- stage: restructured
757
- ? "flip"
758
- : backupCommitId
759
- ? "restructure"
760
- : "backup",
788
+ stage: failedStage,
761
789
  backupCommitId,
762
790
  restructured,
763
791
  });
792
+ recordMigrationStage(failedStage, "failure");
793
+ markMigrationRunStage(runSpan, failedStage, "failure");
794
+ runFailedStage = failedStage;
795
+ runError = error;
764
796
  inMemoryStatus = {
765
797
  state: "failed",
766
- error: `Migration failed at ${restructured ? "flip" : backupCommitId ? "restructure" : "backup"} stage: ${errorMsg}`,
798
+ error: `Migration failed at ${failedStage} stage: ${errorMsg}`,
767
799
  backupCommitId,
768
800
  startedAt: inMemoryStatus.startedAt,
769
801
  };
770
802
  }
771
803
  finally {
804
+ endMigrationRunSpan(runSpan, {
805
+ failedStage: runFailedStage,
806
+ error: runError,
807
+ });
772
808
  if (!shouldSelfRestart) {
773
809
  if (autoSyncPaused) {
774
810
  try {
@@ -924,6 +960,7 @@ export function registerMigrationRoutes(server, options) {
924
960
  logger.info("[migrate-route] Completion checkpoint created", {
925
961
  completionCommitId: completionCommit.commitId,
926
962
  });
963
+ recordMigrationStage("complete", "success");
927
964
  inMemoryStatus = {
928
965
  state: "done",
929
966
  startedAt: status.startedAt,
@@ -952,6 +989,7 @@ export function registerMigrationRoutes(server, options) {
952
989
  status: updatedStatus,
953
990
  }));
954
991
  })().catch((error) => {
992
+ recordMigrationStage("complete", "failure");
955
993
  logger.error("[migrate-route] /sb-migration-complete failed", getErrorMeta(error));
956
994
  res.statusCode = 500;
957
995
  res.end(JSON.stringify({
@@ -974,26 +1012,13 @@ export function registerMigrationRoutes(server, options) {
974
1012
  }))
975
1013
  return;
976
1014
  const body = req.body;
977
- if (!body?.policy ||
978
- typeof body.policy !== "object" ||
979
- Array.isArray(body.policy)) {
980
- res.statusCode = 400;
981
- res.setHeader("Content-Type", "application/json");
982
- res.end(JSON.stringify({ error: "policy object required" }));
983
- return;
984
- }
985
- const VALID_POLICIES = new Set([
986
- "allow",
987
- "ask",
988
- "deny",
989
- ]);
990
- const invalidEntries = Object.entries(body.policy).filter(([, v]) => !VALID_POLICIES.has(v));
991
- if (invalidEntries.length > 0) {
1015
+ const parsedPolicy = parseIntegrationWritePolicy(body?.policy, {
1016
+ required: true,
1017
+ });
1018
+ if (!parsedPolicy.ok) {
992
1019
  res.statusCode = 400;
993
1020
  res.setHeader("Content-Type", "application/json");
994
- res.end(JSON.stringify({
995
- error: `Invalid policy values for: ${invalidEntries.map(([k]) => k).join(", ")}. Allowed: allow, ask, deny`,
996
- }));
1021
+ res.end(JSON.stringify({ error: parsedPolicy.error }));
997
1022
  return;
998
1023
  }
999
1024
  const scratchDirPath = join(appRootDir, SCRATCH_DIR_NAME);
@@ -1005,7 +1030,7 @@ export function registerMigrationRoutes(server, options) {
1005
1030
  catch {
1006
1031
  parsed = {};
1007
1032
  }
1008
- parsed.integrationWritePolicy = body.policy;
1033
+ parsed.integrationWritePolicy = parsedPolicy.policy;
1009
1034
  await mkdir(scratchDirPath, { recursive: true });
1010
1035
  await writeFile(stateFilePath, JSON.stringify(parsed, null, 2) + "\n", "utf-8");
1011
1036
  const status = await resolveStatus(appRootDir);
@@ -1072,99 +1097,6 @@ export function registerMigrationRoutes(server, options) {
1072
1097
  }));
1073
1098
  });
1074
1099
  });
1075
- // --- POST /sb-migration-allow-and-retry-api ----------------------------
1076
- // Sets every integration referenced by the named API to "allow" in the
1077
- // write policy, then flips the checklist item back to "pending" so Clark
1078
- // will re-run the verification tool on its next pass.
1079
- server.middlewares.use("/sb-migration-allow-and-retry-api", bodyParser.json({ strict: true }));
1080
- server.middlewares.use("/sb-migration-allow-and-retry-api", (req, res, next) => {
1081
- void (async () => {
1082
- if (!getIsInitialized())
1083
- return next();
1084
- if (!setupCorsAndValidateMethod({
1085
- req,
1086
- res,
1087
- allowedMethod: "POST",
1088
- allowHeaders: "Content-Type",
1089
- }))
1090
- return;
1091
- const body = req.body;
1092
- const apiName = body?.apiName;
1093
- if (typeof apiName !== "string" || !/^[a-zA-Z0-9_-]+$/.test(apiName)) {
1094
- res.statusCode = 400;
1095
- res.setHeader("Content-Type", "application/json");
1096
- res.end(JSON.stringify({
1097
- error: "apiName must be a non-empty string containing only letters, digits, hyphens, or underscores",
1098
- }));
1099
- return;
1100
- }
1101
- // Read the source file to discover which integration UUIDs are referenced.
1102
- const sourcePath = join(appRootDir, "server", "apis", apiName, "api.ts");
1103
- let source;
1104
- try {
1105
- source = await readFile(sourcePath, "utf-8");
1106
- }
1107
- catch {
1108
- res.statusCode = 404;
1109
- res.setHeader("Content-Type", "application/json");
1110
- res.end(JSON.stringify({ error: `Source not found: ${sourcePath}` }));
1111
- return;
1112
- }
1113
- // Update the write policy: set any referenced integration to "allow".
1114
- const stateFilePath = join(appRootDir, SCRATCH_DIR_NAME, MIGRATION_STATE_FILE);
1115
- let parsed;
1116
- try {
1117
- parsed = JSON.parse(await readFile(stateFilePath, "utf-8"));
1118
- }
1119
- catch {
1120
- parsed = {};
1121
- }
1122
- const existingPolicy = parsed.integrationWritePolicy !== null &&
1123
- typeof parsed.integrationWritePolicy === "object" &&
1124
- !Array.isArray(parsed.integrationWritePolicy)
1125
- ? parsed.integrationWritePolicy
1126
- : {};
1127
- // Allow every integration the verifier will gate on. That's the
1128
- // *union* of v3-source IDs and v2-backup IDs — `runMigrationVerification`
1129
- // unions the two, so allowing only v3-source IDs here would leave a
1130
- // v2-only integration sitting at "ask", and `mostRestrictivePolicy`
1131
- // would keep returning `skipped_mutation` on retry, trapping the user
1132
- // in an unresolvable loop.
1133
- const v2BackupPath = join(appRootDir, SCRATCH_DIR_NAME, "v2-backup", "apis", apiName, "api.yaml");
1134
- const v2Analysis = await analyzeV2BackupMutations(v2BackupPath);
1135
- const updatedPolicy = { ...existingPolicy };
1136
- const allowSet = new Set([
1137
- ...extractIntegrationIdsFromSource(source),
1138
- ...v2Analysis.integrationIds,
1139
- ]);
1140
- for (const id of allowSet) {
1141
- updatedPolicy[id] = "allow";
1142
- }
1143
- parsed.integrationWritePolicy = updatedPolicy;
1144
- await writeFile(stateFilePath, JSON.stringify(parsed, null, 2) + "\n", "utf-8");
1145
- // Flip the checklist item back to pending so Clark will re-verify.
1146
- // Clear stale verification fields so classifyItem can't misclassify
1147
- // if the item transitions to completed via an unexpected path.
1148
- await updateChecklistItem({
1149
- appRootDirPath: appRootDir,
1150
- itemId: `api_${apiName}`,
1151
- status: "pending",
1152
- verificationOutcome: null,
1153
- verificationSkippedReason: null,
1154
- lastVerificationAt: new Date().toISOString(),
1155
- });
1156
- const status = await resolveStatus(appRootDir);
1157
- res.statusCode = 200;
1158
- res.setHeader("Content-Type", "application/json");
1159
- res.end(JSON.stringify({ ok: true, status }));
1160
- })().catch((error) => {
1161
- logger.error("[migrate-route] /sb-migration-allow-and-retry-api failed", getErrorMeta(error));
1162
- res.statusCode = 500;
1163
- res.end(JSON.stringify({
1164
- error: error instanceof Error ? error.message : String(error),
1165
- }));
1166
- });
1167
- });
1168
1100
  // --- POST /sb-migration-retry-api ----------------------------------------
1169
1101
  // Flips a single checklist item back to pending so Clark will re-run
1170
1102
  // verification on its next pass, without changing the integration write