@reticlehq/server 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +105 -0
- package/README.md +17 -0
- package/dist/bridge-security.d.ts +23 -0
- package/dist/bridge-security.d.ts.map +1 -0
- package/dist/bridge-security.js +44 -0
- package/dist/bridge-security.js.map +1 -0
- package/dist/bridge.d.ts +42 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +281 -0
- package/dist/bridge.js.map +1 -0
- package/dist/bridge.test-harness.d.ts +42 -0
- package/dist/bridge.test-harness.d.ts.map +1 -0
- package/dist/bridge.test-harness.js +192 -0
- package/dist/bridge.test-harness.js.map +1 -0
- package/dist/cli-launch.d.ts +53 -0
- package/dist/cli-launch.d.ts.map +1 -0
- package/dist/cli-launch.js +109 -0
- package/dist/cli-launch.js.map +1 -0
- package/dist/cli-parse.d.ts +74 -0
- package/dist/cli-parse.d.ts.map +1 -0
- package/dist/cli-parse.js +321 -0
- package/dist/cli-parse.js.map +1 -0
- package/dist/cli-port.d.ts +26 -0
- package/dist/cli-port.d.ts.map +1 -0
- package/dist/cli-port.js +57 -0
- package/dist/cli-port.js.map +1 -0
- package/dist/cli-verify.d.ts +46 -0
- package/dist/cli-verify.d.ts.map +1 -0
- package/dist/cli-verify.js +181 -0
- package/dist/cli-verify.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +337 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/cloud-sync.d.ts +50 -0
- package/dist/cloud/cloud-sync.d.ts.map +1 -0
- package/dist/cloud/cloud-sync.js +47 -0
- package/dist/cloud/cloud-sync.js.map +1 -0
- package/dist/crawl/crawl-tools.d.ts +8 -0
- package/dist/crawl/crawl-tools.d.ts.map +1 -0
- package/dist/crawl/crawl-tools.js +61 -0
- package/dist/crawl/crawl-tools.js.map +1 -0
- package/dist/crawl/crawl.d.ts +45 -0
- package/dist/crawl/crawl.d.ts.map +1 -0
- package/dist/crawl/crawl.js +106 -0
- package/dist/crawl/crawl.js.map +1 -0
- package/dist/daemon-resilience.d.ts +17 -0
- package/dist/daemon-resilience.d.ts.map +1 -0
- package/dist/daemon-resilience.js +23 -0
- package/dist/daemon-resilience.js.map +1 -0
- package/dist/daemon.d.ts +26 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +122 -0
- package/dist/daemon.js.map +1 -0
- package/dist/domain/domain-model.d.ts +64 -0
- package/dist/domain/domain-model.d.ts.map +1 -0
- package/dist/domain/domain-model.js +127 -0
- package/dist/domain/domain-model.js.map +1 -0
- package/dist/domain/domain-tools.d.ts +9 -0
- package/dist/domain/domain-tools.d.ts.map +1 -0
- package/dist/domain/domain-tools.js +66 -0
- package/dist/domain/domain-tools.js.map +1 -0
- package/dist/domain/flow-risk.d.ts +34 -0
- package/dist/domain/flow-risk.d.ts.map +1 -0
- package/dist/domain/flow-risk.js +81 -0
- package/dist/domain/flow-risk.js.map +1 -0
- package/dist/ee/audit-log.d.ts +15 -0
- package/dist/ee/audit-log.d.ts.map +1 -0
- package/dist/ee/audit-log.js +12 -0
- package/dist/ee/audit-log.js.map +1 -0
- package/dist/events/event-filters.d.ts +65 -0
- package/dist/events/event-filters.d.ts.map +1 -0
- package/dist/events/event-filters.js +98 -0
- package/dist/events/event-filters.js.map +1 -0
- package/dist/events/predicate-eval.d.ts +91 -0
- package/dist/events/predicate-eval.d.ts.map +1 -0
- package/dist/events/predicate-eval.js +299 -0
- package/dist/events/predicate-eval.js.map +1 -0
- package/dist/events/predicate.d.ts +19 -0
- package/dist/events/predicate.d.ts.map +1 -0
- package/dist/events/predicate.js +188 -0
- package/dist/events/predicate.js.map +1 -0
- package/dist/events/reaction.d.ts +34 -0
- package/dist/events/reaction.d.ts.map +1 -0
- package/dist/events/reaction.js +60 -0
- package/dist/events/reaction.js.map +1 -0
- package/dist/events/ring-buffer.d.ts +32 -0
- package/dist/events/ring-buffer.d.ts.map +1 -0
- package/dist/events/ring-buffer.js +75 -0
- package/dist/events/ring-buffer.js.map +1 -0
- package/dist/flows/annotate-tools.d.ts +16 -0
- package/dist/flows/annotate-tools.d.ts.map +1 -0
- package/dist/flows/annotate-tools.js +136 -0
- package/dist/flows/annotate-tools.js.map +1 -0
- package/dist/flows/annotate.d.ts +22 -0
- package/dist/flows/annotate.d.ts.map +1 -0
- package/dist/flows/annotate.js +134 -0
- package/dist/flows/annotate.js.map +1 -0
- package/dist/flows/annotation-store.d.ts +23 -0
- package/dist/flows/annotation-store.d.ts.map +1 -0
- package/dist/flows/annotation-store.js +51 -0
- package/dist/flows/annotation-store.js.map +1 -0
- package/dist/flows/decision.d.ts +13 -0
- package/dist/flows/decision.d.ts.map +1 -0
- package/dist/flows/decision.js +111 -0
- package/dist/flows/decision.js.map +1 -0
- package/dist/flows/flow-classify.d.ts +52 -0
- package/dist/flows/flow-classify.d.ts.map +1 -0
- package/dist/flows/flow-classify.js +99 -0
- package/dist/flows/flow-classify.js.map +1 -0
- package/dist/flows/flow-replay-run.d.ts +15 -0
- package/dist/flows/flow-replay-run.d.ts.map +1 -0
- package/dist/flows/flow-replay-run.js +120 -0
- package/dist/flows/flow-replay-run.js.map +1 -0
- package/dist/flows/flow-replay.d.ts +49 -0
- package/dist/flows/flow-replay.d.ts.map +1 -0
- package/dist/flows/flow-replay.js +391 -0
- package/dist/flows/flow-replay.js.map +1 -0
- package/dist/flows/flow-report.d.ts +23 -0
- package/dist/flows/flow-report.d.ts.map +1 -0
- package/dist/flows/flow-report.js +106 -0
- package/dist/flows/flow-report.js.map +1 -0
- package/dist/flows/flow-scope.d.ts +25 -0
- package/dist/flows/flow-scope.d.ts.map +1 -0
- package/dist/flows/flow-scope.js +32 -0
- package/dist/flows/flow-scope.js.map +1 -0
- package/dist/flows/flow-success.d.ts +33 -0
- package/dist/flows/flow-success.d.ts.map +1 -0
- package/dist/flows/flow-success.js +131 -0
- package/dist/flows/flow-success.js.map +1 -0
- package/dist/flows/flow-tools.d.ts +4 -0
- package/dist/flows/flow-tools.d.ts.map +1 -0
- package/dist/flows/flow-tools.js +460 -0
- package/dist/flows/flow-tools.js.map +1 -0
- package/dist/flows/flows.d.ts +86 -0
- package/dist/flows/flows.d.ts.map +1 -0
- package/dist/flows/flows.js +319 -0
- package/dist/flows/flows.js.map +1 -0
- package/dist/flows/heal.d.ts +43 -0
- package/dist/flows/heal.d.ts.map +1 -0
- package/dist/flows/heal.js +98 -0
- package/dist/flows/heal.js.map +1 -0
- package/dist/flows/recordings.d.ts +46 -0
- package/dist/flows/recordings.d.ts.map +1 -0
- package/dist/flows/recordings.js +43 -0
- package/dist/flows/recordings.js.map +1 -0
- package/dist/flows/replay.d.ts +23 -0
- package/dist/flows/replay.d.ts.map +1 -0
- package/dist/flows/replay.js +160 -0
- package/dist/flows/replay.js.map +1 -0
- package/dist/http-server.d.ts +39 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +145 -0
- package/dist/http-server.js.map +1 -0
- package/dist/idle-shutdown.d.ts +34 -0
- package/dist/idle-shutdown.d.ts.map +1 -0
- package/dist/idle-shutdown.js +68 -0
- package/dist/idle-shutdown.js.map +1 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +371 -0
- package/dist/index.js.map +1 -0
- package/dist/init/cursor.d.ts +25 -0
- package/dist/init/cursor.d.ts.map +1 -0
- package/dist/init/cursor.js +49 -0
- package/dist/init/cursor.js.map +1 -0
- package/dist/init/detect.d.ts +49 -0
- package/dist/init/detect.d.ts.map +1 -0
- package/dist/init/detect.js +84 -0
- package/dist/init/detect.js.map +1 -0
- package/dist/init/mcp.d.ts +40 -0
- package/dist/init/mcp.d.ts.map +1 -0
- package/dist/init/mcp.js +55 -0
- package/dist/init/mcp.js.map +1 -0
- package/dist/init/node-io.d.ts +8 -0
- package/dist/init/node-io.d.ts.map +1 -0
- package/dist/init/node-io.js +57 -0
- package/dist/init/node-io.js.map +1 -0
- package/dist/init/plan.d.ts +72 -0
- package/dist/init/plan.d.ts.map +1 -0
- package/dist/init/plan.js +280 -0
- package/dist/init/plan.js.map +1 -0
- package/dist/init/project-id.d.ts +17 -0
- package/dist/init/project-id.d.ts.map +1 -0
- package/dist/init/project-id.js +38 -0
- package/dist/init/project-id.js.map +1 -0
- package/dist/init/run.d.ts +42 -0
- package/dist/init/run.d.ts.map +1 -0
- package/dist/init/run.js +171 -0
- package/dist/init/run.js.map +1 -0
- package/dist/init/snippets.d.ts +33 -0
- package/dist/init/snippets.d.ts.map +1 -0
- package/dist/init/snippets.js +117 -0
- package/dist/init/snippets.js.map +1 -0
- package/dist/init/vite-config.d.ts +25 -0
- package/dist/init/vite-config.d.ts.map +1 -0
- package/dist/init/vite-config.js +45 -0
- package/dist/init/vite-config.js.map +1 -0
- package/dist/input/network-mock-tools.d.ts +3 -0
- package/dist/input/network-mock-tools.d.ts.map +1 -0
- package/dist/input/network-mock-tools.js +94 -0
- package/dist/input/network-mock-tools.js.map +1 -0
- package/dist/input/network-mock.d.ts +55 -0
- package/dist/input/network-mock.d.ts.map +1 -0
- package/dist/input/network-mock.js +62 -0
- package/dist/input/network-mock.js.map +1 -0
- package/dist/input/real-input.d.ts +174 -0
- package/dist/input/real-input.d.ts.map +1 -0
- package/dist/input/real-input.js +289 -0
- package/dist/input/real-input.js.map +1 -0
- package/dist/input/scroll-find.d.ts +41 -0
- package/dist/input/scroll-find.d.ts.map +1 -0
- package/dist/input/scroll-find.js +59 -0
- package/dist/input/scroll-find.js.map +1 -0
- package/dist/input/scroll-tools.d.ts +8 -0
- package/dist/input/scroll-tools.d.ts.map +1 -0
- package/dist/input/scroll-tools.js +68 -0
- package/dist/input/scroll-tools.js.map +1 -0
- package/dist/input/viewport-tools.d.ts +3 -0
- package/dist/input/viewport-tools.d.ts.map +1 -0
- package/dist/input/viewport-tools.js +65 -0
- package/dist/input/viewport-tools.js.map +1 -0
- package/dist/license/license.d.ts +108 -0
- package/dist/license/license.d.ts.map +1 -0
- package/dist/license/license.js +203 -0
- package/dist/license/license.js.map +1 -0
- package/dist/log.d.ts +6 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +9 -0
- package/dist/log.js.map +1 -0
- package/dist/mcp-proxy.d.ts +16 -0
- package/dist/mcp-proxy.d.ts.map +1 -0
- package/dist/mcp-proxy.js +168 -0
- package/dist/mcp-proxy.js.map +1 -0
- package/dist/mcp.d.ts +14 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +101 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pairing-token.d.ts +28 -0
- package/dist/pairing-token.d.ts.map +1 -0
- package/dist/pairing-token.js +62 -0
- package/dist/pairing-token.js.map +1 -0
- package/dist/pool/browser-pool.d.ts +90 -0
- package/dist/pool/browser-pool.d.ts.map +1 -0
- package/dist/pool/browser-pool.js +221 -0
- package/dist/pool/browser-pool.js.map +1 -0
- package/dist/pool/lease-reaper.d.ts +16 -0
- package/dist/pool/lease-reaper.d.ts.map +1 -0
- package/dist/pool/lease-reaper.js +41 -0
- package/dist/pool/lease-reaper.js.map +1 -0
- package/dist/pool/playwright-launcher.d.ts +19 -0
- package/dist/pool/playwright-launcher.d.ts.map +1 -0
- package/dist/pool/playwright-launcher.js +51 -0
- package/dist/pool/playwright-launcher.js.map +1 -0
- package/dist/project/baselines.d.ts +22 -0
- package/dist/project/baselines.d.ts.map +1 -0
- package/dist/project/baselines.js +45 -0
- package/dist/project/baselines.js.map +1 -0
- package/dist/project/fs-port.d.ts +27 -0
- package/dist/project/fs-port.d.ts.map +1 -0
- package/dist/project/fs-port.js +32 -0
- package/dist/project/fs-port.js.map +1 -0
- package/dist/project/project-store.d.ts +32 -0
- package/dist/project/project-store.d.ts.map +1 -0
- package/dist/project/project-store.js +127 -0
- package/dist/project/project-store.js.map +1 -0
- package/dist/project/project-tools.d.ts +9 -0
- package/dist/project/project-tools.d.ts.map +1 -0
- package/dist/project/project-tools.js +118 -0
- package/dist/project/project-tools.js.map +1 -0
- package/dist/project/reticle-dir.d.ts +61 -0
- package/dist/project/reticle-dir.d.ts.map +1 -0
- package/dist/project/reticle-dir.js +144 -0
- package/dist/project/reticle-dir.js.map +1 -0
- package/dist/runs/build-verification-run.d.ts +30 -0
- package/dist/runs/build-verification-run.d.ts.map +1 -0
- package/dist/runs/build-verification-run.js +71 -0
- package/dist/runs/build-verification-run.js.map +1 -0
- package/dist/runs/profile-redact.d.ts +16 -0
- package/dist/runs/profile-redact.d.ts.map +1 -0
- package/dist/runs/profile-redact.js +32 -0
- package/dist/runs/profile-redact.js.map +1 -0
- package/dist/runs/render-report.d.ts +9 -0
- package/dist/runs/render-report.d.ts.map +1 -0
- package/dist/runs/render-report.js +70 -0
- package/dist/runs/render-report.js.map +1 -0
- package/dist/runs/repair-prompt.d.ts +15 -0
- package/dist/runs/repair-prompt.d.ts.map +1 -0
- package/dist/runs/repair-prompt.js +59 -0
- package/dist/runs/repair-prompt.js.map +1 -0
- package/dist/runs/replay-mapping.d.ts +12 -0
- package/dist/runs/replay-mapping.d.ts.map +1 -0
- package/dist/runs/replay-mapping.js +35 -0
- package/dist/runs/replay-mapping.js.map +1 -0
- package/dist/runs/reticle-runner.d.ts +48 -0
- package/dist/runs/reticle-runner.d.ts.map +1 -0
- package/dist/runs/reticle-runner.js +56 -0
- package/dist/runs/reticle-runner.js.map +1 -0
- package/dist/runs/risk-classify.d.ts +27 -0
- package/dist/runs/risk-classify.d.ts.map +1 -0
- package/dist/runs/risk-classify.js +76 -0
- package/dist/runs/risk-classify.js.map +1 -0
- package/dist/runs/run-store.d.ts +40 -0
- package/dist/runs/run-store.d.ts.map +1 -0
- package/dist/runs/run-store.js +118 -0
- package/dist/runs/run-store.js.map +1 -0
- package/dist/runs/run-tools.d.ts +10 -0
- package/dist/runs/run-tools.d.ts.map +1 -0
- package/dist/runs/run-tools.js +69 -0
- package/dist/runs/run-tools.js.map +1 -0
- package/dist/runs/runner-port.d.ts +14 -0
- package/dist/runs/runner-port.d.ts.map +1 -0
- package/dist/runs/runner-port.js +23 -0
- package/dist/runs/runner-port.js.map +1 -0
- package/dist/runs/verify-http.d.ts +34 -0
- package/dist/runs/verify-http.d.ts.map +1 -0
- package/dist/runs/verify-http.js +102 -0
- package/dist/runs/verify-http.js.map +1 -0
- package/dist/runs/verify-server.d.ts +26 -0
- package/dist/runs/verify-server.d.ts.map +1 -0
- package/dist/runs/verify-server.js +99 -0
- package/dist/runs/verify-server.js.map +1 -0
- package/dist/server-version.d.ts +3 -0
- package/dist/server-version.d.ts.map +1 -0
- package/dist/server-version.js +5 -0
- package/dist/server-version.js.map +1 -0
- package/dist/session/control-envelope.d.ts +49 -0
- package/dist/session/control-envelope.d.ts.map +1 -0
- package/dist/session/control-envelope.js +44 -0
- package/dist/session/control-envelope.js.map +1 -0
- package/dist/session/live-control-tools.d.ts +16 -0
- package/dist/session/live-control-tools.d.ts.map +1 -0
- package/dist/session/live-control-tools.js +204 -0
- package/dist/session/live-control-tools.js.map +1 -0
- package/dist/session/output-budget.d.ts +41 -0
- package/dist/session/output-budget.d.ts.map +1 -0
- package/dist/session/output-budget.js +54 -0
- package/dist/session/output-budget.js.map +1 -0
- package/dist/session/presenter-args.d.ts +8 -0
- package/dist/session/presenter-args.d.ts.map +1 -0
- package/dist/session/presenter-args.js +15 -0
- package/dist/session/presenter-args.js.map +1 -0
- package/dist/session/review-store.d.ts +40 -0
- package/dist/session/review-store.d.ts.map +1 -0
- package/dist/session/review-store.js +61 -0
- package/dist/session/review-store.js.map +1 -0
- package/dist/session/session-health.d.ts +22 -0
- package/dist/session/session-health.d.ts.map +1 -0
- package/dist/session/session-health.js +26 -0
- package/dist/session/session-health.js.map +1 -0
- package/dist/session/session-manager.d.ts +43 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +155 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/session-readiness.d.ts +35 -0
- package/dist/session/session-readiness.d.ts.map +1 -0
- package/dist/session/session-readiness.js +32 -0
- package/dist/session/session-readiness.js.map +1 -0
- package/dist/session/session-reaper.d.ts +37 -0
- package/dist/session/session-reaper.d.ts.map +1 -0
- package/dist/session/session-reaper.js +94 -0
- package/dist/session/session-reaper.js.map +1 -0
- package/dist/session/session-recommendation.d.ts +18 -0
- package/dist/session/session-recommendation.d.ts.map +1 -0
- package/dist/session/session-recommendation.js +14 -0
- package/dist/session/session-recommendation.js.map +1 -0
- package/dist/session/session-tools.d.ts +9 -0
- package/dist/session/session-tools.d.ts.map +1 -0
- package/dist/session/session-tools.js +43 -0
- package/dist/session/session-tools.js.map +1 -0
- package/dist/session/session.d.ts +166 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +408 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/state-select.d.ts +8 -0
- package/dist/session/state-select.d.ts.map +1 -0
- package/dist/session/state-select.js +8 -0
- package/dist/session/state-select.js.map +1 -0
- package/dist/token-auth.d.ts +24 -0
- package/dist/token-auth.d.ts.map +1 -0
- package/dist/token-auth.js +71 -0
- package/dist/token-auth.js.map +1 -0
- package/dist/tools/act-tools.d.ts +3 -0
- package/dist/tools/act-tools.d.ts.map +1 -0
- package/dist/tools/act-tools.js +327 -0
- package/dist/tools/act-tools.js.map +1 -0
- package/dist/tools/act-view.d.ts +19 -0
- package/dist/tools/act-view.d.ts.map +1 -0
- package/dist/tools/act-view.js +46 -0
- package/dist/tools/act-view.js.map +1 -0
- package/dist/tools/assert-grade.d.ts +21 -0
- package/dist/tools/assert-grade.d.ts.map +1 -0
- package/dist/tools/assert-grade.js +52 -0
- package/dist/tools/assert-grade.js.map +1 -0
- package/dist/tools/browser-tools.d.ts +3 -0
- package/dist/tools/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser-tools.js +52 -0
- package/dist/tools/browser-tools.js.map +1 -0
- package/dist/tools/contract-tools.d.ts +8 -0
- package/dist/tools/contract-tools.d.ts.map +1 -0
- package/dist/tools/contract-tools.js +62 -0
- package/dist/tools/contract-tools.js.map +1 -0
- package/dist/tools/dynamic-tools.d.ts +7 -0
- package/dist/tools/dynamic-tools.d.ts.map +1 -0
- package/dist/tools/dynamic-tools.js +103 -0
- package/dist/tools/dynamic-tools.js.map +1 -0
- package/dist/tools/error-recovery.d.ts +31 -0
- package/dist/tools/error-recovery.d.ts.map +1 -0
- package/dist/tools/error-recovery.js +52 -0
- package/dist/tools/error-recovery.js.map +1 -0
- package/dist/tools/invoke-tool.d.ts +23 -0
- package/dist/tools/invoke-tool.d.ts.map +1 -0
- package/dist/tools/invoke-tool.js +99 -0
- package/dist/tools/invoke-tool.js.map +1 -0
- package/dist/tools/lease-tools.d.ts +31 -0
- package/dist/tools/lease-tools.d.ts.map +1 -0
- package/dist/tools/lease-tools.js +164 -0
- package/dist/tools/lease-tools.js.map +1 -0
- package/dist/tools/observe-tools.d.ts +3 -0
- package/dist/tools/observe-tools.d.ts.map +1 -0
- package/dist/tools/observe-tools.js +259 -0
- package/dist/tools/observe-tools.js.map +1 -0
- package/dist/tools/profiles.d.ts +33 -0
- package/dist/tools/profiles.d.ts.map +1 -0
- package/dist/tools/profiles.js +105 -0
- package/dist/tools/profiles.js.map +1 -0
- package/dist/tools/query-paginate.d.ts +15 -0
- package/dist/tools/query-paginate.d.ts.map +1 -0
- package/dist/tools/query-paginate.js +31 -0
- package/dist/tools/query-paginate.js.map +1 -0
- package/dist/tools/read-tools.d.ts +3 -0
- package/dist/tools/read-tools.d.ts.map +1 -0
- package/dist/tools/read-tools.js +329 -0
- package/dist/tools/read-tools.js.map +1 -0
- package/dist/tools/snapshot-delta.d.ts +59 -0
- package/dist/tools/snapshot-delta.d.ts.map +1 -0
- package/dist/tools/snapshot-delta.js +0 -0
- package/dist/tools/snapshot-delta.js.map +1 -0
- package/dist/tools/tool-invoker.d.ts +15 -0
- package/dist/tools/tool-invoker.d.ts.map +1 -0
- package/dist/tools/tool-invoker.js +20 -0
- package/dist/tools/tool-invoker.js.map +1 -0
- package/dist/tools/tool-kit.d.ts +60 -0
- package/dist/tools/tool-kit.d.ts.map +1 -0
- package/dist/tools/tool-kit.js +33 -0
- package/dist/tools/tool-kit.js.map +1 -0
- package/dist/tools/tool-names.d.ts +89 -0
- package/dist/tools/tool-names.d.ts.map +1 -0
- package/dist/tools/tool-names.js +88 -0
- package/dist/tools/tool-names.js.map +1 -0
- package/dist/tools/tools-helpers.d.ts +12 -0
- package/dist/tools/tools-helpers.d.ts.map +1 -0
- package/dist/tools/tools-helpers.js +22 -0
- package/dist/tools/tools-helpers.js.map +1 -0
- package/dist/tools/tools.d.ts +4 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +268 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/update/update-checker.d.ts +20 -0
- package/dist/update/update-checker.d.ts.map +1 -0
- package/dist/update/update-checker.js +94 -0
- package/dist/update/update-checker.js.map +1 -0
- package/dist/update/update-tools.d.ts +3 -0
- package/dist/update/update-tools.d.ts.map +1 -0
- package/dist/update/update-tools.js +94 -0
- package/dist/update/update-tools.js.map +1 -0
- package/dist/update/updater.d.ts +31 -0
- package/dist/update/updater.d.ts.map +1 -0
- package/dist/update/updater.js +120 -0
- package/dist/update/updater.js.map +1 -0
- package/dist/visual/visual-diff.d.ts +46 -0
- package/dist/visual/visual-diff.d.ts.map +1 -0
- package/dist/visual/visual-diff.js +100 -0
- package/dist/visual/visual-diff.js.map +1 -0
- package/dist/visual/visual-store.d.ts +22 -0
- package/dist/visual/visual-store.d.ts.map +1 -0
- package/dist/visual/visual-store.js +60 -0
- package/dist/visual/visual-store.js.map +1 -0
- package/dist/visual/visual-tools.d.ts +9 -0
- package/dist/visual/visual-tools.d.ts.map +1 -0
- package/dist/visual/visual-tools.js +182 -0
- package/dist/visual/visual-tools.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-http.js","sourceRoot":"","sources":["../../src/runs/verify-http.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA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handleVerifyRequest (all routing/guard/verdict logic lives there), and writes the JSON
|
|
4
|
+
* response. Bound to localhost by design; a token adds defence in depth. Keeping this layer dumb means
|
|
5
|
+
* the tested logic is the pure handler — this file is just wire plumbing.
|
|
6
|
+
*/
|
|
7
|
+
import * as http from 'node:http';
|
|
8
|
+
import type { ReticleVerificationRun } from '@reticlehq/core';
|
|
9
|
+
import type { ReticleRunner } from './reticle-runner.js';
|
|
10
|
+
/** Partner pipelines send the token here (localhost-bound, so this is defence-in-depth, not the wall). */
|
|
11
|
+
export declare const TOKEN_HEADER = "x-reticle-token";
|
|
12
|
+
export interface VerifyServerOptions {
|
|
13
|
+
runner: ReticleRunner;
|
|
14
|
+
/** Empty string ⇒ no token required (localhost-only). */
|
|
15
|
+
token: string;
|
|
16
|
+
/** Optional persist hook — the live wiring passes RunStore.write so every verdict is saved. */
|
|
17
|
+
persist?: (run: ReticleVerificationRun) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** Build the request listener. Reads + size-caps the body, then hands off to the pure handler. */
|
|
20
|
+
export declare function createVerifyRequestListener(opts: VerifyServerOptions): http.RequestListener;
|
|
21
|
+
/** Start the verify server on localhost. Resolves once listening; returns the bound server + port. */
|
|
22
|
+
export declare function startVerifyServer(opts: VerifyServerOptions, port: number): Promise<{
|
|
23
|
+
server: http.Server;
|
|
24
|
+
port: number;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=verify-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-server.d.ts","sourceRoot":"","sources":["../../src/runs/verify-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,0GAA0G;AAC1G,eAAO,MAAM,YAAY,oBAAoB,CAAC;AAG9C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,+FAA+F;IAC/F,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAOD,kGAAkG;AAClG,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAsC3F;AAgCD,sGAAsG;AACtG,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAWhD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thin node:http adapter for the verify endpoint. It reads the request body, delegates to the
|
|
3
|
+
* PURE handleVerifyRequest (all routing/guard/verdict logic lives there), and writes the JSON
|
|
4
|
+
* response. Bound to localhost by design; a token adds defence in depth. Keeping this layer dumb means
|
|
5
|
+
* the tested logic is the pure handler — this file is just wire plumbing.
|
|
6
|
+
*/
|
|
7
|
+
import * as http from 'node:http';
|
|
8
|
+
import { LOOPBACK_HOST } from '@reticlehq/core';
|
|
9
|
+
import { handleVerifyRequest } from './verify-http.js';
|
|
10
|
+
const LOCALHOST = LOOPBACK_HOST;
|
|
11
|
+
const MAX_BODY_BYTES = 1_000_000;
|
|
12
|
+
/** Cap how long a single request (and its headers) may take, so a slow/stuck client can't tie up the
|
|
13
|
+
* endpoint indefinitely (slow-loris hardening). */
|
|
14
|
+
const REQUEST_TIMEOUT_MS = 30_000;
|
|
15
|
+
const HEADERS_TIMEOUT_MS = 10_000;
|
|
16
|
+
/** Partner pipelines send the token here (localhost-bound, so this is defence-in-depth, not the wall). */
|
|
17
|
+
export const TOKEN_HEADER = 'x-reticle-token';
|
|
18
|
+
const JSON_HEADERS = { 'Content-Type': 'application/json' };
|
|
19
|
+
function singleHeader(value) {
|
|
20
|
+
if (Array.isArray(value))
|
|
21
|
+
return value[0];
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/** Build the request listener. Reads + size-caps the body, then hands off to the pure handler. */
|
|
25
|
+
export function createVerifyRequestListener(opts) {
|
|
26
|
+
return (req, res) => {
|
|
27
|
+
const chunks = [];
|
|
28
|
+
let size = 0;
|
|
29
|
+
let aborted = false;
|
|
30
|
+
// Single place that ends a request early without ever double-writing or throwing.
|
|
31
|
+
const fail = (status, error) => {
|
|
32
|
+
aborted = true;
|
|
33
|
+
if (!res.headersSent) {
|
|
34
|
+
res.writeHead(status, JSON_HEADERS);
|
|
35
|
+
res.end(JSON.stringify({ error }));
|
|
36
|
+
}
|
|
37
|
+
req.destroy();
|
|
38
|
+
};
|
|
39
|
+
// An aborted/reset socket must never crash the daemon (no 'error' listener ⇒ unhandled throw).
|
|
40
|
+
req.on('error', () => fail(400, 'request error'));
|
|
41
|
+
req.on('data', (chunk) => {
|
|
42
|
+
if (aborted)
|
|
43
|
+
return;
|
|
44
|
+
size += chunk.length;
|
|
45
|
+
if (size > MAX_BODY_BYTES)
|
|
46
|
+
return fail(413, 'request too large');
|
|
47
|
+
chunks.push(chunk);
|
|
48
|
+
});
|
|
49
|
+
req.on('end', () => {
|
|
50
|
+
if (aborted)
|
|
51
|
+
return;
|
|
52
|
+
// Defensive: handleVerifyRequest already catches verify errors, but a rejection here must never
|
|
53
|
+
// become an unhandled rejection that takes down the process.
|
|
54
|
+
writeResponse(req, res, opts, Buffer.concat(chunks).toString('utf8')).catch(() => {
|
|
55
|
+
if (!res.headersSent) {
|
|
56
|
+
res.writeHead(500, JSON_HEADERS);
|
|
57
|
+
res.end(JSON.stringify({ error: 'internal error' }));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function writeResponse(req, res, opts, raw) {
|
|
64
|
+
let body = {};
|
|
65
|
+
if (raw.length > 0) {
|
|
66
|
+
try {
|
|
67
|
+
body = JSON.parse(raw);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
res.writeHead(400, JSON_HEADERS);
|
|
71
|
+
res.end(JSON.stringify({ error: 'invalid json' }));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const token = singleHeader(req.headers[TOKEN_HEADER]);
|
|
76
|
+
const request = {
|
|
77
|
+
method: req.method ?? 'GET',
|
|
78
|
+
path: (req.url ?? '/').split('?')[0] ?? '/',
|
|
79
|
+
body,
|
|
80
|
+
...(token !== undefined ? { token } : {}),
|
|
81
|
+
};
|
|
82
|
+
const result = await handleVerifyRequest(request, opts.runner, opts.token, opts.persist);
|
|
83
|
+
res.writeHead(result.status, JSON_HEADERS);
|
|
84
|
+
res.end(JSON.stringify(result.body));
|
|
85
|
+
}
|
|
86
|
+
/** Start the verify server on localhost. Resolves once listening; returns the bound server + port. */
|
|
87
|
+
export function startVerifyServer(opts, port) {
|
|
88
|
+
const server = http.createServer(createVerifyRequestListener(opts));
|
|
89
|
+
server.requestTimeout = REQUEST_TIMEOUT_MS;
|
|
90
|
+
server.headersTimeout = HEADERS_TIMEOUT_MS;
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
server.listen(port, LOCALHOST, () => {
|
|
93
|
+
const address = server.address();
|
|
94
|
+
const boundPort = typeof address === 'object' && address !== null ? address.port : port;
|
|
95
|
+
resolve({ server, port: boundPort });
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=verify-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-server.js","sourceRoot":"","sources":["../../src/runs/verify-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EA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O,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACxF,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-version.d.ts","sourceRoot":"","sources":["../src/server-version.ts"],"names":[],"mappings":"AAQA,qEAAqE;AACrE,eAAO,MAAM,cAAc,EAAE,MAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const _pkg = createRequire(import.meta.url)('../package.json');
|
|
3
|
+
/** The Reticle server version, read from package.json at startup. */
|
|
4
|
+
export const SERVER_VERSION = _pkg.version;
|
|
5
|
+
//# sourceMappingURL=server-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-version.js","sourceRoot":"","sources":["../src/server-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAM5C,MAAM,IAAI,GAAgB,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAgB,CAAC;AAE3F,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAW,IAAI,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SessionState } from '@reticlehq/core';
|
|
2
|
+
import type { Session } from './session.js';
|
|
3
|
+
/** Live-control: the control block spliced onto tool results so the agent sees human steering. */
|
|
4
|
+
interface ControlEnvelope {
|
|
5
|
+
state: SessionState;
|
|
6
|
+
/** Drained inbox text, delivered to the agent exactly once. */
|
|
7
|
+
guidance: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Agent-readable hint returned when an action is refused mid-pause. Named, not free — the agent's
|
|
11
|
+
* recovery path (address the guidance, then reticle_resume) lives here in exactly one place.
|
|
12
|
+
*/
|
|
13
|
+
export declare const PAUSE_HINT = "Paused by the human. Address the guidance, then call reticle_resume (or wait for the human to resume).";
|
|
14
|
+
/** Shape returned by the short-circuit when an action tool refuses while paused. */
|
|
15
|
+
interface PausedResult {
|
|
16
|
+
paused: true;
|
|
17
|
+
guidance: string[];
|
|
18
|
+
hint: string;
|
|
19
|
+
}
|
|
20
|
+
/** The optional `control` key `withControl` may add — keeps callers' return types honest. */
|
|
21
|
+
type ControlSpread = {
|
|
22
|
+
control?: ControlEnvelope;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Build the piggyback control block for the agent's next tool result.
|
|
26
|
+
*
|
|
27
|
+
* Returns `undefined` iff the session is a CLEAN active one (state === ACTIVE AND inbox empty) —
|
|
28
|
+
* i.e. there is nothing to tell the agent. Otherwise returns `{ state, guidance }`.
|
|
29
|
+
*
|
|
30
|
+
* DRAINS the inbox (the only read path) so a human message is delivered exactly once. Pure: it
|
|
31
|
+
* reads no clock, so the piggyback is deterministic and unit-testable without a fake clock.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildControlEnvelope(session: Session): ControlEnvelope | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* PAUSE short-circuit. When the session is paused, drain the inbox and refuse the action so the
|
|
36
|
+
* human's pause cannot be driven through. Returns undefined when the action may proceed.
|
|
37
|
+
*
|
|
38
|
+
* `drainInbox()` is the SOLE sink for guidance — draining here means the same message can never
|
|
39
|
+
* also surface in a piggyback, guaranteeing delivered-once.
|
|
40
|
+
*/
|
|
41
|
+
export declare function pausedShortCircuit(session: Session): PausedResult | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* PIGGYBACK. Spread a `control` block onto a result object whenever the session is non-active OR
|
|
44
|
+
* the inbox has messages (drained, so guidance is delivered exactly once). When the session is
|
|
45
|
+
* clean (active + empty) nothing is added, keeping the result shape unchanged.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withControl<T extends object>(session: Session, result: T): T & ControlSpread;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=control-envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-envelope.d.ts","sourceRoot":"","sources":["../../src/session/control-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,kGAAkG;AAClG,UAAU,eAAe;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,2GACmF,CAAC;AAE3G,oFAAoF;AACpF,UAAU,YAAY;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6FAA6F;AAC7F,KAAK,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAKlF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAG7E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,aAAa,CAG5F"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SessionState } from '@reticlehq/core';
|
|
2
|
+
/**
|
|
3
|
+
* Agent-readable hint returned when an action is refused mid-pause. Named, not free — the agent's
|
|
4
|
+
* recovery path (address the guidance, then reticle_resume) lives here in exactly one place.
|
|
5
|
+
*/
|
|
6
|
+
export const PAUSE_HINT = 'Paused by the human. Address the guidance, then call reticle_resume (or wait for the human to resume).';
|
|
7
|
+
/**
|
|
8
|
+
* Build the piggyback control block for the agent's next tool result.
|
|
9
|
+
*
|
|
10
|
+
* Returns `undefined` iff the session is a CLEAN active one (state === ACTIVE AND inbox empty) —
|
|
11
|
+
* i.e. there is nothing to tell the agent. Otherwise returns `{ state, guidance }`.
|
|
12
|
+
*
|
|
13
|
+
* DRAINS the inbox (the only read path) so a human message is delivered exactly once. Pure: it
|
|
14
|
+
* reads no clock, so the piggyback is deterministic and unit-testable without a fake clock.
|
|
15
|
+
*/
|
|
16
|
+
export function buildControlEnvelope(session) {
|
|
17
|
+
const state = session.getState();
|
|
18
|
+
const guidance = session.drainInbox().map((m) => m.text);
|
|
19
|
+
if (state === SessionState.ACTIVE && guidance.length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
return { state, guidance };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* PAUSE short-circuit. When the session is paused, drain the inbox and refuse the action so the
|
|
25
|
+
* human's pause cannot be driven through. Returns undefined when the action may proceed.
|
|
26
|
+
*
|
|
27
|
+
* `drainInbox()` is the SOLE sink for guidance — draining here means the same message can never
|
|
28
|
+
* also surface in a piggyback, guaranteeing delivered-once.
|
|
29
|
+
*/
|
|
30
|
+
export function pausedShortCircuit(session) {
|
|
31
|
+
if (session.getState() !== SessionState.PAUSED)
|
|
32
|
+
return undefined;
|
|
33
|
+
return { paused: true, guidance: session.drainInbox().map((m) => m.text), hint: PAUSE_HINT };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* PIGGYBACK. Spread a `control` block onto a result object whenever the session is non-active OR
|
|
37
|
+
* the inbox has messages (drained, so guidance is delivered exactly once). When the session is
|
|
38
|
+
* clean (active + empty) nothing is added, keeping the result shape unchanged.
|
|
39
|
+
*/
|
|
40
|
+
export function withControl(session, result) {
|
|
41
|
+
const control = buildControlEnvelope(session);
|
|
42
|
+
return control === undefined ? result : { ...result, control };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=control-envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-envelope.js","sourceRoot":"","sources":["../../src/session/control-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAU/C;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,wGAAwG,CAAC;AAY3G;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,YAAY,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACjE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC/F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAmB,OAAgB,EAAE,MAAS;IACvE,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolDef } from '../tools/tools.js';
|
|
2
|
+
/**
|
|
3
|
+
* Live-control agent tools: the agent's side of the human-in-the-loop control surface.
|
|
4
|
+
*
|
|
5
|
+
* - reticle_end_session: terminal stop. Sets state `ended` and syncs the panel (PRESENTER) with an
|
|
6
|
+
* optional summary. Idempotent — ending an already-ended session is a safe no-op.
|
|
7
|
+
* - reticle_resume: clears a human pause. Sets state `active` and syncs the panel.
|
|
8
|
+
* - reticle_messages: explicit poll — drains and returns the queued human notes.
|
|
9
|
+
*
|
|
10
|
+
* State changes go through `setState`, which echoes the state to the panel in a SINGLE PRESENTER
|
|
11
|
+
* push (optionally carrying human-facing text, e.g. the end summary) — a transition never emits two
|
|
12
|
+
* PRESENTER commands. No clock is read here — inbox stamps were assigned by the session's injected
|
|
13
|
+
* elapsed clock at enqueue time.
|
|
14
|
+
*/
|
|
15
|
+
export declare const LIVE_CONTROL_TOOLS: ToolDef[];
|
|
16
|
+
//# sourceMappingURL=live-control-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-control-tools.d.ts","sourceRoot":"","sources":["../../src/session/live-control-tools.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAejD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,EAuKvC,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AGENT_ASK_NOTICE, AGENT_WAITING_NOTICE, PresenterTone, SessionState, } from '@reticlehq/core';
|
|
3
|
+
import { ReticleTool } from '../tools/tool-names.js';
|
|
4
|
+
import { asNumber, asString } from '../tools/tools-helpers.js';
|
|
5
|
+
import { waitForReady, RETICLE_LOOP_GUIDE } from './session-readiness.js';
|
|
6
|
+
import { recoveryFor } from '../tools/error-recovery.js';
|
|
7
|
+
/** Default + ceiling for the readiness wait — keep it short so a truly-missing app fails fast. */
|
|
8
|
+
const WAIT_READY_DEFAULT_MS = 5000;
|
|
9
|
+
const WAIT_READY_MAX_MS = 30000;
|
|
10
|
+
const sessionIdShape = {
|
|
11
|
+
sessionId: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Active session ID from reticle_sessions. Omit when only one browser session is open.'),
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Live-control agent tools: the agent's side of the human-in-the-loop control surface.
|
|
18
|
+
*
|
|
19
|
+
* - reticle_end_session: terminal stop. Sets state `ended` and syncs the panel (PRESENTER) with an
|
|
20
|
+
* optional summary. Idempotent — ending an already-ended session is a safe no-op.
|
|
21
|
+
* - reticle_resume: clears a human pause. Sets state `active` and syncs the panel.
|
|
22
|
+
* - reticle_messages: explicit poll — drains and returns the queued human notes.
|
|
23
|
+
*
|
|
24
|
+
* State changes go through `setState`, which echoes the state to the panel in a SINGLE PRESENTER
|
|
25
|
+
* push (optionally carrying human-facing text, e.g. the end summary) — a transition never emits two
|
|
26
|
+
* PRESENTER commands. No clock is read here — inbox stamps were assigned by the session's injected
|
|
27
|
+
* elapsed clock at enqueue time.
|
|
28
|
+
*/
|
|
29
|
+
export const LIVE_CONTROL_TOOLS = [
|
|
30
|
+
{
|
|
31
|
+
name: ReticleTool.END_SESSION,
|
|
32
|
+
description: 'End this session for good — use ONLY when the whole task is complete. Sets state "ended" ' +
|
|
33
|
+
'(calm, terminal) and shows the optional `summary` on the panel. If you are just finishing a ' +
|
|
34
|
+
'turn or waiting on the human, call reticle_yield instead (revivable). Idempotent.',
|
|
35
|
+
inputSchema: { summary: z.string().optional(), ...sessionIdShape },
|
|
36
|
+
outputSchema: { ended: z.boolean(), sessionId: z.string() },
|
|
37
|
+
handler: (deps, args) => {
|
|
38
|
+
const session = deps.sessions.resolve(asString(args['sessionId']));
|
|
39
|
+
// One PRESENTER push for the transition; the optional summary rides the same push.
|
|
40
|
+
session.setState(SessionState.ENDED, asString(args['summary']));
|
|
41
|
+
return Promise.resolve({ ended: true, sessionId: session.id });
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: ReticleTool.YIELD,
|
|
46
|
+
description: 'MANDATORY before you stop driving and hand control back to the human — call this whenever you ' +
|
|
47
|
+
'finish a turn or need to wait on them, so the panel never falsely shows the agent as live. ' +
|
|
48
|
+
'mode:"waiting" = you are done responding and will continue on their next message. ' +
|
|
49
|
+
'mode:"ask" = you are blocked and need an answer first; put the question in `note` so it shows ' +
|
|
50
|
+
'on the panel. The session is REVIVED automatically on your next tool call, so you never need to ' +
|
|
51
|
+
'reopen it. Use reticle_end_session instead only when the whole task is truly complete.',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
mode: z
|
|
54
|
+
.enum([PresenterTone.WAITING, PresenterTone.ASK])
|
|
55
|
+
.describe('"waiting" = turn done, will resume; "ask" = blocked, need the human to answer.'),
|
|
56
|
+
note: z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe('For mode:"ask", the question to show the human on the panel.'),
|
|
60
|
+
...sessionIdShape,
|
|
61
|
+
},
|
|
62
|
+
outputSchema: { yielded: z.boolean(), mode: z.string(), sessionId: z.string() },
|
|
63
|
+
handler: (deps, args) => {
|
|
64
|
+
const session = deps.sessions.resolve(asString(args['sessionId']));
|
|
65
|
+
const ask = asString(args['mode']) === PresenterTone.ASK;
|
|
66
|
+
const note = asString(args['note']);
|
|
67
|
+
const tone = ask ? PresenterTone.ASK : PresenterTone.WAITING;
|
|
68
|
+
const text = ask && note !== undefined && note.trim().length > 0
|
|
69
|
+
? `${AGENT_ASK_NOTICE}: ${note.trim()}`
|
|
70
|
+
: ask
|
|
71
|
+
? AGENT_ASK_NOTICE
|
|
72
|
+
: AGENT_WAITING_NOTICE;
|
|
73
|
+
// autoEnd = revivable end: the panel reflects the handoff now, the agent's next call revives it.
|
|
74
|
+
session.autoEnd(text, tone);
|
|
75
|
+
return Promise.resolve({
|
|
76
|
+
yielded: true,
|
|
77
|
+
mode: ask ? PresenterTone.ASK : PresenterTone.WAITING,
|
|
78
|
+
sessionId: session.id,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: ReticleTool.RESUME,
|
|
84
|
+
description: 'Clear a human pause and resume driving the page. Sets state "active" and syncs the panel ' +
|
|
85
|
+
'(PRESENTER). Call after you have addressed the human guidance returned by a paused reticle_act.',
|
|
86
|
+
inputSchema: { ...sessionIdShape },
|
|
87
|
+
outputSchema: { ok: z.boolean() },
|
|
88
|
+
handler: (deps, args) => {
|
|
89
|
+
const session = deps.sessions.resolve(asString(args['sessionId']));
|
|
90
|
+
// setState echoes ACTIVE to the panel in a single PRESENTER push.
|
|
91
|
+
session.setState(SessionState.ACTIVE);
|
|
92
|
+
return Promise.resolve({ ok: true });
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: ReticleTool.MESSAGES,
|
|
97
|
+
description: 'Drain and return any messages the human queued from the panel since the last poll. Use to ' +
|
|
98
|
+
'explicitly check for human guidance without acting.',
|
|
99
|
+
inputSchema: { ...sessionIdShape },
|
|
100
|
+
outputSchema: { messages: z.array(z.unknown()) },
|
|
101
|
+
handler: (deps, args) => {
|
|
102
|
+
const session = deps.sessions.resolve(asString(args['sessionId']));
|
|
103
|
+
return Promise.resolve({ messages: session.drainInbox() });
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: ReticleTool.REVIEW,
|
|
108
|
+
description: 'List the mistakes the human pinned to elements on the running page (the "annotate the bug ' +
|
|
109
|
+
'where you see it" loop), then resolve each once you have fixed it. Each pending mark carries ' +
|
|
110
|
+
'the human note, the element label, and — when the framework stamped it — the source file:line ' +
|
|
111
|
+
'to open, plus a ready-to-act `fix` hint. After applying a fix, call again with ' +
|
|
112
|
+
'`{ resolve: "<id>" }` to retire that mark. Reading does NOT consume a mark, so you can list, ' +
|
|
113
|
+
'fix, verify, then resolve.',
|
|
114
|
+
inputSchema: {
|
|
115
|
+
resolve: z
|
|
116
|
+
.string()
|
|
117
|
+
.optional()
|
|
118
|
+
.describe('A mark id (e.g. "m1") to retire after you have fixed it. Omit to just list.'),
|
|
119
|
+
all: z
|
|
120
|
+
.boolean()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('Include already-resolved marks in the listing (default: pending only).'),
|
|
123
|
+
...sessionIdShape,
|
|
124
|
+
},
|
|
125
|
+
outputSchema: {
|
|
126
|
+
marks: z.array(z.unknown()),
|
|
127
|
+
pendingCount: z.number(),
|
|
128
|
+
resolved: z.boolean().optional(),
|
|
129
|
+
},
|
|
130
|
+
handler: (deps, args) => {
|
|
131
|
+
const session = deps.sessions.resolve(asString(args['sessionId']));
|
|
132
|
+
const resolveId = asString(args['resolve']);
|
|
133
|
+
let resolved;
|
|
134
|
+
if (resolveId !== undefined) {
|
|
135
|
+
// Grab the note BEFORE retiring it so we can close the loop visually for the human.
|
|
136
|
+
const mark = session.allMarks().find((m) => m.id === resolveId);
|
|
137
|
+
resolved = session.resolveMark(resolveId);
|
|
138
|
+
if (resolved && mark !== undefined) {
|
|
139
|
+
// The human watching the panel sees their flagged bug get marked fixed (fire-and-forget).
|
|
140
|
+
session.pushNarration(`✓ fixed: ${mark.note}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const source = args['all'] === true ? session.allMarks() : session.pendingMarks();
|
|
144
|
+
const marks = source.map((m) => ({ ...m, fix: buildFixHint(m) }));
|
|
145
|
+
const out = {
|
|
146
|
+
marks,
|
|
147
|
+
pendingCount: session.pendingMarkCount(),
|
|
148
|
+
};
|
|
149
|
+
if (resolved !== undefined)
|
|
150
|
+
out.resolved = resolved;
|
|
151
|
+
return Promise.resolve(out);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: ReticleTool.WAIT_READY,
|
|
156
|
+
description: 'Block until the app is connected, then continue — call this once right after init so your ' +
|
|
157
|
+
'first real tool call does not lose the race with the SDK connecting its WebSocket. Returns as ' +
|
|
158
|
+
'soon as a session exists (no latency if one already does), or after `timeoutMs` with a ' +
|
|
159
|
+
'recovery hint if none appears.',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
timeoutMs: z
|
|
162
|
+
.number()
|
|
163
|
+
.optional()
|
|
164
|
+
.describe('How long to wait for a session (ms). Default 5000, max 30000.'),
|
|
165
|
+
},
|
|
166
|
+
outputSchema: {
|
|
167
|
+
ready: z.boolean(),
|
|
168
|
+
sessionCount: z.number(),
|
|
169
|
+
loop: z.string().optional(),
|
|
170
|
+
recovery: z.string().optional(),
|
|
171
|
+
},
|
|
172
|
+
handler: async (deps, args) => {
|
|
173
|
+
const requested = asNumber(args['timeoutMs']) ?? WAIT_READY_DEFAULT_MS;
|
|
174
|
+
const timeoutMs = Math.max(0, Math.min(requested, WAIT_READY_MAX_MS));
|
|
175
|
+
const ready = await waitForReady({
|
|
176
|
+
count: () => deps.sessions.count(),
|
|
177
|
+
timeoutMs,
|
|
178
|
+
now: deps.now,
|
|
179
|
+
sleep: (ms) => new Promise((res) => setTimeout(res, ms)),
|
|
180
|
+
});
|
|
181
|
+
// The first response a fresh agent gets — carry the loop guide so it learns how to drive Reticle.
|
|
182
|
+
if (ready)
|
|
183
|
+
return { ready: true, sessionCount: deps.sessions.count(), loop: RETICLE_LOOP_GUIDE };
|
|
184
|
+
const recovery = recoveryFor('no browser session connected');
|
|
185
|
+
return recovery !== undefined
|
|
186
|
+
? { ready: false, sessionCount: 0, recovery }
|
|
187
|
+
: { ready: false, sessionCount: 0 };
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
/**
|
|
192
|
+
* The single actionable next-move for a pending mark: point the agent at the source (or the element
|
|
193
|
+
* label when no file:line was stamped), echo the human's note, and name the resolve call. Keeping
|
|
194
|
+
* the recovery hint here means the agent is never left guessing what to do with a mark.
|
|
195
|
+
*/
|
|
196
|
+
function buildFixHint(m) {
|
|
197
|
+
const where = m.source !== undefined
|
|
198
|
+
? `Open ${m.source.file}:${String(m.source.line)}`
|
|
199
|
+
: m.label !== undefined
|
|
200
|
+
? `Find the "${m.label}" element`
|
|
201
|
+
: 'Find the flagged element';
|
|
202
|
+
return `${where} and fix: ${m.note}. Then call reticle_review { resolve: "${m.id}" }.`;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=live-control-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-control-tools.js","sourceRoot":"","sources":["../../src/session/live-control-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,kGAAkG;AAClG,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,sFAAsF,CACvF;CACJ,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAc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AI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;aACzD,CAAC,CAAC;YACH,kGAAkG;YAClG,IAAI,KAAK;gBACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;YACxF,MAAM,QAAQ,GAAG,WAAW,CAAC,8BAA8B,CAAC,CAAC;YAC7D,OAAO,QAAQ,KAAK,SAAS;gBAC3B,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE;gBAC7C,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;QACxC,CAAC;KACF;CACF,CAAC;AAEF;;;;GAIG;AACH,SAAS,YAAY,CAAC,CAKrB;IACC,MAAM,KAAK,GACT,CAAC,CAAC,MAAM,KAAK,SAAS;QACpB,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAClD,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS;YACrB,CAAC,CAAC,aAAa,CAAC,CAAC,KAAK,WAAW;YACjC,CAAC,CAAC,0BAA0B,CAAC;IACnC,OAAO,GAAG,KAAK,aAAa,CAAC,CAAC,IAAI,0CAA0C,CAAC,CAAC,EAAE,MAAM,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReticleEvent } from '@reticlehq/core';
|
|
2
|
+
/**
|
|
3
|
+
* A self-budgeting hint returned on event-bearing tool results so the agent can decide whether to
|
|
4
|
+
* narrow its next call (the report flagged 60KB+ results as a real token tax). `bytes` is the JSON
|
|
5
|
+
* size of the payload; `droppedOldest` is present only when a cap actually truncated the timeline —
|
|
6
|
+
* never a silent cap.
|
|
7
|
+
*/
|
|
8
|
+
interface CostHint {
|
|
9
|
+
events: number;
|
|
10
|
+
bytes: number;
|
|
11
|
+
droppedOldest?: number;
|
|
12
|
+
/** Present when the timeline is large — tells the agent to scope its NEXT call (cut tokens). */
|
|
13
|
+
recommendation?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Keep only the most recent `maxEvents` events; report how many older ones were dropped. */
|
|
16
|
+
export declare function applyEventBudget(events: ReticleEvent[], maxEvents: number | undefined): {
|
|
17
|
+
events: ReticleEvent[];
|
|
18
|
+
droppedOldest: number;
|
|
19
|
+
};
|
|
20
|
+
/** Build a cost hint from a payload + the event count it carries. */
|
|
21
|
+
export declare function costHint(payload: unknown, events: number, droppedOldest?: number): CostHint;
|
|
22
|
+
export declare function estimateTokens(text: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* A size preview for non-event read results (snapshot, query). Same intent as CostHint but for
|
|
25
|
+
* payloads measured by size rather than event count: the agent can bail and re-scope (mode:status,
|
|
26
|
+
* a tighter scope, a more specific query) before spending context on a large body. The token
|
|
27
|
+
* figure is an estimate (see estimateTokens).
|
|
28
|
+
*/
|
|
29
|
+
interface SizeCost {
|
|
30
|
+
bytes: number;
|
|
31
|
+
tokens: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function sizeCost(payload: unknown): SizeCost;
|
|
34
|
+
/**
|
|
35
|
+
* Attach a `cost` size preview to a read result. Pure: the cost is computed over the result BEFORE
|
|
36
|
+
* the cost field is added (so it measures the body the agent will actually read), then merged in.
|
|
37
|
+
* Non-object results (e.g. a thrown-error envelope) pass through unchanged.
|
|
38
|
+
*/
|
|
39
|
+
export declare function withSizeCost<T>(result: T): T;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=output-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-budget.d.ts","sourceRoot":"","sources":["../../src/session/output-budget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;GAKG;AACH,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gGAAgG;IAChG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAWD,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,YAAY,EAAE,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B;IAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAQnD;AAED,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,SAAI,GAAG,QAAQ,CAQtF;AAUD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;GAKG;AACH,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAGnD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAG5C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Above this, a timeline is big enough that re-reading it unscoped is a real token tax. Observed
|
|
3
|
+
* live: a single login flooded 319 events / ~37KB because the dashboard's count-up animations emit
|
|
4
|
+
* a dom.text per frame — the agent only dodged the cost by knowing to pass filters. The hint now
|
|
5
|
+
* tells it.
|
|
6
|
+
*/
|
|
7
|
+
const LARGE_TIMELINE_EVENTS = 80;
|
|
8
|
+
const LARGE_TIMELINE_BYTES = 8000;
|
|
9
|
+
/** Keep only the most recent `maxEvents` events; report how many older ones were dropped. */
|
|
10
|
+
export function applyEventBudget(events, maxEvents) {
|
|
11
|
+
if (maxEvents === undefined || maxEvents < 0 || events.length <= maxEvents) {
|
|
12
|
+
return { events, droppedOldest: 0 };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
events: events.slice(events.length - maxEvents),
|
|
16
|
+
droppedOldest: events.length - maxEvents,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Build a cost hint from a payload + the event count it carries. */
|
|
20
|
+
export function costHint(payload, events, droppedOldest = 0) {
|
|
21
|
+
const json = JSON.stringify(payload) ?? '';
|
|
22
|
+
const bytes = json.length;
|
|
23
|
+
const base = droppedOldest > 0 ? { events, bytes, droppedOldest } : { events, bytes };
|
|
24
|
+
if (events >= LARGE_TIMELINE_EVENTS || bytes >= LARGE_TIMELINE_BYTES) {
|
|
25
|
+
base.recommendation = `large timeline (${String(events)} events, ~${String(estimateTokens(json))} tokens) — pass filters:[...] (e.g. ["signal","net"]) or max_events to scope your next call and cut tokens`;
|
|
26
|
+
}
|
|
27
|
+
return base;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Rough token estimate for a string. The exact count is model/tokenizer-specific, but ~4 characters
|
|
31
|
+
* per token is the well-known heuristic for English-ish text (and JSON) across GPT/Claude
|
|
32
|
+
* tokenizers — accurate enough for the only decision it drives: "is this response big enough that I
|
|
33
|
+
* should re-scope before reading it?" Deliberately a cheap, dependency-free approximation, NOT a
|
|
34
|
+
* billing-grade count.
|
|
35
|
+
*/
|
|
36
|
+
const CHARS_PER_TOKEN = 4;
|
|
37
|
+
export function estimateTokens(text) {
|
|
38
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
39
|
+
}
|
|
40
|
+
export function sizeCost(payload) {
|
|
41
|
+
const json = JSON.stringify(payload) ?? '';
|
|
42
|
+
return { bytes: json.length, tokens: estimateTokens(json) };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Attach a `cost` size preview to a read result. Pure: the cost is computed over the result BEFORE
|
|
46
|
+
* the cost field is added (so it measures the body the agent will actually read), then merged in.
|
|
47
|
+
* Non-object results (e.g. a thrown-error envelope) pass through unchanged.
|
|
48
|
+
*/
|
|
49
|
+
export function withSizeCost(result) {
|
|
50
|
+
if (typeof result !== 'object' || result === null)
|
|
51
|
+
return result;
|
|
52
|
+
return { ...result, cost: sizeCost(result) };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=output-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-budget.js","sourceRoot":"","sources":["../../src/session/output-budget.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAC9B,MAAsB,EACtB,SAA6B;IAE7B,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC3E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;IACtC,CAAC;IACD,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC/C,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,SAAS;KACzC,CAAC;AACJ,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,MAAc,EAAE,aAAa,GAAG,CAAC;IAC1E,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAa,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChG,IAAI,MAAM,IAAI,qBAAqB,IAAI,KAAK,IAAI,oBAAoB,EAAE,CAAC;QACrE,IAAI,CAAC,cAAc,GAAG,mBAAmB,MAAM,CAAC,MAAM,CAAC,aAAa,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,4GAA4G,CAAC;IAC/M,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC;AAClD,CAAC;AAaD,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAI,MAAS;IACvC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACjE,OAAO,EAAE,GAAI,MAAkC,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAO,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PresenterTone, SessionState } from '@reticlehq/core';
|
|
2
|
+
/**
|
|
3
|
+
* Build the args for a PRESENTER push. An ended session can carry a `tone` so the panel tells apart
|
|
4
|
+
* how the agent stopped — waiting (turn done), ask (needs you), warn (crashed) — from a calm "done".
|
|
5
|
+
* Tone only rides an ended push; live transitions (active/paused) never carry one. Pure.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildPresenterArgs(state: SessionState, text: string | undefined, tone: PresenterTone | undefined): Record<string, unknown>;
|
|
8
|
+
//# sourceMappingURL=presenter-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presenter-args.d.ts","sourceRoot":"","sources":["../../src/session/presenter-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI,EAAE,aAAa,GAAG,SAAS,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
|