@levelcode/sdk 0.0.5 → 0.1.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 (266) hide show
  1. package/dist/common/src/actions.d.ts +176 -0
  2. package/dist/common/src/analytics-core.d.ts +52 -0
  3. package/dist/common/src/analytics.d.ts +9 -0
  4. package/dist/common/src/browser-actions.d.ts +1200 -0
  5. package/dist/common/src/constants/agents.d.ts +47 -0
  6. package/dist/common/src/constants/analytics-events.d.ts +107 -0
  7. package/dist/common/src/constants/byok.d.ts +2 -0
  8. package/dist/common/src/constants/claude-oauth.d.ts +36 -0
  9. package/dist/common/src/constants/index.d.ts +4 -0
  10. package/dist/common/src/constants/knowledge.d.ts +21 -0
  11. package/dist/common/src/constants/limits.d.ts +14 -0
  12. package/dist/common/src/constants/model-config.d.ts +117 -0
  13. package/dist/common/src/constants/paths.d.ts +23 -0
  14. package/dist/common/src/constants/skills.d.ts +42 -0
  15. package/dist/common/src/constants/ui.d.ts +14 -0
  16. package/dist/common/src/env-ci.d.ts +22 -0
  17. package/dist/common/src/env-process.d.ts +28 -0
  18. package/dist/common/src/env-schema.d.ts +24 -0
  19. package/dist/common/src/env.d.ts +16 -0
  20. package/dist/common/src/mcp/client.d.ts +6 -0
  21. package/dist/common/src/old-constants.d.ts +10 -0
  22. package/dist/common/src/project-file-tree.d.ts +27 -0
  23. package/dist/common/src/templates/agent-validation.d.ts +48 -0
  24. package/dist/common/src/templates/initial-agents-dir/types/agent-definition.d.ts +296 -0
  25. package/dist/common/src/templates/initial-agents-dir/types/tools.d.ts +308 -0
  26. package/dist/common/src/templates/initial-agents-dir/types/util-types.d.ts +128 -0
  27. package/dist/common/src/testing/errors.d.ts +14 -0
  28. package/dist/common/src/testing/mock-modules.d.ts +11 -0
  29. package/dist/common/src/testing/mock-types.d.ts +97 -0
  30. package/dist/common/src/testing/mocks/analytics.d.ts +182 -0
  31. package/dist/common/src/testing/mocks/child-process.d.ts +29 -0
  32. package/dist/common/src/testing/mocks/crypto.d.ts +159 -0
  33. package/dist/common/src/testing/mocks/database.d.ts +197 -0
  34. package/dist/common/src/testing/mocks/fetch.d.ts +35 -0
  35. package/dist/common/src/testing/mocks/filesystem.d.ts +31 -0
  36. package/dist/common/src/testing/mocks/index.d.ts +25 -0
  37. package/dist/common/src/testing/mocks/logger.d.ts +35 -0
  38. package/dist/common/src/testing/mocks/stream.d.ts +203 -0
  39. package/dist/common/src/testing/mocks/timers.d.ts +27 -0
  40. package/dist/common/src/testing/mocks/tree-sitter.d.ts +58 -0
  41. package/dist/common/src/testing-env-process.d.ts +7 -0
  42. package/dist/common/src/tools/constants.d.ts +17 -0
  43. package/dist/common/src/tools/list.d.ts +1140 -0
  44. package/dist/common/src/tools/params/tool/add-message.d.ts +19 -0
  45. package/dist/common/src/tools/params/tool/add-subgoal.d.ts +26 -0
  46. package/dist/common/src/tools/params/tool/ask-user.d.ts +59 -0
  47. package/dist/common/src/tools/params/tool/browser-logs.d.ts +127 -0
  48. package/dist/common/src/tools/params/tool/code-search.d.ts +30 -0
  49. package/dist/common/src/tools/params/tool/create-plan.d.ts +30 -0
  50. package/dist/common/src/tools/params/tool/end-turn.d.ts +13 -0
  51. package/dist/common/src/tools/params/tool/find-files.d.ts +31 -0
  52. package/dist/common/src/tools/params/tool/glob.d.ts +26 -0
  53. package/dist/common/src/tools/params/tool/list-directory.d.ts +25 -0
  54. package/dist/common/src/tools/params/tool/lookup-agent-info.d.ts +13 -0
  55. package/dist/common/src/tools/params/tool/propose-str-replace.d.ts +40 -0
  56. package/dist/common/src/tools/params/tool/propose-write-file.d.ts +29 -0
  57. package/dist/common/src/tools/params/tool/read-docs.d.ts +19 -0
  58. package/dist/common/src/tools/params/tool/read-files.d.ts +35 -0
  59. package/dist/common/src/tools/params/tool/read-subtree.d.ts +40 -0
  60. package/dist/common/src/tools/params/tool/run-file-change-hooks.d.ts +63 -0
  61. package/dist/common/src/tools/params/tool/run-terminal-command.d.ts +88 -0
  62. package/dist/common/src/tools/params/tool/send-message.d.ts +26 -0
  63. package/dist/common/src/tools/params/tool/set-messages.d.ts +15 -0
  64. package/dist/common/src/tools/params/tool/set-output.d.ts +15 -0
  65. package/dist/common/src/tools/params/tool/skill.d.ts +28 -0
  66. package/dist/common/src/tools/params/tool/spawn-agent-inline.d.ts +17 -0
  67. package/dist/common/src/tools/params/tool/spawn-agents.d.ts +26 -0
  68. package/dist/common/src/tools/params/tool/str-replace.d.ts +43 -0
  69. package/dist/common/src/tools/params/tool/suggest-followups.d.ts +26 -0
  70. package/dist/common/src/tools/params/tool/task-completed.d.ts +13 -0
  71. package/dist/common/src/tools/params/tool/task-create.d.ts +18 -0
  72. package/dist/common/src/tools/params/tool/task-get.d.ts +15 -0
  73. package/dist/common/src/tools/params/tool/task-list.d.ts +13 -0
  74. package/dist/common/src/tools/params/tool/task-update.d.ts +23 -0
  75. package/dist/common/src/tools/params/tool/team-create.d.ts +17 -0
  76. package/dist/common/src/tools/params/tool/team-delete.d.ts +13 -0
  77. package/dist/common/src/tools/params/tool/think-deeply.d.ts +15 -0
  78. package/dist/common/src/tools/params/tool/update-subgoal.d.ts +25 -0
  79. package/dist/common/src/tools/params/tool/web-search.d.ts +25 -0
  80. package/dist/common/src/tools/params/tool/write-file.d.ts +31 -0
  81. package/dist/common/src/tools/params/tool/write-todos.d.ts +18 -0
  82. package/dist/common/src/tools/params/utils.d.ts +35 -0
  83. package/dist/common/src/tools/utils.d.ts +4 -0
  84. package/dist/common/src/types/agent-template.d.ts +156 -0
  85. package/dist/common/src/types/contracts/agent-runtime.d.ts +36 -0
  86. package/dist/common/src/types/contracts/analytics.d.ts +8 -0
  87. package/dist/common/src/types/contracts/billing.d.ts +40 -0
  88. package/dist/common/src/types/contracts/client.d.ts +45 -0
  89. package/dist/common/src/types/contracts/database.d.ts +80 -0
  90. package/dist/common/src/types/contracts/env.d.ts +150 -0
  91. package/dist/common/src/types/contracts/llm.d.ts +102 -0
  92. package/dist/common/src/types/contracts/logger.d.ts +8 -0
  93. package/dist/common/src/types/dynamic-agent-template.d.ts +227 -0
  94. package/dist/common/src/types/filesystem.d.ts +6 -0
  95. package/dist/common/src/types/function-params.d.ts +15 -0
  96. package/dist/common/src/types/grant.d.ts +2 -0
  97. package/dist/common/src/types/json.d.ts +9 -0
  98. package/dist/common/src/types/mcp.d.ts +31 -0
  99. package/dist/common/src/types/messages/content-part.d.ts +46 -0
  100. package/dist/common/src/types/messages/data-content.d.ts +3 -0
  101. package/dist/common/src/types/messages/levelcode-message.d.ts +37 -0
  102. package/dist/common/src/types/messages/provider-metadata.d.ts +3 -0
  103. package/dist/common/src/types/print-mode.d.ts +155 -0
  104. package/dist/common/src/types/session-state.d.ts +94 -0
  105. package/dist/common/src/types/skill.d.ts +31 -0
  106. package/dist/common/src/types/source.d.ts +8 -0
  107. package/dist/common/src/types/spawn.d.ts +8 -0
  108. package/dist/common/src/types/team-config.d.ts +39 -0
  109. package/dist/common/src/types/team-protocol.d.ts +64 -0
  110. package/dist/common/src/util/agent-id-parsing.d.ts +22 -0
  111. package/dist/common/src/util/agent-name-normalization.d.ts +12 -0
  112. package/dist/common/src/util/array.d.ts +6 -0
  113. package/dist/common/src/util/credentials.d.ts +11 -0
  114. package/dist/common/src/util/error.d.ts +128 -0
  115. package/dist/common/src/util/file.d.ts +133 -0
  116. package/dist/common/src/util/format-code-search.d.ts +16 -0
  117. package/dist/common/src/util/lru-cache.d.ts +30 -0
  118. package/dist/common/src/util/messages.d.ts +46 -0
  119. package/dist/common/src/util/model-utils.d.ts +8 -0
  120. package/dist/common/src/util/object.d.ts +22 -0
  121. package/dist/common/src/util/promise.d.ts +16 -0
  122. package/dist/common/src/util/random.d.ts +1 -0
  123. package/dist/common/src/util/skills.d.ts +5 -0
  124. package/dist/common/src/util/stop-sequence.d.ts +14 -0
  125. package/dist/common/src/util/string.d.ts +82 -0
  126. package/dist/common/src/util/xml.d.ts +12 -0
  127. package/dist/common/src/util/zod-schema.d.ts +5 -0
  128. package/dist/common/src/utils/team-fs.d.ts +17 -0
  129. package/dist/index.cjs +1940 -917
  130. package/dist/index.cjs.map +24 -9
  131. package/dist/index.mjs +2380 -1357
  132. package/dist/index.mjs.map +24 -9
  133. package/dist/packages/agent-runtime/src/constants.d.ts +1 -0
  134. package/dist/packages/agent-runtime/src/fast-rewrite.d.ts +45 -0
  135. package/dist/packages/agent-runtime/src/find-files/request-files-prompt.d.ts +71 -0
  136. package/dist/packages/agent-runtime/src/generate-diffs-prompt.d.ts +53 -0
  137. package/dist/packages/agent-runtime/src/get-file-reading-updates.d.ts +8 -0
  138. package/dist/packages/agent-runtime/src/llm-api/claude.d.ts +5 -0
  139. package/dist/packages/agent-runtime/src/llm-api/context7-api.d.ts +55 -0
  140. package/dist/packages/agent-runtime/src/llm-api/gemini-with-fallbacks.d.ts +40 -0
  141. package/dist/packages/agent-runtime/src/llm-api/levelcode-web-api.d.ts +49 -0
  142. package/dist/packages/agent-runtime/src/llm-api/relace-api.d.ts +16 -0
  143. package/dist/packages/agent-runtime/src/main-prompt.d.ts +29 -0
  144. package/dist/packages/agent-runtime/src/mcp-constants.d.ts +12 -0
  145. package/dist/packages/agent-runtime/src/mcp.d.ts +10 -0
  146. package/dist/packages/agent-runtime/src/process-file-block.d.ts +56 -0
  147. package/dist/packages/agent-runtime/src/process-str-replace.d.ts +21 -0
  148. package/dist/packages/agent-runtime/src/prompt-agent-stream.d.ts +28 -0
  149. package/dist/packages/agent-runtime/src/run-agent-step.d.ts +73 -0
  150. package/dist/packages/agent-runtime/src/run-programmatic-step.d.ts +40 -0
  151. package/dist/packages/agent-runtime/src/system-prompt/prompts.d.ts +19 -0
  152. package/dist/packages/agent-runtime/src/system-prompt/search-system-prompt.d.ts +14 -0
  153. package/dist/packages/agent-runtime/src/system-prompt/truncate-file-tree.d.ts +13 -0
  154. package/dist/packages/agent-runtime/src/templates/agent-registry.d.ts +35 -0
  155. package/dist/packages/agent-runtime/src/templates/prompts.d.ts +35 -0
  156. package/dist/packages/agent-runtime/src/templates/strings.d.ts +32 -0
  157. package/dist/packages/agent-runtime/src/templates/types.d.ts +13 -0
  158. package/dist/packages/agent-runtime/src/tool-stream-parser.d.ts +31 -0
  159. package/dist/packages/agent-runtime/src/tools/handlers/handler-function-type.d.ts +51 -0
  160. package/dist/packages/agent-runtime/src/tools/handlers/list.d.ts +347 -0
  161. package/dist/packages/agent-runtime/src/tools/handlers/tool/add-message.d.ts +9 -0
  162. package/dist/packages/agent-runtime/src/tools/handlers/tool/add-subgoal.d.ts +9 -0
  163. package/dist/packages/agent-runtime/src/tools/handlers/tool/ask-user.d.ts +10 -0
  164. package/dist/packages/agent-runtime/src/tools/handlers/tool/browser-logs.d.ts +8 -0
  165. package/dist/packages/agent-runtime/src/tools/handlers/tool/code-search.d.ts +8 -0
  166. package/dist/packages/agent-runtime/src/tools/handlers/tool/create-plan.d.ts +13 -0
  167. package/dist/packages/agent-runtime/src/tools/handlers/tool/end-turn.d.ts +7 -0
  168. package/dist/packages/agent-runtime/src/tools/handlers/tool/find-files.d.ts +27 -0
  169. package/dist/packages/agent-runtime/src/tools/handlers/tool/glob.d.ts +10 -0
  170. package/dist/packages/agent-runtime/src/tools/handlers/tool/list-directory.d.ts +10 -0
  171. package/dist/packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.d.ts +14 -0
  172. package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-str-replace.d.ts +15 -0
  173. package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-write-file.d.ts +7 -0
  174. package/dist/packages/agent-runtime/src/tools/handlers/tool/proposed-content-store.d.ts +27 -0
  175. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-docs.d.ts +21 -0
  176. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-files.d.ts +13 -0
  177. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-subtree.d.ts +13 -0
  178. package/dist/packages/agent-runtime/src/tools/handlers/tool/run-file-change-hooks.d.ts +10 -0
  179. package/dist/packages/agent-runtime/src/tools/handlers/tool/run-terminal-command.d.ts +10 -0
  180. package/dist/packages/agent-runtime/src/tools/handlers/tool/send-message.d.ts +10 -0
  181. package/dist/packages/agent-runtime/src/tools/handlers/tool/set-messages.d.ts +9 -0
  182. package/dist/packages/agent-runtime/src/tools/handlers/tool/set-output.d.ts +18 -0
  183. package/dist/packages/agent-runtime/src/tools/handlers/tool/skill.d.ts +11 -0
  184. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.d.ts +29 -0
  185. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.d.ts +100 -0
  186. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agents.d.ts +35 -0
  187. package/dist/packages/agent-runtime/src/tools/handlers/tool/str-replace.d.ts +16 -0
  188. package/dist/packages/agent-runtime/src/tools/handlers/tool/suggest-followups.d.ts +9 -0
  189. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-completed.d.ts +7 -0
  190. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-create.d.ts +9 -0
  191. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-get.d.ts +9 -0
  192. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-list.d.ts +9 -0
  193. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-update.d.ts +9 -0
  194. package/dist/packages/agent-runtime/src/tools/handlers/tool/team-create.d.ts +10 -0
  195. package/dist/packages/agent-runtime/src/tools/handlers/tool/team-delete.d.ts +10 -0
  196. package/dist/packages/agent-runtime/src/tools/handlers/tool/think-deeply.d.ts +9 -0
  197. package/dist/packages/agent-runtime/src/tools/handlers/tool/update-subgoal.d.ts +11 -0
  198. package/dist/packages/agent-runtime/src/tools/handlers/tool/web-search.d.ts +22 -0
  199. package/dist/packages/agent-runtime/src/tools/handlers/tool/write-file.d.ts +49 -0
  200. package/dist/packages/agent-runtime/src/tools/handlers/tool/write-todos.d.ts +9 -0
  201. package/dist/packages/agent-runtime/src/tools/prompts.d.ts +31 -0
  202. package/dist/packages/agent-runtime/src/tools/stream-parser.d.ts +33 -0
  203. package/dist/packages/agent-runtime/src/tools/tool-executor.d.ts +87 -0
  204. package/dist/packages/agent-runtime/src/util/agent-output.d.ts +3 -0
  205. package/dist/packages/agent-runtime/src/util/messages.d.ts +68 -0
  206. package/dist/packages/agent-runtime/src/util/parse-tool-calls-from-text.d.ts +38 -0
  207. package/dist/packages/agent-runtime/src/util/render-read-files-result.d.ts +15 -0
  208. package/dist/packages/agent-runtime/src/util/simplify-tool-results.d.ts +7 -0
  209. package/dist/packages/agent-runtime/src/util/stream-xml-parser.d.ts +34 -0
  210. package/dist/packages/agent-runtime/src/util/token-counter.d.ts +3 -0
  211. package/dist/packages/code-map/src/index.d.ts +3 -0
  212. package/dist/packages/code-map/src/init-node.d.ts +4 -0
  213. package/dist/packages/code-map/src/languages.d.ts +36 -0
  214. package/dist/packages/code-map/src/parse.d.ts +21 -0
  215. package/dist/packages/code-map/src/types.d.ts +8 -0
  216. package/dist/packages/code-map/src/utils.d.ts +1 -0
  217. package/dist/sdk/src/__tests__/client.test.d.ts +1 -0
  218. package/dist/sdk/src/__tests__/code-search.test.d.ts +1 -0
  219. package/dist/sdk/src/__tests__/credentials.test.d.ts +1 -0
  220. package/dist/sdk/src/__tests__/database.test.d.ts +1 -0
  221. package/dist/sdk/src/__tests__/env.test.d.ts +1 -0
  222. package/dist/sdk/src/__tests__/error-utils.test.d.ts +1 -0
  223. package/dist/sdk/src/__tests__/initial-session-state.test.d.ts +1 -0
  224. package/dist/sdk/src/__tests__/knowledge-file-selection.test.d.ts +1 -0
  225. package/dist/sdk/src/__tests__/load-agents.test.d.ts +1 -0
  226. package/dist/sdk/src/__tests__/load-mcp-config.test.d.ts +1 -0
  227. package/dist/sdk/src/__tests__/model-provider.test.d.ts +1 -0
  228. package/dist/sdk/src/__tests__/read-files.test.d.ts +1 -0
  229. package/dist/sdk/src/__tests__/run-cancellation.test.d.ts +1 -0
  230. package/dist/sdk/src/__tests__/run-file-filter.test.d.ts +1 -0
  231. package/dist/sdk/src/__tests__/run-handle-event.test.d.ts +1 -0
  232. package/dist/sdk/src/__tests__/run.integration.test.d.ts +1 -0
  233. package/dist/sdk/src/__tests__/user-knowledge-files.test.d.ts +1 -0
  234. package/dist/sdk/src/__tests__/validate-agents.test.d.ts +1 -0
  235. package/dist/sdk/src/agents/load-agents.d.ts +106 -0
  236. package/dist/sdk/src/agents/load-mcp-config.d.ts +69 -0
  237. package/dist/sdk/src/client.d.ts +33 -0
  238. package/dist/sdk/src/constants.d.ts +4 -0
  239. package/dist/sdk/src/credentials.d.ts +58 -0
  240. package/dist/sdk/src/custom-tool.d.ts +32 -0
  241. package/dist/sdk/src/env.d.ts +31 -0
  242. package/dist/sdk/src/error-utils.d.ts +55 -0
  243. package/dist/sdk/src/impl/__tests__/prompt-result.test.d.ts +1 -0
  244. package/dist/sdk/src/impl/agent-runtime.d.ts +8 -0
  245. package/dist/sdk/src/impl/database.d.ts +7 -0
  246. package/dist/sdk/src/impl/llm.d.ts +8 -0
  247. package/dist/sdk/src/impl/model-provider.d.ts +61 -0
  248. package/dist/sdk/src/index.d.ts +41 -0
  249. package/dist/sdk/src/native/ripgrep.d.ts +7 -0
  250. package/dist/sdk/src/retry-config.d.ts +46 -0
  251. package/dist/sdk/src/run-state.d.ts +81 -0
  252. package/dist/sdk/src/run.d.ts +79 -0
  253. package/dist/sdk/src/skills/load-skills.d.ts +42 -0
  254. package/dist/sdk/src/testing/env.d.ts +5 -0
  255. package/dist/sdk/src/tools/change-file.d.ts +7 -0
  256. package/dist/sdk/src/tools/code-search.d.ts +13 -0
  257. package/dist/sdk/src/tools/glob.d.ts +8 -0
  258. package/dist/sdk/src/tools/index.d.ts +16 -0
  259. package/dist/sdk/src/tools/list-directory.d.ts +7 -0
  260. package/dist/sdk/src/tools/read-files.d.ts +16 -0
  261. package/dist/sdk/src/tools/run-file-change-hooks.d.ts +4 -0
  262. package/dist/sdk/src/tools/run-terminal-command.d.ts +8 -0
  263. package/dist/sdk/src/types/env.d.ts +30 -0
  264. package/dist/sdk/src/validate-agents.d.ts +45 -0
  265. package/package.json +1 -1
  266. package/dist/index.d.ts +0 -3443
@@ -0,0 +1 @@
1
+ export declare const globalStopSequence: string;
@@ -0,0 +1,45 @@
1
+ import { promptFlashWithFallbacks } from './llm-api/gemini-with-fallbacks';
2
+ import { promptRelaceAI } from './llm-api/relace-api';
3
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
4
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
5
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
6
+ import type { Message } from '@levelcode/common/types/messages/levelcode-message';
7
+ /**
8
+ * Rewrites file content using Relace AI with fallback to OpenAI.
9
+ *
10
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
11
+ */
12
+ export declare function fastRewrite(params: {
13
+ initialContent: string;
14
+ editSnippet: string;
15
+ filePath: string;
16
+ userMessage: string | undefined;
17
+ logger: Logger;
18
+ } & ParamsExcluding<typeof promptRelaceAI, 'initialCode'> & ParamsExcluding<typeof rewriteWithOpenAI, 'oldContent'>): Promise<string>;
19
+ /**
20
+ * Rewrites file content using OpenAI's o3-mini model when Gemini Flash output limit is exceeded.
21
+ * Gemini flash can only output 8k tokens, openai models can do at least 16k tokens.
22
+ *
23
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
24
+ */
25
+ export declare function rewriteWithOpenAI(params: {
26
+ oldContent: string;
27
+ editSnippet: string;
28
+ promptAiSdk: PromptAiSdkFn;
29
+ } & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<string>;
30
+ /**
31
+ * Checks if Claude forgot to add "... existing code ..." placeholders.
32
+ *
33
+ * This handles a specific case where Claude sketches an update to a single function,
34
+ * but forgets to add ... existing code ... above and below the function.
35
+ *
36
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
37
+ */
38
+ export declare const shouldAddFilePlaceholders: (params: {
39
+ filePath: string;
40
+ oldContent: string;
41
+ rewrittenNewContent: string;
42
+ messageHistory: Message[];
43
+ fullResponse: string;
44
+ logger: Logger;
45
+ } & ParamsExcluding<typeof promptFlashWithFallbacks, "messages" | "model">) => Promise<boolean>;
@@ -0,0 +1,71 @@
1
+ import { type FinetunedVertexModel } from '@levelcode/common/old-constants';
2
+ import { promptFlashWithFallbacks } from '../llm-api/gemini-with-fallbacks';
3
+ import type { TextBlock } from '../llm-api/claude';
4
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
5
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
6
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
7
+ import type { Message } from '@levelcode/common/types/messages/levelcode-message';
8
+ import type { ProjectFileContext } from '@levelcode/common/util/file';
9
+ export declare function requestRelevantFiles(params: {
10
+ messages: Message[];
11
+ system: string | Array<TextBlock>;
12
+ fileContext: ProjectFileContext;
13
+ assistantPrompt: string | null;
14
+ agentStepId: string;
15
+ clientSessionId: string;
16
+ fingerprintId: string;
17
+ userInputId: string;
18
+ userId: string | undefined;
19
+ repoId: string | undefined;
20
+ logger: Logger;
21
+ } & ParamsExcluding<typeof getRelevantFiles, 'messages' | 'userPrompt' | 'requestType' | 'modelId'>): Promise<string[]>;
22
+ export declare function requestRelevantFilesForTraining(params: {
23
+ messages: Message[];
24
+ fileContext: ProjectFileContext;
25
+ assistantPrompt: string | null;
26
+ logger: Logger;
27
+ } & ParamsExcluding<typeof getRelevantFilesForTraining, 'messages' | 'userPrompt' | 'requestType'>): Promise<string[]>;
28
+ declare function getRelevantFiles(params: {
29
+ messages: Message[];
30
+ system: string | Array<TextBlock>;
31
+ userPrompt: string;
32
+ requestType: string;
33
+ agentStepId: string;
34
+ clientSessionId: string;
35
+ fingerprintId: string;
36
+ userInputId: string;
37
+ userId: string | undefined;
38
+ repoId: string | undefined;
39
+ modelId?: FinetunedVertexModel;
40
+ logger: Logger;
41
+ } & ParamsExcluding<typeof promptFlashWithFallbacks, 'messages' | 'model' | 'useFinetunedModel'>): Promise<{
42
+ files: string[];
43
+ duration: number;
44
+ requestType: string;
45
+ response: string;
46
+ }>;
47
+ /**
48
+ * Gets relevant files for training using Claude Sonnet.
49
+ *
50
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
51
+ */
52
+ declare function getRelevantFilesForTraining(params: {
53
+ messages: Message[];
54
+ system: string | Array<TextBlock>;
55
+ userPrompt: string;
56
+ requestType: string;
57
+ agentStepId: string;
58
+ clientSessionId: string;
59
+ fingerprintId: string;
60
+ userInputId: string;
61
+ userId: string | undefined;
62
+ repoId: string | undefined;
63
+ promptAiSdk: PromptAiSdkFn;
64
+ logger: Logger;
65
+ } & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model' | 'chargeUser'>): Promise<{
66
+ files: string[];
67
+ duration: number;
68
+ requestType: string;
69
+ response: string;
70
+ }>;
71
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
2
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
3
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
4
+ export declare const parseAndGetDiffBlocksSingleFile: (params: {
5
+ newContent: string;
6
+ oldFileContent: string;
7
+ logger: Logger;
8
+ }) => {
9
+ diffBlocks: {
10
+ searchContent: string;
11
+ replaceContent: string;
12
+ }[];
13
+ diffBlocksThatDidntMatch: {
14
+ searchContent: string;
15
+ replaceContent: string;
16
+ }[];
17
+ };
18
+ export declare const tryToDoStringReplacementWithExtraIndentation: (params: {
19
+ oldFileContent: string;
20
+ searchContent: string;
21
+ replaceContent: string;
22
+ }) => {
23
+ searchContent: string;
24
+ replaceContent: string;
25
+ } | null;
26
+ /**
27
+ * Retries generating diff blocks when initial blocks failed to match the old file content.
28
+ *
29
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
30
+ */
31
+ export declare function retryDiffBlocksPrompt(params: {
32
+ filePath: string;
33
+ oldContent: string;
34
+ clientSessionId: string;
35
+ fingerprintId: string;
36
+ userInputId: string;
37
+ userId: string | undefined;
38
+ diffBlocksThatDidntMatch: {
39
+ searchContent: string;
40
+ replaceContent: string;
41
+ }[];
42
+ promptAiSdk: PromptAiSdkFn;
43
+ logger: Logger;
44
+ } & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<{
45
+ newDiffBlocks: {
46
+ searchContent: string;
47
+ replaceContent: string;
48
+ }[];
49
+ newDiffBlocksThatDidntMatch: {
50
+ searchContent: string;
51
+ replaceContent: string;
52
+ }[];
53
+ }>;
@@ -0,0 +1,8 @@
1
+ import type { RequestFilesFn } from '@levelcode/common/types/contracts/client';
2
+ export declare function getFileReadingUpdates(params: {
3
+ requestFiles: RequestFilesFn;
4
+ requestedFiles: string[];
5
+ }): Promise<{
6
+ path: string;
7
+ content: string;
8
+ }[]>;
@@ -0,0 +1,5 @@
1
+ export type TextBlock = {
2
+ text: string;
3
+ type: 'text';
4
+ };
5
+ export type System = string | Array<TextBlock>;
@@ -0,0 +1,55 @@
1
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
2
+ import type { ParamsOf } from '@levelcode/common/types/function-params';
3
+ export interface SearchResponse {
4
+ results: Array<{
5
+ id: string;
6
+ title: string;
7
+ description: string;
8
+ branch: string;
9
+ lastUpdateDate: string;
10
+ state: DocumentState;
11
+ totalTokens: number;
12
+ totalSnippets: number;
13
+ totalPages: number;
14
+ stars?: number;
15
+ trustScore?: number;
16
+ }>;
17
+ }
18
+ type DocumentState = 'initial' | 'finalized' | 'error' | 'delete';
19
+ export interface SearchResult {
20
+ id: string;
21
+ title: string;
22
+ description: string;
23
+ branch: string;
24
+ lastUpdateDate: string;
25
+ state: DocumentState;
26
+ totalTokens: number;
27
+ totalSnippets: number;
28
+ totalPages: number;
29
+ stars?: number;
30
+ trustScore?: number;
31
+ }
32
+ /**
33
+ * Lists all available documentation projects from Context7
34
+ * @returns Array of projects with their metadata, or null if the request fails
35
+ */
36
+ export declare function searchLibraries(params: {
37
+ query: string;
38
+ logger: Logger;
39
+ fetch: typeof globalThis.fetch;
40
+ }): Promise<SearchResult[] | null>;
41
+ /**
42
+ * Fetches documentation context for a specific library
43
+ * @param libraryId The library ID to fetch documentation for
44
+ * @param options Options for the request
45
+ * @returns The documentation text or null if the request fails
46
+ */
47
+ export declare function fetchContext7LibraryDocumentation(params: {
48
+ query: string;
49
+ tokens?: number;
50
+ topic?: string;
51
+ folders?: string;
52
+ logger: Logger;
53
+ fetch: typeof globalThis.fetch;
54
+ } & ParamsOf<typeof searchLibraries>): Promise<string | null>;
55
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { FinetunedVertexModel } from '@levelcode/common/old-constants';
2
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
3
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
4
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
5
+ import type { Message } from '@levelcode/common/types/messages/levelcode-message';
6
+ /**
7
+ * Prompts a Gemini model with fallback logic.
8
+ *
9
+ * Attempts to call the specified Gemini model via the standard Gemini API.
10
+ * If that fails, it falls back to using the Vertex AI Gemini endpoint.
11
+ * If Vertex AI also fails, it falls back to either GPT-4o (if `useGPT4oInsteadOfClaude` is true)
12
+ * or a Claude model (Sonnet for 'max' costMode, Haiku otherwise).
13
+ *
14
+ * This function handles non-streaming requests and returns the complete response string.
15
+ *
16
+ * @param messages - The array of messages forming the conversation history.
17
+ * @param system - An optional system prompt string or array of text blocks.
18
+ * @param options - Configuration options for the API call.
19
+ * @param options.clientSessionId - Unique ID for the client session.
20
+ * @param options.fingerprintId - Unique ID for the user's device/fingerprint.
21
+ * @param options.userInputId - Unique ID for the specific user input triggering this call.
22
+ * @param options.model - The primary Gemini model to attempt.
23
+ * @param options.userId - The ID of the user making the request.
24
+ * @param options.maxTokens - Optional maximum number of tokens for the response.
25
+ * @param options.temperature - Optional temperature setting for generation (0-1).
26
+ * @param options.costMode - Optional cost mode ('free', 'normal', 'max') influencing fallback model choice.
27
+ * @param options.useGPT4oInsteadOfClaude - Optional flag to use GPT-4o instead of Claude as the final fallback.
28
+ * @returns A promise that resolves to the complete response string from the successful API call.
29
+ * @throws {Error} If all API calls (primary and fallbacks) fail.
30
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`. Aborts are not retried.
31
+ */
32
+ export declare function promptFlashWithFallbacks(params: {
33
+ messages: Message[];
34
+ costMode?: string;
35
+ useGPT4oInsteadOfClaude?: boolean;
36
+ thinkingBudget?: number;
37
+ useFinetunedModel?: FinetunedVertexModel | undefined;
38
+ promptAiSdk: PromptAiSdkFn;
39
+ logger: Logger;
40
+ } & ParamsExcluding<PromptAiSdkFn, 'messages'>): Promise<string>;
@@ -0,0 +1,49 @@
1
+ import type { ClientEnv, CiEnv } from '@levelcode/common/types/contracts/env';
2
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
3
+ interface LevelCodeWebApiEnv {
4
+ clientEnv: ClientEnv;
5
+ ciEnv: CiEnv;
6
+ }
7
+ export declare function callWebSearchAPI(params: {
8
+ query: string;
9
+ depth?: 'standard' | 'deep';
10
+ repoUrl?: string | null;
11
+ fetch: typeof globalThis.fetch;
12
+ logger: Logger;
13
+ env: LevelCodeWebApiEnv;
14
+ baseUrl?: string;
15
+ apiKey?: string;
16
+ }): Promise<{
17
+ result?: string;
18
+ error?: string;
19
+ creditsUsed?: number;
20
+ }>;
21
+ export declare function callDocsSearchAPI(params: {
22
+ libraryTitle: string;
23
+ topic?: string;
24
+ maxTokens?: number;
25
+ repoUrl?: string | null;
26
+ fetch: typeof globalThis.fetch;
27
+ logger: Logger;
28
+ env: LevelCodeWebApiEnv;
29
+ baseUrl?: string;
30
+ apiKey?: string;
31
+ }): Promise<{
32
+ documentation?: string;
33
+ error?: string;
34
+ creditsUsed?: number;
35
+ }>;
36
+ export declare function callTokenCountAPI(params: {
37
+ messages: unknown[];
38
+ system?: string;
39
+ model?: string;
40
+ fetch: typeof globalThis.fetch;
41
+ logger: Logger;
42
+ env: LevelCodeWebApiEnv;
43
+ baseUrl?: string;
44
+ apiKey?: string;
45
+ }): Promise<{
46
+ inputTokens?: number;
47
+ error?: string;
48
+ }>;
49
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
2
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
3
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
4
+ /**
5
+ * Applies code edits using Relace AI, with fallback to o3-mini on failure.
6
+ *
7
+ * @returns The updated code with edits applied.
8
+ * @throws {Error} When the request is aborted by user. Check with `isAbortError()`. Aborts are not retried.
9
+ */
10
+ export declare function promptRelaceAI(params: {
11
+ initialCode: string;
12
+ editSnippet: string;
13
+ instructions: string | undefined;
14
+ promptAiSdk: PromptAiSdkFn;
15
+ logger: Logger;
16
+ } & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<string>;
@@ -0,0 +1,29 @@
1
+ import { loopAgentSteps } from './run-agent-step';
2
+ import { getAgentTemplate } from './templates/agent-registry';
3
+ import type { AgentTemplate } from './templates/types';
4
+ import type { ClientAction } from '@levelcode/common/actions';
5
+ import type { RequestToolCallFn, SendActionFn } from '@levelcode/common/types/contracts/client';
6
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
7
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
8
+ import type { PrintModeEvent } from '@levelcode/common/types/print-mode';
9
+ import type { SessionState, AgentOutput } from '@levelcode/common/types/session-state';
10
+ export declare function mainPrompt(params: {
11
+ action: ClientAction<'prompt'>;
12
+ onResponseChunk: (chunk: string | PrintModeEvent) => void;
13
+ localAgentTemplates: Record<string, AgentTemplate>;
14
+ requestToolCall: RequestToolCallFn;
15
+ logger: Logger;
16
+ } & ParamsExcluding<typeof loopAgentSteps, 'userInputId' | 'spawnParams' | 'agentState' | 'prompt' | 'content' | 'agentType' | 'fingerprintId' | 'fileContext' | 'ancestorRunIds'> & ParamsExcluding<typeof getAgentTemplate, 'agentId'>): Promise<{
17
+ sessionState: SessionState;
18
+ output: AgentOutput;
19
+ }>;
20
+ export declare function callMainPrompt(params: {
21
+ action: ClientAction<'prompt'>;
22
+ promptId: string;
23
+ sendAction: SendActionFn;
24
+ logger: Logger;
25
+ signal: AbortSignal;
26
+ } & ParamsExcluding<typeof mainPrompt, 'localAgentTemplates' | 'onResponseChunk'>): Promise<{
27
+ sessionState: SessionState;
28
+ output: AgentOutput;
29
+ }>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Separator used between MCP server name and tool name.
3
+ *
4
+ * LLM APIs (OpenRouter/Anthropic) only allow tool names matching the pattern
5
+ * ^[a-zA-Z0-9_-]{1,128}$, which doesn't include forward slashes.
6
+ *
7
+ * We use double underscore as the separator since it's:
8
+ * - Allowed by the LLM API pattern
9
+ * - Unlikely to conflict with existing tool names
10
+ * - Clearly identifiable as a separator
11
+ */
12
+ export declare const MCP_TOOL_SEPARATOR = "__";
@@ -0,0 +1,10 @@
1
+ import type { AgentTemplate } from './templates/types';
2
+ import type { RequestMcpToolDataFn } from '@levelcode/common/types/contracts/client';
3
+ import type { OptionalFields } from '@levelcode/common/types/function-params';
4
+ import type { CustomToolDefinitions, ProjectFileContext } from '@levelcode/common/util/file';
5
+ export declare function getMCPToolData(params: OptionalFields<{
6
+ toolNames: AgentTemplate['toolNames'];
7
+ mcpServers: AgentTemplate['mcpServers'];
8
+ writeTo: ProjectFileContext['customToolDefinitions'];
9
+ requestMcpToolData: RequestMcpToolDataFn;
10
+ }, 'writeTo'>): Promise<CustomToolDefinitions>;
@@ -0,0 +1,56 @@
1
+ import { type PromptResult } from '@levelcode/common/util/error';
2
+ import { fastRewrite, shouldAddFilePlaceholders } from './fast-rewrite';
3
+ import { retryDiffBlocksPrompt } from './generate-diffs-prompt';
4
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
5
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
6
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
7
+ import type { Message } from '@levelcode/common/types/messages/levelcode-message';
8
+ type WriteFileSuccess = {
9
+ tool: 'write_file';
10
+ path: string;
11
+ content: string;
12
+ patch: string | undefined;
13
+ messages: string[];
14
+ };
15
+ type WriteFileError = {
16
+ tool: 'write_file';
17
+ path: string;
18
+ error: string;
19
+ };
20
+ export type WriteFileResult = WriteFileSuccess | WriteFileError;
21
+ /**
22
+ * Processes a file block from the LLM response, applying edits to create updated file content.
23
+ *
24
+ * Returns a PromptResult to explicitly handle the abort case:
25
+ * - `{ aborted: true }` when the user cancels the operation
26
+ * - `{ aborted: false, value: WriteFileResult }` on success or recoverable error
27
+ */
28
+ export declare function processFileBlock(params: {
29
+ path: string;
30
+ initialContentPromise: Promise<string | null>;
31
+ newContent: string;
32
+ messages: Message[];
33
+ fullResponse: string;
34
+ lastUserPrompt: string | undefined;
35
+ clientSessionId: string;
36
+ fingerprintId: string;
37
+ userInputId: string;
38
+ userId: string | undefined;
39
+ logger: Logger;
40
+ } & ParamsExcluding<typeof handleLargeFile, 'oldContent' | 'editSnippet' | 'filePath'> & ParamsExcluding<typeof fastRewrite, 'initialContent' | 'editSnippet' | 'filePath' | 'userMessage'> & ParamsExcluding<typeof shouldAddFilePlaceholders, 'filePath' | 'oldContent' | 'rewrittenNewContent' | 'messageHistory'>): Promise<PromptResult<WriteFileResult>>;
41
+ /**
42
+ * Handles large file edits by generating SEARCH/REPLACE blocks.
43
+ *
44
+ * Returns a PromptResult to explicitly handle the abort case:
45
+ * - `{ aborted: true }` when the user cancels the operation
46
+ * - `{ aborted: false, value: string }` on success
47
+ * - `{ aborted: false, value: null }` if diff blocks failed to match after retry
48
+ */
49
+ export declare function handleLargeFile(params: {
50
+ oldContent: string;
51
+ editSnippet: string;
52
+ filePath: string;
53
+ logger: Logger;
54
+ promptAiSdk: PromptAiSdkFn;
55
+ } & ParamsExcluding<typeof retryDiffBlocksPrompt, 'oldContent' | 'diffBlocksThatDidntMatch'> & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<PromptResult<string | null>>;
56
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
2
+ export declare function processStrReplace(params: {
3
+ path: string;
4
+ replacements: {
5
+ old: string;
6
+ new: string;
7
+ allowMultiple: boolean;
8
+ }[];
9
+ initialContentPromise: Promise<string | null>;
10
+ logger: Logger;
11
+ }): Promise<{
12
+ tool: 'str_replace';
13
+ path: string;
14
+ content: string;
15
+ patch: string;
16
+ messages: string[];
17
+ } | {
18
+ tool: 'str_replace';
19
+ path: string;
20
+ error: string;
21
+ }>;
@@ -0,0 +1,28 @@
1
+ import type { AgentTemplate } from './templates/types';
2
+ import type { TrackEventFn } from '@levelcode/common/types/contracts/analytics';
3
+ import type { SendActionFn } from '@levelcode/common/types/contracts/client';
4
+ import type { PromptAiSdkStreamFn } from '@levelcode/common/types/contracts/llm';
5
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
6
+ import type { Message } from '@levelcode/common/types/messages/levelcode-message';
7
+ import type { ToolSet } from 'ai';
8
+ export declare const getAgentStreamFromTemplate: (params: {
9
+ agentId?: string;
10
+ apiKey: string;
11
+ clientSessionId: string;
12
+ costMode?: string;
13
+ fingerprintId: string;
14
+ includeCacheControl?: boolean;
15
+ localAgentTemplates: Record<string, AgentTemplate>;
16
+ logger: Logger;
17
+ messages: Message[];
18
+ runId: string;
19
+ signal: AbortSignal;
20
+ template: AgentTemplate;
21
+ tools: ToolSet;
22
+ userId: string | undefined;
23
+ userInputId: string;
24
+ onCostCalculated?: (credits: number) => Promise<void>;
25
+ promptAiSdkStream: PromptAiSdkStreamFn;
26
+ sendAction: SendActionFn;
27
+ trackEvent: TrackEventFn;
28
+ }) => ReturnType<PromptAiSdkStreamFn>;
@@ -0,0 +1,73 @@
1
+ import { type ToolSet } from 'ai';
2
+ import { getMCPToolData } from './mcp';
3
+ import { getAgentStreamFromTemplate } from './prompt-agent-stream';
4
+ import { runProgrammaticStep } from './run-programmatic-step';
5
+ import { getAgentTemplate } from './templates/agent-registry';
6
+ import { getAgentPrompt } from './templates/strings';
7
+ import { processStream } from './tools/stream-parser';
8
+ import type { AgentTemplate } from '@levelcode/common/types/agent-template';
9
+ import type { TrackEventFn } from '@levelcode/common/types/contracts/analytics';
10
+ import type { AddAgentStepFn, FinishAgentRunFn, StartAgentRunFn } from '@levelcode/common/types/contracts/database';
11
+ import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
12
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
13
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
14
+ import type { TextPart, ImagePart } from '@levelcode/common/types/messages/content-part';
15
+ import type { PrintModeEvent } from '@levelcode/common/types/print-mode';
16
+ import type { AgentTemplateType, AgentState, AgentOutput } from '@levelcode/common/types/session-state';
17
+ import type { CustomToolDefinitions, ProjectFileContext } from '@levelcode/common/util/file';
18
+ declare function additionalToolDefinitions(params: {
19
+ agentTemplate: AgentTemplate;
20
+ fileContext: ProjectFileContext;
21
+ } & ParamsExcluding<typeof getMCPToolData, 'toolNames' | 'mcpServers' | 'writeTo'>): Promise<CustomToolDefinitions>;
22
+ export declare const runAgentStep: (params: {
23
+ userId: string | undefined;
24
+ userInputId: string;
25
+ clientSessionId: string;
26
+ costMode?: string;
27
+ fingerprintId: string;
28
+ repoId: string | undefined;
29
+ onResponseChunk: (chunk: string | PrintModeEvent) => void;
30
+ agentType: AgentTemplateType;
31
+ agentTemplate: AgentTemplate;
32
+ fileContext: ProjectFileContext;
33
+ agentState: AgentState;
34
+ localAgentTemplates: Record<string, AgentTemplate>;
35
+ prompt: string | undefined;
36
+ spawnParams: Record<string, any> | undefined;
37
+ system: string;
38
+ n?: number;
39
+ trackEvent: TrackEventFn;
40
+ promptAiSdk: PromptAiSdkFn;
41
+ } & ParamsExcluding<typeof processStream, "agentContext" | "agentState" | "agentStepId" | "agentTemplate" | "fullResponse" | "messages" | "onCostCalculated" | "repoId" | "stream"> & ParamsExcluding<typeof getAgentStreamFromTemplate, "agentId" | "includeCacheControl" | "messages" | "onCostCalculated" | "template"> & ParamsExcluding<typeof getAgentTemplate, "agentId"> & ParamsExcluding<typeof getAgentPrompt, "agentTemplate" | "promptType" | "agentState" | "agentTemplates"> & ParamsExcluding<typeof getMCPToolData, "toolNames" | "mcpServers" | "writeTo"> & ParamsExcluding<PromptAiSdkFn, "messages" | "model" | "onCostCalculated" | "n">) => Promise<{
42
+ agentState: AgentState;
43
+ fullResponse: string;
44
+ shouldEndTurn: boolean;
45
+ messageId: string | null;
46
+ nResponses?: string[];
47
+ }>;
48
+ export declare function loopAgentSteps(params: {
49
+ addAgentStep: AddAgentStepFn;
50
+ agentState: AgentState;
51
+ agentType: AgentTemplateType;
52
+ clearUserPromptMessagesAfterResponse?: boolean;
53
+ clientSessionId: string;
54
+ content?: Array<TextPart | ImagePart>;
55
+ costMode?: string;
56
+ fileContext: ProjectFileContext;
57
+ finishAgentRun: FinishAgentRunFn;
58
+ localAgentTemplates: Record<string, AgentTemplate>;
59
+ logger: Logger;
60
+ parentSystemPrompt?: string;
61
+ parentTools?: ToolSet;
62
+ prompt: string | undefined;
63
+ signal: AbortSignal;
64
+ spawnParams: Record<string, any> | undefined;
65
+ startAgentRun: StartAgentRunFn;
66
+ userId: string | undefined;
67
+ userInputId: string;
68
+ agentTemplate?: AgentTemplate;
69
+ } & ParamsExcluding<typeof additionalToolDefinitions, 'agentTemplate'> & ParamsExcluding<typeof runProgrammaticStep, 'agentState' | 'onCostCalculated' | 'prompt' | 'runId' | 'stepNumber' | 'stepsComplete' | 'system' | 'template' | 'toolCallParams' | 'tools'> & ParamsExcluding<typeof getAgentTemplate, 'agentId'> & ParamsExcluding<typeof getAgentPrompt, 'agentTemplate' | 'promptType' | 'agentTemplates' | 'additionalToolDefinitions'> & ParamsExcluding<typeof getMCPToolData, 'toolNames' | 'mcpServers' | 'writeTo'> & ParamsExcluding<StartAgentRunFn, 'agentId' | 'ancestorRunIds'> & ParamsExcluding<FinishAgentRunFn, 'runId' | 'status' | 'totalSteps' | 'directCredits' | 'totalCredits'> & ParamsExcluding<typeof runAgentStep, 'additionalToolDefinitions' | 'agentState' | 'agentTemplate' | 'prompt' | 'runId' | 'spawnParams' | 'system' | 'tools'> & ParamsExcluding<AddAgentStepFn, 'agentRunId' | 'stepNumber' | 'credits' | 'childRunIds' | 'messageId' | 'status' | 'startTime'>): Promise<{
70
+ agentState: AgentState;
71
+ output: AgentOutput;
72
+ }>;
73
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { ExecuteToolCallParams } from './tools/tool-executor';
2
+ import type { AgentTemplate, PublicAgentState } from '@levelcode/common/types/agent-template';
3
+ import type { HandleStepsLogChunkFn, SendActionFn } from '@levelcode/common/types/contracts/client';
4
+ import type { AddAgentStepFn } from '@levelcode/common/types/contracts/database';
5
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
6
+ import type { ParamsExcluding } from '@levelcode/common/types/function-params';
7
+ import type { PrintModeEvent } from '@levelcode/common/types/print-mode';
8
+ import type { AgentState } from '@levelcode/common/types/session-state';
9
+ export declare const runIdToStepAll: Set<string>;
10
+ export declare function clearAgentGeneratorCache(params: {
11
+ logger: Logger;
12
+ }): void;
13
+ export declare function runProgrammaticStep(params: {
14
+ addAgentStep: AddAgentStepFn;
15
+ agentState: AgentState;
16
+ clientSessionId: string;
17
+ fingerprintId: string;
18
+ handleStepsLogChunk: HandleStepsLogChunkFn;
19
+ localAgentTemplates: Record<string, AgentTemplate>;
20
+ logger: Logger;
21
+ nResponses?: string[];
22
+ onResponseChunk: (chunk: string | PrintModeEvent) => void;
23
+ prompt: string | undefined;
24
+ repoId: string | undefined;
25
+ repoUrl: string | undefined;
26
+ stepNumber: number;
27
+ stepsComplete: boolean;
28
+ template: AgentTemplate;
29
+ toolCallParams: Record<string, any> | undefined;
30
+ sendAction: SendActionFn;
31
+ system: string | undefined;
32
+ userId: string | undefined;
33
+ userInputId: string;
34
+ } & Omit<ExecuteToolCallParams, 'toolName' | 'input' | 'autoInsertEndStepParam' | 'excludeToolFromMessageHistory' | 'agentContext' | 'agentStepId' | 'agentTemplate' | 'fullResponse' | 'previousToolCallFinished' | 'fileProcessingState' | 'toolCallId' | 'toolCalls' | 'toolResults' | 'toolResultsToAddAfterStream'> & ParamsExcluding<AddAgentStepFn, 'agentRunId' | 'stepNumber' | 'credits' | 'childRunIds' | 'status' | 'startTime' | 'messageId'>): Promise<{
35
+ agentState: AgentState;
36
+ endTurn: boolean;
37
+ stepNumber: number;
38
+ generateN?: number;
39
+ }>;
40
+ export declare const getPublicAgentState: (agentState: AgentState & Required<Pick<AgentState, "runId">>) => PublicAgentState;
@@ -0,0 +1,19 @@
1
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
2
+ import type { ProjectFileContext } from '@levelcode/common/util/file';
3
+ export declare const knowledgeFilesPrompt: string;
4
+ export declare const additionalSystemPrompts: {
5
+ readonly '/init': string;
6
+ readonly init: string;
7
+ readonly '/export': string;
8
+ readonly export: string;
9
+ readonly '/compact': string;
10
+ readonly compact: string;
11
+ };
12
+ export declare const getProjectFileTreePrompt: (params: {
13
+ fileContext: ProjectFileContext;
14
+ fileTreeTokenBudget: number;
15
+ mode: "search" | "agent";
16
+ logger: Logger;
17
+ }) => string;
18
+ export declare const getSystemInfoPrompt: (fileContext: ProjectFileContext) => string;
19
+ export declare const getGitChangesPrompt: (fileContext: ProjectFileContext) => string;