pulseed 0.5.1 → 0.5.3
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/dist/adapters/types/a2a.d.ts +6 -6
- package/dist/base/config/identity-loader.d.ts +6 -0
- package/dist/base/config/identity-loader.d.ts.map +1 -1
- package/dist/base/config/identity-loader.js +34 -8
- package/dist/base/config/identity-loader.js.map +1 -1
- package/dist/grounding/gateway.d.ts.map +1 -1
- package/dist/grounding/gateway.js +2 -1
- package/dist/grounding/gateway.js.map +1 -1
- package/dist/grounding/providers/static-policy-provider.d.ts +1 -1
- package/dist/grounding/providers/static-policy-provider.d.ts.map +1 -1
- package/dist/grounding/providers/static-policy-provider.js +12 -8
- package/dist/grounding/providers/static-policy-provider.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interface/chat/chat-event-state.d.ts +10 -0
- package/dist/interface/chat/chat-event-state.d.ts.map +1 -1
- package/dist/interface/chat/chat-event-state.js +184 -9
- package/dist/interface/chat/chat-event-state.js.map +1 -1
- package/dist/interface/chat/chat-events.d.ts +3 -1
- package/dist/interface/chat/chat-events.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.d.ts +25 -1
- package/dist/interface/chat/chat-runner.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.js +751 -83
- package/dist/interface/chat/chat-runner.js.map +1 -1
- package/dist/interface/chat/chat-verifier.d.ts +3 -1
- package/dist/interface/chat/chat-verifier.d.ts.map +1 -1
- package/dist/interface/chat/chat-verifier.js +2 -2
- package/dist/interface/chat/chat-verifier.js.map +1 -1
- package/dist/interface/chat/cross-platform-session.d.ts +4 -0
- package/dist/interface/chat/cross-platform-session.d.ts.map +1 -1
- package/dist/interface/chat/cross-platform-session.js +33 -0
- package/dist/interface/chat/cross-platform-session.js.map +1 -1
- package/dist/interface/chat/failure-recovery.d.ts +11 -0
- package/dist/interface/chat/failure-recovery.d.ts.map +1 -0
- package/dist/interface/chat/failure-recovery.js +115 -0
- package/dist/interface/chat/failure-recovery.js.map +1 -0
- package/dist/interface/chat/grounding.d.ts +1 -1
- package/dist/interface/chat/grounding.d.ts.map +1 -1
- package/dist/interface/chat/grounding.js +2 -2
- package/dist/interface/chat/grounding.js.map +1 -1
- package/dist/interface/chat/ingress-router.d.ts +11 -0
- package/dist/interface/chat/ingress-router.d.ts.map +1 -1
- package/dist/interface/chat/ingress-router.js +46 -2
- package/dist/interface/chat/ingress-router.js.map +1 -1
- package/dist/interface/chat/tend-command.d.ts +8 -0
- package/dist/interface/chat/tend-command.d.ts.map +1 -1
- package/dist/interface/chat/tend-command.js +80 -4
- package/dist/interface/chat/tend-command.js.map +1 -1
- package/dist/interface/cli/cli-command-registry.d.ts.map +1 -1
- package/dist/interface/cli/cli-command-registry.js +4 -0
- package/dist/interface/cli/cli-command-registry.js.map +1 -1
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +41 -7
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/runtime.d.ts +3 -0
- package/dist/interface/cli/commands/runtime.d.ts.map +1 -0
- package/dist/interface/cli/commands/runtime.js +231 -0
- package/dist/interface/cli/commands/runtime.js.map +1 -0
- package/dist/interface/cli/commands/setup/steps-identity.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/steps-identity.js +5 -0
- package/dist/interface/cli/commands/setup/steps-identity.js.map +1 -1
- package/dist/interface/cli/commands/setup/steps-runtime.d.ts +2 -0
- package/dist/interface/cli/commands/setup/steps-runtime.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/steps-runtime.js +11 -2
- package/dist/interface/cli/commands/setup/steps-runtime.js.map +1 -1
- package/dist/interface/cli/setup.d.ts.map +1 -1
- package/dist/interface/cli/setup.js +14 -1
- package/dist/interface/cli/setup.js.map +1 -1
- package/dist/interface/cli/utils.d.ts.map +1 -1
- package/dist/interface/cli/utils.js +4 -0
- package/dist/interface/cli/utils.js.map +1 -1
- package/dist/interface/tui/app.d.ts +2 -0
- package/dist/interface/tui/app.d.ts.map +1 -1
- package/dist/interface/tui/app.js +73 -16
- package/dist/interface/tui/app.js.map +1 -1
- package/dist/interface/tui/chat/scroll.d.ts +3 -0
- package/dist/interface/tui/chat/scroll.d.ts.map +1 -1
- package/dist/interface/tui/chat/scroll.js +15 -0
- package/dist/interface/tui/chat/scroll.js.map +1 -1
- package/dist/interface/tui/chat/types.d.ts +1 -1
- package/dist/interface/tui/chat/types.d.ts.map +1 -1
- package/dist/interface/tui/chat/viewport.d.ts.map +1 -1
- package/dist/interface/tui/chat/viewport.js +8 -2
- package/dist/interface/tui/chat/viewport.js.map +1 -1
- package/dist/interface/tui/chat-surface.d.ts +2 -0
- package/dist/interface/tui/chat-surface.d.ts.map +1 -1
- package/dist/interface/tui/chat-surface.js +11 -0
- package/dist/interface/tui/chat-surface.js.map +1 -1
- package/dist/interface/tui/chat.d.ts.map +1 -1
- package/dist/interface/tui/chat.js +15 -7
- package/dist/interface/tui/chat.js.map +1 -1
- package/dist/interface/tui/clipboard.d.ts +6 -1
- package/dist/interface/tui/clipboard.d.ts.map +1 -1
- package/dist/interface/tui/clipboard.js +24 -5
- package/dist/interface/tui/clipboard.js.map +1 -1
- package/dist/interface/tui/entry.d.ts.map +1 -1
- package/dist/interface/tui/entry.js +28 -3
- package/dist/interface/tui/entry.js.map +1 -1
- package/dist/interface/tui/flicker/MouseTracking.d.ts +1 -1
- package/dist/interface/tui/flicker/MouseTracking.d.ts.map +1 -1
- package/dist/interface/tui/flicker/MouseTracking.js +8 -4
- package/dist/interface/tui/flicker/MouseTracking.js.map +1 -1
- package/dist/interface/tui/fullscreen-chat.d.ts +86 -5
- package/dist/interface/tui/fullscreen-chat.d.ts.map +1 -1
- package/dist/interface/tui/fullscreen-chat.js +586 -32
- package/dist/interface/tui/fullscreen-chat.js.map +1 -1
- package/dist/interface/tui/help-overlay.d.ts.map +1 -1
- package/dist/interface/tui/help-overlay.js +1 -1
- package/dist/interface/tui/help-overlay.js.map +1 -1
- package/dist/interface/tui/markdown-renderer.d.ts.map +1 -1
- package/dist/interface/tui/markdown-renderer.js +40 -12
- package/dist/interface/tui/markdown-renderer.js.map +1 -1
- package/dist/interface/tui/test-entry.js +1 -1
- package/dist/interface/tui/test-entry.js.map +1 -1
- package/dist/orchestrator/execution/adapter-layer.d.ts +2 -0
- package/dist/orchestrator/execution/adapter-layer.d.ts.map +1 -1
- package/dist/orchestrator/execution/adapter-layer.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-context-assembler.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-context-assembler.js +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-context-assembler.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js +53 -12
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-dogfood-benchmark.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-dogfood-benchmark.js +7 -4
- package/dist/orchestrator/execution/agent-loop/agent-loop-dogfood-benchmark.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-prompts.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-prompts.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-prompts.js +10 -3
- package/dist/orchestrator/execution/agent-loop/agent-loop-prompts.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-factory.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-factory.js +2 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-factory.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js +51 -0
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts +13 -4
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js +44 -126
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-display-output.d.ts +27 -0
- package/dist/orchestrator/execution/agent-loop/chat-display-output.d.ts.map +1 -0
- package/dist/orchestrator/execution/agent-loop/chat-display-output.js +157 -0
- package/dist/orchestrator/execution/agent-loop/chat-display-output.js.map +1 -0
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts +1 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/index.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/index.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/index.js +1 -0
- package/dist/orchestrator/execution/agent-loop/index.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts +34 -0
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts.map +1 -0
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js +54 -0
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js.map +1 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-factory.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-factory.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-factory.js +10 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-factory.js.map +1 -1
- package/dist/orchestrator/goal/goal-suggest.d.ts +4 -4
- package/dist/orchestrator/goal/types/goal-tree.d.ts +2 -2
- package/dist/orchestrator/loop/core-loop/contracts.d.ts +19 -0
- package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js +61 -2
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-policy.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-policy.js +27 -0
- package/dist/orchestrator/loop/core-loop/phase-policy.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-specs.d.ts +37 -0
- package/dist/orchestrator/loop/core-loop/phase-specs.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-specs.js +28 -0
- package/dist/orchestrator/loop/core-loop/phase-specs.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +12 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/task-cycle.js +170 -23
- package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -1
- package/dist/orchestrator/loop/core-loop.d.ts +2 -1
- package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop.js +3 -0
- package/dist/orchestrator/loop/core-loop.js.map +1 -1
- package/dist/orchestrator/loop/loop-report-helper.d.ts.map +1 -1
- package/dist/orchestrator/loop/loop-report-helper.js +24 -0
- package/dist/orchestrator/loop/loop-report-helper.js.map +1 -1
- package/dist/orchestrator/loop/loop-result-types.d.ts +7 -0
- package/dist/orchestrator/loop/loop-result-types.d.ts.map +1 -1
- package/dist/orchestrator/loop/loop-result-types.js.map +1 -1
- package/dist/orchestrator/strategy/portfolio-manager.d.ts +2 -2
- package/dist/orchestrator/strategy/portfolio-manager.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-manager.js +11 -1
- package/dist/orchestrator/strategy/portfolio-manager.js.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts +4 -2
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.js +490 -12
- package/dist/orchestrator/strategy/portfolio-rebalance.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager.js +3 -3
- package/dist/orchestrator/strategy/strategy-manager.js.map +1 -1
- package/dist/orchestrator/strategy/types/cross-portfolio.d.ts +2 -2
- package/dist/orchestrator/strategy/types/portfolio.d.ts +12 -12
- package/dist/orchestrator/strategy/types/strategy.d.ts +639 -8
- package/dist/orchestrator/strategy/types/strategy.d.ts.map +1 -1
- package/dist/orchestrator/strategy/types/strategy.js +122 -0
- package/dist/orchestrator/strategy/types/strategy.js.map +1 -1
- package/dist/platform/code-search/candidate-normalizer.d.ts +3 -0
- package/dist/platform/code-search/candidate-normalizer.d.ts.map +1 -0
- package/dist/platform/code-search/candidate-normalizer.js +61 -0
- package/dist/platform/code-search/candidate-normalizer.js.map +1 -0
- package/dist/platform/code-search/candidate.d.ts +25 -0
- package/dist/platform/code-search/candidate.d.ts.map +1 -0
- package/dist/platform/code-search/candidate.js +61 -0
- package/dist/platform/code-search/candidate.js.map +1 -0
- package/dist/platform/code-search/contracts.d.ts +275 -0
- package/dist/platform/code-search/contracts.d.ts.map +1 -0
- package/dist/platform/code-search/contracts.js +22 -0
- package/dist/platform/code-search/contracts.js.map +1 -0
- package/dist/platform/code-search/eval/fixtures.d.ts +14 -0
- package/dist/platform/code-search/eval/fixtures.d.ts.map +1 -0
- package/dist/platform/code-search/eval/fixtures.js +24 -0
- package/dist/platform/code-search/eval/fixtures.js.map +1 -0
- package/dist/platform/code-search/eval/metrics.d.ts +10 -0
- package/dist/platform/code-search/eval/metrics.d.ts.map +1 -0
- package/dist/platform/code-search/eval/metrics.js +20 -0
- package/dist/platform/code-search/eval/metrics.js.map +1 -0
- package/dist/platform/code-search/eval/runner.d.ts +3 -0
- package/dist/platform/code-search/eval/runner.d.ts.map +1 -0
- package/dist/platform/code-search/eval/runner.js +13 -0
- package/dist/platform/code-search/eval/runner.js.map +1 -0
- package/dist/platform/code-search/fusion.d.ts +6 -0
- package/dist/platform/code-search/fusion.d.ts.map +1 -0
- package/dist/platform/code-search/fusion.js +12 -0
- package/dist/platform/code-search/fusion.js.map +1 -0
- package/dist/platform/code-search/generated-detector.d.ts +15 -0
- package/dist/platform/code-search/generated-detector.d.ts.map +1 -0
- package/dist/platform/code-search/generated-detector.js +42 -0
- package/dist/platform/code-search/generated-detector.js.map +1 -0
- package/dist/platform/code-search/indexes/call-graph.d.ts +3 -0
- package/dist/platform/code-search/indexes/call-graph.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/call-graph.js +13 -0
- package/dist/platform/code-search/indexes/call-graph.js.map +1 -0
- package/dist/platform/code-search/indexes/config-index.d.ts +3 -0
- package/dist/platform/code-search/indexes/config-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/config-index.js +7 -0
- package/dist/platform/code-search/indexes/config-index.js.map +1 -0
- package/dist/platform/code-search/indexes/file-index.d.ts +5 -0
- package/dist/platform/code-search/indexes/file-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/file-index.js +106 -0
- package/dist/platform/code-search/indexes/file-index.js.map +1 -0
- package/dist/platform/code-search/indexes/index-store.d.ts +6 -0
- package/dist/platform/code-search/indexes/index-store.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/index-store.js +14 -0
- package/dist/platform/code-search/indexes/index-store.js.map +1 -0
- package/dist/platform/code-search/indexes/indexer.d.ts +3 -0
- package/dist/platform/code-search/indexes/indexer.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/indexer.js +27 -0
- package/dist/platform/code-search/indexes/indexer.js.map +1 -0
- package/dist/platform/code-search/indexes/package-graph.d.ts +3 -0
- package/dist/platform/code-search/indexes/package-graph.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/package-graph.js +26 -0
- package/dist/platform/code-search/indexes/package-graph.js.map +1 -0
- package/dist/platform/code-search/indexes/repo-map-index.d.ts +3 -0
- package/dist/platform/code-search/indexes/repo-map-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/repo-map-index.js +26 -0
- package/dist/platform/code-search/indexes/repo-map-index.js.map +1 -0
- package/dist/platform/code-search/indexes/semantic-index.d.ts +3 -0
- package/dist/platform/code-search/indexes/semantic-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/semantic-index.js +4 -0
- package/dist/platform/code-search/indexes/semantic-index.js.map +1 -0
- package/dist/platform/code-search/indexes/symbol-index.d.ts +3 -0
- package/dist/platform/code-search/indexes/symbol-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/symbol-index.js +84 -0
- package/dist/platform/code-search/indexes/symbol-index.js.map +1 -0
- package/dist/platform/code-search/indexes/test-index.d.ts +3 -0
- package/dist/platform/code-search/indexes/test-index.d.ts.map +1 -0
- package/dist/platform/code-search/indexes/test-index.js +22 -0
- package/dist/platform/code-search/indexes/test-index.js.map +1 -0
- package/dist/platform/code-search/orchestrator.d.ts +9 -0
- package/dist/platform/code-search/orchestrator.d.ts.map +1 -0
- package/dist/platform/code-search/orchestrator.js +81 -0
- package/dist/platform/code-search/orchestrator.js.map +1 -0
- package/dist/platform/code-search/path-policy.d.ts +6 -0
- package/dist/platform/code-search/path-policy.d.ts.map +1 -0
- package/dist/platform/code-search/path-policy.js +60 -0
- package/dist/platform/code-search/path-policy.js.map +1 -0
- package/dist/platform/code-search/progressive-reader.d.ts +8 -0
- package/dist/platform/code-search/progressive-reader.d.ts.map +1 -0
- package/dist/platform/code-search/progressive-reader.js +173 -0
- package/dist/platform/code-search/progressive-reader.js.map +1 -0
- package/dist/platform/code-search/query-planner.d.ts +4 -0
- package/dist/platform/code-search/query-planner.d.ts.map +1 -0
- package/dist/platform/code-search/query-planner.js +107 -0
- package/dist/platform/code-search/query-planner.js.map +1 -0
- package/dist/platform/code-search/reranker.d.ts +4 -0
- package/dist/platform/code-search/reranker.d.ts.map +1 -0
- package/dist/platform/code-search/reranker.js +57 -0
- package/dist/platform/code-search/reranker.js.map +1 -0
- package/dist/platform/code-search/retrievers/callgraph-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/callgraph-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/callgraph-retriever.js +31 -0
- package/dist/platform/code-search/retrievers/callgraph-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/config-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/config-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/config-retriever.js +23 -0
- package/dist/platform/code-search/retrievers/config-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/lexical-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/lexical-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/lexical-retriever.js +49 -0
- package/dist/platform/code-search/retrievers/lexical-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/package-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/package-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/package-retriever.js +29 -0
- package/dist/platform/code-search/retrievers/package-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/repo-map-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/repo-map-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/repo-map-retriever.js +30 -0
- package/dist/platform/code-search/retrievers/repo-map-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/semantic-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/semantic-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/semantic-retriever.js +18 -0
- package/dist/platform/code-search/retrievers/semantic-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/stacktrace-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/stacktrace-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/stacktrace-retriever.js +30 -0
- package/dist/platform/code-search/retrievers/stacktrace-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/symbol-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/symbol-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/symbol-retriever.js +32 -0
- package/dist/platform/code-search/retrievers/symbol-retriever.js.map +1 -0
- package/dist/platform/code-search/retrievers/test-retriever.d.ts +6 -0
- package/dist/platform/code-search/retrievers/test-retriever.d.ts.map +1 -0
- package/dist/platform/code-search/retrievers/test-retriever.js +30 -0
- package/dist/platform/code-search/retrievers/test-retriever.js.map +1 -0
- package/dist/platform/code-search/session-store.d.ts +11 -0
- package/dist/platform/code-search/session-store.d.ts.map +1 -0
- package/dist/platform/code-search/session-store.js +41 -0
- package/dist/platform/code-search/session-store.js.map +1 -0
- package/dist/platform/code-search/trace.d.ts +9 -0
- package/dist/platform/code-search/trace.d.ts.map +1 -0
- package/dist/platform/code-search/trace.js +25 -0
- package/dist/platform/code-search/trace.js.map +1 -0
- package/dist/platform/code-search/verification-retrieval.d.ts +3 -0
- package/dist/platform/code-search/verification-retrieval.d.ts.map +1 -0
- package/dist/platform/code-search/verification-retrieval.js +33 -0
- package/dist/platform/code-search/verification-retrieval.js.map +1 -0
- package/dist/platform/dream/dream-types.d.ts +52 -52
- package/dist/platform/drive/types/satisficing.d.ts +2 -2
- package/dist/platform/knowledge/types/memory-lifecycle.d.ts +2 -2
- package/dist/platform/observation/context-provider.d.ts.map +1 -1
- package/dist/platform/observation/context-provider.js +37 -0
- package/dist/platform/observation/context-provider.js.map +1 -1
- package/dist/platform/observation/observation-helpers.d.ts +2 -2
- package/dist/platform/observation/workspace-context.d.ts.map +1 -1
- package/dist/platform/observation/workspace-context.js +27 -0
- package/dist/platform/observation/workspace-context.js.map +1 -1
- package/dist/platform/soil/contracts.d.ts +47 -47
- package/dist/platform/traits/types/curiosity.d.ts +24 -24
- package/dist/prompt/purposes/learning.d.ts +4 -4
- package/dist/reporting/report-formatters.d.ts.map +1 -1
- package/dist/reporting/report-formatters.js +33 -2
- package/dist/reporting/report-formatters.js.map +1 -1
- package/dist/reporting/reporting-engine.d.ts.map +1 -1
- package/dist/reporting/reporting-engine.js +2 -1
- package/dist/reporting/reporting-engine.js.map +1 -1
- package/dist/reporting/reporting-types.d.ts +11 -0
- package/dist/reporting/reporting-types.d.ts.map +1 -1
- package/dist/reporting/types/report.d.ts +72 -4
- package/dist/reporting/types/report.d.ts.map +1 -1
- package/dist/reporting/types/report.js +10 -0
- package/dist/reporting/types/report.js.map +1 -1
- package/dist/runtime/approval-broker.d.ts +1 -1
- package/dist/runtime/approval-broker.d.ts.map +1 -1
- package/dist/runtime/approval-broker.js +1 -2
- package/dist/runtime/approval-broker.js.map +1 -1
- package/dist/runtime/control/index.d.ts +1 -0
- package/dist/runtime/control/index.d.ts.map +1 -1
- package/dist/runtime/control/index.js +1 -0
- package/dist/runtime/control/index.js.map +1 -1
- package/dist/runtime/control/runtime-control-intent.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-intent.js +0 -8
- package/dist/runtime/control/runtime-control-intent.js.map +1 -1
- package/dist/runtime/control/runtime-control-result-routing.d.ts +28 -0
- package/dist/runtime/control/runtime-control-result-routing.d.ts.map +1 -0
- package/dist/runtime/control/runtime-control-result-routing.js +47 -0
- package/dist/runtime/control/runtime-control-result-routing.js.map +1 -0
- package/dist/runtime/control/runtime-control-service.d.ts +2 -1
- package/dist/runtime/control/runtime-control-service.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-service.js +32 -4
- package/dist/runtime/control/runtime-control-service.js.map +1 -1
- package/dist/runtime/daemon/client.d.ts +13 -1
- package/dist/runtime/daemon/client.d.ts.map +1 -1
- package/dist/runtime/daemon/client.js +2 -2
- package/dist/runtime/daemon/client.js.map +1 -1
- package/dist/runtime/daemon/index.d.ts +1 -0
- package/dist/runtime/daemon/index.d.ts.map +1 -1
- package/dist/runtime/daemon/index.js +1 -0
- package/dist/runtime/daemon/index.js.map +1 -1
- package/dist/runtime/daemon/runner-commands.d.ts +9 -1
- package/dist/runtime/daemon/runner-commands.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-commands.js +33 -2
- package/dist/runtime/daemon/runner-commands.js.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.js +55 -8
- package/dist/runtime/daemon/runner-goal-cycle.js.map +1 -1
- package/dist/runtime/daemon/runner-startup.d.ts +2 -1
- package/dist/runtime/daemon/runner-startup.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-startup.js +32 -5
- package/dist/runtime/daemon/runner-startup.js.map +1 -1
- package/dist/runtime/daemon/runner.d.ts +2 -0
- package/dist/runtime/daemon/runner.d.ts.map +1 -1
- package/dist/runtime/daemon/runner.js +18 -3
- package/dist/runtime/daemon/runner.js.map +1 -1
- package/dist/runtime/daemon/runtime-root.d.ts +5 -0
- package/dist/runtime/daemon/runtime-root.d.ts.map +1 -0
- package/dist/runtime/daemon/runtime-root.js +60 -0
- package/dist/runtime/daemon/runtime-root.js.map +1 -0
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts +25 -0
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts.map +1 -0
- package/dist/runtime/daemon/wait-deadline-resolver.js +88 -0
- package/dist/runtime/daemon/wait-deadline-resolver.js.map +1 -0
- package/dist/runtime/event/server-command-handler.d.ts.map +1 -1
- package/dist/runtime/event/server-command-handler.js +47 -3
- package/dist/runtime/event/server-command-handler.js.map +1 -1
- package/dist/runtime/executor/goal-worker.d.ts +1 -0
- package/dist/runtime/executor/goal-worker.d.ts.map +1 -1
- package/dist/runtime/executor/goal-worker.js +1 -0
- package/dist/runtime/executor/goal-worker.js.map +1 -1
- package/dist/runtime/executor/loop-supervisor.d.ts +24 -1
- package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
- package/dist/runtime/executor/loop-supervisor.js +191 -12
- package/dist/runtime/executor/loop-supervisor.js.map +1 -1
- package/dist/runtime/gateway/chat-session-dispatch.d.ts +1 -0
- package/dist/runtime/gateway/chat-session-dispatch.d.ts.map +1 -1
- package/dist/runtime/gateway/chat-session-dispatch.js +1 -0
- package/dist/runtime/gateway/chat-session-dispatch.js.map +1 -1
- package/dist/runtime/gateway/discord-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/discord-gateway-adapter.js +1 -0
- package/dist/runtime/gateway/discord-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/signal-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/signal-gateway-adapter.js +1 -0
- package/dist/runtime/gateway/signal-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/slack-channel-adapter.d.ts +4 -0
- package/dist/runtime/gateway/slack-channel-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/slack-channel-adapter.js +105 -10
- package/dist/runtime/gateway/slack-channel-adapter.js.map +1 -1
- package/dist/runtime/gateway/telegram-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/telegram-gateway-adapter.js +3 -1
- package/dist/runtime/gateway/telegram-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/whatsapp-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/whatsapp-gateway-adapter.js +1 -0
- package/dist/runtime/gateway/whatsapp-gateway-adapter.js.map +1 -1
- package/dist/runtime/session-registry/index.d.ts +3 -0
- package/dist/runtime/session-registry/index.d.ts.map +1 -0
- package/dist/runtime/session-registry/index.js +3 -0
- package/dist/runtime/session-registry/index.js.map +1 -0
- package/dist/runtime/session-registry/registry.d.ts +39 -0
- package/dist/runtime/session-registry/registry.d.ts.map +1 -0
- package/dist/runtime/session-registry/registry.js +761 -0
- package/dist/runtime/session-registry/registry.js.map +1 -0
- package/dist/runtime/session-registry/types.d.ts +985 -0
- package/dist/runtime/session-registry/types.d.ts.map +1 -0
- package/dist/runtime/session-registry/types.js +108 -0
- package/dist/runtime/session-registry/types.js.map +1 -0
- package/dist/runtime/store/background-run-store.d.ts +75 -0
- package/dist/runtime/store/background-run-store.d.ts.map +1 -0
- package/dist/runtime/store/background-run-store.js +157 -0
- package/dist/runtime/store/background-run-store.js.map +1 -0
- package/dist/runtime/store/index.d.ts +2 -0
- package/dist/runtime/store/index.d.ts.map +1 -1
- package/dist/runtime/store/index.js +1 -0
- package/dist/runtime/store/index.js.map +1 -1
- package/dist/runtime/store/runtime-operation-schemas.d.ts +62 -22
- package/dist/runtime/store/runtime-operation-schemas.d.ts.map +1 -1
- package/dist/runtime/store/runtime-operation-schemas.js +5 -0
- package/dist/runtime/store/runtime-operation-schemas.js.map +1 -1
- package/dist/runtime/store/runtime-paths.d.ts +2 -0
- package/dist/runtime/store/runtime-paths.d.ts.map +1 -1
- package/dist/runtime/store/runtime-paths.js +6 -0
- package/dist/runtime/store/runtime-paths.js.map +1 -1
- package/dist/runtime/store/runtime-schemas.d.ts +6 -6
- package/dist/runtime/types/cron.d.ts +4 -4
- package/dist/runtime/types/daemon.d.ts +60 -0
- package/dist/runtime/types/daemon.d.ts.map +1 -1
- package/dist/runtime/types/daemon.js +14 -0
- package/dist/runtime/types/daemon.js.map +1 -1
- package/dist/runtime/types/envelope.d.ts +2 -2
- package/dist/runtime/types/notification.d.ts +1 -1
- package/dist/tools/builtin/exports.d.ts +4 -0
- package/dist/tools/builtin/exports.d.ts.map +1 -1
- package/dist/tools/builtin/exports.js +4 -0
- package/dist/tools/builtin/exports.js.map +1 -1
- package/dist/tools/builtin/factory.d.ts.map +1 -1
- package/dist/tools/builtin/factory.js +18 -0
- package/dist/tools/builtin/factory.js.map +1 -1
- package/dist/tools/fs/GlobTool/GlobTool.js +2 -2
- package/dist/tools/fs/GlobTool/GlobTool.js.map +1 -1
- package/dist/tools/fs/GrepTool/GrepTool.js +2 -2
- package/dist/tools/fs/GrepTool/GrepTool.js.map +1 -1
- package/dist/tools/fs/ReadTool/ReadTool.js +2 -2
- package/dist/tools/fs/ReadTool/ReadTool.js.map +1 -1
- package/dist/tools/kaggle/KaggleExperimentTools.d.ts +395 -0
- package/dist/tools/kaggle/KaggleExperimentTools.d.ts.map +1 -0
- package/dist/tools/kaggle/KaggleExperimentTools.js +923 -0
- package/dist/tools/kaggle/KaggleExperimentTools.js.map +1 -0
- package/dist/tools/kaggle/KaggleSubmissionTools.d.ts +241 -0
- package/dist/tools/kaggle/KaggleSubmissionTools.d.ts.map +1 -0
- package/dist/tools/kaggle/KaggleSubmissionTools.js +558 -0
- package/dist/tools/kaggle/KaggleSubmissionTools.js.map +1 -0
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts +105 -0
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts.map +1 -0
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js +135 -0
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js.map +1 -0
- package/dist/tools/kaggle/index.d.ts +6 -0
- package/dist/tools/kaggle/index.d.ts.map +1 -0
- package/dist/tools/kaggle/index.js +6 -0
- package/dist/tools/kaggle/index.js.map +1 -0
- package/dist/tools/kaggle/metrics.d.ts +89 -0
- package/dist/tools/kaggle/metrics.d.ts.map +1 -0
- package/dist/tools/kaggle/metrics.js +51 -0
- package/dist/tools/kaggle/metrics.js.map +1 -0
- package/dist/tools/kaggle/paths.d.ts +15 -0
- package/dist/tools/kaggle/paths.d.ts.map +1 -0
- package/dist/tools/kaggle/paths.js +136 -0
- package/dist/tools/kaggle/paths.js.map +1 -0
- package/dist/tools/network/GitHubCliTool/GitHubCliTool.d.ts +2 -2
- package/dist/tools/query/ArchitectureTool/ArchitectureTool.js +1 -1
- package/dist/tools/query/ArchitectureTool/ArchitectureTool.js.map +1 -1
- package/dist/tools/query/CodeReadContextTool/CodeReadContextTool.d.ts +801 -0
- package/dist/tools/query/CodeReadContextTool/CodeReadContextTool.d.ts.map +1 -0
- package/dist/tools/query/CodeReadContextTool/CodeReadContextTool.js +147 -0
- package/dist/tools/query/CodeReadContextTool/CodeReadContextTool.js.map +1 -0
- package/dist/tools/query/CodeReadContextTool/constants.d.ts +5 -0
- package/dist/tools/query/CodeReadContextTool/constants.d.ts.map +1 -0
- package/dist/tools/query/CodeReadContextTool/constants.js +5 -0
- package/dist/tools/query/CodeReadContextTool/constants.js.map +1 -0
- package/dist/tools/query/CodeReadContextTool/prompt.d.ts +2 -0
- package/dist/tools/query/CodeReadContextTool/prompt.d.ts.map +1 -0
- package/dist/tools/query/CodeReadContextTool/prompt.js +6 -0
- package/dist/tools/query/CodeReadContextTool/prompt.js.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts +125 -0
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js +97 -0
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/constants.d.ts +5 -0
- package/dist/tools/query/CodeSearchRepairTool/constants.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/constants.js +5 -0
- package/dist/tools/query/CodeSearchRepairTool/constants.js.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/prompt.d.ts +2 -0
- package/dist/tools/query/CodeSearchRepairTool/prompt.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchRepairTool/prompt.js +5 -0
- package/dist/tools/query/CodeSearchRepairTool/prompt.js.map +1 -0
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts +123 -0
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js +95 -0
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js.map +1 -0
- package/dist/tools/query/CodeSearchTool/constants.d.ts +5 -0
- package/dist/tools/query/CodeSearchTool/constants.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchTool/constants.js +5 -0
- package/dist/tools/query/CodeSearchTool/constants.js.map +1 -0
- package/dist/tools/query/CodeSearchTool/prompt.d.ts +2 -0
- package/dist/tools/query/CodeSearchTool/prompt.d.ts.map +1 -0
- package/dist/tools/query/CodeSearchTool/prompt.js +6 -0
- package/dist/tools/query/CodeSearchTool/prompt.js.map +1 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts +35 -7
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts.map +1 -1
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js +128 -3
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { KaggleMetricDirectionSchema, normalizedMetricScore, parseKaggleMetrics, } from "./metrics.js";
|
|
5
|
+
import { ensureDirectoryWithinStateRoot, getKaggleExperimentDir, resolveKaggleWorkspaceInput, resolveWorkspaceRelativePath, stateRelativePath, validateKaggleExperimentId, workspaceRelativePath, } from "./paths.js";
|
|
6
|
+
import { defaultProcessSessionManager, } from "../system/ProcessSessionTool/ProcessSessionTool.js";
|
|
7
|
+
const DEFAULT_MAX_LOG_CHARS = 12_000;
|
|
8
|
+
export const KaggleExperimentStartInputSchema = z.object({
|
|
9
|
+
workspace: z.string().min(1),
|
|
10
|
+
competition: z.string().min(1),
|
|
11
|
+
experiment_id: z.string().min(1).optional(),
|
|
12
|
+
command: z.string().min(1),
|
|
13
|
+
args: z.array(z.string()).default([]),
|
|
14
|
+
env: z.record(z.string()).optional(),
|
|
15
|
+
strategy_id: z.string().optional(),
|
|
16
|
+
task_id: z.string().optional(),
|
|
17
|
+
expected_metrics_path: z.string().min(1).optional(),
|
|
18
|
+
artifact_refs: z.array(z.string().min(1)).default([]),
|
|
19
|
+
}).strict();
|
|
20
|
+
export const KaggleExperimentReadInputSchema = z.object({
|
|
21
|
+
workspace: z.string().min(1),
|
|
22
|
+
competition: z.string().min(1),
|
|
23
|
+
experiment_id: z.string().min(1).optional(),
|
|
24
|
+
session_id: z.string().min(1).optional(),
|
|
25
|
+
maxChars: z.number().int().min(1).max(100_000).default(DEFAULT_MAX_LOG_CHARS),
|
|
26
|
+
waitMs: z.number().int().min(0).max(30_000).default(0),
|
|
27
|
+
}).strict().refine((input) => input.experiment_id || input.session_id, {
|
|
28
|
+
message: "experiment_id or session_id is required",
|
|
29
|
+
});
|
|
30
|
+
export const KaggleExperimentListInputSchema = z.object({
|
|
31
|
+
workspace: z.string().min(1),
|
|
32
|
+
competition: z.string().min(1),
|
|
33
|
+
include_exited: z.boolean().default(true),
|
|
34
|
+
}).strict();
|
|
35
|
+
export const KaggleExperimentStopInputSchema = z.object({
|
|
36
|
+
workspace: z.string().min(1),
|
|
37
|
+
competition: z.string().min(1),
|
|
38
|
+
experiment_id: z.string().min(1).optional(),
|
|
39
|
+
session_id: z.string().min(1).optional(),
|
|
40
|
+
signal: z.enum(["SIGTERM", "SIGINT", "SIGHUP", "SIGKILL"]).default("SIGTERM"),
|
|
41
|
+
waitMs: z.number().int().min(0).max(30_000).default(1_000),
|
|
42
|
+
}).strict().refine((input) => input.experiment_id || input.session_id, {
|
|
43
|
+
message: "experiment_id or session_id is required",
|
|
44
|
+
});
|
|
45
|
+
export const KaggleMetricReportInputSchema = z.object({
|
|
46
|
+
workspace: z.string().min(1),
|
|
47
|
+
competition: z.string().min(1),
|
|
48
|
+
experiment_id: z.string().min(1).optional(),
|
|
49
|
+
metrics_path: z.string().min(1).optional(),
|
|
50
|
+
baseline_score: z.number().finite().optional(),
|
|
51
|
+
}).strict().refine((input) => input.experiment_id || input.metrics_path, {
|
|
52
|
+
message: "experiment_id or metrics_path is required",
|
|
53
|
+
});
|
|
54
|
+
export const KaggleCompareExperimentsInputSchema = z.object({
|
|
55
|
+
workspace: z.string().min(1),
|
|
56
|
+
competition: z.string().min(1),
|
|
57
|
+
experiment_ids: z.array(z.string().min(1)).optional(),
|
|
58
|
+
metric_direction: KaggleMetricDirectionSchema.optional(),
|
|
59
|
+
}).strict();
|
|
60
|
+
class KaggleToolBase {
|
|
61
|
+
manager;
|
|
62
|
+
constructor(manager = defaultProcessSessionManager) {
|
|
63
|
+
this.manager = manager;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class KaggleExperimentStartTool extends KaggleToolBase {
|
|
67
|
+
metadata = {
|
|
68
|
+
name: "kaggle_experiment_start",
|
|
69
|
+
aliases: ["kaggle_start_experiment"],
|
|
70
|
+
permissionLevel: "execute",
|
|
71
|
+
isReadOnly: false,
|
|
72
|
+
isDestructive: false,
|
|
73
|
+
shouldDefer: false,
|
|
74
|
+
alwaysLoad: false,
|
|
75
|
+
maxConcurrency: 2,
|
|
76
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
77
|
+
tags: ["kaggle", "experiment", "process", "ml"],
|
|
78
|
+
};
|
|
79
|
+
inputSchema = KaggleExperimentStartInputSchema;
|
|
80
|
+
description() {
|
|
81
|
+
return "Start a named Kaggle training experiment under the PulSeed state root, teeing process output into a durable train.log artifact.";
|
|
82
|
+
}
|
|
83
|
+
async call(input, context) {
|
|
84
|
+
const startTime = Date.now();
|
|
85
|
+
try {
|
|
86
|
+
const commandArgs = input.args ?? [];
|
|
87
|
+
const artifactRefs = input.artifact_refs ?? [];
|
|
88
|
+
const experimentId = input.experiment_id
|
|
89
|
+
? validateKaggleExperimentId(input.experiment_id)
|
|
90
|
+
: generateExperimentId();
|
|
91
|
+
const resolved = resolveExperiment(input.workspace, input.competition, experimentId);
|
|
92
|
+
await ensureDirectoryWithinStateRoot(resolved.experimentDir);
|
|
93
|
+
await fs.writeFile(resolved.logPath, "", { flag: "a" });
|
|
94
|
+
const metricsPath = input.expected_metrics_path
|
|
95
|
+
? resolveWorkspaceRelativePath(resolved.workspaceRoot, input.expected_metrics_path, "expected_metrics_path")
|
|
96
|
+
: resolved.metricsPath;
|
|
97
|
+
const extraRefs = artifactRefs.map((ref) => resolveWorkspaceRelativePath(resolved.workspaceRoot, ref, "artifact_refs"));
|
|
98
|
+
const commandMetadata = {
|
|
99
|
+
schema_version: "kaggle-command-v1",
|
|
100
|
+
experiment_id: experimentId,
|
|
101
|
+
competition: input.competition,
|
|
102
|
+
command: input.command,
|
|
103
|
+
args: commandArgs,
|
|
104
|
+
env_keys: Object.keys(input.env ?? {}).sort(),
|
|
105
|
+
cwd: resolved.workspaceRoot,
|
|
106
|
+
created_at: new Date().toISOString(),
|
|
107
|
+
log_path: resolved.logPath,
|
|
108
|
+
metrics_path: metricsPath,
|
|
109
|
+
};
|
|
110
|
+
await fs.writeFile(resolved.commandPath, `${JSON.stringify(commandMetadata, null, 2)}\n`, "utf-8");
|
|
111
|
+
const session = this.manager.start({
|
|
112
|
+
command: process.execPath,
|
|
113
|
+
args: teeWrapperArgs(input.command, commandArgs, resolved.logPath),
|
|
114
|
+
cwd: resolved.workspaceRoot,
|
|
115
|
+
env: input.env,
|
|
116
|
+
label: `kaggle:${input.competition}:${experimentId}`,
|
|
117
|
+
task_id: input.task_id,
|
|
118
|
+
strategy_id: input.strategy_id,
|
|
119
|
+
artifact_refs: [
|
|
120
|
+
resolved.logPath,
|
|
121
|
+
metricsPath,
|
|
122
|
+
resolved.metadataPath,
|
|
123
|
+
resolved.commandPath,
|
|
124
|
+
resolved.processPath,
|
|
125
|
+
resolved.childProcessPath,
|
|
126
|
+
...extraRefs,
|
|
127
|
+
],
|
|
128
|
+
}, resolved.workspaceRoot, context);
|
|
129
|
+
const metadata = experimentMetadata({ ...input, args: commandArgs, artifact_refs: artifactRefs }, resolved, experimentId, metricsPath, extraRefs, session);
|
|
130
|
+
await fs.writeFile(resolved.metadataPath, `${JSON.stringify(metadata, null, 2)}\n`, "utf-8");
|
|
131
|
+
await fs.writeFile(resolved.processPath, `${JSON.stringify(session, null, 2)}\n`, "utf-8");
|
|
132
|
+
const output = {
|
|
133
|
+
experiment_id: experimentId,
|
|
134
|
+
competition: input.competition,
|
|
135
|
+
process: session,
|
|
136
|
+
metadata: artifactRef(resolved.workspaceRoot, resolved.metadataPath),
|
|
137
|
+
artifacts: {
|
|
138
|
+
log: artifactRef(resolved.workspaceRoot, resolved.logPath),
|
|
139
|
+
metrics: artifactRef(resolved.workspaceRoot, metricsPath),
|
|
140
|
+
command: artifactRef(resolved.workspaceRoot, resolved.commandPath),
|
|
141
|
+
process: artifactRef(resolved.workspaceRoot, resolved.processPath),
|
|
142
|
+
child_process: artifactRef(resolved.workspaceRoot, resolved.childProcessPath),
|
|
143
|
+
extra: extraRefs.map((ref) => artifactRef(resolved.workspaceRoot, ref)),
|
|
144
|
+
},
|
|
145
|
+
wait_condition_hints: {
|
|
146
|
+
process_session_exited: {
|
|
147
|
+
type: "process_session_exited",
|
|
148
|
+
session_id: session.session_id,
|
|
149
|
+
},
|
|
150
|
+
metrics_file_exists: {
|
|
151
|
+
type: "file_exists",
|
|
152
|
+
path: stateRelativePath(metricsPath),
|
|
153
|
+
absolute_path: metricsPath,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
metric_threshold_guidance: {
|
|
157
|
+
wait_condition_type: "metric_threshold",
|
|
158
|
+
metric: "cv_score",
|
|
159
|
+
operator: "read_metrics_direction_first",
|
|
160
|
+
value_required: true,
|
|
161
|
+
metric_source: "wait_metadata.metrics",
|
|
162
|
+
metrics_artifact_state_relative_path: stateRelativePath(metricsPath),
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
data: output,
|
|
168
|
+
summary: `Started Kaggle experiment ${experimentId} as process session ${session.session_id}`,
|
|
169
|
+
durationMs: Date.now() - startTime,
|
|
170
|
+
artifacts: [
|
|
171
|
+
resolved.metadataPath,
|
|
172
|
+
resolved.commandPath,
|
|
173
|
+
resolved.processPath,
|
|
174
|
+
resolved.logPath,
|
|
175
|
+
metricsPath,
|
|
176
|
+
...(session.metadataPath ? [session.metadataPath] : []),
|
|
177
|
+
...extraRefs,
|
|
178
|
+
],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
return failureResult(`Failed to start Kaggle experiment: ${err.message}`, startTime);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async checkPermissions(input) {
|
|
186
|
+
return {
|
|
187
|
+
status: "needs_approval",
|
|
188
|
+
reason: `Start Kaggle training command for ${input.competition}: ${input.command} ${(input.args ?? []).join(" ")}`.trim(),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
isConcurrencySafe(_input) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export class KaggleExperimentReadTool extends KaggleToolBase {
|
|
196
|
+
metadata = {
|
|
197
|
+
name: "kaggle_experiment_read",
|
|
198
|
+
aliases: ["kaggle_read_experiment"],
|
|
199
|
+
permissionLevel: "read_metrics",
|
|
200
|
+
isReadOnly: true,
|
|
201
|
+
isDestructive: false,
|
|
202
|
+
shouldDefer: false,
|
|
203
|
+
alwaysLoad: false,
|
|
204
|
+
maxConcurrency: 5,
|
|
205
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
206
|
+
tags: ["kaggle", "experiment", "process", "ml"],
|
|
207
|
+
};
|
|
208
|
+
inputSchema = KaggleExperimentReadInputSchema;
|
|
209
|
+
description() {
|
|
210
|
+
return "Read a Kaggle experiment from durable metadata, train.log, metrics.json, and the live process buffer when available.";
|
|
211
|
+
}
|
|
212
|
+
async call(input, _context) {
|
|
213
|
+
const startTime = Date.now();
|
|
214
|
+
try {
|
|
215
|
+
const located = await locateExperiment(input.workspace, input.competition, input.experiment_id, input.session_id);
|
|
216
|
+
if (!located) {
|
|
217
|
+
return failureResult("Kaggle experiment not found", startTime);
|
|
218
|
+
}
|
|
219
|
+
const liveRead = located.sessionId
|
|
220
|
+
? await this.manager.read({
|
|
221
|
+
session_id: located.sessionId,
|
|
222
|
+
maxChars: input.maxChars,
|
|
223
|
+
waitMs: input.waitMs,
|
|
224
|
+
consume: false,
|
|
225
|
+
})
|
|
226
|
+
: null;
|
|
227
|
+
const processSnapshot = liveRead ?? await readProcessSnapshotFromMetadata(located.processPath);
|
|
228
|
+
const log = await readTail(located.logPath, input.maxChars);
|
|
229
|
+
const metrics = await readMetrics(located.metricsPath);
|
|
230
|
+
const missingArtifacts = await missingPaths([located.logPath, located.metricsPath]);
|
|
231
|
+
const output = {
|
|
232
|
+
experiment_id: located.experimentId,
|
|
233
|
+
session_id: located.sessionId,
|
|
234
|
+
status: statusFromProcessAndMetrics(processSnapshot, metrics.ok ? metrics.metrics : null),
|
|
235
|
+
process: processSnapshot,
|
|
236
|
+
live_output: liveRead?.output ?? null,
|
|
237
|
+
log,
|
|
238
|
+
metrics: metrics.ok ? metrics.metrics : null,
|
|
239
|
+
metrics_status: metrics.ok ? "ok" : metrics.reason,
|
|
240
|
+
metrics_error: metrics.ok ? null : metrics.message,
|
|
241
|
+
missing_artifacts: missingArtifacts.map((artifactPath) => artifactRef(located.workspaceRoot, artifactPath)),
|
|
242
|
+
artifacts: {
|
|
243
|
+
log: artifactRef(located.workspaceRoot, located.logPath),
|
|
244
|
+
metrics: artifactRef(located.workspaceRoot, located.metricsPath),
|
|
245
|
+
metadata: artifactRef(located.workspaceRoot, located.metadataPath),
|
|
246
|
+
process: artifactRef(located.workspaceRoot, located.processPath),
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
return {
|
|
250
|
+
success: true,
|
|
251
|
+
data: output,
|
|
252
|
+
summary: `Read Kaggle experiment ${located.experimentId}: ${output.status}`,
|
|
253
|
+
durationMs: Date.now() - startTime,
|
|
254
|
+
artifacts: [located.metadataPath, located.processPath, located.logPath, located.metricsPath],
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
return failureResult(`Failed to read Kaggle experiment: ${err.message}`, startTime);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async checkPermissions(_input) {
|
|
262
|
+
return { status: "allowed" };
|
|
263
|
+
}
|
|
264
|
+
isConcurrencySafe(_input) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
export class KaggleExperimentListTool extends KaggleToolBase {
|
|
269
|
+
metadata = {
|
|
270
|
+
name: "kaggle_experiment_list",
|
|
271
|
+
aliases: ["kaggle_list_experiments"],
|
|
272
|
+
permissionLevel: "read_metrics",
|
|
273
|
+
isReadOnly: true,
|
|
274
|
+
isDestructive: false,
|
|
275
|
+
shouldDefer: false,
|
|
276
|
+
alwaysLoad: false,
|
|
277
|
+
maxConcurrency: 5,
|
|
278
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
279
|
+
tags: ["kaggle", "experiment", "process", "ml"],
|
|
280
|
+
};
|
|
281
|
+
inputSchema = KaggleExperimentListInputSchema;
|
|
282
|
+
description() {
|
|
283
|
+
return "List Kaggle experiments by merging durable experiment directories with currently live process sessions.";
|
|
284
|
+
}
|
|
285
|
+
async call(input, _context) {
|
|
286
|
+
const startTime = Date.now();
|
|
287
|
+
try {
|
|
288
|
+
const workspaceRoot = resolveKaggleWorkspaceInput(input.workspace, input.competition);
|
|
289
|
+
const experiments = new Map();
|
|
290
|
+
for (const experimentId of await listExperimentIds(workspaceRoot)) {
|
|
291
|
+
const located = resolveLocatedExperiment(workspaceRoot, input.competition, experimentId);
|
|
292
|
+
const metadata = await readJsonObject(located.metadataPath);
|
|
293
|
+
const processSnapshot = await readProcessSnapshotFromMetadata(located.processPath);
|
|
294
|
+
const metrics = await readMetrics(located.metricsPath);
|
|
295
|
+
experiments.set(experimentId, {
|
|
296
|
+
experiment_id: experimentId,
|
|
297
|
+
session_id: typeof metadata?.process === "object" && metadata.process !== null
|
|
298
|
+
? metadata.process.session_id
|
|
299
|
+
: undefined,
|
|
300
|
+
status: statusFromProcessAndMetrics(processSnapshot, metrics.ok ? metrics.metrics : null),
|
|
301
|
+
source: "filesystem",
|
|
302
|
+
metrics: metrics.ok ? metrics.metrics : null,
|
|
303
|
+
metrics_status: metrics.ok ? "ok" : metrics.reason,
|
|
304
|
+
artifacts: {
|
|
305
|
+
log: artifactRef(workspaceRoot, located.logPath),
|
|
306
|
+
metrics: artifactRef(workspaceRoot, located.metricsPath),
|
|
307
|
+
metadata: artifactRef(workspaceRoot, located.metadataPath),
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
for (const session of this.manager.list(input.include_exited)) {
|
|
312
|
+
const experimentId = experimentIdFromSession(session, workspaceRoot);
|
|
313
|
+
if (!experimentId)
|
|
314
|
+
continue;
|
|
315
|
+
const located = resolveLocatedExperiment(workspaceRoot, input.competition, experimentId);
|
|
316
|
+
const existing = experiments.get(experimentId) ?? {};
|
|
317
|
+
const metrics = await readMetrics(located.metricsPath);
|
|
318
|
+
experiments.set(experimentId, {
|
|
319
|
+
...existing,
|
|
320
|
+
experiment_id: experimentId,
|
|
321
|
+
session_id: session.session_id,
|
|
322
|
+
status: statusFromProcessAndMetrics(session, metrics.ok ? metrics.metrics : null),
|
|
323
|
+
source: existing.source ? "filesystem+live" : "live",
|
|
324
|
+
process: session,
|
|
325
|
+
metrics: metrics.ok ? metrics.metrics : null,
|
|
326
|
+
metrics_status: metrics.ok ? "ok" : metrics.reason,
|
|
327
|
+
artifacts: {
|
|
328
|
+
log: artifactRef(workspaceRoot, located.logPath),
|
|
329
|
+
metrics: artifactRef(workspaceRoot, located.metricsPath),
|
|
330
|
+
metadata: artifactRef(workspaceRoot, located.metadataPath),
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
const data = [...experiments.values()].sort((a, b) => String(a.experiment_id).localeCompare(String(b.experiment_id)));
|
|
335
|
+
return {
|
|
336
|
+
success: true,
|
|
337
|
+
data,
|
|
338
|
+
summary: `Found ${data.length} Kaggle experiment(s) for ${input.competition}`,
|
|
339
|
+
durationMs: Date.now() - startTime,
|
|
340
|
+
artifacts: data.flatMap((item) => {
|
|
341
|
+
const artifacts = item.artifacts;
|
|
342
|
+
return artifacts ? Object.values(artifacts).map((ref) => ref.path) : [];
|
|
343
|
+
}),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
return failureResult(`Failed to list Kaggle experiments: ${err.message}`, startTime);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
async checkPermissions(_input) {
|
|
351
|
+
return { status: "allowed" };
|
|
352
|
+
}
|
|
353
|
+
isConcurrencySafe(_input) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
export class KaggleExperimentStopTool extends KaggleToolBase {
|
|
358
|
+
metadata = {
|
|
359
|
+
name: "kaggle_experiment_stop",
|
|
360
|
+
aliases: ["kaggle_stop_experiment"],
|
|
361
|
+
permissionLevel: "execute",
|
|
362
|
+
isReadOnly: false,
|
|
363
|
+
isDestructive: false,
|
|
364
|
+
shouldDefer: false,
|
|
365
|
+
alwaysLoad: false,
|
|
366
|
+
maxConcurrency: 1,
|
|
367
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
368
|
+
tags: ["kaggle", "experiment", "process", "ml"],
|
|
369
|
+
};
|
|
370
|
+
inputSchema = KaggleExperimentStopInputSchema;
|
|
371
|
+
description() {
|
|
372
|
+
return "Stop a running Kaggle experiment process session.";
|
|
373
|
+
}
|
|
374
|
+
async call(input, _context) {
|
|
375
|
+
const startTime = Date.now();
|
|
376
|
+
try {
|
|
377
|
+
const located = await locateExperiment(input.workspace, input.competition, input.experiment_id, input.session_id);
|
|
378
|
+
const sessionId = input.session_id ?? located?.sessionId;
|
|
379
|
+
if (!sessionId) {
|
|
380
|
+
return failureResult("Kaggle experiment session not found", startTime);
|
|
381
|
+
}
|
|
382
|
+
if (located) {
|
|
383
|
+
await signalKaggleChildProcess(located.childProcessPath, input.signal);
|
|
384
|
+
}
|
|
385
|
+
const stopped = await this.manager.stop({ session_id: sessionId, signal: input.signal, waitMs: input.waitMs });
|
|
386
|
+
if (!stopped) {
|
|
387
|
+
return failureResult(`Process session not found: ${sessionId}`, startTime);
|
|
388
|
+
}
|
|
389
|
+
if (located) {
|
|
390
|
+
await fs.writeFile(located.processPath, `${JSON.stringify(stopped, null, 2)}\n`, "utf-8");
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
success: true,
|
|
394
|
+
data: {
|
|
395
|
+
experiment_id: located?.experimentId ?? null,
|
|
396
|
+
session_id: sessionId,
|
|
397
|
+
process: stopped,
|
|
398
|
+
artifacts: located ? {
|
|
399
|
+
process: artifactRef(located.workspaceRoot, located.processPath),
|
|
400
|
+
log: artifactRef(located.workspaceRoot, located.logPath),
|
|
401
|
+
} : null,
|
|
402
|
+
},
|
|
403
|
+
summary: `Stopped Kaggle experiment process session ${sessionId}`,
|
|
404
|
+
durationMs: Date.now() - startTime,
|
|
405
|
+
artifacts: located ? [located.processPath, located.logPath] : stopped.artifactRefs,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
catch (err) {
|
|
409
|
+
return failureResult(`Failed to stop Kaggle experiment: ${err.message}`, startTime);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async checkPermissions(input) {
|
|
413
|
+
return {
|
|
414
|
+
status: "needs_approval",
|
|
415
|
+
reason: `Stop Kaggle experiment ${input.experiment_id ?? input.session_id}`,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
isConcurrencySafe(_input) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
export class KaggleMetricReportTool extends KaggleToolBase {
|
|
423
|
+
metadata = {
|
|
424
|
+
name: "kaggle_metric_report",
|
|
425
|
+
aliases: ["kaggle_report_metric"],
|
|
426
|
+
permissionLevel: "read_only",
|
|
427
|
+
isReadOnly: true,
|
|
428
|
+
isDestructive: false,
|
|
429
|
+
shouldDefer: false,
|
|
430
|
+
alwaysLoad: false,
|
|
431
|
+
maxConcurrency: 5,
|
|
432
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
433
|
+
tags: ["kaggle", "metrics", "ml"],
|
|
434
|
+
};
|
|
435
|
+
inputSchema = KaggleMetricReportInputSchema;
|
|
436
|
+
description() {
|
|
437
|
+
return "Validate a Kaggle metrics.json artifact and return direction-aware score information for wait metadata.";
|
|
438
|
+
}
|
|
439
|
+
async call(input, _context) {
|
|
440
|
+
const startTime = Date.now();
|
|
441
|
+
try {
|
|
442
|
+
const workspaceRoot = resolveKaggleWorkspaceInput(input.workspace, input.competition);
|
|
443
|
+
const metricsPath = input.metrics_path
|
|
444
|
+
? resolveWorkspaceRelativePath(workspaceRoot, input.metrics_path, "metrics_path")
|
|
445
|
+
: path.join(getKaggleExperimentDir(workspaceRoot, input.experiment_id), "metrics.json");
|
|
446
|
+
const metrics = await readMetrics(metricsPath);
|
|
447
|
+
if (!metrics.ok) {
|
|
448
|
+
return {
|
|
449
|
+
success: false,
|
|
450
|
+
data: {
|
|
451
|
+
status: "failure",
|
|
452
|
+
reason: metrics.reason,
|
|
453
|
+
message: metrics.message,
|
|
454
|
+
issues: metrics.issues ?? [],
|
|
455
|
+
artifact: artifactRef(workspaceRoot, metricsPath),
|
|
456
|
+
},
|
|
457
|
+
summary: `Failed to read Kaggle metrics: ${metrics.message} (${stateRelativePath(metricsPath)})`,
|
|
458
|
+
error: metrics.message,
|
|
459
|
+
durationMs: Date.now() - startTime,
|
|
460
|
+
artifacts: [metricsPath],
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
const normalizedScore = normalizedMetricScore(metrics.metrics);
|
|
464
|
+
const baselineDelta = input.baseline_score === undefined
|
|
465
|
+
? null
|
|
466
|
+
: metrics.metrics.direction === "maximize"
|
|
467
|
+
? metrics.metrics.cv_score - input.baseline_score
|
|
468
|
+
: input.baseline_score - metrics.metrics.cv_score;
|
|
469
|
+
const warnings = [
|
|
470
|
+
...(metrics.metrics.cv_std === null ? ["cv_std is null"] : []),
|
|
471
|
+
...(metrics.metrics.holdout_score === null ? ["holdout_score is null"] : []),
|
|
472
|
+
...(!metrics.metrics.artifacts.submission ? ["submission artifact is missing"] : []),
|
|
473
|
+
...(!metrics.metrics.artifacts.model ? ["model artifact is missing"] : []),
|
|
474
|
+
];
|
|
475
|
+
const data = {
|
|
476
|
+
status: "ok",
|
|
477
|
+
experiment_id: metrics.metrics.experiment_id,
|
|
478
|
+
metric_name: metrics.metrics.metric_name,
|
|
479
|
+
direction: metrics.metrics.direction,
|
|
480
|
+
score: metrics.metrics.cv_score,
|
|
481
|
+
normalized_score: normalizedScore,
|
|
482
|
+
baseline_delta: baselineDelta,
|
|
483
|
+
confidence: confidenceForMetrics(metrics.metrics),
|
|
484
|
+
metrics: metrics.metrics,
|
|
485
|
+
warnings,
|
|
486
|
+
artifact: artifactRef(workspaceRoot, metricsPath),
|
|
487
|
+
wait_metadata: {
|
|
488
|
+
metrics: {
|
|
489
|
+
cv_score: metrics.metrics.cv_score,
|
|
490
|
+
normalized_score: normalizedScore,
|
|
491
|
+
baseline_delta: baselineDelta,
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
metric_threshold_guidance: {
|
|
495
|
+
wait_condition_type: "metric_threshold",
|
|
496
|
+
metric: "cv_score",
|
|
497
|
+
operator: metrics.metrics.direction === "maximize" ? "gte" : "lte",
|
|
498
|
+
value_required: true,
|
|
499
|
+
metric_source: "wait_metadata.metrics",
|
|
500
|
+
metrics_artifact_state_relative_path: stateRelativePath(metricsPath),
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
return {
|
|
504
|
+
success: true,
|
|
505
|
+
data,
|
|
506
|
+
summary: `Kaggle metric ${metrics.metrics.metric_name}=${metrics.metrics.cv_score} (${metrics.metrics.direction}) for ${metrics.metrics.experiment_id}`,
|
|
507
|
+
durationMs: Date.now() - startTime,
|
|
508
|
+
artifacts: [metricsPath],
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
return failureResult(`Failed to report Kaggle metrics: ${err.message}`, startTime);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async checkPermissions(_input) {
|
|
516
|
+
return { status: "allowed" };
|
|
517
|
+
}
|
|
518
|
+
isConcurrencySafe(_input) {
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
export class KaggleCompareExperimentsTool extends KaggleToolBase {
|
|
523
|
+
metadata = {
|
|
524
|
+
name: "kaggle_compare_experiments",
|
|
525
|
+
aliases: ["kaggle_compare_metrics"],
|
|
526
|
+
permissionLevel: "read_only",
|
|
527
|
+
isReadOnly: true,
|
|
528
|
+
isDestructive: false,
|
|
529
|
+
shouldDefer: false,
|
|
530
|
+
alwaysLoad: false,
|
|
531
|
+
maxConcurrency: 5,
|
|
532
|
+
maxOutputChars: DEFAULT_MAX_LOG_CHARS,
|
|
533
|
+
tags: ["kaggle", "metrics", "ml"],
|
|
534
|
+
};
|
|
535
|
+
inputSchema = KaggleCompareExperimentsInputSchema;
|
|
536
|
+
description() {
|
|
537
|
+
return "Compare Kaggle experiment metrics and select the best run using maximize or minimize semantics.";
|
|
538
|
+
}
|
|
539
|
+
async call(input, _context) {
|
|
540
|
+
const startTime = Date.now();
|
|
541
|
+
try {
|
|
542
|
+
const workspaceRoot = resolveKaggleWorkspaceInput(input.workspace, input.competition);
|
|
543
|
+
const experimentIds = input.experiment_ids?.map(validateKaggleExperimentId) ?? await listExperimentIds(workspaceRoot);
|
|
544
|
+
const rows = [];
|
|
545
|
+
for (const experimentId of experimentIds) {
|
|
546
|
+
const metricsPath = path.join(getKaggleExperimentDir(workspaceRoot, experimentId), "metrics.json");
|
|
547
|
+
const metrics = await readMetrics(metricsPath);
|
|
548
|
+
if (!metrics.ok) {
|
|
549
|
+
rows.push({
|
|
550
|
+
experiment_id: experimentId,
|
|
551
|
+
status: metrics.reason,
|
|
552
|
+
summary: metrics.message,
|
|
553
|
+
issues: metrics.issues ?? [],
|
|
554
|
+
artifact: artifactRef(workspaceRoot, metricsPath),
|
|
555
|
+
});
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
const direction = input.metric_direction ?? metrics.metrics.direction;
|
|
559
|
+
const normalizedScore = direction === "maximize" ? metrics.metrics.cv_score : -metrics.metrics.cv_score;
|
|
560
|
+
rows.push({
|
|
561
|
+
experiment_id: experimentId,
|
|
562
|
+
status: "ok",
|
|
563
|
+
metric_name: metrics.metrics.metric_name,
|
|
564
|
+
direction,
|
|
565
|
+
score: metrics.metrics.cv_score,
|
|
566
|
+
normalized_score: normalizedScore,
|
|
567
|
+
metrics: metrics.metrics,
|
|
568
|
+
artifact: artifactRef(workspaceRoot, metricsPath),
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const validRows = rows
|
|
572
|
+
.filter((row) => row.status === "ok")
|
|
573
|
+
.sort((a, b) => b.normalized_score - a.normalized_score);
|
|
574
|
+
if (validRows.length === 0) {
|
|
575
|
+
return {
|
|
576
|
+
success: true,
|
|
577
|
+
data: {
|
|
578
|
+
status: "inconclusive",
|
|
579
|
+
best_experiment_id: null,
|
|
580
|
+
delta: null,
|
|
581
|
+
rows,
|
|
582
|
+
recommendation: "No valid metrics.json files were available to compare.",
|
|
583
|
+
},
|
|
584
|
+
summary: "Kaggle experiment comparison inconclusive: no valid metrics.json files",
|
|
585
|
+
durationMs: Date.now() - startTime,
|
|
586
|
+
artifacts: rows.map((row) => row.artifact.path),
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
const metricNames = new Set(validRows.map((row) => row.metric_name));
|
|
590
|
+
const metricDirections = new Set(validRows.map((row) => row.metrics.direction));
|
|
591
|
+
if (metricNames.size > 1 || (!input.metric_direction && metricDirections.size > 1)) {
|
|
592
|
+
return {
|
|
593
|
+
success: true,
|
|
594
|
+
data: {
|
|
595
|
+
status: "inconclusive",
|
|
596
|
+
best_experiment_id: null,
|
|
597
|
+
delta: null,
|
|
598
|
+
rows,
|
|
599
|
+
recommendation: "Experiments must share metric_name and direction before comparison.",
|
|
600
|
+
},
|
|
601
|
+
summary: "Kaggle experiment comparison inconclusive: metrics are not comparable",
|
|
602
|
+
durationMs: Date.now() - startTime,
|
|
603
|
+
artifacts: rows.map((row) => row.artifact.path),
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
const best = validRows[0];
|
|
607
|
+
const runnerUp = validRows[1];
|
|
608
|
+
const delta = runnerUp ? best.normalized_score - runnerUp.normalized_score : null;
|
|
609
|
+
const rankTable = rows.map((row) => row.status === "ok"
|
|
610
|
+
? { ...row, rank: validRows.findIndex((valid) => valid.experiment_id === row.experiment_id) + 1 }
|
|
611
|
+
: { ...row, rank: null });
|
|
612
|
+
return {
|
|
613
|
+
success: true,
|
|
614
|
+
data: {
|
|
615
|
+
status: rows.length === validRows.length ? "ok" : "inconclusive",
|
|
616
|
+
best_experiment_id: best.experiment_id,
|
|
617
|
+
direction: best.direction,
|
|
618
|
+
metric_name: best.metric_name,
|
|
619
|
+
delta,
|
|
620
|
+
rows: rankTable,
|
|
621
|
+
recommendation: delta === null
|
|
622
|
+
? `Use ${best.experiment_id}; it is the only valid experiment.`
|
|
623
|
+
: `Use ${best.experiment_id}; it leads by ${delta}.`,
|
|
624
|
+
},
|
|
625
|
+
summary: `Best Kaggle experiment is ${best.experiment_id} (${best.metric_name}=${best.score}, ${best.direction})`,
|
|
626
|
+
durationMs: Date.now() - startTime,
|
|
627
|
+
artifacts: rows.map((row) => row.artifact.path),
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
catch (err) {
|
|
631
|
+
return failureResult(`Failed to compare Kaggle experiments: ${err.message}`, startTime);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
async checkPermissions(_input) {
|
|
635
|
+
return { status: "allowed" };
|
|
636
|
+
}
|
|
637
|
+
isConcurrencySafe(_input) {
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function resolveExperiment(workspace, competition, experimentId) {
|
|
642
|
+
const workspaceRoot = resolveKaggleWorkspaceInput(workspace, competition);
|
|
643
|
+
const experimentDir = getKaggleExperimentDir(workspaceRoot, experimentId);
|
|
644
|
+
return {
|
|
645
|
+
workspaceRoot,
|
|
646
|
+
experimentId,
|
|
647
|
+
experimentDir,
|
|
648
|
+
metadataPath: path.join(experimentDir, "config.json"),
|
|
649
|
+
commandPath: path.join(experimentDir, "command.json"),
|
|
650
|
+
processPath: path.join(experimentDir, "process.json"),
|
|
651
|
+
childProcessPath: path.join(experimentDir, "child-process.json"),
|
|
652
|
+
logPath: path.join(experimentDir, "train.log"),
|
|
653
|
+
metricsPath: path.join(experimentDir, "metrics.json"),
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function resolveLocatedExperiment(workspaceRoot, competition, experimentId) {
|
|
657
|
+
return resolveExperiment(workspaceRoot, competition, experimentId);
|
|
658
|
+
}
|
|
659
|
+
async function locateExperiment(workspace, competition, experimentId, sessionId) {
|
|
660
|
+
const workspaceRoot = resolveKaggleWorkspaceInput(workspace, competition);
|
|
661
|
+
if (experimentId) {
|
|
662
|
+
const resolved = resolveLocatedExperiment(workspaceRoot, competition, validateKaggleExperimentId(experimentId));
|
|
663
|
+
const metadata = await readJsonObject(resolved.metadataPath);
|
|
664
|
+
const metadataSessionId = typeof metadata?.process === "object" && metadata.process !== null
|
|
665
|
+
? metadata.process.session_id
|
|
666
|
+
: undefined;
|
|
667
|
+
return { ...resolved, sessionId: sessionId ?? metadataSessionId };
|
|
668
|
+
}
|
|
669
|
+
for (const candidateId of await listExperimentIds(workspaceRoot)) {
|
|
670
|
+
const resolved = resolveLocatedExperiment(workspaceRoot, competition, candidateId);
|
|
671
|
+
const metadata = await readJsonObject(resolved.metadataPath);
|
|
672
|
+
const metadataSessionId = typeof metadata?.process === "object" && metadata.process !== null
|
|
673
|
+
? metadata.process.session_id
|
|
674
|
+
: undefined;
|
|
675
|
+
if (metadataSessionId === sessionId) {
|
|
676
|
+
return { ...resolved, sessionId };
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
function experimentMetadata(input, resolved, experimentId, metricsPath, extraRefs, session) {
|
|
682
|
+
const now = new Date().toISOString();
|
|
683
|
+
return {
|
|
684
|
+
schema_version: "kaggle-experiment-v1",
|
|
685
|
+
experiment_id: experimentId,
|
|
686
|
+
competition: input.competition,
|
|
687
|
+
workspace_root: resolved.workspaceRoot,
|
|
688
|
+
workspace_state_relative_path: stateRelativePath(resolved.workspaceRoot),
|
|
689
|
+
experiment_dir: resolved.experimentDir,
|
|
690
|
+
experiment_state_relative_path: stateRelativePath(resolved.experimentDir),
|
|
691
|
+
created_at: now,
|
|
692
|
+
updated_at: now,
|
|
693
|
+
command: {
|
|
694
|
+
command: input.command,
|
|
695
|
+
args: input.args,
|
|
696
|
+
env_keys: Object.keys(input.env ?? {}).sort(),
|
|
697
|
+
},
|
|
698
|
+
process: {
|
|
699
|
+
session_id: session.session_id,
|
|
700
|
+
metadata_path: session.metadataPath,
|
|
701
|
+
metadata_state_relative_path: session.metadataPath ? stateRelativePath(session.metadataPath) : undefined,
|
|
702
|
+
},
|
|
703
|
+
strategy_id: input.strategy_id ?? null,
|
|
704
|
+
task_id: input.task_id ?? null,
|
|
705
|
+
artifacts: {
|
|
706
|
+
log: artifactRef(resolved.workspaceRoot, resolved.logPath),
|
|
707
|
+
metrics: artifactRef(resolved.workspaceRoot, metricsPath),
|
|
708
|
+
command: artifactRef(resolved.workspaceRoot, resolved.commandPath),
|
|
709
|
+
process: artifactRef(resolved.workspaceRoot, resolved.processPath),
|
|
710
|
+
child_process: artifactRef(resolved.workspaceRoot, resolved.childProcessPath),
|
|
711
|
+
extra: extraRefs.map((ref) => artifactRef(resolved.workspaceRoot, ref)),
|
|
712
|
+
},
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function artifactRef(workspaceRoot, artifactPath) {
|
|
716
|
+
return {
|
|
717
|
+
path: artifactPath,
|
|
718
|
+
workspace_relative_path: workspaceRelativePath(workspaceRoot, artifactPath),
|
|
719
|
+
state_relative_path: stateRelativePath(artifactPath),
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
async function readMetrics(metricsPath) {
|
|
723
|
+
let raw;
|
|
724
|
+
try {
|
|
725
|
+
raw = await fs.readFile(metricsPath, "utf-8");
|
|
726
|
+
}
|
|
727
|
+
catch (err) {
|
|
728
|
+
if (err.code === "ENOENT") {
|
|
729
|
+
return { ok: false, reason: "missing", message: "metrics.json is missing" };
|
|
730
|
+
}
|
|
731
|
+
throw err;
|
|
732
|
+
}
|
|
733
|
+
try {
|
|
734
|
+
return parseKaggleMetrics(JSON.parse(raw));
|
|
735
|
+
}
|
|
736
|
+
catch (err) {
|
|
737
|
+
return {
|
|
738
|
+
ok: false,
|
|
739
|
+
reason: "malformed",
|
|
740
|
+
message: `metrics.json is not valid JSON: ${err.message}`,
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async function readTail(filePath, maxChars) {
|
|
745
|
+
try {
|
|
746
|
+
const raw = await fs.readFile(filePath, "utf-8");
|
|
747
|
+
return {
|
|
748
|
+
text: raw.length > maxChars ? raw.slice(raw.length - maxChars) : raw,
|
|
749
|
+
truncated: raw.length > maxChars,
|
|
750
|
+
path: filePath,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
catch (err) {
|
|
754
|
+
if (err.code === "ENOENT") {
|
|
755
|
+
return { text: "", truncated: false, path: filePath };
|
|
756
|
+
}
|
|
757
|
+
throw err;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
async function readJsonObject(filePath) {
|
|
761
|
+
try {
|
|
762
|
+
const raw = await fs.readFile(filePath, "utf-8");
|
|
763
|
+
const parsed = JSON.parse(raw);
|
|
764
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
765
|
+
}
|
|
766
|
+
catch {
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
async function readProcessSnapshotFromMetadata(processPath) {
|
|
771
|
+
const localProcess = await readJsonObject(processPath);
|
|
772
|
+
const processMetadataPath = typeof localProcess?.metadataPath === "string" ? localProcess.metadataPath : null;
|
|
773
|
+
if (processMetadataPath) {
|
|
774
|
+
const durable = await readJsonObject(processMetadataPath);
|
|
775
|
+
if (durable)
|
|
776
|
+
return durable;
|
|
777
|
+
}
|
|
778
|
+
return localProcess;
|
|
779
|
+
}
|
|
780
|
+
async function missingPaths(pathsToCheck) {
|
|
781
|
+
const missing = [];
|
|
782
|
+
for (const candidate of pathsToCheck) {
|
|
783
|
+
try {
|
|
784
|
+
await fs.access(candidate);
|
|
785
|
+
}
|
|
786
|
+
catch (err) {
|
|
787
|
+
if (err.code === "ENOENT") {
|
|
788
|
+
missing.push(candidate);
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
throw err;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return missing;
|
|
795
|
+
}
|
|
796
|
+
async function listExperimentIds(workspaceRoot) {
|
|
797
|
+
const experimentsDir = path.join(workspaceRoot, "experiments");
|
|
798
|
+
try {
|
|
799
|
+
const entries = await fs.readdir(experimentsDir, { withFileTypes: true });
|
|
800
|
+
return entries
|
|
801
|
+
.filter((entry) => entry.isDirectory())
|
|
802
|
+
.map((entry) => entry.name)
|
|
803
|
+
.filter((name) => {
|
|
804
|
+
try {
|
|
805
|
+
validateKaggleExperimentId(name);
|
|
806
|
+
return true;
|
|
807
|
+
}
|
|
808
|
+
catch {
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
catch (err) {
|
|
814
|
+
if (err.code === "ENOENT")
|
|
815
|
+
return [];
|
|
816
|
+
throw err;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function experimentIdFromSession(session, workspaceRoot) {
|
|
820
|
+
for (const ref of session.artifactRefs ?? []) {
|
|
821
|
+
const relative = path.relative(path.join(workspaceRoot, "experiments"), path.resolve(ref));
|
|
822
|
+
if (relative.startsWith("..") || path.isAbsolute(relative))
|
|
823
|
+
continue;
|
|
824
|
+
const [experimentId] = relative.split(path.sep);
|
|
825
|
+
if (!experimentId)
|
|
826
|
+
continue;
|
|
827
|
+
try {
|
|
828
|
+
return validateKaggleExperimentId(experimentId);
|
|
829
|
+
}
|
|
830
|
+
catch {
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
function statusFromProcessAndMetrics(processSnapshot, metrics) {
|
|
837
|
+
if (processSnapshot?.running)
|
|
838
|
+
return "running";
|
|
839
|
+
if (metrics?.status === "completed")
|
|
840
|
+
return "completed";
|
|
841
|
+
if (metrics?.status === "failed")
|
|
842
|
+
return "failed";
|
|
843
|
+
if (processSnapshot && processSnapshot.exitCode !== null) {
|
|
844
|
+
return processSnapshot.exitCode === 0 ? "completed" : "failed";
|
|
845
|
+
}
|
|
846
|
+
return "unknown";
|
|
847
|
+
}
|
|
848
|
+
function confidenceForMetrics(metrics) {
|
|
849
|
+
return metrics.status === "completed" && metrics.cv_std !== null && metrics.valid_rows > 0 ? "high" : "medium";
|
|
850
|
+
}
|
|
851
|
+
function generateExperimentId() {
|
|
852
|
+
const timestamp = new Date().toISOString()
|
|
853
|
+
.replace(/[-:]/g, "")
|
|
854
|
+
.replace(/\.\d{3}Z$/, "Z");
|
|
855
|
+
return `exp-${timestamp}`;
|
|
856
|
+
}
|
|
857
|
+
function teeWrapperArgs(command, args, logPath) {
|
|
858
|
+
const script = `
|
|
859
|
+
const { spawn } = require("node:child_process");
|
|
860
|
+
const fs = require("node:fs");
|
|
861
|
+
const path = require("node:path");
|
|
862
|
+
const command = process.argv[1];
|
|
863
|
+
const args = JSON.parse(process.argv[2]);
|
|
864
|
+
const logPath = process.argv[3];
|
|
865
|
+
const childProcessPath = process.argv[4];
|
|
866
|
+
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
867
|
+
const log = fs.createWriteStream(logPath, { flags: "a" });
|
|
868
|
+
const child = spawn(command, args, { cwd: process.cwd(), env: process.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
869
|
+
fs.writeFileSync(childProcessPath, JSON.stringify({ pid: child.pid, command, args, startedAt: new Date().toISOString() }, null, 2));
|
|
870
|
+
let exiting = false;
|
|
871
|
+
const write = (stream, chunk) => {
|
|
872
|
+
stream.write(chunk);
|
|
873
|
+
log.write(chunk);
|
|
874
|
+
};
|
|
875
|
+
const forwardSignal = (signal) => {
|
|
876
|
+
if (exiting) return;
|
|
877
|
+
exiting = true;
|
|
878
|
+
if (child.exitCode === null && !child.killed) {
|
|
879
|
+
child.kill(signal);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"]) {
|
|
883
|
+
process.on(signal, () => forwardSignal(signal));
|
|
884
|
+
}
|
|
885
|
+
child.stdout.on("data", (chunk) => write(process.stdout, chunk));
|
|
886
|
+
child.stderr.on("data", (chunk) => write(process.stderr, chunk));
|
|
887
|
+
child.on("error", (err) => {
|
|
888
|
+
const msg = "[kaggle experiment process error] " + err.message + "\\n";
|
|
889
|
+
process.stderr.write(msg);
|
|
890
|
+
log.write(msg);
|
|
891
|
+
});
|
|
892
|
+
child.on("exit", (code, signal) => {
|
|
893
|
+
const msg = "[kaggle experiment exited code=" + (code ?? "null") + " signal=" + (signal ?? "null") + "]\\n";
|
|
894
|
+
log.write(msg, () => process.exit(code ?? 1));
|
|
895
|
+
});
|
|
896
|
+
`;
|
|
897
|
+
const childProcessPath = path.join(path.dirname(logPath), "child-process.json");
|
|
898
|
+
return ["-e", script, command, JSON.stringify(args), logPath, childProcessPath];
|
|
899
|
+
}
|
|
900
|
+
function failureResult(message, startTime) {
|
|
901
|
+
return {
|
|
902
|
+
success: false,
|
|
903
|
+
data: null,
|
|
904
|
+
summary: message,
|
|
905
|
+
error: message,
|
|
906
|
+
durationMs: Date.now() - startTime,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
async function signalKaggleChildProcess(childProcessPath, signal) {
|
|
910
|
+
const childProcess = await readJsonObject(childProcessPath);
|
|
911
|
+
const pid = typeof childProcess?.pid === "number" ? childProcess.pid : null;
|
|
912
|
+
if (!pid)
|
|
913
|
+
return;
|
|
914
|
+
try {
|
|
915
|
+
process.kill(pid, signal);
|
|
916
|
+
}
|
|
917
|
+
catch (err) {
|
|
918
|
+
if (err.code !== "ESRCH") {
|
|
919
|
+
throw err;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
//# sourceMappingURL=KaggleExperimentTools.js.map
|