dal-code 1.0.36 → 1.0.37

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 (89) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/core/agent-session.d.ts +4 -1
  3. package/dist/core/agent-session.js +8 -8
  4. package/dist/core/compaction/utils.js +5 -6
  5. package/dist/core/extensions/index.d.ts +1 -1
  6. package/dist/core/extensions/runner.d.ts +3 -2
  7. package/dist/core/extensions/runner.js +1 -1
  8. package/dist/core/extensions/types.d.ts +11 -3
  9. package/dist/core/model-runtime.js +2 -2
  10. package/dist/index.d.ts +1 -1
  11. package/dist/modes/print-mode.js +5 -5
  12. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  13. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  14. package/dist/node_modules/@dalcode/dal-goal/package.json +2 -2
  15. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  16. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  17. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  18. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  19. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  20. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  21. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  22. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +1 -1
  23. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  24. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
  25. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  26. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  27. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  28. package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
  29. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  30. package/dist/node_modules/@dalcode/dal-router/src/index.js +1 -1
  31. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  32. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  33. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +14 -12
  34. package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +2 -2
  35. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  36. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  37. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  38. package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
  39. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  40. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  41. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +14 -14
  42. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  43. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  44. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  45. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  46. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
  47. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
  48. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
  49. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +4 -4
  50. package/dist/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +1 -1
  51. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  52. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  53. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  54. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  55. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  56. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  57. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  58. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  59. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +1 -0
  60. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts +2 -0
  61. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js +5 -2
  62. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  63. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +2 -2
  64. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -6
  65. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  66. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  67. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  68. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  69. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  70. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  71. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  72. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  73. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  74. package/examples/extensions/gondolin/package-lock.json +2 -2
  75. package/examples/extensions/gondolin/package.json +1 -1
  76. package/examples/extensions/plan-mode/index.ts +6 -2
  77. package/examples/extensions/sandbox/package-lock.json +2 -2
  78. package/examples/extensions/sandbox/package.json +1 -1
  79. package/examples/extensions/with-deps/package-lock.json +2 -2
  80. package/examples/extensions/with-deps/package.json +1 -1
  81. package/npm-shrinkwrap.json +2 -2
  82. package/package.json +1 -1
  83. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +0 -1
  84. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js +0 -1
  85. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +0 -1
  86. package/dist/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +0 -1
  87. package/examples/extensions/custom-provider-anthropic/index.ts +0 -617
  88. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  89. package/examples/extensions/custom-provider-anthropic/package.json +0 -19
@@ -1 +1 @@
1
- {"openai-completions":{"chat:mimo-v2.5":{"id":"mimo-v2.5","name":"MiMo-V2.5","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.5-pro":{"id":"mimo-v2.5-pro","name":"MiMo-V2.5-Pro","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"type":"chat"},"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
1
+ {"openai-completions":{"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-ams","baseUrl":"https://token-plan-ams.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
@@ -1 +1 @@
1
- {"openai-completions":{"chat:mimo-v2.5":{"id":"mimo-v2.5","name":"MiMo-V2.5","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.5-pro":{"id":"mimo-v2.5-pro","name":"MiMo-V2.5-Pro","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"type":"chat"},"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
1
+ {"openai-completions":{"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-cn","baseUrl":"https://token-plan-cn.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
@@ -1 +1 @@
1
- {"openai-completions":{"chat:mimo-v2.5":{"id":"mimo-v2.5","name":"MiMo-V2.5","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.5-pro":{"id":"mimo-v2.5-pro","name":"MiMo-V2.5-Pro","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"type":"chat"},"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
1
+ {"openai-completions":{"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi-token-plan-sgp","baseUrl":"https://token-plan-sgp.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
@@ -1 +1 @@
1
- {"openai-completions":{"chat:mimo-v2.5":{"id":"mimo-v2.5","name":"MiMo-V2.5","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0.14,"output":0.28,"cacheRead":0.0028,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.5-pro":{"id":"mimo-v2.5-pro","name":"MiMo-V2.5-Pro","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text"],"cost":{"input":0.435,"output":0.87,"cacheRead":0.0036,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"type":"chat"},"chat:mimo-v2.5-pro-ultraspeed":{"id":"mimo-v2.5-pro-ultraspeed","name":"MiMo-V2.5-Pro-UltraSpeed","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text"],"cost":{"input":1.305,"output":2.61,"cacheRead":0.0108,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"type":"chat"},"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0.14,"output":0.28,"cacheRead":0.0028,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0.435,"output":0.87,"cacheRead":0.0036,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro-ultraspeed":{"id":"mimo-v2.6-pro-ultraspeed","name":"MiMo-V2.6-Pro-UltraSpeed","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":4.35,"output":8.7,"cacheRead":0.036,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
1
+ {"openai-completions":{"chat:mimo-v2.6-flash":{"id":"mimo-v2.6-flash","name":"MiMo-V2.6-Flash","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0.14,"output":0.28,"cacheRead":0.0028,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro":{"id":"mimo-v2.6-pro","name":"MiMo-V2.6-Pro","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":0.435,"output":0.87,"cacheRead":0.0036,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:mimo-v2.6-pro-ultraspeed":{"id":"mimo-v2.6-pro-ultraspeed","name":"MiMo-V2.6-Pro-UltraSpeed","api":"openai-completions","provider":"xiaomi","baseUrl":"https://api.xiaomimimo.com/v1","compat":{"supportsStrictMode":true,"requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek"},"reasoning":true,"input":["text","image"],"cost":{"input":4.35,"output":8.7,"cacheRead":0.036,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"}}}
@@ -154,6 +154,7 @@ export interface ToolCall {
154
154
  arguments: JsonObject;
155
155
  thoughtSignature?: string;
156
156
  namespace?: string;
157
+ argumentsError?: string;
157
158
  }
158
159
  export interface Usage {
159
160
  input: number;
@@ -1,3 +1,5 @@
1
+ import type { ToolCall } from "../types.ts";
1
2
  export declare function repairJson(json: string): string;
2
3
  export declare function parseJsonWithRepair<T>(json: string): T;
4
+ export declare function parseToolCallArguments(json: string | undefined): Pick<ToolCall, "arguments" | "argumentsError">;
3
5
  export declare function parseStreamingJson<T = Record<string, unknown>>(partialJson: string | undefined): T;
@@ -1,2 +1,5 @@
1
- var f=Object.defineProperty;var i=(t,r)=>f(t,"name",{value:r,configurable:!0});import{parse as a}from"partial-json";const d=new Set(['"',"\\","/","b","f","n","r","t","u"]);function h(t){const r=t.codePointAt(0);return r!==void 0&&r>=0&&r<=31}i(h,"isControlCharacter");function p(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
2
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${t.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}i(p,"escapeControlCharacter");function s(t){let r="",c=!1;for(let e=0;e<t.length;e++){const n=t[e];if(!c){r+=n,n==='"'&&(c=!0);continue}if(n==='"'){r+=n,c=!1;continue}if(n==="\\"){const u=t[e+1];if(u===void 0){r+="\\\\";continue}if(u==="u"){const o=t.slice(e+2,e+6);if(/^[0-9a-fA-F]{4}$/.test(o)){r+=`\\u${o}`,e+=5;continue}}if(d.has(u)){r+=`\\${u}`,e+=1;continue}r+="\\\\";continue}r+=h(n)?p(n):n}return r}i(s,"repairJson");function l(t){try{return JSON.parse(t)}catch(r){const c=s(t);if(c!==t)return JSON.parse(c);throw r}}i(l,"parseJsonWithRepair");function C(t){if(!t||t.trim()==="")return{};try{return l(t)}catch{try{return a(t)??{}}catch{try{return a(s(t))??{}}catch{return{}}}}}i(C,"parseStreamingJson");export{l as parseJsonWithRepair,C as parseStreamingJson,s as repairJson};
1
+ var l=Object.defineProperty;var u=(t,r)=>l(t,"name",{value:r,configurable:!0});import{parse as a}from"partial-json";const p=new Set(['"',"\\","/","b","f","n","r","t"]);function d(t){const r=t.codePointAt(0);return r!==void 0&&r>=0&&r<=31}u(d,"isControlCharacter");function g(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
2
+ `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${t.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}u(g,"escapeControlCharacter");function s(t){let r="",c=!1;for(let e=0;e<t.length;e++){const n=t[e];if(!c){r+=n,n==='"'&&(c=!0);continue}if(n==='"'){r+=n,c=!1;continue}if(n==="\\"){const i=t[e+1];if(i===void 0){r+="\\\\";continue}if(i==="u"){const o=t.slice(e+2,e+6);if(/^[0-9a-fA-F]{4}$/.test(o)){r+=`\\u${o}`,e+=5;continue}}if(p.has(i)){r+=`\\${i}`,e+=1;continue}r+="\\\\";continue}r+=d(n)?g(n):n}return r}u(s,"repairJson");function f(t){try{return JSON.parse(t)}catch(r){const c=s(t);if(c!==t)return JSON.parse(c);throw r}}u(f,"parseJsonWithRepair");function S(t){if(!t?.trim())return{arguments:{}};try{const r=f(t);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("Tool arguments must be a JSON object");return{arguments:r}}catch(r){return{arguments:{},argumentsError:`${r instanceof Error?r.message:String(r)}
3
+
4
+ Received arguments:
5
+ ${t}`}}}u(S,"parseToolCallArguments");function x(t){if(!t||t.trim()==="")return{};try{return f(t)}catch{try{return a(t)??{}}catch{try{return a(s(t))??{}}catch{return{}}}}}u(x,"parseStreamingJson");export{f as parseJsonWithRepair,x as parseStreamingJson,S as parseToolCallArguments,s as repairJson};
@@ -1 +1 @@
1
- var R=Object.defineProperty;var n=(e,r)=>R(e,"name",{value:r,configurable:!0});function f(e){return new RegExp(e.join("|"),"i")}n(f,"buildProviderErrorPattern");const p=f(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","^\\s*(?:error:?\\s*)?402\\b","\\b(?:status|http|code)\\W{0,3}402\\b","payment.?required","insufficient.?(?:balance|credits?|funds)","credit balance is too low","exceeded your current quota","quota.?exhausted","\u4F59\u989D\u4E0D\u8DB3","subscription_sharing_usage_limit_exceeded"]),m=f(["overloaded","server_busy","servers are currently busy","currently experiencing high demand","model is at capacity","rate.?limit","too many requests","\\b(?:429|500|502|503|504|520|524)\\b","service.?unavailable","server.?error","internal.?error","empty response","provider.?returned.?error","exceeded request buffer limit while retrying upstream","network.?error","connection.?error","connection.?refused","connection.?lost","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","pending stream has been canceled","retry delay","you can retry your request","try your request again","please retry your request","ResourceExhausted","subscription_sharing_usage_unavailable","subscription_sharing_user_unavailable"]),b=6e4;function _(e,r){const a=e.baseDelayMs*2**Math.max(0,r-1),t=Number.isSafeInteger(a)?a:Number.MAX_SAFE_INTEGER;return Math.min(t,e.maxAgentDelayMs??b)}n(_,"retryDelayMs");class d extends Error{static{n(this,"RetrySleepAbortError")}constructor(){super("Aborted")}}function g(e,r){return new Promise((a,t)=>{if(r?.aborted){t(new d);return}const u=setTimeout(a,e);r?.addEventListener("abort",()=>{clearTimeout(u),t(new d)},{once:!0})})}n(g,"sleep");async function A(e,r,a,t){const u=r?.enabled?r.maxRetries:0;let i=0,s;for(;;){const o=await e();if(o.stopReason==="aborted")return s&&await t?.onRetryFinished?.(!1,s.attempt),o;if(o.stopReason!=="error")return s&&await t?.onRetryFinished?.(!0,s.attempt),o;if(i>=u||!E(o))return s&&await t?.onRetryFinished?.(!1,s.attempt,o.errorMessage),o;i++,s={attempt:i,errorMessage:o.errorMessage||"Unknown error"};const c=_(r,i);await t?.onRetryScheduled?.(i,u,c,s.errorMessage);try{await g(c,a)}catch(l){if(await t?.onRetryFinished?.(!1,i,s.errorMessage),l instanceof d){const{errorMessage:h,...y}=o;return{...y,stopReason:"aborted"}}throw l}await t?.onRetryAttemptStart?.()}}n(A,"retryAssistantCall");function E(e){if(e.stopReason!=="error"||!e.errorMessage)return!1;const r=e.errorMessage;return p.test(r)?!1:m.test(r)}n(E,"isRetryableAssistantError");function w(e){return e.stopReason!=="error"||!e.errorMessage?!1:p.test(e.errorMessage)}n(w,"isAccountLimitAssistantError");export{b as DEFAULT_MAX_AGENT_RETRY_DELAY_MS,w as isAccountLimitAssistantError,E as isRetryableAssistantError,A as retryAssistantCall,_ as retryDelayMs};
1
+ var y=Object.defineProperty;var n=(e,r)=>y(e,"name",{value:r,configurable:!0});function f(e){return new RegExp(e.join("|"),"i")}n(f,"buildProviderErrorPattern");const p=f(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","^\\s*(?:error:?\\s*)?402\\b","\\b(?:status|http|code)\\W{0,3}402\\b","payment.?required","insufficient.?(?:balance|credits?|funds)","credit balance is too low","exceeded your current quota","quota.?exhausted","\u4F59\u989D\u4E0D\u8DB3","subscription_sharing_usage_limit_exceeded"]),R=f(["overloaded","server_busy","servers are currently busy","currently experiencing high demand","model is at capacity","rate.?limit","too many requests","\\b(?:429|500|502|503|504|520|524)\\b","service.?(?:is.?)?(?:temporarily.?)?unavailable","server.?error","internal.?error","empty response","provider.?returned.?(?:an.?)?error","unable to forward upstream","exceeded request buffer limit while retrying upstream","network.?error","connection.?error","connection.?refused","connection.?lost","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","pending stream has been canceled","retry delay","you can retry your request","try your request again","please retry your request","ResourceExhausted","subscription_sharing_usage_unavailable","subscription_sharing_user_unavailable"]),b=6e4;function _(e,r){const a=e.baseDelayMs*2**Math.max(0,r-1),t=Number.isSafeInteger(a)?a:Number.MAX_SAFE_INTEGER;return Math.min(t,e.maxAgentDelayMs??b)}n(_,"retryDelayMs");class d extends Error{static{n(this,"RetrySleepAbortError")}constructor(){super("Aborted")}}function g(e,r){return new Promise((a,t)=>{if(r?.aborted){t(new d);return}const u=setTimeout(a,e);r?.addEventListener("abort",()=>{clearTimeout(u),t(new d)},{once:!0})})}n(g,"sleep");async function w(e,r,a,t){const u=r?.enabled?r.maxRetries:0;let i=0,s;for(;;){const o=await e();if(o.stopReason==="aborted")return s&&await t?.onRetryFinished?.(!1,s.attempt),o;if(o.stopReason!=="error")return s&&await t?.onRetryFinished?.(!0,s.attempt),o;if(i>=u||!E(o))return s&&await t?.onRetryFinished?.(!1,s.attempt,o.errorMessage),o;i++,s={attempt:i,errorMessage:o.errorMessage||"Unknown error"};const c=_(r,i);await t?.onRetryScheduled?.(i,u,c,s.errorMessage);try{await g(c,a)}catch(l){if(await t?.onRetryFinished?.(!1,i,s.errorMessage),l instanceof d){const{errorMessage:h,...m}=o;return{...m,stopReason:"aborted"}}throw l}await t?.onRetryAttemptStart?.()}}n(w,"retryAssistantCall");function E(e){if(e.stopReason!=="error"||!e.errorMessage)return!1;const r=e.errorMessage;return p.test(r)?!1:R.test(r)}n(E,"isRetryableAssistantError");function A(e){return e.stopReason!=="error"||!e.errorMessage?!1:p.test(e.errorMessage)}n(A,"isAccountLimitAssistantError");export{b as DEFAULT_MAX_AGENT_RETRY_DELAY_MS,A as isAccountLimitAssistantError,E as isRetryableAssistantError,w as retryAssistantCall,_ as retryDelayMs};
@@ -1,6 +1,6 @@
1
- var b=Object.defineProperty;var f=(r,t)=>b(r,"name",{value:t,configurable:!0});import{Compile as l}from"typebox/compile";import{Value as g}from"typebox/value";const y=new WeakMap,A=Symbol.for("TypeBox.Kind");function j(r){return typeof r.type=="string"?[r.type]:Array.isArray(r.type)?r.type.filter(t=>typeof t=="string"):[]}f(j,"getSchemaTypes");function O(r,t){switch(t){case"number":return typeof r=="number";case"integer":return typeof r=="number"&&Number.isInteger(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"null":return r===null;case"array":return Array.isArray(r);case"object":return typeof r=="object"&&r!==null&&!Array.isArray(r);default:return!1}}f(O,"matchesJsonType");function p(r){try{return d(r)}catch{return}}f(p,"getSubSchemaValidator");function h(r,t){switch(t){case"number":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isFinite(e))return e}return typeof r=="boolean"?r?1:0:r}case"integer":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isInteger(e))return e}return typeof r=="boolean"?r?1:0:r}case"boolean":{if(r===null)return!1;if(typeof r=="string"){if(r==="true")return!0;if(r==="false")return!1}if(typeof r=="number"){if(r===1)return!0;if(r===0)return!1}return r}case"string":return r===null?"":typeof r=="number"||typeof r=="boolean"?String(r):r;case"null":return r===""||r===0||r===!1?null:r;default:return r}}f(h,"coercePrimitiveByType");function S(r,t){const e=t.properties,n=new Set(e?Object.keys(e):[]);if(e)for(const[i,o]of Object.entries(e))i in r&&(r[i]=c(r[i],o));if(t.additionalProperties&&typeof t.additionalProperties=="object")for(const[i,o]of Object.entries(r))n.has(i)||(r[i]=c(o,t.additionalProperties))}f(S,"applySchemaObjectCoercion");function k(r,t){if(Array.isArray(t.items)){for(let e=0;e<r.length;e++){const n=t.items[e];n&&(r[e]=c(r[e],n))}return}if(t.items&&typeof t.items=="object")for(let e=0;e<r.length;e++)r[e]=c(r[e],t.items)}f(k,"applySchemaArrayCoercion");function u(r,t){for(const e of t)if(p(e)?.Check(r))return r;for(const e of t){const n=structuredClone(r),i=c(n,e);if(p(e)?.Check(i))return i}return r}f(u,"coerceWithUnionSchema");function c(r,t){let e=r;if(Array.isArray(t.allOf))for(const o of t.allOf)e=c(e,o);Array.isArray(t.anyOf)&&(e=u(e,t.anyOf)),Array.isArray(t.oneOf)&&(e=u(e,t.oneOf));const n=j(t),i=n.length>1&&n.some(o=>O(e,o));if(n.length>0&&!i)for(const o of n){const s=h(e,o);if(s!==e){e=s;break}}return n.includes("object")&&typeof e=="object"&&e!==null&&!Array.isArray(e)&&S(e,t),n.includes("array")&&Array.isArray(e)&&k(e,t),e}f(c,"coerceWithJsonSchema");function a(r,t){if(Array.isArray(r)){if(Array.isArray(t.items))for(let i=0;i<r.length;i++){const o=t.items[i];o&&a(r[i],o)}else if(t.items)for(const i of r)a(i,t.items);return}if(typeof r!="object"||r===null||!t.properties)return;const e=r,n=new Set(t.required??[]);for(const[i,o]of Object.entries(t.properties))i in e&&(e[i]===null&&!n.has(i)&&typeof o.$ref!="string"&&p(o)?.Check(null)===!1?delete e[i]:a(e[i],o))}f(a,"normalizeOptionalNulls");function d(r){const t=r,e=y.get(t);if(e)return e;const n=l(r);return y.set(t,n),n}f(d,"getValidator");function P(r){if(r.keyword==="required"){const n=r.params.requiredProperties?.[0];if(n){const i=r.instancePath.replace(/^\//,"").replace(/\//g,".");return i?`${i}.${n}`:n}}return r.instancePath.replace(/^\//,"").replace(/\//g,".")||"root"}f(P,"formatValidationPath");function N(r,t){const e=r.find(n=>n.name===t.name);if(!e)throw new Error(`Tool "${t.name}" not found`);return w(e,t)}f(N,"validateToolCall");function w(r,t){const e=structuredClone(t.arguments);a(e,r.parameters),g.Convert(r.parameters,e);const n=d(r.parameters);if(!Object.getOwnPropertySymbols(r.parameters).includes(A)){const s=c(e,r.parameters);if(s!==e)if(typeof e=="object"&&e!==null&&typeof s=="object"&&s!==null){for(const m of Object.keys(e))delete e[m];Object.assign(e,s)}else return n.Check(s)?s:e}if(n.Check(e))return e;const i=n.Errors(e).map(s=>` - ${P(s)}: ${s.message}`).join(`
1
+ var b=Object.defineProperty;var f=(r,t)=>b(r,"name",{value:t,configurable:!0});import{Compile as g}from"typebox/compile";import{Value as l}from"typebox/value";const y=new WeakMap,A=Symbol.for("TypeBox.Kind");function j(r){return typeof r.type=="string"?[r.type]:Array.isArray(r.type)?r.type.filter(t=>typeof t=="string"):[]}f(j,"getSchemaTypes");function h(r,t){switch(t){case"number":return typeof r=="number";case"integer":return typeof r=="number"&&Number.isInteger(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"null":return r===null;case"array":return Array.isArray(r);case"object":return typeof r=="object"&&r!==null&&!Array.isArray(r);default:return!1}}f(h,"matchesJsonType");function p(r){try{return d(r)}catch{return}}f(p,"getSubSchemaValidator");function O(r,t){switch(t){case"number":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isFinite(e))return e}return typeof r=="boolean"?r?1:0:r}case"integer":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isInteger(e))return e}return typeof r=="boolean"?r?1:0:r}case"boolean":{if(r===null)return!1;if(typeof r=="string"){if(r==="true")return!0;if(r==="false")return!1}if(typeof r=="number"){if(r===1)return!0;if(r===0)return!1}return r}case"string":return r===null?"":typeof r=="number"||typeof r=="boolean"?String(r):r;case"null":return r===""||r===0||r===!1?null:r;default:return r}}f(O,"coercePrimitiveByType");function S(r,t){const e=t.properties,n=new Set(e?Object.keys(e):[]);if(e)for(const[i,o]of Object.entries(e))i in r&&(r[i]=c(r[i],o));if(t.additionalProperties&&typeof t.additionalProperties=="object")for(const[i,o]of Object.entries(r))n.has(i)||(r[i]=c(o,t.additionalProperties))}f(S,"applySchemaObjectCoercion");function k(r,t){if(Array.isArray(t.items)){for(let e=0;e<r.length;e++){const n=t.items[e];n&&(r[e]=c(r[e],n))}return}if(t.items&&typeof t.items=="object")for(let e=0;e<r.length;e++)r[e]=c(r[e],t.items)}f(k,"applySchemaArrayCoercion");function u(r,t){for(const e of t)if(p(e)?.Check(r))return r;for(const e of t){const n=structuredClone(r),i=c(n,e);if(p(e)?.Check(i))return i}return r}f(u,"coerceWithUnionSchema");function c(r,t){let e=r;if(Array.isArray(t.allOf))for(const o of t.allOf)e=c(e,o);Array.isArray(t.anyOf)&&(e=u(e,t.anyOf)),Array.isArray(t.oneOf)&&(e=u(e,t.oneOf));const n=j(t),i=n.length>1&&n.some(o=>h(e,o));if(n.length>0&&!i)for(const o of n){const s=O(e,o);if(s!==e){e=s;break}}return n.includes("object")&&typeof e=="object"&&e!==null&&!Array.isArray(e)&&S(e,t),n.includes("array")&&Array.isArray(e)&&k(e,t),e}f(c,"coerceWithJsonSchema");function a(r,t){if(Array.isArray(r)){if(Array.isArray(t.items))for(let i=0;i<r.length;i++){const o=t.items[i];o&&a(r[i],o)}else if(t.items)for(const i of r)a(i,t.items);return}if(typeof r!="object"||r===null||!t.properties)return;const e=r,n=new Set(t.required??[]);for(const[i,o]of Object.entries(t.properties))i in e&&(e[i]===null&&!n.has(i)&&typeof o.$ref!="string"&&p(o)?.Check(null)===!1?delete e[i]:a(e[i],o))}f(a,"normalizeOptionalNulls");function d(r){const t=r,e=y.get(t);if(e)return e;const n=g(r);return y.set(t,n),n}f(d,"getValidator");function w(r){if(r.keyword==="required"){const n=r.params.requiredProperties?.[0];if(n){const i=r.instancePath.replace(/^\//,"").replace(/\//g,".");return i?`${i}.${n}`:n}}return r.instancePath.replace(/^\//,"").replace(/\//g,".")||"root"}f(w,"formatValidationPath");function q(r,t){const e=r.find(n=>n.name===t.name);if(!e)throw new Error(`Tool "${t.name}" not found`);return P(e,t)}f(q,"validateToolCall");function P(r,t){if(t.argumentsError)throw new Error(`Invalid arguments for tool "${t.name}": ${t.argumentsError}`);const e=structuredClone(t.arguments);a(e,r.parameters),l.Convert(r.parameters,e);const n=d(r.parameters);if(!Object.getOwnPropertySymbols(r.parameters).includes(A)){const s=c(e,r.parameters);if(s!==e)if(typeof e=="object"&&e!==null&&typeof s=="object"&&s!==null){for(const m of Object.keys(e))delete e[m];Object.assign(e,s)}else return n.Check(s)?s:e}if(n.Check(e))return e;const i=n.Errors(e).map(s=>` - ${w(s)}: ${s.message}`).join(`
2
2
  `)||"Unknown validation error",o=`Validation failed for tool "${t.name}":
3
3
  ${i}
4
4
 
5
5
  Received arguments:
6
- ${JSON.stringify(t.arguments,null,2)}`;throw new Error(o)}f(w,"validateToolArguments");export{w as validateToolArguments,N as validateToolCall};
6
+ ${JSON.stringify(t.arguments,null,2)}`;throw new Error(o)}f(P,"validateToolArguments");export{P as validateToolArguments,q as validateToolCall};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-ai",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Unified LLM API with automatic model discovery and provider configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,10 +42,6 @@
42
42
  "./bedrock-provider": {
43
43
  "types": "./dist/bedrock-provider.d.ts",
44
44
  "import": "./dist/bedrock-provider.js"
45
- },
46
- "./bun-oauth": {
47
- "types": "./dist/bun-oauth.d.ts",
48
- "import": "./dist/bun-oauth.js"
49
45
  }
50
46
  },
51
47
  "bin": {
@@ -58,7 +54,7 @@
58
54
  "dependencies": {
59
55
  "@anthropic-ai/sdk": "0.129.0",
60
56
  "@aws-sdk/client-bedrock-runtime": "3.1127.0",
61
- "@earendil-works/pi-telemetry": "^1.0.36",
57
+ "@earendil-works/pi-telemetry": "^1.0.37",
62
58
  "@google/genai": "2.21.0",
63
59
  "@opentelemetry/api": "1.9.0",
64
60
  "@smithy/node-http-handler": "4.12.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-client",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Transport-neutral client for remote pi sessions over framed CBOR bytes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "node": ">=22.19.0"
41
41
  },
42
42
  "dependencies": {
43
- "@earendil-works/chord": "^1.0.36",
44
- "@earendil-works/pi-protocol": "^1.0.36"
43
+ "@earendil-works/chord": "^1.0.37",
44
+ "@earendil-works/pi-protocol": "^1.0.37"
45
45
  }
46
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-codemode",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Sandboxed JavaScript execution where the only capability is calling injected tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-coding-agent",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "private": true,
5
5
  "description": "Self-reference to the package's own dist/index.js for the bundled extensions.",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-mcp",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Standalone Model Context Protocol client for pi and other applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-protocol",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Transport-neutral CBOR protocol for remote pi sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "node": ">=22.19.0"
34
34
  },
35
35
  "dependencies": {
36
- "@earendil-works/chord": "^1.0.36",
36
+ "@earendil-works/chord": "^1.0.37",
37
37
  "typebox": "1.3.27"
38
38
  }
39
39
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-server",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "experimental server package for pi",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "node": ">=22.19.0"
40
40
  },
41
41
  "dependencies": {
42
- "@earendil-works/chord": "^1.0.36",
43
- "@earendil-works/pi-protocol": "^1.0.36"
42
+ "@earendil-works/chord": "^1.0.37",
43
+ "@earendil-works/pi-protocol": "^1.0.37"
44
44
  }
45
45
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-telemetry",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Vendor-neutral telemetry contracts and typed schema utilities for pi",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-tui",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.1.34",
4
+ "version": "0.1.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-gondolin",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-gondolin",
9
- "version": "0.1.34",
9
+ "version": "0.1.35",
10
10
  "dependencies": {
11
11
  "@earendil-works/gondolin": "0.12.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-gondolin",
3
3
  "private": true,
4
- "version": "0.1.34",
4
+ "version": "0.1.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -189,8 +189,12 @@ export default function planModeExtension(pi: ExtensionAPI): void {
189
189
  };
190
190
  });
191
191
 
192
- // Inject plan/execution context before agent starts
193
- pi.on("before_agent_start", async () => {
192
+ // Inject plan/execution context before a user prompt. Runs started by custom messages, such as
193
+ // background task notifications, skip it: the context from the last prompt is still in the
194
+ // conversation, and adding it again on every notification would only repeat it.
195
+ pi.on("before_agent_start", async (event) => {
196
+ if (event.messageType !== "user") return;
197
+
194
198
  if (planModeEnabled) {
195
199
  return {
196
200
  message: {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "1.15.34",
3
+ "version": "1.15.35",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "1.15.34",
9
+ "version": "1.15.35",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "1.15.34",
4
+ "version": "1.15.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.1.34",
9
+ "version": "0.1.35",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.1.34",
4
+ "version": "0.1.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "dal-code",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "dal-code",
9
- "version": "1.0.36",
9
+ "version": "1.0.37",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "1.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dal-code",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "DAL Code terminal",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var s=(e,t)=>S(e,"name",{value:t,configurable:!0});import{getProviderEnvValue as T}from"../../utils/provider-env.js";import{startOAuthCallbackServer as b,waitForCallbackOrManualInput as P}from"./callback-server.js";import{generatePKCE as _}from"./pkce.js";const L=s(e=>atob(e),"decode"),p=L("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),g="https://claude.ai/oauth/authorize",l="https://platform.claude.com/v1/oauth/token",R=T("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",y=53692,m="/callback",I=`http://localhost:${y}${m}`,w="https://platform.claude.com/oauth/code/callback",A="browser",C="copy_code",O="org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";function E(e){const t=e.trim();if(!t)return{};try{const r=new URL(t);return{code:r.searchParams.get("code")??void 0,state:r.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){const[r,o]=t.split("#",2);return{code:r,state:o}}if(t.includes("code=")){const r=new URLSearchParams(t);return{code:r.get("code")??void 0,state:r.get("state")??void 0}}return{code:t}}s(E,"parseAuthorizationInput");function h(e){if(e instanceof Error){const t=[`${e.name}: ${e.message}`],r=e;return r.code&&t.push(`code=${r.code}`),typeof r.errno<"u"&&t.push(`errno=${String(r.errno)}`),typeof e.cause<"u"&&t.push(`cause=${h(e.cause)}`),e.stack&&t.push(`stack=${e.stack}`),t.join("; ")}return String(e)}s(h,"formatErrorDetails");async function k(e,t,r){const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t),signal:AbortSignal.any([r,AbortSignal.timeout(3e4)])}),a=await o.text();if(!o.ok)throw new Error(`HTTP request failed. status=${o.status}; url=${e}; body=${a}`);return a}s(k,"postJson");async function $(e,t,r,o,a){let n;try{n=await k(l,{grant_type:"authorization_code",client_id:p,code:e,state:t,redirect_uri:o,code_verifier:r},a)}catch(c){throw new Error(`Token exchange request failed. url=${l}; redirect_uri=${o}; response_type=authorization_code; details=${h(c)}`)}let i;try{i=JSON.parse(n)}catch(c){throw new Error(`Token exchange returned invalid JSON. url=${l}; body=${n}; details=${h(c)}`)}return{type:"oauth",refresh:i.refresh_token,access:i.access_token,expires:Date.now()+i.expires_in*1e3-300*1e3}}s($,"exchangeAuthorizationCode");async function x(e){const{verifier:t,challenge:r}=await _(),o=s(i=>b({providerName:"Anthropic",host:R,port:i,path:m,redirectHost:"localhost",state:t,complete:s(async c=>c,"complete"),signal:e.signal}),"startCallbackServer"),a=await o(y).catch(()=>o(0)).catch(()=>{}),n=a?.redirectUri??I;try{const i=new URLSearchParams({code:"true",client_id:p,response_type:"code",redirect_uri:n,scope:O,code_challenge:r,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${g}?${i.toString()}`,instructions:"Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."});const c=await P(e,a,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:n});let d,f=t;if(c.type==="callback")d=c.value;else{const u=E(c.input);if(u.state&&u.state!==t)throw new Error("OAuth state mismatch");d=u.code,f=u.state??t}if(!d)throw new Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await $(d,f,t,n,e.signal)}finally{a?.close()}}s(x,"loginAnthropic");async function N(e){const{verifier:t,challenge:r}=await _(),o=new URLSearchParams({code:"true",client_id:p,response_type:"code",redirect_uri:w,scope:O,code_challenge:r,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${g}?${o.toString()}`,instructions:"Complete login in your browser, then copy the code Anthropic shows and paste it here."});const a=await e.prompt({type:"manual_code",message:"Paste the code Anthropic shows after you sign in:",placeholder:"code#state",signal:e.signal}),n=E(a);if(n.state&&n.state!==t)throw new Error("OAuth state mismatch");if(!n.code)throw new Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await $(n.code,n.state??t,t,w,e.signal)}s(N,"loginAnthropicCopyCode");async function v(e,t){let r;try{r=await k(l,{grant_type:"refresh_token",client_id:p,refresh_token:e},t)}catch(a){throw new Error(`Anthropic token refresh request failed. url=${l}; details=${h(a)}`)}let o;try{o=JSON.parse(r)}catch(a){throw new Error(`Anthropic token refresh returned invalid JSON. url=${l}; body=${r}; details=${h(a)}`)}return{type:"oauth",refresh:o.refresh_token,access:o.access_token,expires:Date.now()+o.expires_in*1e3-300*1e3}}s(v,"refreshAnthropicToken");const B={name:"Anthropic (Claude Pro/Max)",isSubscription:!0,async login(e){const t=await e.prompt({type:"select",message:"Select Anthropic login method:",options:[{id:A,label:"Browser login (default)"},{id:C,label:"Copy code login (headless)"}]});if(t===C)return N(e);if(t!==A)throw new Error(`Unknown Anthropic login method: ${t}`);return x(e)},refresh:s((e,t)=>v(e.refresh,t),"refresh"),async toAuth(e){return{apiKey:e.access}}};export{B as anthropicOAuth};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var l=(e,t)=>E(e,"name",{value:t,configurable:!0});import{GITHUB_COPILOT_MODELS as I}from"../../providers/github-copilot.models.js";import{sleep as U}from"../../utils/sleep.js";import{pollOAuthDeviceCodeFlow as S}from"./device-code.js";const A=l(e=>atob(e),"decode"),y=A("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),h={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},M="2026-06-01";function g(e){const t=e.trim();if(!t)return null;try{return(t.includes("://")?new URL(t):new URL(`https://${t}`)).hostname}catch{return null}}l(g,"normalizeDomain");function b(e){return{deviceCodeUrl:`https://${e}/login/device/code`,accessTokenUrl:`https://${e}/login/oauth/access_token`,copilotTokenUrl:`https://api.${e}/copilot_internal/v2/token`}}l(b,"getUrls");function k(e){const t=e.match(/proxy-ep=([^;]+)/);return t?`https://${t[1].replace(/^proxy\./,"api.")}`:null}l(k,"getBaseUrlFromToken");function m(e,t){if(e){const n=k(e);if(n)return n}return t?`https://copilot-api.${t}`:"https://api.individual.githubcopilot.com"}l(m,"getGitHubCopilotBaseUrl");function u(e){return e&&typeof e=="object"?e:void 0}l(u,"asRecord");function $(e,t){const n=u(e)?.data;if(!Array.isArray(n))throw new Error("Invalid Copilot models response");const o=n.flatMap(i=>{const d=u(i),p=d?.id;if(!d||typeof p!="string")return[];const f=u(d.capabilities);return u(f?.supports)?.tool_calls===!1?[]:[{id:p,pickerEnabled:d.model_picker_enabled===!0,policyState:u(d.policy)?.state}]}),r=o.filter(i=>i.pickerEnabled&&i.policyState!=="disabled").map(i=>i.id),a=t&&r.length===0,s=r.length>0||!t?r:o.filter(i=>i.policyState==="enabled").map(i=>i.id),c=o.filter(i=>i.policyState==="unconfigured"&&Object.hasOwn(I,i.id)&&(i.pickerEnabled||a)).map(i=>i.id);return{availableModelIds:s,policyModelIds:c}}l($,"parseGitHubCopilotModelCatalog");async function v(e,t,n,o){const r=o.maxRetries>0&&o.maxElapsedMs>0?AbortSignal.timeout(o.maxElapsedMs):void 0,a=r?AbortSignal.any([n,r]):n,s=r?Date.now()+o.maxElapsedMs:void 0;for(let c=0;;c++){const i=await fetch(e,{...t,signal:AbortSignal.any([a,AbortSignal.timeout(5e3)])});if(i.status!==429||c===o.maxRetries)return i;const d=i.headers.get("retry-after");let p=500*2**c;if(d){const f=Number.parseFloat(d);if(p=Number.isNaN(f)?Date.parse(d)-Date.now():f*1e3,!Number.isFinite(p))return i}if(p=Math.max(0,p),s!==void 0&&p>=s-Date.now())return i;await i.body?.cancel(),await U(p,a)}}l(v,"fetchWithRateLimitRetry");async function x(e,t,n,o){const r=m(e,t),a=r==="https://api.individual.githubcopilot.com",s=await v(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...h,"X-GitHub-Api-Version":M}},n,o);if(!s.ok)throw new Error(`${s.status} ${s.statusText}: ${await s.text()}`);return $(await s.json(),a)}l(x,"fetchGitHubCopilotModels");async function w(e,t){const n=await fetch(e,t);if(!n.ok){const o=await n.text();throw new Error(`${n.status} ${n.statusText}: ${o}`)}return n.json()}l(w,"fetchJson");async function T(e,t){const n=b(e),o=await w(n.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:y,scope:"read:user"}),signal:t});if(!o||typeof o!="object")throw new Error("Invalid device code response");const r=o.device_code,a=o.user_code,s=o.verification_uri,c=o.interval,i=o.expires_in;if(typeof r!="string"||typeof a!="string"||typeof s!="string"||c!==void 0&&typeof c!="number"||typeof i!="number")throw new Error("Invalid device code response fields");let d;try{d=new URL(s)}catch{throw new Error("Untrusted verification_uri in device code response")}if(d.protocol!=="https:"&&d.protocol!=="http:")throw new Error("Untrusted verification_uri in device code response");return{device_code:r,user_code:a,verification_uri:d.href,interval:c,expires_in:i}}l(T,"startDeviceFlow");async function H(e,t,n){const o=b(e);return S({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:n,poll:l(async()=>{const r=await w(o.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:y,device_code:t.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:n});if(r&&typeof r=="object"&&typeof r.access_token=="string")return{status:"complete",value:r.access_token};if(r&&typeof r=="object"&&typeof r.error=="string"){const{error:a,error_description:s,interval:c}=r;if(a==="authorization_pending")return{status:"pending"};if(a==="slow_down")return{status:"slow_down",intervalSeconds:typeof c=="number"?c:void 0};const i=s?`: ${s}`:"";return{status:"failed",message:`Device flow failed: ${a}${i}`}}return{status:"failed",message:"Invalid device token response"}},"poll")})}l(H,"pollForGitHubAccessToken");async function _(e,t,n){const r=b(t||"github.com"),a=await w(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...h},signal:n});if(!a||typeof a!="object")throw new Error("Invalid Copilot token response");const s=a.token,c=a.expires_at;if(typeof s!="string"||typeof c!="number")throw new Error("Invalid Copilot token response fields");return{type:"oauth",refresh:e,access:s,expires:c*1e3-300*1e3,enterpriseUrl:t}}l(_,"refreshGitHubCopilotAccessToken");async function O(e,t,n){const o=await _(e,t,n),{availableModelIds:r}=await x(o.access,t,n,{maxRetries:0,maxElapsedMs:0});return{...o,availableModelIds:r}}l(O,"refreshGitHubCopilotToken");async function G(e,t,n,o){const a=`${m(e,n)}/models/${t}/policy`;let s;try{s=await v(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...h,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},o,{maxRetries:2,maxElapsedMs:5e3})}catch(c){if(o.aborted)throw c;return!1}if(s.status===429)throw new Error(`${s.status} ${s.statusText}: ${await s.text()}`);return s.ok}l(G,"enableGitHubCopilotModel");async function R(e,t,n,o){const r=[];for(const a of t)try{await G(e,a,n,o)&&r.push(a)}catch(s){if(o.aborted)throw s;break}return r}l(R,"enableGitHubCopilotModels");async function L(e){const t=await e.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(e.signal.aborted)throw new Error("Login cancelled");const n=t.trim(),o=g(t);if(n&&!o)throw new Error("Invalid GitHub Enterprise URL/domain");const r=o||"github.com",a=await T(r,e.signal);e.notify({type:"device_code",userCode:a.user_code,verificationUri:a.verification_uri,intervalSeconds:a.interval,expiresInSeconds:a.expires_in});const s=await H(r,a,e.signal),c=await _(s,o??void 0,e.signal),i=await x(c.access,o??void 0,e.signal,{maxRetries:2,maxElapsedMs:5e3});let d=[];return i.policyModelIds.length>0&&(e.notify({type:"progress",message:"Enabling models..."}),d=await R(c.access,i.policyModelIds,o??void 0,e.signal)),{...c,availableModelIds:[...new Set([...i.availableModelIds,...d])]}}l(L,"loginGitHubCopilot");function C(e){const t=e.enterpriseUrl;if(!(typeof t!="string"||!t))return g(t)??void 0}l(C,"copilotEnterpriseDomain");const P={name:"GitHub Copilot",isSubscription:!0,login:L,refresh:l((e,t)=>O(e.refresh,C(e),t),"refresh"),async toAuth(e){return{apiKey:e.access,baseUrl:m(e.access,C(e))}}};export{P as githubCopilotOAuth};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var s=(e,t)=>E(e,"name",{value:t,configurable:!0});let h=null;typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&import("node:crypto").then(e=>{h=e.randomBytes});import{getProviderEnvValue as I}from"../../utils/provider-env.js";import{startOAuthCallbackServer as v,waitForCallbackOrManualInput as A}from"./callback-server.js";import{pollOAuthDeviceCodeFlow as x}from"./device-code.js";import{generatePKCE as S}from"./pkce.js";const u="app_EMoamEEZ73f0CkXaXp7hrann",c="https://auth.openai.com",T=`${c}/oauth/authorize`,_=`${c}/oauth/token`,p="http://localhost:1455/auth/callback",b=`${c}/api/accounts/deviceauth/usercode`,P=`${c}/api/accounts/deviceauth/token`,k=`${c}/codex/device`,R=`${c}/deviceauth/callback`,w=900,m="browser",y="device_code",D="openid profile email offline_access",U="https://api.openai.com/auth";function N(){return I("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}s(N,"getCallbackHost");function $(){if(!h)throw new Error("OpenAI Codex OAuth is only available in Node.js environments");return h(16).toString("hex")}s($,"createState");function L(e){const t=e.trim();if(!t)return{};try{const r=new URL(t);return{code:r.searchParams.get("code")??void 0,state:r.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){const[r,o]=t.split("#",2);return{code:r,state:o}}if(t.includes("code=")){const r=new URLSearchParams(t);return{code:r.get("code")??void 0,state:r.get("state")??void 0}}return{code:t}}s(L,"parseAuthorizationInput");function J(e){try{const t=e.split(".");if(t.length!==3)return null;const r=t[1]??"",o=atob(r);return JSON.parse(o)}catch{return null}}s(J,"decodeJwt");async function f(e,t){try{return await fetch(e,t)}catch(r){throw t.signal?.aborted?new Error("Login cancelled"):r}}s(f,"fetchWithLoginCancellation");async function C(e,t){if(!e.ok){const n=await e.text().catch(()=>"");throw new Error(`OpenAI Codex token ${t} failed (${e.status}): ${n||e.statusText}`)}const o=await e.json();if(!o?.access_token||!o.refresh_token||typeof o.expires_in!="number")throw new Error(`OpenAI Codex token ${t} response missing fields: ${JSON.stringify(o)}`);return{access:o.access_token,refresh:o.refresh_token,expires:Date.now()+o.expires_in*1e3}}s(C,"readTokenResponse");async function z(e,t,r,o){const n=await f(_,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:u,code:e,code_verifier:t,redirect_uri:r}),signal:o});return C(n,"exchange")}s(z,"exchangeAuthorizationCode");async function j(e,t){let r;try{r=await fetch(_,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:u}),signal:t})}catch(o){throw new Error(`OpenAI Codex token refresh error: ${o instanceof Error?o.message:String(o)}`)}return C(r,"refresh")}s(j,"refreshAccessToken");async function V(e){const t=await f(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:u}),signal:e});if(!t.ok){if(t.status===404)throw new Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");const i=await t.text().catch(()=>"");throw new Error(`OpenAI Codex device code request failed with status ${t.status}${i?`: ${i}`:""}`)}const o=await t.json(),n=typeof o?.interval=="string"?Number(o.interval.trim()):o?.interval;if(!o?.device_auth_id||!o.user_code||typeof n!="number"||!Number.isFinite(n)||n<0)throw new Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(o)}`);return{deviceAuthId:o.device_auth_id,userCode:o.user_code,intervalSeconds:n}}s(V,"startOpenAICodexDeviceAuth");async function B(e,t){return x({intervalSeconds:e.intervalSeconds,expiresInSeconds:w,signal:t,poll:s(async()=>{const r=await f(P,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:e.deviceAuthId,user_code:e.userCode}),signal:t});if(r.ok){const a=await r.json();return!a?.authorization_code||!a.code_verifier?{status:"failed",message:`Invalid OpenAI Codex device auth token response: ${JSON.stringify(a)}`}:{status:"complete",value:{authorizationCode:a.authorization_code,codeVerifier:a.code_verifier}}}if(r.status===403||r.status===404)return{status:"pending"};const o=await r.text().catch(()=>"");let n;try{const a=JSON.parse(o)?.error;n=typeof a=="object"?a?.code:a}catch{}return n==="deviceauth_authorization_pending"?{status:"pending"}:n==="slow_down"?{status:"slow_down"}:{status:"failed",message:`OpenAI Codex device auth failed with status ${r.status}${o?`: ${o}`:""}`}},"poll")})}s(B,"pollOpenAICodexDeviceAuth");async function F(e="pi"){const{verifier:t,challenge:r}=await S(),o=$(),n=new URL(T);return n.searchParams.set("response_type","code"),n.searchParams.set("client_id",u),n.searchParams.set("redirect_uri",p),n.searchParams.set("scope",D),n.searchParams.set("code_challenge",r),n.searchParams.set("code_challenge_method","S256"),n.searchParams.set("state",o),n.searchParams.set("id_token_add_organizations","true"),n.searchParams.set("codex_cli_simplified_flow","true"),n.searchParams.set("originator",e),{verifier:t,state:o,url:n.toString()}}s(F,"createAuthorizationFlow");function H(e){const o=J(e)?.[U]?.chatgpt_account_id;return typeof o=="string"&&o.length>0?o:null}s(H,"getAccountId");function g(e){const t=H(e.access);if(!t)throw new Error("Failed to extract accountId from token");return{type:"oauth",access:e.access,refresh:e.refresh,expires:e.expires,accountId:t}}s(g,"credentialsFromToken");async function O(e,t,r,o){return g(await z(e,t,r,o))}s(O,"exchangeAuthorizationCodeForCredentials");async function M(e){const t=await V(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:k,intervalSeconds:t.intervalSeconds,expiresInSeconds:w});const r=await B(t,e.signal);return O(r.authorizationCode,r.codeVerifier,R,e.signal)}s(M,"loginOpenAICodexDeviceCode");async function K(e,t){const{verifier:r,state:o,url:n}=await F(t?.agentName),i=await v({providerName:"OpenAI",host:N(),port:1455,path:"/auth/callback",state:o,complete:s(async a=>a,"complete"),signal:e.signal}).catch(()=>{});e.notify({type:"auth_url",url:n,instructions:"A browser window should open. Complete login to finish."});try{const a=await A(e,i,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:p});let d;if(a.type==="callback")d=a.value;else{const l=L(a.input);if(l.state&&l.state!==o)throw new Error("State mismatch");d=l.code}if(!d)throw new Error("Missing authorization code");return await O(d,r,p,e.signal)}finally{i?.close()}}s(K,"loginOpenAICodex");async function X(e,t){return g(await j(e,t))}s(X,"refreshOpenAICodexToken");const Y={name:"OpenAI (ChatGPT Plus/Pro)",isSubscription:!0,async login(e,t){const r=await e.prompt({type:"select",message:"Select OpenAI Codex login method:",options:[{id:m,label:"Browser login (default)"},{id:y,label:"Device code login (headless)"}]});if(r===y)return M(e);if(r!==m)throw new Error(`Unknown OpenAI Codex login method: ${r}`);return K(e,t)},refresh:s((e,t)=>X(e.refresh,t),"refresh"),async toAuth(e){return{apiKey:e.access}}};export{Y as openaiCodexOAuth};
@@ -1 +0,0 @@
1
- var r=Object.defineProperty;var o=(t,i)=>r(t,"name",{value:i,configurable:!0});import{anthropicOAuth as m}from"./auth/oauth/anthropic.js";import{githubCopilotOAuth as e}from"./auth/oauth/github-copilot.js";import{kimiCodingOAuth as p}from"./auth/oauth/kimi-coding.js";import{registerBundledOAuthFlowLoaders as u}from"./auth/oauth/load.js";import{metaOAuth as h}from"./auth/oauth/meta.js";import{openaiChatGPTOAuth as a}from"./auth/oauth/openai-chatgpt.js";import{openaiCodexOAuth as n}from"./auth/oauth/openai-codex.js";import{openRouterOAuth as f}from"./auth/oauth/openrouter.js";import{createRadiusOAuth as A}from"./auth/oauth/radius.js";import{xaiOAuth as O}from"./auth/oauth/xai.js";function F(){u({anthropic:o(()=>m,"anthropic"),openaiCodex:o(()=>n,"openaiCodex"),openaiChatGPT:o(()=>a,"openaiChatGPT"),githubCopilot:o(()=>e,"githubCopilot"),openrouter:o(()=>f,"openrouter"),kimiCoding:o(()=>p,"kimiCoding"),meta:o(()=>h,"meta"),xai:o(()=>O,"xai"),radius:A})}o(F,"registerBunOAuthFlows");export{F as registerBunOAuthFlows};