praxis-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +534 -0
- package/dist/application/background-agent-manager.d.ts +66 -0
- package/dist/application/background-agent-manager.d.ts.map +1 -0
- package/dist/application/background-agent-manager.js +362 -0
- package/dist/application/background-agent-manager.js.map +1 -0
- package/dist/application/background-bash-manager.d.ts +54 -0
- package/dist/application/background-bash-manager.d.ts.map +1 -0
- package/dist/application/background-bash-manager.js +354 -0
- package/dist/application/background-bash-manager.js.map +1 -0
- package/dist/application/background-task-id.d.ts +5 -0
- package/dist/application/background-task-id.d.ts.map +1 -0
- package/dist/application/background-task-id.js +25 -0
- package/dist/application/background-task-id.js.map +1 -0
- package/dist/application/claude-project-purge.d.ts +50 -0
- package/dist/application/claude-project-purge.d.ts.map +1 -0
- package/dist/application/claude-project-purge.js +459 -0
- package/dist/application/claude-project-purge.js.map +1 -0
- package/dist/application/managed-worktree.d.ts +15 -0
- package/dist/application/managed-worktree.d.ts.map +1 -0
- package/dist/application/managed-worktree.js +127 -0
- package/dist/application/managed-worktree.js.map +1 -0
- package/dist/application/model-compactor.d.ts +8 -0
- package/dist/application/model-compactor.d.ts.map +1 -0
- package/dist/application/model-compactor.js +70 -0
- package/dist/application/model-compactor.js.map +1 -0
- package/dist/application/scheduled-prompt-manager.d.ts +69 -0
- package/dist/application/scheduled-prompt-manager.d.ts.map +1 -0
- package/dist/application/scheduled-prompt-manager.js +387 -0
- package/dist/application/scheduled-prompt-manager.js.map +1 -0
- package/dist/application/session-service.d.ts +142 -0
- package/dist/application/session-service.d.ts.map +1 -0
- package/dist/application/session-service.js +1690 -0
- package/dist/application/session-service.js.map +1 -0
- package/dist/application/session-worktree.d.ts +55 -0
- package/dist/application/session-worktree.d.ts.map +1 -0
- package/dist/application/session-worktree.js +311 -0
- package/dist/application/session-worktree.js.map +1 -0
- package/dist/application/subagent-service.d.ts +98 -0
- package/dist/application/subagent-service.d.ts.map +1 -0
- package/dist/application/subagent-service.js +1305 -0
- package/dist/application/subagent-service.js.map +1 -0
- package/dist/application/tool-use-summary.d.ts +8 -0
- package/dist/application/tool-use-summary.d.ts.map +1 -0
- package/dist/application/tool-use-summary.js +53 -0
- package/dist/application/tool-use-summary.js.map +1 -0
- package/dist/application/top-level-agent-manager.d.ts +58 -0
- package/dist/application/top-level-agent-manager.d.ts.map +1 -0
- package/dist/application/top-level-agent-manager.js +907 -0
- package/dist/application/top-level-agent-manager.js.map +1 -0
- package/dist/application/workflow-manager.d.ts +61 -0
- package/dist/application/workflow-manager.d.ts.map +1 -0
- package/dist/application/workflow-manager.js +582 -0
- package/dist/application/workflow-manager.js.map +1 -0
- package/dist/application/workflow-meta.d.ts +18 -0
- package/dist/application/workflow-meta.d.ts.map +1 -0
- package/dist/application/workflow-meta.js +146 -0
- package/dist/application/workflow-meta.js.map +1 -0
- package/dist/application/workflow-runtime.d.ts +29 -0
- package/dist/application/workflow-runtime.d.ts.map +1 -0
- package/dist/application/workflow-runtime.js +176 -0
- package/dist/application/workflow-runtime.js.map +1 -0
- package/dist/application/workflow-worktree.d.ts +9 -0
- package/dist/application/workflow-worktree.d.ts.map +1 -0
- package/dist/application/workflow-worktree.js +11 -0
- package/dist/application/workflow-worktree.js.map +1 -0
- package/dist/cli/agents-dashboard.d.ts +37 -0
- package/dist/cli/agents-dashboard.d.ts.map +1 -0
- package/dist/cli/agents-dashboard.js +408 -0
- package/dist/cli/agents-dashboard.js.map +1 -0
- package/dist/cli/controls.d.ts +15 -0
- package/dist/cli/controls.d.ts.map +1 -0
- package/dist/cli/controls.js +219 -0
- package/dist/cli/controls.js.map +1 -0
- package/dist/cli/debug.d.ts +13 -0
- package/dist/cli/debug.d.ts.map +1 -0
- package/dist/cli/debug.js +37 -0
- package/dist/cli/debug.js.map +1 -0
- package/dist/cli/interactive.d.ts +63 -0
- package/dist/cli/interactive.d.ts.map +1 -0
- package/dist/cli/interactive.js +600 -0
- package/dist/cli/interactive.js.map +1 -0
- package/dist/cli/protocol.d.ts +251 -0
- package/dist/cli/protocol.d.ts.map +1 -0
- package/dist/cli/protocol.js +2146 -0
- package/dist/cli/protocol.js.map +1 -0
- package/dist/cli.d.ts +116 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +3901 -0
- package/dist/cli.js.map +1 -0
- package/dist/compatibility/claude/compaction.d.ts +19 -0
- package/dist/compatibility/claude/compaction.d.ts.map +1 -0
- package/dist/compatibility/claude/compaction.js +82 -0
- package/dist/compatibility/claude/compaction.js.map +1 -0
- package/dist/compatibility/claude/context.d.ts +24 -0
- package/dist/compatibility/claude/context.d.ts.map +1 -0
- package/dist/compatibility/claude/context.js +92 -0
- package/dist/compatibility/claude/context.js.map +1 -0
- package/dist/compatibility/claude/dynamic-context.d.ts +20 -0
- package/dist/compatibility/claude/dynamic-context.d.ts.map +1 -0
- package/dist/compatibility/claude/dynamic-context.js +168 -0
- package/dist/compatibility/claude/dynamic-context.js.map +1 -0
- package/dist/compatibility/claude/file-history.d.ts +14 -0
- package/dist/compatibility/claude/file-history.d.ts.map +1 -0
- package/dist/compatibility/claude/file-history.js +340 -0
- package/dist/compatibility/claude/file-history.js.map +1 -0
- package/dist/compatibility/claude/file-resources.d.ts +28 -0
- package/dist/compatibility/claude/file-resources.d.ts.map +1 -0
- package/dist/compatibility/claude/file-resources.js +168 -0
- package/dist/compatibility/claude/file-resources.js.map +1 -0
- package/dist/compatibility/claude/fork.d.ts +9 -0
- package/dist/compatibility/claude/fork.d.ts.map +1 -0
- package/dist/compatibility/claude/fork.js +225 -0
- package/dist/compatibility/claude/fork.js.map +1 -0
- package/dist/compatibility/claude/history.d.ts +4 -0
- package/dist/compatibility/claude/history.d.ts.map +1 -0
- package/dist/compatibility/claude/history.js +86 -0
- package/dist/compatibility/claude/history.js.map +1 -0
- package/dist/compatibility/claude/ownership.d.ts +87 -0
- package/dist/compatibility/claude/ownership.d.ts.map +1 -0
- package/dist/compatibility/claude/ownership.js +100 -0
- package/dist/compatibility/claude/ownership.js.map +1 -0
- package/dist/compatibility/claude/paths.d.ts +17 -0
- package/dist/compatibility/claude/paths.d.ts.map +1 -0
- package/dist/compatibility/claude/paths.js +54 -0
- package/dist/compatibility/claude/paths.js.map +1 -0
- package/dist/compatibility/claude/pr-links.d.ts +25 -0
- package/dist/compatibility/claude/pr-links.d.ts.map +1 -0
- package/dist/compatibility/claude/pr-links.js +80 -0
- package/dist/compatibility/claude/pr-links.js.map +1 -0
- package/dist/compatibility/claude/projection.d.ts +11 -0
- package/dist/compatibility/claude/projection.d.ts.map +1 -0
- package/dist/compatibility/claude/projection.js +325 -0
- package/dist/compatibility/claude/projection.js.map +1 -0
- package/dist/compatibility/claude/schema.d.ts +18 -0
- package/dist/compatibility/claude/schema.d.ts.map +1 -0
- package/dist/compatibility/claude/schema.js +983 -0
- package/dist/compatibility/claude/schema.js.map +1 -0
- package/dist/compatibility/claude/shared-resources.d.ts +51 -0
- package/dist/compatibility/claude/shared-resources.d.ts.map +1 -0
- package/dist/compatibility/claude/shared-resources.js +382 -0
- package/dist/compatibility/claude/shared-resources.js.map +1 -0
- package/dist/compatibility/claude/sidechain.d.ts +50 -0
- package/dist/compatibility/claude/sidechain.d.ts.map +1 -0
- package/dist/compatibility/claude/sidechain.js +90 -0
- package/dist/compatibility/claude/sidechain.js.map +1 -0
- package/dist/compatibility/claude/tool-links.d.ts +13 -0
- package/dist/compatibility/claude/tool-links.d.ts.map +1 -0
- package/dist/compatibility/claude/tool-links.js +61 -0
- package/dist/compatibility/claude/tool-links.js.map +1 -0
- package/dist/compatibility/claude/translation.d.ts +71 -0
- package/dist/compatibility/claude/translation.d.ts.map +1 -0
- package/dist/compatibility/claude/translation.js +443 -0
- package/dist/compatibility/claude/translation.js.map +1 -0
- package/dist/compatibility/claude/workflow-replay.d.ts +10 -0
- package/dist/compatibility/claude/workflow-replay.d.ts.map +1 -0
- package/dist/compatibility/claude/workflow-replay.js +66 -0
- package/dist/compatibility/claude/workflow-replay.js.map +1 -0
- package/dist/compatibility/claude/workflow.d.ts +33 -0
- package/dist/compatibility/claude/workflow.d.ts.map +1 -0
- package/dist/compatibility/claude/workflow.js +76 -0
- package/dist/compatibility/claude/workflow.js.map +1 -0
- package/dist/core/compaction.d.ts +16 -0
- package/dist/core/compaction.d.ts.map +1 -0
- package/dist/core/compaction.js +2 -0
- package/dist/core/compaction.js.map +1 -0
- package/dist/core/context-budget.d.ts +28 -0
- package/dist/core/context-budget.d.ts.map +1 -0
- package/dist/core/context-budget.js +108 -0
- package/dist/core/context-budget.js.map +1 -0
- package/dist/core/context.d.ts +16 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +13 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/runtime.d.ts +394 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +507 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/usage.d.ts +26 -0
- package/dist/core/usage.d.ts.map +1 -0
- package/dist/core/usage.js +133 -0
- package/dist/core/usage.js.map +1 -0
- package/dist/extensions/claude-extension-tools.d.ts +16 -0
- package/dist/extensions/claude-extension-tools.d.ts.map +1 -0
- package/dist/extensions/claude-extension-tools.js +78 -0
- package/dist/extensions/claude-extension-tools.js.map +1 -0
- package/dist/extensions/claude-extensions.d.ts +41 -0
- package/dist/extensions/claude-extensions.d.ts.map +1 -0
- package/dist/extensions/claude-extensions.js +270 -0
- package/dist/extensions/claude-extensions.js.map +1 -0
- package/dist/hooks/claude-hook-tools.d.ts +26 -0
- package/dist/hooks/claude-hook-tools.d.ts.map +1 -0
- package/dist/hooks/claude-hook-tools.js +129 -0
- package/dist/hooks/claude-hook-tools.js.map +1 -0
- package/dist/hooks/claude-hooks.d.ts +87 -0
- package/dist/hooks/claude-hooks.d.ts.map +1 -0
- package/dist/hooks/claude-hooks.js +411 -0
- package/dist/hooks/claude-hooks.js.map +1 -0
- package/dist/maintenance/doctor.d.ts +33 -0
- package/dist/maintenance/doctor.d.ts.map +1 -0
- package/dist/maintenance/doctor.js +391 -0
- package/dist/maintenance/doctor.js.map +1 -0
- package/dist/maintenance/self-update.d.ts +31 -0
- package/dist/maintenance/self-update.d.ts.map +1 -0
- package/dist/maintenance/self-update.js +81 -0
- package/dist/maintenance/self-update.js.map +1 -0
- package/dist/mcp/claude-mcp-management.d.ts +28 -0
- package/dist/mcp/claude-mcp-management.d.ts.map +1 -0
- package/dist/mcp/claude-mcp-management.js +169 -0
- package/dist/mcp/claude-mcp-management.js.map +1 -0
- package/dist/mcp/claude-mcp-oauth.d.ts +113 -0
- package/dist/mcp/claude-mcp-oauth.d.ts.map +1 -0
- package/dist/mcp/claude-mcp-oauth.js +1053 -0
- package/dist/mcp/claude-mcp-oauth.js.map +1 -0
- package/dist/mcp/claude-mcp-tools.d.ts +98 -0
- package/dist/mcp/claude-mcp-tools.d.ts.map +1 -0
- package/dist/mcp/claude-mcp-tools.js +1246 -0
- package/dist/mcp/claude-mcp-tools.js.map +1 -0
- package/dist/mcp/praxis-mcp-server.d.ts +35 -0
- package/dist/mcp/praxis-mcp-server.d.ts.map +1 -0
- package/dist/mcp/praxis-mcp-server.js +520 -0
- package/dist/mcp/praxis-mcp-server.js.map +1 -0
- package/dist/permissions/claude-auto-classifier.d.ts +20 -0
- package/dist/permissions/claude-auto-classifier.d.ts.map +1 -0
- package/dist/permissions/claude-auto-classifier.js +140 -0
- package/dist/permissions/claude-auto-classifier.js.map +1 -0
- package/dist/permissions/claude-permission-resolver.d.ts +30 -0
- package/dist/permissions/claude-permission-resolver.d.ts.map +1 -0
- package/dist/permissions/claude-permission-resolver.js +334 -0
- package/dist/permissions/claude-permission-resolver.js.map +1 -0
- package/dist/persistence/claude-job-store.d.ts +68 -0
- package/dist/persistence/claude-job-store.d.ts.map +1 -0
- package/dist/persistence/claude-job-store.js +311 -0
- package/dist/persistence/claude-job-store.js.map +1 -0
- package/dist/persistence/claude-scheduled-task-store.d.ts +29 -0
- package/dist/persistence/claude-scheduled-task-store.d.ts.map +1 -0
- package/dist/persistence/claude-scheduled-task-store.js +163 -0
- package/dist/persistence/claude-scheduled-task-store.js.map +1 -0
- package/dist/persistence/claude-sidechain-store.d.ts +18 -0
- package/dist/persistence/claude-sidechain-store.d.ts.map +1 -0
- package/dist/persistence/claude-sidechain-store.js +107 -0
- package/dist/persistence/claude-sidechain-store.js.map +1 -0
- package/dist/persistence/claude-task-store.d.ts +72 -0
- package/dist/persistence/claude-task-store.d.ts.map +1 -0
- package/dist/persistence/claude-task-store.js +440 -0
- package/dist/persistence/claude-task-store.js.map +1 -0
- package/dist/persistence/claude-transcript-store.d.ts +85 -0
- package/dist/persistence/claude-transcript-store.d.ts.map +1 -0
- package/dist/persistence/claude-transcript-store.js +385 -0
- package/dist/persistence/claude-transcript-store.js.map +1 -0
- package/dist/persistence/claude-workflow-store.d.ts +41 -0
- package/dist/persistence/claude-workflow-store.d.ts.map +1 -0
- package/dist/persistence/claude-workflow-store.js +263 -0
- package/dist/persistence/claude-workflow-store.js.map +1 -0
- package/dist/persistence/in-memory-sidechain-store.d.ts +12 -0
- package/dist/persistence/in-memory-sidechain-store.d.ts.map +1 -0
- package/dist/persistence/in-memory-sidechain-store.js +30 -0
- package/dist/persistence/in-memory-sidechain-store.js.map +1 -0
- package/dist/persistence/in-memory-transcript-store.d.ts +15 -0
- package/dist/persistence/in-memory-transcript-store.d.ts.map +1 -0
- package/dist/persistence/in-memory-transcript-store.js +95 -0
- package/dist/persistence/in-memory-transcript-store.js.map +1 -0
- package/dist/platform/atomic-write.d.ts +5 -0
- package/dist/platform/atomic-write.d.ts.map +1 -0
- package/dist/platform/atomic-write.js +25 -0
- package/dist/platform/atomic-write.js.map +1 -0
- package/dist/platform/bounded-process-runner.d.ts +28 -0
- package/dist/platform/bounded-process-runner.d.ts.map +1 -0
- package/dist/platform/bounded-process-runner.js +209 -0
- package/dist/platform/bounded-process-runner.js.map +1 -0
- package/dist/platform/claude-version.d.ts +5 -0
- package/dist/platform/claude-version.d.ts.map +1 -0
- package/dist/platform/claude-version.js +17 -0
- package/dist/platform/claude-version.js.map +1 -0
- package/dist/platform/command-shell.d.ts +3 -0
- package/dist/platform/command-shell.d.ts.map +1 -0
- package/dist/platform/command-shell.js +15 -0
- package/dist/platform/command-shell.js.map +1 -0
- package/dist/platform/exclusive-file-lease.d.ts +15 -0
- package/dist/platform/exclusive-file-lease.d.ts.map +1 -0
- package/dist/platform/exclusive-file-lease.js +265 -0
- package/dist/platform/exclusive-file-lease.js.map +1 -0
- package/dist/platform/sensitive-data.d.ts +8 -0
- package/dist/platform/sensitive-data.d.ts.map +1 -0
- package/dist/platform/sensitive-data.js +138 -0
- package/dist/platform/sensitive-data.js.map +1 -0
- package/dist/platform/tmux-worktree.d.ts +30 -0
- package/dist/platform/tmux-worktree.d.ts.map +1 -0
- package/dist/platform/tmux-worktree.js +138 -0
- package/dist/platform/tmux-worktree.js.map +1 -0
- package/dist/plugins/claude-plugin-eval-discovery.d.ts +20 -0
- package/dist/plugins/claude-plugin-eval-discovery.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-eval-discovery.js +128 -0
- package/dist/plugins/claude-plugin-eval-discovery.js.map +1 -0
- package/dist/plugins/claude-plugin-eval-graders.d.ts +49 -0
- package/dist/plugins/claude-plugin-eval-graders.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-eval-graders.js +137 -0
- package/dist/plugins/claude-plugin-eval-graders.js.map +1 -0
- package/dist/plugins/claude-plugin-eval-runner.d.ts +50 -0
- package/dist/plugins/claude-plugin-eval-runner.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-eval-runner.js +189 -0
- package/dist/plugins/claude-plugin-eval-runner.js.map +1 -0
- package/dist/plugins/claude-plugin-eval-schema.d.ts +80 -0
- package/dist/plugins/claude-plugin-eval-schema.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-eval-schema.js +436 -0
- package/dist/plugins/claude-plugin-eval-schema.js.map +1 -0
- package/dist/plugins/claude-plugin-eval.d.ts +66 -0
- package/dist/plugins/claude-plugin-eval.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-eval.js +438 -0
- package/dist/plugins/claude-plugin-eval.js.map +1 -0
- package/dist/plugins/claude-plugin-maintenance.d.ts +39 -0
- package/dist/plugins/claude-plugin-maintenance.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-maintenance.js +336 -0
- package/dist/plugins/claude-plugin-maintenance.js.map +1 -0
- package/dist/plugins/claude-plugin-marketplace.d.ts +97 -0
- package/dist/plugins/claude-plugin-marketplace.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-marketplace.js +1433 -0
- package/dist/plugins/claude-plugin-marketplace.js.map +1 -0
- package/dist/plugins/claude-plugin-mcpb.d.ts +71 -0
- package/dist/plugins/claude-plugin-mcpb.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-mcpb.js +885 -0
- package/dist/plugins/claude-plugin-mcpb.js.map +1 -0
- package/dist/plugins/claude-plugin-runtime.d.ts +120 -0
- package/dist/plugins/claude-plugin-runtime.d.ts.map +1 -0
- package/dist/plugins/claude-plugin-runtime.js +1263 -0
- package/dist/plugins/claude-plugin-runtime.js.map +1 -0
- package/dist/providers/anthropic-compatible.d.ts +35 -0
- package/dist/providers/anthropic-compatible.d.ts.map +1 -0
- package/dist/providers/anthropic-compatible.js +733 -0
- package/dist/providers/anthropic-compatible.js.map +1 -0
- package/dist/providers/environment.d.ts +14 -0
- package/dist/providers/environment.d.ts.map +1 -0
- package/dist/providers/environment.js +67 -0
- package/dist/providers/environment.js.map +1 -0
- package/dist/providers/fallback-provider.d.ts +17 -0
- package/dist/providers/fallback-provider.d.ts.map +1 -0
- package/dist/providers/fallback-provider.js +70 -0
- package/dist/providers/fallback-provider.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +30 -0
- package/dist/providers/openai-compatible.d.ts.map +1 -0
- package/dist/providers/openai-compatible.js +409 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/tools/claude-interactive-tools.d.ts +58 -0
- package/dist/tools/claude-interactive-tools.d.ts.map +1 -0
- package/dist/tools/claude-interactive-tools.js +390 -0
- package/dist/tools/claude-interactive-tools.js.map +1 -0
- package/dist/tools/claude-lsp-formatters.d.ts +2 -0
- package/dist/tools/claude-lsp-formatters.d.ts.map +1 -0
- package/dist/tools/claude-lsp-formatters.js +291 -0
- package/dist/tools/claude-lsp-formatters.js.map +1 -0
- package/dist/tools/claude-lsp-tool.d.ts +22 -0
- package/dist/tools/claude-lsp-tool.d.ts.map +1 -0
- package/dist/tools/claude-lsp-tool.js +744 -0
- package/dist/tools/claude-lsp-tool.js.map +1 -0
- package/dist/tools/claude-scheduled-tools.d.ts +20 -0
- package/dist/tools/claude-scheduled-tools.d.ts.map +1 -0
- package/dist/tools/claude-scheduled-tools.js +344 -0
- package/dist/tools/claude-scheduled-tools.js.map +1 -0
- package/dist/tools/claude-task-tools.d.ts +30 -0
- package/dist/tools/claude-task-tools.d.ts.map +1 -0
- package/dist/tools/claude-task-tools.js +503 -0
- package/dist/tools/claude-task-tools.js.map +1 -0
- package/dist/tools/claude-user-message.d.ts +16 -0
- package/dist/tools/claude-user-message.d.ts.map +1 -0
- package/dist/tools/claude-user-message.js +98 -0
- package/dist/tools/claude-user-message.js.map +1 -0
- package/dist/tools/claude-workflow-tools.d.ts +27 -0
- package/dist/tools/claude-workflow-tools.d.ts.map +1 -0
- package/dist/tools/claude-workflow-tools.js +257 -0
- package/dist/tools/claude-workflow-tools.js.map +1 -0
- package/dist/tools/claude-worktree-tools.d.ts +17 -0
- package/dist/tools/claude-worktree-tools.d.ts.map +1 -0
- package/dist/tools/claude-worktree-tools.js +135 -0
- package/dist/tools/claude-worktree-tools.js.map +1 -0
- package/dist/tools/filtered-tool-registry.d.ts +16 -0
- package/dist/tools/filtered-tool-registry.d.ts.map +1 -0
- package/dist/tools/filtered-tool-registry.js +51 -0
- package/dist/tools/filtered-tool-registry.js.map +1 -0
- package/dist/tools/glob.d.ts +9 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +88 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/local-tools.d.ts +47 -0
- package/dist/tools/local-tools.d.ts.map +1 -0
- package/dist/tools/local-tools.js +1082 -0
- package/dist/tools/local-tools.js.map +1 -0
- package/dist/tools/notebook.d.ts +22 -0
- package/dist/tools/notebook.d.ts.map +1 -0
- package/dist/tools/notebook.js +154 -0
- package/dist/tools/notebook.js.map +1 -0
- package/dist/tools/web.d.ts +48 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +726 -0
- package/dist/tools/web.js.map +1 -0
- package/package.json +145 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const CLAUDE_DATA_OWNERSHIP = [
|
|
2
|
+
{
|
|
3
|
+
resource: 'transcript',
|
|
4
|
+
plane: 'shared',
|
|
5
|
+
praxisAccess: 'append-only',
|
|
6
|
+
location: 'projects/<project-key>/<session-id>.jsonl',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
resource: 'auto-memory',
|
|
10
|
+
plane: 'shared',
|
|
11
|
+
praxisAccess: 'read-write',
|
|
12
|
+
location: 'projects/<project-key>/memory/',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
resource: 'durable-task-graph',
|
|
16
|
+
plane: 'shared',
|
|
17
|
+
praxisAccess: 'read-write',
|
|
18
|
+
location: 'tasks/<session-id>/',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
resource: 'scheduled-prompts',
|
|
22
|
+
plane: 'shared',
|
|
23
|
+
praxisAccess: 'read-write',
|
|
24
|
+
location: '.claude/scheduled_tasks.json',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
resource: 'file-history',
|
|
28
|
+
plane: 'shared',
|
|
29
|
+
praxisAccess: 'read-write',
|
|
30
|
+
location: 'file-history/<session-id>/ and transcript snapshot/delta records',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
resource: 'instructions',
|
|
34
|
+
plane: 'shared',
|
|
35
|
+
praxisAccess: 'read-only',
|
|
36
|
+
location: 'CLAUDE.md and .claude rules',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
resource: 'skills',
|
|
40
|
+
plane: 'shared',
|
|
41
|
+
praxisAccess: 'read-only',
|
|
42
|
+
location: 'skills/ and .claude/skills/',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
resource: 'commands',
|
|
46
|
+
plane: 'shared',
|
|
47
|
+
praxisAccess: 'read-only',
|
|
48
|
+
location: 'commands/ and .claude/commands/',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
resource: 'agents',
|
|
52
|
+
plane: 'shared',
|
|
53
|
+
praxisAccess: 'read-only',
|
|
54
|
+
location: 'agents/ and .claude/agents/',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
resource: 'settings',
|
|
58
|
+
plane: 'shared',
|
|
59
|
+
praxisAccess: 'read-only',
|
|
60
|
+
location: 'settings.json and .claude/settings*.json',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
resource: 'hooks',
|
|
64
|
+
plane: 'shared',
|
|
65
|
+
praxisAccess: 'read-only',
|
|
66
|
+
location: 'hooks declared by Claude settings',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
resource: 'mcp',
|
|
70
|
+
plane: 'shared',
|
|
71
|
+
praxisAccess: 'read-only',
|
|
72
|
+
location: '.mcp.json and Claude-compatible settings',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
resource: 'provider-payload',
|
|
76
|
+
plane: 'praxis-sidecar',
|
|
77
|
+
praxisAccess: 'read-write',
|
|
78
|
+
location: 'praxis/providers/',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
resource: 'search-index',
|
|
82
|
+
plane: 'praxis-sidecar',
|
|
83
|
+
praxisAccess: 'read-write',
|
|
84
|
+
location: 'praxis/indexes/',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
resource: 'session-lock',
|
|
88
|
+
plane: 'praxis-sidecar',
|
|
89
|
+
praxisAccess: 'read-write',
|
|
90
|
+
location: 'praxis/locks/',
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
export function getDataOwnership(resource) {
|
|
94
|
+
const policy = CLAUDE_DATA_OWNERSHIP.find((item) => item.resource === resource);
|
|
95
|
+
if (!policy) {
|
|
96
|
+
throw new Error(`Missing Claude data ownership policy: ${resource}`);
|
|
97
|
+
}
|
|
98
|
+
return policy;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership.js","sourceRoot":"","sources":["../../../src/compatibility/claude/ownership.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;QACE,QAAQ,EAAE,YAAY;QACtB,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,aAAa;QAC3B,QAAQ,EAAE,2CAA2C;KACtD;IACD;QACE,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,YAAY;QAC1B,QAAQ,EAAE,gCAAgC;KAC3C;IACD;QACE,QAAQ,EAAE,oBAAoB;QAC9B,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,YAAY;QAC1B,QAAQ,EAAE,qBAAqB;KAChC;IACD;QACE,QAAQ,EAAE,mBAAmB;QAC7B,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,YAAY;QAC1B,QAAQ,EAAE,8BAA8B;KACzC;IACD;QACE,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,YAAY;QAC1B,QAAQ,EACN,kEAAkE;KACrE;IACD;QACE,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,WAAW;QACzB,QAAQ,EAAE,6BAA6B;KACxC;IACD;QACE,QAAQ,EAAE,QAAQ;Q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AAyC,QAAQ,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function isClaudeSessionId(value: string): boolean;
|
|
2
|
+
export interface ResolveClaudePathsOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
configDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ClaudePaths {
|
|
8
|
+
configRoot: string;
|
|
9
|
+
projectRoot: string;
|
|
10
|
+
sessionFile: string;
|
|
11
|
+
taskRoot: string;
|
|
12
|
+
praxisRoot: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function sanitizeClaudeProjectPath(path: string): string;
|
|
15
|
+
export declare function resolveClaudeScheduledTaskFile(cwd: string): string;
|
|
16
|
+
export declare function resolveClaudePaths({ cwd, sessionId, configDir, }: ResolveClaudePathsOptions): ClaudePaths;
|
|
17
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/compatibility/claude/paths.ts"],"names":[],"mappings":"AASA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAaD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9D;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wBAAgB,kBAAkB,CAAC,EACjC,GAAG,EACH,SAAS,EACT,SAAS,GACV,EAAE,yBAAyB,GAAG,WAAW,CA4BzC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { getDataOwnership } from './ownership.js';
|
|
4
|
+
const MAX_SANITIZED_LENGTH = 200;
|
|
5
|
+
const SESSION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
export function isClaudeSessionId(value) {
|
|
7
|
+
return SESSION_ID_PATTERN.test(value);
|
|
8
|
+
}
|
|
9
|
+
function stablePathHash(value) {
|
|
10
|
+
let hash = 0;
|
|
11
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
12
|
+
hash = Math.imul(hash, 31) + value.charCodeAt(index);
|
|
13
|
+
hash |= 0;
|
|
14
|
+
}
|
|
15
|
+
return Math.abs(hash);
|
|
16
|
+
}
|
|
17
|
+
export function sanitizeClaudeProjectPath(path) {
|
|
18
|
+
const sanitized = path.replace(/[^a-zA-Z0-9]/g, '-');
|
|
19
|
+
if (sanitized.length <= MAX_SANITIZED_LENGTH) {
|
|
20
|
+
return sanitized;
|
|
21
|
+
}
|
|
22
|
+
return `${sanitized.slice(0, MAX_SANITIZED_LENGTH)}-${stablePathHash(path).toString(36)}`;
|
|
23
|
+
}
|
|
24
|
+
export function resolveClaudeScheduledTaskFile(cwd) {
|
|
25
|
+
const policy = getDataOwnership('scheduled-prompts');
|
|
26
|
+
if (policy.plane !== 'shared' ||
|
|
27
|
+
policy.praxisAccess !== 'read-write' ||
|
|
28
|
+
policy.location !== '.claude/scheduled_tasks.json') {
|
|
29
|
+
throw new Error('Invalid scheduled prompt ownership policy');
|
|
30
|
+
}
|
|
31
|
+
return resolve(cwd, '.claude', 'scheduled_tasks.json');
|
|
32
|
+
}
|
|
33
|
+
export function resolveClaudePaths({ cwd, sessionId, configDir, }) {
|
|
34
|
+
if (!isClaudeSessionId(sessionId)) {
|
|
35
|
+
throw new Error(`Invalid Claude session ID: ${sessionId}`);
|
|
36
|
+
}
|
|
37
|
+
const configuredRoot = configDir ?? process.env.CLAUDE_CONFIG_DIR;
|
|
38
|
+
const configRoot = resolve(configuredRoot ?? resolve(homedir(), '.claude'));
|
|
39
|
+
const projectRoot = resolve(configRoot, 'projects', sanitizeClaudeProjectPath(cwd));
|
|
40
|
+
const taskPolicy = getDataOwnership('durable-task-graph');
|
|
41
|
+
if (taskPolicy.plane !== 'shared' ||
|
|
42
|
+
taskPolicy.praxisAccess !== 'read-write' ||
|
|
43
|
+
taskPolicy.location !== 'tasks/<session-id>/') {
|
|
44
|
+
throw new Error('Invalid durable task graph ownership policy');
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
configRoot,
|
|
48
|
+
projectRoot,
|
|
49
|
+
sessionFile: resolve(projectRoot, `${sessionId}.jsonl`),
|
|
50
|
+
taskRoot: resolve(configRoot, 'tasks', sessionId),
|
|
51
|
+
praxisRoot: resolve(configRoot, 'praxis'),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/compatibility/claude/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAChC,MAAM,kBAAkB,GACtB,iEAAiE,CAAA;AAEnE,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACvC,CAAC;AAgBD,SAA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C,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,cAAc,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC,CAAA;IAC3E,MAAM,WAAW,GAAG,OAAO,CACzB,UAAU,EACV,UAAU,EACV,yBAAyB,CAAC,GAAG,CAAC,CAC/B,CAAA;IACD,MAAM,UAAU,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;IACzD,IACE,UAAU,CAAC,KAAK,KAAK,QAAQ;QAC7B,UAAU,CAAC,YAAY,KAAK,YAAY;QACxC,UAAU,CAAC,QAAQ,KAAK,qBAAqB,EAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;IAED,OAAO;QACL,UAAU;QACV,WAAW;QACX,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,SAAS,QAAQ,CAAC;QACvD,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC;QACjD,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC;KAC1C,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ClaudeTranscriptEntry } from './schema.js';
|
|
2
|
+
export interface ClaudePrLink {
|
|
3
|
+
prNumber: number;
|
|
4
|
+
prUrl: string;
|
|
5
|
+
prRepository: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ClaudePrReference {
|
|
9
|
+
prNumber: number;
|
|
10
|
+
prRepository?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseClaudePrReference(value: string): ClaudePrReference;
|
|
13
|
+
export declare function getClaudePrLink(entries: readonly ClaudeTranscriptEntry[], sessionId: string): ClaudePrLink | null;
|
|
14
|
+
export declare function matchesClaudePrReference(link: Pick<ClaudePrLink, 'prNumber'> & {
|
|
15
|
+
prRepository?: string;
|
|
16
|
+
}, reference: ClaudePrReference): boolean;
|
|
17
|
+
export declare function createClaudePrSessionFilter<T extends {
|
|
18
|
+
prNumber?: number;
|
|
19
|
+
prRepository?: string;
|
|
20
|
+
}>(selector: string | true): (session: T) => boolean;
|
|
21
|
+
export declare function filterClaudePrLinkedSessions<T extends {
|
|
22
|
+
prNumber?: number;
|
|
23
|
+
prRepository?: string;
|
|
24
|
+
}>(sessions: readonly T[], selector: string | true): T[];
|
|
25
|
+
//# sourceMappingURL=pr-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-links.d.ts","sourceRoot":"","sources":["../../../src/compatibility/claude/pr-links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAOD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAgCvE;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,SAAS,EAAE,MAAM,GAChB,YAAY,GAAG,IAAI,CAyBrB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAChE,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAQT;AAED,wBAAgB,2BAA2B,CACzC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EACtD,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAmBlD;AAED,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EACtD,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,CAEtD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function parsePrNumber(value) {
|
|
2
|
+
const number = Number(value);
|
|
3
|
+
return Number.isSafeInteger(number) && number > 0 ? number : null;
|
|
4
|
+
}
|
|
5
|
+
export function parseClaudePrReference(value) {
|
|
6
|
+
const source = value.trim();
|
|
7
|
+
const direct = /^#?([1-9]\d*)$/u.exec(source);
|
|
8
|
+
const directNumber = direct?.[1] ? parsePrNumber(direct[1]) : null;
|
|
9
|
+
if (directNumber !== null) {
|
|
10
|
+
return { prNumber: directNumber };
|
|
11
|
+
}
|
|
12
|
+
const url = /^https?:\/\/github\.com\/([^/\s]+)\/([^/\s]+)\/pull\/([1-9]\d*)(?:[/?#].*)?$/iu.exec(source);
|
|
13
|
+
const urlNumber = url?.[3] ? parsePrNumber(url[3]) : null;
|
|
14
|
+
if (url?.[1] && url[2] && urlNumber !== null) {
|
|
15
|
+
return {
|
|
16
|
+
prNumber: urlNumber,
|
|
17
|
+
prRepository: `${url[1]}/${url[2]}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const shorthand = /^([^/\s#]+)\/([^/\s#]+)#([1-9]\d*)$/u.exec(source);
|
|
21
|
+
const shorthandNumber = shorthand?.[3] ? parsePrNumber(shorthand[3]) : null;
|
|
22
|
+
if (shorthand?.[1] && shorthand[2] && shorthandNumber !== null) {
|
|
23
|
+
return {
|
|
24
|
+
prNumber: shorthandNumber,
|
|
25
|
+
prRepository: `${shorthand[1]}/${shorthand[2]}`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Invalid PR reference ${value}; expected a PR number, GitHub pull URL, or owner/repo#number`);
|
|
29
|
+
}
|
|
30
|
+
export function getClaudePrLink(entries, sessionId) {
|
|
31
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
32
|
+
const entry = entries[index];
|
|
33
|
+
if (entry?.type !== 'pr-link' || entry.sessionId !== sessionId)
|
|
34
|
+
continue;
|
|
35
|
+
if (typeof entry.prNumber !== 'number' ||
|
|
36
|
+
!Number.isSafeInteger(entry.prNumber) ||
|
|
37
|
+
entry.prNumber < 1 ||
|
|
38
|
+
typeof entry.prUrl !== 'string' ||
|
|
39
|
+
entry.prUrl.length === 0 ||
|
|
40
|
+
typeof entry.prRepository !== 'string' ||
|
|
41
|
+
entry.prRepository.length === 0 ||
|
|
42
|
+
typeof entry.timestamp !== 'string' ||
|
|
43
|
+
entry.timestamp.length === 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
prNumber: entry.prNumber,
|
|
48
|
+
prUrl: entry.prUrl,
|
|
49
|
+
prRepository: entry.prRepository,
|
|
50
|
+
timestamp: entry.timestamp,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
export function matchesClaudePrReference(link, reference) {
|
|
56
|
+
return (link.prNumber === reference.prNumber &&
|
|
57
|
+
(reference.prRepository === undefined ||
|
|
58
|
+
(typeof link.prRepository === 'string' &&
|
|
59
|
+
link.prRepository.toLowerCase() ===
|
|
60
|
+
reference.prRepository.toLowerCase())));
|
|
61
|
+
}
|
|
62
|
+
export function createClaudePrSessionFilter(selector) {
|
|
63
|
+
if (selector === true) {
|
|
64
|
+
return (session) => typeof session.prNumber === 'number' &&
|
|
65
|
+
Number.isSafeInteger(session.prNumber) &&
|
|
66
|
+
session.prNumber > 0;
|
|
67
|
+
}
|
|
68
|
+
const reference = parseClaudePrReference(selector);
|
|
69
|
+
return (session) => typeof session.prNumber === 'number' &&
|
|
70
|
+
matchesClaudePrReference({
|
|
71
|
+
prNumber: session.prNumber,
|
|
72
|
+
...(session.prRepository === undefined
|
|
73
|
+
? {}
|
|
74
|
+
: { prRepository: session.prRepository }),
|
|
75
|
+
}, reference);
|
|
76
|
+
}
|
|
77
|
+
export function filterClaudePrLinkedSessions(sessions, selector) {
|
|
78
|
+
return sessions.filter(createClaudePrSessionFilter(selector));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=pr-links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-links.js","sourceRoot":"","sources":["../../../src/compatibility/claude/pr-links.ts"],"names":[],"mappings":"AAcA,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;AACnE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC3B,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAClE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;IACnC,CAAC;IAED,MAAM,GAAG,GACP,gFAAgF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C,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;YACtC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACxB,CAAC;IACD,MAAM,SAAS,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IAClD,OAAO,CAAC,OAAO,EAAE,EAAE,CACjB,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QACpC,wBAAwB,CACtB;YACE,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS;gBACpC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;SAC5C,EACD,SAAS,CACV,CAAA;AACL,CAAC;AAED,MAAM,UAAU,4BAA4B,CAE1C,QAAsB,EAAE,QAAuB;IAC/C,OAAO,QAAQ,CAAC,MAAM,CAAC,2BAA2B,CAAI,QAAQ,CAAC,CAAC,CAAA;AAClE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModelMessage } from '../../core/runtime.js';
|
|
2
|
+
import type { ClaudeTranscriptEntry } from './schema.js';
|
|
3
|
+
export interface ClaudeTextMessage {
|
|
4
|
+
role: 'user' | 'assistant';
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function projectClaudeTextMessages(entries: readonly ClaudeTranscriptEntry[]): ClaudeTextMessage[];
|
|
8
|
+
export declare function projectClaudeModelMessages(entries: readonly ClaudeTranscriptEntry[]): ModelMessage[];
|
|
9
|
+
export declare function getClaudeLastPrompt(entries: readonly ClaudeTranscriptEntry[]): string | null;
|
|
10
|
+
export declare function getClaudeAgentSetting(entries: readonly ClaudeTranscriptEntry[]): string | null;
|
|
11
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/compatibility/claude/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,YAAY,EAGb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB;AA4ID,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,iBAAiB,EAAE,CAuBrB;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,YAAY,EAAE,CAgMhB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,GAAG,IAAI,CAQf;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,GAAG,IAAI,CAYf"}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { selectClaudeActiveTranscript } from './history.js';
|
|
2
|
+
function compactedEntries(entries) {
|
|
3
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
4
|
+
if (entries[index]?.isCompactSummary === true)
|
|
5
|
+
return entries.slice(index);
|
|
6
|
+
}
|
|
7
|
+
return entries;
|
|
8
|
+
}
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
const IMAGE_MEDIA_TYPES = new Set([
|
|
13
|
+
'image/png',
|
|
14
|
+
'image/jpeg',
|
|
15
|
+
'image/gif',
|
|
16
|
+
'image/webp',
|
|
17
|
+
]);
|
|
18
|
+
const DOCUMENT_MEDIA_TYPES = new Set([
|
|
19
|
+
'application/pdf',
|
|
20
|
+
'text/plain',
|
|
21
|
+
'text/markdown',
|
|
22
|
+
'application/json',
|
|
23
|
+
]);
|
|
24
|
+
function projectToolResultContent(content) {
|
|
25
|
+
if (typeof content === 'string') {
|
|
26
|
+
return {
|
|
27
|
+
content,
|
|
28
|
+
contentBlocks: [],
|
|
29
|
+
images: [],
|
|
30
|
+
documents: [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!Array.isArray(content))
|
|
34
|
+
return null;
|
|
35
|
+
const parts = [];
|
|
36
|
+
const contentBlocks = [];
|
|
37
|
+
const images = [];
|
|
38
|
+
const documents = [];
|
|
39
|
+
for (const block of content) {
|
|
40
|
+
if (!isRecord(block)) {
|
|
41
|
+
parts.push('[structured tool result omitted]');
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (block.type === 'text' && typeof block.text === 'string') {
|
|
45
|
+
parts.push(block.text);
|
|
46
|
+
contentBlocks.push({ type: 'text', text: block.text });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (block.type === 'image' &&
|
|
50
|
+
isRecord(block.source) &&
|
|
51
|
+
block.source.type === 'base64' &&
|
|
52
|
+
typeof block.source.media_type === 'string' &&
|
|
53
|
+
IMAGE_MEDIA_TYPES.has(block.source.media_type) &&
|
|
54
|
+
typeof block.source.data === 'string') {
|
|
55
|
+
const image = {
|
|
56
|
+
type: 'image',
|
|
57
|
+
mediaType: block.source.media_type,
|
|
58
|
+
data: block.source.data,
|
|
59
|
+
};
|
|
60
|
+
images.push(image);
|
|
61
|
+
contentBlocks.push(image);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (block.type === 'document' &&
|
|
65
|
+
isRecord(block.source) &&
|
|
66
|
+
block.source.type === 'base64' &&
|
|
67
|
+
typeof block.source.media_type === 'string' &&
|
|
68
|
+
DOCUMENT_MEDIA_TYPES.has(block.source.media_type) &&
|
|
69
|
+
typeof block.source.data === 'string') {
|
|
70
|
+
const document = {
|
|
71
|
+
type: 'document',
|
|
72
|
+
mediaType: block.source.media_type,
|
|
73
|
+
data: block.source.data,
|
|
74
|
+
};
|
|
75
|
+
documents.push(document);
|
|
76
|
+
contentBlocks.push(document);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
parts.push(`[${String(block.type ?? 'structured')} tool result omitted]`);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
content: parts.join('\n') ||
|
|
83
|
+
(images.length > 0 || documents.length > 0
|
|
84
|
+
? ''
|
|
85
|
+
: '[empty structured tool result]'),
|
|
86
|
+
contentBlocks: images.length > 0 || documents.length > 0 ? contentBlocks : [],
|
|
87
|
+
images,
|
|
88
|
+
documents,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function projectNestedMemory(entry) {
|
|
92
|
+
if (entry.type !== 'attachment' || !isRecord(entry.attachment))
|
|
93
|
+
return null;
|
|
94
|
+
if (entry.attachment.type !== 'nested_memory' ||
|
|
95
|
+
!isRecord(entry.attachment.content) ||
|
|
96
|
+
typeof entry.attachment.content.content !== 'string') {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return entry.attachment.content.content;
|
|
100
|
+
}
|
|
101
|
+
function projectHookContext(entry) {
|
|
102
|
+
if (entry.type !== 'attachment' || !isRecord(entry.attachment))
|
|
103
|
+
return null;
|
|
104
|
+
if (entry.attachment.type === 'hook_success' &&
|
|
105
|
+
typeof entry.attachment.content === 'string') {
|
|
106
|
+
return entry.attachment.content || null;
|
|
107
|
+
}
|
|
108
|
+
if (entry.attachment.type === 'hook_additional_context' &&
|
|
109
|
+
Array.isArray(entry.attachment.content)) {
|
|
110
|
+
const content = entry.attachment.content.filter((value) => typeof value === 'string');
|
|
111
|
+
return content.join('\n') || null;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
export function projectClaudeTextMessages(entries) {
|
|
116
|
+
const messages = [];
|
|
117
|
+
for (const entry of compactedEntries(selectClaudeActiveTranscript(entries))) {
|
|
118
|
+
if (!isRecord(entry.message))
|
|
119
|
+
continue;
|
|
120
|
+
const role = entry.message.role;
|
|
121
|
+
if (role !== 'user' && role !== 'assistant')
|
|
122
|
+
continue;
|
|
123
|
+
const content = entry.message.content;
|
|
124
|
+
if (typeof content === 'string') {
|
|
125
|
+
messages.push({ role, content });
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!Array.isArray(content))
|
|
129
|
+
continue;
|
|
130
|
+
const text = content
|
|
131
|
+
.filter((block) => isRecord(block) && block.type === 'text')
|
|
132
|
+
.map((block) => block.text)
|
|
133
|
+
.filter((value) => typeof value === 'string')
|
|
134
|
+
.join('');
|
|
135
|
+
if (text.length > 0)
|
|
136
|
+
messages.push({ role, content: text });
|
|
137
|
+
}
|
|
138
|
+
return messages;
|
|
139
|
+
}
|
|
140
|
+
export function projectClaudeModelMessages(entries) {
|
|
141
|
+
const active = selectClaudeActiveTranscript(entries);
|
|
142
|
+
const compacted = compactedEntries(active);
|
|
143
|
+
const messages = active.flatMap((entry) => {
|
|
144
|
+
const attachmentContext = projectNestedMemory(entry);
|
|
145
|
+
return attachmentContext === null || attachmentContext.length === 0
|
|
146
|
+
? []
|
|
147
|
+
: [{ role: 'system', content: attachmentContext }];
|
|
148
|
+
});
|
|
149
|
+
messages.push(...compacted.flatMap((entry) => {
|
|
150
|
+
const hookContext = projectHookContext(entry);
|
|
151
|
+
return hookContext === null || hookContext.length === 0
|
|
152
|
+
? []
|
|
153
|
+
: [{ role: 'system', content: hookContext }];
|
|
154
|
+
}));
|
|
155
|
+
for (const entry of compacted) {
|
|
156
|
+
if (projectNestedMemory(entry) !== null ||
|
|
157
|
+
projectHookContext(entry) !== null) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (!isRecord(entry.message))
|
|
161
|
+
continue;
|
|
162
|
+
const role = entry.message.role;
|
|
163
|
+
const content = entry.message.content;
|
|
164
|
+
if (role === 'user') {
|
|
165
|
+
if (typeof content === 'string') {
|
|
166
|
+
messages.push({ role: 'user', content });
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (!Array.isArray(content))
|
|
170
|
+
continue;
|
|
171
|
+
const text = content
|
|
172
|
+
.filter((block) => isRecord(block) && block.type === 'text')
|
|
173
|
+
.map((block) => block.text)
|
|
174
|
+
.filter((value) => typeof value === 'string')
|
|
175
|
+
.join('');
|
|
176
|
+
const images = content.flatMap((block) => {
|
|
177
|
+
if (!isRecord(block) ||
|
|
178
|
+
block.type !== 'image' ||
|
|
179
|
+
!isRecord(block.source) ||
|
|
180
|
+
block.source.type !== 'base64' ||
|
|
181
|
+
typeof block.source.media_type !== 'string' ||
|
|
182
|
+
!IMAGE_MEDIA_TYPES.has(block.source.media_type) ||
|
|
183
|
+
typeof block.source.data !== 'string')
|
|
184
|
+
return [];
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
type: 'image',
|
|
188
|
+
mediaType: block.source.media_type,
|
|
189
|
+
data: block.source.data,
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
});
|
|
193
|
+
const documents = content.flatMap((block) => {
|
|
194
|
+
if (!isRecord(block) ||
|
|
195
|
+
block.type !== 'document' ||
|
|
196
|
+
!isRecord(block.source) ||
|
|
197
|
+
block.source.type !== 'base64' ||
|
|
198
|
+
typeof block.source.media_type !== 'string' ||
|
|
199
|
+
!DOCUMENT_MEDIA_TYPES.has(block.source.media_type) ||
|
|
200
|
+
typeof block.source.data !== 'string')
|
|
201
|
+
return [];
|
|
202
|
+
return [
|
|
203
|
+
{
|
|
204
|
+
type: 'document',
|
|
205
|
+
mediaType: block.source.media_type,
|
|
206
|
+
data: block.source.data,
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
});
|
|
210
|
+
if (text.length > 0 || images.length > 0 || documents.length > 0) {
|
|
211
|
+
messages.push({
|
|
212
|
+
role: 'user',
|
|
213
|
+
content: text,
|
|
214
|
+
...(images.length > 0 ? { images } : {}),
|
|
215
|
+
...(documents.length > 0 ? { documents } : {}),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
for (const block of content) {
|
|
219
|
+
if (!isRecord(block) ||
|
|
220
|
+
block.type !== 'tool_result' ||
|
|
221
|
+
typeof block.tool_use_id !== 'string') {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const toolContent = projectToolResultContent(block.content);
|
|
225
|
+
if (toolContent === null)
|
|
226
|
+
continue;
|
|
227
|
+
messages.push({
|
|
228
|
+
role: 'tool',
|
|
229
|
+
toolCallId: block.tool_use_id,
|
|
230
|
+
content: toolContent.content,
|
|
231
|
+
...(Array.isArray(entry.toolUseResult) &&
|
|
232
|
+
toolContent.contentBlocks.length > 0
|
|
233
|
+
? { contentBlocks: toolContent.contentBlocks }
|
|
234
|
+
: {}),
|
|
235
|
+
...(toolContent.images.length > 0
|
|
236
|
+
? { images: toolContent.images }
|
|
237
|
+
: {}),
|
|
238
|
+
...(toolContent.documents.length > 0
|
|
239
|
+
? { documents: toolContent.documents }
|
|
240
|
+
: {}),
|
|
241
|
+
isError: block.is_error === true,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (role !== 'assistant' || !Array.isArray(content))
|
|
247
|
+
continue;
|
|
248
|
+
const text = content
|
|
249
|
+
.filter((block) => isRecord(block) && block.type === 'text')
|
|
250
|
+
.map((block) => block.text)
|
|
251
|
+
.filter((value) => typeof value === 'string')
|
|
252
|
+
.join('');
|
|
253
|
+
const toolCalls = [];
|
|
254
|
+
const thinkingBlocks = [];
|
|
255
|
+
for (const block of content) {
|
|
256
|
+
if (isRecord(block) &&
|
|
257
|
+
block.type === 'thinking' &&
|
|
258
|
+
typeof block.thinking === 'string' &&
|
|
259
|
+
typeof block.signature === 'string') {
|
|
260
|
+
thinkingBlocks.push({
|
|
261
|
+
type: 'thinking',
|
|
262
|
+
thinking: block.thinking,
|
|
263
|
+
signature: block.signature,
|
|
264
|
+
});
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (isRecord(block) &&
|
|
268
|
+
block.type === 'redacted_thinking' &&
|
|
269
|
+
typeof block.data === 'string') {
|
|
270
|
+
thinkingBlocks.push({ type: 'redacted_thinking', data: block.data });
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (!isRecord(block) ||
|
|
274
|
+
block.type !== 'tool_use' ||
|
|
275
|
+
typeof block.id !== 'string' ||
|
|
276
|
+
typeof block.name !== 'string' ||
|
|
277
|
+
!isRecord(block.input)) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
toolCalls.push({
|
|
281
|
+
id: block.id,
|
|
282
|
+
name: block.name,
|
|
283
|
+
input: block.input,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (text.length === 0 &&
|
|
287
|
+
toolCalls.length === 0 &&
|
|
288
|
+
thinkingBlocks.length === 0)
|
|
289
|
+
continue;
|
|
290
|
+
messages.push(toolCalls.length === 0
|
|
291
|
+
? {
|
|
292
|
+
role: 'assistant',
|
|
293
|
+
content: text,
|
|
294
|
+
...(thinkingBlocks.length > 0 ? { thinkingBlocks } : {}),
|
|
295
|
+
}
|
|
296
|
+
: {
|
|
297
|
+
role: 'assistant',
|
|
298
|
+
content: text,
|
|
299
|
+
...(thinkingBlocks.length > 0 ? { thinkingBlocks } : {}),
|
|
300
|
+
toolCalls,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return messages;
|
|
304
|
+
}
|
|
305
|
+
export function getClaudeLastPrompt(entries) {
|
|
306
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
307
|
+
const entry = entries[index];
|
|
308
|
+
if (entry?.type === 'last-prompt' && typeof entry.lastPrompt === 'string') {
|
|
309
|
+
return entry.lastPrompt;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
export function getClaudeAgentSetting(entries) {
|
|
315
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
316
|
+
const entry = entries[index];
|
|
317
|
+
if (entry?.type === 'agent-setting' &&
|
|
318
|
+
typeof entry.agentSetting === 'string' &&
|
|
319
|
+
entry.agentSetting.length > 0) {
|
|
320
|
+
return entry.agentSetting;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=projection.js.map
|