@superblocksteam/vite-plugin-file-sync 2.0.86 → 2.0.87-next.1

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 (195) hide show
  1. package/dist/ai-service/agent/middleware.d.ts +1 -1
  2. package/dist/ai-service/agent/middleware.js +2 -2
  3. package/dist/ai-service/agent/middleware.js.map +1 -1
  4. package/dist/ai-service/agent/prompts/api-prompts.d.ts +33 -0
  5. package/dist/ai-service/agent/prompts/api-prompts.d.ts.map +1 -0
  6. package/dist/ai-service/agent/prompts/api-prompts.js +446 -0
  7. package/dist/ai-service/agent/prompts/api-prompts.js.map +1 -0
  8. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  9. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +16 -154
  10. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  11. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  12. package/dist/ai-service/agent/tool-message-utils.js +13 -2
  13. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  14. package/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -1
  15. package/dist/ai-service/agent/tools/apis/analysis.js +159 -15
  16. package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -1
  17. package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -1
  18. package/dist/ai-service/agent/tools/apis/api-executor.js +13 -1
  19. package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -1
  20. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +12 -0
  21. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts.map +1 -1
  22. package/dist/ai-service/agent/tools/apis/get-api-docs.js +3 -3
  23. package/dist/ai-service/agent/tools/apis/get-api-docs.js.map +1 -1
  24. package/dist/ai-service/agent/tools/apis/get-integration-types.d.ts +12 -0
  25. package/dist/ai-service/agent/tools/apis/get-integration-types.d.ts.map +1 -0
  26. package/dist/ai-service/agent/tools/apis/get-integration-types.js +76 -0
  27. package/dist/ai-service/agent/tools/apis/get-integration-types.js.map +1 -0
  28. package/dist/ai-service/agent/tools/apis/integration-types.js +4 -4
  29. package/dist/ai-service/agent/tools/apis/integration-types.js.map +1 -1
  30. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
  31. package/dist/ai-service/agent/tools/apis/test-api.js +5 -4
  32. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
  33. package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -1
  34. package/dist/ai-service/agent/tools/build-capture-screenshot.js +23 -0
  35. package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -1
  36. package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -1
  37. package/dist/ai-service/agent/tools/build-debug.js +13 -1
  38. package/dist/ai-service/agent/tools/build-debug.js.map +1 -1
  39. package/dist/ai-service/agent/tools/index.d.ts +1 -0
  40. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  41. package/dist/ai-service/agent/tools/index.js +1 -0
  42. package/dist/ai-service/agent/tools/index.js.map +1 -1
  43. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  44. package/dist/ai-service/agent/tools/integrations/execute-request.js +14 -1
  45. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  46. package/dist/ai-service/agent/tools/integrations/internal.d.ts +1 -0
  47. package/dist/ai-service/agent/tools/integrations/internal.d.ts.map +1 -1
  48. package/dist/ai-service/agent/tools/integrations/internal.js +9 -4
  49. package/dist/ai-service/agent/tools/integrations/internal.js.map +1 -1
  50. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  51. package/dist/ai-service/agent/tools.js +19 -9
  52. package/dist/ai-service/agent/tools.js.map +1 -1
  53. package/dist/ai-service/agent/tools2/tools/web-fetch.d.ts.map +1 -1
  54. package/dist/ai-service/agent/tools2/tools/web-fetch.js +7 -1
  55. package/dist/ai-service/agent/tools2/tools/web-fetch.js.map +1 -1
  56. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  57. package/dist/ai-service/agent/utils.js +11 -0
  58. package/dist/ai-service/agent/utils.js.map +1 -1
  59. package/dist/ai-service/app-interface/filesystem/index.d.ts +4 -1
  60. package/dist/ai-service/app-interface/filesystem/index.d.ts.map +1 -1
  61. package/dist/ai-service/app-interface/filesystem/index.js +3 -1
  62. package/dist/ai-service/app-interface/filesystem/index.js.map +1 -1
  63. package/dist/ai-service/app-interface/filesystem/path-validator.d.ts +43 -0
  64. package/dist/ai-service/app-interface/filesystem/path-validator.d.ts.map +1 -0
  65. package/dist/ai-service/app-interface/filesystem/path-validator.js +9 -0
  66. package/dist/ai-service/app-interface/filesystem/path-validator.js.map +1 -0
  67. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.d.ts +50 -0
  68. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.d.ts.map +1 -0
  69. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.js +68 -0
  70. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.js.map +1 -0
  71. package/dist/ai-service/app-interface/filesystem/validation.d.ts +25 -8
  72. package/dist/ai-service/app-interface/filesystem/validation.d.ts.map +1 -1
  73. package/dist/ai-service/app-interface/filesystem/validation.js +52 -28
  74. package/dist/ai-service/app-interface/filesystem/validation.js.map +1 -1
  75. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +1 -0
  76. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -1
  77. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +4 -1
  78. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -1
  79. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.d.ts +49 -0
  80. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.d.ts.map +1 -0
  81. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.js +67 -0
  82. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.js.map +1 -0
  83. package/dist/ai-service/app-interface/shell.d.ts +5 -2
  84. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  85. package/dist/ai-service/app-interface/shell.js +11 -6
  86. package/dist/ai-service/app-interface/shell.js.map +1 -1
  87. package/dist/ai-service/chat/chat-session-store.js +3 -3
  88. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  89. package/dist/ai-service/clark-provider/clark-provider.d.ts +1 -0
  90. package/dist/ai-service/clark-provider/clark-provider.d.ts.map +1 -1
  91. package/dist/ai-service/clark-provider/clark-provider.js +6 -1
  92. package/dist/ai-service/clark-provider/clark-provider.js.map +1 -1
  93. package/dist/ai-service/features.d.ts +4 -0
  94. package/dist/ai-service/features.d.ts.map +1 -1
  95. package/dist/ai-service/features.js +4 -0
  96. package/dist/ai-service/features.js.map +1 -1
  97. package/dist/ai-service/index.d.ts +21 -0
  98. package/dist/ai-service/index.d.ts.map +1 -1
  99. package/dist/ai-service/index.js +119 -10
  100. package/dist/ai-service/index.js.map +1 -1
  101. package/dist/ai-service/judge/judge-eval-service-runner.d.ts.map +1 -1
  102. package/dist/ai-service/judge/judge-eval-service-runner.js +2 -0
  103. package/dist/ai-service/judge/judge-eval-service-runner.js.map +1 -1
  104. package/dist/ai-service/llm/client.js +2 -2
  105. package/dist/ai-service/llm/client.js.map +1 -1
  106. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
  107. package/dist/ai-service/llm/context-v2/context.js +4 -4
  108. package/dist/ai-service/llm/context-v2/context.js.map +1 -1
  109. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts.map +1 -1
  110. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js +11 -2
  111. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js.map +1 -1
  112. package/dist/ai-service/llm/context-v2/prompts/compaction.d.ts +1 -1
  113. package/dist/ai-service/llm/context-v2/prompts/compaction.d.ts.map +1 -1
  114. package/dist/ai-service/llm/context-v2/prompts/compaction.js +15 -6
  115. package/dist/ai-service/llm/context-v2/prompts/compaction.js.map +1 -1
  116. package/dist/ai-service/llm/context-v2/types.d.ts +4 -9
  117. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
  118. package/dist/ai-service/llm/context-v2/types.js +15 -45
  119. package/dist/ai-service/llm/context-v2/types.js.map +1 -1
  120. package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -1
  121. package/dist/ai-service/llm/stream/observers/logging.js +2 -4
  122. package/dist/ai-service/llm/stream/observers/logging.js.map +1 -1
  123. package/dist/ai-service/llm/stream/retry-engine.d.ts +4 -0
  124. package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
  125. package/dist/ai-service/llm/stream/retry-engine.js +24 -1
  126. package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
  127. package/dist/ai-service/llm/types.d.ts +4 -1
  128. package/dist/ai-service/llm/types.d.ts.map +1 -1
  129. package/dist/ai-service/security/index.d.ts +2 -1
  130. package/dist/ai-service/security/index.d.ts.map +1 -1
  131. package/dist/ai-service/security/index.js +2 -1
  132. package/dist/ai-service/security/index.js.map +1 -1
  133. package/dist/ai-service/security/secret-scanner-service.d.ts +52 -0
  134. package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -0
  135. package/dist/ai-service/security/secret-scanner-service.js +290 -0
  136. package/dist/ai-service/security/secret-scanner-service.js.map +1 -0
  137. package/dist/ai-service/security/secret-scanner.d.ts +8 -15
  138. package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
  139. package/dist/ai-service/security/secret-scanner.js +1 -50
  140. package/dist/ai-service/security/secret-scanner.js.map +1 -1
  141. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.d.ts +1 -1
  142. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.d.ts.map +1 -1
  143. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.js +28 -21
  144. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.js.map +1 -1
  145. package/dist/ai-service/skills/system/superblocks-api/skill.generated.d.ts +1 -1
  146. package/dist/ai-service/skills/system/superblocks-api/skill.generated.d.ts.map +1 -1
  147. package/dist/ai-service/skills/system/superblocks-api/skill.generated.js +286 -116
  148. package/dist/ai-service/skills/system/superblocks-api/skill.generated.js.map +1 -1
  149. package/dist/ai-service/state-machine/clark-fsm.d.ts +7 -0
  150. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  151. package/dist/ai-service/state-machine/clark-fsm.js +1 -5
  152. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  153. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  154. package/dist/ai-service/state-machine/handlers/agent-planning.js +14 -12
  155. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  156. package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
  157. package/dist/ai-service/state-machine/handlers/idle.js +18 -10
  158. package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
  159. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  160. package/dist/ai-service/state-machine/handlers/llm-generating.js +53 -12
  161. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  162. package/dist/ai-service/state-machine/helpers/peer.d.ts +5 -0
  163. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  164. package/dist/ai-service/state-machine/helpers/peer.js +19 -0
  165. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  166. package/dist/ai-service/template-renderer.d.ts +2 -1
  167. package/dist/ai-service/template-renderer.d.ts.map +1 -1
  168. package/dist/ai-service/template-renderer.js +28 -3
  169. package/dist/ai-service/template-renderer.js.map +1 -1
  170. package/dist/ai-service/types.d.ts +2 -0
  171. package/dist/ai-service/types.d.ts.map +1 -1
  172. package/dist/ai-service/types.js.map +1 -1
  173. package/dist/lock-service/activity-tracker.d.ts +5 -0
  174. package/dist/lock-service/activity-tracker.d.ts.map +1 -1
  175. package/dist/lock-service/activity-tracker.js +13 -0
  176. package/dist/lock-service/activity-tracker.js.map +1 -1
  177. package/dist/lock-service/index.d.ts +8 -0
  178. package/dist/lock-service/index.d.ts.map +1 -1
  179. package/dist/lock-service/index.js +54 -0
  180. package/dist/lock-service/index.js.map +1 -1
  181. package/dist/socket-manager.d.ts.map +1 -1
  182. package/dist/socket-manager.js +9 -0
  183. package/dist/socket-manager.js.map +1 -1
  184. package/dist/sync-service/index.d.ts.map +1 -1
  185. package/dist/sync-service/index.js +40 -7
  186. package/dist/sync-service/index.js.map +1 -1
  187. package/dist/util/log-sanitizer.d.ts +1 -0
  188. package/dist/util/log-sanitizer.d.ts.map +1 -1
  189. package/dist/util/log-sanitizer.js +8 -0
  190. package/dist/util/log-sanitizer.js.map +1 -1
  191. package/dist/vite-plugin-yaml-types.d.ts +6 -2
  192. package/dist/vite-plugin-yaml-types.d.ts.map +1 -1
  193. package/dist/vite-plugin-yaml-types.js +82 -8
  194. package/dist/vite-plugin-yaml-types.js.map +1 -1
  195. package/package.json +22 -11
@@ -22,7 +22,7 @@ export declare function outputLimiter(maxChars?: number): ToolMiddleware;
22
22
  *
23
23
  * @param options - Configuration options
24
24
  * @param options.enabled - Whether secret scanning is enabled (default: true)
25
- * @param options.timeout - Timeout for secret scanning in ms (default: 5000)
25
+ * @param options.timeout - Timeout for secret scanning in ms (default: scanner's DEFAULT_SCAN_TIMEOUT_MS)
26
26
  */
27
27
  export declare function secretScanningMiddleware(options?: {
28
28
  enabled?: boolean;
@@ -75,10 +75,10 @@ const TOOL_LOG_SUMMARY_NAMES = {
75
75
  *
76
76
  * @param options - Configuration options
77
77
  * @param options.enabled - Whether secret scanning is enabled (default: true)
78
- * @param options.timeout - Timeout for secret scanning in ms (default: 5000)
78
+ * @param options.timeout - Timeout for secret scanning in ms (default: scanner's DEFAULT_SCAN_TIMEOUT_MS)
79
79
  */
80
80
  export function secretScanningMiddleware(options) {
81
- const { enabled = true, timeout = 5000 } = options ?? {};
81
+ const { enabled = true, timeout } = options ?? {};
82
82
  return (tool) => {
83
83
  // If disabled globally, return the tool unmodified
84
84
  if (!enabled) {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/ai-service/agent/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sCAAsC,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD,yGAAyG;AACzG,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAC3B,WAAmB,wBAAwB;IAE3C,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,OAAO;YACL,GAAG,IAAI;YACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAElD,mEAAmE;gBACnE,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;oBACzD,OAAO,MAAM,CAAC;gBAChB,CAAC;gBAED,0BAA0B;gBAC1B,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;gBAC/C,I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
@@ -0,0 +1,33 @@
1
+ /**
2
+ * API prompt sections for YAML and SDK experiences.
3
+ *
4
+ * These functions generate the appropriate API documentation sections
5
+ * based on whether the SDK API feature flag is enabled.
6
+ */
7
+ /**
8
+ * YAML-based API prompt section (legacy experience).
9
+ *
10
+ * Uses:
11
+ * - useApi from @superblocksteam/library
12
+ * - APIs in apis/ApiName/api.yaml
13
+ * - getApiDocs tool is mandatory before API work
14
+ */
15
+ export declare function buildYamlApiSection(): string;
16
+ /**
17
+ * SDK-based API prompt section (new experience).
18
+ *
19
+ * Uses:
20
+ * - useApi from @/hooks/useApi.js
21
+ * - APIs in server/apis/ApiName/api.ts
22
+ * - SDK READMEs for documentation
23
+ * - Zod schemas and integration IDs
24
+ */
25
+ export declare function buildSdkApiSection(): string;
26
+ /**
27
+ * Tool guidance that differs by experience.
28
+ *
29
+ * @param sdkEnabled - Whether the SDK API experience is enabled
30
+ * @returns Tool call guidance section content
31
+ */
32
+ export declare function buildApiToolGuidance(sdkEnabled: boolean): string;
33
+ //# sourceMappingURL=api-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-prompts.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/prompts/api-prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAyJ5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CA+O3C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,CAsBhE"}
@@ -0,0 +1,446 @@
1
+ /**
2
+ * API prompt sections for YAML and SDK experiences.
3
+ *
4
+ * These functions generate the appropriate API documentation sections
5
+ * based on whether the SDK API feature flag is enabled.
6
+ */
7
+ /**
8
+ * YAML-based API prompt section (legacy experience).
9
+ *
10
+ * Uses:
11
+ * - useApi from @superblocksteam/library
12
+ * - APIs in apis/ApiName/api.yaml
13
+ * - getApiDocs tool is mandatory before API work
14
+ */
15
+ export function buildYamlApiSection() {
16
+ return `<apis>
17
+ ## Using APIs - The ONLY Superblocks-Specific Feature
18
+
19
+ **🚨 MANDATORY: Call \`getApiDocs\` before explaining API syntax, bindings, or showing example code.** Superblocks syntax differs from public documentation - do NOT rely on general knowledge.
20
+
21
+ <integrations_and_data_sources>
22
+ **CRITICAL: Always prefer integrations and data sources already in use in the current application.**
23
+
24
+ Before creating APIs with new integrations:
25
+ - Check which integrations are already used in existing APIs
26
+ - Prefer the most frequently used integration. If multiple integrations are equally common, use the askMultiChoice tool to let the user choose rather than guessing.
27
+ - Only introduce new integrations if existing ones cannot fulfill the requirement
28
+ </integrations_and_data_sources>
29
+
30
+ <creating_and_editing_apis>
31
+ **CRITICAL: Only modify APIs when explicitly requested by the user.**
32
+
33
+ Rules for API modification:
34
+ - If the user tags/mentions an API but says "don't change the API" or "without modifying the API", don't change it
35
+ - If the user tags an API for context/reference only, do not modify it
36
+ - Only delegate to the API tool when the user explicitly requests API creation or modification
37
+ - When the user does request changes to multiple APIs, parallelize the tool calls to optimize the process
38
+
39
+ Examples of when NOT to modify APIs:
40
+ - "The getUsersApi returns this data [tagged API] but don't change it"
41
+ - "Using the existing searchApi [tagged], update the UI to show results"
42
+ - "The API is working fine, just fix the display"
43
+
44
+ Examples of when TO modify APIs:
45
+ - "Update the getUsersApi to include email addresses"
46
+ - "Create a new API to fetch products"
47
+ - "Change the searchApi to filter by category"
48
+ </creating_and_editing_apis>
49
+
50
+ <api_failure_handling>
51
+ **CRITICAL: When APIs fail, timeout, or error - stop everything and ask the user first.**
52
+
53
+ If an API you created or are testing encounters issues (connection failure, timeout, error response, wrong data, connection refused):
54
+
55
+ **Do not:**
56
+ - Create any UI pages, components, or anything else
57
+ - Switch to a different integration than the one the user requested
58
+
59
+ Instead, you must explain what failed and why and use askMultiChoice to present options.
60
+ A working API is a prerequisite for building UI. The user specified the integration for a reason.
61
+ </api_failure_handling>
62
+
63
+ <permissions>
64
+ If the user requests checking user data, like email, ID, this information cannot be passed from the frontend because it is UNSAFE and can result in security vulnerabilities.
65
+
66
+ You must NEVER attempt to rely on frontend data for security-critical operations, rely on the injected \`Global\` object in APIs instead.
67
+ </permissions>
68
+
69
+ APIs MUST be loaded using \`useApi\` with the exact API name based on its folder. The interface for \`useApi\` is:
70
+ \`\`\`typescript
71
+ interface useApi<Name, Input, Response> {
72
+ (apiName: Name): {
73
+ run: (params: Input) => Promise<Response | undefined>;
74
+ cancel: () => Promise<void>;
75
+ }
76
+ }
77
+ \`\`\`
78
+
79
+ The Name, Input, and Response generics are supplied for you, you do not need to write them yourself. Your API call from the client side should conform to the inferred interfaces.
80
+
81
+ **CRITICAL: When a user says that an API is not working or has an error, ALWAYS check the API call sites in the application and ensure the inputs are correct! DO NOT assume the API itself is broken, it is important to verify the frontend code first!**
82
+
83
+ \`\`\`typescript
84
+ // in pages/MyPage/use-get-users.ts
85
+ import { useApi } from "@superblocksteam/library";
86
+ import { useState, useCallback } from "react";
87
+ import { toast } from "sonner";
88
+
89
+ export default function useGetUsers({ email, name }: { email: string | undefined, name: string | undefined }) {
90
+ const { run } = useApi("GetUsers"); // in folder apis/GetUsers/api.yaml
91
+ const [loading, setLoading] = useState(false);
92
+ const [users, setUsers] = useState<{ id: string; email: string; name: string }[]>([]);
93
+
94
+ const fetchUsers = useCallback(async () => {
95
+ setLoading(true);
96
+ try {
97
+ // ALWAYS include ALL inputs, even if they are empty
98
+ const response = await run({ email: email ? email : null, name: name ? name : null });
99
+ setUsers(response.users);
100
+ } catch (error) {
101
+ console.error(error);
102
+ toast.error("Error fetching users: " + (error as Error).message);
103
+ } finally {
104
+ setLoading(false);
105
+ }
106
+ }, [email, name, run]);
107
+ return { fetchUsers, loading, users };
108
+ }
109
+ \`\`\`
110
+
111
+ ### Critical Rules
112
+
113
+ 1. **MUST call API by the exact name**: Format is \`<ApiName>\` in folder apis/<ApiName>/api.yaml
114
+ 2. **Always pass parameters to the function**: \`await api({ param1: value1, param2: value2 })\`
115
+ 3. **Store response in React state**: You should use React state primitives (useState, useReducer, etc.) to store the response.
116
+ 4. **Use async/await pattern**: APIs are async functions
117
+ 5. **Use loading states and visual feedback**: You should always strive to track loading and error states for each API call.
118
+ 6. **ALWAYS check API input/output interfaces**: NEVER guess the response structure - use the actual interface defined by the API
119
+ 7. **ALWAYS include all parameters in the function call**: NEVER omit parameters the API expects, even if they are optional, they should be included and passed as null
120
+ 8. **ALWAYS include error handling**: NEVER omit error handling, you should always handle errors and show a message to the user if the API call fails.
121
+ 9. **ALWAYS Prevent hot module reload loops**: When calling an API from \`useEffect\`, guard the first run so it does not re-trigger on hot module reloads.
122
+
123
+ \`\`\`tsx
124
+ const hasLoadedRef = useRef(false);
125
+ useEffect(() => {
126
+ if (hasLoadedRef.current) return;
127
+ hasLoadedRef.current = true;
128
+ fetchData();
129
+ }, []);
130
+ \`\`\`
131
+
132
+ ### File Handling
133
+
134
+ **CRITICAL: Files must be wrapped in \`{ files: [...] }\` format.**
135
+
136
+ \`\`\`tsx
137
+ // ✅ CORRECT - Frontend: wrap files in { files: [...] }
138
+ const response = await runUploadApi({ userFile: { files: selectedFiles } });
139
+
140
+ // ❌ WRONG - backend cannot process unwrapped files
141
+ const response = await runUploadApi({ userFile: selectedFiles });
142
+ \`\`\`
143
+
144
+ \`\`\`typescript
145
+ // ✅ Backend API: access via .files property
146
+ const file = inputs.userFile.files[0];
147
+ // Available: file.name, file.size, file.type, file.extension
148
+ \`\`\`
149
+
150
+ ### Efficient-Friendly Patterns
151
+
152
+ Efficiency is key when building applications for production. You should always be thinking about patterns that will help you build efficient applications
153
+ when it comes to loading data from APIs.
154
+
155
+ Here are some examples (not exhaustive) that you should consider when building applications:
156
+ 1. **Default to Smart Loading**: Always check for existing data before showing loading states
157
+ 2. **Loading State Hierarchy**:
158
+ - Empty state → Full loading
159
+ - Has data → Keep showing data during refetch
160
+ - Error state → Show error with retry option, optionally keep stale data in background in case of retry
161
+ 3. **Debounce Rapid Requests**: Prevent multiple API calls in short succession
162
+ 4. **Use hooks to encapsulate API logic**: Use hooks to encapsulate API logic and avoid repeating the same code in multiple places.
163
+
164
+ ### Interpreting testApi Results
165
+
166
+ **CRITICAL**: \`success: false\` or missing = FAILURE. Never show success toast. Even when \`success: true\`, verify the output data is valid before confirming success to the user.
167
+ </apis>`;
168
+ }
169
+ /**
170
+ * SDK-based API prompt section (new experience).
171
+ *
172
+ * Uses:
173
+ * - useApi from @/hooks/useApi.js
174
+ * - APIs in server/apis/ApiName/api.ts
175
+ * - SDK READMEs for documentation
176
+ * - Zod schemas and integration IDs
177
+ */
178
+ export function buildSdkApiSection() {
179
+ return `<apis>
180
+ ## Using APIs - The ONLY Superblocks-Specific Feature
181
+ <sdk>
182
+ The API SDK is available via the installed \`@superblocksteam/sdk-api\` package.
183
+
184
+ **MANDATORY: Read READMEs Before Writing APIs**
185
+
186
+ Before writing ANY API, you MUST:
187
+ 1. **Read the root SDK README**: \`node_modules/@superblocksteam/sdk-api/README.md\`
188
+ - Contains comprehensive documentation, API reference, error handling guidance, and examples
189
+ - This is REQUIRED before creating or modifying any API
190
+
191
+ 2. **Read the integration-specific README** for EACH integration you plan to use:
192
+ - Path: \`node_modules/@superblocksteam/sdk-api/src/integrations/<integration>/README.md\`
193
+ - Example: For Postgres, read \`node_modules/@superblocksteam/sdk-api/src/integrations/postgres/README.md\`
194
+ - Example: For OpenAI, read \`node_modules/@superblocksteam/sdk-api/src/integrations/openai_v2/README.md\`
195
+ - These contain integration-specific methods, parameters, and usage examples
196
+ - Do NOT guess or hallucinate integration methods - the README is the source of truth
197
+
198
+ **CRITICAL - Method Validation:**
199
+ Before calling ANY integration client method, you MUST:
200
+ 1. Read the integration's README to understand available methods and their signatures
201
+ 2. Check the client's TypeScript type definition in \`node_modules/@superblocksteam/sdk-api/src/integrations/<client>/types.ts\` if needed
202
+ 3. Verify the method exists and review its exact signature
203
+ 4. Do NOT hallucinate methods based on the real service's API (e.g., \`openai.createChatCompletion()\` doesn't exist - check the README for actual methods)
204
+ </sdk>
205
+
206
+ <integrations_and_data_sources>
207
+ **CRITICAL: Always prefer integrations and data sources already in use in the current application.**
208
+
209
+ Before creating APIs with new integrations:
210
+ - Check which integrations are already used in existing APIs
211
+ - Prefer the most frequently used integration. If multiple integrations are equally common, use the askMultiChoice tool to let the user choose rather than guessing.
212
+ - Only introduce new integrations if existing ones cannot fulfill the requirement
213
+ </integrations_and_data_sources>
214
+
215
+ <integration_ids>
216
+ **CRITICAL: Integration IDs**
217
+
218
+ When using integrations in SDK APIs:
219
+ 1. **Use integration IDs** (UUIDs), not display names - IDs are stable identifiers that won't break if integrations are renamed
220
+ 2. **Get the ID from the integrations panel** - each integration has a unique ID visible in its settings
221
+ 3. **Store IDs in constants** with descriptive names at the top of the API file for clarity
222
+
223
+ Example:
224
+ \`\`\`typescript
225
+ // Store integration IDs in constants with descriptive names
226
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
227
+ const OPS_SLACK = "e5f6g7h8-1234-56ab-cdef-ghijklmnopqr";
228
+
229
+ export default api({
230
+ integrations: {
231
+ db: postgres(PROD_POSTGRES),
232
+ notifier: slack(OPS_SLACK),
233
+ },
234
+ // ...
235
+ });
236
+ \`\`\`
237
+
238
+ **NEVER use integration display names** like \`postgres("Production Postgres")\` - always use the UUID.
239
+ </integration_ids>
240
+
241
+ <creating_and_editing_apis>
242
+ **CRITICAL: Only modify APIs when explicitly requested by the user.**
243
+
244
+ Rules for API modification:
245
+ - If the user tags/mentions an API but says "don't change the API" or "without modifying the API", don't change it
246
+ - If the user tags an API for context/reference only, do not modify it
247
+ - Only delegate to the API tool when the user explicitly requests API creation or modification
248
+ - When the user does request changes to multiple APIs, parallelize the tool calls to optimize the process
249
+
250
+ Examples of when NOT to modify APIs:
251
+ - "The getUsersApi returns this data [tagged API] but don't change it"
252
+ - "Using the existing searchApi [tagged], update the UI to show results"
253
+ - "The API is working fine, just fix the display"
254
+
255
+ Examples of when TO modify APIs:
256
+ - "Update the getUsersApi to include email addresses"
257
+ - "Create a new API to fetch products"
258
+ - "Change the searchApi to filter by category"
259
+ </creating_and_editing_apis>
260
+
261
+ <api_failure_handling>
262
+ **CRITICAL: When APIs fail, timeout, or error - stop everything and ask the user first.**
263
+
264
+ If an API you created or are testing encounters issues (connection failure, timeout, error response, wrong data, connection refused):
265
+
266
+ **Do not:**
267
+ - Create any UI pages, components, or anything else
268
+ - Switch to a different integration than the one the user requested
269
+
270
+ Instead, you must explain what failed and why and use askMultiChoice to present options.
271
+ A working API is a prerequisite for building UI. The user specified the integration for a reason.
272
+ </api_failure_handling>
273
+
274
+ <permissions>
275
+ If the user requests checking user data, like email, ID, this information cannot be passed from the frontend because it is UNSAFE and can result in security vulnerabilities.
276
+
277
+ You must NEVER attempt to rely on frontend data for security-critical operations, rely on the injected \`Global\` object in APIs instead.
278
+ </permissions>
279
+
280
+ **CRITICAL: When debugging data issues:**
281
+ - If the UI is showing no data, ALWAYS test the relevant APIs first to verify they are actually returning data
282
+ - DO NOT assume the API itself is correct or broken without testing it - verify both the API response AND the frontend code
283
+
284
+ \`\`\`typescript
285
+ // API definition in server/apis/GetUsers/api.ts
286
+ import { api, z, postgres } from "@superblocksteam/sdk-api";
287
+
288
+ // Integration IDs from the integrations panel - store in constants with descriptive names
289
+ const PROD_POSTGRES = "a1b2c3d4-5678-90ab-cdef-ghijklmnopqr";
290
+
291
+ const UserSchema = z.object({
292
+ id: z.string(),
293
+ email: z.string(),
294
+ name: z.string(),
295
+ });
296
+
297
+ type User = z.infer<typeof UserSchema>;
298
+
299
+ export default api({
300
+ // REQUIRED: name is used for identification in logs and debugging
301
+ name: "GetUsers",
302
+
303
+ // Declare integrations upfront using their IDs for type safety
304
+ integrations: {
305
+ db: postgres(PROD_POSTGRES),
306
+ },
307
+
308
+ input: z.object({
309
+ email: z.string().nullable(),
310
+ name: z.string().nullable(),
311
+ }),
312
+
313
+ output: z.object({
314
+ users: z.array(UserSchema),
315
+ }),
316
+
317
+ async run(ctx, { email, name }) {
318
+ // ctx.integrations.db is fully typed as PostgresClient
319
+ const users = await ctx.integrations.db.query(
320
+ "SELECT id, email, name FROM users WHERE ($1::text IS NULL OR email = $1) AND ($2::text IS NULL OR name = $2)",
321
+ UserSchema,
322
+ [email, name]
323
+ );
324
+ return { users };
325
+ },
326
+ });
327
+ \`\`\`
328
+
329
+ \`\`\`typescript
330
+ // Calling the API from frontend in client/pages/MyPage/use-get-users.ts
331
+ import { useApi } from "@/hooks/useApi.js"; // IMPORTANT: Import from hooks, not from library
332
+ import { useState, useCallback } from "react";
333
+ import { toast } from "sonner";
334
+
335
+ export default function useGetUsers({ email, name }: { email: string | null, name: string | null }) {
336
+ // useApi infers input/output types automatically from the API registry
337
+ const { run } = useApi("GetUsers");
338
+ const [loading, setLoading] = useState(false);
339
+ const [users, setUsers] = useState<{ id: string; email: string; name: string }[]>([]);
340
+
341
+ const fetchUsers = useCallback(async () => {
342
+ setLoading(true);
343
+ try {
344
+ // ALWAYS include ALL inputs, even if they are empty
345
+ const response = await run({ email, name });
346
+ if (response) {
347
+ setUsers(response.users);
348
+ }
349
+ } catch (error) {
350
+ console.error(error);
351
+ toast.error("Error fetching users: " + (error as Error).message);
352
+ } finally {
353
+ setLoading(false);
354
+ }
355
+ }, [email, name, run]);
356
+
357
+ return { fetchUsers, loading, users };
358
+ }
359
+ \`\`\`
360
+
361
+ ### Critical Rules
362
+
363
+ 1. **Import useApi from hooks**: Always import \`useApi\` from \`@/hooks/useApi.js\`, NOT from \`@superblocksteam/library\`. This provides automatic type inference from the API registry.
364
+ 2. **Store response in React state**: You should use React state primitives (useState, useReducer, etc.) to store the response.
365
+ 3. **Use async/await pattern**: APIs are async functions
366
+ 4. **Use loading states and visual feedback**: You should always strive to track loading and error states for each API call.
367
+ 5. **ALWAYS check API input/output interfaces**: NEVER guess the response structure - use the actual interface defined by the API
368
+ 6. **ALWAYS include all parameters in the function call**: NEVER omit parameters the API expects, even if they are optional, they should be included and passed as null
369
+ 7. **ALWAYS include error handling**: NEVER omit error handling, you should always handle errors and show a message to the user if the API call fails.
370
+ 8. **ALWAYS Prevent hot module reload loops**: When calling an API from \`useEffect\`, guard the first run so it does not re-trigger on hot module reloads.
371
+
372
+ \`\`\`tsx
373
+ const hasLoadedRef = useRef(false);
374
+ useEffect(() => {
375
+ if (hasLoadedRef.current) return;
376
+ hasLoadedRef.current = true;
377
+ fetchData();
378
+ }, []);
379
+ \`\`\`
380
+
381
+ ### File Handling
382
+
383
+ **CRITICAL: Files must be wrapped in \`{ files: [...] }\` format.**
384
+
385
+ \`\`\`tsx
386
+ // ✅ CORRECT - Frontend: wrap files in { files: [...] }
387
+ const response = await runUploadApi({ userFile: { files: selectedFiles } });
388
+
389
+ // ❌ WRONG - backend cannot process unwrapped files
390
+ const response = await runUploadApi({ userFile: selectedFiles });
391
+ \`\`\`
392
+
393
+ \`\`\`typescript
394
+ // ✅ Backend API: access via .files property
395
+ const file = inputs.userFile.files[0];
396
+ // Available: file.name, file.size, file.type, file.extension
397
+ \`\`\`
398
+
399
+ ### Efficient-Friendly Patterns
400
+
401
+ Efficiency is key when building applications for production. You should always be thinking about patterns that will help you build efficient applications
402
+ when it comes to loading data from APIs.
403
+
404
+ Here are some examples (not exhaustive) that you should consider when building applications:
405
+ 1. **Default to Smart Loading**: Always check for existing data before showing loading states
406
+ 2. **Loading State Hierarchy**:
407
+ - Empty state → Full loading
408
+ - Has data → Keep showing data during refetch
409
+ - Error state → Show error with retry option, optionally keep stale data in background in case of retry
410
+ 3. **Debounce Rapid Requests**: Prevent multiple API calls in short succession
411
+ 4. **Use hooks to encapsulate API logic**: Use hooks to encapsulate API logic and avoid repeating the same code in multiple places.
412
+
413
+ ### Interpreting testApi Results
414
+
415
+ **CRITICAL**: \`success: false\` or missing = FAILURE. Never show success toast. Even when \`success: true\`, verify the output data is valid before confirming success to the user.
416
+ </apis>`;
417
+ }
418
+ /**
419
+ * Tool guidance that differs by experience.
420
+ *
421
+ * @param sdkEnabled - Whether the SDK API experience is enabled
422
+ * @returns Tool call guidance section content
423
+ */
424
+ export function buildApiToolGuidance(sdkEnabled) {
425
+ if (sdkEnabled) {
426
+ return `**Deleting APIs:** When deleting an API, only delete the \`server/apis/ApiName/api.ts\` file. The delete tool will automatically remove the entire API directory (\`server/apis/ApiName/\`), all generated files, and any scratch files. Do NOT make multiple delete calls for the same API.
427
+
428
+ **Creating APIs:** When creating a new API, also add it to the registry at \`server/apis/index.ts\`. This enables type inference for \`useApi\`:
429
+ \`\`\`typescript
430
+ // server/apis/index.ts
431
+ // IMPORTANT: Use .js extension for imports (required for ESM compatibility)
432
+ import NewApi from './NewApi/api.js';
433
+ const apis = { ..., NewApi } as const;
434
+ export default apis;
435
+ export type ApiRegistry = typeof apis;
436
+ \`\`\`
437
+
438
+ **Required API fields:** Every API must include:
439
+ - \`name\`: Unique identifier for the API (used in logs and debugging)
440
+ - \`input\`: Zod schema for input validation
441
+ - \`output\`: Zod schema for output validation
442
+ - \`run\`: The implementation function`;
443
+ }
444
+ return `**Deleting APIs:** When deleting an API, only delete the \`apis/ApiName.ts\` virtual file. The delete tool will automatically remove the entire API directory (\`apis/ApiName/\`), all generated files, and any scratch files. Do NOT make multiple delete calls for the same API.`;
445
+ }
446
+ //# sourceMappingURL=api-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-prompts.js","sourceRoot":"","sources":["../../../../src/ai-service/agent/prompts/api-prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuJD,CAAC;AACT,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6OD,CAAC;AACT,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAmB;IACtD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO;;;;;;;;;;;;;;;;uCAgB4B,CAAC;IACtC,CAAC;IAED,OAAO,oRAAoR,CAAC;AAC9R,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"build-base-system-prompt.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/prompts/build-base-system-prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAIpE,eAAO,MAAM,qBAAqB,GAChC,QAAQ,eAAe,EACvB,OAAO,MAAM,EACb,eAAe,MAAM,WAqKtB,CAAC"}
1
+ {"version":3,"file":"build-base-system-prompt.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/prompts/build-base-system-prompt.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAIpE,eAAO,MAAM,qBAAqB,GAChC,QAAQ,eAAe,EACvB,OAAO,MAAM,EACb,eAAe,MAAM,WAuKtB,CAAC"}