pi-harness-runtime 1.1.398 → 1.1.403
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/AGENTS.md +44 -2
- package/CHANGELOG.md +28 -0
- package/RULES.md +28 -0
- package/harness/agent-handoff.ts +2 -3
- package/harness/autonomous-review.ts +1 -1
- package/harness/blackboard.ts +2 -3
- package/harness/context-compact-orchestrator.ts +1 -1
- package/harness/context-window-manager.ts +2 -2
- package/harness/e2e/playwright-runner.ts +6 -4
- package/harness/herdr-agents.ts +1 -1
- package/harness/job-state-machine.ts +1 -1
- package/harness/langchain/daemon.ts +3 -3
- package/harness/langchain/graph.ts +2 -2
- package/harness/langchain/ping-pong-middleware.ts +2 -2
- package/harness/loop-code-agent.ts +6 -4
- package/harness/loop-controller.ts +1 -1
- package/harness/loop-review-agent.ts +1 -1
- package/harness/loop-types.ts +1 -1
- package/harness/master-planner.ts +1 -1
- package/harness/project-detector/detector.ts +1 -2
- package/harness/repair-engine.ts +2 -4
- package/harness/service-diagnostics.ts +1 -1
- package/harness/skill-sync.ts +3 -3
- package/index.ts +276 -55
- package/mirror.ts +1 -1
- package/package.json +5 -3
- package/packages/a2a-adapter/dist/discovery.d.ts.map +1 -1
- package/packages/a2a-adapter/dist/discovery.js +0 -1
- package/packages/a2a-adapter/dist/discovery.js.map +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/discovery.ts +0 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/dist/index.d.ts +9 -0
- package/packages/auth/dist/index.d.ts.map +1 -0
- package/packages/auth/dist/index.js +9 -0
- package/packages/auth/dist/index.js.map +1 -0
- package/packages/auth/package.json +1 -1
- package/packages/auth/src/index.ts +9 -0
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/dist/index.d.ts +52 -0
- package/packages/config-capture/dist/index.d.ts.map +1 -0
- package/packages/config-capture/dist/index.js +261 -0
- package/packages/config-capture/dist/index.js.map +1 -0
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/dist/extension.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.js +215 -0
- package/packages/file-copy-helper/dist/extension.debug.js.map +1 -0
- package/packages/file-copy-helper/dist/extension.js +222 -0
- package/packages/file-copy-helper/dist/extension.js.map +1 -0
- package/packages/file-copy-helper/dist/index.d.ts +3 -0
- package/packages/file-copy-helper/dist/index.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/index.js +3 -0
- package/packages/file-copy-helper/dist/index.js.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts +21 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.js +348 -0
- package/packages/file-copy-helper/dist/intent-detector.js.map +1 -0
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/auto-continue.d.ts +161 -2
- package/packages/jev-judge/dist/auto-continue.d.ts.map +1 -1
- package/packages/jev-judge/dist/auto-continue.js +267 -22
- package/packages/jev-judge/dist/auto-continue.js.map +1 -1
- package/packages/jev-judge/dist/index.d.ts +2 -0
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +2 -0
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/question-risk.d.ts +53 -0
- package/packages/jev-judge/dist/question-risk.d.ts.map +1 -0
- package/packages/jev-judge/dist/question-risk.js +105 -0
- package/packages/jev-judge/dist/question-risk.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/auto-continue.ts +426 -29
- package/packages/jev-judge/src/index.ts +4 -0
- package/packages/jev-judge/src/question-risk.ts +155 -0
- package/packages/jev-judge/tests/auto-continue-context.test.ts +243 -0
- package/packages/jev-judge/tests/outcome-application.test.ts +132 -0
- package/packages/jev-judge/tests/question-risk.test.ts +129 -0
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/README.md +36 -3
- package/packages/logging/dist/config.d.ts +7 -0
- package/packages/logging/dist/config.d.ts.map +1 -1
- package/packages/logging/dist/config.js +14 -0
- package/packages/logging/dist/config.js.map +1 -1
- package/packages/logging/dist/incidents/schema.d.ts +111 -0
- package/packages/logging/dist/incidents/schema.d.ts.map +1 -0
- package/packages/logging/dist/incidents/schema.js +0 -0
- package/packages/logging/dist/incidents/schema.js.map +1 -0
- package/packages/logging/dist/index.d.ts +2 -0
- package/packages/logging/dist/index.d.ts.map +1 -1
- package/packages/logging/dist/index.js +2 -0
- package/packages/logging/dist/index.js.map +1 -1
- package/packages/logging/dist/server/http.d.ts +4 -3
- package/packages/logging/dist/server/http.d.ts.map +1 -1
- package/packages/logging/dist/server/http.js +35 -3
- package/packages/logging/dist/server/http.js.map +1 -1
- package/packages/logging/dist/server/incident-qdrant.d.ts +83 -0
- package/packages/logging/dist/server/incident-qdrant.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-qdrant.js +129 -0
- package/packages/logging/dist/server/incident-qdrant.js.map +1 -0
- package/packages/logging/dist/server/incident-store.d.ts +76 -0
- package/packages/logging/dist/server/incident-store.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-store.js +157 -0
- package/packages/logging/dist/server/incident-store.js.map +1 -0
- package/packages/logging/dist/server/index.d.ts +4 -0
- package/packages/logging/dist/server/index.d.ts.map +1 -1
- package/packages/logging/dist/server/index.js +2 -0
- package/packages/logging/dist/server/index.js.map +1 -1
- package/packages/logging/dist/server/service.d.ts +33 -0
- package/packages/logging/dist/server/service.d.ts.map +1 -1
- package/packages/logging/dist/server/service.js +63 -0
- package/packages/logging/dist/server/service.js.map +1 -1
- package/packages/logging/dist/shipper.d.ts +74 -3
- package/packages/logging/dist/shipper.d.ts.map +1 -1
- package/packages/logging/dist/shipper.js +88 -5
- package/packages/logging/dist/shipper.js.map +1 -1
- package/packages/logging/dist/singleton.d.ts.map +1 -1
- package/packages/logging/dist/singleton.js +1 -0
- package/packages/logging/dist/singleton.js.map +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/logging/src/config.ts +22 -0
- package/packages/logging/src/incidents/schema.ts +0 -0
- package/packages/logging/src/index.ts +17 -0
- package/packages/logging/src/server/http.ts +42 -3
- package/packages/logging/src/server/incident-qdrant.ts +177 -0
- package/packages/logging/src/server/incident-store.ts +192 -0
- package/packages/logging/src/server/index.ts +21 -0
- package/packages/logging/src/server/service.ts +79 -0
- package/packages/logging/src/shipper.ts +120 -5
- package/packages/logging/src/singleton.ts +1 -0
- package/packages/logging/test/fanout.test.ts +186 -0
- package/packages/logging/test/incidents.test.ts +404 -0
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts +10 -2
- package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -1
- package/packages/notification/dist/adapters/detail-format.js +39 -0
- package/packages/notification/dist/adapters/detail-format.js.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.d.ts +33 -0
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.js +84 -7
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.js +6 -2
- package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +59 -7
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/pending-question.d.ts +69 -2
- package/packages/notification/dist/pending-question.d.ts.map +1 -1
- package/packages/notification/dist/pending-question.js +88 -2
- package/packages/notification/dist/pending-question.js.map +1 -1
- package/packages/notification/dist/types.d.ts +18 -0
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/adapters/detail-format.ts +42 -2
- package/packages/notification/src/adapters/line-adapter.ts +94 -7
- package/packages/notification/src/adapters/telegram-adapter.ts +6 -2
- package/packages/notification/src/notification-center.ts +65 -8
- package/packages/notification/src/pending-question.ts +160 -8
- package/packages/notification/src/types.ts +18 -0
- package/packages/notification/test/approval-payload.test.ts +269 -0
- package/packages/notification/test/pending-question-lifecycle.test.ts +195 -0
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/dist/index.d.ts +9 -0
- package/packages/okf-indexer/dist/index.d.ts.map +1 -0
- package/packages/okf-indexer/dist/index.js +9 -0
- package/packages/okf-indexer/dist/index.js.map +1 -0
- package/packages/okf-indexer/package.json +1 -1
- package/packages/okf-indexer/src/index.ts +9 -0
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/dist/provider-router.d.ts.map +1 -1
- package/packages/provider-router/dist/types.d.ts +2 -2
- package/packages/provider-router/dist/types.d.ts.map +1 -1
- package/packages/provider-router/dist/types.js +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-router/src/types.ts +2 -2
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/dist/index.d.ts +9 -0
- package/packages/scheduler/dist/index.d.ts.map +1 -0
- package/packages/scheduler/dist/index.js +9 -0
- package/packages/scheduler/dist/index.js.map +1 -0
- package/packages/scheduler/dist/scheduler.d.ts +17 -0
- package/packages/scheduler/dist/scheduler.d.ts.map +1 -0
- package/packages/scheduler/dist/scheduler.js +41 -0
- package/packages/scheduler/dist/scheduler.js.map +1 -0
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler/src/index.ts +9 -0
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/dist/index.d.ts +7 -0
- package/packages/shared-context/dist/index.d.ts.map +1 -0
- package/packages/shared-context/dist/index.js +7 -0
- package/packages/shared-context/dist/index.js.map +1 -0
- package/packages/shared-context/dist/shared-context.d.ts +12 -0
- package/packages/shared-context/dist/shared-context.d.ts.map +1 -0
- package/packages/shared-context/dist/shared-context.js +39 -0
- package/packages/shared-context/dist/shared-context.js.map +1 -0
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/dist/client.d.ts +56 -0
- package/packages/skill-mcp-client/dist/client.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/client.js +101 -0
- package/packages/skill-mcp-client/dist/client.js.map +1 -0
- package/packages/skill-mcp-client/dist/errors.d.ts +44 -0
- package/packages/skill-mcp-client/dist/errors.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/errors.js +68 -0
- package/packages/skill-mcp-client/dist/errors.js.map +1 -0
- package/packages/skill-mcp-client/dist/index.d.ts +9 -0
- package/packages/skill-mcp-client/dist/index.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/index.js +9 -0
- package/packages/skill-mcp-client/dist/index.js.map +1 -0
- package/packages/skill-mcp-client/dist/types.d.ts +106 -0
- package/packages/skill-mcp-client/dist/types.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/types.js +14 -0
- package/packages/skill-mcp-client/dist/types.js.map +1 -0
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -5
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/telegram/src/agent-messages.d.ts +28 -0
- package/packages/telegram/src/agent-messages.js +90 -0
- package/packages/telegram/src/bindings.d.ts +296 -0
- package/packages/telegram/src/bindings.js +1086 -0
- package/packages/telegram/src/bus.d.ts +759 -0
- package/packages/telegram/src/bus.js +2732 -0
- package/packages/telegram/src/commands.d.ts +761 -0
- package/packages/telegram/src/commands.js +2622 -0
- package/packages/telegram/src/config.d.ts +222 -0
- package/packages/telegram/src/config.js +844 -0
- package/packages/telegram/src/delivery.d.ts +161 -0
- package/packages/telegram/src/delivery.js +550 -0
- package/packages/telegram/src/extension.d.ts +7 -0
- package/packages/telegram/src/extension.js +2444 -0
- package/packages/telegram/src/inbound.d.ts +94 -0
- package/packages/telegram/src/inbound.js +478 -0
- package/packages/telegram/src/index.d.ts +6 -0
- package/packages/telegram/src/index.js +6 -0
- package/packages/telegram/src/keyboard.d.ts +21 -0
- package/packages/telegram/src/keyboard.js +37 -0
- package/packages/telegram/src/lifecycle.d.ts +210 -0
- package/packages/telegram/src/lifecycle.js +538 -0
- package/packages/telegram/src/pi.d.ts +76 -0
- package/packages/telegram/src/pi.js +130 -0
- package/packages/telegram/src/polling.d.ts +332 -0
- package/packages/telegram/src/polling.js +1219 -0
- package/packages/telegram/src/replies.d.ts +210 -0
- package/packages/telegram/src/replies.js +752 -0
- package/packages/telegram/src/routing.d.ts +388 -0
- package/packages/telegram/src/routing.js +7886 -0
- package/packages/telegram/src/runtime.d.ts +159 -0
- package/packages/telegram/src/runtime.js +351 -0
- package/packages/telegram/src/telegram-api.d.ts +564 -0
- package/packages/telegram/src/telegram-api.js +1332 -0
- package/packages/telegram/src/turns.d.ts +108 -0
- package/packages/telegram/src/turns.js +482 -0
- package/packages/telegram/src/updates.d.ts +1545 -0
- package/packages/telegram/src/updates.js +6420 -0
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/dist/detector.d.ts +54 -0
- package/packages/todo-bd-sync/dist/detector.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/detector.js +132 -0
- package/packages/todo-bd-sync/dist/detector.js.map +1 -0
- package/packages/todo-bd-sync/dist/extension.d.ts +30 -0
- package/packages/todo-bd-sync/dist/extension.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/extension.js +35 -0
- package/packages/todo-bd-sync/dist/extension.js.map +1 -0
- package/packages/todo-bd-sync/dist/index.d.ts +87 -0
- package/packages/todo-bd-sync/dist/index.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/index.js +296 -0
- package/packages/todo-bd-sync/dist/index.js.map +1 -0
- package/packages/todo-bd-sync/dist/sync.d.ts +72 -0
- package/packages/todo-bd-sync/dist/sync.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/sync.js +290 -0
- package/packages/todo-bd-sync/dist/sync.js.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts +49 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js +240 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts +126 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js +329 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js.map +1 -0
- package/packages/todo-bd-sync/dist/types.d.ts +65 -0
- package/packages/todo-bd-sync/dist/types.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/types.js +67 -0
- package/packages/todo-bd-sync/dist/types.js.map +1 -0
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/dist/index.d.ts +94 -0
- package/packages/token-estimation/dist/index.d.ts.map +1 -0
- package/packages/token-estimation/dist/index.js +115 -0
- package/packages/token-estimation/dist/index.js.map +1 -0
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/dist/ai-providers.d.ts +36 -0
- package/packages/types/dist/ai-providers.d.ts.map +1 -0
- package/packages/types/dist/ai-providers.js +66 -0
- package/packages/types/dist/ai-providers.js.map +1 -0
- package/packages/types/dist/index.d.ts +12 -0
- package/packages/types/dist/index.d.ts.map +1 -0
- package/packages/types/dist/index.js +12 -0
- package/packages/types/dist/index.js.map +1 -0
- package/packages/types/package.json +5 -5
- package/packages/types/src/index.ts +12 -0
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/worktree/worktree.ts +1 -1
- package/packages/write-review/package.json +1 -1
- package/renderer.ts +1 -1
- package/scripts/build-packages.ts +162 -0
- package/scripts/relay-client.ts +2 -2
- package/scripts/typecheck-packages.mjs +3 -3
- package/scripts/unified-webhook-server.ts +22 -10
- package/scripts/verify-package-contents.ts +345 -0
- package/scripts/ws-server.ts +1 -1
- package/tracker.ts +1 -1
- package/harness/browser-scrapers/base-browser-scraper.d.ts +0 -91
- package/harness/browser-scrapers/chrome-profile-manager.d.ts +0 -80
- package/harness/browser-scrapers/codex-browser-scraper.d.ts +0 -60
- package/harness/browser-scrapers/index.d.ts +0 -29
- package/harness/browser-scrapers/zai-browser-scraper.d.ts +0 -79
- package/harness/e2e/browser-scrapers/base-browser-scraper.d.ts +0 -92
- package/harness/e2e/browser-scrapers/chrome-profile-manager.d.ts +0 -81
- package/harness/e2e/browser-scrapers/codex-browser-scraper.d.ts +0 -61
- package/harness/e2e/browser-scrapers/index.d.ts +0 -30
- package/harness/e2e/browser-scrapers/zai-browser-scraper.d.ts +0 -80
- package/harness/langchain/agents.d.ts +0 -143
- package/harness/langchain/agents.test.d.ts +0 -2
- package/harness/langchain/checkpointer.d.ts +0 -48
- package/harness/langchain/checkpointer.test.d.ts +0 -8
- package/harness/langchain/cron-cli.d.ts +0 -12
- package/harness/langchain/daemon.d.ts +0 -161
- package/harness/langchain/daemon.test.d.ts +0 -11
- package/harness/langchain/file-tools.d.ts +0 -97
- package/harness/langchain/graph.d.ts +0 -706
- package/harness/langchain/model-router.d.ts +0 -63
- package/harness/langchain/model-router.test.d.ts +0 -2
- package/harness/langchain/models.d.ts +0 -72
- package/harness/langchain/ping-pong-middleware.d.ts +0 -28
- package/harness/langchain/ping-pong-middleware.test.d.ts +0 -2
- package/harness/langchain/run.d.ts +0 -15
- package/harness/langchain/scoreboard.test.d.ts +0 -13
- package/harness/langchain/status-line.d.ts +0 -91
- package/harness/langchain/status-line.test.d.ts +0 -8
- package/harness/langchain/surge.d.ts +0 -111
- package/harness/langchain/surge.test.d.ts +0 -10
- package/harness/langchain/widget.d.ts +0 -105
- package/harness/langchain/widget.test.d.ts +0 -8
- package/packages/autonomous-runtime/dist/worker.d.ts +0 -63
- package/packages/autonomous-runtime/dist/worker.js +0 -133
- package/packages/capability-registry/src/types.d.ts +0 -47
- package/packages/clipboard/dist/clipboard.d.ts +0 -11
- package/packages/clipboard/dist/clipboard.js +0 -40
- package/packages/clipboard/dist/index.d.ts +0 -2
- package/packages/clipboard/dist/index.js +0 -2
- package/packages/clipboard/dist/types.d.ts +0 -13
- package/packages/clipboard/dist/types.js +0 -5
- package/packages/context-discovery/dist/discover.d.ts +0 -3
- package/packages/context-discovery/dist/discover.js +0 -42
- package/packages/context-discovery/dist/discovery.d.ts +0 -28
- package/packages/context-discovery/dist/discovery.js +0 -21
- package/packages/context-discovery/dist/index.d.ts +0 -3
- package/packages/context-discovery/dist/index.js +0 -2
- package/packages/context-discovery/dist/types.d.ts +0 -16
- package/packages/context-discovery/dist/types.js +0 -2
- package/packages/event-bus/dist/bus.d.ts +0 -15
- package/packages/event-bus/dist/bus.js +0 -90
- package/packages/event-bus/dist/index.d.ts +0 -4
- package/packages/event-bus/dist/index.js +0 -3
- package/packages/event-bus/dist/test/bus.test.js +0 -52
- package/packages/event-bus/dist/types.d.ts +0 -27
- package/packages/event-bus/dist/types.js +0 -10
- package/packages/event-store/dist/index.d.ts +0 -3
- package/packages/event-store/dist/index.js +0 -2
- package/packages/event-store/dist/store.d.ts +0 -15
- package/packages/event-store/dist/store.js +0 -131
- package/packages/event-store/dist/test/store.test.js +0 -57
- package/packages/event-store/dist/types.d.ts +0 -48
- package/packages/event-store/dist/types.js +0 -5
- package/packages/event-store/src/types.d.ts +0 -48
- package/packages/file-copy-helper/dist/src/extension.js +0 -186
- package/packages/model-registry/src/types.d.ts +0 -63
- package/packages/notification/dist/src/adapters/email-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/email-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/email-adapter.js +0 -89
- package/packages/notification/dist/src/adapters/email-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/line-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.js +0 -99
- package/packages/notification/dist/src/adapters/line-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.js +0 -84
- package/packages/notification/dist/src/adapters/ntfy-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts +0 -56
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.js +0 -251
- package/packages/notification/dist/src/adapters/telegram-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts +0 -15
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.js +0 -64
- package/packages/notification/dist/src/adapters/webhook-adapter.js.map +0 -1
- package/packages/notification/dist/src/base-adapter.d.ts +0 -36
- package/packages/notification/dist/src/base-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/base-adapter.js +0 -39
- package/packages/notification/dist/src/base-adapter.js.map +0 -1
- package/packages/notification/dist/src/index.d.ts +0 -12
- package/packages/notification/dist/src/index.d.ts.map +0 -1
- package/packages/notification/dist/src/index.js +0 -12
- package/packages/notification/dist/src/index.js.map +0 -1
- package/packages/notification/dist/src/notification-center.d.ts +0 -89
- package/packages/notification/dist/src/notification-center.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-center.js +0 -356
- package/packages/notification/dist/src/notification-center.js.map +0 -1
- package/packages/notification/dist/src/notification-policy.d.ts +0 -66
- package/packages/notification/dist/src/notification-policy.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-policy.js +0 -153
- package/packages/notification/dist/src/notification-policy.js.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts +0 -86
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.js +0 -149
- package/packages/notification/dist/src/telegram-webhook-handler.js.map +0 -1
- package/packages/notification/dist/src/types.d.ts +0 -106
- package/packages/notification/dist/src/types.d.ts.map +0 -1
- package/packages/notification/dist/src/types.js +0 -7
- package/packages/notification/dist/src/types.js.map +0 -1
- package/packages/projection-engine/dist/engine.d.ts +0 -61
- package/packages/projection-engine/dist/engine.js +0 -76
- package/packages/projection-engine/dist/index.d.ts +0 -2
- package/packages/projection-engine/dist/index.js +0 -2
- package/packages/projection-engine/dist/project.d.ts +0 -3
- package/packages/projection-engine/dist/project.js +0 -24
- package/packages/projection-engine/dist/types.d.ts +0 -55
- package/packages/projection-engine/dist/types.js +0 -5
- package/packages/projection-engine/src/types.d.ts +0 -55
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts +0 -140
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/builder.js +0 -332
- package/packages/provider-adapter-sdk/dist/src/builder.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.js +0 -111
- package/packages/provider-adapter-sdk/dist/src/errors.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.d.ts +0 -15
- package/packages/provider-adapter-sdk/dist/src/index.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.js +0 -19
- package/packages/provider-adapter-sdk/dist/src/index.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts +0 -108
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.js +0 -301
- package/packages/provider-adapter-sdk/dist/src/registry.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.js +0 -392
- package/packages/provider-adapter-sdk/dist/src/tester.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.d.ts +0 -182
- package/packages/provider-adapter-sdk/dist/src/types.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.js +0 -11
- package/packages/provider-adapter-sdk/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.d.ts +0 -47
- package/packages/provider-router/dist/capability-registry/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.js +0 -10
- package/packages/provider-router/dist/capability-registry/src/types.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.d.ts +0 -23
- package/packages/provider-router/dist/provider-router/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.js +0 -25
- package/packages/provider-router/dist/provider-router/src/index.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/provider-router/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.js +0 -45
- package/packages/provider-router/dist/provider-router/src/policy.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.js +0 -222
- package/packages/provider-router/dist/provider-router/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.js +0 -110
- package/packages/provider-router/dist/provider-router/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.d.ts +0 -91
- package/packages/provider-router/dist/provider-router/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.js +0 -10
- package/packages/provider-router/dist/provider-router/src/types.js.map +0 -1
- package/packages/provider-router/dist/src/index.d.ts +0 -23
- package/packages/provider-router/dist/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/src/index.js +0 -25
- package/packages/provider-router/dist/src/index.js.map +0 -1
- package/packages/provider-router/dist/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/src/policy.js +0 -45
- package/packages/provider-router/dist/src/policy.js.map +0 -1
- package/packages/provider-router/dist/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/src/provider-router.js +0 -222
- package/packages/provider-router/dist/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/src/strategies.js +0 -110
- package/packages/provider-router/dist/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/src/types.d.ts +0 -91
- package/packages/provider-router/dist/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/src/types.js +0 -10
- package/packages/provider-router/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.d.ts +0 -412
- package/packages/provider-router/dist/types/src/runtime-types.d.ts.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.js +0 -2
- package/packages/provider-router/dist/types/src/runtime-types.js.map +0 -1
- package/packages/session-api/dist/api.d.ts +0 -83
- package/packages/session-api/dist/api.js +0 -35
- package/packages/session-api/dist/index.d.ts +0 -2
- package/packages/session-api/dist/index.js +0 -2
- package/packages/session-api/dist/types.d.ts +0 -22
- package/packages/session-api/dist/types.js +0 -5
- package/packages/session-export/dist/exporter.d.ts +0 -28
- package/packages/session-export/dist/exporter.js +0 -38
- package/packages/session-export/dist/index.d.ts +0 -2
- package/packages/session-export/dist/index.js +0 -2
- package/packages/session-export/dist/types.d.ts +0 -20
- package/packages/session-export/dist/types.js +0 -5
- package/packages/subscription-engine/dist/engine.d.ts +0 -13
- package/packages/subscription-engine/dist/engine.js +0 -40
- package/packages/subscription-engine/dist/index.d.ts +0 -2
- package/packages/subscription-engine/dist/index.js +0 -2
- package/packages/subscription-engine/dist/subscriptions.d.ts +0 -19
- package/packages/subscription-engine/dist/subscriptions.js +0 -32
- package/packages/subscription-engine/dist/types.d.ts +0 -24
- package/packages/subscription-engine/dist/types.js +0 -5
- package/packages/trajectory/test/store.test.d.ts +0 -2
- package/packages/workflow-events/dist/events.d.ts +0 -38
- package/packages/workflow-events/dist/events.js +0 -46
- package/packages/workflow-events/dist/index.d.ts +0 -2
- package/packages/workflow-events/dist/index.js +0 -2
- package/packages/workflow-events/dist/pipeline.d.ts +0 -21
- package/packages/workflow-events/dist/pipeline.js +0 -27
- package/packages/workflow-events/dist/types.d.ts +0 -110
- package/packages/workflow-events/dist/types.js +0 -5
- package/packages/workflow-events/src/types.d.ts +0 -110
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The risk facts of a pending question.
|
|
3
|
+
*
|
|
4
|
+
* The autonomous decision is only as safe as the facts it is based on: a
|
|
5
|
+
* question that asks for permission for a destructive or irreversible
|
|
6
|
+
* action must never be approved while the user is away. The facts are
|
|
7
|
+
* derived deterministically from the question the agent asked and from the
|
|
8
|
+
* kind of the question - never from a guess.
|
|
9
|
+
*
|
|
10
|
+
* The classifier is deliberately conservative: an uncertain case is
|
|
11
|
+
* classified as "needs an explicit authorization", so the deterministic
|
|
12
|
+
* policy waits for a human instead of continuing the work.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Words that name an action that destroys, drops or overwrites something.
|
|
16
|
+
*/
|
|
17
|
+
const DESTRUCTIVE_PATTERNS = [
|
|
18
|
+
{ name: "delete", pattern: /\b(delete|remove|drop|truncate|wipe|purge|destroy|erase)\b/ },
|
|
19
|
+
{ name: "reset", pattern: /\b(reset|rollback|revert)\b/ },
|
|
20
|
+
{ name: "revoke", pattern: /\b(revoke|rotate|invalidate)\b/ },
|
|
21
|
+
{ name: "force-push", pattern: /\b(force[\s-]?push|push\s+(--force|-f\b)|reset\s+--hard|clean\s+-\w*f)\b/ },
|
|
22
|
+
{ name: "drop-object", pattern: /\bdrop\s+(table|database|schema|collection|index|bucket)\b/ },
|
|
23
|
+
{ name: "delete-object", pattern: /\bdelete\s+(the\s+)?(database|table|file|folder|branch|tag|user|account|volume|key)\b/ },
|
|
24
|
+
{ name: "terminate", pattern: /\b(terminate|kill|shutdown|stop)\b/ },
|
|
25
|
+
{ name: "overwrite", pattern: /\boverwrite\b/ },
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Words that name an action that reaches the outside world.
|
|
29
|
+
*/
|
|
30
|
+
const EXTERNAL_PATTERNS = [
|
|
31
|
+
{ name: "production", pattern: /\b(production|prod|live)\b/ },
|
|
32
|
+
{ name: "deploy", pattern: /\b(deploy|publish|release|ship)\b/ },
|
|
33
|
+
{ name: "merge-main", pattern: /\bmerge\b.*\b(main|master|develop)\b/ },
|
|
34
|
+
{ name: "notify-people", pattern: /\b(send|post|notify|email|message|announce)\b.*\b(users|customers|clients|everyone|subscribers|team|customer)\b/ },
|
|
35
|
+
{ name: "money", pattern: /\b(payment|purchase|order|invoice|charge|refund|spend|billing)\b/ },
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Words that name a secret or a credential.
|
|
39
|
+
*/
|
|
40
|
+
const SENSITIVE_PATTERNS = [
|
|
41
|
+
{ name: "credentials", pattern: /\b(secret|credential|api[\s-]?key|token|password)\b/ },
|
|
42
|
+
];
|
|
43
|
+
function matchPatterns(text, patterns, signals) {
|
|
44
|
+
let matched = false;
|
|
45
|
+
for (const { name, pattern } of patterns) {
|
|
46
|
+
if (pattern.test(text)) {
|
|
47
|
+
signals.push(name);
|
|
48
|
+
matched = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return matched;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Derive the risk facts of a pending question.
|
|
55
|
+
*
|
|
56
|
+
* The rules:
|
|
57
|
+
*
|
|
58
|
+
* - A question of kind "explicit" asks for an explicit human authorization.
|
|
59
|
+
* Jev never approves it on its own.
|
|
60
|
+
* - A question of kind "approval" is the agent proposing work. It stays
|
|
61
|
+
* auto-approvable as long as nothing in it is risky - that is the whole
|
|
62
|
+
* point of the timeout: routine, reversible work continues when the user
|
|
63
|
+
* is away.
|
|
64
|
+
* - A question that names a destructive action is destructive, and its
|
|
65
|
+
* reversibility cannot be proven - so it waits.
|
|
66
|
+
* - A question that reaches the outside world or touches a secret needs a
|
|
67
|
+
* human as well.
|
|
68
|
+
* - A question with an unknown kind or an empty text is uncertain, and an
|
|
69
|
+
* uncertain case waits for the human.
|
|
70
|
+
*/
|
|
71
|
+
export function classifyQuestionRisk(input) {
|
|
72
|
+
const text = (input.text ?? "").toLowerCase();
|
|
73
|
+
const kind = input.kind;
|
|
74
|
+
const signals = [];
|
|
75
|
+
const destructive = matchPatterns(text, DESTRUCTIVE_PATTERNS, signals);
|
|
76
|
+
const external = matchPatterns(text, EXTERNAL_PATTERNS, signals);
|
|
77
|
+
const sensitive = matchPatterns(text, SENSITIVE_PATTERNS, signals);
|
|
78
|
+
// Only an explicitly demanded authorization blocks the autonomous
|
|
79
|
+
// decision. An "approval" question is the agent proposing work: it
|
|
80
|
+
// stays auto-approvable unless the wording names a risky action.
|
|
81
|
+
let requiresExplicitAuthorization = kind === "explicit";
|
|
82
|
+
// A destructive action never gets an autonomous approval.
|
|
83
|
+
if (destructive) {
|
|
84
|
+
requiresExplicitAuthorization = true;
|
|
85
|
+
}
|
|
86
|
+
// An action that reaches the outside world or touches a secret needs a
|
|
87
|
+
// human as well.
|
|
88
|
+
if (external || sensitive) {
|
|
89
|
+
requiresExplicitAuthorization = true;
|
|
90
|
+
}
|
|
91
|
+
// Unknown kind or unknown text: the action cannot be judged.
|
|
92
|
+
if (!kind || !text.trim()) {
|
|
93
|
+
requiresExplicitAuthorization = true;
|
|
94
|
+
signals.push("unknown-question");
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
requiresExplicitAuthorization,
|
|
98
|
+
destructive,
|
|
99
|
+
// A destructive action is not provably reversible.
|
|
100
|
+
reversible: !destructive,
|
|
101
|
+
external,
|
|
102
|
+
signals,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=question-risk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question-risk.js","sourceRoot":"","sources":["../src/question-risk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoCH;;GAEG;AACH,MAAM,oBAAoB,GAAkB;IAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,4DAA4D,EAAE;IACzF,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,6BAA6B,EAAE;IACzD,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,gCAAgC,EAAE;IAC7D,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,0EAA0E,EAAE;IAC3G,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,4DAA4D,EAAE;IAC9F,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,uFAAuF,EAAE;IAC3H,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,oCAAoC,EAAE;IACpE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,iBAAiB,GAAkB;IACxC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,4BAA4B,EAAE;IAC7D,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,mCAAmC,EAAE;IAChE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,sCAAsC,EAAE;IACvE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iHAAiH,EAAE;IACrJ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,kEAAkE,EAAE;CAC9F,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACzC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,qDAAqD,EAAE;CACvF,CAAC;AAEF,SAAS,aAAa,CACrB,IAAY,EACZ,QAAuB,EACvB,OAAiB;IAEjB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CACnC,KAAwB;IAExB,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAEnE,kEAAkE;IAClE,mEAAmE;IACnE,iEAAiE;IACjE,IAAI,6BAA6B,GAAG,IAAI,KAAK,UAAU,CAAC;IAExD,0DAA0D;IAC1D,IAAI,WAAW,EAAE,CAAC;QACjB,6BAA6B,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,uEAAuE;IACvE,iBAAiB;IACjB,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC3B,6BAA6B,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3B,6BAA6B,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACN,6BAA6B;QAC7B,WAAW;QACX,mDAAmD;QACnD,UAAU,EAAE,CAAC,WAAW;QACxB,QAAQ;QACR,OAAO;KACP,CAAC;AACH,CAAC"}
|
|
@@ -23,13 +23,261 @@ export interface TaskState {
|
|
|
23
23
|
userResponded: boolean;
|
|
24
24
|
lastUserActivity?: Date;
|
|
25
25
|
sessionStartTime: Date;
|
|
26
|
+
/** The bounded decision context (question, risk, task state). */
|
|
27
|
+
context?: DecisionContext;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The typed outcome of a decision.
|
|
32
|
+
*
|
|
33
|
+
* It is not the same shape as a human answer: an autonomous decision is
|
|
34
|
+
* never reported as a user "yes".
|
|
35
|
+
*/
|
|
36
|
+
export type DecisionOutcome =
|
|
37
|
+
| "approve"
|
|
38
|
+
| "reject"
|
|
39
|
+
| "wait"
|
|
40
|
+
| "proceed_with_caution";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The pending question Jev has to decide about.
|
|
44
|
+
*
|
|
45
|
+
* Without it Jev can only see progress, not what the agent asked permission
|
|
46
|
+
* to do.
|
|
47
|
+
*/
|
|
48
|
+
export interface PendingQuestionContext {
|
|
49
|
+
/** The canonical request ID. */
|
|
50
|
+
requestId: string;
|
|
51
|
+
/** The complete question text. */
|
|
52
|
+
text: string;
|
|
53
|
+
/** The detected kind of the question. */
|
|
54
|
+
kind: "routine" | "approval" | "clarification" | "explicit";
|
|
55
|
+
/** The exact action the agent proposes. */
|
|
56
|
+
proposedAction?: string;
|
|
57
|
+
/** What happens when the question is approved. */
|
|
58
|
+
consequence?: string;
|
|
59
|
+
/** Does the action need an explicit human authorization? */
|
|
60
|
+
requiresExplicitAuthorization?: boolean;
|
|
61
|
+
/** Does the action destroy or overwrite something? */
|
|
62
|
+
destructive?: boolean;
|
|
63
|
+
/** Does the action leave the machine (network, mail, deploy)? */
|
|
64
|
+
external?: boolean;
|
|
65
|
+
/** Can the action be undone? */
|
|
66
|
+
reversible?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The bounded context of a decision.
|
|
71
|
+
*
|
|
72
|
+
* Everything is bounded on purpose: an unbounded todo transcript makes the
|
|
73
|
+
* evaluation input large and expensive without making it better.
|
|
74
|
+
*/
|
|
75
|
+
export interface DecisionContext {
|
|
76
|
+
question?: PendingQuestionContext;
|
|
77
|
+
/** The task the session is working on right now. */
|
|
78
|
+
currentTask?: string;
|
|
79
|
+
/** 0..1 */
|
|
80
|
+
completionRatio?: number;
|
|
81
|
+
totalTasks?: number;
|
|
82
|
+
completedTasks?: number;
|
|
83
|
+
/** What blocks the work. */
|
|
84
|
+
blockers?: string[];
|
|
85
|
+
/** The next relevant tasks. */
|
|
86
|
+
nextTasks?: string[];
|
|
87
|
+
/** The state of the last validation run. */
|
|
88
|
+
validationStatus?: string;
|
|
89
|
+
/** How long the question is already waiting. */
|
|
90
|
+
waitedMinutes?: number;
|
|
91
|
+
/** When the decision has to be made. */
|
|
92
|
+
deadlineMinutes?: number;
|
|
93
|
+
/** When the user was last active. */
|
|
94
|
+
lastUserActivity?: Date;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** How many task titles reach the evaluation. */
|
|
98
|
+
export const MAX_LISTED_TASKS = 10;
|
|
99
|
+
/** How much of the question text reaches the evaluation. */
|
|
100
|
+
export const MAX_QUESTION_CHARS = 2000;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The deterministic part of a decision.
|
|
104
|
+
*
|
|
105
|
+
* Jev proposes an outcome, this function decides what is actually allowed.
|
|
106
|
+
* The rules live in code and not in a prompt: a clarification is never
|
|
107
|
+
* turned into an approval of a guessed interpretation, and an action that
|
|
108
|
+
* needs an explicit human authorization or that cannot be undone is never
|
|
109
|
+
* approved autonomously.
|
|
110
|
+
*/
|
|
111
|
+
export interface DecisionPolicyResult {
|
|
112
|
+
outcome: DecisionOutcome;
|
|
113
|
+
/** The rule that changed the outcome, when one did. */
|
|
114
|
+
appliedRule?: string;
|
|
115
|
+
reason: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface DecisionPolicyOptions {
|
|
119
|
+
/** The confidence an autonomous approval needs. */
|
|
120
|
+
confidenceThreshold?: number;
|
|
121
|
+
/** The confidence of the proposed outcome. */
|
|
122
|
+
confidence?: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Is the value a known outcome?
|
|
127
|
+
*
|
|
128
|
+
* The evaluation returns the outcome as a free-text choice: an unknown
|
|
129
|
+
* value is ignored instead of being guessed.
|
|
130
|
+
*/
|
|
131
|
+
export function isDecisionOutcome(value: unknown): value is DecisionOutcome {
|
|
132
|
+
return (
|
|
133
|
+
value === "approve" ||
|
|
134
|
+
value === "reject" ||
|
|
135
|
+
value === "wait" ||
|
|
136
|
+
value === "proceed_with_caution"
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Combine the threshold outcome with the structured outcome of the
|
|
142
|
+
* evaluation.
|
|
143
|
+
*
|
|
144
|
+
* The evaluation may only tighten the decision: a rejection stays a
|
|
145
|
+
* rejection, a wait stays a wait, and an approval never beats the
|
|
146
|
+
* thresholds.
|
|
147
|
+
*/
|
|
148
|
+
export function tightenOutcome(
|
|
149
|
+
thresholdOutcome: DecisionOutcome,
|
|
150
|
+
proposed: DecisionOutcome | undefined,
|
|
151
|
+
): DecisionOutcome {
|
|
152
|
+
if (!proposed) return thresholdOutcome;
|
|
153
|
+
if (proposed === "reject") return "reject";
|
|
154
|
+
if (proposed === "wait") return "wait";
|
|
155
|
+
if (proposed === "proceed_with_caution") {
|
|
156
|
+
return thresholdOutcome === "approve" ? "proceed_with_caution" : thresholdOutcome;
|
|
157
|
+
}
|
|
158
|
+
// The evaluation proposed an approval: the thresholds keep their veto.
|
|
159
|
+
return thresholdOutcome === "wait" ? "wait" : thresholdOutcome;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Are the risk facts of the proposed action unknown?
|
|
164
|
+
*
|
|
165
|
+
* A question without a kind and without a single known risk fact cannot be
|
|
166
|
+
* judged: the policy waits for the human instead of continuing on a guess.
|
|
167
|
+
*/
|
|
168
|
+
export function hasUnknownRiskFacts(question: PendingQuestionContext): boolean {
|
|
169
|
+
if (!question.kind) return true;
|
|
170
|
+
return (
|
|
171
|
+
question.requiresExplicitAuthorization === undefined &&
|
|
172
|
+
question.destructive === undefined &&
|
|
173
|
+
question.reversible === undefined
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function applyDecisionPolicy(
|
|
178
|
+
proposed: DecisionOutcome,
|
|
179
|
+
context: DecisionContext | undefined,
|
|
180
|
+
options?: DecisionPolicyOptions,
|
|
181
|
+
): DecisionPolicyResult {
|
|
182
|
+
const question = context?.question;
|
|
183
|
+
|
|
184
|
+
if (proposed === "approve" || proposed === "proceed_with_caution") {
|
|
185
|
+
if (question?.kind === "clarification") {
|
|
186
|
+
return {
|
|
187
|
+
outcome: "wait",
|
|
188
|
+
appliedRule: "clarification-never-approved",
|
|
189
|
+
reason:
|
|
190
|
+
"A clarification asks which option is meant. Guessing it would decide for the user.",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (question?.requiresExplicitAuthorization) {
|
|
195
|
+
return {
|
|
196
|
+
outcome: "wait",
|
|
197
|
+
appliedRule: "explicit-authorization-required",
|
|
198
|
+
reason: "The action needs an explicit human authorization.",
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (question?.destructive && question.reversible === false) {
|
|
203
|
+
return {
|
|
204
|
+
outcome: "wait",
|
|
205
|
+
appliedRule: "irreversible-action",
|
|
206
|
+
reason: "The action cannot be undone, so it waits for the user.",
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (question?.destructive) {
|
|
211
|
+
return {
|
|
212
|
+
outcome: "proceed_with_caution",
|
|
213
|
+
appliedRule: "destructive-action",
|
|
214
|
+
reason: "The action is destructive but reversible, so it proceeds with caution.",
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Nothing is known about the risk of the action: an uncertain case
|
|
219
|
+
// waits for the human instead of continuing on a guess.
|
|
220
|
+
if (question && hasUnknownRiskFacts(question)) {
|
|
221
|
+
return {
|
|
222
|
+
outcome: "wait",
|
|
223
|
+
appliedRule: "unknown-risk-facts",
|
|
224
|
+
reason:
|
|
225
|
+
"The risk of the proposed action is unknown, so it waits for the user.",
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const threshold = options?.confidenceThreshold ?? 0.7;
|
|
230
|
+
const confidence = options?.confidence;
|
|
231
|
+
if (typeof confidence === "number" && confidence < threshold) {
|
|
232
|
+
return {
|
|
233
|
+
outcome: "wait",
|
|
234
|
+
appliedRule: "confidence-below-threshold",
|
|
235
|
+
reason: `The confidence ${confidence.toFixed(2)} is below the threshold ${threshold.toFixed(2)}.`,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return { outcome: proposed, reason: "No policy rule applied." };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* What the runtime does with a Jev outcome.
|
|
245
|
+
*
|
|
246
|
+
* - `continue`: the work resumes with a steer to the agent.
|
|
247
|
+
* - `pause`: the work stops and waits for a human.
|
|
248
|
+
* - `discard`: the decision was stale and must not change anything.
|
|
249
|
+
* - `wait`: the question stays open for a later decision.
|
|
250
|
+
*/
|
|
251
|
+
export type OutcomeApplication = "continue" | "pause" | "discard" | "wait";
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Decide what a Jev outcome means for the running work.
|
|
255
|
+
*
|
|
256
|
+
* `requestClosed` tells whether the pending question was still open and
|
|
257
|
+
* could be closed with the Jev decision. A closed question is the only
|
|
258
|
+
* proof that nobody answered in the meantime: when the request was already
|
|
259
|
+
* answered by a human the Jev decision is stale, and a stale decision must
|
|
260
|
+
* never continue the work.
|
|
261
|
+
*
|
|
262
|
+
* The rule is deterministic: only a successfully closed request may continue
|
|
263
|
+
* or pause the work, and a rejection never continues it.
|
|
264
|
+
*/
|
|
265
|
+
export function decideOutcomeApplication(
|
|
266
|
+
outcome: DecisionOutcome,
|
|
267
|
+
requestClosed: boolean,
|
|
268
|
+
): OutcomeApplication {
|
|
269
|
+
if (outcome === "wait") return "wait";
|
|
270
|
+
if (!requestClosed) return "discard";
|
|
271
|
+
return outcome === "reject" ? "pause" : "continue";
|
|
26
272
|
}
|
|
27
273
|
|
|
28
274
|
/**
|
|
29
275
|
* Auto-continue decision
|
|
30
276
|
*/
|
|
31
277
|
export interface AutoContinueDecision {
|
|
32
|
-
action: "proceed" | "wait" | "proceed_with_caution";
|
|
278
|
+
action: "proceed" | "wait" | "proceed_with_caution" | "reject";
|
|
279
|
+
/** The typed outcome after the policy was applied. */
|
|
280
|
+
outcome: DecisionOutcome;
|
|
33
281
|
probability: number; // 0-1 confidence to proceed
|
|
34
282
|
riskLevel: "minimal" | "low" | "medium" | "high" | "critical";
|
|
35
283
|
reasoning: string;
|
|
@@ -37,6 +285,8 @@ export interface AutoContinueDecision {
|
|
|
37
285
|
estimatedImpact: "minimal" | "moderate" | "significant" | "major";
|
|
38
286
|
confidence: "high" | "medium" | "low";
|
|
39
287
|
waitRecommendation?: number; // minutes to wait if action is "wait"
|
|
288
|
+
/** The policy rule that changed the outcome, when one did. */
|
|
289
|
+
policyApplied?: string;
|
|
40
290
|
}
|
|
41
291
|
|
|
42
292
|
/**
|
|
@@ -92,6 +342,19 @@ export class AutoContinueJudge {
|
|
|
92
342
|
|
|
93
343
|
try {
|
|
94
344
|
const result = await this.jev.evaluate(state, {
|
|
345
|
+
outcome: {
|
|
346
|
+
type: "choice",
|
|
347
|
+
instructions:
|
|
348
|
+
"The decision for the pending question. Reject it when the proposed action must not happen.",
|
|
349
|
+
options: ["approve", "proceed_with_caution", "wait", "reject"],
|
|
350
|
+
optionDescriptions: {
|
|
351
|
+
approve: "the agent may continue with the planned work",
|
|
352
|
+
proceed_with_caution:
|
|
353
|
+
"the agent may continue, but reports every significant step",
|
|
354
|
+
wait: "keep waiting for the user, the question stays open",
|
|
355
|
+
reject: "the proposed action must not happen, the work pauses",
|
|
356
|
+
},
|
|
357
|
+
},
|
|
95
358
|
shouldProceed: {
|
|
96
359
|
type: "noul",
|
|
97
360
|
instructions:
|
|
@@ -153,11 +416,52 @@ export class AutoContinueJudge {
|
|
|
153
416
|
},
|
|
154
417
|
});
|
|
155
418
|
|
|
156
|
-
return this.buildDecision(result, taskState);
|
|
419
|
+
return this.applyPolicy(this.buildDecision(result, taskState), taskState);
|
|
157
420
|
} catch (error) {
|
|
158
421
|
logError("[AutoContinueJudge]", `Jev call failed: ${error}`);
|
|
159
|
-
return this.fallbackDecision(taskState);
|
|
422
|
+
return this.applyPolicy(this.fallbackDecision(taskState), taskState);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Apply the deterministic policy to a proposed decision.
|
|
428
|
+
*
|
|
429
|
+
* The policy is code, not a prompt: it decides what is actually allowed,
|
|
430
|
+
* and it records which rule changed the outcome.
|
|
431
|
+
*/
|
|
432
|
+
private applyPolicy(
|
|
433
|
+
decision: AutoContinueDecision,
|
|
434
|
+
taskState: TaskState,
|
|
435
|
+
): AutoContinueDecision {
|
|
436
|
+
const policy = applyDecisionPolicy(decision.outcome, taskState.context, {
|
|
437
|
+
confidenceThreshold: this.config.proceedThreshold,
|
|
438
|
+
confidence: decision.probability,
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
decision.outcome = policy.outcome;
|
|
442
|
+
|
|
443
|
+
if (policy.appliedRule) {
|
|
444
|
+
decision.policyApplied = policy.appliedRule;
|
|
445
|
+
decision.reasoning = `${decision.reasoning} - ${policy.reason}`;
|
|
160
446
|
}
|
|
447
|
+
|
|
448
|
+
if (policy.outcome === "wait" && decision.action !== "wait") {
|
|
449
|
+
decision.action = "wait";
|
|
450
|
+
decision.waitRecommendation =
|
|
451
|
+
decision.waitRecommendation ?? this.config.maxWaitMinutes;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (policy.outcome === "proceed_with_caution" && decision.action === "proceed") {
|
|
455
|
+
decision.action = "proceed_with_caution";
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// A rejection is never downgraded: the work pauses and waits for a
|
|
459
|
+
// human.
|
|
460
|
+
if (policy.outcome === "reject") {
|
|
461
|
+
decision.action = "reject";
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return decision;
|
|
161
465
|
}
|
|
162
466
|
|
|
163
467
|
/**
|
|
@@ -169,7 +473,8 @@ export class AutoContinueJudge {
|
|
|
169
473
|
const result = await this.decide(taskState);
|
|
170
474
|
|
|
171
475
|
return {
|
|
172
|
-
shouldContinue:
|
|
476
|
+
shouldContinue:
|
|
477
|
+
result.action === "proceed" || result.action === "proceed_with_caution",
|
|
173
478
|
probability: result.probability,
|
|
174
479
|
confidence: result.confidence,
|
|
175
480
|
};
|
|
@@ -179,30 +484,7 @@ export class AutoContinueJudge {
|
|
|
179
484
|
* Build state for Jev
|
|
180
485
|
*/
|
|
181
486
|
private buildState(taskState: TaskState): string {
|
|
182
|
-
|
|
183
|
-
(taskState.completedTasks.length / taskState.totalTasks) * 100
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const state = {
|
|
187
|
-
task_summary: {
|
|
188
|
-
completed: taskState.completedTasks.length,
|
|
189
|
-
remaining: taskState.remainingTasks.length,
|
|
190
|
-
total: taskState.totalTasks,
|
|
191
|
-
completion_percent: completionPercent,
|
|
192
|
-
completed_list: taskState.completedTasks,
|
|
193
|
-
remaining_list: taskState.remainingTasks,
|
|
194
|
-
},
|
|
195
|
-
user_status: {
|
|
196
|
-
responded: taskState.userResponded,
|
|
197
|
-
wait_time_minutes: taskState.waitTimeMinutes,
|
|
198
|
-
last_activity: taskState.lastUserActivity?.toISOString() ?? "unknown",
|
|
199
|
-
session_duration_minutes: Math.round(
|
|
200
|
-
(Date.now() - taskState.sessionStartTime.getTime()) / 60000
|
|
201
|
-
),
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
return JSON.stringify(state, null, 2);
|
|
487
|
+
return JSON.stringify(buildDecisionState(taskState), null, 2);
|
|
206
488
|
}
|
|
207
489
|
|
|
208
490
|
/**
|
|
@@ -231,6 +513,15 @@ export class AutoContinueJudge {
|
|
|
231
513
|
|
|
232
514
|
const waitBenefit = (result.decisions.waitBenefit?.response as { noul: number })?.noul ?? 0.5;
|
|
233
515
|
|
|
516
|
+
// The structured outcome of the evaluation. It can make the decision
|
|
517
|
+
// stricter (reject, wait) but never looser than the thresholds allow.
|
|
518
|
+
const outcomeChoice = (
|
|
519
|
+
result.decisions.outcome?.response as { choice?: string } | undefined
|
|
520
|
+
)?.choice;
|
|
521
|
+
const proposedOutcome = isDecisionOutcome(outcomeChoice)
|
|
522
|
+
? outcomeChoice
|
|
523
|
+
: undefined;
|
|
524
|
+
|
|
234
525
|
// Determine action based on thresholds
|
|
235
526
|
let action: AutoContinueDecision["action"];
|
|
236
527
|
let confidence: AutoContinueDecision["confidence"];
|
|
@@ -254,6 +545,31 @@ export class AutoContinueJudge {
|
|
|
254
545
|
reasoning = `Waiting recommended (${((1 - probability) * 100).toFixed(0)}% confidence to wait)`;
|
|
255
546
|
}
|
|
256
547
|
|
|
548
|
+
let outcome: DecisionOutcome =
|
|
549
|
+
action === "proceed"
|
|
550
|
+
? "approve"
|
|
551
|
+
: action === "proceed_with_caution"
|
|
552
|
+
? "proceed_with_caution"
|
|
553
|
+
: "wait";
|
|
554
|
+
|
|
555
|
+
// The outcome of the evaluation may only tighten the decision: a
|
|
556
|
+
// rejection stays a rejection, a wait stays a wait, and an approval
|
|
557
|
+
// never beats the thresholds.
|
|
558
|
+
outcome = tightenOutcome(outcome, proposedOutcome);
|
|
559
|
+
if (outcome === "reject") {
|
|
560
|
+
action = "reject";
|
|
561
|
+
confidence = probability > 0.85 ? "high" : "medium";
|
|
562
|
+
reasoning = `Jev rejected the proposed action (${(probability * 100).toFixed(0)}% confidence to proceed)`;
|
|
563
|
+
} else if (outcome === "wait" && proposedOutcome === "wait") {
|
|
564
|
+
action = "wait";
|
|
565
|
+
reasoning = "Jev decided to wait for the user";
|
|
566
|
+
} else if (outcome === "proceed_with_caution" && proposedOutcome === "proceed_with_caution") {
|
|
567
|
+
action = "proceed_with_caution";
|
|
568
|
+
} else if (proposedOutcome === "approve" && outcome === "wait") {
|
|
569
|
+
// The thresholds keep their veto: a low confidence stays a wait.
|
|
570
|
+
reasoning = `${reasoning} - Jev proposed an approval, the confidence stays below the threshold`;
|
|
571
|
+
}
|
|
572
|
+
|
|
257
573
|
// Calculate recommended wait time
|
|
258
574
|
let waitRecommendation: number | undefined;
|
|
259
575
|
if (action === "wait") {
|
|
@@ -265,6 +581,7 @@ export class AutoContinueJudge {
|
|
|
265
581
|
|
|
266
582
|
return {
|
|
267
583
|
action,
|
|
584
|
+
outcome,
|
|
268
585
|
probability,
|
|
269
586
|
riskLevel,
|
|
270
587
|
reasoning,
|
|
@@ -296,6 +613,7 @@ export class AutoContinueJudge {
|
|
|
296
613
|
if (completionPercent >= 0.8 && taskState.waitTimeMinutes >= 15) {
|
|
297
614
|
return {
|
|
298
615
|
action: "proceed_with_caution",
|
|
616
|
+
outcome: "proceed_with_caution",
|
|
299
617
|
probability: 0.6,
|
|
300
618
|
riskLevel: "medium",
|
|
301
619
|
reasoning: "Fallback: high completion, waited long time",
|
|
@@ -308,6 +626,7 @@ export class AutoContinueJudge {
|
|
|
308
626
|
|
|
309
627
|
return {
|
|
310
628
|
action: this.config.fallbackAction,
|
|
629
|
+
outcome: "wait",
|
|
311
630
|
probability: 0.5,
|
|
312
631
|
riskLevel: "medium",
|
|
313
632
|
reasoning: "Fallback: Jev unavailable, using default behavior",
|
|
@@ -319,6 +638,82 @@ export class AutoContinueJudge {
|
|
|
319
638
|
}
|
|
320
639
|
}
|
|
321
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Is the question old enough for an autonomous decision?
|
|
643
|
+
*
|
|
644
|
+
* The threshold belongs to the caller: the judge is only asked once the
|
|
645
|
+
* question waited long enough.
|
|
646
|
+
*/
|
|
647
|
+
export function isEligibleForDecision(
|
|
648
|
+
waitedMinutes: number,
|
|
649
|
+
minWaitMinutes: number
|
|
650
|
+
): boolean {
|
|
651
|
+
return waitedMinutes >= minWaitMinutes;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* The bounded evaluation input of a decision.
|
|
656
|
+
*
|
|
657
|
+
* It carries the question Jev has to decide about, the risk of the proposed
|
|
658
|
+
* action and the relevant task state - and nothing that grows without a
|
|
659
|
+
* bound.
|
|
660
|
+
*/
|
|
661
|
+
export function buildDecisionState(taskState: TaskState): Record<string, unknown> {
|
|
662
|
+
const completionPercent = Math.round(
|
|
663
|
+
(taskState.completedTasks.length / taskState.totalTasks) * 100
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
const context = taskState.context;
|
|
667
|
+
const question = context?.question;
|
|
668
|
+
|
|
669
|
+
return {
|
|
670
|
+
task_summary: {
|
|
671
|
+
completed: taskState.completedTasks.length,
|
|
672
|
+
remaining: taskState.remainingTasks.length,
|
|
673
|
+
total: taskState.totalTasks,
|
|
674
|
+
completion_percent: completionPercent,
|
|
675
|
+
// Bounded: the evaluation input stays small, the most recent
|
|
676
|
+
// completions and the first remaining tasks are the relevant ones.
|
|
677
|
+
completed_list: taskState.completedTasks.slice(-MAX_LISTED_TASKS),
|
|
678
|
+
remaining_list: taskState.remainingTasks.slice(0, MAX_LISTED_TASKS),
|
|
679
|
+
},
|
|
680
|
+
user_status: {
|
|
681
|
+
responded: taskState.userResponded,
|
|
682
|
+
wait_time_minutes: taskState.waitTimeMinutes,
|
|
683
|
+
last_activity: taskState.lastUserActivity?.toISOString() ?? "unknown",
|
|
684
|
+
session_duration_minutes: Math.round(
|
|
685
|
+
(Date.now() - taskState.sessionStartTime.getTime()) / 60000
|
|
686
|
+
),
|
|
687
|
+
},
|
|
688
|
+
// The question Jev decides about. Without it Jev only sees progress.
|
|
689
|
+
pending_question: question
|
|
690
|
+
? {
|
|
691
|
+
request_id: question.requestId,
|
|
692
|
+
kind: question.kind,
|
|
693
|
+
text: question.text.slice(0, MAX_QUESTION_CHARS),
|
|
694
|
+
proposed_action: question.proposedAction ?? "unknown",
|
|
695
|
+
consequence_of_approval: question.consequence ?? "unknown",
|
|
696
|
+
// The risk facts are unknown when they were not determined: an
|
|
697
|
+
// unknown fact is reported as unknown and never as "harmless".
|
|
698
|
+
requires_explicit_authorization:
|
|
699
|
+
question.requiresExplicitAuthorization ?? "unknown",
|
|
700
|
+
destructive: question.destructive ?? "unknown",
|
|
701
|
+
external_effect: question.external ?? "unknown",
|
|
702
|
+
reversible: question.reversible ?? "unknown",
|
|
703
|
+
}
|
|
704
|
+
: null,
|
|
705
|
+
decision_context: {
|
|
706
|
+
current_task: context?.currentTask ?? "unknown",
|
|
707
|
+
completion_ratio: context?.completionRatio ?? completionPercent / 100,
|
|
708
|
+
blockers: (context?.blockers ?? []).slice(0, MAX_LISTED_TASKS),
|
|
709
|
+
next_tasks: (context?.nextTasks ?? []).slice(0, MAX_LISTED_TASKS),
|
|
710
|
+
validation_status: context?.validationStatus ?? "unknown",
|
|
711
|
+
waited_minutes: context?.waitedMinutes ?? taskState.waitTimeMinutes,
|
|
712
|
+
deadline_minutes: context?.deadlineMinutes ?? null,
|
|
713
|
+
},
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
|
|
322
717
|
/**
|
|
323
718
|
* Helper: Create task state from todo list
|
|
324
719
|
*/
|
|
@@ -326,7 +721,8 @@ export function createTaskState(
|
|
|
326
721
|
completedTasks: string[],
|
|
327
722
|
remainingTasks: string[],
|
|
328
723
|
lastUserActivity?: Date,
|
|
329
|
-
sessionStartTime?: Date
|
|
724
|
+
sessionStartTime?: Date,
|
|
725
|
+
context?: DecisionContext
|
|
330
726
|
): TaskState {
|
|
331
727
|
const totalTasks = completedTasks.length + remainingTasks.length;
|
|
332
728
|
|
|
@@ -340,5 +736,6 @@ export function createTaskState(
|
|
|
340
736
|
userResponded: false,
|
|
341
737
|
lastUserActivity,
|
|
342
738
|
sessionStartTime: sessionStartTime ?? new Date(),
|
|
739
|
+
context,
|
|
343
740
|
};
|
|
344
741
|
}
|
|
@@ -697,6 +697,10 @@ export { DecisionEngine } from "./decision-engine.js";
|
|
|
697
697
|
export { AutoContinueJudge, createTaskState } from "./auto-continue.js";
|
|
698
698
|
export type { TaskState, AutoContinueDecision, AutoContinueConfig } from "./auto-continue.js";
|
|
699
699
|
|
|
700
|
+
// Export the deterministic risk classifier of a pending question
|
|
701
|
+
export { classifyQuestionRisk } from "./question-risk.js";
|
|
702
|
+
export type { QuestionRiskFacts, QuestionRiskInput } from "./question-risk.js";
|
|
703
|
+
|
|
700
704
|
// Export WrapUpJudge
|
|
701
705
|
export { checkWrapUp, getTodoSummary } from "./wrap-up-judge.js";
|
|
702
706
|
export type { WrapUpResult } from "./wrap-up-judge.js";
|