@kilnai/cli 1.0.7 → 2.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/README.md +34 -8
- package/dist/application/__tests__/session-report.test.d.ts +2 -0
- package/dist/application/__tests__/session-report.test.d.ts.map +1 -0
- package/dist/application/__tests__/session-report.test.js +100 -0
- package/dist/application/__tests__/session-report.test.js.map +1 -0
- package/dist/application/agent-loader.d.ts +30 -2
- package/dist/application/agent-loader.d.ts.map +1 -1
- package/dist/application/agent-loader.js +99 -3
- package/dist/application/agent-loader.js.map +1 -1
- package/dist/application/agent-loader.test.js +112 -18
- package/dist/application/agent-loader.test.js.map +1 -1
- package/dist/application/agent-skill-context.d.ts +12 -0
- package/dist/application/agent-skill-context.d.ts.map +1 -0
- package/dist/application/agent-skill-context.js +32 -0
- package/dist/application/agent-skill-context.js.map +1 -0
- package/dist/application/agent-skill-context.test.d.ts +2 -0
- package/dist/application/agent-skill-context.test.d.ts.map +1 -0
- package/dist/application/agent-skill-context.test.js +156 -0
- package/dist/application/agent-skill-context.test.js.map +1 -0
- package/dist/application/benchmark-session-executor.d.ts +14 -0
- package/dist/application/benchmark-session-executor.d.ts.map +1 -0
- package/dist/application/benchmark-session-executor.js +210 -0
- package/dist/application/benchmark-session-executor.js.map +1 -0
- package/dist/application/config-apply-tool.d.ts +30 -0
- package/dist/application/config-apply-tool.d.ts.map +1 -0
- package/dist/application/config-apply-tool.js +68 -0
- package/dist/application/config-apply-tool.js.map +1 -0
- package/dist/application/config-apply.d.ts +9 -0
- package/dist/application/config-apply.d.ts.map +1 -0
- package/dist/application/config-apply.js +146 -0
- package/dist/application/config-apply.js.map +1 -0
- package/dist/application/config-approval.d.ts +10 -0
- package/dist/application/config-approval.d.ts.map +1 -0
- package/dist/application/config-approval.js +30 -0
- package/dist/application/config-approval.js.map +1 -0
- package/dist/application/config-mutation-store.d.ts +25 -0
- package/dist/application/config-mutation-store.d.ts.map +1 -0
- package/dist/application/config-mutation-store.js +59 -0
- package/dist/application/config-mutation-store.js.map +1 -0
- package/dist/application/config-proposal.d.ts +22 -0
- package/dist/application/config-proposal.d.ts.map +1 -0
- package/dist/application/config-proposal.js +395 -0
- package/dist/application/config-proposal.js.map +1 -0
- package/dist/application/config-propose-tool.d.ts +30 -0
- package/dist/application/config-propose-tool.d.ts.map +1 -0
- package/dist/application/config-propose-tool.js +63 -0
- package/dist/application/config-propose-tool.js.map +1 -0
- package/dist/application/config-read-tool.d.ts +26 -0
- package/dist/application/config-read-tool.d.ts.map +1 -0
- package/dist/application/config-read-tool.js +51 -0
- package/dist/application/config-read-tool.js.map +1 -0
- package/dist/application/config-status.d.ts +9 -0
- package/dist/application/config-status.d.ts.map +1 -0
- package/dist/application/config-status.js +361 -0
- package/dist/application/config-status.js.map +1 -0
- package/dist/application/config-tools.d.ts +3 -0
- package/dist/application/config-tools.d.ts.map +1 -0
- package/dist/application/config-tools.js +11 -0
- package/dist/application/config-tools.js.map +1 -0
- package/dist/application/context-types.d.ts +4 -17
- package/dist/application/context-types.d.ts.map +1 -1
- package/dist/application/context-types.js.map +1 -1
- package/dist/application/first-party-agent-defaults.d.ts +3 -0
- package/dist/application/first-party-agent-defaults.d.ts.map +1 -0
- package/dist/application/first-party-agent-defaults.js +135 -0
- package/dist/application/first-party-agent-defaults.js.map +1 -0
- package/dist/application/instruction-profile-context.d.ts +15 -0
- package/dist/application/instruction-profile-context.d.ts.map +1 -0
- package/dist/application/instruction-profile-context.js +80 -0
- package/dist/application/instruction-profile-context.js.map +1 -0
- package/dist/application/instruction-profile-loader.d.ts +20 -0
- package/dist/application/instruction-profile-loader.d.ts.map +1 -0
- package/dist/application/instruction-profile-loader.js +132 -0
- package/dist/application/instruction-profile-loader.js.map +1 -0
- package/dist/application/instruction-profile-loader.test.d.ts +2 -0
- package/dist/application/instruction-profile-loader.test.d.ts.map +1 -0
- package/dist/application/instruction-profile-loader.test.js +100 -0
- package/dist/application/instruction-profile-loader.test.js.map +1 -0
- package/dist/application/operator-theme-preferences.d.ts +11 -0
- package/dist/application/operator-theme-preferences.d.ts.map +1 -0
- package/dist/application/operator-theme-preferences.js +49 -0
- package/dist/application/operator-theme-preferences.js.map +1 -0
- package/dist/application/project-context.d.ts +22 -0
- package/dist/application/project-context.d.ts.map +1 -0
- package/dist/application/project-context.js +139 -0
- package/dist/application/project-context.js.map +1 -0
- package/dist/application/project-root-resolver.d.ts +14 -0
- package/dist/application/project-root-resolver.d.ts.map +1 -0
- package/dist/application/project-root-resolver.js +71 -0
- package/dist/application/project-root-resolver.js.map +1 -0
- package/dist/application/repo-shim-projection.d.ts +48 -0
- package/dist/application/repo-shim-projection.d.ts.map +1 -0
- package/dist/application/repo-shim-projection.js +536 -0
- package/dist/application/repo-shim-projection.js.map +1 -0
- package/dist/application/resume-sidebar-info.d.ts +9 -0
- package/dist/application/resume-sidebar-info.d.ts.map +1 -0
- package/dist/application/resume-sidebar-info.js +40 -0
- package/dist/application/resume-sidebar-info.js.map +1 -0
- package/dist/application/resume-strategy-feedback.d.ts.map +1 -1
- package/dist/application/resume-strategy-feedback.js +2 -1
- package/dist/application/resume-strategy-feedback.js.map +1 -1
- package/dist/application/run-session.d.ts +15 -0
- package/dist/application/run-session.d.ts.map +1 -1
- package/dist/application/run-session.js +110 -19
- package/dist/application/run-session.js.map +1 -1
- package/dist/application/runtime-session-rehydration.d.ts +9 -0
- package/dist/application/runtime-session-rehydration.d.ts.map +1 -0
- package/dist/application/runtime-session-rehydration.js +115 -0
- package/dist/application/runtime-session-rehydration.js.map +1 -0
- package/dist/application/session-context-artifacts.d.ts +19 -0
- package/dist/application/session-context-artifacts.d.ts.map +1 -0
- package/dist/application/session-context-artifacts.js +60 -0
- package/dist/application/session-context-artifacts.js.map +1 -0
- package/dist/application/session-metadata.d.ts +35 -0
- package/dist/application/session-metadata.d.ts.map +1 -0
- package/dist/application/session-metadata.js +157 -0
- package/dist/application/session-metadata.js.map +1 -0
- package/dist/application/session-report.d.ts.map +1 -1
- package/dist/application/session-report.js +8 -0
- package/dist/application/session-report.js.map +1 -1
- package/dist/application/session-resume.d.ts +1 -1
- package/dist/application/session-resume.d.ts.map +1 -1
- package/dist/application/session-resume.js +4 -4
- package/dist/application/session-resume.js.map +1 -1
- package/dist/application/work-governance-context.d.ts +7 -0
- package/dist/application/work-governance-context.d.ts.map +1 -0
- package/dist/application/work-governance-context.js +64 -0
- package/dist/application/work-governance-context.js.map +1 -0
- package/dist/application/work-governance-context.test.d.ts +2 -0
- package/dist/application/work-governance-context.test.d.ts.map +1 -0
- package/dist/application/work-governance-context.test.js +55 -0
- package/dist/application/work-governance-context.test.js.map +1 -0
- package/dist/application/work-governance-policy.d.ts +15 -0
- package/dist/application/work-governance-policy.d.ts.map +1 -0
- package/dist/application/work-governance-policy.js +53 -0
- package/dist/application/work-governance-policy.js.map +1 -0
- package/dist/application/work-governance-tool.d.ts +421 -0
- package/dist/application/work-governance-tool.d.ts.map +1 -0
- package/dist/application/work-governance-tool.js +937 -0
- package/dist/application/work-governance-tool.js.map +1 -0
- package/dist/application/work-governance-tool.test.d.ts +2 -0
- package/dist/application/work-governance-tool.test.d.ts.map +1 -0
- package/dist/application/work-governance-tool.test.js +935 -0
- package/dist/application/work-governance-tool.test.js.map +1 -0
- package/dist/application/work-governance-workflows.d.ts +23 -0
- package/dist/application/work-governance-workflows.d.ts.map +1 -0
- package/dist/application/work-governance-workflows.js +177 -0
- package/dist/application/work-governance-workflows.js.map +1 -0
- package/dist/application/workflow-snapshot-export.d.ts +81 -0
- package/dist/application/workflow-snapshot-export.d.ts.map +1 -0
- package/dist/application/workflow-snapshot-export.js +141 -0
- package/dist/application/workflow-snapshot-export.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +242 -24
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/benchmark.d.ts +8 -0
- package/dist/commands/benchmark.d.ts.map +1 -0
- package/dist/commands/benchmark.js +287 -0
- package/dist/commands/benchmark.js.map +1 -0
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +369 -39
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/config.test.d.ts +2 -0
- package/dist/commands/config.test.d.ts.map +1 -0
- package/dist/commands/config.test.js +86 -0
- package/dist/commands/config.test.js.map +1 -0
- package/dist/commands/goal.d.ts +12 -0
- package/dist/commands/goal.d.ts.map +1 -0
- package/dist/commands/goal.js +469 -0
- package/dist/commands/goal.js.map +1 -0
- package/dist/commands/goal.test.d.ts +2 -0
- package/dist/commands/goal.test.d.ts.map +1 -0
- package/dist/commands/goal.test.js +317 -0
- package/dist/commands/goal.test.js.map +1 -0
- package/dist/commands/gui-options.d.ts +5 -0
- package/dist/commands/gui-options.d.ts.map +1 -0
- package/dist/commands/gui-options.js +18 -0
- package/dist/commands/gui-options.js.map +1 -0
- package/dist/commands/gui-session-detail.d.ts +4 -0
- package/dist/commands/gui-session-detail.d.ts.map +1 -0
- package/dist/commands/gui-session-detail.js +32 -0
- package/dist/commands/gui-session-detail.js.map +1 -0
- package/dist/commands/gui-session-summaries.d.ts +5 -0
- package/dist/commands/gui-session-summaries.d.ts.map +1 -0
- package/dist/commands/gui-session-summaries.js +62 -0
- package/dist/commands/gui-session-summaries.js.map +1 -0
- package/dist/commands/gui-shutdown-monitor.d.ts +8 -0
- package/dist/commands/gui-shutdown-monitor.d.ts.map +1 -0
- package/dist/commands/gui-shutdown-monitor.js +50 -0
- package/dist/commands/gui-shutdown-monitor.js.map +1 -0
- package/dist/commands/gui-window.d.ts +42 -0
- package/dist/commands/gui-window.d.ts.map +1 -0
- package/dist/commands/gui-window.js +287 -0
- package/dist/commands/gui-window.js.map +1 -0
- package/dist/commands/gui-workspace.d.ts +3 -0
- package/dist/commands/gui-workspace.d.ts.map +1 -0
- package/dist/commands/gui-workspace.js +297 -0
- package/dist/commands/gui-workspace.js.map +1 -0
- package/dist/commands/gui.d.ts +14 -0
- package/dist/commands/gui.d.ts.map +1 -0
- package/dist/commands/gui.js +391 -0
- package/dist/commands/gui.js.map +1 -0
- package/dist/commands/import-native.d.ts +34 -0
- package/dist/commands/import-native.d.ts.map +1 -0
- package/dist/commands/import-native.js +302 -0
- package/dist/commands/import-native.js.map +1 -0
- package/dist/commands/init-templates.d.ts.map +1 -1
- package/dist/commands/init-templates.js +13 -12
- package/dist/commands/init-templates.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp-config.d.ts.map +1 -1
- package/dist/commands/mcp-config.js +6 -3
- package/dist/commands/mcp-config.js.map +1 -1
- package/dist/commands/memory.d.ts +1 -1
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +188 -39
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +64 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/route.d.ts +3 -0
- package/dist/commands/route.d.ts.map +1 -0
- package/dist/commands/route.js +19 -0
- package/dist/commands/route.js.map +1 -0
- package/dist/commands/run.d.ts +23 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +416 -81
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/skill-capture.js +34 -14
- package/dist/commands/skill-capture.js.map +1 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +10 -9
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/status.d.ts +5 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +134 -5
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +8 -6
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +173 -48
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tools.d.ts +2 -0
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +34 -15
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/tui.d.ts +6 -4
- package/dist/commands/tui.d.ts.map +1 -1
- package/dist/commands/tui.js +594 -94
- package/dist/commands/tui.js.map +1 -1
- package/dist/commands/uninstall.d.ts +13 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +111 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config/builtin-tool-surface-config.d.ts +6 -0
- package/dist/config/builtin-tool-surface-config.d.ts.map +1 -0
- package/dist/config/builtin-tool-surface-config.js +27 -0
- package/dist/config/builtin-tool-surface-config.js.map +1 -0
- package/dist/config/config-merger.d.ts +1 -1
- package/dist/config/config-merger.d.ts.map +1 -1
- package/dist/config/config-merger.js +21 -4
- package/dist/config/config-merger.js.map +1 -1
- package/dist/config/config-merger.test.js +202 -7
- package/dist/config/config-merger.test.js.map +1 -1
- package/dist/config/global-config.d.ts +59 -13
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +580 -5
- package/dist/config/global-config.js.map +1 -1
- package/dist/config/global-config.test.js +481 -8
- package/dist/config/global-config.test.js.map +1 -1
- package/dist/config/harness-integration-capabilities.d.ts +27 -0
- package/dist/config/harness-integration-capabilities.d.ts.map +1 -0
- package/dist/config/harness-integration-capabilities.js +64 -0
- package/dist/config/harness-integration-capabilities.js.map +1 -0
- package/dist/config/interactive-use-config.d.ts +25 -0
- package/dist/config/interactive-use-config.d.ts.map +1 -0
- package/dist/config/interactive-use-config.js +210 -0
- package/dist/config/interactive-use-config.js.map +1 -0
- package/dist/config/json-comments.d.ts +2 -0
- package/dist/config/json-comments.d.ts.map +1 -0
- package/dist/config/json-comments.js +21 -0
- package/dist/config/json-comments.js.map +1 -0
- package/dist/config/managed-agent-direct-adapters.d.ts +15 -0
- package/dist/config/managed-agent-direct-adapters.d.ts.map +1 -0
- package/dist/config/managed-agent-direct-adapters.js +54 -0
- package/dist/config/managed-agent-direct-adapters.js.map +1 -0
- package/dist/config/managed-agent-provider-models.d.ts +3 -0
- package/dist/config/managed-agent-provider-models.d.ts.map +1 -0
- package/dist/config/managed-agent-provider-models.js +12 -0
- package/dist/config/managed-agent-provider-models.js.map +1 -0
- package/dist/config/managed-agent-routes.d.ts +49 -0
- package/dist/config/managed-agent-routes.d.ts.map +1 -0
- package/dist/config/managed-agent-routes.js +578 -0
- package/dist/config/managed-agent-routes.js.map +1 -0
- package/dist/config/managed-invocation-context-resolver.d.ts +10 -0
- package/dist/config/managed-invocation-context-resolver.d.ts.map +1 -0
- package/dist/config/managed-invocation-context-resolver.js +98 -0
- package/dist/config/managed-invocation-context-resolver.js.map +1 -0
- package/dist/config/managed-invocation-context-resolver.test.d.ts +2 -0
- package/dist/config/managed-invocation-context-resolver.test.d.ts.map +1 -0
- package/dist/config/managed-invocation-context-resolver.test.js +133 -0
- package/dist/config/managed-invocation-context-resolver.test.js.map +1 -0
- package/dist/config/model-task-suitability.d.ts +9 -0
- package/dist/config/model-task-suitability.d.ts.map +1 -0
- package/dist/config/model-task-suitability.js +40 -0
- package/dist/config/model-task-suitability.js.map +1 -0
- package/dist/config/native-agent-projection.d.ts +16 -0
- package/dist/config/native-agent-projection.d.ts.map +1 -0
- package/dist/config/native-agent-projection.js +242 -0
- package/dist/config/native-agent-projection.js.map +1 -0
- package/dist/config/native-hook-projection.d.ts +11 -0
- package/dist/config/native-hook-projection.d.ts.map +1 -0
- package/dist/config/native-hook-projection.js +180 -0
- package/dist/config/native-hook-projection.js.map +1 -0
- package/dist/config/native-permission-projection.d.ts +12 -0
- package/dist/config/native-permission-projection.d.ts.map +1 -0
- package/dist/config/native-permission-projection.js +162 -0
- package/dist/config/native-permission-projection.js.map +1 -0
- package/dist/config/native-projection-backup.d.ts +8 -0
- package/dist/config/native-projection-backup.d.ts.map +1 -0
- package/dist/config/native-projection-backup.js +19 -0
- package/dist/config/native-projection-backup.js.map +1 -0
- package/dist/config/native-projection-policy.d.ts +10 -0
- package/dist/config/native-projection-policy.d.ts.map +1 -0
- package/dist/config/native-projection-policy.js +9 -0
- package/dist/config/native-projection-policy.js.map +1 -0
- package/dist/config/native-projection-state.d.ts +57 -0
- package/dist/config/native-projection-state.d.ts.map +1 -0
- package/dist/config/native-projection-state.js +199 -0
- package/dist/config/native-projection-state.js.map +1 -0
- package/dist/config/native-skill-projection.d.ts +24 -0
- package/dist/config/native-skill-projection.d.ts.map +1 -0
- package/dist/config/native-skill-projection.js +170 -0
- package/dist/config/native-skill-projection.js.map +1 -0
- package/dist/config/operator-identity-context.d.ts +7 -0
- package/dist/config/operator-identity-context.d.ts.map +1 -0
- package/dist/config/operator-identity-context.js +46 -0
- package/dist/config/operator-identity-context.js.map +1 -0
- package/dist/config/operator-identity-context.test.d.ts +2 -0
- package/dist/config/operator-identity-context.test.d.ts.map +1 -0
- package/dist/config/operator-identity-context.test.js +61 -0
- package/dist/config/operator-identity-context.test.js.map +1 -0
- package/dist/config/operator-voice.d.ts +10 -0
- package/dist/config/operator-voice.d.ts.map +1 -0
- package/dist/config/operator-voice.js +29 -0
- package/dist/config/operator-voice.js.map +1 -0
- package/dist/config/provider-route-candidates.d.ts +20 -0
- package/dist/config/provider-route-candidates.d.ts.map +1 -0
- package/dist/config/provider-route-candidates.js +211 -0
- package/dist/config/provider-route-candidates.js.map +1 -0
- package/dist/config/provider-route-candidates.test.d.ts +2 -0
- package/dist/config/provider-route-candidates.test.d.ts.map +1 -0
- package/dist/config/provider-route-candidates.test.js +150 -0
- package/dist/config/provider-route-candidates.test.js.map +1 -0
- package/dist/config/skill-registry.d.ts +9 -0
- package/dist/config/skill-registry.d.ts.map +1 -0
- package/dist/config/skill-registry.js +13 -0
- package/dist/config/skill-registry.js.map +1 -0
- package/dist/config/skill-registry.test.d.ts +2 -0
- package/dist/config/skill-registry.test.d.ts.map +1 -0
- package/dist/config/skill-registry.test.js +64 -0
- package/dist/config/skill-registry.test.js.map +1 -0
- package/dist/config/task-skill-selection.d.ts +24 -0
- package/dist/config/task-skill-selection.d.ts.map +1 -0
- package/dist/config/task-skill-selection.js +79 -0
- package/dist/config/task-skill-selection.js.map +1 -0
- package/dist/config/translators/claude-translator.d.ts +7 -0
- package/dist/config/translators/claude-translator.d.ts.map +1 -0
- package/dist/config/translators/claude-translator.js +30 -0
- package/dist/config/translators/claude-translator.js.map +1 -0
- package/dist/config/translators/codex-translator.d.ts +7 -0
- package/dist/config/translators/codex-translator.d.ts.map +1 -0
- package/dist/config/translators/codex-translator.js +20 -0
- package/dist/config/translators/codex-translator.js.map +1 -0
- package/dist/config/translators/opencode-translator.d.ts +7 -0
- package/dist/config/translators/opencode-translator.d.ts.map +1 -0
- package/dist/config/translators/opencode-translator.js +19 -0
- package/dist/config/translators/opencode-translator.js.map +1 -0
- package/dist/config/translators/permission-projection.d.ts +26 -0
- package/dist/config/translators/permission-projection.d.ts.map +1 -0
- package/dist/config/translators/permission-projection.js +22 -0
- package/dist/config/translators/permission-projection.js.map +1 -0
- package/dist/config/web-tools-config.d.ts +45 -0
- package/dist/config/web-tools-config.d.ts.map +1 -0
- package/dist/config/web-tools-config.js +846 -0
- package/dist/config/web-tools-config.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/engines/engine-registry.d.ts +45 -0
- package/dist/engines/engine-registry.d.ts.map +1 -0
- package/dist/engines/engine-registry.js +125 -0
- package/dist/engines/engine-registry.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -18
- package/dist/index.js.map +1 -1
- package/dist/kiln-yaml-types.d.ts +207 -1
- package/dist/kiln-yaml-types.d.ts.map +1 -1
- package/dist/kiln-yaml-types.js +29 -0
- package/dist/kiln-yaml-types.js.map +1 -1
- package/dist/kiln-yaml.d.ts +1 -1
- package/dist/kiln-yaml.d.ts.map +1 -1
- package/dist/kiln-yaml.js +93 -0
- package/dist/kiln-yaml.js.map +1 -1
- package/dist/mcp/config-generator.d.ts.map +1 -1
- package/dist/mcp/config-generator.js +8 -7
- package/dist/mcp/config-generator.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -25
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -103
- package/dist/mcp/index.js.map +1 -1
- package/dist/wrapper/__tests__/session-manager-context-governor.test.d.ts +2 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.d.ts.map +1 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.js +210 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.js.map +1 -0
- package/dist/wrapper/claude-code-process.d.ts +1 -0
- package/dist/wrapper/claude-code-process.d.ts.map +1 -1
- package/dist/wrapper/claude-code-process.js +32 -19
- package/dist/wrapper/claude-code-process.js.map +1 -1
- package/dist/wrapper/cleanup-registry.d.ts.map +1 -1
- package/dist/wrapper/cleanup-registry.js +3 -1
- package/dist/wrapper/cleanup-registry.js.map +1 -1
- package/dist/wrapper/codex-session.d.ts +3 -0
- package/dist/wrapper/codex-session.d.ts.map +1 -1
- package/dist/wrapper/codex-session.js +193 -85
- package/dist/wrapper/codex-session.js.map +1 -1
- package/dist/wrapper/debug.d.ts.map +1 -1
- package/dist/wrapper/debug.js +2 -0
- package/dist/wrapper/debug.js.map +1 -1
- package/dist/wrapper/direct-provider-adapter-factory.d.ts +12 -0
- package/dist/wrapper/direct-provider-adapter-factory.d.ts.map +1 -0
- package/dist/wrapper/direct-provider-adapter-factory.js +99 -0
- package/dist/wrapper/direct-provider-adapter-factory.js.map +1 -0
- package/dist/wrapper/index.d.ts +0 -2
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +0 -1
- package/dist/wrapper/index.js.map +1 -1
- package/dist/wrapper/opencode-session.d.ts +4 -0
- package/dist/wrapper/opencode-session.d.ts.map +1 -1
- package/dist/wrapper/opencode-session.js +245 -38
- package/dist/wrapper/opencode-session.js.map +1 -1
- package/dist/wrapper/permission-evaluator.d.ts +2 -1
- package/dist/wrapper/permission-evaluator.d.ts.map +1 -1
- package/dist/wrapper/permission-evaluator.js +54 -0
- package/dist/wrapper/permission-evaluator.js.map +1 -1
- package/dist/wrapper/permission-normalizer.d.ts +5 -1
- package/dist/wrapper/permission-normalizer.d.ts.map +1 -1
- package/dist/wrapper/permission-normalizer.js +17 -0
- package/dist/wrapper/permission-normalizer.js.map +1 -1
- package/dist/wrapper/permission-policy-authorizer.d.ts +1 -1
- package/dist/wrapper/permission-policy-authorizer.js +1 -1
- package/dist/wrapper/pooled-harness-session.d.ts +24 -0
- package/dist/wrapper/pooled-harness-session.d.ts.map +1 -0
- package/dist/wrapper/pooled-harness-session.js +123 -0
- package/dist/wrapper/pooled-harness-session.js.map +1 -0
- package/dist/wrapper/preamble-builder.d.ts +4 -1
- package/dist/wrapper/preamble-builder.d.ts.map +1 -1
- package/dist/wrapper/preamble-builder.js +48 -20
- package/dist/wrapper/preamble-builder.js.map +1 -1
- package/dist/wrapper/provider-session.d.ts +25 -5
- package/dist/wrapper/provider-session.d.ts.map +1 -1
- package/dist/wrapper/provider-session.js +562 -138
- package/dist/wrapper/provider-session.js.map +1 -1
- package/dist/wrapper/session-manager.d.ts.map +1 -1
- package/dist/wrapper/session-manager.js +16 -5
- package/dist/wrapper/session-manager.js.map +1 -1
- package/dist/wrapper/session-registry.d.ts +11 -1
- package/dist/wrapper/session-registry.d.ts.map +1 -1
- package/dist/wrapper/session-registry.js +167 -259
- package/dist/wrapper/session-registry.js.map +1 -1
- package/dist/wrapper/session-store.d.ts +33 -10
- package/dist/wrapper/session-store.d.ts.map +1 -1
- package/dist/wrapper/session-store.js +327 -84
- package/dist/wrapper/session-store.js.map +1 -1
- package/dist/wrapper/session.d.ts +55 -2
- package/dist/wrapper/session.d.ts.map +1 -1
- package/dist/wrapper/session.js +11 -2
- package/dist/wrapper/session.js.map +1 -1
- package/package.json +8 -8
- package/dist/application/__tests__/plan-exit-tool.test.d.ts +0 -2
- package/dist/application/__tests__/plan-exit-tool.test.d.ts.map +0 -1
- package/dist/application/__tests__/plan-exit-tool.test.js +0 -12
- package/dist/application/__tests__/plan-exit-tool.test.js.map +0 -1
- package/dist/application/context-governor.d.ts +0 -26
- package/dist/application/context-governor.d.ts.map +0 -1
- package/dist/application/context-governor.js +0 -164
- package/dist/application/context-governor.js.map +0 -1
- package/dist/application/plan-exit-tool.d.ts +0 -19
- package/dist/application/plan-exit-tool.d.ts.map +0 -1
- package/dist/application/plan-exit-tool.js +0 -13
- package/dist/application/plan-exit-tool.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -7
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -24
- package/dist/commands/serve.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -36
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -156
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/transports.d.ts +0 -28
- package/dist/mcp/transports.d.ts.map +0 -1
- package/dist/mcp/transports.js +0 -108
- package/dist/mcp/transports.js.map +0 -1
- package/dist/mcp-entry.d.ts +0 -3
- package/dist/mcp-entry.d.ts.map +0 -1
- package/dist/mcp-entry.js +0 -19
- package/dist/mcp-entry.js.map +0 -1
- package/dist/sync/agent-sync.d.ts +0 -13
- package/dist/sync/agent-sync.d.ts.map +0 -1
- package/dist/sync/agent-sync.js +0 -130
- package/dist/sync/agent-sync.js.map +0 -1
- package/dist/sync/agent-sync.test.d.ts +0 -2
- package/dist/sync/agent-sync.test.d.ts.map +0 -1
- package/dist/sync/agent-sync.test.js +0 -130
- package/dist/sync/agent-sync.test.js.map +0 -1
- package/dist/sync/agents-md-sync.d.ts +0 -7
- package/dist/sync/agents-md-sync.d.ts.map +0 -1
- package/dist/sync/agents-md-sync.js +0 -44
- package/dist/sync/agents-md-sync.js.map +0 -1
- package/dist/sync/agents-md-sync.test.d.ts +0 -2
- package/dist/sync/agents-md-sync.test.d.ts.map +0 -1
- package/dist/sync/agents-md-sync.test.js +0 -154
- package/dist/sync/agents-md-sync.test.js.map +0 -1
- package/dist/sync/hook-sync.d.ts +0 -8
- package/dist/sync/hook-sync.d.ts.map +0 -1
- package/dist/sync/hook-sync.js +0 -90
- package/dist/sync/hook-sync.js.map +0 -1
- package/dist/sync/security-sync.d.ts +0 -9
- package/dist/sync/security-sync.d.ts.map +0 -1
- package/dist/sync/security-sync.js +0 -161
- package/dist/sync/security-sync.js.map +0 -1
- package/dist/sync/skill-sync.d.ts +0 -10
- package/dist/sync/skill-sync.d.ts.map +0 -1
- package/dist/sync/skill-sync.js +0 -87
- package/dist/sync/skill-sync.js.map +0 -1
- package/dist/sync/skill-sync.test.d.ts +0 -2
- package/dist/sync/skill-sync.test.d.ts.map +0 -1
- package/dist/sync/skill-sync.test.js +0 -163
- package/dist/sync/skill-sync.test.js.map +0 -1
- package/dist/wrapper/executable-provider-session.d.ts +0 -26
- package/dist/wrapper/executable-provider-session.d.ts.map +0 -1
- package/dist/wrapper/executable-provider-session.js +0 -214
- package/dist/wrapper/executable-provider-session.js.map +0 -1
package/dist/commands/run.js
CHANGED
|
@@ -3,23 +3,38 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import readline from "node:readline";
|
|
5
5
|
import { SessionManager } from "../wrapper/session-manager.js";
|
|
6
|
-
import { createDefaultRegistry, isDirectApiProvider } from "../wrapper/session-registry.js";
|
|
6
|
+
import { createDefaultRegistry, getRuntimeProviderAvailability, isDirectApiProvider, } from "../wrapper/session-registry.js";
|
|
7
7
|
import { cleanupRegistry } from "../wrapper/cleanup-registry.js";
|
|
8
8
|
import { defaultBuildSystemPrompt } from "../config.js";
|
|
9
|
+
import { withGlobalIdentityContext } from "../config/operator-identity-context.js";
|
|
9
10
|
import { findAgent, loadAgentDefinitions, } from "../application/agent-loader.js";
|
|
11
|
+
import { resolveAgentSkillContextCandidates, withContextCandidates, } from "../application/agent-skill-context.js";
|
|
12
|
+
import { resolveInstructionProfileContextCandidates } from "../application/instruction-profile-context.js";
|
|
13
|
+
import { withWorkGovernanceContext } from "../application/work-governance-context.js";
|
|
14
|
+
import { readKilnYaml } from "../kiln-yaml.js";
|
|
10
15
|
import { computeEvalScore, printContextGovernancePreview, printReport, summarizeContextGovernance, } from "../application/session-report.js";
|
|
11
16
|
import { buildModuleSummaryArtifact, extractTouchedFilePaths } from "../application/repo-summary-cache.js";
|
|
17
|
+
import { buildCliCompletionContextArtifacts } from "../application/session-context-artifacts.js";
|
|
12
18
|
import { inferResumeStrategyFeedback } from "../application/resume-strategy-feedback.js";
|
|
13
19
|
import { resolveResumeSessionId } from "../application/session-resume.js";
|
|
20
|
+
import { deriveSessionMetadata } from "../application/session-metadata.js";
|
|
14
21
|
import { SessionHooks } from "../application/session-hooks.js";
|
|
15
22
|
import { runSession } from "../application/run-session.js";
|
|
16
23
|
import { ApprovalMemoryStore as ApprovalMemoryStoreImpl } from "../wrapper/index.js";
|
|
17
24
|
import { TranscriptStore } from "../wrapper/session-store.js";
|
|
18
25
|
import { resolveEffectiveModel } from "../config/env-config.js";
|
|
19
|
-
import { readGlobalConfig } from "../config/global-config.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
26
|
+
import { readGlobalConfig, resolveGlobalDefaultModel } from "../config/global-config.js";
|
|
27
|
+
import { loadKilnConfig } from "../config/config-merger.js";
|
|
28
|
+
import { inferRouteTask, resolveProviderRouteCandidates } from "../config/provider-route-candidates.js";
|
|
29
|
+
import { createManagedDirectProviderAdapterFactory } from "../config/managed-agent-direct-adapters.js";
|
|
30
|
+
import { createKilnConfigTools } from "../application/config-tools.js";
|
|
31
|
+
import { createWorkGovernanceTools } from "../application/work-governance-tool.js";
|
|
32
|
+
import { discoverManagedAgentProviderModels } from "../config/managed-agent-provider-models.js";
|
|
33
|
+
import { resolveManagedInvocationToolOptions } from "../config/managed-agent-routes.js";
|
|
34
|
+
import { loadConfiguredBuiltinToolSurfaceOptions } from "../config/builtin-tool-surface-config.js";
|
|
35
|
+
import { resolveEngineAvailabilityMap } from "../engines/engine-registry.js";
|
|
36
|
+
import { SkillGenerator, AnthropicAdapter, GoalRunStore, WorkItemStore, createSessionBuiltinToolOptions, formatProviderModelRouteCooldown, mapProviderModelRouteErrorToOutcome, scoreComplexity, } from "@kilnai/core";
|
|
37
|
+
import { ProviderModelRouteHealthStore, discoverGuiDirectProviderModelDiscovery, getProjectContextArtifactCache, } from "@kilnai/runtime";
|
|
23
38
|
function resolveMode(flags) {
|
|
24
39
|
if (flags.apiKey && flags.provider)
|
|
25
40
|
return "byok";
|
|
@@ -29,6 +44,44 @@ function resolveMode(flags) {
|
|
|
29
44
|
}
|
|
30
45
|
const DEFAULT_POLICY = { approval: "never", sandbox: "workspace-write" };
|
|
31
46
|
const PLAN_POLICY = { approval: "untrusted", sandbox: "read-only" };
|
|
47
|
+
export function buildRunSessionRequirements(preferredProvider) {
|
|
48
|
+
return {
|
|
49
|
+
preferredProvider,
|
|
50
|
+
requiresMcp: preferredProvider === undefined,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function resolveRunProviderModelAdmission(input) {
|
|
54
|
+
if (!isDirectApiProvider(input.provider)) {
|
|
55
|
+
return { ok: true };
|
|
56
|
+
}
|
|
57
|
+
const discovery = input.discovery[input.provider];
|
|
58
|
+
if (!discovery) {
|
|
59
|
+
return {
|
|
60
|
+
ok: false,
|
|
61
|
+
error: `Provider '${input.provider}' is unavailable`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (discovery.status !== "available") {
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
error: discovery.reason,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const model = input.model?.trim() ?? "";
|
|
71
|
+
if (model.length === 0) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: `Provider '${input.provider}' requires a selected model.`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (!discovery.models.includes(model)) {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
error: `Provider '${input.provider}' does not advertise model '${model}'`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { ok: true };
|
|
84
|
+
}
|
|
32
85
|
function buildConfig(flags, mode) {
|
|
33
86
|
return {
|
|
34
87
|
mode,
|
|
@@ -37,8 +90,49 @@ function buildConfig(flags, mode) {
|
|
|
37
90
|
permissionPolicy: flags.plan ? PLAN_POLICY : (flags.permissionPolicy ?? DEFAULT_POLICY),
|
|
38
91
|
};
|
|
39
92
|
}
|
|
93
|
+
async function resolveAdmittedRunRouteCandidates(input) {
|
|
94
|
+
const rejectedReasons = [];
|
|
95
|
+
const directCandidates = input.candidates.filter((candidate) => isDirectApiProvider(candidate.provider));
|
|
96
|
+
const directDiscovery = directCandidates.length > 0
|
|
97
|
+
? await discoverGuiDirectProviderModelDiscovery({
|
|
98
|
+
...getRuntimeProviderAvailability(input.registry),
|
|
99
|
+
...Object.fromEntries(directCandidates.map((candidate) => [candidate.provider, true])),
|
|
100
|
+
}, {
|
|
101
|
+
...process.env,
|
|
102
|
+
...input.env,
|
|
103
|
+
})
|
|
104
|
+
: {};
|
|
105
|
+
const admitted = [];
|
|
106
|
+
for (const candidate of input.candidates) {
|
|
107
|
+
if (!isDirectApiProvider(candidate.provider)) {
|
|
108
|
+
admitted.push(candidate);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const admission = resolveRunProviderModelAdmission({
|
|
112
|
+
provider: candidate.provider,
|
|
113
|
+
model: candidate.model,
|
|
114
|
+
discovery: directDiscovery,
|
|
115
|
+
});
|
|
116
|
+
if (!admission.ok) {
|
|
117
|
+
rejectedReasons.push(`${formatRouteCandidate(candidate)}: ${admission.error}`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (candidate.model) {
|
|
121
|
+
const health = await input.routeHealthStore.evaluateRouteHealth(candidate.provider, candidate.model);
|
|
122
|
+
if (!health.healthy) {
|
|
123
|
+
rejectedReasons.push(`${formatRouteCandidate(candidate)}: ${formatProviderModelRouteCooldown(health)}`);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
admitted.push(candidate);
|
|
128
|
+
}
|
|
129
|
+
return { candidates: admitted, rejectedReasons };
|
|
130
|
+
}
|
|
131
|
+
function formatRouteCandidate(candidate) {
|
|
132
|
+
return candidate.model ? `${candidate.provider}/${candidate.model}` : candidate.provider;
|
|
133
|
+
}
|
|
40
134
|
function appendAgentInstructionsToSystemPrompt(appConfig, agent) {
|
|
41
|
-
const instructions = agent
|
|
135
|
+
const instructions = renderAgentProfilePromptContext(agent);
|
|
42
136
|
if (!instructions) {
|
|
43
137
|
return appConfig;
|
|
44
138
|
}
|
|
@@ -53,18 +147,42 @@ function appendAgentInstructionsToSystemPrompt(appConfig, agent) {
|
|
|
53
147
|
},
|
|
54
148
|
};
|
|
55
149
|
}
|
|
150
|
+
function renderAgentProfilePromptContext(agent) {
|
|
151
|
+
if (!agent) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return [
|
|
155
|
+
"## Agent Profile",
|
|
156
|
+
`name: ${agent.name}`,
|
|
157
|
+
agent.displayName ? `displayName: ${agent.displayName}` : undefined,
|
|
158
|
+
agent.nicknameCandidates?.length ? `nicknameCandidates: ${agent.nicknameCandidates.join(", ")}` : undefined,
|
|
159
|
+
`role: ${agent.role}`,
|
|
160
|
+
agent.description ? `description: ${agent.description}` : undefined,
|
|
161
|
+
agent.goal ? `goal: ${agent.goal}` : undefined,
|
|
162
|
+
agent.backstory ? `backstory: ${agent.backstory}` : undefined,
|
|
163
|
+
agent.tier ? `tier: ${agent.tier}` : undefined,
|
|
164
|
+
agent.mode ? `mode: ${agent.mode}` : undefined,
|
|
165
|
+
agent.authorityProfile ? `authorityProfile: ${agent.authorityProfile}` : undefined,
|
|
166
|
+
agent.routeId ? `routeId: ${agent.routeId}` : undefined,
|
|
167
|
+
agent.skills?.length ? `skills: ${agent.skills.join(", ")}` : undefined,
|
|
168
|
+
agent.instructionProfiles?.length ? `instructionProfiles: ${agent.instructionProfiles.join(", ")}` : undefined,
|
|
169
|
+
agent.instructions ? "instructions:" : undefined,
|
|
170
|
+
agent.instructions,
|
|
171
|
+
].filter((line) => Boolean(line)).join("\n");
|
|
172
|
+
}
|
|
56
173
|
function parseSubmittedPlan(line) {
|
|
57
174
|
try {
|
|
58
175
|
const parsed = JSON.parse(line);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
?
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
67
|
-
|
|
176
|
+
if (parsed.kind === "tool_call_started") {
|
|
177
|
+
const payload = typeof parsed.payload === "object" && parsed.payload !== null
|
|
178
|
+
? parsed.payload
|
|
179
|
+
: undefined;
|
|
180
|
+
return payload ? extractSubmitPlan(payload) : undefined;
|
|
181
|
+
}
|
|
182
|
+
if (parsed.kind === "plan_submitted") {
|
|
183
|
+
return renderStructuredPlanSummary(parsed.payload);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
68
186
|
}
|
|
69
187
|
catch {
|
|
70
188
|
return undefined;
|
|
@@ -82,7 +200,70 @@ function extractSubmitPlan(event) {
|
|
|
82
200
|
? event.input
|
|
83
201
|
: undefined;
|
|
84
202
|
const plan = input?.plan;
|
|
85
|
-
|
|
203
|
+
if (typeof plan === "string") {
|
|
204
|
+
return plan;
|
|
205
|
+
}
|
|
206
|
+
return renderStructuredPlanSummary(input);
|
|
207
|
+
}
|
|
208
|
+
function renderStructuredPlanSummary(input) {
|
|
209
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const plan = input;
|
|
213
|
+
const objective = typeof plan.objective === "string" ? plan.objective.trim() : "";
|
|
214
|
+
if (!objective) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
const list = (value) => Array.isArray(value)
|
|
218
|
+
? value.flatMap((entry) => typeof entry === "string" ? [entry.trim()] : []).filter((entry) => entry.length > 0)
|
|
219
|
+
: [];
|
|
220
|
+
const recommendation = plan.workGovernanceRecommendation
|
|
221
|
+
&& typeof plan.workGovernanceRecommendation === "object"
|
|
222
|
+
&& !Array.isArray(plan.workGovernanceRecommendation)
|
|
223
|
+
? plan.workGovernanceRecommendation
|
|
224
|
+
: undefined;
|
|
225
|
+
const proposedWorkItems = Array.isArray(plan.proposedWorkItems)
|
|
226
|
+
? plan.proposedWorkItems.filter((entry) => entry && typeof entry === "object" && !Array.isArray(entry))
|
|
227
|
+
: [];
|
|
228
|
+
const lines = [
|
|
229
|
+
objective,
|
|
230
|
+
typeof plan.riskClassification === "string" ? `- risk: ${plan.riskClassification}` : undefined,
|
|
231
|
+
typeof recommendation?.posture === "string" ? `- posture: ${recommendation.posture}` : undefined,
|
|
232
|
+
typeof recommendation?.workflowProfile === "string" ? `- workflow: ${recommendation.workflowProfile}` : undefined,
|
|
233
|
+
typeof recommendation?.rationale === "string" ? `- governance rationale: ${recommendation.rationale}` : undefined,
|
|
234
|
+
typeof plan.sourceSpecificationId === "string" ? `- source specification: ${plan.sourceSpecificationId}` : undefined,
|
|
235
|
+
...list(plan.clarificationRecordIds).map((clarification) => `- clarification: ${clarification}`),
|
|
236
|
+
...list(plan.affectedSurfaces).map((surface) => `- affected surface: ${surface}`),
|
|
237
|
+
...list(plan.nonGoals).map((goal) => `- non-goal: ${goal}`),
|
|
238
|
+
...list(plan.assumptions).map((assumption) => `- assumption: ${assumption}`),
|
|
239
|
+
...list(plan.operatorDecisionsRequired).map((decision) => `- decision: ${decision}`),
|
|
240
|
+
...list(plan.expectedEvidence).map((evidence) => `- evidence: ${evidence}`),
|
|
241
|
+
...list(plan.verificationGates).map((gate) => `- gate: ${gate}`),
|
|
242
|
+
...list(plan.managedAgentDelegationCandidates).map((candidate) => `- delegation candidate: ${candidate}`),
|
|
243
|
+
...list(plan.approvalBoundaries).map((boundary) => `- approval boundary: ${boundary}`),
|
|
244
|
+
typeof plan.rollbackNotes === "string" && plan.rollbackNotes.trim().length > 0
|
|
245
|
+
? `- rollback: ${plan.rollbackNotes.trim()}`
|
|
246
|
+
: undefined,
|
|
247
|
+
...list(plan.residualRisks).map((risk) => `- residual risk: ${risk}`),
|
|
248
|
+
...proposedWorkItems.flatMap((item) => {
|
|
249
|
+
const itemId = typeof item.id === "string" ? item.id.trim() : "";
|
|
250
|
+
const itemSummary = typeof item.summary === "string" ? item.summary.trim() : "";
|
|
251
|
+
const itemWorkflow = typeof item.workflowProfile === "string" ? item.workflowProfile.trim() : "";
|
|
252
|
+
const itemRisk = typeof item.risk === "string" ? item.risk.trim() : "";
|
|
253
|
+
const itemEvidence = list(item.expectedEvidence);
|
|
254
|
+
const itemGates = list(item.verificationGates);
|
|
255
|
+
const itemDeps = list(item.dependencies);
|
|
256
|
+
return [
|
|
257
|
+
itemSummary || itemId ? `- work item ${itemId || "item"}: ${itemSummary || "(no summary)"}` : undefined,
|
|
258
|
+
itemWorkflow ? ` workflow: ${itemWorkflow}` : undefined,
|
|
259
|
+
itemRisk ? ` risk: ${itemRisk}` : undefined,
|
|
260
|
+
...itemEvidence.map((evidence) => ` evidence: ${evidence}`),
|
|
261
|
+
...itemGates.map((gate) => ` gate: ${gate}`),
|
|
262
|
+
...itemDeps.map((dependency) => ` depends on: ${dependency}`),
|
|
263
|
+
];
|
|
264
|
+
}),
|
|
265
|
+
].filter((line) => typeof line === "string" && line.length > 0);
|
|
266
|
+
return lines.join("\n");
|
|
86
267
|
}
|
|
87
268
|
async function readSubmittedPlanFromTranscript(projectPath, sessionId) {
|
|
88
269
|
try {
|
|
@@ -144,14 +325,55 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
144
325
|
}
|
|
145
326
|
}
|
|
146
327
|
const globalConfig = readGlobalConfig();
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const
|
|
328
|
+
const projectConfig = readKilnYaml(join(cwd, ".kiln"));
|
|
329
|
+
const resolvedKilnConfig = await loadKilnConfig(cwd);
|
|
330
|
+
const configuredRouteCandidates = resolveProviderRouteCandidates({
|
|
331
|
+
globalConfig,
|
|
332
|
+
flagProvider: flags.provider,
|
|
333
|
+
flagModel: flags.model,
|
|
334
|
+
taskText: task,
|
|
335
|
+
agentTaskAffinity: resolvedAgent?.taskAffinity,
|
|
336
|
+
}).map((candidate) => (candidate.model || !resolvedAgent?.model
|
|
337
|
+
? candidate
|
|
338
|
+
: { ...candidate, model: resolvedAgent.model }));
|
|
339
|
+
const preferredProvider = configuredRouteCandidates[0]?.provider;
|
|
340
|
+
if (flags.requestedAuthority
|
|
341
|
+
&& flags.requestedAuthority !== "auto"
|
|
342
|
+
&& (!preferredProvider || !isDirectApiProvider(preferredProvider))) {
|
|
343
|
+
console.error("--authority is only supported for direct API providers in CLI run. Use --plan for harness read-only planning.");
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
const effectiveModel = configuredRouteCandidates[0]?.model
|
|
347
|
+
?? resolveEffectiveModel(flags.model, resolveGlobalDefaultModel(globalConfig))
|
|
348
|
+
?? resolvedAgent?.model;
|
|
349
|
+
const config = buildConfig({ ...flags, provider: preferredProvider }, mode);
|
|
350
|
+
let identityAppConfig = withWorkGovernanceContext(withGlobalIdentityContext(appConfig, globalConfig), resolvedKilnConfig?.workGovernance);
|
|
351
|
+
identityAppConfig = withContextCandidates(identityAppConfig, resolveInstructionProfileContextCandidates({
|
|
352
|
+
projectPath: cwd,
|
|
353
|
+
globalConfig,
|
|
354
|
+
projectConfig,
|
|
355
|
+
agent: resolvedAgent,
|
|
356
|
+
}));
|
|
357
|
+
try {
|
|
358
|
+
identityAppConfig = withContextCandidates(identityAppConfig, resolveAgentSkillContextCandidates(resolvedAgent, cwd, undefined, resolvedKilnConfig?.skills, {
|
|
359
|
+
task: inferRouteTask({
|
|
360
|
+
text: task,
|
|
361
|
+
agentTaskAffinity: resolvedAgent?.taskAffinity,
|
|
362
|
+
}),
|
|
363
|
+
provider: preferredProvider,
|
|
364
|
+
model: effectiveModel,
|
|
365
|
+
modelTaskSuitability: resolvedKilnConfig?.modelTaskSuitability,
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
const runtimeAppConfig = appendAgentInstructionsToSystemPrompt(identityAppConfig, resolvedAgent);
|
|
150
373
|
const sessionId = randomUUID();
|
|
151
374
|
const { registry, worktreeManager } = createDefaultRegistry();
|
|
152
375
|
const contextArtifactCache = await getProjectContextArtifactCache(cwd);
|
|
153
376
|
const manager = new SessionManager(config, runtimeAppConfig, contextArtifactCache, worktreeManager);
|
|
154
|
-
const preferredProvider = config.provider;
|
|
155
377
|
const resumeSessionId = await resolveResumeSessionId(cwd, flags.resume, preferredProvider);
|
|
156
378
|
const transcriptStore = new TranscriptStore(cwd);
|
|
157
379
|
const resumedMeta = resumeSessionId
|
|
@@ -184,14 +406,37 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
184
406
|
if (config.mode === "byok" && config.provider && config.apiKey) {
|
|
185
407
|
env[`${config.provider.toUpperCase()}_API_KEY`] = config.apiKey;
|
|
186
408
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
409
|
+
const directRouteHealthStore = configuredRouteCandidates.some((candidate) => isDirectApiProvider(candidate.provider))
|
|
410
|
+
? new ProviderModelRouteHealthStore()
|
|
411
|
+
: undefined;
|
|
412
|
+
const admittedRoutes = configuredRouteCandidates.length > 0
|
|
413
|
+
? await resolveAdmittedRunRouteCandidates({
|
|
414
|
+
candidates: configuredRouteCandidates,
|
|
415
|
+
registry,
|
|
416
|
+
env,
|
|
417
|
+
routeHealthStore: directRouteHealthStore ?? new ProviderModelRouteHealthStore(),
|
|
418
|
+
})
|
|
419
|
+
: { candidates: [], rejectedReasons: [] };
|
|
420
|
+
if (configuredRouteCandidates.length > 0 && admittedRoutes.candidates.length === 0) {
|
|
421
|
+
console.error("Error: No configured provider routes are currently available.");
|
|
422
|
+
for (const reason of admittedRoutes.rejectedReasons) {
|
|
423
|
+
console.error(`- ${reason}`);
|
|
424
|
+
}
|
|
425
|
+
process.exit(1);
|
|
426
|
+
}
|
|
427
|
+
const requirements = buildRunSessionRequirements(preferredProvider);
|
|
191
428
|
const startedAt = new Date().toISOString();
|
|
429
|
+
const initialMetadata = deriveSessionMetadata({
|
|
430
|
+
task,
|
|
431
|
+
provider: preferredProvider,
|
|
432
|
+
model: effectiveModel,
|
|
433
|
+
});
|
|
192
434
|
await transcriptStore.init(sessionId, {
|
|
193
435
|
kilnSessionId: sessionId,
|
|
194
436
|
provider: preferredProvider ?? "unknown",
|
|
437
|
+
title: initialMetadata.title,
|
|
438
|
+
summary: initialMetadata.summary,
|
|
439
|
+
tags: initialMetadata.tags,
|
|
195
440
|
task,
|
|
196
441
|
startedAt,
|
|
197
442
|
resumeStrategy: context.resumeStrategy,
|
|
@@ -206,6 +451,38 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
206
451
|
.filter((block) => block.kind === "artifact")
|
|
207
452
|
.map((block) => block.content),
|
|
208
453
|
});
|
|
454
|
+
const configuredBuiltinToolOptions = await loadConfiguredBuiltinToolSurfaceOptions(appConfig, cwd, {
|
|
455
|
+
memoryAuthority: {
|
|
456
|
+
modelFacingSession: true,
|
|
457
|
+
permissionPolicy: config.permissionPolicy,
|
|
458
|
+
permissionAgent: resolvedAgent?.name,
|
|
459
|
+
caller: { kind: "operator_surface", id: "run" },
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
const workItemStore = new WorkItemStore();
|
|
463
|
+
const goalRunStore = new GoalRunStore();
|
|
464
|
+
const builtinToolOptions = createSessionBuiltinToolOptions({
|
|
465
|
+
...configuredBuiltinToolOptions,
|
|
466
|
+
workItemStore,
|
|
467
|
+
goalRunStore,
|
|
468
|
+
additionalTools: [
|
|
469
|
+
...(configuredBuiltinToolOptions.additionalTools ?? []),
|
|
470
|
+
...createKilnConfigTools(cwd),
|
|
471
|
+
...createWorkGovernanceTools(resolvedKilnConfig?.workGovernance, { workItemStore, goalRunStore }),
|
|
472
|
+
],
|
|
473
|
+
});
|
|
474
|
+
const engineAvailability = resolveEngineAvailabilityMap(globalConfig);
|
|
475
|
+
const managedAgentProviderModels = await discoverManagedAgentProviderModels();
|
|
476
|
+
const managedInvocationResolution = await resolveManagedInvocationToolOptions(globalConfig, {
|
|
477
|
+
cwd,
|
|
478
|
+
registry,
|
|
479
|
+
surface: "run",
|
|
480
|
+
isProviderAvailable: (providerId) => engineAvailability.get(providerId),
|
|
481
|
+
providerModels: managedAgentProviderModels,
|
|
482
|
+
directAdapterFactory: createManagedDirectProviderAdapterFactory({ builtinToolOptions, runtimeEnv: env }),
|
|
483
|
+
artifactStore: builtinToolOptions.artifactResources?.store,
|
|
484
|
+
});
|
|
485
|
+
const managedInvocation = appConfig.managedInvocation ?? managedInvocationResolution.managedInvocation;
|
|
209
486
|
const sessionConfig = {
|
|
210
487
|
task,
|
|
211
488
|
systemPrompt: context.systemPrompt,
|
|
@@ -220,25 +497,46 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
220
497
|
outputSchema: flags.outputSchema,
|
|
221
498
|
addDir: flags.addDir,
|
|
222
499
|
localProvider: flags.localProvider,
|
|
500
|
+
builtinToolOptions,
|
|
501
|
+
managedInvocation,
|
|
223
502
|
model: effectiveModel,
|
|
503
|
+
reasoningEffort: flags.reasoningEffort,
|
|
504
|
+
requestedAuthority: flags.requestedAuthority,
|
|
224
505
|
};
|
|
225
506
|
const sessionHooks = new SessionHooks(appConfig.kilnYaml?.hooks, {
|
|
226
507
|
sessionId,
|
|
227
508
|
workingDirectory: context.workingDirectory,
|
|
228
509
|
});
|
|
229
510
|
const approvalMemoryStore = new ApprovalMemoryStoreImpl(cwd);
|
|
511
|
+
let signalHandlersRegistered = false;
|
|
512
|
+
let shutdownStarted = false;
|
|
513
|
+
const unregisterSignalHandlers = () => {
|
|
514
|
+
if (!signalHandlersRegistered)
|
|
515
|
+
return;
|
|
516
|
+
process.off("SIGINT", shutdown);
|
|
517
|
+
process.off("SIGTERM", shutdown);
|
|
518
|
+
signalHandlersRegistered = false;
|
|
519
|
+
};
|
|
230
520
|
const shutdown = () => {
|
|
231
|
-
|
|
521
|
+
if (shutdownStarted)
|
|
522
|
+
return;
|
|
523
|
+
shutdownStarted = true;
|
|
524
|
+
unregisterSignalHandlers();
|
|
525
|
+
void cleanupRegistry.runAll().finally(() => {
|
|
526
|
+
process.exit(130);
|
|
527
|
+
});
|
|
232
528
|
};
|
|
233
529
|
process.on("SIGINT", shutdown);
|
|
234
530
|
process.on("SIGTERM", shutdown);
|
|
531
|
+
signalHandlersRegistered = true;
|
|
235
532
|
sessionHooks.sessionStart();
|
|
236
|
-
const { finalCostUsd, sessionSucceeded, lastError, accumulatedText, toolCallCount, turnDepth, successfulProviderId, transcript, exactArtifacts, submittedPlan: submittedPlanFromSession, } = await runSession({
|
|
533
|
+
const { finalCostUsd, sessionSucceeded, lastError, accumulatedText, toolCallCount, turnDepth, successfulProviderId, successfulModelId, attempts, transcript, exactArtifacts, submittedPlan: submittedPlanFromSession, } = await runSession({
|
|
237
534
|
registry,
|
|
238
535
|
cleanupRegistry,
|
|
239
536
|
manager,
|
|
240
537
|
context,
|
|
241
538
|
requirements,
|
|
539
|
+
routeCandidates: admittedRoutes.candidates.length > 0 ? admittedRoutes.candidates : undefined,
|
|
242
540
|
sessionConfig,
|
|
243
541
|
permissionPolicy: config.permissionPolicy,
|
|
244
542
|
permissionAgent: resolvedAgent?.name,
|
|
@@ -246,15 +544,40 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
246
544
|
approvalMemoryStore,
|
|
247
545
|
env,
|
|
248
546
|
sessionHooks,
|
|
547
|
+
}).finally(() => {
|
|
548
|
+
sessionHooks.sessionEnd();
|
|
549
|
+
unregisterSignalHandlers();
|
|
249
550
|
});
|
|
250
|
-
|
|
551
|
+
if (directRouteHealthStore) {
|
|
552
|
+
for (const attempt of attempts) {
|
|
553
|
+
if (!isDirectApiProvider(attempt.providerId) || !attempt.model) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
const errorMessage = attempt.error ?? lastError ?? "Provider ended with unknown error";
|
|
557
|
+
await directRouteHealthStore.recordOutcome({
|
|
558
|
+
providerId: attempt.providerId,
|
|
559
|
+
modelId: attempt.model,
|
|
560
|
+
outcome: attempt.succeeded
|
|
561
|
+
? { type: "ok" }
|
|
562
|
+
: mapProviderModelRouteErrorToOutcome(errorMessage),
|
|
563
|
+
...(attempt.succeeded ? {} : { errorMessage }),
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
251
567
|
try {
|
|
252
568
|
for (const [seq, entry] of transcript.entries()) {
|
|
569
|
+
const timestamp = "ts" in entry && typeof entry.ts === "string"
|
|
570
|
+
? entry.ts
|
|
571
|
+
: new Date().toISOString();
|
|
572
|
+
const legacyType = typeof entry.event.type === "string" ? entry.event.type : "assistant_message";
|
|
253
573
|
await transcriptStore.append(sessionId, {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
574
|
+
eventId: randomUUID(),
|
|
575
|
+
kilnSessionId: sessionId,
|
|
576
|
+
sequence: seq + 1,
|
|
577
|
+
timestamp,
|
|
578
|
+
kind: mapTranscriptTypeToKind(legacyType),
|
|
579
|
+
source: mapTranscriptTypeToSource(legacyType),
|
|
580
|
+
payload: entry.event,
|
|
258
581
|
});
|
|
259
582
|
}
|
|
260
583
|
}
|
|
@@ -264,10 +587,13 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
264
587
|
if (flags.plan && submittedPlanFromSession !== undefined) {
|
|
265
588
|
try {
|
|
266
589
|
await transcriptStore.append(sessionId, {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
590
|
+
eventId: randomUUID(),
|
|
591
|
+
kilnSessionId: sessionId,
|
|
592
|
+
sequence: transcript.length + 1,
|
|
593
|
+
timestamp: new Date().toISOString(),
|
|
594
|
+
kind: "tool_call_started",
|
|
595
|
+
source: { actor: "tool", surface: "cli", component: "run-command" },
|
|
596
|
+
payload: {
|
|
271
597
|
type: "tool_use",
|
|
272
598
|
name: "submit_plan",
|
|
273
599
|
input: { plan: submittedPlanFromSession },
|
|
@@ -286,6 +612,14 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
286
612
|
const meta = {
|
|
287
613
|
kilnSessionId: sessionId,
|
|
288
614
|
provider: successfulProviderId ?? "unknown",
|
|
615
|
+
title: initialMetadata.title,
|
|
616
|
+
summary: initialMetadata.summary,
|
|
617
|
+
tags: deriveSessionMetadata({
|
|
618
|
+
task,
|
|
619
|
+
provider: successfulProviderId ?? preferredProvider,
|
|
620
|
+
model: successfulModelId ?? effectiveModel,
|
|
621
|
+
hasFileChanges: exactArtifacts.some((artifact) => /\b(created|modified|deleted|file)\b/i.test(artifact)),
|
|
622
|
+
}).tags,
|
|
289
623
|
task,
|
|
290
624
|
startedAt,
|
|
291
625
|
completedAt,
|
|
@@ -307,52 +641,19 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
307
641
|
};
|
|
308
642
|
try {
|
|
309
643
|
await transcriptStore.finalize(sessionId, meta);
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
createdAt: now,
|
|
324
|
-
updatedAt: now,
|
|
325
|
-
};
|
|
326
|
-
contextArtifactCache.set(artifact);
|
|
327
|
-
const projectArtifact = {
|
|
328
|
-
key: buildCliProjectSummaryArtifactKey(cwd),
|
|
329
|
-
kind: "project-summary",
|
|
330
|
-
content: [
|
|
331
|
-
`Project path: ${cwd}`,
|
|
332
|
-
`Domain: ${context.domain.displayName}`,
|
|
333
|
-
`Last successful provider: ${successfulProviderId ?? "unknown"}`,
|
|
334
|
-
`Latest task: ${task}`,
|
|
335
|
-
`Latest turn depth: ${turnDepth}`,
|
|
336
|
-
].join("\n"),
|
|
337
|
-
createdAt: now,
|
|
338
|
-
updatedAt: now,
|
|
339
|
-
};
|
|
340
|
-
contextArtifactCache.set(projectArtifact);
|
|
341
|
-
const planArtifact = {
|
|
342
|
-
key: buildCliPlanSummaryArtifactKey(cwd, task, 80),
|
|
343
|
-
kind: "plan-summary",
|
|
344
|
-
content: [
|
|
345
|
-
`Task pattern: ${task}`,
|
|
346
|
-
`Successful provider: ${successfulProviderId ?? "unknown"}`,
|
|
347
|
-
`Observed turn depth: ${turnDepth}`,
|
|
348
|
-
`Observed tool calls: ${toolCallCount}`,
|
|
349
|
-
"Useful exact artifacts:",
|
|
350
|
-
...exactArtifacts.slice(0, 8).map((artifact) => `- ${artifact}`),
|
|
351
|
-
].join("\n"),
|
|
352
|
-
createdAt: now,
|
|
353
|
-
updatedAt: now,
|
|
354
|
-
};
|
|
355
|
-
contextArtifactCache.set(planArtifact);
|
|
644
|
+
const artifacts = buildCliCompletionContextArtifacts({
|
|
645
|
+
sessionId,
|
|
646
|
+
projectPath: cwd,
|
|
647
|
+
domainDisplayName: context.domain.displayName,
|
|
648
|
+
task,
|
|
649
|
+
successfulProviderId,
|
|
650
|
+
toolCallCount,
|
|
651
|
+
turnDepth,
|
|
652
|
+
exactArtifacts,
|
|
653
|
+
});
|
|
654
|
+
contextArtifactCache.set(artifacts.sessionArtifact);
|
|
655
|
+
contextArtifactCache.set(artifacts.projectArtifact);
|
|
656
|
+
contextArtifactCache.set(artifacts.planArtifact);
|
|
356
657
|
const touchedFiles = extractTouchedFilePaths(exactArtifacts);
|
|
357
658
|
for (const filePath of touchedFiles.slice(0, 5)) {
|
|
358
659
|
const moduleArtifact = await buildModuleSummaryArtifact(cwd, filePath);
|
|
@@ -392,6 +693,9 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
392
693
|
if (!sessionSucceeded) {
|
|
393
694
|
await transcriptStore.finalize(sessionId, {
|
|
394
695
|
completedAt: new Date().toISOString(),
|
|
696
|
+
title: initialMetadata.title,
|
|
697
|
+
summary: initialMetadata.summary,
|
|
698
|
+
tags: initialMetadata.tags,
|
|
395
699
|
costUsd: finalCostUsd,
|
|
396
700
|
toolCount: toolCallCount,
|
|
397
701
|
turnDepth,
|
|
@@ -483,6 +787,37 @@ export async function runCommand(appConfig, task, flags) {
|
|
|
483
787
|
return;
|
|
484
788
|
}
|
|
485
789
|
}
|
|
790
|
+
function mapTranscriptTypeToKind(type) {
|
|
791
|
+
switch (type) {
|
|
792
|
+
case "user":
|
|
793
|
+
return "user_message";
|
|
794
|
+
case "text_delta":
|
|
795
|
+
return "assistant_delta";
|
|
796
|
+
case "tool_use":
|
|
797
|
+
return "tool_call_started";
|
|
798
|
+
case "tool_result":
|
|
799
|
+
return "tool_call_completed";
|
|
800
|
+
case "error":
|
|
801
|
+
return "error_recorded";
|
|
802
|
+
default:
|
|
803
|
+
return "assistant_message";
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function mapTranscriptTypeToSource(type) {
|
|
807
|
+
switch (type) {
|
|
808
|
+
case "user":
|
|
809
|
+
return { actor: "user", surface: "cli", component: "run-command" };
|
|
810
|
+
case "text_delta":
|
|
811
|
+
return { actor: "assistant", surface: "cli", component: "run-command" };
|
|
812
|
+
case "tool_use":
|
|
813
|
+
case "tool_result":
|
|
814
|
+
return { actor: "tool", surface: "cli", component: "run-command" };
|
|
815
|
+
case "error":
|
|
816
|
+
return { actor: "runtime", surface: "cli", component: "run-command" };
|
|
817
|
+
default:
|
|
818
|
+
return { actor: "system", surface: "cli", component: "run-command" };
|
|
819
|
+
}
|
|
820
|
+
}
|
|
486
821
|
export async function runParallelWorkers(appConfig, task, flags, workerCount, runner = runCommand) {
|
|
487
822
|
const results = await Promise.allSettled(Array.from({ length: workerCount }, async (_, i) => {
|
|
488
823
|
await runner(appConfig, task, { ...flags, workers: 1, isolate: true });
|