@caupulican/pi-adaptative 0.81.38 → 0.81.40
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/CHANGELOG.md +131 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +133 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +198 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +311 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +31 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +823 -79
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +1043 -86
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +7 -7
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +66 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +170 -0
- package/dist/core/agent-paths.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +397 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +4 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +255 -103
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +754 -1173
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +26 -9
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +46 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +24 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +43 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +90 -156
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +192 -968
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +24 -13
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +26 -6
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +146 -18
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +56 -0
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/worker-claim.js +239 -0
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +68 -13
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +101 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +52 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +25 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +93 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +87 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +5 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +56 -15
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +20 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +17 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +105 -4
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +91 -6
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +90 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +78 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +58 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +82 -6
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +13 -6
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +20 -28
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +27 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -8
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +43 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +6 -9
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +4 -4
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +10 -5
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +129 -81
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +4 -11
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +87 -51
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +6 -5
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +197 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +83 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +78 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +633 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +25 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +189 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +75 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +161 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +25 -7
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +33 -9
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +217 -127
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +50 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +15 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +225 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +76 -17
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +367 -124
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +64 -27
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +28 -1
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +33 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +58 -0
- package/dist/core/session-role.js.map +1 -0
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/settings-manager.d.ts +51 -7
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +168 -82
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +13 -6
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +20 -22
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +12 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +56 -12
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +85 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +91 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +6 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +13 -31
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +39 -6
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +153 -110
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +95 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +44 -2
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +214 -19
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +124 -22
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +4 -4
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +43 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +168 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -2
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +6 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +165 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +84 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +151 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +252 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +179 -1
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +7 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +197 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +76 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +67 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +74 -21
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -6
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +112 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +153 -0
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +128 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +92 -2
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +7 -0
- package/docs/ui-reference/orchestration-before.txt +7 -0
- package/docs/ui-reference/orchestration-reference.txt +6 -0
- package/docs/usage.md +14 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +42 -2
- package/docs/worktree-sync.md +250 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +10 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -16
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -53
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts +0 -15
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js +0 -161
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { stateFile } from "../agent-paths.js";
|
|
2
|
+
import { isWorkerSession } from "../session-role.js";
|
|
3
|
+
import { isRecordObject } from "../util/value-guards.js";
|
|
4
|
+
import { HostStateStore, isHostFingerprint } from "./host-state-store.js";
|
|
4
5
|
import { hasUsableModelPerfSample, isModelPerfProfile, updateModelPerfProfile, } from "./perf-profile.js";
|
|
5
6
|
const STORE_VERSION = 1;
|
|
6
7
|
const MAX_RULES_PER_MODEL = 5;
|
|
@@ -14,21 +15,18 @@ function normalizeProfile(profile) {
|
|
|
14
15
|
...(isProtocol(profile?.protocol) && { protocol: profile.protocol }),
|
|
15
16
|
...(isToolProbe(profile?.toolProbe) && { toolProbe: profile.toolProbe }),
|
|
16
17
|
...(isModelPerfProfile(profile?.perf) && { perf: profile.perf }),
|
|
17
|
-
teachStats:
|
|
18
|
+
teachStats: isRecordObject(profile?.teachStats) ? filterTeachStats(profile.teachStats) : {},
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
function isRecord(value) {
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
-
}
|
|
23
21
|
function isRule(value) {
|
|
24
|
-
return (
|
|
22
|
+
return (isRecordObject(value) &&
|
|
25
23
|
typeof value.mode === "string" &&
|
|
26
24
|
typeof value.text === "string" &&
|
|
27
25
|
typeof value.addedAt === "string" &&
|
|
28
26
|
typeof value.lastFiredAt === "string");
|
|
29
27
|
}
|
|
30
28
|
function isProtocol(value) {
|
|
31
|
-
if (!
|
|
29
|
+
if (!isRecordObject(value) || typeof value.version !== "number")
|
|
32
30
|
return false;
|
|
33
31
|
if (value.status === "failed") {
|
|
34
32
|
return (typeof value.attemptedAt === "string" &&
|
|
@@ -40,7 +38,7 @@ function isProtocol(value) {
|
|
|
40
38
|
typeof value.calibratedAt === "string");
|
|
41
39
|
}
|
|
42
40
|
function isToolProbe(value) {
|
|
43
|
-
return (
|
|
41
|
+
return (isRecordObject(value) &&
|
|
44
42
|
typeof value.version === "number" &&
|
|
45
43
|
(value.status === "native" || value.status === "text-protocol" || value.status === "none") &&
|
|
46
44
|
typeof value.probedAt === "string" &&
|
|
@@ -52,7 +50,7 @@ function isToolProbe(value) {
|
|
|
52
50
|
(value.diagnostic === undefined || typeof value.diagnostic === "string"));
|
|
53
51
|
}
|
|
54
52
|
function isTeachStats(value) {
|
|
55
|
-
return (
|
|
53
|
+
return (isRecordObject(value) &&
|
|
56
54
|
typeof value.taught === "number" &&
|
|
57
55
|
typeof value.recurrenceBefore === "number" &&
|
|
58
56
|
typeof value.recurrenceAfter === "number");
|
|
@@ -67,9 +65,32 @@ function ruleRecency(rule) {
|
|
|
67
65
|
const added = Date.parse(rule.addedAt);
|
|
68
66
|
return Number.isFinite(added) ? added : 0;
|
|
69
67
|
}
|
|
70
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Minimum post-rule recurrences before efficacy can retire a rule early — a single relapse is
|
|
70
|
+
* noise, not proof the rule stopped working.
|
|
71
|
+
*/
|
|
72
|
+
const MIN_RECURRENCE_AFTER_FOR_EFFICACY = 2;
|
|
73
|
+
/**
|
|
74
|
+
* Efficacy-based early retirement. `agent-session.ts`'s `_handleModelAdaptationTelemetry` bumps
|
|
75
|
+
* `recurrenceBefore` each time a failure mode recurs BEFORE a standing rule exists for it (the
|
|
76
|
+
* baseline that earned the rule), then switches to bumping `recurrenceAfter` each time the SAME mode
|
|
77
|
+
* recurs AFTER the rule fired. So a rule that is actually working keeps `recurrenceAfter` low relative
|
|
78
|
+
* to its own pre-rule baseline; a rule that has caught up to (or exceeded) that baseline has
|
|
79
|
+
* demonstrably stopped reducing recurrence and should retire before the time-based outer bound.
|
|
80
|
+
*/
|
|
81
|
+
function isRuleEffective(stats) {
|
|
82
|
+
if (!stats || stats.recurrenceAfter < MIN_RECURRENCE_AFTER_FOR_EFFICACY)
|
|
83
|
+
return true; // not enough post-rule evidence yet
|
|
84
|
+
return stats.recurrenceAfter < stats.recurrenceBefore;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Prune rules past the time-based outer bound (`RETIRE_AFTER_MS`, always enforced) OR past efficacy
|
|
88
|
+
* (a rule that stopped reducing recurrence retires early; a rule that keeps helping persists until
|
|
89
|
+
* the outer bound).
|
|
90
|
+
*/
|
|
91
|
+
function pruneRetiredRules(rules, teachStats, now) {
|
|
71
92
|
const cutoff = now.getTime() - RETIRE_AFTER_MS;
|
|
72
|
-
return rules.filter((rule) => ruleRecency(rule) >= cutoff);
|
|
93
|
+
return rules.filter((rule) => ruleRecency(rule) >= cutoff && isRuleEffective(teachStats[rule.mode]));
|
|
73
94
|
}
|
|
74
95
|
function enforceRuleCap(rules) {
|
|
75
96
|
if (rules.length <= MAX_RULES_PER_MODEL)
|
|
@@ -80,41 +101,69 @@ function mergeRule(rules, rule) {
|
|
|
80
101
|
const withoutSameMode = rules.filter((existing) => existing.mode !== rule.mode);
|
|
81
102
|
return enforceRuleCap([...withoutSameMode, rule]);
|
|
82
103
|
}
|
|
104
|
+
function parseAdaptationHost(value, hostId) {
|
|
105
|
+
if (!isRecordObject(value))
|
|
106
|
+
return undefined;
|
|
107
|
+
const profiles = {};
|
|
108
|
+
for (const [model, candidate] of Object.entries(value)) {
|
|
109
|
+
if (!isRecordObject(candidate) ||
|
|
110
|
+
candidate.model !== model ||
|
|
111
|
+
typeof candidate.at !== "string" ||
|
|
112
|
+
!isHostFingerprint(candidate.host) ||
|
|
113
|
+
candidate.host.id !== hostId ||
|
|
114
|
+
!isRecordObject(candidate.profile))
|
|
115
|
+
continue;
|
|
116
|
+
profiles[model] = {
|
|
117
|
+
model,
|
|
118
|
+
profile: normalizeProfile(candidate.profile),
|
|
119
|
+
at: candidate.at,
|
|
120
|
+
host: candidate.host,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return profiles;
|
|
124
|
+
}
|
|
83
125
|
export class ModelAdaptationStore {
|
|
84
|
-
|
|
85
|
-
fingerprint;
|
|
126
|
+
storage;
|
|
86
127
|
constructor(filePath, options) {
|
|
87
|
-
this.
|
|
88
|
-
|
|
128
|
+
this.storage = new HostStateStore({
|
|
129
|
+
filePath,
|
|
130
|
+
version: STORE_VERSION,
|
|
131
|
+
fingerprint: options?.fingerprint,
|
|
132
|
+
readOnly: options?.readOnly ?? isWorkerSession(),
|
|
133
|
+
parseHost: parseAdaptationHost,
|
|
134
|
+
});
|
|
89
135
|
}
|
|
90
136
|
static forAgentDir(agentDir, options) {
|
|
91
|
-
return new ModelAdaptationStore(
|
|
92
|
-
}
|
|
93
|
-
load() {
|
|
94
|
-
try {
|
|
95
|
-
if (!existsSync(this.filePath))
|
|
96
|
-
return { version: STORE_VERSION, hosts: {} };
|
|
97
|
-
const parsed = JSON.parse(readFileSync(this.filePath, "utf-8"));
|
|
98
|
-
if (parsed && parsed.version === STORE_VERSION && parsed.hosts && typeof parsed.hosts === "object") {
|
|
99
|
-
return parsed;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Unreadable/corrupt store: start fresh in memory; the next save rewrites the file.
|
|
104
|
-
}
|
|
105
|
-
return { version: STORE_VERSION, hosts: {} };
|
|
106
|
-
}
|
|
107
|
-
write(file) {
|
|
108
|
-
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
109
|
-
writeFileSync(this.filePath, `${JSON.stringify(file, null, "\t")}\n`, "utf-8");
|
|
137
|
+
return new ModelAdaptationStore(stateFile(agentDir, "model-adaptation.json"), options);
|
|
110
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Load-mutate-write under a single exclusive lock so two concurrent stores (e.g. two sessions
|
|
141
|
+
* sharing an agentDir) can't both read the old file and clobber each other's write.
|
|
142
|
+
*/
|
|
111
143
|
store(model, profile, at) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
144
|
+
return this.storage.mutateCurrentHost(() => ({}), (profiles, host) => {
|
|
145
|
+
const entry = { model, profile: normalizeProfile(profile), at, host };
|
|
146
|
+
profiles[model] = entry;
|
|
147
|
+
return { result: entry, changed: true };
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** Keep the complete profile read-modify-write transaction under the host-state lock. */
|
|
151
|
+
mutateProfile(model, now, mutate, storedAt = now.toISOString()) {
|
|
152
|
+
return this.storage.mutateCurrentHost(() => ({}), (profiles, host) => {
|
|
153
|
+
const current = normalizeProfile(profiles[model]?.profile);
|
|
154
|
+
const activeRules = pruneRetiredRules(current.rules, current.teachStats, now);
|
|
155
|
+
const pruned = activeRules.length !== current.rules.length;
|
|
156
|
+
const active = pruned ? { ...current, rules: activeRules } : current;
|
|
157
|
+
const requested = mutate(active);
|
|
158
|
+
const applied = requested !== undefined;
|
|
159
|
+
if (!applied && !pruned) {
|
|
160
|
+
return { result: { profile: active, applied: false }, changed: false };
|
|
161
|
+
}
|
|
162
|
+
const profile = normalizeProfile(requested ?? active);
|
|
163
|
+
const entry = { model, profile, at: storedAt, host };
|
|
164
|
+
profiles[model] = entry;
|
|
165
|
+
return { result: { profile, entry, applied }, changed: true };
|
|
166
|
+
});
|
|
118
167
|
}
|
|
119
168
|
/** Persist the profile for a model on the CURRENT host. Best-effort, returns the entry. */
|
|
120
169
|
save(model, profile, at) {
|
|
@@ -122,21 +171,18 @@ export class ModelAdaptationStore {
|
|
|
122
171
|
}
|
|
123
172
|
/** Profile for a model on the current host; prunes retired rules before returning. */
|
|
124
173
|
get(model, now = new Date()) {
|
|
125
|
-
const
|
|
126
|
-
const file = this.load();
|
|
127
|
-
const entry = file.hosts[host.id]?.[model];
|
|
174
|
+
const entry = this.storage.getHost()?.[model];
|
|
128
175
|
if (!entry)
|
|
129
176
|
return emptyProfile();
|
|
130
177
|
const profile = normalizeProfile(entry.profile);
|
|
131
|
-
const prunedRules = pruneRetiredRules(profile.rules, now);
|
|
178
|
+
const prunedRules = pruneRetiredRules(profile.rules, profile.teachStats, now);
|
|
132
179
|
if (prunedRules.length !== profile.rules.length) {
|
|
133
|
-
return this.
|
|
180
|
+
return this.mutateProfile(model, now, () => undefined).profile;
|
|
134
181
|
}
|
|
135
182
|
return profile;
|
|
136
183
|
}
|
|
137
184
|
/** Add or replace one standing rule, enforcing the per-model cap. */
|
|
138
185
|
addRule(model, rule, now = new Date()) {
|
|
139
|
-
const profile = this.get(model, now);
|
|
140
186
|
const at = now.toISOString();
|
|
141
187
|
const nextRule = {
|
|
142
188
|
mode: rule.mode,
|
|
@@ -144,69 +190,71 @@ export class ModelAdaptationStore {
|
|
|
144
190
|
addedAt: rule.addedAt ?? at,
|
|
145
191
|
lastFiredAt: rule.lastFiredAt ?? at,
|
|
146
192
|
};
|
|
147
|
-
|
|
193
|
+
const result = this.mutateProfile(model, now, (profile) => ({
|
|
194
|
+
...profile,
|
|
195
|
+
rules: mergeRule(profile.rules, nextRule),
|
|
196
|
+
}));
|
|
197
|
+
return result.entry;
|
|
148
198
|
}
|
|
149
199
|
removeRule(model, mode, at = new Date()) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.store(model, { ...profile, rules }, at.toISOString());
|
|
155
|
-
return true;
|
|
200
|
+
return this.mutateProfile(model, at, (profile) => {
|
|
201
|
+
const rules = profile.rules.filter((rule) => rule.mode !== mode);
|
|
202
|
+
return rules.length === profile.rules.length ? undefined : { ...profile, rules };
|
|
203
|
+
}).applied;
|
|
156
204
|
}
|
|
157
205
|
/** Update last-fired recency for an existing rule. No-op when absent. */
|
|
158
206
|
markRuleFired(model, mode, at = new Date()) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return
|
|
207
|
+
const result = this.mutateProfile(model, at, (profile) => {
|
|
208
|
+
const rules = profile.rules.map((rule) => rule.mode === mode ? { ...rule, lastFiredAt: at.toISOString() } : rule);
|
|
209
|
+
return rules.every((rule, index) => rule === profile.rules[index]) ? undefined : { ...profile, rules };
|
|
210
|
+
});
|
|
211
|
+
return result.applied ? result.entry : undefined;
|
|
164
212
|
}
|
|
165
213
|
setProtocol(model, protocol, at) {
|
|
166
214
|
const now = at ?? (protocol.status === "failed" ? protocol.attemptedAt : protocol.calibratedAt);
|
|
167
|
-
|
|
168
|
-
return this.store(model, { ...profile, protocol }, now);
|
|
215
|
+
return this.mutateProfile(model, new Date(now), (profile) => ({ ...profile, protocol }), now).entry;
|
|
169
216
|
}
|
|
170
217
|
setToolProbe(model, toolProbe, at) {
|
|
171
218
|
const now = at ?? toolProbe.probedAt;
|
|
172
|
-
|
|
173
|
-
return this.store(model, { ...profile, toolProbe }, now);
|
|
219
|
+
return this.mutateProfile(model, new Date(now), (profile) => ({ ...profile, toolProbe }), now).entry;
|
|
174
220
|
}
|
|
175
221
|
recordPerfSample(model, sample, at) {
|
|
176
222
|
if (!hasUsableModelPerfSample(sample))
|
|
177
223
|
return undefined;
|
|
178
224
|
const now = at ?? sample.at ?? new Date().toISOString();
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return
|
|
225
|
+
const result = this.mutateProfile(model, new Date(now), (profile) => {
|
|
226
|
+
const perf = updateModelPerfProfile(profile.perf, sample, now);
|
|
227
|
+
return perf ? { ...profile, perf } : undefined;
|
|
228
|
+
}, now);
|
|
229
|
+
return result.applied ? result.entry : undefined;
|
|
184
230
|
}
|
|
185
231
|
removeProtocol(model, at = new Date()) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
232
|
+
return this.mutateProfile(model, at, (profile) => {
|
|
233
|
+
if (!profile.protocol)
|
|
234
|
+
return undefined;
|
|
235
|
+
const { protocol: _protocol, ...rest } = profile;
|
|
236
|
+
return rest;
|
|
237
|
+
}).applied;
|
|
192
238
|
}
|
|
193
239
|
setTeachStats(model, mode, stats, at) {
|
|
194
240
|
const now = at ?? new Date().toISOString();
|
|
195
|
-
|
|
196
|
-
|
|
241
|
+
return this.mutateProfile(model, new Date(now), (profile) => ({
|
|
242
|
+
...profile,
|
|
243
|
+
teachStats: { ...profile.teachStats, [mode]: stats },
|
|
244
|
+
}), now).entry;
|
|
197
245
|
}
|
|
198
246
|
/** Profiles for the current host (default) or an explicit host id. */
|
|
199
247
|
getForHost(hostId) {
|
|
200
|
-
|
|
201
|
-
return Object.values(file.hosts[hostId ?? this.fingerprint().id] ?? {}).map((entry) => ({
|
|
248
|
+
return Object.values(this.storage.getHost(hostId) ?? {}).map((entry) => ({
|
|
202
249
|
...entry,
|
|
203
250
|
profile: normalizeProfile(entry.profile),
|
|
204
251
|
}));
|
|
205
252
|
}
|
|
206
253
|
/** Every stored profile across all hosts (for cross-machine comparisons). */
|
|
207
254
|
getAll() {
|
|
208
|
-
|
|
209
|
-
|
|
255
|
+
return this.storage
|
|
256
|
+
.getAllHosts()
|
|
257
|
+
.flatMap((models) => Object.values(models).map((entry) => ({ ...entry, profile: normalizeProfile(entry.profile) })));
|
|
210
258
|
}
|
|
211
259
|
}
|
|
212
260
|
//# sourceMappingURL=adaptation-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptation-store.js","sourceRoot":"","sources":["../../../src/core/models/adaptation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAwB,MAAM,oBAAoB,CAAC;AAClF,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAGlB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA8DjD,SAAS,YAAY,GAA2B;IAC/C,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AAAA,CACrC;AAED,SAAS,gBAAgB,CAAC,OAAoD,EAA0B;IACvG,OAAO;QACN,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACxE,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpE,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QACxE,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACnD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAC9F,CAAC;IAAA,CACF;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { currentHostFingerprint, type HostFingerprint } from \"./fitness-store.ts\";\nimport {\n\thasUsableModelPerfSample,\n\tisModelPerfProfile,\n\ttype ModelPerfProfile,\n\ttype ModelPerfSample,\n\tupdateModelPerfProfile,\n} from \"./perf-profile.ts\";\n\nconst STORE_VERSION = 1;\nconst MAX_RULES_PER_MODEL = 5;\nconst RETIRE_AFTER_MS = 30 * 24 * 60 * 60 * 1000;\n\nexport interface ModelAdaptationRule {\n\tmode: string;\n\ttext: string;\n\taddedAt: string;\n\tlastFiredAt: string;\n}\n\nexport type ModelProtocolCalibration =\n\t| {\n\t\t\tversion: number;\n\t\t\tstatus?: \"calibrated\";\n\t\t\tvariant: string;\n\t\t\tcalibratedAt: string;\n\t }\n\t| {\n\t\t\tversion: number;\n\t\t\tstatus: \"failed\";\n\t\t\tattemptedAt: string;\n\t\t\tvariantsTried: string[];\n\t };\n\nexport type ModelToolProbeVerdict = \"native\" | \"text-protocol\" | \"none\";\nexport type NativeToolProbeGrade = \"task\" | \"echo-only\" | \"absent\";\n\nexport interface ModelToolProbe {\n\tversion: number;\n\tstatus: ModelToolProbeVerdict;\n\tprobedAt: string;\n\tvariant?: string;\n\tnativeGrade?: NativeToolProbeGrade;\n\tdiagnostic?: string;\n}\n\nexport interface ModelTeachStats {\n\ttaught: number;\n\trecurrenceBefore: number;\n\trecurrenceAfter: number;\n}\n\nexport interface ModelAdaptationProfile {\n\trules: ModelAdaptationRule[];\n\tprotocol?: ModelProtocolCalibration;\n\ttoolProbe?: ModelToolProbe;\n\tperf?: ModelPerfProfile;\n\tteachStats: Record<string, ModelTeachStats>;\n}\n\nexport interface StoredModelAdaptation {\n\tmodel: string;\n\tprofile: ModelAdaptationProfile;\n\tat: string;\n\thost: HostFingerprint;\n}\n\ninterface AdaptationStoreFile {\n\tversion: 1;\n\t/** hostId -> modelRef -> latest stored adaptation profile. */\n\thosts: Record<string, Record<string, StoredModelAdaptation>>;\n}\n\nfunction emptyProfile(): ModelAdaptationProfile {\n\treturn { rules: [], teachStats: {} };\n}\n\nfunction normalizeProfile(profile: Partial<ModelAdaptationProfile> | undefined): ModelAdaptationProfile {\n\treturn {\n\t\trules: Array.isArray(profile?.rules) ? profile.rules.filter(isRule) : [],\n\t\t...(isProtocol(profile?.protocol) && { protocol: profile.protocol }),\n\t\t...(isToolProbe(profile?.toolProbe) && { toolProbe: profile.toolProbe }),\n\t\t...(isModelPerfProfile(profile?.perf) && { perf: profile.perf }),\n\t\tteachStats: isRecord(profile?.teachStats) ? filterTeachStats(profile.teachStats) : {},\n\t};\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isRule(value: unknown): value is ModelAdaptationRule {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value.mode === \"string\" &&\n\t\ttypeof value.text === \"string\" &&\n\t\ttypeof value.addedAt === \"string\" &&\n\t\ttypeof value.lastFiredAt === \"string\"\n\t);\n}\n\nfunction isProtocol(value: unknown): value is ModelProtocolCalibration {\n\tif (!isRecord(value) || typeof value.version !== \"number\") return false;\n\tif (value.status === \"failed\") {\n\t\treturn (\n\t\t\ttypeof value.attemptedAt === \"string\" &&\n\t\t\tArray.isArray(value.variantsTried) &&\n\t\t\tvalue.variantsTried.every((variant) => typeof variant === \"string\")\n\t\t);\n\t}\n\treturn (\n\t\t(value.status === undefined || value.status === \"calibrated\") &&\n\t\ttypeof value.variant === \"string\" &&\n\t\ttypeof value.calibratedAt === \"string\"\n\t);\n}\n\nfunction isToolProbe(value: unknown): value is ModelToolProbe {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value.version === \"number\" &&\n\t\t(value.status === \"native\" || value.status === \"text-protocol\" || value.status === \"none\") &&\n\t\ttypeof value.probedAt === \"string\" &&\n\t\t(value.variant === undefined || typeof value.variant === \"string\") &&\n\t\t(value.nativeGrade === undefined ||\n\t\t\tvalue.nativeGrade === \"task\" ||\n\t\t\tvalue.nativeGrade === \"echo-only\" ||\n\t\t\tvalue.nativeGrade === \"absent\") &&\n\t\t(value.diagnostic === undefined || typeof value.diagnostic === \"string\")\n\t);\n}\n\nfunction isTeachStats(value: unknown): value is ModelTeachStats {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value.taught === \"number\" &&\n\t\ttypeof value.recurrenceBefore === \"number\" &&\n\t\ttypeof value.recurrenceAfter === \"number\"\n\t);\n}\n\nfunction filterTeachStats(value: Record<string, unknown>): Record<string, ModelTeachStats> {\n\treturn Object.fromEntries(\n\t\tObject.entries(value).filter((entry): entry is [string, ModelTeachStats] => isTeachStats(entry[1])),\n\t);\n}\n\nfunction ruleRecency(rule: ModelAdaptationRule): number {\n\tconst lastFired = Date.parse(rule.lastFiredAt);\n\tif (Number.isFinite(lastFired)) return lastFired;\n\tconst added = Date.parse(rule.addedAt);\n\treturn Number.isFinite(added) ? added : 0;\n}\n\nfunction pruneRetiredRules(rules: readonly ModelAdaptationRule[], now: Date): ModelAdaptationRule[] {\n\tconst cutoff = now.getTime() - RETIRE_AFTER_MS;\n\treturn rules.filter((rule) => ruleRecency(rule) >= cutoff);\n}\n\nfunction enforceRuleCap(rules: readonly ModelAdaptationRule[]): ModelAdaptationRule[] {\n\tif (rules.length <= MAX_RULES_PER_MODEL) return [...rules];\n\treturn [...rules].sort((a, b) => ruleRecency(b) - ruleRecency(a)).slice(0, MAX_RULES_PER_MODEL);\n}\n\nfunction mergeRule(rules: readonly ModelAdaptationRule[], rule: ModelAdaptationRule): ModelAdaptationRule[] {\n\tconst withoutSameMode = rules.filter((existing) => existing.mode !== rule.mode);\n\treturn enforceRuleCap([...withoutSameMode, rule]);\n}\n\nexport class ModelAdaptationStore {\n\tprivate readonly filePath: string;\n\tprivate readonly fingerprint: () => HostFingerprint;\n\n\tconstructor(filePath: string, options?: { fingerprint?: () => HostFingerprint }) {\n\t\tthis.filePath = filePath;\n\t\tthis.fingerprint = options?.fingerprint ?? currentHostFingerprint;\n\t}\n\n\tstatic forAgentDir(agentDir: string, options?: { fingerprint?: () => HostFingerprint }): ModelAdaptationStore {\n\t\treturn new ModelAdaptationStore(join(agentDir, \"state\", \"model-adaptation.json\"), options);\n\t}\n\n\tprivate load(): AdaptationStoreFile {\n\t\ttry {\n\t\t\tif (!existsSync(this.filePath)) return { version: STORE_VERSION, hosts: {} };\n\t\t\tconst parsed = JSON.parse(readFileSync(this.filePath, \"utf-8\")) as AdaptationStoreFile;\n\t\t\tif (parsed && parsed.version === STORE_VERSION && parsed.hosts && typeof parsed.hosts === \"object\") {\n\t\t\t\treturn parsed;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Unreadable/corrupt store: start fresh in memory; the next save rewrites the file.\n\t\t}\n\t\treturn { version: STORE_VERSION, hosts: {} };\n\t}\n\n\tprivate write(file: AdaptationStoreFile): void {\n\t\tmkdirSync(dirname(this.filePath), { recursive: true });\n\t\twriteFileSync(this.filePath, `${JSON.stringify(file, null, \"\\t\")}\\n`, \"utf-8\");\n\t}\n\n\tprivate store(model: string, profile: ModelAdaptationProfile, at: string): StoredModelAdaptation {\n\t\tconst host = this.fingerprint();\n\t\tconst entry: StoredModelAdaptation = { model, profile: normalizeProfile(profile), at, host };\n\t\tconst file = this.load();\n\t\tfile.hosts[host.id] = { ...(file.hosts[host.id] ?? {}), [model]: entry };\n\t\tthis.write(file);\n\t\treturn entry;\n\t}\n\n\t/** Persist the profile for a model on the CURRENT host. Best-effort, returns the entry. */\n\tsave(model: string, profile: ModelAdaptationProfile, at?: string): StoredModelAdaptation {\n\t\treturn this.store(model, profile, at ?? new Date().toISOString());\n\t}\n\n\t/** Profile for a model on the current host; prunes retired rules before returning. */\n\tget(model: string, now: Date = new Date()): ModelAdaptationProfile {\n\t\tconst host = this.fingerprint();\n\t\tconst file = this.load();\n\t\tconst entry = file.hosts[host.id]?.[model];\n\t\tif (!entry) return emptyProfile();\n\t\tconst profile = normalizeProfile(entry.profile);\n\t\tconst prunedRules = pruneRetiredRules(profile.rules, now);\n\t\tif (prunedRules.length !== profile.rules.length) {\n\t\t\treturn this.store(model, { ...profile, rules: prunedRules }, now.toISOString()).profile;\n\t\t}\n\t\treturn profile;\n\t}\n\n\t/** Add or replace one standing rule, enforcing the per-model cap. */\n\taddRule(\n\t\tmodel: string,\n\t\trule: { mode: string; text: string; addedAt?: string; lastFiredAt?: string },\n\t\tnow = new Date(),\n\t): StoredModelAdaptation {\n\t\tconst profile = this.get(model, now);\n\t\tconst at = now.toISOString();\n\t\tconst nextRule: ModelAdaptationRule = {\n\t\t\tmode: rule.mode,\n\t\t\ttext: rule.text,\n\t\t\taddedAt: rule.addedAt ?? at,\n\t\t\tlastFiredAt: rule.lastFiredAt ?? at,\n\t\t};\n\t\treturn this.store(model, { ...profile, rules: mergeRule(profile.rules, nextRule) }, at);\n\t}\n\n\tremoveRule(model: string, mode: string, at = new Date()): boolean {\n\t\tconst profile = this.get(model, at);\n\t\tconst rules = profile.rules.filter((rule) => rule.mode !== mode);\n\t\tif (rules.length === profile.rules.length) return false;\n\t\tthis.store(model, { ...profile, rules }, at.toISOString());\n\t\treturn true;\n\t}\n\n\t/** Update last-fired recency for an existing rule. No-op when absent. */\n\tmarkRuleFired(model: string, mode: string, at = new Date()): StoredModelAdaptation | undefined {\n\t\tconst profile = this.get(model, at);\n\t\tconst rules = profile.rules.map((rule) =>\n\t\t\trule.mode === mode ? { ...rule, lastFiredAt: at.toISOString() } : rule,\n\t\t);\n\t\tif (rules.every((rule, index) => rule === profile.rules[index])) return undefined;\n\t\treturn this.store(model, { ...profile, rules }, at.toISOString());\n\t}\n\n\tsetProtocol(model: string, protocol: ModelProtocolCalibration, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? (protocol.status === \"failed\" ? protocol.attemptedAt : protocol.calibratedAt);\n\t\tconst profile = this.get(model, new Date(now));\n\t\treturn this.store(model, { ...profile, protocol }, now);\n\t}\n\n\tsetToolProbe(model: string, toolProbe: ModelToolProbe, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? toolProbe.probedAt;\n\t\tconst profile = this.get(model, new Date(now));\n\t\treturn this.store(model, { ...profile, toolProbe }, now);\n\t}\n\n\trecordPerfSample(model: string, sample: ModelPerfSample, at?: string): StoredModelAdaptation | undefined {\n\t\tif (!hasUsableModelPerfSample(sample)) return undefined;\n\t\tconst now = at ?? sample.at ?? new Date().toISOString();\n\t\tconst profile = this.get(model, new Date(now));\n\t\tconst perf = updateModelPerfProfile(profile.perf, sample, now);\n\t\tif (!perf) return undefined;\n\t\treturn this.store(model, { ...profile, perf }, now);\n\t}\n\n\tremoveProtocol(model: string, at = new Date()): boolean {\n\t\tconst profile = this.get(model, at);\n\t\tif (!profile.protocol) return false;\n\t\tconst { protocol: _protocol, ...rest } = profile;\n\t\tthis.store(model, rest, at.toISOString());\n\t\treturn true;\n\t}\n\n\tsetTeachStats(model: string, mode: string, stats: ModelTeachStats, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? new Date().toISOString();\n\t\tconst profile = this.get(model, new Date(now));\n\t\treturn this.store(model, { ...profile, teachStats: { ...profile.teachStats, [mode]: stats } }, now);\n\t}\n\n\t/** Profiles for the current host (default) or an explicit host id. */\n\tgetForHost(hostId?: string): StoredModelAdaptation[] {\n\t\tconst file = this.load();\n\t\treturn Object.values(file.hosts[hostId ?? this.fingerprint().id] ?? {}).map((entry) => ({\n\t\t\t...entry,\n\t\t\tprofile: normalizeProfile(entry.profile),\n\t\t}));\n\t}\n\n\t/** Every stored profile across all hosts (for cross-machine comparisons). */\n\tgetAll(): StoredModelAdaptation[] {\n\t\tconst file = this.load();\n\t\treturn Object.values(file.hosts).flatMap((models) =>\n\t\t\tObject.values(models).map((entry) => ({ ...entry, profile: normalizeProfile(entry.profile) })),\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"adaptation-store.js","sourceRoot":"","sources":["../../../src/core/models/adaptation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAwB,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAGlB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AA8DjD,SAAS,YAAY,GAA2B;IAC/C,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AAAA,CACrC;AAED,SAAS,gBAAgB,CAAC,OAAoD,EAA0B;IACvG,OAAO;QACN,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACxE,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpE,GAAG,CAAC,WAAW,CAAC,OAAO,EA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IAED,6EAA6E;IAC7E,MAAM,GAA4B;QACjC,OAAO,IAAI,CAAC,OAAO;aACjB,WAAW,EAAE;aACb,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACnB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAC9F,CAAC;IAAA,CACH;CACD","sourcesContent":["import { stateFile } from \"../agent-paths.ts\";\nimport { isWorkerSession } from \"../session-role.ts\";\nimport { isRecordObject } from \"../util/value-guards.ts\";\nimport { type HostFingerprint, HostStateStore, isHostFingerprint } from \"./host-state-store.ts\";\nimport {\n\thasUsableModelPerfSample,\n\tisModelPerfProfile,\n\ttype ModelPerfProfile,\n\ttype ModelPerfSample,\n\tupdateModelPerfProfile,\n} from \"./perf-profile.ts\";\n\nconst STORE_VERSION = 1;\nconst MAX_RULES_PER_MODEL = 5;\nconst RETIRE_AFTER_MS = 30 * 24 * 60 * 60 * 1000;\n\nexport interface ModelAdaptationRule {\n\tmode: string;\n\ttext: string;\n\taddedAt: string;\n\tlastFiredAt: string;\n}\n\nexport type ModelProtocolCalibration =\n\t| {\n\t\t\tversion: number;\n\t\t\tstatus?: \"calibrated\";\n\t\t\tvariant: string;\n\t\t\tcalibratedAt: string;\n\t }\n\t| {\n\t\t\tversion: number;\n\t\t\tstatus: \"failed\";\n\t\t\tattemptedAt: string;\n\t\t\tvariantsTried: string[];\n\t };\n\nexport type ModelToolProbeVerdict = \"native\" | \"text-protocol\" | \"none\";\nexport type NativeToolProbeGrade = \"task\" | \"echo-only\" | \"absent\";\n\nexport interface ModelToolProbe {\n\tversion: number;\n\tstatus: ModelToolProbeVerdict;\n\tprobedAt: string;\n\tvariant?: string;\n\tnativeGrade?: NativeToolProbeGrade;\n\tdiagnostic?: string;\n}\n\nexport interface ModelTeachStats {\n\ttaught: number;\n\trecurrenceBefore: number;\n\trecurrenceAfter: number;\n}\n\nexport interface ModelAdaptationProfile {\n\trules: ModelAdaptationRule[];\n\tprotocol?: ModelProtocolCalibration;\n\ttoolProbe?: ModelToolProbe;\n\tperf?: ModelPerfProfile;\n\tteachStats: Record<string, ModelTeachStats>;\n}\n\nexport interface StoredModelAdaptation {\n\tmodel: string;\n\tprofile: ModelAdaptationProfile;\n\tat: string;\n\thost: HostFingerprint;\n}\n\ninterface ProfileMutation {\n\tprofile: ModelAdaptationProfile;\n\tentry?: StoredModelAdaptation;\n\tapplied: boolean;\n}\n\nfunction emptyProfile(): ModelAdaptationProfile {\n\treturn { rules: [], teachStats: {} };\n}\n\nfunction normalizeProfile(profile: Partial<ModelAdaptationProfile> | undefined): ModelAdaptationProfile {\n\treturn {\n\t\trules: Array.isArray(profile?.rules) ? profile.rules.filter(isRule) : [],\n\t\t...(isProtocol(profile?.protocol) && { protocol: profile.protocol }),\n\t\t...(isToolProbe(profile?.toolProbe) && { toolProbe: profile.toolProbe }),\n\t\t...(isModelPerfProfile(profile?.perf) && { perf: profile.perf }),\n\t\tteachStats: isRecordObject(profile?.teachStats) ? filterTeachStats(profile.teachStats) : {},\n\t};\n}\n\nfunction isRule(value: unknown): value is ModelAdaptationRule {\n\treturn (\n\t\tisRecordObject(value) &&\n\t\ttypeof value.mode === \"string\" &&\n\t\ttypeof value.text === \"string\" &&\n\t\ttypeof value.addedAt === \"string\" &&\n\t\ttypeof value.lastFiredAt === \"string\"\n\t);\n}\n\nfunction isProtocol(value: unknown): value is ModelProtocolCalibration {\n\tif (!isRecordObject(value) || typeof value.version !== \"number\") return false;\n\tif (value.status === \"failed\") {\n\t\treturn (\n\t\t\ttypeof value.attemptedAt === \"string\" &&\n\t\t\tArray.isArray(value.variantsTried) &&\n\t\t\tvalue.variantsTried.every((variant) => typeof variant === \"string\")\n\t\t);\n\t}\n\treturn (\n\t\t(value.status === undefined || value.status === \"calibrated\") &&\n\t\ttypeof value.variant === \"string\" &&\n\t\ttypeof value.calibratedAt === \"string\"\n\t);\n}\n\nfunction isToolProbe(value: unknown): value is ModelToolProbe {\n\treturn (\n\t\tisRecordObject(value) &&\n\t\ttypeof value.version === \"number\" &&\n\t\t(value.status === \"native\" || value.status === \"text-protocol\" || value.status === \"none\") &&\n\t\ttypeof value.probedAt === \"string\" &&\n\t\t(value.variant === undefined || typeof value.variant === \"string\") &&\n\t\t(value.nativeGrade === undefined ||\n\t\t\tvalue.nativeGrade === \"task\" ||\n\t\t\tvalue.nativeGrade === \"echo-only\" ||\n\t\t\tvalue.nativeGrade === \"absent\") &&\n\t\t(value.diagnostic === undefined || typeof value.diagnostic === \"string\")\n\t);\n}\n\nfunction isTeachStats(value: unknown): value is ModelTeachStats {\n\treturn (\n\t\tisRecordObject(value) &&\n\t\ttypeof value.taught === \"number\" &&\n\t\ttypeof value.recurrenceBefore === \"number\" &&\n\t\ttypeof value.recurrenceAfter === \"number\"\n\t);\n}\n\nfunction filterTeachStats(value: Record<string, unknown>): Record<string, ModelTeachStats> {\n\treturn Object.fromEntries(\n\t\tObject.entries(value).filter((entry): entry is [string, ModelTeachStats] => isTeachStats(entry[1])),\n\t);\n}\n\nfunction ruleRecency(rule: ModelAdaptationRule): number {\n\tconst lastFired = Date.parse(rule.lastFiredAt);\n\tif (Number.isFinite(lastFired)) return lastFired;\n\tconst added = Date.parse(rule.addedAt);\n\treturn Number.isFinite(added) ? added : 0;\n}\n\n/**\n * Minimum post-rule recurrences before efficacy can retire a rule early — a single relapse is\n * noise, not proof the rule stopped working.\n */\nconst MIN_RECURRENCE_AFTER_FOR_EFFICACY = 2;\n\n/**\n * Efficacy-based early retirement. `agent-session.ts`'s `_handleModelAdaptationTelemetry` bumps\n * `recurrenceBefore` each time a failure mode recurs BEFORE a standing rule exists for it (the\n * baseline that earned the rule), then switches to bumping `recurrenceAfter` each time the SAME mode\n * recurs AFTER the rule fired. So a rule that is actually working keeps `recurrenceAfter` low relative\n * to its own pre-rule baseline; a rule that has caught up to (or exceeded) that baseline has\n * demonstrably stopped reducing recurrence and should retire before the time-based outer bound.\n */\nfunction isRuleEffective(stats: ModelTeachStats | undefined): boolean {\n\tif (!stats || stats.recurrenceAfter < MIN_RECURRENCE_AFTER_FOR_EFFICACY) return true; // not enough post-rule evidence yet\n\treturn stats.recurrenceAfter < stats.recurrenceBefore;\n}\n\n/**\n * Prune rules past the time-based outer bound (`RETIRE_AFTER_MS`, always enforced) OR past efficacy\n * (a rule that stopped reducing recurrence retires early; a rule that keeps helping persists until\n * the outer bound).\n */\nfunction pruneRetiredRules(\n\trules: readonly ModelAdaptationRule[],\n\tteachStats: Record<string, ModelTeachStats>,\n\tnow: Date,\n): ModelAdaptationRule[] {\n\tconst cutoff = now.getTime() - RETIRE_AFTER_MS;\n\treturn rules.filter((rule) => ruleRecency(rule) >= cutoff && isRuleEffective(teachStats[rule.mode]));\n}\n\nfunction enforceRuleCap(rules: readonly ModelAdaptationRule[]): ModelAdaptationRule[] {\n\tif (rules.length <= MAX_RULES_PER_MODEL) return [...rules];\n\treturn [...rules].sort((a, b) => ruleRecency(b) - ruleRecency(a)).slice(0, MAX_RULES_PER_MODEL);\n}\n\nfunction mergeRule(rules: readonly ModelAdaptationRule[], rule: ModelAdaptationRule): ModelAdaptationRule[] {\n\tconst withoutSameMode = rules.filter((existing) => existing.mode !== rule.mode);\n\treturn enforceRuleCap([...withoutSameMode, rule]);\n}\n\nfunction parseAdaptationHost(value: unknown, hostId: string): Record<string, StoredModelAdaptation> | undefined {\n\tif (!isRecordObject(value)) return undefined;\n\tconst profiles: Record<string, StoredModelAdaptation> = {};\n\tfor (const [model, candidate] of Object.entries(value)) {\n\t\tif (\n\t\t\t!isRecordObject(candidate) ||\n\t\t\tcandidate.model !== model ||\n\t\t\ttypeof candidate.at !== \"string\" ||\n\t\t\t!isHostFingerprint(candidate.host) ||\n\t\t\tcandidate.host.id !== hostId ||\n\t\t\t!isRecordObject(candidate.profile)\n\t\t)\n\t\t\tcontinue;\n\t\tprofiles[model] = {\n\t\t\tmodel,\n\t\t\tprofile: normalizeProfile(candidate.profile),\n\t\t\tat: candidate.at,\n\t\t\thost: candidate.host,\n\t\t};\n\t}\n\treturn profiles;\n}\n\nexport class ModelAdaptationStore {\n\tprivate readonly storage: HostStateStore<Record<string, StoredModelAdaptation>>;\n\n\tconstructor(filePath: string, options?: { fingerprint?: () => HostFingerprint; readOnly?: boolean }) {\n\t\tthis.storage = new HostStateStore({\n\t\t\tfilePath,\n\t\t\tversion: STORE_VERSION,\n\t\t\tfingerprint: options?.fingerprint,\n\t\t\treadOnly: options?.readOnly ?? isWorkerSession(),\n\t\t\tparseHost: parseAdaptationHost,\n\t\t});\n\t}\n\n\tstatic forAgentDir(\n\t\tagentDir: string,\n\t\toptions?: { fingerprint?: () => HostFingerprint; readOnly?: boolean },\n\t): ModelAdaptationStore {\n\t\treturn new ModelAdaptationStore(stateFile(agentDir, \"model-adaptation.json\"), options);\n\t}\n\n\t/**\n\t * Load-mutate-write under a single exclusive lock so two concurrent stores (e.g. two sessions\n\t * sharing an agentDir) can't both read the old file and clobber each other's write.\n\t */\n\tprivate store(model: string, profile: ModelAdaptationProfile, at: string): StoredModelAdaptation {\n\t\treturn this.storage.mutateCurrentHost(\n\t\t\t() => ({}),\n\t\t\t(profiles, host) => {\n\t\t\t\tconst entry: StoredModelAdaptation = { model, profile: normalizeProfile(profile), at, host };\n\t\t\t\tprofiles[model] = entry;\n\t\t\t\treturn { result: entry, changed: true };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Keep the complete profile read-modify-write transaction under the host-state lock. */\n\tprivate mutateProfile(\n\t\tmodel: string,\n\t\tnow: Date,\n\t\tmutate: (profile: ModelAdaptationProfile) => ModelAdaptationProfile | undefined,\n\t\tstoredAt = now.toISOString(),\n\t): ProfileMutation {\n\t\treturn this.storage.mutateCurrentHost<ProfileMutation>(\n\t\t\t() => ({}),\n\t\t\t(profiles, host) => {\n\t\t\t\tconst current = normalizeProfile(profiles[model]?.profile);\n\t\t\t\tconst activeRules = pruneRetiredRules(current.rules, current.teachStats, now);\n\t\t\t\tconst pruned = activeRules.length !== current.rules.length;\n\t\t\t\tconst active = pruned ? { ...current, rules: activeRules } : current;\n\t\t\t\tconst requested = mutate(active);\n\t\t\t\tconst applied = requested !== undefined;\n\t\t\t\tif (!applied && !pruned) {\n\t\t\t\t\treturn { result: { profile: active, applied: false }, changed: false };\n\t\t\t\t}\n\t\t\t\tconst profile = normalizeProfile(requested ?? active);\n\t\t\t\tconst entry: StoredModelAdaptation = { model, profile, at: storedAt, host };\n\t\t\t\tprofiles[model] = entry;\n\t\t\t\treturn { result: { profile, entry, applied }, changed: true };\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Persist the profile for a model on the CURRENT host. Best-effort, returns the entry. */\n\tsave(model: string, profile: ModelAdaptationProfile, at?: string): StoredModelAdaptation {\n\t\treturn this.store(model, profile, at ?? new Date().toISOString());\n\t}\n\n\t/** Profile for a model on the current host; prunes retired rules before returning. */\n\tget(model: string, now: Date = new Date()): ModelAdaptationProfile {\n\t\tconst entry = this.storage.getHost()?.[model];\n\t\tif (!entry) return emptyProfile();\n\t\tconst profile = normalizeProfile(entry.profile);\n\t\tconst prunedRules = pruneRetiredRules(profile.rules, profile.teachStats, now);\n\t\tif (prunedRules.length !== profile.rules.length) {\n\t\t\treturn this.mutateProfile(model, now, () => undefined).profile;\n\t\t}\n\t\treturn profile;\n\t}\n\n\t/** Add or replace one standing rule, enforcing the per-model cap. */\n\taddRule(\n\t\tmodel: string,\n\t\trule: { mode: string; text: string; addedAt?: string; lastFiredAt?: string },\n\t\tnow = new Date(),\n\t): StoredModelAdaptation {\n\t\tconst at = now.toISOString();\n\t\tconst nextRule: ModelAdaptationRule = {\n\t\t\tmode: rule.mode,\n\t\t\ttext: rule.text,\n\t\t\taddedAt: rule.addedAt ?? at,\n\t\t\tlastFiredAt: rule.lastFiredAt ?? at,\n\t\t};\n\t\tconst result = this.mutateProfile(model, now, (profile) => ({\n\t\t\t...profile,\n\t\t\trules: mergeRule(profile.rules, nextRule),\n\t\t}));\n\t\treturn result.entry!;\n\t}\n\n\tremoveRule(model: string, mode: string, at = new Date()): boolean {\n\t\treturn this.mutateProfile(model, at, (profile) => {\n\t\t\tconst rules = profile.rules.filter((rule) => rule.mode !== mode);\n\t\t\treturn rules.length === profile.rules.length ? undefined : { ...profile, rules };\n\t\t}).applied;\n\t}\n\n\t/** Update last-fired recency for an existing rule. No-op when absent. */\n\tmarkRuleFired(model: string, mode: string, at = new Date()): StoredModelAdaptation | undefined {\n\t\tconst result = this.mutateProfile(model, at, (profile) => {\n\t\t\tconst rules = profile.rules.map((rule) =>\n\t\t\t\trule.mode === mode ? { ...rule, lastFiredAt: at.toISOString() } : rule,\n\t\t\t);\n\t\t\treturn rules.every((rule, index) => rule === profile.rules[index]) ? undefined : { ...profile, rules };\n\t\t});\n\t\treturn result.applied ? result.entry : undefined;\n\t}\n\n\tsetProtocol(model: string, protocol: ModelProtocolCalibration, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? (protocol.status === \"failed\" ? protocol.attemptedAt : protocol.calibratedAt);\n\t\treturn this.mutateProfile(model, new Date(now), (profile) => ({ ...profile, protocol }), now).entry!;\n\t}\n\n\tsetToolProbe(model: string, toolProbe: ModelToolProbe, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? toolProbe.probedAt;\n\t\treturn this.mutateProfile(model, new Date(now), (profile) => ({ ...profile, toolProbe }), now).entry!;\n\t}\n\n\trecordPerfSample(model: string, sample: ModelPerfSample, at?: string): StoredModelAdaptation | undefined {\n\t\tif (!hasUsableModelPerfSample(sample)) return undefined;\n\t\tconst now = at ?? sample.at ?? new Date().toISOString();\n\t\tconst result = this.mutateProfile(\n\t\t\tmodel,\n\t\t\tnew Date(now),\n\t\t\t(profile) => {\n\t\t\t\tconst perf = updateModelPerfProfile(profile.perf, sample, now);\n\t\t\t\treturn perf ? { ...profile, perf } : undefined;\n\t\t\t},\n\t\t\tnow,\n\t\t);\n\t\treturn result.applied ? result.entry : undefined;\n\t}\n\n\tremoveProtocol(model: string, at = new Date()): boolean {\n\t\treturn this.mutateProfile(model, at, (profile) => {\n\t\t\tif (!profile.protocol) return undefined;\n\t\t\tconst { protocol: _protocol, ...rest } = profile;\n\t\t\treturn rest;\n\t\t}).applied;\n\t}\n\n\tsetTeachStats(model: string, mode: string, stats: ModelTeachStats, at?: string): StoredModelAdaptation {\n\t\tconst now = at ?? new Date().toISOString();\n\t\treturn this.mutateProfile(\n\t\t\tmodel,\n\t\t\tnew Date(now),\n\t\t\t(profile) => ({\n\t\t\t\t...profile,\n\t\t\t\tteachStats: { ...profile.teachStats, [mode]: stats },\n\t\t\t}),\n\t\t\tnow,\n\t\t).entry!;\n\t}\n\n\t/** Profiles for the current host (default) or an explicit host id. */\n\tgetForHost(hostId?: string): StoredModelAdaptation[] {\n\t\treturn Object.values(this.storage.getHost(hostId) ?? {}).map((entry) => ({\n\t\t\t...entry,\n\t\t\tprofile: normalizeProfile(entry.profile),\n\t\t}));\n\t}\n\n\t/** Every stored profile across all hosts (for cross-machine comparisons). */\n\tgetAll(): StoredModelAdaptation[] {\n\t\treturn this.storage\n\t\t\t.getAllHosts()\n\t\t\t.flatMap((models) =>\n\t\t\t\tObject.values(models).map((entry) => ({ ...entry, profile: normalizeProfile(entry.profile) })),\n\t\t\t);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-model-suggestions.d.ts","sourceRoot":"","sources":["../../../src/core/models/default-model-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6DAA6D,CAAC;AAE/F;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,eAAe;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oGAAoG;IACpG,WAAW,EAAE,OAAO,CAAC;IACrB,mGAAmG;IACnG,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,yBAAyB,EAAE,SAAS,eAAe,
|
|
1
|
+
{"version":3,"file":"default-model-suggestions.d.ts","sourceRoot":"","sources":["../../../src/core/models/default-model-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6DAA6D,CAAC;AAE/F;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,eAAe;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oGAAoG;IACpG,WAAW,EAAE,OAAO,CAAC;IACrB,mGAAmG;IACnG,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,yBAAyB,EAAE,SAAS,eAAe,EA2G/D,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,sBAAsB,CAAC,WAAW,GAAE,SAAS,eAAe,EAA8B,GAAG,MAAM,EAAE,CAcpH","sourcesContent":["import type { FitnessRole } from \"../../modes/interactive/components/fitness-role-selector.ts\";\n\n/**\n * Curated local-model suggestions: a starting roster validated during pi-adaptative's own\n * small-model research so a user does not have to know WHICH model fits WHICH role. Each entry is\n * an install ref (accepted by /models add) plus the role it was validated for and whether it can use\n * tools. Native tool-calling remains preferred when it works; text-protocol models are listed only\n * when their runtime is pi-managed and the fitness/probe path can calibrate that fallback.\n *\n * Honesty: these are SUGGESTIONS, not guarantees. Fitness is a property of the model AND the host\n * hardware, so no per-model score is baked in here — `/models add` auto-probes on the actual\n * machine, and the roster only encodes what role each model was SHAPED for. `assignRole` is the\n * /fitness role the suggestion maps to (undefined = no single-setting slot yet; use it as a\n * research/worker lane model).\n */\n\nexport interface ModelSuggestion {\n\t/** Display name in the suggestions list. */\n\tname: string;\n\t/** Ref accepted by /models add and the source normalizer. */\n\tpullRef: string;\n\t/** Role this model was validated/shaped for. */\n\trole: string;\n\t/** True if the model can use tools after host-local probing/calibration (required for executor). */\n\ttoolCalling: boolean;\n\t/** The /fitness assignment target this suggestion maps to, when there is a single-setting slot. */\n\tassignRole?: FitnessRole;\n\t/** One-line rationale from the validation work; never a fabricated numeric score. */\n\trationale: string;\n\t/** Optional caveat (quant selection, RAM needs). */\n\tnote?: string;\n}\n\nexport const DEFAULT_MODEL_SUGGESTIONS: readonly ModelSuggestion[] = [\n\t{\n\t\tname: \"qwen3:1.7b\",\n\t\tpullRef: \"qwen3:1.7b\",\n\t\trole: \"Toolkit executor / reflex muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Validated as the executor: reliable native tool-calling and low latency, so direct toolkit commands run without retries.\",\n\t},\n\t{\n\t\tname: \"qwen3:0.6b\",\n\t\tpullRef: \"qwen3:0.6b\",\n\t\trole: \"Minimal executor (fastest)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Fastest local option; on harder requests it can narrate without executing, so prefer it only when speed dominates and requests are simple.\",\n\t},\n\t{\n\t\tname: \"MiniCPM5-1B (full-base)\",\n\t\tpullRef: \"hf.co/openbmb/MiniCPM5-1B\",\n\t\trole: \"Full-base Transformers executor / tiny local muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Full-base Hugging Face MiniCPM5-1B target: pi installs an isolated Transformers runtime and probes native tool-calling first, then calibrates the text protocol only if native tool calls do not work.\",\n\t\tnote: \"Not GGUF/quantized: weights and Python deps land under pi-owned runtime/cache directories, separate from Ollama and system Python.\",\n\t},\n\t{\n\t\tname: \"FastContext-1.0-4B\",\n\t\tpullRef: \"hf.co/KikoCis/FastContext-1.0-4B-longctx-imatrix-GGUF:fastcontext4b.Q4_K_M.imx.gguf\",\n\t\trole: \"Repository scout (context_scout)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"scout\",\n\t\trationale:\n\t\t\t\"The model the context_scout lane is built around (Plan 9): 4B Qwen3, 256K context, trained for read-only repo exploration returning file:line citations. /fitness must pass the tool-calls + research lanes before assignment.\",\n\t\tnote: \"Q4 ≈ 2.5 GB; ~5-6 GB peak with 32-64K KV. Qwen3 template caveat: if tool calls fail the probe, use the Modelfile recipe in docs/scout.md.\",\n\t},\n\t{\n\t\tname: \"Ornith-1.0-9B\",\n\t\tpullRef: \"hf.co/deepreinforce-ai/Ornith-1.0-9B-GGUF:Q4_K_M\",\n\t\trole: \"Agentic-coding worker / router cheap tier\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"router-cheap\",\n\t\trationale:\n\t\t\t\"External candidate (not from pi's own validation research): MIT, Qwen 3.5 base, RL-trained for agentic coding with native tool-calling — the strongest local worker SHAPE in the roster. /fitness on your hardware is the validator.\",\n\t\tnote: \"Q4_K_M ≈ 5.6 GB weights, ~7-8 GB peak with KV — on a 10 GB box run it as the ONLY local model. Qwen 3.5 arch: confirm pi's pinned Ollama supports it and probe tool-calls with /fitness before assigning (template derives from the GGUF). Larger boxes: consider router-medium after a passed worker lane.\",\n\t},\n\t{\n\t\tname: \"Bonsai-4B (GGUF Q1_0)\",\n\t\tpullRef: \"hf.co/prism-ml/Bonsai-4B-gguf:Q1_0\",\n\t\trole: \"Context curator / reflex brain / lighter lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Lighter Bonsai lane model for context curation and structured local analysis; the exact Q1_0 artifact keeps /models suggest one-step.\",\n\t\tnote: \"Recommended when Bonsai-8B is too heavy. Pi pulls this exact GGUF through managed Ollama, probes /fitness on the host, then offers the curator role.\",\n\t},\n\t{\n\t\tname: \"Bonsai-27B (1-bit + vision)\",\n\t\tpullRef: \"hf.co/prism-ml/Bonsai-27B-gguf:Q1_0\",\n\t\trole: \"Context curator / reflex brain / vision-capable lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"External 1-bit 27B, binary weights, 262K-class context, vision via mmproj; served by pi through prism-ml's llama.cpp build (stock llama.cpp/Ollama cannot serve these weights). /fitness on your hardware is the validator — never pre-claim tool-calling.\",\n\t\tnote: \"~3.8 GB weights + 629 MB vision projector + a one-time llama-server runtime download; CPU-served on GPU-less hosts. Pi installs the pinned prism llama.cpp runtime, downloads both files, starts llama-server, and registers the model in one step. Provider-recommended sampling is temp 0.7 / top-p 0.95 / top-k 20; models.json has no per-model default-sampling field yet, so pi cannot wire this — set it per-request/session if your workflow needs it.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-1.7B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-1.7B-gguf\",\n\t\trole: \"Search scout (heavy-lifter)\",\n\t\ttoolCalling: false,\n\t\trationale:\n\t\t\t\"Ternary weights, very fast; strong at structured search plans. No tool-calling template — use it as a research/worker lane model, never an executor.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0). The ternary Q2_0 build needs prism-ml's patched llama.cpp.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-4B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-4B-gguf\",\n\t\trole: \"Context curator / reflex brain / lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Validated as the 'brain': strict-JSON interpretation and faithful digests. Drives context curation and the toolkit reflex interpreter. Not a tool-caller.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0).\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-8B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-8B-gguf\",\n\t\trole: \"Routing judge (larger machines)\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"judge\",\n\t\trationale:\n\t\t\t\"A judge candidate for machines with more headroom — too slow on ~16GB-class hardware in this research, kept for a bigger box.\",\n\t\tnote: \"Heavy: confirm tok/s with /fitness before committing. Ternary quant may need prism-ml's patched llama.cpp.\",\n\t},\n\t{\n\t\tname: \"needle (function-call tester, 26M)\",\n\t\tpullRef: \"hf.co/Cactus-Compute/needle\",\n\t\trole: \"Standalone function-call test bench (not a chat/lane model)\",\n\t\ttoolCalling: false,\n\t\trationale:\n\t\t\t\"NOT a pi chat model, executor, or lane model — needle is a 26M-parameter single-shot function-call SPECIALIST invoked one query at a time through its own `needle run` CLI, useful only as a standalone bench for probing tool-call behavior in isolation. No OpenAI-compatible endpoint, no chat lanes, no models.json registration, and no /fitness probe: use /models needle <query> [tools-json] to test it directly instead.\",\n\t\tnote: \"Upstream weights (needle.pkl) are pickle-only — arbitrary code execution on load by construction, not something pi's pinned-sha256 verification makes safe in the abstract, only tamper-evident.\",\n\t},\n];\n\n/** Bounded plain-text roster for `/models suggest` and the empty-store hint. */\nexport function formatModelSuggestions(suggestions: readonly ModelSuggestion[] = DEFAULT_MODEL_SUGGESTIONS): string[] {\n\tconst lines = [\n\t\t\"Suggested local models (validated roles from pi's own small-model research; probe on YOUR hardware with /fitness):\",\n\t];\n\tfor (const suggestion of suggestions) {\n\t\tlines.push(\n\t\t\t` - ${suggestion.name} → ${suggestion.role}${suggestion.toolCalling ? \"\" : \" [no tool-calling]\"}`,\n\t\t\t` /models add ${suggestion.pullRef}`,\n\t\t\t` ${suggestion.rationale}`,\n\t\t);\n\t\tif (suggestion.note) lines.push(` note: ${suggestion.note}`);\n\t}\n\tlines.push(\"Add one with /models add <ref> — pi pulls it, probes it, and offers a role in one step.\");\n\treturn lines;\n}\n"]}
|
|
@@ -51,6 +51,15 @@ export const DEFAULT_MODEL_SUGGESTIONS = [
|
|
|
51
51
|
rationale: "Lighter Bonsai lane model for context curation and structured local analysis; the exact Q1_0 artifact keeps /models suggest one-step.",
|
|
52
52
|
note: "Recommended when Bonsai-8B is too heavy. Pi pulls this exact GGUF through managed Ollama, probes /fitness on the host, then offers the curator role.",
|
|
53
53
|
},
|
|
54
|
+
{
|
|
55
|
+
name: "Bonsai-27B (1-bit + vision)",
|
|
56
|
+
pullRef: "hf.co/prism-ml/Bonsai-27B-gguf:Q1_0",
|
|
57
|
+
role: "Context curator / reflex brain / vision-capable lane analyst",
|
|
58
|
+
toolCalling: false,
|
|
59
|
+
assignRole: "curator",
|
|
60
|
+
rationale: "External 1-bit 27B, binary weights, 262K-class context, vision via mmproj; served by pi through prism-ml's llama.cpp build (stock llama.cpp/Ollama cannot serve these weights). /fitness on your hardware is the validator — never pre-claim tool-calling.",
|
|
61
|
+
note: "~3.8 GB weights + 629 MB vision projector + a one-time llama-server runtime download; CPU-served on GPU-less hosts. Pi installs the pinned prism llama.cpp runtime, downloads both files, starts llama-server, and registers the model in one step. Provider-recommended sampling is temp 0.7 / top-p 0.95 / top-k 20; models.json has no per-model default-sampling field yet, so pi cannot wire this — set it per-request/session if your workflow needs it.",
|
|
62
|
+
},
|
|
54
63
|
{
|
|
55
64
|
name: "Ternary-Bonsai-1.7B",
|
|
56
65
|
pullRef: "hf.co/prism-ml/Ternary-Bonsai-1.7B-gguf",
|
|
@@ -77,6 +86,14 @@ export const DEFAULT_MODEL_SUGGESTIONS = [
|
|
|
77
86
|
rationale: "A judge candidate for machines with more headroom — too slow on ~16GB-class hardware in this research, kept for a bigger box.",
|
|
78
87
|
note: "Heavy: confirm tok/s with /fitness before committing. Ternary quant may need prism-ml's patched llama.cpp.",
|
|
79
88
|
},
|
|
89
|
+
{
|
|
90
|
+
name: "needle (function-call tester, 26M)",
|
|
91
|
+
pullRef: "hf.co/Cactus-Compute/needle",
|
|
92
|
+
role: "Standalone function-call test bench (not a chat/lane model)",
|
|
93
|
+
toolCalling: false,
|
|
94
|
+
rationale: "NOT a pi chat model, executor, or lane model — needle is a 26M-parameter single-shot function-call SPECIALIST invoked one query at a time through its own `needle run` CLI, useful only as a standalone bench for probing tool-call behavior in isolation. No OpenAI-compatible endpoint, no chat lanes, no models.json registration, and no /fitness probe: use /models needle <query> [tools-json] to test it directly instead.",
|
|
95
|
+
note: "Upstream weights (needle.pkl) are pickle-only — arbitrary code execution on load by construction, not something pi's pinned-sha256 verification makes safe in the abstract, only tamper-evident.",
|
|
96
|
+
},
|
|
80
97
|
];
|
|
81
98
|
/** Bounded plain-text roster for `/models suggest` and the empty-store hint. */
|
|
82
99
|
export function formatModelSuggestions(suggestions = DEFAULT_MODEL_SUGGESTIONS) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-model-suggestions.js","sourceRoot":"","sources":["../../../src/core/models/default-model-suggestions.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAC,MAAM,yBAAyB,GAA+B;IACpE;QACC,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,kCAAkC;QACxC,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,UAAU;QACtB,SAAS,EACR,0HAA0H;KAC3H;IACD;QACC,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,4BAA4B;QAClC,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,UAAU;QACtB,SAAS,EACR,4IAA4I;KAC7I;IACD;QACC,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,2BAA2B;QACpC,IAAI,EAAE,qDAAqD;QAC3D,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,UAAU;QACtB,SAAS,EACR,wMAAwM;QACzM,IAAI,EAAE,oIAAoI;KAC1I;IACD;QACC,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,qFAAqF;QAC9F,IAAI,EAAE,kCAAkC;QAC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AAC,IAAI,CACT,OAAO,UAAU,CAAC,IAAI,QAAM,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE,EAClG,qBAAqB,UAAU,CAAC,OAAO,EAAE,EACzC,SAAS,UAAU,CAAC,SAAS,EAAE,CAC/B,CAAC;QACF,IAAI,UAAU,CAAC,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,eAAe,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,2FAAyF,CAAC,CAAC;IACtG,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import type { FitnessRole } from \"../../modes/interactive/components/fitness-role-selector.ts\";\n\n/**\n * Curated local-model suggestions: a starting roster validated during pi-adaptative's own\n * small-model research so a user does not have to know WHICH model fits WHICH role. Each entry is\n * an install ref (accepted by /models add) plus the role it was validated for and whether it can use\n * tools. Native tool-calling remains preferred when it works; text-protocol models are listed only\n * when their runtime is pi-managed and the fitness/probe path can calibrate that fallback.\n *\n * Honesty: these are SUGGESTIONS, not guarantees. Fitness is a property of the model AND the host\n * hardware, so no per-model score is baked in here — `/models add` auto-probes on the actual\n * machine, and the roster only encodes what role each model was SHAPED for. `assignRole` is the\n * /fitness role the suggestion maps to (undefined = no single-setting slot yet; use it as a\n * research/worker lane model).\n */\n\nexport interface ModelSuggestion {\n\t/** Display name in the suggestions list. */\n\tname: string;\n\t/** Ref accepted by /models add and the source normalizer. */\n\tpullRef: string;\n\t/** Role this model was validated/shaped for. */\n\trole: string;\n\t/** True if the model can use tools after host-local probing/calibration (required for executor). */\n\ttoolCalling: boolean;\n\t/** The /fitness assignment target this suggestion maps to, when there is a single-setting slot. */\n\tassignRole?: FitnessRole;\n\t/** One-line rationale from the validation work; never a fabricated numeric score. */\n\trationale: string;\n\t/** Optional caveat (quant selection, RAM needs). */\n\tnote?: string;\n}\n\nexport const DEFAULT_MODEL_SUGGESTIONS: readonly ModelSuggestion[] = [\n\t{\n\t\tname: \"qwen3:1.7b\",\n\t\tpullRef: \"qwen3:1.7b\",\n\t\trole: \"Toolkit executor / reflex muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Validated as the executor: reliable native tool-calling and low latency, so direct toolkit commands run without retries.\",\n\t},\n\t{\n\t\tname: \"qwen3:0.6b\",\n\t\tpullRef: \"qwen3:0.6b\",\n\t\trole: \"Minimal executor (fastest)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Fastest local option; on harder requests it can narrate without executing, so prefer it only when speed dominates and requests are simple.\",\n\t},\n\t{\n\t\tname: \"MiniCPM5-1B (full-base)\",\n\t\tpullRef: \"hf.co/openbmb/MiniCPM5-1B\",\n\t\trole: \"Full-base Transformers executor / tiny local muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Full-base Hugging Face MiniCPM5-1B target: pi installs an isolated Transformers runtime and probes native tool-calling first, then calibrates the text protocol only if native tool calls do not work.\",\n\t\tnote: \"Not GGUF/quantized: weights and Python deps land under pi-owned runtime/cache directories, separate from Ollama and system Python.\",\n\t},\n\t{\n\t\tname: \"FastContext-1.0-4B\",\n\t\tpullRef: \"hf.co/KikoCis/FastContext-1.0-4B-longctx-imatrix-GGUF:fastcontext4b.Q4_K_M.imx.gguf\",\n\t\trole: \"Repository scout (context_scout)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"scout\",\n\t\trationale:\n\t\t\t\"The model the context_scout lane is built around (Plan 9): 4B Qwen3, 256K context, trained for read-only repo exploration returning file:line citations. /fitness must pass the tool-calls + research lanes before assignment.\",\n\t\tnote: \"Q4 ≈ 2.5 GB; ~5-6 GB peak with 32-64K KV. Qwen3 template caveat: if tool calls fail the probe, use the Modelfile recipe in docs/scout.md.\",\n\t},\n\t{\n\t\tname: \"Ornith-1.0-9B\",\n\t\tpullRef: \"hf.co/deepreinforce-ai/Ornith-1.0-9B-GGUF:Q4_K_M\",\n\t\trole: \"Agentic-coding worker / router cheap tier\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"router-cheap\",\n\t\trationale:\n\t\t\t\"External candidate (not from pi's own validation research): MIT, Qwen 3.5 base, RL-trained for agentic coding with native tool-calling — the strongest local worker SHAPE in the roster. /fitness on your hardware is the validator.\",\n\t\tnote: \"Q4_K_M ≈ 5.6 GB weights, ~7-8 GB peak with KV — on a 10 GB box run it as the ONLY local model. Qwen 3.5 arch: confirm pi's pinned Ollama supports it and probe tool-calls with /fitness before assigning (template derives from the GGUF). Larger boxes: consider router-medium after a passed worker lane.\",\n\t},\n\t{\n\t\tname: \"Bonsai-4B (GGUF Q1_0)\",\n\t\tpullRef: \"hf.co/prism-ml/Bonsai-4B-gguf:Q1_0\",\n\t\trole: \"Context curator / reflex brain / lighter lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Lighter Bonsai lane model for context curation and structured local analysis; the exact Q1_0 artifact keeps /models suggest one-step.\",\n\t\tnote: \"Recommended when Bonsai-8B is too heavy. Pi pulls this exact GGUF through managed Ollama, probes /fitness on the host, then offers the curator role.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-1.7B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-1.7B-gguf\",\n\t\trole: \"Search scout (heavy-lifter)\",\n\t\ttoolCalling: false,\n\t\trationale:\n\t\t\t\"Ternary weights, very fast; strong at structured search plans. No tool-calling template — use it as a research/worker lane model, never an executor.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0). The ternary Q2_0 build needs prism-ml's patched llama.cpp.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-4B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-4B-gguf\",\n\t\trole: \"Context curator / reflex brain / lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Validated as the 'brain': strict-JSON interpretation and faithful digests. Drives context curation and the toolkit reflex interpreter. Not a tool-caller.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0).\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-8B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-8B-gguf\",\n\t\trole: \"Routing judge (larger machines)\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"judge\",\n\t\trationale:\n\t\t\t\"A judge candidate for machines with more headroom — too slow on ~16GB-class hardware in this research, kept for a bigger box.\",\n\t\tnote: \"Heavy: confirm tok/s with /fitness before committing. Ternary quant may need prism-ml's patched llama.cpp.\",\n\t},\n];\n\n/** Bounded plain-text roster for `/models suggest` and the empty-store hint. */\nexport function formatModelSuggestions(suggestions: readonly ModelSuggestion[] = DEFAULT_MODEL_SUGGESTIONS): string[] {\n\tconst lines = [\n\t\t\"Suggested local models (validated roles from pi's own small-model research; probe on YOUR hardware with /fitness):\",\n\t];\n\tfor (const suggestion of suggestions) {\n\t\tlines.push(\n\t\t\t` - ${suggestion.name} → ${suggestion.role}${suggestion.toolCalling ? \"\" : \" [no tool-calling]\"}`,\n\t\t\t` /models add ${suggestion.pullRef}`,\n\t\t\t` ${suggestion.rationale}`,\n\t\t);\n\t\tif (suggestion.note) lines.push(` note: ${suggestion.note}`);\n\t}\n\tlines.push(\"Add one with /models add <ref> — pi pulls it, probes it, and offers a role in one step.\");\n\treturn lines;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"default-model-suggestions.js","sourceRoot":"","sources":["../../../src/core/models/default-model-suggestions.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAC,MAAM,yBAAyB,GAA+B;IACpE;QACC,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,kCAAkC;QACxC,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE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tG,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import type { FitnessRole } from \"../../modes/interactive/components/fitness-role-selector.ts\";\n\n/**\n * Curated local-model suggestions: a starting roster validated during pi-adaptative's own\n * small-model research so a user does not have to know WHICH model fits WHICH role. Each entry is\n * an install ref (accepted by /models add) plus the role it was validated for and whether it can use\n * tools. Native tool-calling remains preferred when it works; text-protocol models are listed only\n * when their runtime is pi-managed and the fitness/probe path can calibrate that fallback.\n *\n * Honesty: these are SUGGESTIONS, not guarantees. Fitness is a property of the model AND the host\n * hardware, so no per-model score is baked in here — `/models add` auto-probes on the actual\n * machine, and the roster only encodes what role each model was SHAPED for. `assignRole` is the\n * /fitness role the suggestion maps to (undefined = no single-setting slot yet; use it as a\n * research/worker lane model).\n */\n\nexport interface ModelSuggestion {\n\t/** Display name in the suggestions list. */\n\tname: string;\n\t/** Ref accepted by /models add and the source normalizer. */\n\tpullRef: string;\n\t/** Role this model was validated/shaped for. */\n\trole: string;\n\t/** True if the model can use tools after host-local probing/calibration (required for executor). */\n\ttoolCalling: boolean;\n\t/** The /fitness assignment target this suggestion maps to, when there is a single-setting slot. */\n\tassignRole?: FitnessRole;\n\t/** One-line rationale from the validation work; never a fabricated numeric score. */\n\trationale: string;\n\t/** Optional caveat (quant selection, RAM needs). */\n\tnote?: string;\n}\n\nexport const DEFAULT_MODEL_SUGGESTIONS: readonly ModelSuggestion[] = [\n\t{\n\t\tname: \"qwen3:1.7b\",\n\t\tpullRef: \"qwen3:1.7b\",\n\t\trole: \"Toolkit executor / reflex muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Validated as the executor: reliable native tool-calling and low latency, so direct toolkit commands run without retries.\",\n\t},\n\t{\n\t\tname: \"qwen3:0.6b\",\n\t\tpullRef: \"qwen3:0.6b\",\n\t\trole: \"Minimal executor (fastest)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Fastest local option; on harder requests it can narrate without executing, so prefer it only when speed dominates and requests are simple.\",\n\t},\n\t{\n\t\tname: \"MiniCPM5-1B (full-base)\",\n\t\tpullRef: \"hf.co/openbmb/MiniCPM5-1B\",\n\t\trole: \"Full-base Transformers executor / tiny local muscle\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"executor\",\n\t\trationale:\n\t\t\t\"Full-base Hugging Face MiniCPM5-1B target: pi installs an isolated Transformers runtime and probes native tool-calling first, then calibrates the text protocol only if native tool calls do not work.\",\n\t\tnote: \"Not GGUF/quantized: weights and Python deps land under pi-owned runtime/cache directories, separate from Ollama and system Python.\",\n\t},\n\t{\n\t\tname: \"FastContext-1.0-4B\",\n\t\tpullRef: \"hf.co/KikoCis/FastContext-1.0-4B-longctx-imatrix-GGUF:fastcontext4b.Q4_K_M.imx.gguf\",\n\t\trole: \"Repository scout (context_scout)\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"scout\",\n\t\trationale:\n\t\t\t\"The model the context_scout lane is built around (Plan 9): 4B Qwen3, 256K context, trained for read-only repo exploration returning file:line citations. /fitness must pass the tool-calls + research lanes before assignment.\",\n\t\tnote: \"Q4 ≈ 2.5 GB; ~5-6 GB peak with 32-64K KV. Qwen3 template caveat: if tool calls fail the probe, use the Modelfile recipe in docs/scout.md.\",\n\t},\n\t{\n\t\tname: \"Ornith-1.0-9B\",\n\t\tpullRef: \"hf.co/deepreinforce-ai/Ornith-1.0-9B-GGUF:Q4_K_M\",\n\t\trole: \"Agentic-coding worker / router cheap tier\",\n\t\ttoolCalling: true,\n\t\tassignRole: \"router-cheap\",\n\t\trationale:\n\t\t\t\"External candidate (not from pi's own validation research): MIT, Qwen 3.5 base, RL-trained for agentic coding with native tool-calling — the strongest local worker SHAPE in the roster. /fitness on your hardware is the validator.\",\n\t\tnote: \"Q4_K_M ≈ 5.6 GB weights, ~7-8 GB peak with KV — on a 10 GB box run it as the ONLY local model. Qwen 3.5 arch: confirm pi's pinned Ollama supports it and probe tool-calls with /fitness before assigning (template derives from the GGUF). Larger boxes: consider router-medium after a passed worker lane.\",\n\t},\n\t{\n\t\tname: \"Bonsai-4B (GGUF Q1_0)\",\n\t\tpullRef: \"hf.co/prism-ml/Bonsai-4B-gguf:Q1_0\",\n\t\trole: \"Context curator / reflex brain / lighter lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Lighter Bonsai lane model for context curation and structured local analysis; the exact Q1_0 artifact keeps /models suggest one-step.\",\n\t\tnote: \"Recommended when Bonsai-8B is too heavy. Pi pulls this exact GGUF through managed Ollama, probes /fitness on the host, then offers the curator role.\",\n\t},\n\t{\n\t\tname: \"Bonsai-27B (1-bit + vision)\",\n\t\tpullRef: \"hf.co/prism-ml/Bonsai-27B-gguf:Q1_0\",\n\t\trole: \"Context curator / reflex brain / vision-capable lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"External 1-bit 27B, binary weights, 262K-class context, vision via mmproj; served by pi through prism-ml's llama.cpp build (stock llama.cpp/Ollama cannot serve these weights). /fitness on your hardware is the validator — never pre-claim tool-calling.\",\n\t\tnote: \"~3.8 GB weights + 629 MB vision projector + a one-time llama-server runtime download; CPU-served on GPU-less hosts. Pi installs the pinned prism llama.cpp runtime, downloads both files, starts llama-server, and registers the model in one step. Provider-recommended sampling is temp 0.7 / top-p 0.95 / top-k 20; models.json has no per-model default-sampling field yet, so pi cannot wire this — set it per-request/session if your workflow needs it.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-1.7B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-1.7B-gguf\",\n\t\trole: \"Search scout (heavy-lifter)\",\n\t\ttoolCalling: false,\n\t\trationale:\n\t\t\t\"Ternary weights, very fast; strong at structured search plans. No tool-calling template — use it as a research/worker lane model, never an executor.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0). The ternary Q2_0 build needs prism-ml's patched llama.cpp.\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-4B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-4B-gguf\",\n\t\trole: \"Context curator / reflex brain / lane analyst\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"curator\",\n\t\trationale:\n\t\t\t\"Validated as the 'brain': strict-JSON interpretation and faithful digests. Drives context curation and the toolkit reflex interpreter. Not a tool-caller.\",\n\t\tnote: \"Pick a GGUF quant the runtime accepts (e.g. :Q8_0).\",\n\t},\n\t{\n\t\tname: \"Ternary-Bonsai-8B\",\n\t\tpullRef: \"hf.co/prism-ml/Ternary-Bonsai-8B-gguf\",\n\t\trole: \"Routing judge (larger machines)\",\n\t\ttoolCalling: false,\n\t\tassignRole: \"judge\",\n\t\trationale:\n\t\t\t\"A judge candidate for machines with more headroom — too slow on ~16GB-class hardware in this research, kept for a bigger box.\",\n\t\tnote: \"Heavy: confirm tok/s with /fitness before committing. Ternary quant may need prism-ml's patched llama.cpp.\",\n\t},\n\t{\n\t\tname: \"needle (function-call tester, 26M)\",\n\t\tpullRef: \"hf.co/Cactus-Compute/needle\",\n\t\trole: \"Standalone function-call test bench (not a chat/lane model)\",\n\t\ttoolCalling: false,\n\t\trationale:\n\t\t\t\"NOT a pi chat model, executor, or lane model — needle is a 26M-parameter single-shot function-call SPECIALIST invoked one query at a time through its own `needle run` CLI, useful only as a standalone bench for probing tool-call behavior in isolation. No OpenAI-compatible endpoint, no chat lanes, no models.json registration, and no /fitness probe: use /models needle <query> [tools-json] to test it directly instead.\",\n\t\tnote: \"Upstream weights (needle.pkl) are pickle-only — arbitrary code execution on load by construction, not something pi's pinned-sha256 verification makes safe in the abstract, only tamper-evident.\",\n\t},\n];\n\n/** Bounded plain-text roster for `/models suggest` and the empty-store hint. */\nexport function formatModelSuggestions(suggestions: readonly ModelSuggestion[] = DEFAULT_MODEL_SUGGESTIONS): string[] {\n\tconst lines = [\n\t\t\"Suggested local models (validated roles from pi's own small-model research; probe on YOUR hardware with /fitness):\",\n\t];\n\tfor (const suggestion of suggestions) {\n\t\tlines.push(\n\t\t\t` - ${suggestion.name} → ${suggestion.role}${suggestion.toolCalling ? \"\" : \" [no tool-calling]\"}`,\n\t\t\t` /models add ${suggestion.pullRef}`,\n\t\t\t` ${suggestion.rationale}`,\n\t\t);\n\t\tif (suggestion.note) lines.push(` note: ${suggestion.note}`);\n\t}\n\tlines.push(\"Add one with /models add <ref> — pi pulls it, probes it, and offers a role in one step.\");\n\treturn lines;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelFitnessReport } from "../research/model-fitness.ts";
|
|
2
|
+
import { type HostFingerprint } from "./host-state-store.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Durable, HOST-KEYED storage for model fitness reports. Fitness is a property of a model ON a
|
|
4
5
|
* host (tok/s and latency-driven failures do not travel between machines), so reports are keyed
|
|
@@ -6,14 +7,6 @@ import type { ModelFitnessReport } from "../research/model-fitness.ts";
|
|
|
6
7
|
* "waiting for better hardware" on another, and pi remembers both without confusing them —
|
|
7
8
|
* including when settings/dotfiles are synced across machines.
|
|
8
9
|
*/
|
|
9
|
-
export interface HostFingerprint {
|
|
10
|
-
/** Stable, human-readable id derived from the specs below. */
|
|
11
|
-
id: string;
|
|
12
|
-
cpu: string;
|
|
13
|
-
cores: number;
|
|
14
|
-
totalMemGb: number;
|
|
15
|
-
}
|
|
16
|
-
export declare function currentHostFingerprint(): HostFingerprint;
|
|
17
10
|
export interface StoredFitnessReport {
|
|
18
11
|
model: string;
|
|
19
12
|
report: ModelFitnessReport;
|
|
@@ -21,15 +14,15 @@ export interface StoredFitnessReport {
|
|
|
21
14
|
host: HostFingerprint;
|
|
22
15
|
}
|
|
23
16
|
export declare class FitnessStore {
|
|
24
|
-
private readonly
|
|
25
|
-
private readonly fingerprint;
|
|
17
|
+
private readonly storage;
|
|
26
18
|
constructor(filePath: string, options?: {
|
|
27
19
|
fingerprint?: () => HostFingerprint;
|
|
20
|
+
readOnly?: boolean;
|
|
28
21
|
});
|
|
29
22
|
static forAgentDir(agentDir: string, options?: {
|
|
30
23
|
fingerprint?: () => HostFingerprint;
|
|
24
|
+
readOnly?: boolean;
|
|
31
25
|
}): FitnessStore;
|
|
32
|
-
private load;
|
|
33
26
|
/** Persist the latest report for a model on the CURRENT host. Best-effort, returns the entry. */
|
|
34
27
|
save(model: string, report: ModelFitnessReport, at?: string): StoredFitnessReport;
|
|
35
28
|
/** Drop a model's report for the CURRENT host (uninstall cleanup). No-op when absent. */
|