@levelcode/sdk 0.0.4 → 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 +1958 -917
  130. package/dist/index.cjs.map +25 -10
  131. package/dist/index.mjs +2392 -1351
  132. package/dist/index.mjs.map +25 -10
  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,156 @@
1
+ /**
2
+ * Backend Agent Template Types
3
+ *
4
+ * This file provides backend-compatible agent template types with strict validation.
5
+ * It imports base types from the user-facing template to eliminate duplication.
6
+ */
7
+ import { z } from 'zod/v4';
8
+ import type { MCPConfig } from './mcp';
9
+ import type { Model } from '../old-constants';
10
+ import type { ToolResultOutput } from './messages/content-part';
11
+ import type { AgentState, AgentTemplateType } from './session-state';
12
+ import type { ToolCall, AgentState as PublicAgentState } from '../templates/initial-agents-dir/types/agent-definition';
13
+ import type { Logger } from '../templates/initial-agents-dir/types/util-types';
14
+ import type { ToolName } from '../tools/constants';
15
+ export type AgentId = `${string}/${string}@${number}.${number}.${number}`;
16
+ export type OpenRouterReasoningOptions = {
17
+ /**
18
+ * https://openrouter.ai/docs/use-cases/reasoning-tokens
19
+ * One of `max_tokens` or `effort` is required.
20
+ * If `exclude` is true, reasoning will be removed from the response. Default is false.
21
+ */
22
+ enabled?: boolean;
23
+ exclude?: boolean;
24
+ } & ({
25
+ max_tokens: number;
26
+ } | {
27
+ effort: 'high' | 'medium' | 'low' | 'minimal' | 'none';
28
+ });
29
+ export type OpenRouterProviderRoutingOptions = {
30
+ /**
31
+ * List of provider slugs to try in order (e.g. ["anthropic", "openai"])
32
+ */
33
+ order?: string[];
34
+ /**
35
+ * Whether to allow backup providers when primary is unavailable (default: true)
36
+ */
37
+ allow_fallbacks?: boolean;
38
+ /**
39
+ * Only use providers that support all parameters in your request (default: false)
40
+ */
41
+ require_parameters?: boolean;
42
+ /**
43
+ * Control whether to use providers that may store data
44
+ */
45
+ data_collection?: 'allow' | 'deny';
46
+ /**
47
+ * List of provider slugs to allow for this request
48
+ */
49
+ only?: string[];
50
+ /**
51
+ * List of provider slugs to skip for this request
52
+ */
53
+ ignore?: string[];
54
+ /**
55
+ * List of quantization levels to filter by (e.g. ["int4", "int8"])
56
+ */
57
+ quantizations?: Array<'int4' | 'int8' | 'fp4' | 'fp6' | 'fp8' | 'fp16' | 'bf16' | 'fp32' | 'unknown'>;
58
+ /**
59
+ * Sort providers by price, throughput, or latency
60
+ */
61
+ sort?: 'price' | 'throughput' | 'latency';
62
+ /**
63
+ * Maximum pricing you want to pay for this request
64
+ */
65
+ max_price?: {
66
+ prompt?: number | string;
67
+ completion?: number | string;
68
+ image?: number | string;
69
+ audio?: number | string;
70
+ request?: number | string;
71
+ };
72
+ };
73
+ export type OpenRouterProviderOptions = {
74
+ models?: string[];
75
+ reasoning?: OpenRouterReasoningOptions;
76
+ /**
77
+ * A unique identifier representing your end-user, which can
78
+ * help OpenRouter to monitor and detect abuse.
79
+ */
80
+ user?: string;
81
+ };
82
+ /**
83
+ * Backend agent template with strict validation and Zod schemas
84
+ * Extends the user-facing AgentDefinition but with backend-specific requirements
85
+ */
86
+ export type AgentTemplate<P = string | undefined, T = Record<string, any> | undefined> = {
87
+ id: AgentTemplateType;
88
+ displayName: string;
89
+ model: Model;
90
+ reasoningOptions?: OpenRouterReasoningOptions;
91
+ providerOptions?: OpenRouterProviderRoutingOptions;
92
+ mcpServers: Record<string, MCPConfig>;
93
+ toolNames: (ToolName | (string & {}))[];
94
+ spawnableAgents: AgentTemplateType[];
95
+ spawnerPrompt?: string;
96
+ systemPrompt: string;
97
+ instructionsPrompt: string;
98
+ stepPrompt: string;
99
+ parentInstructions?: Record<string, string>;
100
+ inputSchema: {
101
+ prompt?: z.ZodSchema<P>;
102
+ params?: z.ZodSchema<T>;
103
+ };
104
+ includeMessageHistory: boolean;
105
+ inheritParentSystemPrompt: boolean;
106
+ outputMode: 'last_message' | 'all_messages' | 'structured_output';
107
+ outputSchema?: z.ZodSchema<any>;
108
+ handleSteps?: StepHandler<P, T> | string;
109
+ };
110
+ export type StepText = {
111
+ type: 'STEP_TEXT';
112
+ text: string;
113
+ };
114
+ export type GenerateN = {
115
+ type: 'GENERATE_N';
116
+ n: number;
117
+ };
118
+ export declare const StepTextSchema: z.ZodObject<{
119
+ type: z.ZodLiteral<"STEP_TEXT">;
120
+ text: z.ZodString;
121
+ }, z.core.$strip>;
122
+ export declare const GenerateNSchema: z.ZodObject<{
123
+ type: z.ZodLiteral<"GENERATE_N">;
124
+ n: z.ZodNumber;
125
+ }, z.core.$strip>;
126
+ export declare const HandleStepsToolCallSchema: z.ZodObject<{
127
+ toolName: z.ZodString;
128
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
129
+ includeToolCall: z.ZodOptional<z.ZodBoolean>;
130
+ }, z.core.$strip>;
131
+ export declare const HandleStepsYieldValueSchema: z.ZodUnion<readonly [z.ZodLiteral<"STEP">, z.ZodLiteral<"STEP_ALL">, z.ZodObject<{
132
+ type: z.ZodLiteral<"STEP_TEXT">;
133
+ text: z.ZodString;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ type: z.ZodLiteral<"GENERATE_N">;
136
+ n: z.ZodNumber;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ toolName: z.ZodString;
139
+ input: z.ZodRecord<z.ZodString, z.ZodAny>;
140
+ includeToolCall: z.ZodOptional<z.ZodBoolean>;
141
+ }, z.core.$strip>]>;
142
+ export type HandleStepsYieldValue = z.infer<typeof HandleStepsYieldValueSchema>;
143
+ export type StepGenerator = Generator<Omit<ToolCall, 'toolCallId'> | 'STEP' | 'STEP_ALL' | StepText | GenerateN, // Generic tool call type
144
+ void, {
145
+ agentState: PublicAgentState;
146
+ toolResult: ToolResultOutput[];
147
+ stepsComplete: boolean;
148
+ nResponses?: string[];
149
+ }>;
150
+ export type StepHandler<P = string | undefined, T = Record<string, any> | undefined> = (context: {
151
+ agentState: AgentState;
152
+ prompt: P;
153
+ params: T;
154
+ logger: Logger;
155
+ }) => StepGenerator;
156
+ export { Logger, PublicAgentState };
@@ -0,0 +1,36 @@
1
+ import type { TrackEventFn } from './analytics';
2
+ import type { ConsumeCreditsWithFallbackFn } from './billing';
3
+ import type { HandleStepsLogChunkFn, RequestFilesFn, RequestMcpToolDataFn, RequestOptionalFileFn, RequestToolCallFn, SendActionFn, SendSubagentChunkFn } from './client';
4
+ import type { AddAgentStepFn, DatabaseAgentCache, FetchAgentFromDatabaseFn, FinishAgentRunFn, GetUserInfoFromApiKeyFn, StartAgentRunFn } from './database';
5
+ import type { ClientEnv, CiEnv } from './env';
6
+ import type { PromptAiSdkFn, PromptAiSdkStreamFn, PromptAiSdkStructuredFn } from './llm';
7
+ import type { Logger } from './logger';
8
+ /** Shared dependencies */
9
+ export type AgentRuntimeDeps = {
10
+ clientEnv: ClientEnv;
11
+ ciEnv: CiEnv;
12
+ getUserInfoFromApiKey: GetUserInfoFromApiKeyFn;
13
+ fetchAgentFromDatabase: FetchAgentFromDatabaseFn;
14
+ startAgentRun: StartAgentRunFn;
15
+ finishAgentRun: FinishAgentRunFn;
16
+ addAgentStep: AddAgentStepFn;
17
+ consumeCreditsWithFallback: ConsumeCreditsWithFallbackFn;
18
+ promptAiSdkStream: PromptAiSdkStreamFn;
19
+ promptAiSdk: PromptAiSdkFn;
20
+ promptAiSdkStructured: PromptAiSdkStructuredFn;
21
+ databaseAgentCache: DatabaseAgentCache;
22
+ trackEvent: TrackEventFn;
23
+ logger: Logger;
24
+ fetch: typeof globalThis.fetch;
25
+ };
26
+ /** Per-run dependencies */
27
+ export type AgentRuntimeScopedDeps = {
28
+ handleStepsLogChunk: HandleStepsLogChunkFn;
29
+ requestToolCall: RequestToolCallFn;
30
+ requestMcpToolData: RequestMcpToolDataFn;
31
+ requestFiles: RequestFilesFn;
32
+ requestOptionalFile: RequestOptionalFileFn;
33
+ sendAction: SendActionFn;
34
+ sendSubagentChunk: SendSubagentChunkFn;
35
+ apiKey: string;
36
+ };
@@ -0,0 +1,8 @@
1
+ import type { Logger } from './logger';
2
+ import type { AnalyticsEvent } from '../../constants/analytics-events';
3
+ export type TrackEventFn = (params: {
4
+ event: AnalyticsEvent;
5
+ userId: string;
6
+ properties?: Record<string, any>;
7
+ logger: Logger;
8
+ }) => void;
@@ -0,0 +1,40 @@
1
+ import type { Logger } from './logger';
2
+ import type { ErrorOr } from '../../util/error';
3
+ export type GetUserUsageDataFn = (params: {
4
+ userId: string;
5
+ logger: Logger;
6
+ }) => Promise<{
7
+ usageThisCycle: number;
8
+ balance: {
9
+ totalRemaining: number;
10
+ totalDebt: number;
11
+ netBalance: number;
12
+ breakdown: Record<string, number>;
13
+ };
14
+ nextQuotaReset: string;
15
+ autoTopupTriggered?: boolean;
16
+ autoTopupEnabled?: boolean;
17
+ }>;
18
+ export type ConsumeCreditsWithFallbackFn = (params: {
19
+ userId: string;
20
+ creditsToCharge: number;
21
+ repoUrl?: string | null;
22
+ context: string;
23
+ logger: Logger;
24
+ }) => Promise<ErrorOr<CreditFallbackResult>>;
25
+ export type CreditFallbackResult = {
26
+ organizationId?: string;
27
+ organizationName?: string;
28
+ chargedToOrganization: boolean;
29
+ };
30
+ export type GetOrganizationUsageResponseFn = (params: {
31
+ organizationId: string;
32
+ userId: string;
33
+ logger: Logger;
34
+ }) => Promise<{
35
+ type: 'usage-response';
36
+ usage: number;
37
+ remainingBalance: number;
38
+ balanceBreakdown: Record<string, never>;
39
+ next_quota_reset: null;
40
+ }>;
@@ -0,0 +1,45 @@
1
+ import type { ServerAction } from '../../actions';
2
+ import type { MCPConfig } from '../mcp';
3
+ import type { ToolResultOutput } from '../messages/content-part';
4
+ export type RequestToolCallFn = (params: {
5
+ userInputId: string;
6
+ toolName: string;
7
+ input: Record<string, any> & {
8
+ timeout_seconds?: number;
9
+ };
10
+ mcpConfig?: MCPConfig;
11
+ }) => Promise<{
12
+ output: ToolResultOutput[];
13
+ }>;
14
+ export type RequestMcpToolDataFn = (params: {
15
+ mcpConfig: MCPConfig;
16
+ toolNames: string[] | null;
17
+ }) => Promise<{
18
+ name: string;
19
+ description?: string;
20
+ inputSchema: unknown;
21
+ }[]>;
22
+ export type RequestFilesFn = (params: {
23
+ filePaths: string[];
24
+ }) => Promise<Record<string, string | null>>;
25
+ export type RequestOptionalFileFn = (params: {
26
+ filePath: string;
27
+ }) => Promise<string | null>;
28
+ export type SendSubagentChunkFn = (params: {
29
+ userInputId: string;
30
+ agentId: string;
31
+ agentType: string;
32
+ chunk: string;
33
+ prompt?: string | undefined;
34
+ forwardToPrompt?: boolean;
35
+ }) => void;
36
+ export type HandleStepsLogChunkFn = (params: {
37
+ userInputId: string;
38
+ runId: string;
39
+ level: 'debug' | 'info' | 'warn' | 'error';
40
+ data: unknown;
41
+ message?: string;
42
+ }) => void;
43
+ export type SendActionFn = (params: {
44
+ action: ServerAction;
45
+ }) => void;
@@ -0,0 +1,80 @@
1
+ import type { AgentTemplate } from '@levelcode/common/types/agent-template';
2
+ import type { Logger } from '@levelcode/common/types/contracts/logger';
3
+ type User = {
4
+ id: string;
5
+ email: string;
6
+ discord_id: string | null;
7
+ referral_code: string | null;
8
+ stripe_customer_id: string | null;
9
+ banned: boolean;
10
+ };
11
+ export declare const userColumns: readonly ["id", "email", "discord_id", "referral_code", "stripe_customer_id", "banned"];
12
+ export type UserColumn = keyof User;
13
+ export type GetUserInfoFromApiKeyInput<T extends UserColumn> = {
14
+ apiKey: string;
15
+ fields: readonly T[];
16
+ logger: Logger;
17
+ };
18
+ export type GetUserInfoFromApiKeyOutput<T extends UserColumn> = Promise<{
19
+ [K in T]: User[K];
20
+ } | null>;
21
+ export type GetUserInfoFromApiKeyFn = <T extends UserColumn>(params: GetUserInfoFromApiKeyInput<T>) => GetUserInfoFromApiKeyOutput<T>;
22
+ type AgentRun = {
23
+ agent_id: string;
24
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
25
+ };
26
+ export type AgentRunColumn = keyof AgentRun;
27
+ export type GetAgentRunFromIdInput<T extends AgentRunColumn> = {
28
+ runId: string;
29
+ userId: string;
30
+ fields: readonly T[];
31
+ };
32
+ export type GetAgentRunFromIdOutput<T extends AgentRunColumn> = Promise<{
33
+ [K in T]: AgentRun[K];
34
+ } | null>;
35
+ export type GetAgentRunFromIdFn = <T extends AgentRunColumn>(params: GetAgentRunFromIdInput<T>) => GetAgentRunFromIdOutput<T>;
36
+ /**
37
+ * Fetch and validate an agent from the database by `publisher/agent-id[@version]` format
38
+ */
39
+ export type FetchAgentFromDatabaseFn = (params: {
40
+ apiKey: string;
41
+ parsedAgentId: {
42
+ publisherId: string;
43
+ agentId: string;
44
+ version?: string;
45
+ };
46
+ logger: Logger;
47
+ }) => Promise<AgentTemplate | null>;
48
+ export type StartAgentRunFn = (params: {
49
+ apiKey: string;
50
+ userId?: string;
51
+ agentId: string;
52
+ ancestorRunIds: string[];
53
+ logger: Logger;
54
+ }) => Promise<string | null>;
55
+ export type FinishAgentRunFn = (params: {
56
+ apiKey: string;
57
+ userId: string | undefined;
58
+ runId: string;
59
+ status: 'completed' | 'failed' | 'cancelled';
60
+ totalSteps: number;
61
+ directCredits: number;
62
+ totalCredits: number;
63
+ errorMessage?: string;
64
+ logger: Logger;
65
+ }) => Promise<void>;
66
+ export type AddAgentStepFn = (params: {
67
+ apiKey: string;
68
+ userId: string | undefined;
69
+ agentRunId: string;
70
+ stepNumber: number;
71
+ credits?: number;
72
+ childRunIds?: string[];
73
+ messageId: string | null;
74
+ status?: 'running' | 'completed' | 'skipped';
75
+ errorMessage?: string;
76
+ startTime: Date;
77
+ logger: Logger;
78
+ }) => Promise<string | null>;
79
+ export type DatabaseAgentCache = Map<string, AgentTemplate | null>;
80
+ export {};
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Environment variable contract types for dependency injection.
3
+ *
4
+ * ARCHITECTURE:
5
+ * =============
6
+ * Base types (defined here in common) that packages extend:
7
+ *
8
+ * ┌─────────────────────────────────────────────────────────────────┐
9
+ * │ BASE TYPES (common) │
10
+ * ├─────────────────────────────────────────────────────────────────┤
11
+ * │ BaseProcessEnv - OS/runtime vars (SHELL, HOME, TERM, etc.) │
12
+ * │ BaseCiEnv - CI vars (CI, GITHUB_ACTIONS, etc.) │
13
+ * │ ClientEnv - Public vars (NEXT_PUBLIC_*) from env-schema │
14
+ * └─────────────────────────────────────────────────────────────────┘
15
+ * │
16
+ * extends │
17
+ * ▼
18
+ * ┌─────────────────────────────────────────────────────────────────┐
19
+ * │ PACKAGE-SPECIFIC ENVS │
20
+ * ├─────────────────────────────────────────────────────────────────┤
21
+ * │ CLI: CliProcessEnv = BaseProcessEnv & { CLI-specific } │
22
+ * │ SDK: SdkProcessEnv = BaseProcessEnv & { SDK-specific } │
23
+ * │ Server: ServerEnv = ClientEnv & { server secrets } │
24
+ * │ Evals: EvalsCiEnv = BaseCiEnv & { eval-specific } │
25
+ * └─────────────────────────────────────────────────────────────────┘
26
+ *
27
+ * Each package imports the base types and extends them with package-specific vars.
28
+ */
29
+ import type { ClientEnv } from '../../env-schema';
30
+ export type { ClientEnv } from '../../env-schema';
31
+ /**
32
+ * Base CI environment variables.
33
+ * Used in CI/CD pipelines across all packages.
34
+ */
35
+ export type BaseCiEnv = {
36
+ CI?: string;
37
+ GITHUB_ACTIONS?: string;
38
+ RENDER?: string;
39
+ IS_PULL_REQUEST?: string;
40
+ };
41
+ /**
42
+ * Base runtime environment variables.
43
+ * These are OS-level env vars common across all packages.
44
+ */
45
+ export type BaseEnv = {
46
+ SHELL?: string;
47
+ COMSPEC?: string;
48
+ HOME?: string;
49
+ USERPROFILE?: string;
50
+ APPDATA?: string;
51
+ XDG_CONFIG_HOME?: string;
52
+ TERM?: string;
53
+ TERM_PROGRAM?: string;
54
+ TERM_BACKGROUND?: string;
55
+ TERMINAL_EMULATOR?: string;
56
+ COLORFGBG?: string;
57
+ NODE_ENV?: string;
58
+ NODE_PATH?: string;
59
+ PATH?: string;
60
+ };
61
+ /**
62
+ * Extended CI env with LevelCode-specific CI vars.
63
+ * Used by agent-runtime and server code.
64
+ */
65
+ export type CiEnv = BaseCiEnv & {
66
+ LEVELCODE_GITHUB_TOKEN?: string;
67
+ LEVELCODE_API_KEY?: string;
68
+ EVAL_RESULTS_EMAIL?: string;
69
+ };
70
+ /**
71
+ * Extended process env with terminal/IDE detection.
72
+ * This is the full ProcessEnv used by CLI and SDK.
73
+ * Packages can import this or create their own extensions of BaseProcessEnv.
74
+ */
75
+ export type ProcessEnv = BaseEnv & {
76
+ KITTY_WINDOW_ID?: string;
77
+ SIXEL_SUPPORT?: string;
78
+ ZED_NODE_ENV?: string;
79
+ VSCODE_THEME_KIND?: string;
80
+ VSCODE_COLOR_THEME_KIND?: string;
81
+ VSCODE_GIT_IPC_HANDLE?: string;
82
+ VSCODE_PID?: string;
83
+ VSCODE_CWD?: string;
84
+ VSCODE_NLS_CONFIG?: string;
85
+ CURSOR_PORT?: string;
86
+ CURSOR?: string;
87
+ JETBRAINS_REMOTE_RUN?: string;
88
+ IDEA_INITIAL_DIRECTORY?: string;
89
+ IDE_CONFIG_DIR?: string;
90
+ JB_IDE_CONFIG_DIR?: string;
91
+ VISUAL?: string;
92
+ EDITOR?: string;
93
+ LEVELCODE_CLI_EDITOR?: string;
94
+ LEVELCODE_EDITOR?: string;
95
+ OPEN_TUI_THEME?: string;
96
+ OPENTUI_THEME?: string;
97
+ LEVELCODE_IS_BINARY?: string;
98
+ LEVELCODE_CLI_VERSION?: string;
99
+ LEVELCODE_CLI_TARGET?: string;
100
+ LEVELCODE_RG_PATH?: string;
101
+ LEVELCODE_WASM_DIR?: string;
102
+ VERBOSE?: string;
103
+ OVERRIDE_TARGET?: string;
104
+ OVERRIDE_PLATFORM?: string;
105
+ OVERRIDE_ARCH?: string;
106
+ };
107
+ /**
108
+ * Function type for getting a client env value.
109
+ */
110
+ export type GetClientEnvFn = () => ClientEnv;
111
+ /**
112
+ * Function type for getting base env values.
113
+ */
114
+ export type GetBaseEnvFn = () => BaseEnv;
115
+ /**
116
+ * Function type for getting full process env values.
117
+ */
118
+ export type GetProcessEnvFn = () => ProcessEnv;
119
+ /**
120
+ * Function type for getting base CI env values.
121
+ */
122
+ export type GetBaseCiEnvFn = () => BaseCiEnv;
123
+ /**
124
+ * Function type for getting extended CI env values.
125
+ */
126
+ export type GetCiEnvFn = () => CiEnv;
127
+ /**
128
+ * Base env deps - minimal set for most functions.
129
+ */
130
+ export type BaseEnvDeps = {
131
+ clientEnv: ClientEnv;
132
+ env: BaseEnv;
133
+ };
134
+ /**
135
+ * Combined env deps with full process env.
136
+ * Used in CLI and client-side code.
137
+ */
138
+ export type EnvDeps = {
139
+ clientEnv: ClientEnv;
140
+ processEnv: ProcessEnv;
141
+ };
142
+ /**
143
+ * Full env deps including CI vars.
144
+ * Note: ServerEnv is defined in packages/internal and should be imported from there.
145
+ */
146
+ export type FullEnvDeps = {
147
+ clientEnv: ClientEnv;
148
+ processEnv: ProcessEnv;
149
+ ciEnv: CiEnv;
150
+ };
@@ -0,0 +1,102 @@
1
+ import type { TrackEventFn } from './analytics';
2
+ import type { SendActionFn } from './client';
3
+ import type { OpenRouterProviderRoutingOptions, AgentTemplate } from '../agent-template';
4
+ import type { ParamsExcluding } from '../function-params';
5
+ import type { Logger } from './logger';
6
+ import type { Model } from '../../old-constants';
7
+ import type { Message } from '../messages/levelcode-message';
8
+ import type { PromptResult } from '../../util/error';
9
+ import type { generateText, streamText, ToolCallPart } from 'ai';
10
+ import type z from 'zod/v4';
11
+ export type StreamChunk = {
12
+ type: 'text';
13
+ text: string;
14
+ agentId?: string;
15
+ } | {
16
+ type: 'reasoning';
17
+ text: string;
18
+ } | Pick<ToolCallPart, 'type' | 'toolCallId' | 'toolName' | 'input' | 'providerOptions'> | {
19
+ type: 'error';
20
+ message: string;
21
+ };
22
+ export type PromptAiSdkStreamFn = (params: {
23
+ apiKey: string;
24
+ runId: string;
25
+ messages: Message[];
26
+ clientSessionId: string;
27
+ fingerprintId: string;
28
+ model: Model;
29
+ userId: string | undefined;
30
+ chargeUser?: boolean;
31
+ thinkingBudget?: number;
32
+ userInputId: string;
33
+ agentId?: string;
34
+ maxRetries?: number;
35
+ onCostCalculated?: (credits: number) => Promise<void>;
36
+ includeCacheControl?: boolean;
37
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
38
+ /** List of agents that can be spawned - used to transform agent tool calls */
39
+ spawnableAgents?: string[];
40
+ /** Map of locally available agent templates - used to transform agent tool calls */
41
+ localAgentTemplates?: Record<string, AgentTemplate>;
42
+ /** Cost mode - 'free' mode means 0 credits charged for all agents */
43
+ costMode?: string;
44
+ sendAction: SendActionFn;
45
+ logger: Logger;
46
+ trackEvent: TrackEventFn;
47
+ signal: AbortSignal;
48
+ } & ParamsExcluding<typeof streamText, 'model' | 'messages'>) => AsyncGenerator<StreamChunk, PromptResult<string | null>>;
49
+ export type PromptAiSdkFn = (params: {
50
+ apiKey: string;
51
+ runId: string;
52
+ messages: Message[];
53
+ clientSessionId: string;
54
+ fingerprintId: string;
55
+ userInputId: string;
56
+ model: Model;
57
+ userId: string | undefined;
58
+ chargeUser?: boolean;
59
+ agentId?: string;
60
+ onCostCalculated?: (credits: number) => Promise<void>;
61
+ includeCacheControl?: boolean;
62
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
63
+ maxRetries?: number;
64
+ /** Cost mode - 'free' mode means 0 credits charged for all agents */
65
+ costMode?: string;
66
+ sendAction: SendActionFn;
67
+ logger: Logger;
68
+ trackEvent: TrackEventFn;
69
+ n?: number;
70
+ signal: AbortSignal;
71
+ } & ParamsExcluding<typeof generateText, 'model' | 'messages'>) => Promise<PromptResult<string>>;
72
+ export type PromptAiSdkStructuredInput<T> = {
73
+ apiKey: string;
74
+ runId: string;
75
+ messages: Message[];
76
+ schema: z.ZodType<T>;
77
+ clientSessionId: string;
78
+ fingerprintId: string;
79
+ userInputId: string;
80
+ model: Model;
81
+ userId: string | undefined;
82
+ maxTokens?: number;
83
+ temperature?: number;
84
+ timeout?: number;
85
+ chargeUser?: boolean;
86
+ agentId?: string;
87
+ onCostCalculated?: (credits: number) => Promise<void>;
88
+ includeCacheControl?: boolean;
89
+ agentProviderOptions?: OpenRouterProviderRoutingOptions;
90
+ maxRetries?: number;
91
+ sendAction: SendActionFn;
92
+ logger: Logger;
93
+ trackEvent: TrackEventFn;
94
+ signal: AbortSignal;
95
+ };
96
+ export type PromptAiSdkStructuredOutput<T> = Promise<PromptResult<T>>;
97
+ export type PromptAiSdkStructuredFn = <T>(params: PromptAiSdkStructuredInput<T>) => PromptAiSdkStructuredOutput<T>;
98
+ export type HandleOpenRouterStreamFn = (params: {
99
+ body: any;
100
+ userId: string;
101
+ agentId: string;
102
+ }) => Promise<ReadableStream>;
@@ -0,0 +1,8 @@
1
+ export type LoggerFn = (data: unknown, msg?: string, ...args: unknown[]) => unknown;
2
+ export type Logger = {
3
+ debug: LoggerFn;
4
+ info: LoggerFn;
5
+ warn: LoggerFn;
6
+ error: LoggerFn;
7
+ };
8
+ export type LoggerWithContextFn = (context: Record<string, any>) => Logger;