@kilnai/cli 1.0.4 → 2.0.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 +31 -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 +392 -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 +6 -5
- 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
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
import { finishGoalExecutionAttempt, GoalRunStore, selectNextGoalExecutionStep, startGoalExecutionAttempt, WorkItemStore, workItemToolMetadata, } from "@kilnai/core";
|
|
2
|
+
import { assessWorkGovernance } from "./work-governance-policy.js";
|
|
3
|
+
import { chooseWorkflowProfile, evidenceMatrixForWorkflowProfile, findWorkflowProfile, requiredEvidenceForWorkflowProfile, verificationGatesForWorkflowProfile, WORK_GOVERNANCE_WORKFLOW_PROFILES, } from "./work-governance-workflows.js";
|
|
4
|
+
const TRIGGERS = [
|
|
5
|
+
"architecture",
|
|
6
|
+
"security",
|
|
7
|
+
"ui",
|
|
8
|
+
"runtime",
|
|
9
|
+
"provider-routing",
|
|
10
|
+
"managed-agents",
|
|
11
|
+
"config",
|
|
12
|
+
"multi-file",
|
|
13
|
+
"cross-surface",
|
|
14
|
+
"long-running",
|
|
15
|
+
"verification-heavy",
|
|
16
|
+
"formal-proof-candidate",
|
|
17
|
+
];
|
|
18
|
+
const RISKS = ["low", "medium", "high"];
|
|
19
|
+
const EVIDENCE = [
|
|
20
|
+
"surface-map",
|
|
21
|
+
"risk-hypothesis",
|
|
22
|
+
"spec",
|
|
23
|
+
"plan",
|
|
24
|
+
"tests",
|
|
25
|
+
"typecheck",
|
|
26
|
+
"browser-qa",
|
|
27
|
+
"managed-agent-review",
|
|
28
|
+
"formal-proof",
|
|
29
|
+
"residual-risk",
|
|
30
|
+
];
|
|
31
|
+
const WORK_ITEM_STATUSES = ["pending", "in_progress", "blocked", "completed", "cancelled"];
|
|
32
|
+
const WORK_ITEM_PAUSE_REQUIREMENT_KINDS = [
|
|
33
|
+
"operator_input",
|
|
34
|
+
"credentials",
|
|
35
|
+
"approval",
|
|
36
|
+
"authority_elevation",
|
|
37
|
+
];
|
|
38
|
+
const WORK_ITEM_PAUSE_REQUIREMENT_STATUSES = ["pending", "resolved"];
|
|
39
|
+
const MANAGED_INVOCATION_PROFILES = [
|
|
40
|
+
"foundation-readonly-plan",
|
|
41
|
+
"foundation-propose-writes",
|
|
42
|
+
"foundation-apply-approved-writes",
|
|
43
|
+
"foundation-memory-write-proposals",
|
|
44
|
+
];
|
|
45
|
+
const MANAGED_INVOCATION_AUTHORITIES = ["auto", "read_only", "audited", "destructive"];
|
|
46
|
+
export function createWorkGovernanceTools(config, options = {}) {
|
|
47
|
+
const store = options.workItemStore ?? new WorkItemStore();
|
|
48
|
+
const goalRunStore = options.goalRunStore ?? new GoalRunStore();
|
|
49
|
+
return [
|
|
50
|
+
new WorkGovernanceAssessTool(config),
|
|
51
|
+
new WorkProfileListTool(),
|
|
52
|
+
new WorkItemUpdateTool(config, store),
|
|
53
|
+
new WorkItemListTool(store),
|
|
54
|
+
new WorkItemCompleteTool(store),
|
|
55
|
+
new WorkItemExecutionStartTool(goalRunStore, store),
|
|
56
|
+
new WorkItemExecutionFinishTool(goalRunStore, store),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
export class WorkGovernanceAssessTool {
|
|
60
|
+
config;
|
|
61
|
+
name = "work_governance.assess";
|
|
62
|
+
description = [
|
|
63
|
+
"Assess whether a task should be handled directly or orchestrated through managed agents.",
|
|
64
|
+
"Use before broad, risky, cross-surface, provider, runtime, UI, config, or verification-heavy work.",
|
|
65
|
+
].join(" ");
|
|
66
|
+
annotations = {
|
|
67
|
+
readOnly: true,
|
|
68
|
+
idempotent: true,
|
|
69
|
+
};
|
|
70
|
+
inputSchema = {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
summary: {
|
|
74
|
+
type: "string",
|
|
75
|
+
minLength: 1,
|
|
76
|
+
description: "Short description of the intended work.",
|
|
77
|
+
},
|
|
78
|
+
estimatedFiles: {
|
|
79
|
+
type: "number",
|
|
80
|
+
minimum: 0,
|
|
81
|
+
description: "Optional estimated number of files the work may touch.",
|
|
82
|
+
},
|
|
83
|
+
risk: {
|
|
84
|
+
enum: RISKS,
|
|
85
|
+
description: "Optional preliminary risk estimate.",
|
|
86
|
+
},
|
|
87
|
+
triggers: {
|
|
88
|
+
type: "array",
|
|
89
|
+
items: { enum: TRIGGERS },
|
|
90
|
+
description: "Known work-governance triggers that apply to this task.",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ["summary"],
|
|
94
|
+
additionalProperties: false,
|
|
95
|
+
};
|
|
96
|
+
outputSchema = {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
recommendation: { enum: ["direct", "orchestrate"] },
|
|
100
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
101
|
+
triggers: { type: "array", items: { enum: TRIGGERS } },
|
|
102
|
+
requiredEvidence: { type: "array", items: { type: "string" } },
|
|
103
|
+
},
|
|
104
|
+
required: ["recommendation", "reasons", "triggers", "requiredEvidence"],
|
|
105
|
+
additionalProperties: false,
|
|
106
|
+
};
|
|
107
|
+
constructor(config) {
|
|
108
|
+
this.config = config;
|
|
109
|
+
}
|
|
110
|
+
async execute(input) {
|
|
111
|
+
const summary = input.input.summary;
|
|
112
|
+
if (typeof summary !== "string" || summary.trim().length === 0) {
|
|
113
|
+
return { output: 'Invalid input: "summary" must be a non-empty string', isError: true };
|
|
114
|
+
}
|
|
115
|
+
const estimatedFiles = typeof input.input.estimatedFiles === "number" && Number.isFinite(input.input.estimatedFiles)
|
|
116
|
+
? input.input.estimatedFiles
|
|
117
|
+
: undefined;
|
|
118
|
+
const risk = isRisk(input.input.risk) ? input.input.risk : undefined;
|
|
119
|
+
const triggers = Array.isArray(input.input.triggers)
|
|
120
|
+
? input.input.triggers.filter(isTrigger)
|
|
121
|
+
: [];
|
|
122
|
+
const assessment = assessWorkGovernance(this.config, {
|
|
123
|
+
summary,
|
|
124
|
+
estimatedFiles,
|
|
125
|
+
risk,
|
|
126
|
+
triggers,
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
output: [
|
|
130
|
+
`recommendation: ${assessment.recommendation}`,
|
|
131
|
+
`reasons: ${assessment.reasons.join("; ")}`,
|
|
132
|
+
assessment.triggers.length > 0 ? `triggers: ${assessment.triggers.join(", ")}` : "triggers: none",
|
|
133
|
+
assessment.requiredEvidence.length > 0
|
|
134
|
+
? `requiredEvidence: ${assessment.requiredEvidence.join(", ")}`
|
|
135
|
+
: "requiredEvidence: none",
|
|
136
|
+
].join("\n"),
|
|
137
|
+
isError: false,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export class WorkProfileListTool {
|
|
142
|
+
name = "work_profile.list";
|
|
143
|
+
description = [
|
|
144
|
+
"List canonical Kiln workflow profiles for selecting the right execution posture, agents, authority, and evidence gates.",
|
|
145
|
+
"Use before creating governed work items or delegating broad work.",
|
|
146
|
+
].join(" ");
|
|
147
|
+
annotations = {
|
|
148
|
+
readOnly: true,
|
|
149
|
+
idempotent: true,
|
|
150
|
+
};
|
|
151
|
+
inputSchema = {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
trigger: {
|
|
155
|
+
enum: TRIGGERS,
|
|
156
|
+
description: "Optional trigger filter.",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
additionalProperties: false,
|
|
160
|
+
};
|
|
161
|
+
async execute(input) {
|
|
162
|
+
const trigger = isTrigger(input.input.trigger) ? input.input.trigger : undefined;
|
|
163
|
+
const profiles = trigger
|
|
164
|
+
? WORK_GOVERNANCE_WORKFLOW_PROFILES.filter((profile) => profile.triggers.includes(trigger))
|
|
165
|
+
: WORK_GOVERNANCE_WORKFLOW_PROFILES;
|
|
166
|
+
return {
|
|
167
|
+
output: JSON.stringify({
|
|
168
|
+
profiles: profiles.map((profile) => ({
|
|
169
|
+
id: profile.id,
|
|
170
|
+
description: profile.description,
|
|
171
|
+
triggers: profile.triggers,
|
|
172
|
+
minimumRisk: profile.minimumRisk,
|
|
173
|
+
recommendedAgentProfiles: profile.recommendedAgentProfiles,
|
|
174
|
+
defaultAuthorityProfile: profile.defaultAuthorityProfile,
|
|
175
|
+
requiredEvidence: profile.requiredEvidence,
|
|
176
|
+
verificationGates: profile.verificationGates,
|
|
177
|
+
evidenceMatrix: evidenceMatrixForWorkflowProfile(profile),
|
|
178
|
+
})),
|
|
179
|
+
}, null, 2),
|
|
180
|
+
isError: false,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export class WorkItemUpdateTool {
|
|
185
|
+
config;
|
|
186
|
+
store;
|
|
187
|
+
name = "work_item.update";
|
|
188
|
+
description = [
|
|
189
|
+
"Create or update a governed work item with workflow profile, expected evidence, route/agent hints, and verification gates.",
|
|
190
|
+
"Use this when decomposing non-trivial work before managed child invocation or direct execution.",
|
|
191
|
+
].join(" ");
|
|
192
|
+
annotations = {
|
|
193
|
+
readOnly: false,
|
|
194
|
+
idempotent: false,
|
|
195
|
+
};
|
|
196
|
+
inputSchema = {
|
|
197
|
+
type: "object",
|
|
198
|
+
properties: {
|
|
199
|
+
id: { type: "string", description: "Optional stable work item id. Omit to create a new id." },
|
|
200
|
+
summary: { type: "string", minLength: 1, description: "Bounded work item summary." },
|
|
201
|
+
status: { enum: WORK_ITEM_STATUSES, description: "Optional lifecycle status." },
|
|
202
|
+
workflowProfile: {
|
|
203
|
+
enum: WORK_GOVERNANCE_WORKFLOW_PROFILES.map((profile) => profile.id),
|
|
204
|
+
description: "Optional workflow profile. When omitted, Kiln infers one from triggers and risk.",
|
|
205
|
+
},
|
|
206
|
+
risk: { enum: RISKS, description: "Optional risk estimate." },
|
|
207
|
+
triggers: {
|
|
208
|
+
type: "array",
|
|
209
|
+
items: { enum: TRIGGERS },
|
|
210
|
+
description: "Governance triggers that apply to this work item.",
|
|
211
|
+
},
|
|
212
|
+
surface: { type: "string", description: "Optional affected surface, such as gui, cli, tui, runtime, or docs." },
|
|
213
|
+
assignedAgentProfile: { type: "string", description: "Optional configured Kiln agent profile assigned to the work item." },
|
|
214
|
+
routeId: { type: "string", description: "Optional managed invocation route id." },
|
|
215
|
+
authorityProfile: { type: "string", description: "Optional authority profile for the assigned work." },
|
|
216
|
+
expectedEvidence: {
|
|
217
|
+
type: "array",
|
|
218
|
+
items: { enum: EVIDENCE },
|
|
219
|
+
description: "Optional extra or overriding evidence expected before closeout.",
|
|
220
|
+
},
|
|
221
|
+
providedEvidence: {
|
|
222
|
+
type: "array",
|
|
223
|
+
items: { enum: EVIDENCE },
|
|
224
|
+
description: "Optional evidence already produced.",
|
|
225
|
+
},
|
|
226
|
+
verificationGates: {
|
|
227
|
+
type: "array",
|
|
228
|
+
items: { type: "string" },
|
|
229
|
+
description: "Optional extra verification gates.",
|
|
230
|
+
},
|
|
231
|
+
dependencies: {
|
|
232
|
+
type: "array",
|
|
233
|
+
items: { type: "string" },
|
|
234
|
+
description: "Optional work item ids that must complete first.",
|
|
235
|
+
},
|
|
236
|
+
residualRisk: { type: "string", description: "Known residual risk, if already available." },
|
|
237
|
+
pauseRequirements: {
|
|
238
|
+
type: "array",
|
|
239
|
+
items: {
|
|
240
|
+
type: "object",
|
|
241
|
+
properties: {
|
|
242
|
+
id: { type: "string", minLength: 1 },
|
|
243
|
+
kind: { enum: WORK_ITEM_PAUSE_REQUIREMENT_KINDS },
|
|
244
|
+
summary: { type: "string", minLength: 1 },
|
|
245
|
+
status: { enum: WORK_ITEM_PAUSE_REQUIREMENT_STATUSES },
|
|
246
|
+
resolvedBy: { type: "string" },
|
|
247
|
+
resolvedAt: { type: "string" },
|
|
248
|
+
resolution: { type: "string" },
|
|
249
|
+
},
|
|
250
|
+
required: ["id", "kind", "summary", "status"],
|
|
251
|
+
additionalProperties: false,
|
|
252
|
+
},
|
|
253
|
+
description: "Optional unresolved or resolved requirements that must be cleared before execution can start.",
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
required: ["summary"],
|
|
257
|
+
additionalProperties: false,
|
|
258
|
+
};
|
|
259
|
+
constructor(config, store) {
|
|
260
|
+
this.config = config;
|
|
261
|
+
this.store = store;
|
|
262
|
+
}
|
|
263
|
+
async execute(input) {
|
|
264
|
+
const summary = readText(input.input.summary);
|
|
265
|
+
if (!summary) {
|
|
266
|
+
return { output: 'Invalid input: "summary" must be a non-empty string', isError: true };
|
|
267
|
+
}
|
|
268
|
+
const triggers = readTriggers(input.input.triggers);
|
|
269
|
+
const risk = isRisk(input.input.risk) ? input.input.risk : undefined;
|
|
270
|
+
const explicitProfile = readText(input.input.workflowProfile);
|
|
271
|
+
const workflowProfile = explicitProfile ? findWorkflowProfile(explicitProfile) : chooseWorkflowProfile(triggers, risk);
|
|
272
|
+
if (!workflowProfile) {
|
|
273
|
+
return { output: `Invalid input: unknown workflowProfile "${explicitProfile}"`, isError: true };
|
|
274
|
+
}
|
|
275
|
+
const assessment = assessWorkGovernance(this.config, {
|
|
276
|
+
summary,
|
|
277
|
+
risk,
|
|
278
|
+
triggers,
|
|
279
|
+
});
|
|
280
|
+
const expectedEvidence = uniqueEvidence([
|
|
281
|
+
...requiredEvidenceForWorkflowProfile(workflowProfile),
|
|
282
|
+
...assessment.requiredEvidence,
|
|
283
|
+
...readEvidence(input.input.expectedEvidence),
|
|
284
|
+
]);
|
|
285
|
+
const verificationGates = uniqueText([
|
|
286
|
+
...verificationGatesForWorkflowProfile(workflowProfile),
|
|
287
|
+
...readTextArray(input.input.verificationGates),
|
|
288
|
+
]);
|
|
289
|
+
const pauseRequirements = readPauseRequirements(input.input.pauseRequirements);
|
|
290
|
+
if (!pauseRequirements.ok) {
|
|
291
|
+
return { output: `Invalid input: ${pauseRequirements.message}`, isError: true };
|
|
292
|
+
}
|
|
293
|
+
const item = this.store.upsert({
|
|
294
|
+
id: readText(input.input.id),
|
|
295
|
+
summary,
|
|
296
|
+
status: readStatus(input.input.status),
|
|
297
|
+
workflowProfile: workflowProfile.id,
|
|
298
|
+
risk,
|
|
299
|
+
triggers,
|
|
300
|
+
surface: readText(input.input.surface),
|
|
301
|
+
assignedAgentProfile: readText(input.input.assignedAgentProfile),
|
|
302
|
+
routeId: readText(input.input.routeId),
|
|
303
|
+
authorityProfile: readText(input.input.authorityProfile) ?? workflowProfile.defaultAuthorityProfile,
|
|
304
|
+
expectedEvidence,
|
|
305
|
+
providedEvidence: readEvidence(input.input.providedEvidence),
|
|
306
|
+
verificationGates,
|
|
307
|
+
dependencies: readTextArray(input.input.dependencies),
|
|
308
|
+
residualRisk: readText(input.input.residualRisk),
|
|
309
|
+
pauseRequirements: pauseRequirements.requirements,
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
output: JSON.stringify({ item }, null, 2),
|
|
313
|
+
metadata: workItemToolMetadata("work_item.update", {
|
|
314
|
+
operation: "update",
|
|
315
|
+
id: item.id,
|
|
316
|
+
status: item.status,
|
|
317
|
+
item,
|
|
318
|
+
sequence: item.sequence,
|
|
319
|
+
}),
|
|
320
|
+
isError: false,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export class WorkItemListTool {
|
|
325
|
+
store;
|
|
326
|
+
name = "work_item.list";
|
|
327
|
+
description = "List session governed work items and their evidence status.";
|
|
328
|
+
annotations = {
|
|
329
|
+
readOnly: true,
|
|
330
|
+
idempotent: true,
|
|
331
|
+
};
|
|
332
|
+
inputSchema = {
|
|
333
|
+
type: "object",
|
|
334
|
+
properties: {
|
|
335
|
+
status: { enum: WORK_ITEM_STATUSES, description: "Optional status filter." },
|
|
336
|
+
},
|
|
337
|
+
additionalProperties: false,
|
|
338
|
+
};
|
|
339
|
+
constructor(store) {
|
|
340
|
+
this.store = store;
|
|
341
|
+
}
|
|
342
|
+
async execute(input) {
|
|
343
|
+
const status = readStatus(input.input.status);
|
|
344
|
+
const items = this.store.list(status);
|
|
345
|
+
const snapshot = this.store.snapshot(status);
|
|
346
|
+
return {
|
|
347
|
+
output: JSON.stringify({ items }, null, 2),
|
|
348
|
+
metadata: workItemToolMetadata("work_item.list", {
|
|
349
|
+
operation: "list",
|
|
350
|
+
...(status ? { status } : {}),
|
|
351
|
+
items,
|
|
352
|
+
itemCount: items.length,
|
|
353
|
+
sequence: snapshot.sequence,
|
|
354
|
+
}),
|
|
355
|
+
isError: false,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
export class WorkItemCompleteTool {
|
|
360
|
+
store;
|
|
361
|
+
name = "work_item.complete";
|
|
362
|
+
description = [
|
|
363
|
+
"Attempt to close a governed work item.",
|
|
364
|
+
"The tool fails closed when expected evidence or required residual risk is missing.",
|
|
365
|
+
].join(" ");
|
|
366
|
+
annotations = {
|
|
367
|
+
readOnly: false,
|
|
368
|
+
idempotent: false,
|
|
369
|
+
};
|
|
370
|
+
inputSchema = {
|
|
371
|
+
type: "object",
|
|
372
|
+
properties: {
|
|
373
|
+
id: { type: "string", minLength: 1, description: "Work item id." },
|
|
374
|
+
providedEvidence: {
|
|
375
|
+
type: "array",
|
|
376
|
+
items: { enum: EVIDENCE },
|
|
377
|
+
description: "Evidence produced for this work item.",
|
|
378
|
+
},
|
|
379
|
+
residualRisk: { type: "string", description: "Residual-risk closeout. Required when residual-risk is expected evidence." },
|
|
380
|
+
skippedVerificationGates: {
|
|
381
|
+
type: "array",
|
|
382
|
+
items: { type: "string" },
|
|
383
|
+
description: "Verification gates intentionally skipped during closeout. Requires residual-risk closeout.",
|
|
384
|
+
},
|
|
385
|
+
verificationGateResults: verificationGateResultsSchema(),
|
|
386
|
+
},
|
|
387
|
+
required: ["id"],
|
|
388
|
+
additionalProperties: false,
|
|
389
|
+
};
|
|
390
|
+
constructor(store) {
|
|
391
|
+
this.store = store;
|
|
392
|
+
}
|
|
393
|
+
async execute(input) {
|
|
394
|
+
const id = readText(input.input.id);
|
|
395
|
+
if (!id) {
|
|
396
|
+
return { output: 'Invalid input: "id" must be a non-empty string', isError: true };
|
|
397
|
+
}
|
|
398
|
+
const completion = this.store.complete({
|
|
399
|
+
id,
|
|
400
|
+
providedEvidence: readEvidence(input.input.providedEvidence),
|
|
401
|
+
skippedVerificationGates: readTextArray(input.input.skippedVerificationGates),
|
|
402
|
+
verificationGateResults: readVerificationGateResults(input.input.verificationGateResults),
|
|
403
|
+
residualRisk: readText(input.input.residualRisk),
|
|
404
|
+
});
|
|
405
|
+
if (!completion) {
|
|
406
|
+
return { output: `Work item not found: ${id}`, isError: true };
|
|
407
|
+
}
|
|
408
|
+
const missing = [
|
|
409
|
+
...completion.missingEvidence,
|
|
410
|
+
...completion.missingVerificationGates.map((gate) => `missing gate: ${gate}`),
|
|
411
|
+
...completion.failedVerificationGates.map((gate) => `failed gate: ${gate}`),
|
|
412
|
+
...(completion.missingResidualRisk ? ["residual-risk closeout"] : []),
|
|
413
|
+
];
|
|
414
|
+
if (missing.length > 0) {
|
|
415
|
+
return {
|
|
416
|
+
output: JSON.stringify({
|
|
417
|
+
status: "blocked",
|
|
418
|
+
missing,
|
|
419
|
+
item: completion.item,
|
|
420
|
+
}, null, 2),
|
|
421
|
+
metadata: workItemToolMetadata("work_item.complete", {
|
|
422
|
+
operation: "complete",
|
|
423
|
+
id: completion.item.id,
|
|
424
|
+
status: completion.item.status,
|
|
425
|
+
item: completion.item,
|
|
426
|
+
missingEvidence: completion.missingEvidence,
|
|
427
|
+
missingVerificationGates: completion.missingVerificationGates,
|
|
428
|
+
failedVerificationGates: completion.failedVerificationGates,
|
|
429
|
+
missingResidualRisk: completion.missingResidualRisk,
|
|
430
|
+
sequence: completion.item.sequence,
|
|
431
|
+
errorCode: "missing_evidence",
|
|
432
|
+
}),
|
|
433
|
+
isError: true,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
output: JSON.stringify({
|
|
438
|
+
status: "completed",
|
|
439
|
+
item: completion.item,
|
|
440
|
+
}, null, 2),
|
|
441
|
+
metadata: workItemToolMetadata("work_item.complete", {
|
|
442
|
+
operation: "complete",
|
|
443
|
+
id: completion.item.id,
|
|
444
|
+
status: completion.item.status,
|
|
445
|
+
item: completion.item,
|
|
446
|
+
missingEvidence: completion.missingEvidence,
|
|
447
|
+
missingVerificationGates: completion.missingVerificationGates,
|
|
448
|
+
failedVerificationGates: completion.failedVerificationGates,
|
|
449
|
+
missingResidualRisk: completion.missingResidualRisk,
|
|
450
|
+
sequence: completion.item.sequence,
|
|
451
|
+
}),
|
|
452
|
+
isError: false,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
export class WorkItemExecutionStartTool {
|
|
457
|
+
goalRunStore;
|
|
458
|
+
workItemStore;
|
|
459
|
+
name = "work_item.execution.start";
|
|
460
|
+
description = [
|
|
461
|
+
"Start the next ready work item execution attempt for a goal.",
|
|
462
|
+
"Selects the next ready pending item when workItemId is omitted and pauses instead of advancing when dependencies or state block execution.",
|
|
463
|
+
].join(" ");
|
|
464
|
+
annotations = {
|
|
465
|
+
readOnly: false,
|
|
466
|
+
idempotent: false,
|
|
467
|
+
};
|
|
468
|
+
inputSchema = {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
goalRunId: { type: "string", minLength: 1, description: "Goal run id." },
|
|
472
|
+
workItemId: { type: "string", description: "Optional explicit work item id. Omit to select the next ready item." },
|
|
473
|
+
summary: { type: "string", description: "Attempt summary." },
|
|
474
|
+
managedInvocationId: { type: "string", description: "Managed child invocation id when delegation has already been requested." },
|
|
475
|
+
managedProviderId: {
|
|
476
|
+
type: "string",
|
|
477
|
+
description: "Configured managed provider id to include in the suggested managed_agent.invoke request.",
|
|
478
|
+
},
|
|
479
|
+
managedModel: {
|
|
480
|
+
type: "string",
|
|
481
|
+
description: "Optional configured managed model to include in the suggested managed_agent.invoke request.",
|
|
482
|
+
},
|
|
483
|
+
managedReasoningEffort: {
|
|
484
|
+
type: "string",
|
|
485
|
+
description: "Optional reasoning effort to include in the suggested managed_agent.invoke request.",
|
|
486
|
+
},
|
|
487
|
+
managedProfile: {
|
|
488
|
+
enum: MANAGED_INVOCATION_PROFILES,
|
|
489
|
+
description: "Managed invocation authority profile to include in the suggested managed_agent.invoke request.",
|
|
490
|
+
},
|
|
491
|
+
requestedAuthority: {
|
|
492
|
+
enum: MANAGED_INVOCATION_AUTHORITIES,
|
|
493
|
+
description: "Requested child authority to include in the suggested managed_agent.invoke request.",
|
|
494
|
+
},
|
|
495
|
+
governanceRecommendation: {
|
|
496
|
+
enum: ["direct", "orchestrate"],
|
|
497
|
+
description: "Optional work_governance.assess recommendation used for ready-item selection.",
|
|
498
|
+
},
|
|
499
|
+
governanceReasons: {
|
|
500
|
+
type: "array",
|
|
501
|
+
items: { type: "string" },
|
|
502
|
+
description: "Optional work_governance.assess reasons.",
|
|
503
|
+
},
|
|
504
|
+
requiredEvidence: {
|
|
505
|
+
type: "array",
|
|
506
|
+
items: { type: "string" },
|
|
507
|
+
description: "Optional evidence required by governance assessment.",
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
required: ["goalRunId"],
|
|
511
|
+
additionalProperties: false,
|
|
512
|
+
};
|
|
513
|
+
constructor(goalRunStore, workItemStore) {
|
|
514
|
+
this.goalRunStore = goalRunStore;
|
|
515
|
+
this.workItemStore = workItemStore;
|
|
516
|
+
}
|
|
517
|
+
async execute(input) {
|
|
518
|
+
const goalRunId = readText(input.input.goalRunId);
|
|
519
|
+
if (!goalRunId) {
|
|
520
|
+
return { output: 'Invalid input: "goalRunId" must be a non-empty string', isError: true };
|
|
521
|
+
}
|
|
522
|
+
const goal = this.goalRunStore.get(goalRunId);
|
|
523
|
+
if (!goal) {
|
|
524
|
+
return { output: `Goal not found: ${goalRunId}`, isError: true };
|
|
525
|
+
}
|
|
526
|
+
const explicitWorkItemId = readText(input.input.workItemId);
|
|
527
|
+
const selected = explicitWorkItemId
|
|
528
|
+
? this.workItemStore.get(explicitWorkItemId)
|
|
529
|
+
: undefined;
|
|
530
|
+
const step = selectNextGoalExecutionStep({
|
|
531
|
+
goalRun: goal,
|
|
532
|
+
workItems: this.workItemStore.snapshot().items,
|
|
533
|
+
governanceAssessment: {
|
|
534
|
+
recommendation: input.input.governanceRecommendation === "orchestrate" ? "orchestrate" : "direct",
|
|
535
|
+
reasons: readTextArray(input.input.governanceReasons),
|
|
536
|
+
requiredEvidence: readTextArray(input.input.requiredEvidence),
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
if (step.status !== "ready") {
|
|
540
|
+
return {
|
|
541
|
+
output: JSON.stringify({ status: "paused", step }, null, 2),
|
|
542
|
+
isError: true,
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
if (explicitWorkItemId && !selected) {
|
|
546
|
+
return { output: `Work item not found: ${explicitWorkItemId}`, isError: true };
|
|
547
|
+
}
|
|
548
|
+
if (explicitWorkItemId && step.workItemId !== explicitWorkItemId) {
|
|
549
|
+
return {
|
|
550
|
+
output: JSON.stringify({
|
|
551
|
+
status: "paused",
|
|
552
|
+
reason: "Explicit work item is not the next ready item for this goal.",
|
|
553
|
+
readyWorkItemId: step.workItemId,
|
|
554
|
+
requestedWorkItemId: explicitWorkItemId,
|
|
555
|
+
}, null, 2),
|
|
556
|
+
isError: true,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const managedInvocationId = readText(input.input.managedInvocationId);
|
|
560
|
+
if (step.executionMode === "managed_delegation" && !managedInvocationId) {
|
|
561
|
+
const managedInvocation = buildManagedInvocationRequest(goal, step, input.input);
|
|
562
|
+
return {
|
|
563
|
+
output: JSON.stringify({
|
|
564
|
+
status: "paused",
|
|
565
|
+
reason: "managedInvocationId is required before starting managed-delegation execution.",
|
|
566
|
+
workItemId: step.workItemId,
|
|
567
|
+
routeId: managedInvocation.routeId,
|
|
568
|
+
agentProfile: managedInvocation.agentProfile,
|
|
569
|
+
requiredEvidence: step.requiredEvidence,
|
|
570
|
+
nextTool: "managed_agent.invoke",
|
|
571
|
+
managedInvocationRequest: managedInvocation.request,
|
|
572
|
+
...(managedInvocation.missingFields.length > 0
|
|
573
|
+
? { missingManagedInvocationFields: managedInvocation.missingFields }
|
|
574
|
+
: {}),
|
|
575
|
+
}, null, 2),
|
|
576
|
+
isError: true,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
try {
|
|
580
|
+
const started = startGoalExecutionAttempt({
|
|
581
|
+
goalRunStore: this.goalRunStore,
|
|
582
|
+
workItemStore: this.workItemStore,
|
|
583
|
+
goalRunId,
|
|
584
|
+
workItemId: step.workItemId,
|
|
585
|
+
executionMode: step.executionMode,
|
|
586
|
+
summary: readText(input.input.summary),
|
|
587
|
+
managedInvocationId,
|
|
588
|
+
});
|
|
589
|
+
return {
|
|
590
|
+
output: JSON.stringify({
|
|
591
|
+
status: "started",
|
|
592
|
+
goal: started.goal,
|
|
593
|
+
item: started.item,
|
|
594
|
+
attempt: started.attempt,
|
|
595
|
+
}, null, 2),
|
|
596
|
+
metadata: workItemToolMetadata("work_item.execution.start", {
|
|
597
|
+
operation: "execution_started",
|
|
598
|
+
id: started.item.id,
|
|
599
|
+
status: started.item.status,
|
|
600
|
+
item: started.item,
|
|
601
|
+
attempt: started.attempt,
|
|
602
|
+
sequence: started.item.sequence,
|
|
603
|
+
}),
|
|
604
|
+
isError: false,
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
return { output: error instanceof Error ? error.message : String(error), isError: true };
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
export class WorkItemExecutionFinishTool {
|
|
613
|
+
goalRunStore;
|
|
614
|
+
workItemStore;
|
|
615
|
+
name = "work_item.execution.finish";
|
|
616
|
+
description = [
|
|
617
|
+
"Finish a work item execution attempt with evidence and residual-risk closeout.",
|
|
618
|
+
"Blocks the item when expected evidence is missing and updates the owning goal state.",
|
|
619
|
+
].join(" ");
|
|
620
|
+
annotations = {
|
|
621
|
+
readOnly: false,
|
|
622
|
+
idempotent: false,
|
|
623
|
+
};
|
|
624
|
+
inputSchema = {
|
|
625
|
+
type: "object",
|
|
626
|
+
properties: {
|
|
627
|
+
goalRunId: { type: "string", minLength: 1, description: "Goal run id." },
|
|
628
|
+
workItemId: { type: "string", minLength: 1, description: "Work item id." },
|
|
629
|
+
attemptId: { type: "string", minLength: 1, description: "Execution attempt id." },
|
|
630
|
+
providedEvidence: {
|
|
631
|
+
type: "array",
|
|
632
|
+
items: { enum: EVIDENCE },
|
|
633
|
+
description: "Evidence produced by the attempt.",
|
|
634
|
+
},
|
|
635
|
+
residualRisk: { type: "string", description: "Residual-risk closeout." },
|
|
636
|
+
skippedVerificationGates: {
|
|
637
|
+
type: "array",
|
|
638
|
+
items: { type: "string" },
|
|
639
|
+
description: "Verification gates intentionally skipped by the attempt. Requires residual-risk closeout.",
|
|
640
|
+
},
|
|
641
|
+
verificationGateResults: verificationGateResultsSchema(),
|
|
642
|
+
summary: { type: "string", description: "Attempt result summary." },
|
|
643
|
+
closeoutSummary: { type: "string", description: "Goal closeout summary if this attempt completes the final work item." },
|
|
644
|
+
},
|
|
645
|
+
required: ["goalRunId", "workItemId", "attemptId"],
|
|
646
|
+
additionalProperties: false,
|
|
647
|
+
};
|
|
648
|
+
constructor(goalRunStore, workItemStore) {
|
|
649
|
+
this.goalRunStore = goalRunStore;
|
|
650
|
+
this.workItemStore = workItemStore;
|
|
651
|
+
}
|
|
652
|
+
async execute(input) {
|
|
653
|
+
const goalRunId = readText(input.input.goalRunId);
|
|
654
|
+
const workItemId = readText(input.input.workItemId);
|
|
655
|
+
const attemptId = readText(input.input.attemptId);
|
|
656
|
+
if (!goalRunId || !workItemId || !attemptId) {
|
|
657
|
+
return {
|
|
658
|
+
output: 'Invalid input: "goalRunId", "workItemId", and "attemptId" must be non-empty strings',
|
|
659
|
+
isError: true,
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
try {
|
|
663
|
+
const finished = finishGoalExecutionAttempt({
|
|
664
|
+
goalRunStore: this.goalRunStore,
|
|
665
|
+
workItemStore: this.workItemStore,
|
|
666
|
+
goalRunId,
|
|
667
|
+
workItemId,
|
|
668
|
+
attemptId,
|
|
669
|
+
providedEvidence: readEvidence(input.input.providedEvidence),
|
|
670
|
+
skippedVerificationGates: readTextArray(input.input.skippedVerificationGates),
|
|
671
|
+
verificationGateResults: readVerificationGateResults(input.input.verificationGateResults),
|
|
672
|
+
residualRisk: readText(input.input.residualRisk),
|
|
673
|
+
summary: readText(input.input.summary),
|
|
674
|
+
closeoutSummary: readText(input.input.closeoutSummary),
|
|
675
|
+
});
|
|
676
|
+
const missing = [
|
|
677
|
+
...finished.missingEvidence,
|
|
678
|
+
...finished.missingGoalEvidence,
|
|
679
|
+
...finished.missingVerificationGates.map((gate) => `missing gate: ${gate}`),
|
|
680
|
+
...finished.failedVerificationGates.map((gate) => `failed gate: ${gate}`),
|
|
681
|
+
...(finished.missingResidualRisk ? ["residual-risk closeout"] : []),
|
|
682
|
+
];
|
|
683
|
+
return {
|
|
684
|
+
output: JSON.stringify({
|
|
685
|
+
status: missing.length > 0 ? "blocked" : "completed",
|
|
686
|
+
missing,
|
|
687
|
+
goal: finished.goal,
|
|
688
|
+
item: finished.item,
|
|
689
|
+
attempt: finished.attempt,
|
|
690
|
+
}, null, 2),
|
|
691
|
+
metadata: workItemToolMetadata("work_item.execution.finish", {
|
|
692
|
+
operation: "execution_finished",
|
|
693
|
+
id: finished.item.id,
|
|
694
|
+
status: finished.item.status,
|
|
695
|
+
item: finished.item,
|
|
696
|
+
attempt: finished.attempt,
|
|
697
|
+
missingEvidence: finished.missingEvidence,
|
|
698
|
+
missingGoalEvidence: finished.missingGoalEvidence,
|
|
699
|
+
missingVerificationGates: finished.missingVerificationGates,
|
|
700
|
+
failedVerificationGates: finished.failedVerificationGates,
|
|
701
|
+
missingResidualRisk: finished.missingResidualRisk,
|
|
702
|
+
sequence: finished.item.sequence,
|
|
703
|
+
...(missing.length > 0 ? { errorCode: "missing_evidence" } : {}),
|
|
704
|
+
}),
|
|
705
|
+
isError: missing.length > 0,
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
catch (error) {
|
|
709
|
+
return { output: error instanceof Error ? error.message : String(error), isError: true };
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function buildManagedInvocationRequest(goal, step, input) {
|
|
714
|
+
const routeId = step.workItem.routeId ?? step.workItem.routingRecommendation?.routeId ?? goal.routePolicy.preferredRouteId;
|
|
715
|
+
const agentProfile = step.workItem.assignedAgentProfile
|
|
716
|
+
?? step.workItem.routingRecommendation?.agentProfile
|
|
717
|
+
?? goal.routePolicy.managedAgentProfile;
|
|
718
|
+
const providerId = readText(input.managedProviderId);
|
|
719
|
+
const model = readText(input.managedModel);
|
|
720
|
+
const reasoningEffort = readText(input.managedReasoningEffort)
|
|
721
|
+
?? step.workItem.routingRecommendation?.reasoningEffort;
|
|
722
|
+
const expectedEvidence = step.requiredEvidence;
|
|
723
|
+
const residualRiskRequired = expectedEvidence.includes("residual-risk");
|
|
724
|
+
const request = {
|
|
725
|
+
profile: readManagedInvocationProfile(input.managedProfile)
|
|
726
|
+
?? readManagedInvocationProfile(step.workItem.authorityProfile)
|
|
727
|
+
?? "foundation-readonly-plan",
|
|
728
|
+
...(routeId ? { routeId } : {}),
|
|
729
|
+
...(providerId
|
|
730
|
+
? {
|
|
731
|
+
providerRoute: {
|
|
732
|
+
providerId,
|
|
733
|
+
...(model ? { model } : {}),
|
|
734
|
+
...(reasoningEffort ? { reasoningEffort } : {}),
|
|
735
|
+
},
|
|
736
|
+
}
|
|
737
|
+
: {}),
|
|
738
|
+
requestedAuthority: readManagedInvocationAuthority(input.requestedAuthority)
|
|
739
|
+
?? readManagedInvocationAuthority(step.workItem.authorityProfile)
|
|
740
|
+
?? goal.authorityEnvelope.maximumAuthority,
|
|
741
|
+
task: formatManagedInvocationTask(goal, step),
|
|
742
|
+
summary: step.workItem.summary,
|
|
743
|
+
workItemId: step.workItemId,
|
|
744
|
+
...(agentProfile ? { agentProfile } : {}),
|
|
745
|
+
roleIntent: `Execute governed work item ${step.workItemId} for goal ${goal.id}.`,
|
|
746
|
+
expectedEvidence,
|
|
747
|
+
requiredResultFields: managedInvocationResultFields(expectedEvidence),
|
|
748
|
+
doneCriteria: managedInvocationDoneCriteria(step),
|
|
749
|
+
residualRiskRequired,
|
|
750
|
+
};
|
|
751
|
+
return {
|
|
752
|
+
routeId,
|
|
753
|
+
agentProfile,
|
|
754
|
+
missingFields: providerId ? [] : ["providerRoute.providerId"],
|
|
755
|
+
request,
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function formatManagedInvocationTask(goal, step) {
|
|
759
|
+
const lines = [
|
|
760
|
+
step.workItem.summary,
|
|
761
|
+
`Goal: ${goal.objective}`,
|
|
762
|
+
`Work item id: ${step.workItemId}`,
|
|
763
|
+
];
|
|
764
|
+
if (step.requiredEvidence.length > 0) {
|
|
765
|
+
lines.push(`Produce evidence: ${step.requiredEvidence.join(", ")}.`);
|
|
766
|
+
}
|
|
767
|
+
if (step.workItem.verificationGates.length > 0) {
|
|
768
|
+
lines.push(`Verification gates: ${step.workItem.verificationGates.join("; ")}.`);
|
|
769
|
+
}
|
|
770
|
+
lines.push("Return a concise handoff with summary, evidence, checks, and residual risk when required.");
|
|
771
|
+
return lines.join("\n");
|
|
772
|
+
}
|
|
773
|
+
function managedInvocationResultFields(expectedEvidence) {
|
|
774
|
+
return uniqueText([
|
|
775
|
+
"summary",
|
|
776
|
+
"evidence",
|
|
777
|
+
"checks",
|
|
778
|
+
...(expectedEvidence.includes("residual-risk") ? ["residualRisk"] : []),
|
|
779
|
+
]);
|
|
780
|
+
}
|
|
781
|
+
function managedInvocationDoneCriteria(step) {
|
|
782
|
+
return uniqueText([
|
|
783
|
+
...step.workItem.verificationGates,
|
|
784
|
+
...(step.requiredEvidence.length > 0
|
|
785
|
+
? [`Produce required evidence: ${step.requiredEvidence.join(", ")}.`]
|
|
786
|
+
: []),
|
|
787
|
+
...(step.requiredEvidence.includes("residual-risk")
|
|
788
|
+
? ["Document residual risk before closeout."]
|
|
789
|
+
: []),
|
|
790
|
+
]);
|
|
791
|
+
}
|
|
792
|
+
function readManagedInvocationProfile(value) {
|
|
793
|
+
return MANAGED_INVOCATION_PROFILES.includes(value)
|
|
794
|
+
? value
|
|
795
|
+
: undefined;
|
|
796
|
+
}
|
|
797
|
+
function readManagedInvocationAuthority(value) {
|
|
798
|
+
return MANAGED_INVOCATION_AUTHORITIES.includes(value)
|
|
799
|
+
? value
|
|
800
|
+
: undefined;
|
|
801
|
+
}
|
|
802
|
+
function isRisk(value) {
|
|
803
|
+
return RISKS.includes(value);
|
|
804
|
+
}
|
|
805
|
+
function isTrigger(value) {
|
|
806
|
+
return TRIGGERS.includes(value);
|
|
807
|
+
}
|
|
808
|
+
function readStatus(value) {
|
|
809
|
+
return WORK_ITEM_STATUSES.includes(value) ? value : undefined;
|
|
810
|
+
}
|
|
811
|
+
function readPauseRequirements(value) {
|
|
812
|
+
if (value === undefined) {
|
|
813
|
+
return { ok: true };
|
|
814
|
+
}
|
|
815
|
+
if (!Array.isArray(value)) {
|
|
816
|
+
return { ok: false, message: '"pauseRequirements" must be an array' };
|
|
817
|
+
}
|
|
818
|
+
const requirements = [];
|
|
819
|
+
for (const candidate of value) {
|
|
820
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
821
|
+
return { ok: false, message: '"pauseRequirements" entries must be objects' };
|
|
822
|
+
}
|
|
823
|
+
const record = candidate;
|
|
824
|
+
const id = readText(record.id);
|
|
825
|
+
const summary = readText(record.summary);
|
|
826
|
+
const kind = readPauseRequirementKind(record.kind);
|
|
827
|
+
const status = readPauseRequirementStatus(record.status);
|
|
828
|
+
if (!id || !summary || !kind || !status) {
|
|
829
|
+
return {
|
|
830
|
+
ok: false,
|
|
831
|
+
message: '"pauseRequirements" entries require id, kind, summary, and status',
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
requirements.push({
|
|
835
|
+
id,
|
|
836
|
+
kind,
|
|
837
|
+
summary,
|
|
838
|
+
status,
|
|
839
|
+
...(readText(record.resolvedBy) ? { resolvedBy: readText(record.resolvedBy) } : {}),
|
|
840
|
+
...(readText(record.resolvedAt) ? { resolvedAt: readText(record.resolvedAt) } : {}),
|
|
841
|
+
...(readText(record.resolution) ? { resolution: readText(record.resolution) } : {}),
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
return { ok: true, requirements };
|
|
845
|
+
}
|
|
846
|
+
function readPauseRequirementKind(value) {
|
|
847
|
+
return WORK_ITEM_PAUSE_REQUIREMENT_KINDS.includes(value)
|
|
848
|
+
? value
|
|
849
|
+
: undefined;
|
|
850
|
+
}
|
|
851
|
+
function readPauseRequirementStatus(value) {
|
|
852
|
+
return WORK_ITEM_PAUSE_REQUIREMENT_STATUSES.includes(value)
|
|
853
|
+
? value
|
|
854
|
+
: undefined;
|
|
855
|
+
}
|
|
856
|
+
function verificationGateResultsSchema() {
|
|
857
|
+
return {
|
|
858
|
+
type: "array",
|
|
859
|
+
items: {
|
|
860
|
+
type: "object",
|
|
861
|
+
properties: {
|
|
862
|
+
gate: { type: "string", minLength: 1 },
|
|
863
|
+
status: { enum: ["passed", "failed", "skipped"] },
|
|
864
|
+
summary: { type: "string" },
|
|
865
|
+
evidence: {
|
|
866
|
+
type: "array",
|
|
867
|
+
items: { type: "string" },
|
|
868
|
+
},
|
|
869
|
+
completedAt: { type: "string" },
|
|
870
|
+
},
|
|
871
|
+
required: ["gate", "status"],
|
|
872
|
+
additionalProperties: false,
|
|
873
|
+
},
|
|
874
|
+
description: "Recorded verification gate results such as build, typecheck, test, review, or browser QA outcomes.",
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
function readVerificationGateResults(value) {
|
|
878
|
+
if (!Array.isArray(value)) {
|
|
879
|
+
return [];
|
|
880
|
+
}
|
|
881
|
+
const results = [];
|
|
882
|
+
const seen = new Set();
|
|
883
|
+
for (const entry of value) {
|
|
884
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
885
|
+
continue;
|
|
886
|
+
}
|
|
887
|
+
const record = entry;
|
|
888
|
+
const gate = readText(record.gate);
|
|
889
|
+
const status = readVerificationGateResultStatus(record.status);
|
|
890
|
+
if (!gate || !status || seen.has(gate)) {
|
|
891
|
+
continue;
|
|
892
|
+
}
|
|
893
|
+
seen.add(gate);
|
|
894
|
+
const summary = readText(record.summary);
|
|
895
|
+
const completedAt = readText(record.completedAt);
|
|
896
|
+
const evidence = readTextArray(record.evidence);
|
|
897
|
+
results.push({
|
|
898
|
+
gate,
|
|
899
|
+
status,
|
|
900
|
+
...(summary ? { summary } : {}),
|
|
901
|
+
...(evidence.length > 0 ? { evidence } : {}),
|
|
902
|
+
...(completedAt ? { completedAt } : {}),
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
return results;
|
|
906
|
+
}
|
|
907
|
+
function readVerificationGateResultStatus(value) {
|
|
908
|
+
return value === "passed" || value === "failed" || value === "skipped" ? value : undefined;
|
|
909
|
+
}
|
|
910
|
+
function readTriggers(value) {
|
|
911
|
+
return Array.isArray(value) ? uniqueText(value.filter(isTrigger)) : [];
|
|
912
|
+
}
|
|
913
|
+
function readEvidence(value) {
|
|
914
|
+
return Array.isArray(value) ? uniqueEvidence(value.filter(isEvidence)) : [];
|
|
915
|
+
}
|
|
916
|
+
function isEvidence(value) {
|
|
917
|
+
return EVIDENCE.includes(value);
|
|
918
|
+
}
|
|
919
|
+
function readTextArray(value) {
|
|
920
|
+
return Array.isArray(value)
|
|
921
|
+
? uniqueText(value.map(readText).filter((item) => item !== undefined))
|
|
922
|
+
: [];
|
|
923
|
+
}
|
|
924
|
+
function readText(value) {
|
|
925
|
+
if (typeof value !== "string") {
|
|
926
|
+
return undefined;
|
|
927
|
+
}
|
|
928
|
+
const trimmed = value.trim();
|
|
929
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
930
|
+
}
|
|
931
|
+
function uniqueEvidence(values) {
|
|
932
|
+
return [...new Set(values)];
|
|
933
|
+
}
|
|
934
|
+
function uniqueText(values) {
|
|
935
|
+
return [...new Set(values)];
|
|
936
|
+
}
|
|
937
|
+
//# sourceMappingURL=work-governance-tool.js.map
|