@mastra/code-sdk 0.0.0-mastracode-cloud-20260706153555
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.
- package/CHANGELOG.md +22 -0
- package/LICENSE.md +30 -0
- package/README.md +50 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +173 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +166 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +54 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +34 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +5 -0
- package/dist/acp.js.map +1 -0
- package/dist/agents/instructions.d.ts +6 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +41 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +65 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +442 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +13 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +107 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +55 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +115 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +45 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +38 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +38 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +20 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +82 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +22 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +19 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +57 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +22 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +107 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +13 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +181 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +89 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +268 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/sandbox-reattach.d.ts +19 -0
- package/dist/agents/sandbox-reattach.d.ts.map +1 -0
- package/dist/agents/sandbox-reattach.js +17 -0
- package/dist/agents/sandbox-reattach.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +96 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +105 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +18 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +126 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workspace.d.ts +22 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +194 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +152 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +21 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +17 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +94 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +100 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +302 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +95 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +527 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/storage.d.ts +91 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +187 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +68 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +192 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +14 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +120 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +8 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +52 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +201 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +56 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +7 -0
- package/dist/evals/scorers/index.js.map +1 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +238 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +196 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +188 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +85 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +32 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +38 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +296 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +134 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +9 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +78 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +125 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/manager.d.ts +47 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +284 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +152 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +7 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +712 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +24 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +309 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +9 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +48 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +97 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +128 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +34 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +205 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +49 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +374 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/types.d.ts +85 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +20 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +28 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +21 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/onboarding/om-settings.d.ts +20 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +26 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +48 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +111 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +323 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +594 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +119 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +81 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/install.d.ts +20 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +179 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +15 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +221 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +60 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +369 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +75 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +2 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +20 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +26 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +96 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +152 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/types.d.ts +45 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +53 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +40 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +79 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +62 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +50 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +151 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +58 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +263 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +70 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +291 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/schema.d.ts +167 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +92 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +17 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +43 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +88 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +22 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +35 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +65 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +74 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +55 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +207 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +49 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +43 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +56 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +99 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +161 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +302 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +104 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +48 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +155 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +96 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +72 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +98 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +108 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +52 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +177 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +126 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/github-copilot.ts"],"sourcesContent":["/**\n * GitHub Copilot OAuth Provider\n *\n * Uses OAuth tokens from AuthStorage to authenticate with GitHub Copilot's chat API.\n * The Copilot API speaks an OpenAI-compatible chat format, so we plug\n * `@ai-sdk/openai-compatible` into Copilot's API URL and use a custom fetch to inject\n * the bearer token and Copilot-specific headers.\n *\n * Inspired by:\n * - opencode: https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/plugin/github-copilot/copilot.ts\n * - pi-mono: https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/utils/oauth/github-copilot.ts\n */\n\nimport { createOpenAICompatible } from '@ai-sdk/openai-compatible';\nimport type { MastraModelConfig } from '@mastra/core/llm';\nimport type { JSONSchema7 } from '@mastra/schema-compat';\nimport { applyCompatLayer, GoogleSchemaCompatLayer } from '@mastra/schema-compat';\nimport { wrapLanguageModel } from 'ai';\nimport type { LanguageModelMiddleware } from 'ai';\nimport { COPILOT_HEADERS, fetchCopilotModels, getGitHubCopilotBaseUrl } from '../auth/providers/github-copilot.js';\nimport type { CopilotModelEntry, GitHubCopilotCredentials } from '../auth/providers/github-copilot.js';\nimport { AuthStorage } from '../auth/storage.js';\n\nconst COPILOT_PROVIDER_ID = 'github-copilot';\n\n// Singleton auth storage instance (shared with claude-max.ts / openai-codex.ts when not overridden).\nlet authStorageInstance: AuthStorage | null = null;\n\n/** Get or create the shared AuthStorage instance. */\nexport function getAuthStorage(): AuthStorage {\n if (!authStorageInstance) {\n authStorageInstance = new AuthStorage();\n }\n return authStorageInstance;\n}\n\n/** Set a custom AuthStorage instance (useful for tests / TUI integration). */\nexport function setAuthStorage(storage: AuthStorage | undefined): void {\n authStorageInstance = storage ?? null;\n}\n\n/**\n * Heuristic: did this request come from the agent (e.g. tool result follow-ups) rather\n * than a fresh user turn? Mirrors opencode's `isAgent` logic — Copilot bills these\n * differently via the `x-initiator` header.\n */\nfunction detectIsAgent(body: unknown): boolean {\n if (!body || typeof body !== 'object') return false;\n const obj = body as Record<string, unknown>;\n\n const messages = obj.messages;\n if (Array.isArray(messages) && messages.length > 0) {\n const last = messages[messages.length - 1] as { role?: string; content?: unknown };\n if (last?.role && last.role !== 'user') return true;\n if (Array.isArray(last?.content)) {\n // If the last user turn carries any tool_result parts, treat it as an agent turn.\n const hasToolResult = last.content.some(\n (part: unknown) => part && typeof part === 'object' && (part as { type?: string }).type === 'tool_result',\n );\n if (hasToolResult) return true;\n }\n }\n\n const input = obj.input;\n if (Array.isArray(input) && input.length > 0) {\n const last = input[input.length - 1] as { role?: string };\n if (last?.role && last.role !== 'user') return true;\n }\n\n return false;\n}\n\n/** Detect image/vision content in a request body. */\nfunction detectIsVision(body: unknown): boolean {\n if (!body || typeof body !== 'object') return false;\n const obj = body as Record<string, unknown>;\n\n const matchPart = (part: unknown): boolean => {\n if (!part || typeof part !== 'object') return false;\n const t = (part as { type?: string }).type;\n return t === 'image' || t === 'image_url' || t === 'input_image';\n };\n\n const messages = obj.messages;\n if (Array.isArray(messages)) {\n return messages.some(\n (msg: unknown) =>\n msg &&\n typeof msg === 'object' &&\n Array.isArray((msg as { content?: unknown }).content) &&\n ((msg as { content: unknown[] }).content as unknown[]).some(matchPart),\n );\n }\n\n const input = obj.input;\n if (Array.isArray(input)) {\n return input.some(\n (item: unknown) =>\n item &&\n typeof item === 'object' &&\n Array.isArray((item as { content?: unknown }).content) &&\n ((item as { content: unknown[] }).content as unknown[]).some(matchPart),\n );\n }\n\n return false;\n}\n\n/**\n * Build a fetch wrapper that authenticates with GitHub Copilot OAuth.\n *\n * - Injects the short-lived Copilot bearer token (auto-refreshed by AuthStorage).\n * - Adds the VS Code-like Copilot headers required by the API.\n * - Rewrites the request URL onto the per-token API base when `rewriteUrl` is true.\n */\nexport function buildGitHubCopilotOAuthFetch(\n opts: { authStorage?: AuthStorage; rewriteUrl?: boolean } = {},\n): typeof fetch {\n return (async (url: string | URL | Request, init?: Parameters<typeof fetch>[1]) => {\n const storage = opts.authStorage ?? getAuthStorage();\n storage.reload();\n\n const cred = storage.get(COPILOT_PROVIDER_ID);\n if (!cred || cred.type !== 'oauth') {\n throw new Error('Not logged in to GitHub Copilot. Run /login first.');\n }\n\n // getApiKey() refreshes the Copilot bearer if it has expired.\n const accessToken = await storage.getApiKey(COPILOT_PROVIDER_ID);\n if (!accessToken) {\n throw new Error('Failed to refresh GitHub Copilot token. Please /login again.');\n }\n storage.reload();\n\n const enterpriseUrl = (cred as GitHubCopilotCredentials).enterpriseUrl;\n\n let parsedBody: unknown;\n if (typeof init?.body === 'string') {\n try {\n parsedBody = JSON.parse(init.body);\n } catch {\n parsedBody = undefined;\n }\n }\n const isAgent = detectIsAgent(parsedBody);\n const isVision = detectIsVision(parsedBody);\n\n // Preserve non-auth headers from caller.\n const headers = new Headers();\n if (init?.headers) {\n const source =\n init.headers instanceof Headers\n ? init.headers\n : Array.isArray(init.headers)\n ? new Headers(init.headers as Array<[string, string]>)\n : new Headers(init.headers as Record<string, string>);\n source.forEach((value, key) => {\n const lower = key.toLowerCase();\n if (lower !== 'authorization' && lower !== 'x-api-key') {\n headers.set(key, value);\n }\n });\n }\n\n headers.set('Authorization', `Bearer ${accessToken}`);\n headers.set('x-initiator', isAgent ? 'agent' : 'user');\n headers.set('Openai-Intent', 'conversation-edits');\n if (isVision) {\n headers.set('Copilot-Vision-Request', 'true');\n }\n for (const [key, value] of Object.entries(COPILOT_HEADERS)) {\n // Only set if caller didn't already provide it (allow overrides for tests).\n if (!headers.has(key)) {\n headers.set(key, value);\n }\n }\n\n const finalUrl =\n opts.rewriteUrl !== false\n ? rewriteToCopilotBase(url, accessToken, enterpriseUrl)\n : url instanceof URL\n ? url\n : typeof url === 'string'\n ? new URL(url)\n : new URL((url as Request).url);\n\n try {\n return await fetch(finalUrl, { ...init, headers });\n } catch (error) {\n if (error && typeof error === 'object') {\n Object.assign(error as Record<string, unknown>, {\n requestUrl: finalUrl.toString(),\n });\n }\n throw error;\n }\n }) as typeof fetch;\n}\n\nfunction rewriteToCopilotBase(url: string | URL | Request, token: string, enterpriseDomain?: string): URL {\n const original = url instanceof URL ? url : new URL(typeof url === 'string' ? url : (url as Request).url);\n const base = new URL(getGitHubCopilotBaseUrl(token, enterpriseDomain));\n // Copilot's OpenAI-compatible API serves endpoints at the root of the base host\n // (`/chat/completions`, `/responses`, `/models`, ...) — not under a `/v1/` prefix\n // like api.openai.com does. The @ai-sdk/openai default baseURL is\n // `https://api.openai.com/v1`, so the SDK builds requests like\n // `https://api.openai.com/v1/chat/completions`. Strip the leading `/v1` segment\n // when rewriting onto the Copilot base or Copilot will return 404 Not Found.\n const pathname = original.pathname.replace(/^\\/v1(\\/|$)/, '/');\n return new URL(`${pathname}${original.search}`, base);\n}\n\nfunction isGeminiModel(modelId: string): boolean {\n return modelId.startsWith('gemini-');\n}\n\nfunction applyGeminiSchemaCompatToTools(modelId: string, tools: unknown): unknown {\n if (!Array.isArray(tools)) {\n return tools;\n }\n\n const compatLayer = new GoogleSchemaCompatLayer({\n provider: COPILOT_PROVIDER_ID,\n modelId,\n supportsStructuredOutputs: false,\n });\n\n return tools.map(tool => {\n if (!tool || typeof tool !== 'object' || (tool as { type?: unknown }).type !== 'function') {\n return tool;\n }\n\n const functionTool = tool as { inputSchema?: JSONSchema7 };\n if (!functionTool.inputSchema) {\n return tool;\n }\n\n return {\n ...functionTool,\n inputSchema: applyCompatLayer({\n schema: functionTool.inputSchema,\n compatLayers: [compatLayer],\n mode: 'aiSdkSchema',\n }).jsonSchema as JSONSchema7,\n };\n });\n}\n\n/** Middleware that prevents sending parameters Copilot's endpoint rejects. */\nfunction createCopilotMiddleware(modelId: string): LanguageModelMiddleware {\n return {\n specificationVersion: 'v3',\n transformParams: async ({ params }) => {\n if (params.temperature !== undefined && params.temperature !== null) {\n delete params.topP;\n }\n\n if (isGeminiModel(modelId)) {\n (params as { tools?: unknown }).tools = applyGeminiSchemaCompatToTools(\n modelId,\n (params as { tools?: unknown }).tools,\n );\n }\n\n return params;\n },\n };\n}\n\n/**\n * Creates a model that talks to GitHub Copilot using OAuth credentials.\n *\n * Copilot's `/chat/completions` endpoint is OpenAI-compatible, but GitHub Copilot\n * is not OpenAI. Use the generic OpenAI-compatible adapter with Copilot's base URL\n * instead of the OpenAI provider plus URL rewriting.\n */\nexport function githubCopilotProvider(\n modelId: string = 'gpt-4.1',\n options?: { headers?: Record<string, string> },\n): MastraModelConfig {\n const headers = options?.headers;\n const copilot = createOpenAICompatible({\n name: COPILOT_PROVIDER_ID,\n baseURL: 'https://api.githubcopilot.com',\n apiKey: process.env.NODE_ENV === 'test' || process.env.VITEST ? 'test-api-key' : 'oauth-placeholder',\n headers,\n fetch:\n process.env.NODE_ENV === 'test' || process.env.VITEST\n ? undefined\n : (buildGitHubCopilotOAuthFetch({ rewriteUrl: false }) as any),\n });\n\n return wrapLanguageModel({\n model: copilot.chatModel(modelId),\n middleware: [createCopilotMiddleware(modelId)],\n });\n}\n\n// ---------------------------------------------------------------------------\n// Live model catalog\n// ---------------------------------------------------------------------------\n\n/**\n * Hard-coded fallback advertised when the live `/models` request fails (network\n * down, expired token, etc.). Keep this conservative because the live catalog is\n * the source of truth for the user's currently-enabled Copilot models.\n *\n * Available across all paid Copilot tiers and free of premium-request charges.\n */\nconst COPILOT_FALLBACK_MODELS: CopilotModelEntry[] = [\n {\n id: 'gpt-4.1',\n name: 'GPT-4.1',\n vendor: 'OpenAI',\n supportedEndpoints: ['/chat/completions'],\n isAnthropicShaped: false,\n supportsVision: true,\n supportsToolCalls: true,\n },\n];\n\nconst CATALOG_TTL_MS = 10 * 60 * 1000;\nconst CATALOG_FAILURE_TTL_MS = 60 * 1000;\nconst CATALOG_FETCH_TIMEOUT_MS = 5_000;\n\ninterface CatalogCacheEntry {\n fetchedAt: number;\n ttl: number;\n models: CopilotModelEntry[];\n}\n\nlet catalogCache: CatalogCacheEntry | null = null;\nlet inflightFetch: Promise<CopilotModelEntry[]> | null = null;\n\n/** Reset the in-process Copilot catalog cache (test seam, also useful after logout). */\nexport function clearCopilotCatalogCache(): void {\n catalogCache = null;\n inflightFetch = null;\n}\n\n/**\n * Return the user's currently-available Copilot models.\n *\n * - Returns `[]` when the user is not logged in to GitHub Copilot.\n * - Returns the cached list when a recent fetch succeeded.\n * - On the cache-miss / expired path, fetches `/models` with a 5s timeout, filters\n * to picker-enabled and non-policy-disabled models, then caches for 10 minutes.\n * - On fetch failure, returns a small hard-coded fallback (so packs still work\n * offline) and caches that for 1 minute to avoid hammering the API.\n *\n * Concurrent calls during a fetch share the inflight promise.\n */\nexport async function getCopilotModelCatalog(opts: { authStorage?: AuthStorage } = {}): Promise<CopilotModelEntry[]> {\n const storage = opts.authStorage ?? getAuthStorage();\n storage.reload();\n\n const cred = storage.get(COPILOT_PROVIDER_ID);\n if (!cred || cred.type !== 'oauth') {\n return [];\n }\n\n const now = Date.now();\n if (catalogCache && now - catalogCache.fetchedAt < catalogCache.ttl) {\n return catalogCache.models;\n }\n\n if (inflightFetch) return inflightFetch;\n\n inflightFetch = (async (): Promise<CopilotModelEntry[]> => {\n try {\n // getApiKey() refreshes the Copilot bearer if it has expired.\n const accessToken = await storage.getApiKey(COPILOT_PROVIDER_ID);\n if (!accessToken) throw new Error('No Copilot bearer token');\n storage.reload();\n\n const refreshed = storage.get(COPILOT_PROVIDER_ID);\n const enterpriseUrl = (refreshed as GitHubCopilotCredentials | undefined)?.enterpriseUrl;\n const baseUrl = getGitHubCopilotBaseUrl(accessToken, enterpriseUrl);\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), CATALOG_FETCH_TIMEOUT_MS);\n try {\n const models = await fetchCopilotModels({\n baseUrl,\n bearerToken: accessToken,\n signal: controller.signal,\n });\n catalogCache = { fetchedAt: Date.now(), ttl: CATALOG_TTL_MS, models };\n return models;\n } finally {\n clearTimeout(timer);\n }\n } catch (error) {\n catalogCache = {\n fetchedAt: Date.now(),\n ttl: CATALOG_FAILURE_TTL_MS,\n models: COPILOT_FALLBACK_MODELS,\n };\n console.warn(\n 'Failed to fetch live GitHub Copilot models, using fallback list:',\n error instanceof Error ? error.message : error,\n );\n return COPILOT_FALLBACK_MODELS;\n } finally {\n inflightFetch = null;\n }\n })();\n\n return inflightFetch;\n}\n"],"mappings":"AAaA,SAAS,8BAA8B;AAGvC,SAAS,kBAAkB,+BAA+B;AAC1D,SAAS,yBAAyB;AAElC,SAAS,iBAAiB,oBAAoB,+BAA+B;AAE7E,SAAS,mBAAmB;AAE5B,MAAM,sBAAsB;AAG5B,IAAI,sBAA0C;AAGvC,SAAS,iBAA8B;AAC5C,MAAI,CAAC,qBAAqB;AACxB,0BAAsB,IAAI,YAAY;AAAA,EACxC;AACA,SAAO;AACT;AAGO,SAAS,eAAe,SAAwC;AACrE,wBAAsB,WAAW;AACnC;AAOA,SAAS,cAAc,MAAwB;AAC7C,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,QAAM,MAAM;AAEZ,QAAM,WAAW,IAAI;AACrB,MAAI,MAAM,QAAQ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AAA,QACA,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MAC3C;AACA,aAAO;AAAA,IACT,UAAE;AACA,sBAAgB;AAAA,IAClB;AAAA,EACF,GAAG;AAEH,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex OAuth Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses OAuth tokens from AuthStorage to authenticate with ChatGPT Plus/Pro subscription.
|
|
5
|
+
* This allows access to OpenAI models through the ChatGPT OAuth flow.
|
|
6
|
+
*
|
|
7
|
+
* Inspired by opencode's Codex plugin implementation:
|
|
8
|
+
* https://github.com/sst/opencode/blob/main/packages/opencode/src/plugin/codex.ts
|
|
9
|
+
*/
|
|
10
|
+
import type { MastraModelConfig } from '@mastra/core/llm';
|
|
11
|
+
import type { LanguageModelMiddleware } from 'ai';
|
|
12
|
+
import { AuthStorage } from '../auth/storage.js';
|
|
13
|
+
/**
|
|
14
|
+
* Get or create the shared AuthStorage instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAuthStorage(): AuthStorage;
|
|
17
|
+
/**
|
|
18
|
+
* Set a custom AuthStorage instance (useful for TUI integration)
|
|
19
|
+
*/
|
|
20
|
+
export declare function setAuthStorage(storage: AuthStorage | undefined): void;
|
|
21
|
+
/** Valid thinking level values. */
|
|
22
|
+
export type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
23
|
+
export declare function getEffectiveThinkingLevel(modelId: string, level: ThinkingLevel): ThinkingLevel;
|
|
24
|
+
export declare const THINKING_LEVEL_TO_REASONING_EFFORT: Record<ThinkingLevel, string | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Create Codex middleware with the given reasoning effort level.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createCodexMiddleware(reasoningEffort?: string): LanguageModelMiddleware;
|
|
29
|
+
/**
|
|
30
|
+
* Build a fetch function that handles OpenAI Codex OAuth.
|
|
31
|
+
* Preserves non-authorization headers from init.
|
|
32
|
+
* When rewriteUrl is true (default), rewrites /v1/responses and /chat/completions
|
|
33
|
+
* to the Codex API endpoint. Set rewriteUrl: false for gateway usage where the
|
|
34
|
+
* SDK already targets the correct URL.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildOpenAICodexOAuthFetch(opts?: {
|
|
37
|
+
authStorage?: AuthStorage;
|
|
38
|
+
rewriteUrl?: boolean;
|
|
39
|
+
}): typeof fetch;
|
|
40
|
+
/**
|
|
41
|
+
* Build a fetch function for Stagehand-on-Codex.
|
|
42
|
+
*
|
|
43
|
+
* The Codex backend has two requirements that AI SDK's non-streaming
|
|
44
|
+
* `generateText` path doesn't naturally satisfy:
|
|
45
|
+
*
|
|
46
|
+
* 1. `stream: true` must be set on every request body.
|
|
47
|
+
* 2. The response is delivered as Server-Sent Events; AI SDK's
|
|
48
|
+
* non-streaming code path expects a single JSON body.
|
|
49
|
+
*
|
|
50
|
+
* This fetch forces streaming on the outgoing request, collects the SSE
|
|
51
|
+
* events, and synthesizes the non-streaming JSON shape that
|
|
52
|
+
* `@ai-sdk/openai`'s Responses API parser expects.
|
|
53
|
+
*
|
|
54
|
+
* Headers, OAuth refresh, and URL targeting are handled by the caller via
|
|
55
|
+
* `baseURL` / `headers` on the AI SDK provider; this fetch only injects the
|
|
56
|
+
* live OAuth bearer per call.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildCodexStagehandFetch(authStorage: AuthStorage): typeof fetch;
|
|
59
|
+
/**
|
|
60
|
+
* Creates an OpenAI model using ChatGPT OAuth authentication
|
|
61
|
+
* Uses OAuth tokens from AuthStorage (auto-refreshes when needed)
|
|
62
|
+
*
|
|
63
|
+
* IMPORTANT: This uses the Codex API endpoint, not the standard OpenAI API.
|
|
64
|
+
* URLs are rewritten from /v1/responses or /chat/completions to the Codex endpoint.
|
|
65
|
+
*/
|
|
66
|
+
export declare function openaiCodexProvider(modelId?: string, options?: {
|
|
67
|
+
thinkingLevel?: ThinkingLevel;
|
|
68
|
+
headers?: Record<string, string>;
|
|
69
|
+
}): MastraModelConfig;
|
|
70
|
+
//# sourceMappingURL=openai-codex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-codex.d.ts","sourceRoot":"","sources":["../../src/providers/openai-codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,IAAI,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUjD;;GAEG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAErE;AAOD,mCAAmC;AACnC,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAIxE,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,aAAa,CAO9F;AAID,eAAO,MAAM,kCAAkC,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAMxF,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,uBAAuB,CA4BvF;AAqCD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7D,OAAO,KAAK,CAyDd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,KAAK,CAgC/E;AAwID;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,MAA4B,EACrC,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC5E,iBAAiB,CAmCnB"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
+
import { wrapLanguageModel } from "ai";
|
|
3
|
+
import { AuthStorage } from "../auth/storage.js";
|
|
4
|
+
const CODEX_API_ENDPOINT = "https://chatgpt.com/backend-api/codex/responses";
|
|
5
|
+
const CODEX_ORIGINATOR = "mastracode";
|
|
6
|
+
const CODEX_USER_AGENT = "mastracode";
|
|
7
|
+
let authStorageInstance = null;
|
|
8
|
+
function getAuthStorage() {
|
|
9
|
+
if (!authStorageInstance) {
|
|
10
|
+
authStorageInstance = new AuthStorage();
|
|
11
|
+
}
|
|
12
|
+
return authStorageInstance;
|
|
13
|
+
}
|
|
14
|
+
function setAuthStorage(storage) {
|
|
15
|
+
authStorageInstance = storage ?? null;
|
|
16
|
+
}
|
|
17
|
+
const CODEX_INSTRUCTIONS = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
18
|
+
|
|
19
|
+
IMPORTANT: You should be concise, direct, and helpful. Focus on solving the user's problem efficiently.`;
|
|
20
|
+
const GPT5_MODEL_RE = /^gpt-5(?:\.|-|$)/;
|
|
21
|
+
function getEffectiveThinkingLevel(modelId, level) {
|
|
22
|
+
if (GPT5_MODEL_RE.test(modelId) && level === "off") {
|
|
23
|
+
return "low";
|
|
24
|
+
}
|
|
25
|
+
return level;
|
|
26
|
+
}
|
|
27
|
+
const THINKING_LEVEL_TO_REASONING_EFFORT = {
|
|
28
|
+
off: void 0,
|
|
29
|
+
low: "low",
|
|
30
|
+
medium: "medium",
|
|
31
|
+
high: "high",
|
|
32
|
+
xhigh: "xhigh"
|
|
33
|
+
};
|
|
34
|
+
function createCodexMiddleware(reasoningEffort) {
|
|
35
|
+
return {
|
|
36
|
+
specificationVersion: "v3",
|
|
37
|
+
transformParams: async ({ params }) => {
|
|
38
|
+
if (params.temperature !== void 0 && params.temperature !== null) {
|
|
39
|
+
delete params.topP;
|
|
40
|
+
}
|
|
41
|
+
params.providerOptions = {
|
|
42
|
+
...params.providerOptions,
|
|
43
|
+
openai: {
|
|
44
|
+
...params.providerOptions?.openai ?? {},
|
|
45
|
+
instructions: CODEX_INSTRUCTIONS,
|
|
46
|
+
// Codex API requires store to be false
|
|
47
|
+
store: false,
|
|
48
|
+
// Enable reasoning for Codex models — without this, the model
|
|
49
|
+
// skips the reasoning/action phase and goes straight to final_answer,
|
|
50
|
+
// resulting in narration instead of tool calls.
|
|
51
|
+
...reasoningEffort ? { reasoningEffort } : {}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return params;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function getCodexBearer(authStorage) {
|
|
59
|
+
const storage = authStorage ?? getAuthStorage();
|
|
60
|
+
storage.reload();
|
|
61
|
+
const cred = storage.get("openai-codex");
|
|
62
|
+
if (!cred || cred.type !== "oauth") {
|
|
63
|
+
throw new Error("Not logged in to OpenAI Codex. Run /login first.");
|
|
64
|
+
}
|
|
65
|
+
let accessToken = cred.access;
|
|
66
|
+
if (Date.now() >= cred.expires) {
|
|
67
|
+
const refreshedToken = await storage.getApiKey("openai-codex");
|
|
68
|
+
if (!refreshedToken) {
|
|
69
|
+
throw new Error("Failed to refresh OpenAI Codex token. Please /login again.");
|
|
70
|
+
}
|
|
71
|
+
accessToken = refreshedToken;
|
|
72
|
+
storage.reload();
|
|
73
|
+
}
|
|
74
|
+
return { accessToken, accountId: cred.accountId };
|
|
75
|
+
}
|
|
76
|
+
function buildOpenAICodexOAuthFetch(opts = {}) {
|
|
77
|
+
return (async (url, init) => {
|
|
78
|
+
const { accessToken, accountId } = await getCodexBearer(opts.authStorage);
|
|
79
|
+
const headers = new Headers();
|
|
80
|
+
if (init?.headers) {
|
|
81
|
+
if (init.headers instanceof Headers) {
|
|
82
|
+
init.headers.forEach((value, key) => {
|
|
83
|
+
if (key.toLowerCase() !== "authorization") {
|
|
84
|
+
headers.set(key, value);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else if (Array.isArray(init.headers)) {
|
|
88
|
+
for (const [key, value] of init.headers) {
|
|
89
|
+
if (key.toLowerCase() !== "authorization" && value !== void 0) {
|
|
90
|
+
headers.set(key, String(value));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
for (const [key, value] of Object.entries(init.headers)) {
|
|
95
|
+
if (key.toLowerCase() !== "authorization" && value !== void 0) {
|
|
96
|
+
headers.set(key, String(value));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
102
|
+
if (!headers.has("originator")) {
|
|
103
|
+
headers.set("originator", CODEX_ORIGINATOR);
|
|
104
|
+
}
|
|
105
|
+
if (!headers.has("User-Agent")) {
|
|
106
|
+
headers.set("User-Agent", CODEX_USER_AGENT);
|
|
107
|
+
}
|
|
108
|
+
if (accountId) {
|
|
109
|
+
headers.set("ChatGPT-Account-ID", accountId);
|
|
110
|
+
}
|
|
111
|
+
const parsed = url instanceof URL ? url : new URL(typeof url === "string" ? url : url.url);
|
|
112
|
+
const shouldRewrite = opts.rewriteUrl !== false && (parsed.pathname.includes("/v1/responses") || parsed.pathname.includes("/chat/completions"));
|
|
113
|
+
const finalUrl = shouldRewrite ? new URL(CODEX_API_ENDPOINT) : parsed;
|
|
114
|
+
try {
|
|
115
|
+
return await fetch(finalUrl, { ...init, headers });
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (error && typeof error === "object") {
|
|
118
|
+
Object.assign(error, {
|
|
119
|
+
requestUrl: finalUrl.toString()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function buildCodexStagehandFetch(authStorage) {
|
|
127
|
+
return (async (url, init) => {
|
|
128
|
+
const { accessToken } = await getCodexBearer(authStorage);
|
|
129
|
+
const headers = new Headers(init?.headers);
|
|
130
|
+
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
131
|
+
headers.set("Accept", "text/event-stream");
|
|
132
|
+
let body = init?.body;
|
|
133
|
+
if (typeof init?.body === "string") {
|
|
134
|
+
try {
|
|
135
|
+
const parsed = JSON.parse(init.body);
|
|
136
|
+
parsed.stream = true;
|
|
137
|
+
body = JSON.stringify(parsed);
|
|
138
|
+
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const upstream = await fetch(url, { ...init, headers, body });
|
|
143
|
+
if (!upstream.ok) return upstream;
|
|
144
|
+
const aggregated = await aggregateCodexStream(upstream);
|
|
145
|
+
return new Response(aggregated, {
|
|
146
|
+
status: 200,
|
|
147
|
+
headers: { "content-type": "application/json" }
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async function aggregateCodexStream(response) {
|
|
152
|
+
if (!response.body) {
|
|
153
|
+
throw new Error("Codex streaming response had no body");
|
|
154
|
+
}
|
|
155
|
+
const reader = response.body.getReader();
|
|
156
|
+
const decoder = new TextDecoder("utf-8");
|
|
157
|
+
let buffer = "";
|
|
158
|
+
let finalResponse = null;
|
|
159
|
+
let createdResponse = null;
|
|
160
|
+
const items = /* @__PURE__ */ new Map();
|
|
161
|
+
const textBuffers = /* @__PURE__ */ new Map();
|
|
162
|
+
const handleEvent = (event) => {
|
|
163
|
+
if (!event.data || event.data === "[DONE]") return;
|
|
164
|
+
let payload;
|
|
165
|
+
try {
|
|
166
|
+
payload = JSON.parse(event.data);
|
|
167
|
+
} catch {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const type = payload.type ?? event.event ?? "";
|
|
171
|
+
switch (type) {
|
|
172
|
+
case "response.created": {
|
|
173
|
+
createdResponse = payload.response ?? createdResponse;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "response.output_item.added": {
|
|
177
|
+
if (typeof payload.output_index === "number" && payload.item) {
|
|
178
|
+
items.set(payload.output_index, payload.item);
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "response.output_item.done": {
|
|
183
|
+
if (typeof payload.output_index === "number" && payload.item) {
|
|
184
|
+
items.set(payload.output_index, payload.item);
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
case "response.output_text.delta": {
|
|
189
|
+
const key = `${payload.output_index}:${payload.content_index ?? 0}`;
|
|
190
|
+
textBuffers.set(key, (textBuffers.get(key) ?? "") + (payload.delta ?? ""));
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "response.completed": {
|
|
194
|
+
finalResponse = payload.response ?? finalResponse;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
case "response.error":
|
|
198
|
+
case "error": {
|
|
199
|
+
throw new Error(`Codex stream error: ${JSON.stringify(payload.error ?? payload)}`);
|
|
200
|
+
}
|
|
201
|
+
default:
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const processChunk = (chunk) => {
|
|
206
|
+
buffer += chunk.replace(/\r\n/g, "\n");
|
|
207
|
+
let sepIdx;
|
|
208
|
+
while ((sepIdx = buffer.indexOf("\n\n")) !== -1) {
|
|
209
|
+
const raw = buffer.slice(0, sepIdx);
|
|
210
|
+
buffer = buffer.slice(sepIdx + 2);
|
|
211
|
+
const event = {};
|
|
212
|
+
const dataLines = [];
|
|
213
|
+
for (const line of raw.split("\n")) {
|
|
214
|
+
if (line.startsWith("event:")) {
|
|
215
|
+
event.event = line.slice(6).trim();
|
|
216
|
+
} else if (line.startsWith("data:")) {
|
|
217
|
+
dataLines.push(line.slice(5).trimStart());
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (dataLines.length > 0) {
|
|
221
|
+
event.data = dataLines.join("\n");
|
|
222
|
+
}
|
|
223
|
+
handleEvent(event);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
try {
|
|
227
|
+
while (true) {
|
|
228
|
+
const { value, done } = await reader.read();
|
|
229
|
+
if (done) break;
|
|
230
|
+
processChunk(decoder.decode(value, { stream: true }));
|
|
231
|
+
}
|
|
232
|
+
processChunk(decoder.decode());
|
|
233
|
+
} finally {
|
|
234
|
+
reader.releaseLock();
|
|
235
|
+
}
|
|
236
|
+
const base = finalResponse ?? createdResponse ?? { output: [] };
|
|
237
|
+
const finalItems = Array.from(items.entries()).sort(([a], [b]) => a - b).map(([index, item]) => {
|
|
238
|
+
if (item?.type === "message" && Array.isArray(item.content)) {
|
|
239
|
+
item.content = item.content.map((c, ci) => {
|
|
240
|
+
const key = `${index}:${ci}`;
|
|
241
|
+
if (textBuffers.has(key)) {
|
|
242
|
+
return { ...c, text: textBuffers.get(key) };
|
|
243
|
+
}
|
|
244
|
+
return c;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return item;
|
|
248
|
+
});
|
|
249
|
+
base.output = finalItems.length > 0 ? finalItems : base.output ?? [];
|
|
250
|
+
return JSON.stringify(base);
|
|
251
|
+
}
|
|
252
|
+
function openaiCodexProvider(modelId = "codex-mini-latest", options) {
|
|
253
|
+
const requestedLevel = options?.thinkingLevel ?? "medium";
|
|
254
|
+
const effectiveLevel = getEffectiveThinkingLevel(modelId, requestedLevel);
|
|
255
|
+
const reasoningEffort = THINKING_LEVEL_TO_REASONING_EFFORT[effectiveLevel];
|
|
256
|
+
const middleware = createCodexMiddleware(reasoningEffort);
|
|
257
|
+
const headers = options?.headers;
|
|
258
|
+
const baseURL = process.env.OPENAI_BASE_URL;
|
|
259
|
+
if (process.env.NODE_ENV === "test" || process.env.VITEST) {
|
|
260
|
+
const openai2 = createOpenAI({
|
|
261
|
+
apiKey: "test-api-key",
|
|
262
|
+
baseURL,
|
|
263
|
+
headers
|
|
264
|
+
});
|
|
265
|
+
return wrapLanguageModel({
|
|
266
|
+
model: openai2.responses(modelId),
|
|
267
|
+
middleware: [middleware]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const openai = createOpenAI({
|
|
271
|
+
apiKey: "oauth-dummy-key",
|
|
272
|
+
baseURL,
|
|
273
|
+
headers,
|
|
274
|
+
fetch: buildOpenAICodexOAuthFetch()
|
|
275
|
+
});
|
|
276
|
+
return wrapLanguageModel({
|
|
277
|
+
model: openai.responses(modelId),
|
|
278
|
+
middleware: [middleware]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
export {
|
|
282
|
+
THINKING_LEVEL_TO_REASONING_EFFORT,
|
|
283
|
+
buildCodexStagehandFetch,
|
|
284
|
+
buildOpenAICodexOAuthFetch,
|
|
285
|
+
createCodexMiddleware,
|
|
286
|
+
getAuthStorage,
|
|
287
|
+
getEffectiveThinkingLevel,
|
|
288
|
+
openaiCodexProvider,
|
|
289
|
+
setAuthStorage
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=openai-codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/openai-codex.ts"],"sourcesContent":["/**\n * OpenAI Codex OAuth Provider\n *\n * Uses OAuth tokens from AuthStorage to authenticate with ChatGPT Plus/Pro subscription.\n * This allows access to OpenAI models through the ChatGPT OAuth flow.\n *\n * Inspired by opencode's Codex plugin implementation:\n * https://github.com/sst/opencode/blob/main/packages/opencode/src/plugin/codex.ts\n */\n\nimport { createOpenAI } from '@ai-sdk/openai';\nimport type { MastraModelConfig } from '@mastra/core/llm';\nimport { wrapLanguageModel } from 'ai';\nimport type { LanguageModelMiddleware } from 'ai';\nimport { AuthStorage } from '../auth/storage.js';\n\n// Codex API endpoint (not standard OpenAI API)\nconst CODEX_API_ENDPOINT = 'https://chatgpt.com/backend-api/codex/responses';\nconst CODEX_ORIGINATOR = 'mastracode';\nconst CODEX_USER_AGENT = 'mastracode';\n\n// Singleton auth storage instance (shared with claude-max.ts)\nlet authStorageInstance: AuthStorage | null = null;\n\n/**\n * Get or create the shared AuthStorage instance\n */\nexport function getAuthStorage(): AuthStorage {\n if (!authStorageInstance) {\n authStorageInstance = new AuthStorage();\n }\n return authStorageInstance;\n}\n\n/**\n * Set a custom AuthStorage instance (useful for TUI integration)\n */\nexport function setAuthStorage(storage: AuthStorage | undefined): void {\n authStorageInstance = storage ?? null;\n}\n\n// Default instructions for Codex API (required)\nconst CODEX_INSTRUCTIONS = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: You should be concise, direct, and helpful. Focus on solving the user's problem efficiently.`;\n\n/** Valid thinking level values. */\nexport type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'xhigh';\n\nconst GPT5_MODEL_RE = /^gpt-5(?:\\.|-|$)/;\n\nexport function getEffectiveThinkingLevel(modelId: string, level: ThinkingLevel): ThinkingLevel {\n // GPT-5.* models on Codex require at least low reasoning.\n if (GPT5_MODEL_RE.test(modelId) && level === 'off') {\n return 'low';\n }\n\n return level;\n}\n\n// Map thinkingLevel state values to OpenAI reasoningEffort values.\n// undefined means omit the parameter (no reasoning).\nexport const THINKING_LEVEL_TO_REASONING_EFFORT: Record<ThinkingLevel, string | undefined> = {\n off: undefined,\n low: 'low',\n medium: 'medium',\n high: 'high',\n xhigh: 'xhigh',\n};\n\n/**\n * Create Codex middleware with the given reasoning effort level.\n */\nexport function createCodexMiddleware(reasoningEffort?: string): LanguageModelMiddleware {\n return {\n specificationVersion: 'v3',\n transformParams: async ({ params }) => {\n // Remove topP if temperature is set (OpenAI doesn't like both)\n if (params.temperature !== undefined && params.temperature !== null) {\n delete params.topP;\n }\n\n // Codex API requires specific settings via providerOptions\n // Use type assertion to satisfy JSONValue constraints\n params.providerOptions = {\n ...params.providerOptions,\n openai: {\n ...(params.providerOptions?.openai ?? {}),\n instructions: CODEX_INSTRUCTIONS,\n // Codex API requires store to be false\n store: false,\n // Enable reasoning for Codex models — without this, the model\n // skips the reasoning/action phase and goes straight to final_answer,\n // resulting in narration instead of tool calls.\n ...(reasoningEffort ? { reasoningEffort } : {}),\n },\n } as typeof params.providerOptions;\n\n return params;\n },\n };\n}\n\n/**\n * Get a live OAuth bearer token for the Codex OAuth credential.\n *\n * Refreshes the token if it's expired, and returns the credential's\n * accountId alongside the access token. Throws if the user isn't logged in\n * or if the refresh fails.\n *\n * This is the only piece of Codex auth that is genuinely shared between\n * the main agent's fetch (`buildOpenAICodexOAuthFetch`) and the Stagehand\n * fetch (`buildCodexStagehandFetch`).\n */\nasync function getCodexBearer(\n authStorage?: AuthStorage,\n): Promise<{ accessToken: string; accountId: string | undefined }> {\n const storage = authStorage ?? getAuthStorage();\n storage.reload();\n\n const cred = storage.get('openai-codex');\n if (!cred || cred.type !== 'oauth') {\n throw new Error('Not logged in to OpenAI Codex. Run /login first.');\n }\n\n let accessToken = cred.access;\n if (Date.now() >= cred.expires) {\n const refreshedToken = await storage.getApiKey('openai-codex');\n if (!refreshedToken) {\n throw new Error('Failed to refresh OpenAI Codex token. Please /login again.');\n }\n accessToken = refreshedToken;\n storage.reload();\n }\n\n return { accessToken, accountId: (cred as any).accountId as string | undefined };\n}\n\n/**\n * Build a fetch function that handles OpenAI Codex OAuth.\n * Preserves non-authorization headers from init.\n * When rewriteUrl is true (default), rewrites /v1/responses and /chat/completions\n * to the Codex API endpoint. Set rewriteUrl: false for gateway usage where the\n * SDK already targets the correct URL.\n */\nexport function buildOpenAICodexOAuthFetch(\n opts: { authStorage?: AuthStorage; rewriteUrl?: boolean } = {},\n): typeof fetch {\n return (async (url: string | URL | Request, init?: Parameters<typeof fetch>[1]) => {\n const { accessToken, accountId } = await getCodexBearer(opts.authStorage);\n\n // Preserve non-authorization headers\n const headers = new Headers();\n if (init?.headers) {\n if (init.headers instanceof Headers) {\n init.headers.forEach((value, key) => {\n if (key.toLowerCase() !== 'authorization') {\n headers.set(key, value);\n }\n });\n } else if (Array.isArray(init.headers)) {\n for (const [key, value] of init.headers) {\n if (key!.toLowerCase() !== 'authorization' && value !== undefined) {\n headers.set(key!, String(value));\n }\n }\n } else {\n for (const [key, value] of Object.entries(init.headers)) {\n if (key.toLowerCase() !== 'authorization' && value !== undefined) {\n headers.set(key, String(value));\n }\n }\n }\n }\n\n headers.set('Authorization', `Bearer ${accessToken}`);\n if (!headers.has('originator')) {\n headers.set('originator', CODEX_ORIGINATOR);\n }\n if (!headers.has('User-Agent')) {\n headers.set('User-Agent', CODEX_USER_AGENT);\n }\n if (accountId) {\n headers.set('ChatGPT-Account-ID', accountId);\n }\n\n // URL rewriting — only when rewriteUrl !== false\n const parsed = url instanceof URL ? url : new URL(typeof url === 'string' ? url : (url as Request).url);\n const shouldRewrite =\n opts.rewriteUrl !== false &&\n (parsed.pathname.includes('/v1/responses') || parsed.pathname.includes('/chat/completions'));\n const finalUrl = shouldRewrite ? new URL(CODEX_API_ENDPOINT) : parsed;\n\n try {\n return await fetch(finalUrl, { ...init, headers });\n } catch (error) {\n if (error && typeof error === 'object') {\n Object.assign(error as Record<string, unknown>, {\n requestUrl: finalUrl.toString(),\n });\n }\n throw error;\n }\n }) as typeof fetch;\n}\n\n/**\n * Build a fetch function for Stagehand-on-Codex.\n *\n * The Codex backend has two requirements that AI SDK's non-streaming\n * `generateText` path doesn't naturally satisfy:\n *\n * 1. `stream: true` must be set on every request body.\n * 2. The response is delivered as Server-Sent Events; AI SDK's\n * non-streaming code path expects a single JSON body.\n *\n * This fetch forces streaming on the outgoing request, collects the SSE\n * events, and synthesizes the non-streaming JSON shape that\n * `@ai-sdk/openai`'s Responses API parser expects.\n *\n * Headers, OAuth refresh, and URL targeting are handled by the caller via\n * `baseURL` / `headers` on the AI SDK provider; this fetch only injects the\n * live OAuth bearer per call.\n */\nexport function buildCodexStagehandFetch(authStorage: AuthStorage): typeof fetch {\n return (async (url: string | URL | Request, init?: Parameters<typeof fetch>[1]) => {\n // Refresh + inject the OAuth bearer per call\n const { accessToken } = await getCodexBearer(authStorage);\n const headers = new Headers(init?.headers);\n headers.set('Authorization', `Bearer ${accessToken}`);\n headers.set('Accept', 'text/event-stream');\n\n // Force stream: true on the request body\n type FetchBody = NonNullable<Parameters<typeof fetch>[1]>['body'];\n let body: FetchBody | undefined = init?.body;\n if (typeof init?.body === 'string') {\n try {\n const parsed = JSON.parse(init.body) as Record<string, unknown>;\n parsed.stream = true;\n body = JSON.stringify(parsed);\n if (!headers.has('content-type')) headers.set('content-type', 'application/json');\n } catch {\n // Not JSON; leave as-is\n }\n }\n\n const upstream = await fetch(url, { ...init, headers, body });\n if (!upstream.ok) return upstream;\n\n // Aggregate SSE -> synthesized non-streaming Response\n const aggregated = await aggregateCodexStream(upstream);\n return new Response(aggregated, {\n status: 200,\n headers: { 'content-type': 'application/json' },\n });\n }) as typeof fetch;\n}\n\n/**\n * Read an SSE Response and reduce it to a single JSON string matching the\n * non-streaming OpenAI Responses-API shape.\n *\n * Event vocabulary we care about (per OpenAI Responses API streaming):\n * - response.created → carries `response` object (id, model, usage stub)\n * - response.output_item.added/done → output items (message, reasoning, etc.)\n * - response.output_text.delta → text chunks\n * - response.completed → final `response` snapshot incl. usage\n * - response.error / error → bubble up as a thrown body\n *\n * Reasoning events (`response.reasoning_summary.*`) are intentionally ignored\n * for the non-streaming text response.\n */\nasync function aggregateCodexStream(response: Response): Promise<string> {\n if (!response.body) {\n throw new Error('Codex streaming response had no body');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder('utf-8');\n let buffer = '';\n\n let finalResponse: any = null;\n let createdResponse: any = null;\n // Track output_items by index so we can rebuild the final array\n const items = new Map<number, any>();\n // Accumulate output_text deltas keyed by item_index + content_index\n const textBuffers = new Map<string, string>();\n\n const handleEvent = (event: { event?: string; data?: string }) => {\n if (!event.data || event.data === '[DONE]') return;\n let payload: any;\n try {\n payload = JSON.parse(event.data);\n } catch {\n return;\n }\n const type: string = payload.type ?? event.event ?? '';\n\n switch (type) {\n case 'response.created': {\n createdResponse = payload.response ?? createdResponse;\n break;\n }\n case 'response.output_item.added': {\n if (typeof payload.output_index === 'number' && payload.item) {\n items.set(payload.output_index, payload.item);\n }\n break;\n }\n case 'response.output_item.done': {\n if (typeof payload.output_index === 'number' && payload.item) {\n items.set(payload.output_index, payload.item);\n }\n break;\n }\n case 'response.output_text.delta': {\n const key = `${payload.output_index}:${payload.content_index ?? 0}`;\n textBuffers.set(key, (textBuffers.get(key) ?? '') + (payload.delta ?? ''));\n break;\n }\n case 'response.completed': {\n finalResponse = payload.response ?? finalResponse;\n break;\n }\n case 'response.error':\n case 'error': {\n throw new Error(`Codex stream error: ${JSON.stringify(payload.error ?? payload)}`);\n }\n default:\n // Ignore reasoning / unknown events\n break;\n }\n };\n\n // SSE parser: events separated by blank line; lines like \"event: x\" / \"data: y\"\n // Normalize CRLF→LF so \\r\\n\\r\\n event boundaries parse correctly (SSE spec allows CRLF).\n const processChunk = (chunk: string) => {\n buffer += chunk.replace(/\\r\\n/g, '\\n');\n let sepIdx: number;\n while ((sepIdx = buffer.indexOf('\\n\\n')) !== -1) {\n const raw = buffer.slice(0, sepIdx);\n buffer = buffer.slice(sepIdx + 2);\n const event: { event?: string; data?: string } = {};\n const dataLines: string[] = [];\n for (const line of raw.split('\\n')) {\n if (line.startsWith('event:')) {\n event.event = line.slice(6).trim();\n } else if (line.startsWith('data:')) {\n dataLines.push(line.slice(5).trimStart());\n }\n }\n if (dataLines.length > 0) {\n event.data = dataLines.join('\\n');\n }\n handleEvent(event);\n }\n };\n\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n processChunk(decoder.decode(value, { stream: true }));\n }\n processChunk(decoder.decode());\n } finally {\n reader.releaseLock();\n }\n\n // Stitch accumulated text deltas back into their items\n const base = finalResponse ?? createdResponse ?? { output: [] };\n const finalItems = Array.from(items.entries())\n .sort(([a], [b]) => a - b)\n .map(([index, item]) => {\n // Patch message-type items' content text using buffered deltas\n if (item?.type === 'message' && Array.isArray(item.content)) {\n item.content = item.content.map((c: any, ci: number) => {\n const key = `${index}:${ci}`;\n if (textBuffers.has(key)) {\n return { ...c, text: textBuffers.get(key) };\n }\n return c;\n });\n }\n return item;\n });\n\n base.output = finalItems.length > 0 ? finalItems : (base.output ?? []);\n\n return JSON.stringify(base);\n}\n\n/**\n * Creates an OpenAI model using ChatGPT OAuth authentication\n * Uses OAuth tokens from AuthStorage (auto-refreshes when needed)\n *\n * IMPORTANT: This uses the Codex API endpoint, not the standard OpenAI API.\n * URLs are rewritten from /v1/responses or /chat/completions to the Codex endpoint.\n */\nexport function openaiCodexProvider(\n modelId: string = 'codex-mini-latest',\n options?: { thinkingLevel?: ThinkingLevel; headers?: Record<string, string> },\n): MastraModelConfig {\n const requestedLevel: ThinkingLevel = options?.thinkingLevel ?? 'medium';\n const effectiveLevel = getEffectiveThinkingLevel(modelId, requestedLevel);\n const reasoningEffort = THINKING_LEVEL_TO_REASONING_EFFORT[effectiveLevel];\n const middleware = createCodexMiddleware(reasoningEffort);\n const headers = options?.headers;\n\n const baseURL = process.env.OPENAI_BASE_URL;\n\n // Test environment: use API key\n if (process.env.NODE_ENV === 'test' || process.env.VITEST) {\n const openai = createOpenAI({\n apiKey: 'test-api-key',\n baseURL,\n headers,\n });\n return wrapLanguageModel({\n model: openai.responses(modelId),\n middleware: [middleware],\n });\n }\n\n const openai = createOpenAI({\n apiKey: 'oauth-dummy-key',\n baseURL,\n headers,\n fetch: buildOpenAICodexOAuthFetch() as any,\n });\n\n // Use the responses API for Codex models\n // Wrap with middleware\n return wrapLanguageModel({\n model: openai.responses(modelId),\n middleware: [middleware],\n });\n}\n"],"mappings":"AAUA,SAAS,oBAAoB;AAE7B,SAAS,yBAAyB;AAElC,SAAS,mBAAmB;AAG5B,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AA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;","names":["openai"]}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type PermissionPolicy = 'allow' | 'ask' | 'deny';
|
|
3
|
+
export type MastraCodeSessionState = {
|
|
4
|
+
currentModelId: string;
|
|
5
|
+
modeId: string;
|
|
6
|
+
};
|
|
7
|
+
export type MastraCodeComposedState = MastraCodeState & MastraCodeSessionState;
|
|
8
|
+
export interface MastraCodeState {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
[key: `subagentModelId_${string}`]: string | undefined;
|
|
11
|
+
subagentModelId?: string;
|
|
12
|
+
projectPath?: string;
|
|
13
|
+
projectName?: string;
|
|
14
|
+
/** When set, this project is a GitHub/cloud-sandbox-backed project. */
|
|
15
|
+
githubProjectId?: string;
|
|
16
|
+
/** Persisted sandbox id for reattaching the project's cloud workspace. */
|
|
17
|
+
sandboxId?: string;
|
|
18
|
+
/** Path inside the sandbox the repo is cloned into. */
|
|
19
|
+
sandboxWorkdir?: string;
|
|
20
|
+
/** Active git worktree path inside the sandbox for the current unit of work. */
|
|
21
|
+
worktreePath?: string;
|
|
22
|
+
/** Active feature branch checked out in the worktree. */
|
|
23
|
+
branch?: string;
|
|
24
|
+
configDir: string;
|
|
25
|
+
homeDir?: string;
|
|
26
|
+
gitBranch?: string;
|
|
27
|
+
lastCommand?: string;
|
|
28
|
+
observerModelId: string;
|
|
29
|
+
reflectorModelId: string;
|
|
30
|
+
observationThreshold: number;
|
|
31
|
+
reflectionThreshold: number;
|
|
32
|
+
cavemanObservations: boolean;
|
|
33
|
+
observeAttachments: 'auto' | boolean;
|
|
34
|
+
omScope?: 'thread' | 'resource';
|
|
35
|
+
thinkingLevel: 'off' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
36
|
+
yolo: boolean;
|
|
37
|
+
permissionRules: {
|
|
38
|
+
categories: Record<string, PermissionPolicy>;
|
|
39
|
+
tools: Record<string, PermissionPolicy>;
|
|
40
|
+
};
|
|
41
|
+
smartEditing: boolean;
|
|
42
|
+
notifications: 'bell' | 'system' | 'both' | 'off';
|
|
43
|
+
tasks: Array<{
|
|
44
|
+
id?: string;
|
|
45
|
+
content: string;
|
|
46
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
47
|
+
activeForm: string;
|
|
48
|
+
}>;
|
|
49
|
+
sandboxAllowedPaths: string[];
|
|
50
|
+
pluginSkillPaths: string[];
|
|
51
|
+
pluginCommandPaths: string[];
|
|
52
|
+
pluginInstructions: string[];
|
|
53
|
+
activePlan: {
|
|
54
|
+
title: string;
|
|
55
|
+
plan: string;
|
|
56
|
+
approvedAt: string;
|
|
57
|
+
} | null;
|
|
58
|
+
activeBrowserSettings?: {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
provider: 'stagehand' | 'agent-browser';
|
|
61
|
+
headless?: boolean;
|
|
62
|
+
viewport?: {
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
cdpUrl?: string;
|
|
67
|
+
stagehand?: {
|
|
68
|
+
env: 'LOCAL' | 'BROWSERBASE';
|
|
69
|
+
apiKey?: string;
|
|
70
|
+
projectId?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare const stateSchema: z.ZodObject<{
|
|
75
|
+
currentModelId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
modeId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
subagentModelId: z.ZodOptional<z.ZodString>;
|
|
78
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
79
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
80
|
+
githubProjectId: z.ZodOptional<z.ZodString>;
|
|
81
|
+
sandboxId: z.ZodOptional<z.ZodString>;
|
|
82
|
+
sandboxWorkdir: z.ZodOptional<z.ZodString>;
|
|
83
|
+
worktreePath: z.ZodOptional<z.ZodString>;
|
|
84
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
85
|
+
configDir: z.ZodDefault<z.ZodString>;
|
|
86
|
+
homeDir: z.ZodOptional<z.ZodString>;
|
|
87
|
+
gitBranch: z.ZodOptional<z.ZodString>;
|
|
88
|
+
lastCommand: z.ZodOptional<z.ZodString>;
|
|
89
|
+
observerModelId: z.ZodDefault<z.ZodString>;
|
|
90
|
+
reflectorModelId: z.ZodDefault<z.ZodString>;
|
|
91
|
+
observationThreshold: z.ZodDefault<z.ZodNumber>;
|
|
92
|
+
reflectionThreshold: z.ZodDefault<z.ZodNumber>;
|
|
93
|
+
cavemanObservations: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
observeAttachments: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodBoolean]>>;
|
|
95
|
+
omScope: z.ZodOptional<z.ZodEnum<{
|
|
96
|
+
thread: "thread";
|
|
97
|
+
resource: "resource";
|
|
98
|
+
}>>;
|
|
99
|
+
thinkingLevel: z.ZodDefault<z.ZodEnum<{
|
|
100
|
+
off: "off";
|
|
101
|
+
low: "low";
|
|
102
|
+
medium: "medium";
|
|
103
|
+
high: "high";
|
|
104
|
+
xhigh: "xhigh";
|
|
105
|
+
}>>;
|
|
106
|
+
yolo: z.ZodDefault<z.ZodBoolean>;
|
|
107
|
+
permissionRules: z.ZodDefault<z.ZodObject<{
|
|
108
|
+
categories: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
109
|
+
allow: "allow";
|
|
110
|
+
ask: "ask";
|
|
111
|
+
deny: "deny";
|
|
112
|
+
}>>>;
|
|
113
|
+
tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
114
|
+
allow: "allow";
|
|
115
|
+
ask: "ask";
|
|
116
|
+
deny: "deny";
|
|
117
|
+
}>>>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
smartEditing: z.ZodDefault<z.ZodBoolean>;
|
|
120
|
+
notifications: z.ZodDefault<z.ZodEnum<{
|
|
121
|
+
off: "off";
|
|
122
|
+
bell: "bell";
|
|
123
|
+
system: "system";
|
|
124
|
+
both: "both";
|
|
125
|
+
}>>;
|
|
126
|
+
tasks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
127
|
+
id: z.ZodOptional<z.ZodString>;
|
|
128
|
+
content: z.ZodString;
|
|
129
|
+
status: z.ZodEnum<{
|
|
130
|
+
pending: "pending";
|
|
131
|
+
in_progress: "in_progress";
|
|
132
|
+
completed: "completed";
|
|
133
|
+
}>;
|
|
134
|
+
activeForm: z.ZodString;
|
|
135
|
+
}, z.core.$strip>>>;
|
|
136
|
+
sandboxAllowedPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
137
|
+
pluginSkillPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
138
|
+
pluginCommandPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
139
|
+
pluginInstructions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
140
|
+
activePlan: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
141
|
+
title: z.ZodString;
|
|
142
|
+
plan: z.ZodString;
|
|
143
|
+
approvedAt: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>>;
|
|
145
|
+
activeBrowserSettings: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
enabled: z.ZodBoolean;
|
|
147
|
+
provider: z.ZodEnum<{
|
|
148
|
+
stagehand: "stagehand";
|
|
149
|
+
"agent-browser": "agent-browser";
|
|
150
|
+
}>;
|
|
151
|
+
headless: z.ZodOptional<z.ZodBoolean>;
|
|
152
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
153
|
+
width: z.ZodNumber;
|
|
154
|
+
height: z.ZodNumber;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
cdpUrl: z.ZodOptional<z.ZodString>;
|
|
157
|
+
stagehand: z.ZodOptional<z.ZodObject<{
|
|
158
|
+
env: z.ZodEnum<{
|
|
159
|
+
LOCAL: "LOCAL";
|
|
160
|
+
BROWSERBASE: "BROWSERBASE";
|
|
161
|
+
}>;
|
|
162
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
163
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, z.core.$strip>>;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,sBAAsB,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,CAAC,GAAG,EAAE,mBAAmB,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;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