@cursor/july 0.1.30 → 0.1.31

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 (392) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +10 -5
  3. package/dist/bin/agent-serve.js +4 -4
  4. package/dist/channels/github/index.d.ts +1 -1
  5. package/dist/channels/github/index.js +1 -1
  6. package/dist/channels/slack/bot-mentions.d.ts +1 -1
  7. package/dist/channels/slack/bot-mentions.d.ts.map +1 -1
  8. package/dist/channels/slack/bot-mentions.js +1 -1
  9. package/dist/channels/slack/eval-directive.js +1 -1
  10. package/dist/channels/slack/external-policy.d.ts +1 -1
  11. package/dist/channels/slack/external-policy.js +1 -1
  12. package/dist/channels/slack/log.d.ts +1 -1
  13. package/dist/channels/slack/log.js +1 -1
  14. package/dist/channels/slack/setup.js +1 -1
  15. package/dist/channels/slack/socket-mode.js +1 -1
  16. package/dist/docs/404.html +3 -3
  17. package/dist/docs/ab.html +11 -11
  18. package/dist/docs/assets/{ab.md.BMCZ6Hd7.js → ab.md.DAQoJ-up.js} +6 -6
  19. package/dist/docs/assets/{ab.md.BMCZ6Hd7.lean.js → ab.md.DAQoJ-up.lean.js} +1 -1
  20. package/dist/docs/assets/{app.Cm4lsMc4.js → app.DigB_9cQ.js} +1 -1
  21. package/dist/docs/assets/building-with-agents.md.CnHqvYDd.js +13 -0
  22. package/dist/docs/assets/{building-with-agents.md.CJCtZCyi.lean.js → building-with-agents.md.CnHqvYDd.lean.js} +1 -1
  23. package/dist/docs/assets/chunks/@localSearchIndexroot.CnFFl07y.js +1 -0
  24. package/dist/docs/assets/chunks/{VPLocalSearchBox.CYUFXspH.js → VPLocalSearchBox.BCMX25Bv.js} +1 -1
  25. package/dist/docs/assets/chunks/{theme.CTjkX9vc.js → theme.BDDWeELx.js} +2 -2
  26. package/dist/docs/assets/concepts.md.DFaQEFkA.js +4 -0
  27. package/dist/docs/assets/concepts.md.DFaQEFkA.lean.js +1 -0
  28. package/dist/docs/assets/deployment.md.9MYBuKM1.js +55 -0
  29. package/dist/docs/assets/deployment.md.9MYBuKM1.lean.js +1 -0
  30. package/dist/docs/assets/{evals.md.DYOjkRCX.js → evals.md.BIUoVZ6X.js} +13 -13
  31. package/dist/docs/assets/evals.md.BIUoVZ6X.lean.js +1 -0
  32. package/dist/docs/assets/{example-agents_approval-buddy.md.DFGBYLcc.js → example-agents_approval-buddy.md.BhEfleVx.js} +4 -4
  33. package/dist/docs/assets/{example-agents_approval-buddy.md.DFGBYLcc.lean.js → example-agents_approval-buddy.md.BhEfleVx.lean.js} +1 -1
  34. package/dist/docs/assets/example-agents_benny.md.2Et1qa8f.js +7 -0
  35. package/dist/docs/assets/{example-agents_bugbot.md.DelIdhxB.js → example-agents_bugbot.md.ByUexi5i.js} +5 -5
  36. package/dist/docs/assets/{example-agents_codebase-wiki.md.DC6sgwn0.js → example-agents_codebase-wiki.md.B4y-7ZVW.js} +6 -6
  37. package/dist/docs/assets/{example-agents_codebase-wiki.md.DC6sgwn0.lean.js → example-agents_codebase-wiki.md.B4y-7ZVW.lean.js} +1 -1
  38. package/dist/docs/assets/{example-agents_codeowners-review.md.Ku_tG2RY.js → example-agents_codeowners-review.md.D6ay4nvf.js} +6 -6
  39. package/dist/docs/assets/{example-agents_codeowners-review.md.Ku_tG2RY.lean.js → example-agents_codeowners-review.md.D6ay4nvf.lean.js} +1 -1
  40. package/dist/docs/assets/{example-agents_concierge.md.4rQTSMXt.js → example-agents_concierge.md.lL8rhYlj.js} +7 -7
  41. package/dist/docs/assets/{example-agents_fsd.md.CzgUrDfi.js → example-agents_fsd.md.DfNKQTHz.js} +5 -5
  42. package/dist/docs/assets/example-agents_index.md.DgGBwckv.js +2 -0
  43. package/dist/docs/assets/example-agents_index.md.DgGBwckv.lean.js +1 -0
  44. package/dist/docs/assets/{example-agents_knowledge-base.md.BPJiVueF.js → example-agents_knowledge-base.md.CzyZ2DCr.js} +5 -5
  45. package/dist/docs/assets/{example-agents_knowledge-base.md.BPJiVueF.lean.js → example-agents_knowledge-base.md.CzyZ2DCr.lean.js} +1 -1
  46. package/dist/docs/assets/example-agents_oncall.md.wFFXXEyW.js +10 -0
  47. package/dist/docs/assets/{example-agents_security-reviewer.md.Dhj_m7_B.js → example-agents_security-reviewer.md.Dkf1gyo6.js} +8 -8
  48. package/dist/docs/assets/example-agents_slack-agent.md.DvgvT4nn.js +5 -0
  49. package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.js +24 -0
  50. package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.lean.js +1 -0
  51. package/dist/docs/assets/{guides_agent-to-agent.md.Bpzgq2Pq.js → guides_agent-to-agent.md.Bmbxy-FA.js} +4 -4
  52. package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.js +9 -0
  53. package/dist/docs/assets/{guides_github.md.DOOCpqsW.js → guides_github.md.R2QlpR75.js} +5 -5
  54. package/dist/docs/assets/{guides_human-in-the-loop.md.DlUqsp1S.js → guides_human-in-the-loop.md.BWvT7UqY.js} +1 -1
  55. package/dist/docs/assets/{guides_mcp-oauth.md.Dd8EgSem.js → guides_mcp-oauth.md.C7G7IykG.js} +5 -5
  56. package/dist/docs/assets/guides_mcp-oauth.md.C7G7IykG.lean.js +1 -0
  57. package/dist/docs/assets/guides_slack.md.zriQpU_9.js +47 -0
  58. package/dist/docs/assets/guides_slack.md.zriQpU_9.lean.js +1 -0
  59. package/dist/docs/assets/{guides_webhooks.md.wSOYas3X.js → guides_webhooks.md.DiAwSR42.js} +1 -1
  60. package/dist/docs/assets/{hillclimbing.md.DHNast08.js → hillclimbing.md.D9Y1_bYh.js} +1 -1
  61. package/dist/docs/assets/index.md.CZqbBJPB.js +20 -0
  62. package/dist/docs/assets/index.md.CZqbBJPB.lean.js +1 -0
  63. package/dist/docs/assets/{quickstart.md.BU6Iwi_9.js → quickstart.md.TnEXYgYW.js} +12 -12
  64. package/dist/docs/assets/{reference_agent-config.md.DrW2JUM8.js → reference_agent-config.md.kuN6-OxK.js} +1 -1
  65. package/dist/docs/assets/reference_cli.md.sD-IUWjg.js +73 -0
  66. package/dist/docs/assets/{reference_cli.md.ccoKOoXt.lean.js → reference_cli.md.sD-IUWjg.lean.js} +1 -1
  67. package/dist/docs/assets/{reference_connections.md.B9Q3TOve.js → reference_connections.md.DGqAsFXb.js} +3 -3
  68. package/dist/docs/assets/reference_http-api.md.CfVM_ICa.js +11 -0
  69. package/dist/docs/assets/{reference_project-layout.md.Bd_CKtNS.js → reference_project-layout.md.D8E6ZmHJ.js} +4 -4
  70. package/dist/docs/assets/{reference_project-layout.md.Bd_CKtNS.lean.js → reference_project-layout.md.D8E6ZmHJ.lean.js} +1 -1
  71. package/dist/docs/assets/{reference_schedules.md.w_F2mXB6.js → reference_schedules.md.gmfYzf_I.js} +1 -1
  72. package/dist/docs/assets/{reference_sessions.md.DLd6mvbv.js → reference_sessions.md.C_ouF_uf.js} +3 -3
  73. package/dist/docs/assets/{reference_tools.md.BRSDnTbN.js → reference_tools.md.BswAQM41.js} +3 -3
  74. package/dist/docs/assets/{scaffolding-agents.md.C3pTrmoE.js → scaffolding-agents.md.Bsr9Pwzu.js} +1 -1
  75. package/dist/docs/assets/{scaffolding-agents.md.C3pTrmoE.lean.js → scaffolding-agents.md.Bsr9Pwzu.lean.js} +1 -1
  76. package/dist/docs/assets/{storage.md.DRTdnFvd.js → storage.md.xZoiGM58.js} +3 -3
  77. package/dist/docs/assets/storage.md.xZoiGM58.lean.js +1 -0
  78. package/dist/docs/assets/troubleshooting.md.B5RVX_tL.js +1 -0
  79. package/dist/docs/assets/{troubleshooting.md.CmQkmnzC.lean.js → troubleshooting.md.B5RVX_tL.lean.js} +1 -1
  80. package/dist/docs/building-with-agents.html +12 -12
  81. package/dist/docs/concepts.html +6 -6
  82. package/dist/docs/deployment.html +32 -32
  83. package/dist/docs/evals.html +19 -19
  84. package/dist/docs/example-agents/approval-buddy.html +9 -9
  85. package/dist/docs/example-agents/benny.html +11 -11
  86. package/dist/docs/example-agents/bugbot.html +10 -10
  87. package/dist/docs/example-agents/codebase-wiki.html +11 -11
  88. package/dist/docs/example-agents/codeowners-review.html +11 -11
  89. package/dist/docs/example-agents/concierge.html +12 -12
  90. package/dist/docs/example-agents/fsd.html +10 -10
  91. package/dist/docs/example-agents/index.html +7 -7
  92. package/dist/docs/example-agents/knowledge-base.html +10 -10
  93. package/dist/docs/example-agents/oncall.html +10 -10
  94. package/dist/docs/example-agents/security-reviewer.html +13 -13
  95. package/dist/docs/example-agents/slack-agent.html +10 -10
  96. package/dist/docs/example-agents/weather-agent.html +16 -16
  97. package/dist/docs/guides/agent-to-agent.html +9 -9
  98. package/dist/docs/guides/cloud-runtime.html +7 -7
  99. package/dist/docs/guides/github.html +10 -10
  100. package/dist/docs/guides/human-in-the-loop.html +7 -7
  101. package/dist/docs/guides/mcp-oauth.html +11 -11
  102. package/dist/docs/guides/slack.html +22 -17
  103. package/dist/docs/guides/webhooks.html +7 -7
  104. package/dist/docs/hashmap.json +1 -1
  105. package/dist/docs/hillclimbing.html +7 -7
  106. package/dist/docs/index.html +9 -9
  107. package/dist/docs/quickstart.html +17 -17
  108. package/dist/docs/reference/agent-config.html +7 -7
  109. package/dist/docs/reference/channels.html +5 -5
  110. package/dist/docs/reference/cli.html +56 -48
  111. package/dist/docs/reference/connections.html +9 -9
  112. package/dist/docs/reference/hooks.html +5 -5
  113. package/dist/docs/reference/http-api.html +7 -7
  114. package/dist/docs/reference/instructions.html +5 -5
  115. package/dist/docs/reference/playground.html +5 -5
  116. package/dist/docs/reference/project-layout.html +9 -9
  117. package/dist/docs/reference/prompt.html +5 -5
  118. package/dist/docs/reference/schedules.html +7 -7
  119. package/dist/docs/reference/sessions.html +8 -8
  120. package/dist/docs/reference/skills.html +5 -5
  121. package/dist/docs/reference/subagents.html +5 -5
  122. package/dist/docs/reference/tools.html +9 -9
  123. package/dist/docs/scaffolding-agents.html +6 -6
  124. package/dist/docs/storage.html +9 -9
  125. package/dist/docs/troubleshooting.html +6 -6
  126. package/dist/evals/reporters.d.ts +1 -1
  127. package/dist/evals/reporters.js +1 -1
  128. package/dist/evals.d.ts +2 -2
  129. package/dist/files-backends/agent-store-presigned-url.d.ts +100 -0
  130. package/dist/files-backends/agent-store-presigned-url.d.ts.map +1 -0
  131. package/dist/files-backends/agent-store-presigned-url.js +347 -0
  132. package/dist/files-backends/cursor-hosted.d.ts +87 -0
  133. package/dist/files-backends/cursor-hosted.d.ts.map +1 -0
  134. package/dist/files-backends/cursor-hosted.js +540 -0
  135. package/dist/files-backends/local-fs.d.ts +33 -0
  136. package/dist/files-backends/local-fs.d.ts.map +1 -0
  137. package/dist/files-backends/local-fs.js +199 -0
  138. package/dist/files.d.ts +139 -0
  139. package/dist/files.d.ts.map +1 -0
  140. package/dist/files.js +89 -0
  141. package/dist/internal/ab-collector.js +2 -2
  142. package/dist/internal/ab-fold.js +1 -1
  143. package/dist/internal/cli-ax.d.ts +2 -2
  144. package/dist/internal/cli-ax.js +2 -2
  145. package/dist/internal/cli-deploy.d.ts +1 -1
  146. package/dist/internal/cli-deploy.d.ts.map +1 -1
  147. package/dist/internal/cli-deploy.js +7 -2
  148. package/dist/internal/cli-docs.d.ts +1 -1
  149. package/dist/internal/cli-docs.js +1 -1
  150. package/dist/internal/cli-github.js +13 -13
  151. package/dist/internal/cli-mcp-oauth.d.ts +1 -1
  152. package/dist/internal/cli-mcp-oauth.js +2 -2
  153. package/dist/internal/cli-mcp.d.ts +3 -3
  154. package/dist/internal/cli-mcp.js +4 -4
  155. package/dist/internal/cli-skills.js +1 -1
  156. package/dist/internal/cloud-turn-cost.d.ts +9 -1
  157. package/dist/internal/cloud-turn-cost.d.ts.map +1 -1
  158. package/dist/internal/cloud-turn-cost.js +14 -4
  159. package/dist/internal/cursor/account-mcp.js +5 -5
  160. package/dist/internal/cursor/backend-client.js +1 -1
  161. package/dist/internal/cursor/github-credentials.js +3 -3
  162. package/dist/internal/cursor-account-mcp-auth.d.ts +1 -1
  163. package/dist/internal/cursor-account-mcp-auth.js +1 -1
  164. package/dist/internal/cursor-event-relay.js +1 -1
  165. package/dist/internal/cursor-relay-core.d.ts +1 -1
  166. package/dist/internal/cursor-relay-core.d.ts.map +1 -1
  167. package/dist/internal/cursor-slack-relay.js +1 -1
  168. package/dist/internal/deploy-client.d.ts +6 -1
  169. package/dist/internal/deploy-client.d.ts.map +1 -1
  170. package/dist/internal/deploy-client.js +3 -2
  171. package/dist/internal/deploy-source.d.ts +2 -2
  172. package/dist/internal/deploy-source.js +2 -2
  173. package/dist/internal/discovery.js +2 -2
  174. package/dist/internal/distribution.d.ts +5 -5
  175. package/dist/internal/distribution.d.ts.map +1 -1
  176. package/dist/internal/distribution.js +6 -6
  177. package/dist/internal/docs-site.js +5 -5
  178. package/dist/internal/eval-run-store.js +8 -8
  179. package/dist/internal/evals-client.d.ts +1 -1
  180. package/dist/internal/evals-client.js +1 -1
  181. package/dist/internal/github-fanout.js +2 -2
  182. package/dist/internal/host-files.d.ts +29 -0
  183. package/dist/internal/host-files.d.ts.map +1 -0
  184. package/dist/internal/host-files.js +283 -0
  185. package/dist/internal/host-platforms.js +5 -5
  186. package/dist/internal/hosting.d.ts +1 -1
  187. package/dist/internal/hosting.js +1 -1
  188. package/dist/internal/http-channel.d.ts.map +1 -1
  189. package/dist/internal/http-channel.js +26 -0
  190. package/dist/internal/install-cursor-skills.d.ts +1 -1
  191. package/dist/internal/install-cursor-skills.d.ts.map +1 -1
  192. package/dist/internal/install-cursor-skills.js +33 -4
  193. package/dist/internal/local-control-plane.js +2 -2
  194. package/dist/internal/logs-client.d.ts +2 -2
  195. package/dist/internal/logs-client.js +2 -2
  196. package/dist/internal/mcp-endpoint.js +1 -1
  197. package/dist/internal/mcp-oauth.js +2 -2
  198. package/dist/internal/platform-schedule-sync.js +2 -2
  199. package/dist/internal/playground/toolchain.js +6 -6
  200. package/dist/internal/reminder-runner.js +13 -13
  201. package/dist/internal/resolved-connections.js +6 -6
  202. package/dist/internal/schedule-runner.js +1 -1
  203. package/dist/internal/sdk-runner.js +5 -5
  204. package/dist/internal/server.js +16 -16
  205. package/dist/internal/session-cost.d.ts +3 -2
  206. package/dist/internal/session-cost.d.ts.map +1 -1
  207. package/dist/internal/session-cost.js +7 -6
  208. package/dist/internal/session-engine.d.ts +31 -1
  209. package/dist/internal/session-engine.d.ts.map +1 -1
  210. package/dist/internal/session-engine.js +119 -31
  211. package/dist/internal/slack-provision-client.js +1 -1
  212. package/dist/internal/storage-coordinator.js +7 -7
  213. package/dist/internal/trajectory.js +2 -2
  214. package/dist/internal/turn-cost.d.ts +27 -0
  215. package/dist/internal/turn-cost.d.ts.map +1 -0
  216. package/dist/internal/turn-cost.js +83 -0
  217. package/dist/internal/update-check.d.ts +3 -3
  218. package/dist/internal/update-check.d.ts.map +1 -1
  219. package/dist/internal/update-check.js +5 -5
  220. package/dist/memory.d.ts +1 -1
  221. package/dist/memory.js +1 -1
  222. package/dist/playground/assets/index-50PKeJlG.css +1 -0
  223. package/dist/playground/assets/index-C0f2Wl1q.js +85 -0
  224. package/dist/playground/index.html +2 -2
  225. package/dist/storage.d.ts +1 -1
  226. package/dist/storage.js +1 -1
  227. package/dist/types.d.ts +120 -16
  228. package/dist/types.d.ts.map +1 -1
  229. package/docs/README.md +23 -23
  230. package/docs/ab.md +12 -12
  231. package/docs/building-with-agents.md +9 -9
  232. package/docs/concepts.md +11 -11
  233. package/docs/deployment.md +55 -43
  234. package/docs/evals.md +20 -20
  235. package/docs/example-agents/approval-buddy.md +9 -9
  236. package/docs/example-agents/benny.md +13 -13
  237. package/docs/example-agents/bugbot.md +6 -6
  238. package/docs/example-agents/codebase-wiki.md +8 -8
  239. package/docs/example-agents/codeowners-review.md +8 -8
  240. package/docs/example-agents/concierge.md +10 -10
  241. package/docs/example-agents/fsd.md +7 -7
  242. package/docs/example-agents/index.md +8 -8
  243. package/docs/example-agents/knowledge-base.md +9 -9
  244. package/docs/example-agents/oncall.md +7 -7
  245. package/docs/example-agents/security-reviewer.md +12 -12
  246. package/docs/example-agents/slack-agent.md +10 -10
  247. package/docs/example-agents/weather-agent.md +30 -26
  248. package/docs/guides/agent-to-agent.md +4 -4
  249. package/docs/guides/cloud-runtime.md +3 -3
  250. package/docs/guides/github.md +6 -6
  251. package/docs/guides/human-in-the-loop.md +1 -1
  252. package/docs/guides/mcp-oauth.md +9 -9
  253. package/docs/guides/slack.md +94 -21
  254. package/docs/guides/webhooks.md +1 -1
  255. package/docs/hillclimbing.md +3 -3
  256. package/docs/quickstart.md +18 -18
  257. package/docs/reference/agent-config.md +1 -1
  258. package/docs/reference/cli.md +110 -79
  259. package/docs/reference/connections.md +3 -3
  260. package/docs/reference/http-api.md +2 -2
  261. package/docs/reference/project-layout.md +7 -7
  262. package/docs/reference/schedules.md +1 -1
  263. package/docs/reference/sessions.md +7 -7
  264. package/docs/reference/tools.md +3 -3
  265. package/docs/scaffolding-agents.md +2 -2
  266. package/docs/storage.md +5 -5
  267. package/docs/troubleshooting.md +11 -10
  268. package/package.json +3 -1
  269. package/skills/ab/SKILL.md +5 -5
  270. package/skills/create-agent/SKILL.md +17 -17
  271. package/skills/debug/SKILL.md +10 -10
  272. package/skills/evals/SKILL.md +13 -13
  273. package/skills/framework-map/SKILL.md +3 -3
  274. package/skills/github/SKILL.md +11 -11
  275. package/skills/hillclimb/SKILL.md +9 -9
  276. package/skills/mcp-auth/SKILL.md +11 -11
  277. package/skills/setup-slack/SKILL.md +28 -28
  278. package/src/bin/agent-serve.ts +4 -4
  279. package/src/channels/github/index.ts +1 -1
  280. package/src/channels/slack/bot-mentions.ts +1 -1
  281. package/src/channels/slack/eval-directive.ts +1 -1
  282. package/src/channels/slack/external-policy.ts +1 -1
  283. package/src/channels/slack/log.ts +1 -1
  284. package/src/channels/slack/setup.ts +1 -1
  285. package/src/channels/slack/socket-mode.ts +1 -1
  286. package/src/evals/reporters.ts +1 -1
  287. package/src/evals.ts +2 -2
  288. package/src/files-backends/agent-store-presigned-url.ts +402 -0
  289. package/src/files-backends/cursor-hosted.ts +698 -0
  290. package/src/files-backends/local-fs.ts +178 -0
  291. package/src/files.ts +195 -0
  292. package/src/internal/ab-collector.ts +2 -2
  293. package/src/internal/ab-fold.ts +1 -1
  294. package/src/internal/cli-ax.ts +2 -2
  295. package/src/internal/cli-deploy.ts +7 -2
  296. package/src/internal/cli-docs.ts +1 -1
  297. package/src/internal/cli-github.ts +13 -13
  298. package/src/internal/cli-mcp-oauth.ts +2 -2
  299. package/src/internal/cli-mcp.ts +4 -4
  300. package/src/internal/cli-skills.ts +1 -1
  301. package/src/internal/cloud-turn-cost.ts +20 -4
  302. package/src/internal/cursor/account-mcp.ts +5 -5
  303. package/src/internal/cursor/backend-client.ts +1 -1
  304. package/src/internal/cursor/github-credentials.ts +3 -3
  305. package/src/internal/cursor-account-mcp-auth.ts +1 -1
  306. package/src/internal/cursor-event-relay.ts +1 -1
  307. package/src/internal/cursor-relay-core.ts +1 -1
  308. package/src/internal/cursor-slack-relay.ts +1 -1
  309. package/src/internal/deploy-client.ts +8 -2
  310. package/src/internal/deploy-source.ts +2 -2
  311. package/src/internal/discovery.ts +2 -2
  312. package/src/internal/distribution.ts +6 -6
  313. package/src/internal/docs-site.ts +5 -5
  314. package/src/internal/eval-run-store.ts +8 -8
  315. package/src/internal/evals-client.ts +1 -1
  316. package/src/internal/github-fanout.ts +2 -2
  317. package/src/internal/host-files.ts +372 -0
  318. package/src/internal/host-platforms.ts +5 -5
  319. package/src/internal/hosting.ts +1 -1
  320. package/src/internal/http-channel.ts +30 -0
  321. package/src/internal/install-cursor-skills.ts +31 -3
  322. package/src/internal/local-control-plane.ts +2 -2
  323. package/src/internal/logs-client.ts +2 -2
  324. package/src/internal/mcp-endpoint.ts +1 -1
  325. package/src/internal/mcp-oauth.ts +2 -2
  326. package/src/internal/platform-schedule-sync.ts +2 -2
  327. package/src/internal/playground/toolchain.ts +6 -6
  328. package/src/internal/reminder-runner.ts +13 -13
  329. package/src/internal/resolved-connections.ts +6 -6
  330. package/src/internal/schedule-runner.ts +1 -1
  331. package/src/internal/sdk-runner.ts +5 -5
  332. package/src/internal/server.ts +16 -16
  333. package/src/internal/session-cost.ts +7 -6
  334. package/src/internal/session-engine.ts +141 -28
  335. package/src/internal/slack-provision-client.ts +1 -1
  336. package/src/internal/storage-coordinator.ts +7 -7
  337. package/src/internal/trajectory.ts +2 -2
  338. package/src/internal/turn-cost.ts +110 -0
  339. package/src/internal/update-check.ts +6 -6
  340. package/src/memory.ts +1 -1
  341. package/src/storage.ts +1 -1
  342. package/src/types.ts +148 -16
  343. package/dist/docs/assets/building-with-agents.md.CJCtZCyi.js +0 -13
  344. package/dist/docs/assets/chunks/@localSearchIndexroot.CbQshWFK.js +0 -1
  345. package/dist/docs/assets/concepts.md.Cfb9b-k1.js +0 -4
  346. package/dist/docs/assets/concepts.md.Cfb9b-k1.lean.js +0 -1
  347. package/dist/docs/assets/deployment.md.TecHo0_2.js +0 -55
  348. package/dist/docs/assets/deployment.md.TecHo0_2.lean.js +0 -1
  349. package/dist/docs/assets/evals.md.DYOjkRCX.lean.js +0 -1
  350. package/dist/docs/assets/example-agents_benny.md.B0gjhI-p.js +0 -7
  351. package/dist/docs/assets/example-agents_index.md.D2PEVSXl.js +0 -2
  352. package/dist/docs/assets/example-agents_index.md.D2PEVSXl.lean.js +0 -1
  353. package/dist/docs/assets/example-agents_oncall.md.BG_sUMly.js +0 -10
  354. package/dist/docs/assets/example-agents_slack-agent.md.buLbgvBf.js +0 -5
  355. package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.js +0 -24
  356. package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.lean.js +0 -1
  357. package/dist/docs/assets/guides_cloud-runtime.md.gVzabdQL.js +0 -9
  358. package/dist/docs/assets/guides_mcp-oauth.md.Dd8EgSem.lean.js +0 -1
  359. package/dist/docs/assets/guides_slack.md.CjmJSvZS.js +0 -42
  360. package/dist/docs/assets/guides_slack.md.CjmJSvZS.lean.js +0 -1
  361. package/dist/docs/assets/index.md.CH_s5uZe.js +0 -20
  362. package/dist/docs/assets/index.md.CH_s5uZe.lean.js +0 -1
  363. package/dist/docs/assets/reference_cli.md.ccoKOoXt.js +0 -65
  364. package/dist/docs/assets/reference_http-api.md.BncLd3PZ.js +0 -11
  365. package/dist/docs/assets/storage.md.DRTdnFvd.lean.js +0 -1
  366. package/dist/docs/assets/troubleshooting.md.CmQkmnzC.js +0 -1
  367. package/dist/internal/model-pricing.d.ts +0 -49
  368. package/dist/internal/model-pricing.d.ts.map +0 -1
  369. package/dist/internal/model-pricing.js +0 -377
  370. package/dist/playground/assets/index-CquRB-l0.js +0 -85
  371. package/dist/playground/assets/index-Dj0bWpkn.css +0 -1
  372. package/src/internal/model-pricing.ts +0 -426
  373. /package/dist/docs/assets/{example-agents_benny.md.B0gjhI-p.lean.js → example-agents_benny.md.2Et1qa8f.lean.js} +0 -0
  374. /package/dist/docs/assets/{example-agents_bugbot.md.DelIdhxB.lean.js → example-agents_bugbot.md.ByUexi5i.lean.js} +0 -0
  375. /package/dist/docs/assets/{example-agents_concierge.md.4rQTSMXt.lean.js → example-agents_concierge.md.lL8rhYlj.lean.js} +0 -0
  376. /package/dist/docs/assets/{example-agents_fsd.md.CzgUrDfi.lean.js → example-agents_fsd.md.DfNKQTHz.lean.js} +0 -0
  377. /package/dist/docs/assets/{example-agents_oncall.md.BG_sUMly.lean.js → example-agents_oncall.md.wFFXXEyW.lean.js} +0 -0
  378. /package/dist/docs/assets/{example-agents_security-reviewer.md.Dhj_m7_B.lean.js → example-agents_security-reviewer.md.Dkf1gyo6.lean.js} +0 -0
  379. /package/dist/docs/assets/{example-agents_slack-agent.md.buLbgvBf.lean.js → example-agents_slack-agent.md.DvgvT4nn.lean.js} +0 -0
  380. /package/dist/docs/assets/{guides_agent-to-agent.md.Bpzgq2Pq.lean.js → guides_agent-to-agent.md.Bmbxy-FA.lean.js} +0 -0
  381. /package/dist/docs/assets/{guides_cloud-runtime.md.gVzabdQL.lean.js → guides_cloud-runtime.md.BZ2GA7Es.lean.js} +0 -0
  382. /package/dist/docs/assets/{guides_github.md.DOOCpqsW.lean.js → guides_github.md.R2QlpR75.lean.js} +0 -0
  383. /package/dist/docs/assets/{guides_human-in-the-loop.md.DlUqsp1S.lean.js → guides_human-in-the-loop.md.BWvT7UqY.lean.js} +0 -0
  384. /package/dist/docs/assets/{guides_webhooks.md.wSOYas3X.lean.js → guides_webhooks.md.DiAwSR42.lean.js} +0 -0
  385. /package/dist/docs/assets/{hillclimbing.md.DHNast08.lean.js → hillclimbing.md.D9Y1_bYh.lean.js} +0 -0
  386. /package/dist/docs/assets/{quickstart.md.BU6Iwi_9.lean.js → quickstart.md.TnEXYgYW.lean.js} +0 -0
  387. /package/dist/docs/assets/{reference_agent-config.md.DrW2JUM8.lean.js → reference_agent-config.md.kuN6-OxK.lean.js} +0 -0
  388. /package/dist/docs/assets/{reference_connections.md.B9Q3TOve.lean.js → reference_connections.md.DGqAsFXb.lean.js} +0 -0
  389. /package/dist/docs/assets/{reference_http-api.md.BncLd3PZ.lean.js → reference_http-api.md.CfVM_ICa.lean.js} +0 -0
  390. /package/dist/docs/assets/{reference_schedules.md.w_F2mXB6.lean.js → reference_schedules.md.gmfYzf_I.lean.js} +0 -0
  391. /package/dist/docs/assets/{reference_sessions.md.DLd6mvbv.lean.js → reference_sessions.md.C_ouF_uf.lean.js} +0 -0
  392. /package/dist/docs/assets/{reference_tools.md.BRSDnTbN.lean.js → reference_tools.md.BswAQM41.lean.js} +0 -0
@@ -79,6 +79,7 @@ import {
79
79
  import { isDevMode } from "./dev-mode.js";
80
80
  import { EventLogStore } from "./event-log.js";
81
81
  import { TurnEventMapper } from "./event-mapper.js";
82
+ import { createHostFilesApi } from "./host-files.js";
82
83
  import { createHostKvApi } from "./host-kv.js";
83
84
  import {
84
85
  createHostPlatforms,
@@ -93,7 +94,6 @@ import {
93
94
  } from "./ids.js";
94
95
  import { validateToolInput } from "./json-schema.js";
95
96
  import { McpHost } from "./mcp-host.js";
96
- import { estimateTurnCost } from "./model-pricing.js";
97
97
  import {
98
98
  buildSessionContextBlock,
99
99
  SCHEDULE_CHANNEL_PREFIX,
@@ -103,6 +103,11 @@ import type { AgentRunner } from "./sdk-runner.js";
103
103
  import { SessionStore } from "./session-store.js";
104
104
  import { StorageCoordinator } from "./storage-coordinator.js";
105
105
  import { normalizeToolResult, toolCallErrorMessage } from "./tool-result.js";
106
+ import {
107
+ type EstimateTurnCostFn,
108
+ estimateTurnCostFromApi,
109
+ roundCostUsd,
110
+ } from "./turn-cost.js";
106
111
  import { TurnGovernor } from "./turn-governor.js";
107
112
  import {
108
113
  buildAgentsMdContent,
@@ -200,6 +205,11 @@ export interface SessionEngineOptions {
200
205
  * usage/cost so the playground Trace tab can still show an estimate.
201
206
  */
202
207
  getCloudUsage?: (sdkAgentId: string) => Promise<CloudAgentUsage | undefined>;
208
+ /**
209
+ * Resolve turn cost via `POST /v1/models/estimate-cost`. Tests inject a
210
+ * stub; production uses billed usage events when an agent id is known.
211
+ */
212
+ estimateTurnCost?: EstimateTurnCostFn;
203
213
  }
204
214
 
205
215
  /**
@@ -303,6 +313,7 @@ export class SessionEngine {
303
313
  private reminderApi: HostContext["reminders"];
304
314
  private evalsApi: HostContext["evals"];
305
315
  private readonly kvApi: HostContext["kv"];
316
+ private readonly filesApi: HostContext["files"];
306
317
  /** Engine-owned artifacts service behind every `ctx.artifacts` facade. */
307
318
  private readonly artifactsStore: ArtifactsStore;
308
319
  /** Serve-time resolved connections (see {@link setResolvedConnections}). */
@@ -310,6 +321,7 @@ export class SessionEngine {
310
321
  private readonly getCloudUsage: (
311
322
  sdkAgentId: string
312
323
  ) => Promise<CloudAgentUsage | undefined>;
324
+ private readonly estimateTurnCost: EstimateTurnCostFn;
313
325
  /** Sessions whose completed turns are fully priced (no further backfill). */
314
326
  private readonly cloudCostBackfillDone = new Set<string>();
315
327
  /** Deduped in-flight cloud cost backfills, keyed by session id. */
@@ -321,6 +333,7 @@ export class SessionEngine {
321
333
  this.runner = options.runner;
322
334
  this.logger = options.logger ?? (() => {});
323
335
  this.getCloudUsage = options.getCloudUsage ?? defaultGetCloudUsage;
336
+ this.estimateTurnCost = options.estimateTurnCost ?? estimateTurnCostFromApi;
324
337
  this.turnGovernor = new TurnGovernor(options.project.agent.concurrency);
325
338
  this.sessions = new SessionStore(join(options.stateRoot, "sessions"));
326
339
  this.nudgeStore = new SlackNudgeStore(
@@ -333,7 +346,7 @@ export class SessionEngine {
333
346
  (sessionId) => this.sessions.eventFilePath(sessionId),
334
347
  (sessionId, error) =>
335
348
  this.logger(
336
- `[agentkit] failed to persist events for ${sessionId}: ${describeError(error)}`
349
+ `[agent-sdk] failed to persist events for ${sessionId}: ${describeError(error)}`
337
350
  )
338
351
  );
339
352
  this.storage =
@@ -350,6 +363,10 @@ export class SessionEngine {
350
363
  stateRoot: options.stateRoot,
351
364
  ...(this.storage === undefined ? {} : { storage: this.storage }),
352
365
  });
366
+ this.filesApi = createHostFilesApi({
367
+ agentName: options.project.name,
368
+ stateRoot: options.stateRoot,
369
+ });
353
370
  this.artifactsStore = new ArtifactsStore({
354
371
  stateRoot: options.stateRoot,
355
372
  storage: this.storage,
@@ -419,10 +436,24 @@ export class SessionEngine {
419
436
  reminders: this.reminderApi,
420
437
  evals: this.evalsApi,
421
438
  kv: this.kvApi,
439
+ files: this.filesApi,
422
440
  slackNudges: this.slackNudgeHostApi(),
423
441
  };
424
442
  }
425
443
 
444
+ /**
445
+ * Host services with `files` bound to one session, so a relative path in a
446
+ * tool or hook resolves to that session's scope and can never be read as
447
+ * another session's. Unbound (no session) keeps `host.files` usable for
448
+ * `{ scope: "deployment" }` and fails loudly on session-scoped calls.
449
+ */
450
+ private hostForSession(sessionId: string | undefined): HostContext {
451
+ const host = this.host;
452
+ return sessionId === undefined
453
+ ? host
454
+ : { ...host, files: this.filesApi.forSession(sessionId) };
455
+ }
456
+
426
457
  /** Unbound `ctx.artifacts` facade (channel handlers, scratch tool calls). */
427
458
  get artifacts(): ArtifactsApi {
428
459
  return this.artifactsApi();
@@ -684,7 +715,7 @@ export class SessionEngine {
684
715
  }
685
716
  } catch (error) {
686
717
  this.logger(
687
- `[agentkit] ab "${experiment.name}" enrollment failed (sticky skip): ${describeError(error)}`
718
+ `[agent-sdk] ab "${experiment.name}" enrollment failed (sticky skip): ${describeError(error)}`
688
719
  );
689
720
  variant = null;
690
721
  }
@@ -1165,12 +1196,12 @@ export class SessionEngine {
1165
1196
  // tell an operator the workspace is hot when nothing touched it.
1166
1197
  this.logger(
1167
1198
  outcome.warmed
1168
- ? `[agentkit] warmed ${workspaceDir} in ${Date.now() - startedAt}ms`
1169
- : `[agentkit] did not warm ${workspaceDir}: ${outcome.reason}`
1199
+ ? `[agent-sdk] warmed ${workspaceDir} in ${Date.now() - startedAt}ms`
1200
+ : `[agent-sdk] did not warm ${workspaceDir}: ${outcome.reason}`
1170
1201
  );
1171
1202
  } catch (error) {
1172
1203
  this.logger(
1173
- `[agentkit] could not warm ${workspaceDir}: ${describeError(error)}`
1204
+ `[agent-sdk] could not warm ${workspaceDir}: ${describeError(error)}`
1174
1205
  );
1175
1206
  }
1176
1207
  }
@@ -1203,7 +1234,7 @@ export class SessionEngine {
1203
1234
  this.queueDispatch(sessionId, event);
1204
1235
  } catch (error) {
1205
1236
  this.logger(
1206
- `[agentkit] failed to record event for ${sessionId}: ${describeError(error)}`
1237
+ `[agent-sdk] failed to record event for ${sessionId}: ${describeError(error)}`
1207
1238
  );
1208
1239
  }
1209
1240
  };
@@ -1306,15 +1337,15 @@ export class SessionEngine {
1306
1337
 
1307
1338
  const finalResult = outcome.result ?? mapper.finalText;
1308
1339
  const finalUsage = outcome.usage ?? mapper.usage;
1309
- // Estimated dollar cost of this loop pass, persisted alongside usage so
1310
- // traces / A/B metrics / the CLI can aggregate spend without re-pricing.
1311
1340
  const finalCost =
1312
1341
  finalUsage === undefined
1313
1342
  ? undefined
1314
- : estimateTurnCost(
1315
- this.project.agent.model ?? DEFAULT_MODEL,
1316
- finalUsage
1317
- );
1343
+ : await this.estimateTurnCost({
1344
+ model: this.project.agent.model ?? DEFAULT_MODEL,
1345
+ usage: finalUsage,
1346
+ agentId: record.sdkAgentId,
1347
+ conversationId: record.sdkAgentId ?? sessionId,
1348
+ });
1318
1349
  if (finalCost !== undefined) {
1319
1350
  outcome = { ...outcome, cost: finalCost };
1320
1351
  }
@@ -1561,7 +1592,7 @@ export class SessionEngine {
1561
1592
  session: this.sessionInfo(record),
1562
1593
  workspaceDir: this.harnessCwd(record),
1563
1594
  stateRoot: this.stateRoot,
1564
- host: this.host,
1595
+ host: this.hostForSession(record.sessionId),
1565
1596
  artifacts: this.artifactsApi({
1566
1597
  sessionId: record.sessionId,
1567
1598
  turnId,
@@ -1887,7 +1918,7 @@ export class SessionEngine {
1887
1918
  session,
1888
1919
  workspaceDir,
1889
1920
  stateRoot: this.stateRoot,
1890
- host: this.host,
1921
+ host: this.hostForSession(record?.sessionId),
1891
1922
  // Scratch calls have no real session; their facade stays unbound.
1892
1923
  artifacts:
1893
1924
  record === undefined
@@ -1977,7 +2008,7 @@ export class SessionEngine {
1977
2008
  .then(() => this.dispatchEvent(sessionId, event))
1978
2009
  .catch((error) => {
1979
2010
  this.logger(
1980
- `[agentkit] event dispatch failed for ${sessionId}: ${describeError(error)}`
2011
+ `[agent-sdk] event dispatch failed for ${sessionId}: ${describeError(error)}`
1981
2012
  );
1982
2013
  })
1983
2014
  .then(() => {
@@ -2022,7 +2053,7 @@ export class SessionEngine {
2022
2053
  await handler(event, channelCtx, sessionCtx);
2023
2054
  } catch (error) {
2024
2055
  this.logger(
2025
- `[agentkit] channel "${record.channelId}" handler for ${event.type} threw: ${describeError(error)}`
2056
+ `[agent-sdk] channel "${record.channelId}" handler for ${event.type} threw: ${describeError(error)}`
2026
2057
  );
2027
2058
  }
2028
2059
  }
@@ -2055,7 +2086,7 @@ export class SessionEngine {
2055
2086
  });
2056
2087
  } catch (error) {
2057
2088
  this.logger(
2058
- `[agentkit] hook "${hook.name}" handler for ${event.type} threw: ${describeError(error)}`
2089
+ `[agent-sdk] hook "${hook.name}" handler for ${event.type} threw: ${describeError(error)}`
2059
2090
  );
2060
2091
  }
2061
2092
  }
@@ -2165,7 +2196,7 @@ export class SessionEngine {
2165
2196
  };
2166
2197
  } catch (error) {
2167
2198
  this.logger(
2168
- `[agentkit] cursor-hosted session list failed; falling back to local: ${describeError(error)}`
2199
+ `[agent-sdk] cursor-hosted session list failed; falling back to local: ${describeError(error)}`
2169
2200
  );
2170
2201
  }
2171
2202
  }
@@ -2306,7 +2337,7 @@ export class SessionEngine {
2306
2337
  startIndex = 0
2307
2338
  ): Promise<ReadableStream<Uint8Array>> {
2308
2339
  // Playground Trace replays this stream; backfill before the snapshot
2309
- // so historical Sherlock-style cloud turns can show est. cost.
2340
+ // so historical Sherlock-style cloud turns can show billed cost.
2310
2341
  await this.backfillCloudTurnCosts(sessionId);
2311
2342
  const log = await this.logs.get(sessionId);
2312
2343
  return log.stream(startIndex);
@@ -2355,6 +2386,84 @@ export class SessionEngine {
2355
2386
  });
2356
2387
  }
2357
2388
 
2389
+ /**
2390
+ * Billed/catalog cost for a session. Powers playground, traces, and
2391
+ * `agent-sdk cost` via `GET /v1/session/:id/cost`.
2392
+ */
2393
+ async sessionCost(sessionId: string): Promise<{
2394
+ sessionId: string;
2395
+ source: "usage" | "catalog" | "unavailable";
2396
+ cost: { rawCostCents: number; chargedCents: number };
2397
+ costUsd: number;
2398
+ rawCostUsd: number;
2399
+ model?: string;
2400
+ }> {
2401
+ const record = await this.getOrRestoreSession(sessionId);
2402
+ if (record === undefined) {
2403
+ throw new Error(`Unknown session: ${sessionId}`);
2404
+ }
2405
+ await this.backfillCloudTurnCosts(sessionId);
2406
+ const events = await this.listEvents(sessionId);
2407
+ const sdkAgentId =
2408
+ (record.sdkAgentId !== undefined && record.sdkAgentId !== ""
2409
+ ? record.sdkAgentId
2410
+ : undefined) ?? cloudSdkAgentIdFromEvents(events);
2411
+ const model = this.project.agent.model ?? DEFAULT_MODEL;
2412
+ const priced = await this.estimateTurnCost({
2413
+ model,
2414
+ agentId: sdkAgentId,
2415
+ conversationId: sdkAgentId ?? sessionId,
2416
+ });
2417
+ if (
2418
+ priced !== undefined &&
2419
+ (priced.source === "usage" || priced.totalUsd > 0)
2420
+ ) {
2421
+ return {
2422
+ sessionId,
2423
+ source: priced.source,
2424
+ cost: {
2425
+ rawCostCents: priced.rawCostCents ?? priced.chargedCents ?? 0,
2426
+ chargedCents: priced.chargedCents ?? priced.totalUsd * 100,
2427
+ },
2428
+ costUsd: priced.totalUsd,
2429
+ rawCostUsd: roundCostUsd(
2430
+ (priced.rawCostCents ??
2431
+ priced.chargedCents ??
2432
+ priced.totalUsd * 100) / 100
2433
+ ),
2434
+ model: priced.model,
2435
+ };
2436
+ }
2437
+ let costUsd = 0;
2438
+ let rawCostUsd = 0;
2439
+ let source: "usage" | "catalog" | "unavailable" = "unavailable";
2440
+ let modelId: string | undefined;
2441
+ for (const event of events) {
2442
+ if (event.type !== "turn.completed" || event.data.cost === undefined) {
2443
+ continue;
2444
+ }
2445
+ costUsd = roundCostUsd(costUsd + event.data.cost.totalUsd);
2446
+ const rawCents = event.data.cost.rawCostCents;
2447
+ rawCostUsd = roundCostUsd(
2448
+ rawCostUsd +
2449
+ (rawCents !== undefined ? rawCents / 100 : event.data.cost.totalUsd)
2450
+ );
2451
+ source = event.data.cost.source;
2452
+ modelId = event.data.cost.model;
2453
+ }
2454
+ return {
2455
+ sessionId,
2456
+ source,
2457
+ cost: {
2458
+ rawCostCents: rawCostUsd * 100,
2459
+ chargedCents: costUsd * 100,
2460
+ },
2461
+ costUsd,
2462
+ rawCostUsd,
2463
+ model: modelId,
2464
+ };
2465
+ }
2466
+
2358
2467
  /** Snapshot of recorded events (for download / offline trace). */
2359
2468
  async listEvents(
2360
2469
  sessionId: string,
@@ -2371,7 +2480,7 @@ export class SessionEngine {
2371
2480
  /**
2372
2481
  * Historical cloud turns may lack usage/cost on `turn.completed` (pre-0.1.29
2373
2482
  * engines, or getUsage still zero at turn end). Fill them from billed usage
2374
- * before the playground replays the stream so Trace can show est. cost.
2483
+ * before the playground replays the stream so Trace can show cost.
2375
2484
  */
2376
2485
  private backfillCloudTurnCosts(sessionId: string): Promise<void> {
2377
2486
  if (this.cloudCostBackfillDone.has(sessionId)) {
@@ -2384,7 +2493,7 @@ export class SessionEngine {
2384
2493
  const work = this.runCloudTurnCostBackfill(sessionId)
2385
2494
  .catch((error) => {
2386
2495
  this.logger(
2387
- `[agentkit] cloud cost backfill failed for ${sessionId}: ${describeError(error)}`
2496
+ `[agent-sdk] cloud cost backfill failed for ${sessionId}: ${describeError(error)}`
2388
2497
  );
2389
2498
  })
2390
2499
  .finally(() => {
@@ -2599,7 +2708,9 @@ export class SessionEngine {
2599
2708
  try {
2600
2709
  await this.runBulkRestore(storage, policy);
2601
2710
  } catch (error) {
2602
- this.logger(`[agentkit] session restore failed: ${describeError(error)}`);
2711
+ this.logger(
2712
+ `[agent-sdk] session restore failed: ${describeError(error)}`
2713
+ );
2603
2714
  }
2604
2715
  }
2605
2716
 
@@ -2656,7 +2767,7 @@ export class SessionEngine {
2656
2767
  return { record, events };
2657
2768
  } catch (error) {
2658
2769
  this.logger(
2659
- `[agentkit] failed to restore session ${record.sessionId}: ${describeError(error)}`
2770
+ `[agent-sdk] failed to restore session ${record.sessionId}: ${describeError(error)}`
2660
2771
  );
2661
2772
  return undefined;
2662
2773
  }
@@ -2675,7 +2786,7 @@ export class SessionEngine {
2675
2786
  (ndjson === undefined ? 0 : Buffer.byteLength(ndjson, "utf8"));
2676
2787
  if (bytes > budget) {
2677
2788
  this.logger(
2678
- `[agentkit] session restore stopped at the ${policy.maxTotalBytes}-byte budget after ${restored} session(s); remaining sessions restore lazily on resume`
2789
+ `[agent-sdk] session restore stopped at the ${policy.maxTotalBytes}-byte budget after ${restored} session(s); remaining sessions restore lazily on resume`
2679
2790
  );
2680
2791
  break outer;
2681
2792
  }
@@ -2685,13 +2796,13 @@ export class SessionEngine {
2685
2796
  restored += 1;
2686
2797
  } catch (error) {
2687
2798
  this.logger(
2688
- `[agentkit] failed to restore session ${item.record.sessionId}: ${describeError(error)}`
2799
+ `[agent-sdk] failed to restore session ${item.record.sessionId}: ${describeError(error)}`
2689
2800
  );
2690
2801
  }
2691
2802
  }
2692
2803
  }
2693
2804
  if (restored > 0) {
2694
- this.logger(`[agentkit] restored ${restored} session(s) from storage`);
2805
+ this.logger(`[agent-sdk] restored ${restored} session(s) from storage`);
2695
2806
  }
2696
2807
  }
2697
2808
 
@@ -2805,7 +2916,7 @@ export class SessionEngine {
2805
2916
  const events = await storage.listSessionEvents(record.sessionId);
2806
2917
  await this.materializeSession(record, eventsNdjson(events));
2807
2918
  this.logger(
2808
- `[agentkit] lazily restored session ${record.sessionId} from storage`
2919
+ `[agent-sdk] lazily restored session ${record.sessionId} from storage`
2809
2920
  );
2810
2921
  return record;
2811
2922
  }
@@ -2895,9 +3006,11 @@ async function defaultGetCloudUsage(
2895
3006
  const billed = await Agent.getUsage(sdkAgentId);
2896
3007
  return {
2897
3008
  usage: mapSdkTokenUsage(billed.usage),
3009
+ cost: billed.cost,
2898
3010
  runs: billed.runs.map((run) => ({
2899
3011
  runId: run.runId,
2900
3012
  usage: mapSdkTokenUsage(run.usage),
3013
+ cost: run.cost,
2901
3014
  })),
2902
3015
  };
2903
3016
  } catch {
@@ -381,7 +381,7 @@ function mapErrorResponse(
381
381
  switch (response.status) {
382
382
  case 401:
383
383
  return new SlackProvisionApiError(
384
- "The Cursor API key was rejected. Run `agentkit login` again or update CURSOR_API_KEY.",
384
+ "The Cursor API key was rejected. Run `agent-sdk login` again or update CURSOR_API_KEY.",
385
385
  { status: 401 }
386
386
  );
387
387
  case 403:
@@ -399,7 +399,7 @@ export class StorageCoordinator {
399
399
  // under at-most-once). The session is unrecoverable; treat as a miss
400
400
  // so the conversation can continue rather than failing forever.
401
401
  this.logger(
402
- `[agentkit] storage continuation entry points at missing session ${sessionId}; treating as a miss`
402
+ `[agent-sdk] storage continuation entry points at missing session ${sessionId}; treating as a miss`
403
403
  );
404
404
  return undefined;
405
405
  }
@@ -566,7 +566,7 @@ export class StorageCoordinator {
566
566
  return Array.isArray(runs) ? runs : [];
567
567
  } catch (error) {
568
568
  this.logger(
569
- `[agentkit] storage evals.list() failed: ${describeError(error)}`
569
+ `[agent-sdk] storage evals.list() failed: ${describeError(error)}`
570
570
  );
571
571
  return [];
572
572
  }
@@ -628,7 +628,7 @@ export class StorageCoordinator {
628
628
  return value ?? undefined;
629
629
  } catch (error) {
630
630
  this.logger(
631
- `[agentkit] storage abs.getSnapshot() failed: ${describeError(error)}`
631
+ `[agent-sdk] storage abs.getSnapshot() failed: ${describeError(error)}`
632
632
  );
633
633
  return undefined;
634
634
  }
@@ -661,7 +661,7 @@ export class StorageCoordinator {
661
661
  clearTimeout(timer);
662
662
  if (!drained) {
663
663
  this.logger(
664
- `[agentkit] storage shutdown drain timed out after ${CLOSE_DRAIN_TIMEOUT_MS}ms with ${this.pending} write(s) undelivered`
664
+ `[agent-sdk] storage shutdown drain timed out after ${CLOSE_DRAIN_TIMEOUT_MS}ms with ${this.pending} write(s) undelivered`
665
665
  );
666
666
  }
667
667
  }
@@ -709,7 +709,7 @@ export class StorageCoordinator {
709
709
  return Array.isArray(entries) ? entries : [];
710
710
  } catch (error) {
711
711
  this.logger(
712
- `[agentkit] storage list(${prefix}) failed: ${describeError(error)}`
712
+ `[agent-sdk] storage list(${prefix}) failed: ${describeError(error)}`
713
713
  );
714
714
  return [];
715
715
  }
@@ -723,7 +723,7 @@ export class StorageCoordinator {
723
723
  this.dropped += ops.length;
724
724
  if (this.dropped <= ops.length || this.dropped % 1_000 < ops.length) {
725
725
  this.logger(
726
- `[agentkit] storage queue full (${MAX_PENDING_OPS} pending writes); dropped ${this.dropped} write(s) so far — the sink is too slow for the traffic`
726
+ `[agent-sdk] storage queue full (${MAX_PENDING_OPS} pending writes); dropped ${this.dropped} write(s) so far — the sink is too slow for the traffic`
727
727
  );
728
728
  }
729
729
  return;
@@ -736,7 +736,7 @@ export class StorageCoordinator {
736
736
  await op.run(ctx);
737
737
  } catch (error) {
738
738
  this.logger(
739
- `[agentkit] storage ${op.label} failed: ${describeError(error)}`
739
+ `[agent-sdk] storage ${op.label} failed: ${describeError(error)}`
740
740
  );
741
741
  } finally {
742
742
  this.pending -= 1;
@@ -355,7 +355,7 @@ export function formatTrajectoryText(trajectory: Trajectory): string {
355
355
  `turns: ${trajectory.turns.length} tools=${trajectory.toolCallCount} failed: ${trajectory.turnsFailed}${
356
356
  trajectory.totalCostUsd === undefined
357
357
  ? ""
358
- : ` est. cost: ${formatCostUsd(trajectory.totalCostUsd)}`
358
+ : ` cost: ${formatCostUsd(trajectory.totalCostUsd)}`
359
359
  }`
360
360
  );
361
361
  for (const turn of trajectory.turns) {
@@ -397,7 +397,7 @@ export function formatTrajectoryText(trajectory: Trajectory): string {
397
397
  ` usage: in ${turn.usage.inputTokens} out ${turn.usage.outputTokens}${
398
398
  turn.cost === undefined
399
399
  ? ""
400
- : ` est. cost: ${formatCostUsd(turn.cost.totalUsd)}`
400
+ : ` cost: ${formatCostUsd(turn.cost.totalUsd)}`
401
401
  }`
402
402
  );
403
403
  }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Dollar cost for an agent turn, computed by the Cloud Agents
3
+ * `POST /v1/models/estimate-cost` endpoint (billed usage events when an
4
+ * agent/conversation id is known, otherwise live catalog pricing).
5
+ */
6
+
7
+ import type { ModelSetting, TurnCost, TurnUsage } from "../types.js";
8
+ import { cursorExternalApiUrl, resolveApiKey } from "./cursor/credentials.js";
9
+
10
+ export interface UsageCostCents {
11
+ rawCostCents: number;
12
+ chargedCents: number;
13
+ }
14
+
15
+ export interface EstimateTurnCostInput {
16
+ model: ModelSetting;
17
+ usage?: TurnUsage;
18
+ agentId?: string;
19
+ conversationId?: string;
20
+ runId?: string;
21
+ }
22
+
23
+ export type EstimateTurnCostFn = (
24
+ input: EstimateTurnCostInput
25
+ ) => Promise<TurnCost | undefined>;
26
+
27
+ export function modelSettingId(model: ModelSetting): string {
28
+ return typeof model === "string" ? model : model.id;
29
+ }
30
+
31
+ export function roundCostUsd(usd: number): number {
32
+ return Math.round(usd * 1e6) / 1e6;
33
+ }
34
+
35
+ export function turnCostFromCents(args: {
36
+ model: string | ModelSetting;
37
+ cost: UsageCostCents;
38
+ source: TurnCost["source"];
39
+ }): TurnCost {
40
+ const totalUsd = roundCostUsd(args.cost.chargedCents / 100);
41
+ const model =
42
+ typeof args.model === "string" ? args.model : modelSettingId(args.model);
43
+ return {
44
+ totalUsd,
45
+ inputUsd: 0,
46
+ outputUsd: 0,
47
+ cacheReadUsd: 0,
48
+ cacheWriteUsd: 0,
49
+ model,
50
+ source: args.source,
51
+ rawCostCents: args.cost.rawCostCents,
52
+ chargedCents: args.cost.chargedCents,
53
+ };
54
+ }
55
+
56
+ interface EstimateCostApiResponse {
57
+ model?: string;
58
+ cost?: UsageCostCents;
59
+ source?: "usage" | "catalog";
60
+ }
61
+
62
+ export async function estimateTurnCostFromApi(
63
+ input: EstimateTurnCostInput
64
+ ): Promise<TurnCost | undefined> {
65
+ const resolved = await resolveApiKey();
66
+ if (resolved === undefined) {
67
+ return undefined;
68
+ }
69
+ const model = modelSettingId(input.model);
70
+ const response = await fetch(
71
+ `${cursorExternalApiUrl()}/v1/models/estimate-cost`,
72
+ {
73
+ method: "POST",
74
+ headers: {
75
+ authorization: `Bearer ${resolved.apiKey}`,
76
+ "content-type": "application/json",
77
+ },
78
+ body: JSON.stringify({
79
+ model,
80
+ inputTokens: input.usage?.inputTokens,
81
+ outputTokens: input.usage?.outputTokens,
82
+ cacheReadTokens: input.usage?.cacheReadTokens,
83
+ cacheWriteTokens: input.usage?.cacheWriteTokens,
84
+ agentId: input.agentId,
85
+ conversationId: input.conversationId,
86
+ runId: input.runId,
87
+ }),
88
+ }
89
+ );
90
+ if (!response.ok) {
91
+ return undefined;
92
+ }
93
+ let body: EstimateCostApiResponse;
94
+ try {
95
+ body = (await response.json()) as EstimateCostApiResponse;
96
+ } catch {
97
+ return undefined;
98
+ }
99
+ if (
100
+ typeof body.cost?.rawCostCents !== "number" ||
101
+ typeof body.cost.chargedCents !== "number"
102
+ ) {
103
+ return undefined;
104
+ }
105
+ return turnCostFromCents({
106
+ model: body.model ?? model,
107
+ cost: body.cost,
108
+ source: body.source === "usage" ? "usage" : "catalog",
109
+ });
110
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Outdated-version warning + `agentkit update`.
2
+ * Outdated-version warning + `agent-sdk update`.
3
3
  *
4
4
  * Every CLI run of a published install compares its own version against the
5
5
  * npm registry's `latest` dist-tag and warns on stderr when behind. The
@@ -8,7 +8,7 @@
8
8
  * network; a stale cache refreshes inline under a short timeout, and any
9
9
  * network failure is silent (the warning is best-effort, never a blocker).
10
10
  *
11
- * `agentkit update` re-runs the lookup fresh, figures out how this copy was
11
+ * `agent-sdk update` re-runs the lookup fresh, figures out how this copy was
12
12
  * installed (global npm/pnpm/yarn/bun, or a project dependency), and runs the
13
13
  * matching install command.
14
14
  */
@@ -36,7 +36,7 @@ const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
36
36
  /** Inline refresh budget; a slow registry must not stall the command. */
37
37
  const WARN_FETCH_TIMEOUT_MS = 1500;
38
38
 
39
- /** `agentkit update` runs interactively, so it can afford a real timeout. */
39
+ /** `agent-sdk update` runs interactively, so it can afford a real timeout. */
40
40
  const UPDATE_FETCH_TIMEOUT_MS = 10_000;
41
41
 
42
42
  // ============================================================================
@@ -276,7 +276,7 @@ function isTruthyEnv(value: string | undefined): boolean {
276
276
  }
277
277
 
278
278
  // ============================================================================
279
- // `agentkit update`
279
+ // `agent-sdk update`
280
280
  // ============================================================================
281
281
 
282
282
  export interface UpdateCommand {
@@ -303,7 +303,7 @@ export async function detectUpdateCommand(args: {
303
303
  const spec = `${packageName}@latest`;
304
304
  const posixRoot = args.packageRoot.split(sep).join("/");
305
305
 
306
- // npx / pnpm dlx caches are ephemeral; a fresh `npx agentkit` already
306
+ // npx / pnpm dlx caches are ephemeral; a fresh `npx agent-sdk` already
307
307
  // resolves latest, and upgrading the cache entry in place helps nobody.
308
308
  if (posixRoot.includes("/_npx/") || posixRoot.includes("/.pnpm-store/")) {
309
309
  return undefined;
@@ -457,7 +457,7 @@ export interface UpdateCliOptions {
457
457
  err?: (text: string) => void;
458
458
  }
459
459
 
460
- /** `agentkit update` — upgrade this install to the latest published version. */
460
+ /** `agent-sdk update` — upgrade this install to the latest published version. */
461
461
  export async function cmdUpdate(options?: UpdateCliOptions): Promise<number> {
462
462
  const c = stderrPalette();
463
463
  const out =
package/src/memory.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * later sessions can recall and build on past work.
4
4
  *
5
5
  * The write side is {@link memoryHook}, authored as a thin re-export at
6
- * `agent/hooks/memory.ts` (scaffolded by `agentkit init`): after each turn
6
+ * `agent/hooks/memory.ts` (scaffolded by `agent-sdk init`): after each turn
7
7
  * it appends one record (timestamp, session, user message, final result,
8
8
  * usage) to `<stateRoot>/memory/journal.jsonl`.
9
9
  *
package/src/storage.ts CHANGED
@@ -254,7 +254,7 @@ export function defineStorage(config: StorageConfig): StorageDefinition {
254
254
 
255
255
  /**
256
256
  * Framework-owned key root. All {@link storageKeys} values live under this
257
- * prefix so a shared store can route or namespace agentkit data.
257
+ * prefix so a shared store can route or namespace Agent SDK data.
258
258
  */
259
259
  export const STORAGE_KEY_ROOT = "agentkit/v1" as const;
260
260